aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-08-21 05:30:39 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-08-21 05:30:39 -0400
commit654db73e0615e77f7206128b6e5524553d653c66 (patch)
tree0f4b968e1b4718d41b42bdf34739a135e982f092
parentd260d9abc13ae60c3206c3110f2d7f23ceeb2449 (diff)
cleanup
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx57
1 files changed, 24 insertions, 33 deletions
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 222ebed8f..a2ea12ac5 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -268,12 +268,32 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
}
}
+ recordKeyHandler = (e: KeyboardEvent) => {
+ if (this.props.Document !== SelectionManager.SelectedDocuments()[0].props.Document) {
+ return;
+ }
+ e.stopPropagation();
+ e.preventDefault();
+ e.which === 174 && e.altKey && this.recordBullet();
+ }
+
+ recordBullet = async () => {
+ let completedCue = "end session";
+ let results = await DictationManager.Controls.listen({
+ interimHandler: this.setCurrentBulletContent,
+ continuous: { indefinite: false },
+ terminators: [completedCue, "bullet", "next"]
+ });
+ if (results && [DictationManager.Controls.Infringed, completedCue].includes(results)) {
+ DictationManager.Controls.stop();
+ return;
+ }
+ this.nextBullet(this._editorView!.state.selection.to);
+ setTimeout(this.recordBullet, 2000);
+ }
+
setCurrentBulletContent = (value: string) => {
if (this._editorView) {
- // let next = value.endsWith("bullet");
- // if (next) {
- // value = value.split("bullet")[0];
- // }
let state = this._editorView.state;
let from = state.selection.from;
let to = state.selection.to;
@@ -281,15 +301,11 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
state = this._editorView.state;
let updated = TextSelection.create(state.doc, from, from + value.length);
this._editorView.dispatch(state.tr.setSelection(updated));
- // if (next) {
- // this.nextBullet(this._editorView.state.selection.to);
- // }
}
}
nextBullet = (pos: number) => {
if (this._editorView) {
- // DictationManager.Controls.stop(false);
let frag = Fragment.fromArray(this.newListItems(2));
let slice = new Slice(frag, 2, 2);
let state = this._editorView.state;
@@ -297,7 +313,6 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
pos += 4;
state = this._editorView.state;
this._editorView.dispatch(state.tr.setSelection(TextSelection.create(this._editorView.state.doc, pos, pos)));
- // this.recordSession();
}
}
@@ -309,30 +324,6 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
return listItems;
}
- recordSession = async () => {
- let completedCue = "end session";
- let results = await DictationManager.Controls.listen({
- interimHandler: this.setCurrentBulletContent,
- continuous: { indefinite: false },
- terminators: [completedCue, "bullet", "next"]
- });
- if (results && [DictationManager.Controls.Infringed, completedCue].includes(results)) {
- DictationManager.Controls.stop();
- return;
- }
- this.nextBullet(this._editorView!.state.selection.to);
- setTimeout(this.recordSession, 2000);
- }
-
- recordKeyHandler = (e: KeyboardEvent) => {
- if (this.props.Document !== SelectionManager.SelectedDocuments()[0].props.Document) {
- return;
- }
- e.stopPropagation();
- e.preventDefault();
- e.which === 174 && e.altKey && this.recordSession();
- }
-
componentDidMount() {
const config = {
schema,