diff options
| author | bobzel <zzzman@gmail.com> | 2024-03-29 10:29:21 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-03-29 10:29:21 -0400 |
| commit | ddaad0a2119dcb0dedf432aaff69abe5c92ac991 (patch) | |
| tree | 0b3d756eecbb936939f04b66c2c372bb6d26cdbc /src/client/views/nodes/formattedText/RichTextRules.ts | |
| parent | 0772ae0522be1fde19362ab7bb0808e13b4f382c (diff) | |
enabled %<notestyle> to switch note types. fixed linking to top-level templates (postit, idea, etc). customized postit and idea style.
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextRules.ts')
| -rw-r--r-- | src/client/views/nodes/formattedText/RichTextRules.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts index 418ec92ef..682d4f96f 100644 --- a/src/client/views/nodes/formattedText/RichTextRules.ts +++ b/src/client/views/nodes/formattedText/RichTextRules.ts @@ -1,6 +1,6 @@ import { ellipsis, emDash, InputRule, smartQuotes, textblockTypeInputRule } from 'prosemirror-inputrules'; import { NodeSelection, TextSelection } from 'prosemirror-state'; -import { Doc, FieldResult, StrListCast } from '../../../../fields/Doc'; +import { Doc, DocListCast, FieldResult, StrListCast } from '../../../../fields/Doc'; import { DocData } from '../../../../fields/DocSymbols'; import { Id } from '../../../../fields/FieldSymbols'; import { List } from '../../../../fields/List'; @@ -244,10 +244,18 @@ export class RichTextRules { }), // activate a style by name using prefix '%<color name>' - new InputRule(new RegExp(/%[a-z]+$/), (state, match, start, end) => { + new InputRule(new RegExp(/%[a-zA-Z_]+$/), (state, match, start, end) => { const color = match[0].substring(1, match[0].length); const marks = RichTextMenu.Instance._brushMap.get(color); + if ( + DocListCast((Doc.UserDoc().template_notes as Doc).data) + .map(d => StrCast(d.title)) + .includes(color) + ) { + setTimeout(() => this.TextBox.DocumentView?.().switchViews(true, color)); + return state.tr.deleteRange(start, end); + } if (marks) { const tr = state.tr.deleteRange(start, end); return marks ? Array.from(marks).reduce((tr, m) => tr.addStoredMark(m), tr) : tr; |
