本文整理汇总了TypeScript中slate.Block类的典型用法代码示例。如果您正苦于以下问题:TypeScript Block类的具体用法?TypeScript Block怎么用?TypeScript Block使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Block类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
normalize: (editor: Editor, { code, node }: any) => {
switch (code) {
case 'last_child_type_invalid': {
const paragraph = Block.create('paragraph');
return editor.insertNodeByKey(node.key, node.nodes.size, paragraph);
}
}
},
示例2:
export const makeFragment = (text: string, syntax?: string) => {
const lines = text.split('\n').map(line =>
Block.create({
type: 'code_line',
nodes: [Text.create(line)],
})
);
const block = Block.create({
data: {
syntax,
},
type: 'code_block',
nodes: lines,
});
return Document.create({
nodes: [block],
});
};
示例3:
mark: Mark.create({type: 'test_mark'}),
data: Data.create({})
})
.applyOperation({
type: "set_mark",
path: 'a',
offset: 0,
length: 1,
properties: {type: 'test_mark'},
newProperties: {type: 'new_test_mark'},
data: Data.create({})
})
.applyOperation({
type: "insert_node",
path: 'a',
node: Block.create({type: 'block'}),
data: Data.create({})
})
.applyOperation({
type: "merge_node",
path: 'a',
position: 0,
properties: {type: 'node'},
data: Data.create({})
})
.applyOperation({
type: "move_node",
path: 'a',
newPath: 'a',
data: Data.create({})
})