Parchment
npm install --save parchmentBlots
class Blot {
static blotName: string;
static className: string;
static tagName: string;
static scope: Scope;
domNode: Node;
prev: Blot;
next: Blot;
parent: Blot;
// 创建相应的节点
static create(value?: any): Node;
constructor(domNode: Node, value?: any);
// 对于子集,是Blot的长度
// 对于父节点,是所有子节点的总和
length(): Number;
// 如果适用,按照给定的指数和长度进行操作
// 经常会把响应转移到合适的子节点上
deleteAt(index: number, length: number);
formatAt(index: number, length: number, format: string, value: any);
insertAt(index: number, text: string);
insertAt(index: number, embed: string, value: any);
// 返回当前Blot与父节点之间的偏移量
offset(ancestor: Blot = this.parent): number;
// 更新的生命周期之后调用。
// 不能修改文档的值和长度,并且任何DOM操作都必须降低DOM树的复杂性。
// 共享上下文对象被传递给所有的Blots。
optimize(context: {[key: string]: any}): void;
// 当Blot改变是调用,伴随着改变记录。
// blot的内部值能够被更新,并且允许修改Blot本身。
// 可以通过用户行为或者API调用触发。
// 共享上下文对象被传递给所有的Blots。
update(mutations: MutationRecord[], context: {[key: string]: any});
/** 仅对于作为子节点 **/
// 如果是Blot的类型,返回由domNode表示的值。
// 本身没有对domNode的类型进行校验,需要应用程序在调用之前进行外部校验。
static value(domNode): any;
// 给定一个node和一个在DOM选择范围内的偏移量,返回一个该位置的索引。
index(node: Node, offset: number): number;
// 给定一个Blot的位置信息坐标,返回当前节点在DOM可选范围的偏移量
position(index: number, inclusive: boolean): [Node, number];
// 返回当前Blot代表的值
// 除了来自于API或者通过update检测的用户改变,不应该被改变。
value(): any;
/** 仅对于作为父节点 **/
// Blots的白名单上数组,可以是直接的子节点
static allowedChildren: Blot[];
// 默认节点,当节点为空时会被插入
static defaultChild: string;
children: LinkedList<Blot>;
// 在构造时调用,应该填写子节点的LinkedList
build();
// 有用的后代搜索功能,不应该被修改
descendant(type: BlotClass, index: number, inclusive): Blot
descendents(type: BlotClass, index: number, length: number): Blot[];
/** 仅对于作为格式表 **/
// 如果是Blot的类型,返回domNode的格式化后的值
// 不需要检查domNode是否为Blot的类型
static formats(domNode: Node);
// Blot应用格式。不应该传递个子节点或者其他Blot
format(format: name, value: any);
// 返回格式代表的Blot,包括来自于Attributors的。
formats(): Object;
}Example
Block Blot
Inline Blot
Embed Blot
Scroll
Attributors
Attributor
Class Attributor
Style Attributor
Registry
Last updated