aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/FormattedTextBox.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-04-24 09:22:41 -0400
committerbob <bcz@cs.brown.edu>2019-04-24 09:22:41 -0400
commit04b177406a98a52f4f8b3f94375f94db2f46a5df (patch)
tree26ef7703f0516657a66d47f1c6eff1d23b8267e8 /src/client/views/nodes/FormattedTextBox.tsx
parent27f505949ae47c3c5f83633115b9d238936d4003 (diff)
added simple text box titling
Diffstat (limited to 'src/client/views/nodes/FormattedTextBox.tsx')
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 56c21dbd3..91b44962d 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -166,6 +166,7 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
Document.SetOnPrototype(fieldKey, new RichTextField(e.target.value));
// doc.SetData(fieldKey, e.target.value, RichTextField);
}
+ @action
onPointerDown = (e: React.PointerEvent): void => {
if (e.button === 1 && this.props.isSelected() && !e.altKey && !e.ctrlKey && !e.metaKey) {
console.log("first");
@@ -251,7 +252,8 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
});
}
- onKeyPress(e: React.KeyboardEvent) {
+ @action
+ onKeyPress = (e: React.KeyboardEvent) => {
if (e.key == "Escape") {
SelectionManager.DeselectAll();
}
@@ -260,6 +262,11 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte
// stop propagation doesn't seem to stop propagation of native keyboard events.
// so we set a flag on the native event that marks that the event's been handled.
(e.nativeEvent as any).DASHFormattedTextBoxHandled = true;
+ if (this.props.Document.Title.startsWith("-") && this._editorView) {
+ let str = this._editorView.state.doc.textContent;
+ let titlestr = str.substr(0, Math.min(40, str.length));
+ this.props.Document.SetText(KeyStore.Title, "-" + titlestr + (str.length > 40 ? "..." : ""));
+ };
}
render() {
let style = this.props.isOverlay ? "scroll" : "hidden";