aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/RichTextRules.ts
diff options
context:
space:
mode:
authorNaafiyan Ahmed <naafiyan@gmail.com>2022-03-17 16:35:32 -0400
committerNaafiyan Ahmed <naafiyan@gmail.com>2022-03-17 16:35:32 -0400
commitcb5f0847b098d89a1390acf90579b3c7fbc5ac3e (patch)
tree0266608b61495b5903ff419fa26e04fb5fbeef0a /src/client/views/nodes/formattedText/RichTextRules.ts
parentf1f341b53a1a49427cf7ef40afdcd95a9b0e4e9d (diff)
parent5c874c6829d9957696dfe61014173b6800c864df (diff)
Merge branch 'naafi-linking' of https://github.com/brown-dash/Dash-Web into naafi-linking
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextRules.ts')
-rw-r--r--src/client/views/nodes/formattedText/RichTextRules.ts26
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>'