diff options
-rw-r--r-- | src/client/views/nodes/formattedText/DailyJournal.tsx | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/client/views/nodes/formattedText/DailyJournal.tsx b/src/client/views/nodes/formattedText/DailyJournal.tsx index fc7290988..ae5582ef7 100644 --- a/src/client/views/nodes/formattedText/DailyJournal.tsx +++ b/src/client/views/nodes/formattedText/DailyJournal.tsx @@ -20,6 +20,8 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() @observable isLoadingPrompts: boolean = false; // track if prompts are loading @observable showPromptMenu = false; @observable inlinePromptsEnabled = true; + @observable askPromptsEnabled = true; + _ref = React.createRef<FormattedTextBox>(); // reference to the formatted textbox @@ -105,6 +107,13 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() @action.bound toggleInlinePrompts() { this.inlinePromptsEnabled = !this.inlinePromptsEnabled; } + + /** + * Method to toggle on/off inline /ask prompts + */ + @action.bound toggleAskPrompts() { + this.askPromptsEnabled = !this.askPromptsEnabled; + } /** * Method to handle click on document (to close prompt menu) @@ -164,7 +173,7 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() // characters before cursor const triggerText = state.doc.textBetween(Math.max(0, cursorPos - 4), cursorPos); - if (triggerText === '/ask') { + if (triggerText === '/ask' && this.askPromptsEnabled) { // remove /ask text const tr = state.tr.delete(cursorPos - 4, cursorPos); editorView.dispatch(tr); @@ -187,7 +196,6 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() */ @action insertPredictiveQuestion = async () => { - // if (!this.inlinePromptsEnabled) return; const editorView = this._ref.current?.EditorView; if (!editorView) return; @@ -470,6 +478,34 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() width: '100%', }} > + /ask + <input + type="checkbox" + checked={this.askPromptsEnabled} + onChange={this.toggleAskPrompts} + style={{ margin: 0 }} + /> + </label> + </div> + + <div + style={{ + display: 'flex', + justifyContent: 'flex-end', + alignItems: 'center', + marginBottom: '10px', + }} + > + <label + style={{ + display: 'flex', + alignItems: 'center', + gap: '6px', + fontSize: '14px', + justifyContent: 'flex-end', + width: '100%', + }} + > Inline Prompting <input type="checkbox" @@ -478,7 +514,6 @@ export class DailyJournal extends ViewBoxAnnotatableComponent<FieldViewProps>() style={{ margin: 0 }} /> </label> - </div> <button |