From 66f2b03283a1e42c48b1c16b4344b730c0a2e9f3 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 11 Oct 2024 14:19:35 -0400
Subject: cleaned up comparisonBox a bit - fixed text doc placeholder text and
 fixed parsing keyword/question/answer from flashcard creator.  also fixed
 text boxes within in comparisonBox

---
 src/client/views/nodes/formattedText/FormattedTextBox.tsx | 9 +++++++++
 1 file changed, 9 insertions(+)

(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 c57307974..bf19a2f82 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -360,6 +360,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
                         // if no template, or there's text that didn't come from the layout template, write it to the document. (if this is driven by a template, then this overwrites the template text which is intended)
                         if (force || ((this._finishingLink || this._props.isContentActive() || this._inDrop) && (textChange || removeSelection(newJson) !== removeSelection(prevData?.Data)))) {
                             textChange && (dataDoc[this.fieldKey + '_modificationDate'] = new DateField(new Date(Date.now())));
+                            textChange && (dataDoc[this.fieldKey + '_placeholder'] = undefined);
                             const numstring = NumCast(dataDoc[this.fieldKey], null);
                             dataDoc[this.fieldKey] =
                                 numstring !== undefined ? Number(newText) : newText || (DocCast(dataDoc.proto)?.[this.fieldKey] === undefined && this.layoutDoc[this.fieldKey] === undefined) ? new RichTextField(newJson, newText) : undefined;
@@ -1330,6 +1331,14 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
         this._disposers.selected = reaction(
             () => this._props.rootSelected?.() || this._props.isContentActive(),
             action(selected => {
+                if (selected && this.dataDoc[this.fieldKey + '_placeholder']) {
+                    setTimeout(() => {
+                        selectAll(this._editorView!.state, (tx: Transaction) => {
+                            this._editorView?.dispatch(tx);
+                            this._editorView!.focus();
+                        });
+                    });
+                }
                 this.prepareForTyping();
                 if (FormattedTextBox._globalHighlights.has('Bold Text')) {
                     this.layoutDoc[DocCss] = this.layoutDoc[DocCss] + 1; // css change happens outside of mobx/react, so this will notify anyone interested in the layout that it has changed
-- 
cgit v1.2.3-70-g09d2

