aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-12-03 20:14:32 -0500
committerSam Wilkins <samwilkins333@gmail.com>2019-12-03 20:14:32 -0500
commita9997d9148325b68f6335c0401cd92414dd29081 (patch)
tree1a53022982b3f408ce7249114ec94b70e7cc631b /src
parent018514e53f3d079780f5a9e559e75820af756975 (diff)
parentd8b3a6fc2cc6cf15680de82cc512ef5e392bd375 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src')
-rw-r--r--src/client/util/RichTextRules.ts8
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx5
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();