From 3e531aa898492cb05e25081f422bb59adab72e8e Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 11 Feb 2025 16:03:29 -0500 Subject: enabled multi-select modification of text documents from topBar buttons. fixed diagram box layout and scrolling. fixed problem with createDoc tool where it would fail when it got an array. fixed formatting of chat box errors. --- src/client/views/nodes/formattedText/FormattedTextBox.tsx | 13 +++++++++++++ src/client/views/nodes/formattedText/RichTextMenu.tsx | 12 ++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/client/views/nodes/formattedText') diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index 55ad543ca..a6870d65b 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -1694,8 +1694,11 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent this.EditorView?.dispatch(this.EditorView.state.tr.setSelection(TextSelection.near(this.EditorView.state.doc.resolve(pos)))), 100); setTimeout(() => (this.ProseRef?.children?.[0] as HTMLElement).focus(), 200); }; + + IsFocused = false; @action onFocused = (e: React.FocusEvent): void => { + this.IsFocused = true; // applyDevTools.applyDevTools(this.EditorView); e.stopPropagation(); }; @@ -1779,6 +1782,16 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent { + let ele: HTMLElement | null = e.relatedTarget instanceof HTMLElement ? e.relatedTarget : null; + if (ele?.tabIndex === -1) { + for (; ele; ele = ele?.parentElement) { + if (ele?.className === 'fonticonbox') { + setTimeout(() => this._ref.current?.focus()); + break; + } + } + } + if (ele?.className !== 'fonticonbox') this.IsFocused = false; if (this.ProseRef?.children[0] !== e.nativeEvent.target) return; if (!(this.EditorView?.state.selection instanceof NodeSelection) || this.EditorView.state.selection.node.type !== this.EditorView.state.schema.nodes.footnote) { const stordMarks = this.EditorView?.state.storedMarks?.slice(); diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx index c0acbe36f..09994a889 100644 --- a/src/client/views/nodes/formattedText/RichTextMenu.tsx +++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx @@ -180,6 +180,7 @@ export class RichTextMenu extends AntimodeMenu { } } } + this.setActiveMarkButtons(this.getActiveMarksOnSelection()); }; // finds font sizes and families in selection @@ -366,10 +367,13 @@ export class RichTextMenu extends AntimodeMenu { setFontField = (value: string, fontField: 'fitBox' | 'fontSize' | 'fontFamily' | 'fontColor' | 'fontHighlight') => { if (this.TextView && this.view && fontField !== 'fitBox') { - const { text, paragraph } = this.view.state.schema.nodes; - const selNode = this.view.state.selection.$anchor.node(); - if (this.view.state.selection.from === 1 && this.view.state.selection.empty && [undefined, text, paragraph].includes(selNode?.type)) { - this.TextView.dataDoc[this.TextView.fieldKey + `_${fontField}`] = value; + if (!this.TextView.IsFocused) { + 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 } = {}; -- cgit v1.2.3-70-g09d2