diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2019-12-03 18:50:08 -0500 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2019-12-03 18:50:08 -0500 |
commit | d8b3a6fc2cc6cf15680de82cc512ef5e392bd375 (patch) | |
tree | 97586715c91fcef195d6cfb7633ee8cc897b3647 /src | |
parent | 213962406327cc2f7267064f3016fabf0fd16872 (diff) |
fixed text higlighing
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/RichTextRules.ts | 8 | ||||
-rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts index bf365579a..cef1011cc 100644 --- a/src/client/util/RichTextRules.ts +++ b/src/client/util/RichTextRules.ts @@ -72,28 +72,28 @@ export const inpRules = { return state.tr.deleteRange(start, end).addStoredMark(schema.marks.pFontSize.create({ fontSize: size })); }), new InputRule( - new RegExp(/t/), + new RegExp(/t$/), (state, match, start, end) => { if (state.selection.to === state.selection.from) return null; const node = (state.doc.resolve(start) as any).nodeAfter; return node ? state.tr.addMark(start, end, schema.marks.user_tag.create({ userid: Doc.CurrentUserEmail, tag: "todo", modified: Math.round(Date.now() / 1000 / 60) })) : state.tr; }), new InputRule( - new RegExp(/i/), + new RegExp(/i$/), (state, match, start, end) => { if (state.selection.to === state.selection.from) return null; const node = (state.doc.resolve(start) as any).nodeAfter; return node ? state.tr.addMark(start, end, schema.marks.user_tag.create({ userid: Doc.CurrentUserEmail, tag: "ignore", modified: Math.round(Date.now() / 1000 / 60) })) : state.tr; }), new InputRule( - new RegExp(/\!/), + new RegExp(/!$/), (state, match, start, end) => { if (state.selection.to === state.selection.from) return null; const node = (state.doc.resolve(start) as any).nodeAfter; return node ? state.tr.addMark(start, end, schema.marks.user_tag.create({ userid: Doc.CurrentUserEmail, tag: "important", modified: Math.round(Date.now() / 1000 / 60) })) : state.tr; }), new InputRule( - new RegExp(/\x/), + new RegExp(/x$/), (state, match, start, end) => { if (state.selection.to === state.selection.from) return null; const node = (state.doc.resolve(start) as any).nodeAfter; diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index f9b246c10..fcd8b6202 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -142,6 +142,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps & constructor(props: any) { super(props); FormattedTextBox.Instance = this; + this.updateHighlights(); } public get CurrentDiv(): HTMLDivElement { return this._ref.current!; } @@ -191,6 +192,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps & } const state = this._editorView.state.apply(tx); this._editorView.updateState(state); + (tx.storedMarks && !this._editorView.state.storedMarks) && (this._editorView.state.storedMarks = tx.storedMarks); const tsel = this._editorView.state.selection.$from; tsel.marks().filter(m => m.type === this._editorView!.state.schema.marks.user_mark).map(m => AudioBox.SetScrubTime(Math.max(0, m.attrs.modified * 5000 - 1000))); @@ -328,7 +330,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps & } return ret; } - static _highlights: string[] = []; + static _highlights: string[] = ["Text from Others", "Todo Items", "Important Items", "Disagree Items", "Ignore Items"]; updateHighlights = () => { clearStyleSheetRules(FormattedTextBox._userStyleSheet); @@ -370,6 +372,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps & document.addEventListener("pointermove", this.sidebarMove); document.addEventListener("pointerup", this.sidebarUp); e.stopPropagation(); + e.preventDefault(); // prevents text from being selected during drag } sidebarMove = (e: PointerEvent) => { let bounds = this.CurrentDiv.getBoundingClientRect(); |