aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/FormattedTextBox.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-09-06 11:37:59 -0400
committerbob <bcz@cs.brown.edu>2019-09-06 11:37:59 -0400
commit2707e0898d535cc143272b7bf3b80f829368c097 (patch)
treec8fc8e37ee160a72673cf999c56642f1750ac043 /src/client/views/nodes/FormattedTextBox.tsx
parenteb05b987d7a1b2ca2e50268a0c15f2de7d44c5bd (diff)
added metadata ui for text
Diffstat (limited to 'src/client/views/nodes/FormattedTextBox.tsx')
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 8d3286d71..c09e88592 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -173,6 +173,16 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
if (state.selection.empty && FormattedTextBox._toolTipTextMenu && tx.storedMarks) {
FormattedTextBox._toolTipTextMenu.mark_key_pressed(tx.storedMarks);
}
+
+ let metadata = this._editorView!.state.selection.$from.marks().find((m: Mark) => m.type === schema.marks.metadata);
+ if (metadata) {
+ let range = this._editorView!.state.selection.$from.blockRange(this._editorView!.state.selection.$to);
+ let text = range ? this._editorView!.state.doc.textBetween(range.start, range.end) : "";
+ let key = text.split("::")[0];
+ let value = text.split("::")[text.split("::").length - 1];
+ this.dataDoc[key] = value;
+ }
+
this._keymap["ACTIVE"] = true; // hack to ignore an initial carriage return when creating a textbox from the action menu
this._applyingChange = true;
@@ -787,7 +797,6 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
if (e.key === "Tab" || e.key === "Enter") {
e.preventDefault();
}
-
this._editorView!.state.tr.addStoredMark(schema.marks.user_mark.create({ userid: Doc.CurrentUserEmail, modified: timenow() }));
this.updateTitle();