本文整理匯總了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({})
})