diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-12-10 20:03:07 -0500 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-12-10 20:03:07 -0500 |
commit | c17b200f6d0cb136851b798f280aba9b3862c337 (patch) | |
tree | ff517440354dfafe650a9f6542a32e7e2d161eb3 /src/client/util/RichTextRules.ts | |
parent | 853fbfb7a76cc81c2b4f47e094be159263c88a7a (diff) | |
parent | ca70b29bbb1818764b98196f8c28a1255a17965c (diff) |
Merge branches 'master' and 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/util/RichTextRules.ts')
-rw-r--r-- | src/client/util/RichTextRules.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts index 5f2d67a3e..94bfc5ef2 100644 --- a/src/client/util/RichTextRules.ts +++ b/src/client/util/RichTextRules.ts @@ -143,6 +143,20 @@ export const inpRules = { return null; }), new InputRule( + new RegExp(/q$/), + (state, match, start, end) => { + if (state.selection.to === state.selection.from) return null; + const pos = (state.doc.resolve(start) as any); + let depth = pos.path.length / 3 - 1; + for (; depth >= 0; depth--) { + if (pos.node(depth).type === schema.nodes.paragraph) { + const replaced = state.tr.setNodeMarkup(pos.pos - pos.parentOffset - 1, pos.node(depth).type, { ...pos.node(depth).attrs, inset: 30 }); + return replaced.setSelection(new TextSelection(replaced.doc.resolve(end - 2))); + } + } + return null; + }), + new InputRule( new RegExp(/!$/), (state, match, start, end) => { if (state.selection.to === state.selection.from && !(state as any).EnteringStyle) return null; |