diff options
author | bobzel <zzzman@gmail.com> | 2022-10-07 15:03:16 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2022-10-07 15:03:16 -0400 |
commit | 0e41cb323c486b23c70e53d14a563adaf0eeef9e (patch) | |
tree | 3cc353c16996c58709cdf5ec8ca8fbe88fe6bb89 /src/client/views/nodes/formattedText/RichTextRules.ts | |
parent | 69eb6d5514c36bd7065d2702cb2fb71e62c039ff (diff) |
fixes for equations : :eq as option to ctrl-m inside a text box. added background for equations. fixed cursor focus issues.
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextRules.ts')
-rw-r--r-- | src/client/views/nodes/formattedText/RichTextRules.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts index 2eb62c38d..7ddd1a2c4 100644 --- a/src/client/views/nodes/formattedText/RichTextRules.ts +++ b/src/client/views/nodes/formattedText/RichTextRules.ts @@ -295,6 +295,15 @@ export class RichTextRules { return state.tr; }), + // create an inline equation node + // eq:<equation>> + new InputRule(new RegExp(/:eq([a-zA-Z-0-9\(\)]*)$/), (state, match, start, end) => { + const fieldKey = 'math' + Utils.GenerateGuid(); + this.TextBox.dataDoc[fieldKey] = match[1]; + const tr = state.tr.setSelection(new TextSelection(state.tr.doc.resolve(end - 3), state.tr.doc.resolve(end))).replaceSelectionWith(schema.nodes.equation.create({ fieldKey })); + return tr.setSelection(new NodeSelection(tr.doc.resolve(tr.selection.$from.pos - 1))); + }), + // create an inline view of a document {{ <layoutKey> : <Doc> }} // {{:Doc}} => show default view of document // {{<layout>}} => show layout for this doc |