diff options
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextRules.ts')
-rw-r--r-- | src/client/views/nodes/formattedText/RichTextRules.ts | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts index 711136469..bafae84dc 100644 --- a/src/client/views/nodes/formattedText/RichTextRules.ts +++ b/src/client/views/nodes/formattedText/RichTextRules.ts @@ -34,13 +34,9 @@ export class RichTextRules { wrappingInputRule( /^1\.\s$/, schema.nodes.ordered_list, - () => { - return ({ mapStyle: "decimal", bulletStyle: 1 }); - }, - (match: any, node: any) => { - return node.childCount + node.attrs.order === +match[1]; - }, - (type: any) => ({ type: type, attrs: { mapStyle: "decimal", bulletStyle: 1 } }) + () => ({ mapStyle: "decimal", bulletStyle: 1 }), + (match: any, node: any) => node.childCount + node.attrs.order === +match[1], + ((type: any) => ({ type: type, attrs: { mapStyle: "decimal", bulletStyle: 1 } })) as any ), // A. create alphabetical ordered list @@ -55,20 +51,16 @@ export class RichTextRules { (match: any, node: any) => { return node.childCount + node.attrs.order === +match[1]; }, - (type: any) => ({ type: type, attrs: { mapStyle: "multi", bulletStyle: 1 } }) + ((type: any) => ({ type: type, attrs: { mapStyle: "multi", bulletStyle: 1 } })) as any ), // * + - create bullet list wrappingInputRule(/^\s*([-+*])\s$/, schema.nodes.ordered_list, // match => { - () => { - return ({ mapStyle: "bullet" }); - // return ({ order: +match[1] }) - }, - (match: any, node: any) => { - return node.childCount + node.attrs.order === +match[1]; - }, - (type: any) => ({ type: type, attrs: { mapStyle: "bullet" } })), + () => ({ mapStyle: "bullet" }), // ({ order: +match[1] }) + (match: any, node: any) => node.childCount + node.attrs.order === +match[1], + ((type: any) => ({ type: type, attrs: { mapStyle: "bullet" } })) as any + ), // ``` create code block textblockTypeInputRule(/^```$/, schema.nodes.code_block), @@ -221,7 +213,7 @@ export class RichTextRules { tr.deleteRange(start, end).replaceSelectionWith(newNode); // replace insertion with a footnote. return tr.setSelection(new NodeSelection( // select the footnote node to open its display tr.doc.resolve( // get the location of the footnote node by subtracting the nodesize of the footnote from the current insertion point anchor (which will be immediately after the footnote node) - tr.selection.anchor - tr.selection.$anchor.nodeBefore!.nodeSize))); + tr.selection.anchor - (tr.selection.$anchor.nodeBefore?.nodeSize || 0)))); }), // activate a style by name using prefix '%<color name>' |