diff options
Diffstat (limited to 'src/client/views/nodes/formattedText')
| -rw-r--r-- | src/client/views/nodes/formattedText/FormattedTextBox.tsx | 13 | ||||
| -rw-r--r-- | src/client/views/nodes/formattedText/RichTextMenu.tsx | 12 |
2 files changed, 21 insertions, 4 deletions
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<FormattedTextB setTimeout(() => 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<FormattedTextB @action onBlur = (e: React.FocusEvent) => { + 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<AntimodeMenuProps> { } } } + this.setActiveMarkButtons(this.getActiveMarksOnSelection()); }; // finds font sizes and families in selection @@ -366,10 +367,13 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> { 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 } = {}; |
