diff options
| author | bobzel <zzzman@gmail.com> | 2024-03-21 17:34:23 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-03-21 17:34:23 -0400 |
| commit | 2b9c89e54c19a53f0e1978850e8d05ac31186e21 (patch) | |
| tree | e4f8f1910f147743d25601597f815cbd302e6301 /src/client/views/nodes/formattedText/RichTextRules.ts | |
| parent | a974aa4e6573c8becf93f78610406747fec14c1c (diff) | |
changed gpt calls from text box to package result into an elision node.
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextRules.ts')
| -rw-r--r-- | src/client/views/nodes/formattedText/RichTextRules.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts index b97141e92..adc031636 100644 --- a/src/client/views/nodes/formattedText/RichTextRules.ts +++ b/src/client/views/nodes/formattedText/RichTextRules.ts @@ -354,10 +354,15 @@ export class RichTextRules { { inCode: true } ), - new InputRule(new RegExp(/(^|[^=])(\(\(.*\)\))/), (state, match, start, end) => { + // pass the contents between '((' and '))' to chatGPT and append the result + new InputRule(new RegExp(/(^|[^=])(\(\(.*\)\))$/), (state, match, start, end) => { var count = 0; // ignore first return value which will be the notation that chat is pending a result KeyValueBox.SetField(this.Document, '', match[2], false, (gptval: FieldResult) => { - count && this.TextBox.EditorView?.dispatch(this.TextBox.EditorView!.state.tr.insertText(' ' + (gptval as string))); + if (count) { + const tr = this.TextBox.EditorView?.state.tr.insertText(' ' + (gptval as string)); + tr && this.TextBox.EditorView?.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(end + 2), tr.doc.resolve(end + 2 + (gptval as string).length)))); + RichTextMenu.Instance.elideSelection(this.TextBox.EditorView?.state, true); + } count++; }); return null; |
