aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/RichTextMenu.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-02-12 12:54:53 -0500
committerbobzel <zzzman@gmail.com>2025-02-12 12:54:53 -0500
commit5d738b4fe832ef1c554448440ede237c32632d10 (patch)
treee2e7a4eabe4472dca1bc4144f41491c36a0138cd /src/client/views/nodes/formattedText/RichTextMenu.tsx
parent3e531aa898492cb05e25081f422bb59adab72e8e (diff)
cleaning up how text boxes maintain focus when UI widgets are interacted with.
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextMenu.tsx')
-rw-r--r--src/client/views/nodes/formattedText/RichTextMenu.tsx13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx
index 09994a889..758b4035e 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -367,20 +367,19 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
setFontField = (value: string, fontField: 'fitBox' | 'fontSize' | 'fontFamily' | 'fontColor' | 'fontHighlight') => {
if (this.TextView && this.view && fontField !== 'fitBox') {
- if (!this.TextView.IsFocused) {
+ if (this.view.hasFocus()) {
+ const attrs: { [key: string]: string } = {};
+ attrs[fontField] = value;
+ const fmark = this.view.state.schema.marks['pF' + fontField.substring(1)].create(attrs);
+ this.setMark(fmark, this.view.state, (tx: Transaction) => this.view?.dispatch(tx.addStoredMark(fmark)), true);
+ } else {
Array.from(new Set([...DocumentView.Selected(), this.TextView.DocumentView?.()]))
.filter(v => v?.ComponentView instanceof FormattedTextBox && v.ComponentView.EditorView?.TextView)
.map(v => v!.ComponentView as FormattedTextBox)
.forEach(view => {
view.EditorView!.TextView!.dataDoc[(view.EditorView!.TextView!.fieldKey ?? 'text') + `_${fontField}`] = value;
});
- this.view.focus();
}
- const attrs: { [key: string]: string } = {};
- attrs[fontField] = value;
- const fmark = this.view?.state.schema.marks['pF' + fontField.substring(1)].create(attrs);
- this.setMark(fmark, this.view.state, (tx: Transaction) => this.view!.dispatch(tx.addStoredMark(fmark)), true);
- this.view.focus();
} else if (this.dataDoc) {
this.dataDoc[`${Doc.LayoutFieldKey(this.dataDoc)}_${fontField}`] = value;
this.updateMenu(undefined, undefined, undefined, this.dataDoc);