aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/FormattedTextBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-11-29 19:48:32 -0500
committerbobzel <zzzman@gmail.com>2023-11-29 19:48:32 -0500
commit48b0153d814cddad71caa8103e7ff4c761b66eaa (patch)
tree790d98e927f9d16f588d6ee3d0d1d4849ea79b3e /src/client/views/nodes/formattedText/FormattedTextBox.tsx
parent412e4aa10e0fab8a949c78e851efdc68661dd522 (diff)
fixed menu functions that referenced 'self' instead of 'this'
Diffstat (limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 0b63ac89d..31c0545d4 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -110,6 +110,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
private _recordingStart: number = 0;
private _ignoreScroll = false;
private _lastText = '';
+ private _hadDownFocus = false;
private _focusSpeed: Opt<number>;
private _keymap: any = undefined;
private _rules: RichTextRules | undefined;
@@ -117,6 +118,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
private _forceDownNode: Node | undefined;
private _downX = 0;
private _downY = 0;
+ private _downTime = 0;
private _break = true;
public ProseRef?: HTMLDivElement;
public get EditorView() {
@@ -1623,6 +1625,8 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
}
this._downX = e.clientX;
this._downY = e.clientY;
+ this._downTime = Date.now();
+ this._hadDownFocus = this.ProseRef?.children[0].className.includes('focused') ?? false;
FormattedTextBoxComment.textBox = this;
if (e.button === 0 && (this.props.rootSelected() || this.props.rootSelected()) && !e.altKey && !e.ctrlKey && !e.metaKey) {
if (e.clientX < this.ProseRef!.getBoundingClientRect().right) {
@@ -1641,6 +1645,9 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
onPointerUp = (e: React.PointerEvent): void => {
const editor = this._editorView!;
const state = editor?.state;
+ if (!Utils.isClick(e.clientX, e.clientY, this._downX, this._downY, this._downTime) && !this._hadDownFocus) {
+ (this.ProseRef?.children[0] as HTMLElement)?.blur?.();
+ }
if (!state || !editor || !this.ProseRef?.children[0].className.includes('-focused')) return;
if (!state.selection.empty && !(state.selection instanceof NodeSelection)) this.setupAnchorMenu();
else if (this.props.isContentActive(true)) {