@mp-lb/mdkit 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,6 +18,7 @@ const describeElement = (element) => {
|
|
|
18
18
|
};
|
|
19
19
|
const describeEventTarget = (target) => target instanceof Element ? describeElement(target) : String(target);
|
|
20
20
|
const isInteractiveElement = (target) => !!target.closest("a,button,input,select,textarea,[contenteditable='false']");
|
|
21
|
+
const isNativeFocusTarget = (target) => !!target.closest("a[href],button,input,select,textarea,[contenteditable='true'],[tabindex]:not([tabindex='-1'])");
|
|
21
22
|
const createEditorDebugSnapshot = (editor, phase) => {
|
|
22
23
|
const activeElement = typeof document === "undefined" || !document.activeElement
|
|
23
24
|
? null
|
|
@@ -344,6 +345,9 @@ export const TiptapMarkdownSurface = (props) => {
|
|
|
344
345
|
if (editor.isDestroyed) {
|
|
345
346
|
return;
|
|
346
347
|
}
|
|
348
|
+
if (!editor.isFocused && !editor.view.hasFocus()) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
347
351
|
const target = event.target;
|
|
348
352
|
if (!(target instanceof Element)) {
|
|
349
353
|
return;
|
|
@@ -352,6 +356,9 @@ export const TiptapMarkdownSurface = (props) => {
|
|
|
352
356
|
target.closest(".mp-lb-mdkit-toolbar")) {
|
|
353
357
|
return;
|
|
354
358
|
}
|
|
359
|
+
if (isNativeFocusTarget(target)) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
355
362
|
editor.commands.blur();
|
|
356
363
|
};
|
|
357
364
|
document.addEventListener("pointerdown", blurEditorOnExternalPointerDown, {
|