From 75e76f1ec098ea9cbcd76432002da1bb73d74eba Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 10 Apr 2025 14:44:07 -0400
Subject: fixed removing predictive prompt.  fixed first letter typed after
 predictive prompt

---
 .../views/nodes/formattedText/FormattedTextBox.tsx    | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

(limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')

diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index a45b8a488..bef999e6d 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -78,7 +78,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
     public static LayoutString(fieldStr: string) {
         return FieldView.LayoutString(FormattedTextBox, fieldStr);
     }
-    public static MakeConfig(rules?: RichTextRules, textBox?: FormattedTextBox) {
+    public static MakeConfig(rules?: RichTextRules, textBox?: FormattedTextBox, plugs?: Plugin[]) {
         return {
             schema,
             plugins: [
@@ -89,6 +89,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
                 keymap(baseKeymap),
                 new Plugin({ props: { attributes: { class: 'ProseMirror-example-setup-style' } } }),
                 new Plugin({ view: () => new FormattedTextBoxComment() }),
+                ...(plugs ?? []),
             ],
         };
     }
@@ -140,6 +141,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
     public ApplyingChange: string = '';
 
     @observable _showSidebar = false;
+    @observable _userPlugins: Plugin[] = [];
 
     @computed get fontColor()      { return this._props.styleProvider?.(this.dataDoc, this._props, StyleProp.FontColor) as string; } // prettier-ignore
     @computed get fontSize()       { return this._props.styleProvider?.(this.dataDoc, this._props, StyleProp.FontSize) as string; } // prettier-ignore
@@ -153,7 +155,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
     }
 
     // eslint-disable-next-line no-return-assign
-    @computed get config()                     { return FormattedTextBox.MakeConfig(this._rules = new RichTextRules(this.Document, this), this); } // prettier-ignore
+    @computed get config()                     { return FormattedTextBox.MakeConfig(this._rules = new RichTextRules(this.Document, this), this, this._userPlugins ?? []); } // prettier-ignore
     @computed get recordingDictation()         { return this.dataDoc?.mediaState === mediaState.Recording; } // prettier-ignore
     @computed get SidebarShown()               { return !!(this._showSidebar || this.layoutDoc._layout_showSidebar);  } // prettier-ignore
     @computed get allSidebarDocs()             { return DocListCast(this.dataDoc[this.sidebarKey]); } // prettier-ignore
@@ -1224,6 +1226,17 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
         if (nh) this.layoutDoc._nativeHeight = scrollHeight;
     };
 
+    addPlugin = (plugin: Plugin) => {
+        const editorView = this.EditorView;
+        if (editorView) {
+            this._userPlugins.push(plugin);
+            const newState = editorView.state.reconfigure({
+                plugins: [...editorView.state.plugins, plugin],
+            });
+            editorView.updateState(newState);
+        }
+    };
+
     @computed get tagsHeight() {
         return this.DocumentView?.().showTags ? Math.max(0, 20 - Math.max(this._props.yPadding ?? 0, NumCast(this.layoutDoc._yMargin))) * this.ScreenToLocalBoxXf().Scale : 0;
     }
@@ -1403,7 +1416,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
                 } else if (!separated && node.isBlock) {
                     text += '\n';
                     separated = true;
-                } else if (node.type.name === 'hard_break') {
+                } else if (node.type.name === schema.nodes.hard_break.name) {
                     text += '\n';
                 }
             },
-- 
cgit v1.2.3-70-g09d2

