@mp-lb/mdkit 0.2.2-main.16.1 → 0.2.3
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.
|
@@ -191,6 +191,33 @@ export const TiptapMarkdownSurface = (props) => {
|
|
|
191
191
|
useEffect(() => {
|
|
192
192
|
editor?.setEditable(!readOnly);
|
|
193
193
|
}, [editor, readOnly]);
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!editor) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const blurEditorOnExternalPointerDown = (event) => {
|
|
199
|
+
if (editor.isDestroyed) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const target = event.target;
|
|
203
|
+
if (!(target instanceof Element)) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (editorSurfaceRef.current?.contains(target) ||
|
|
207
|
+
target.closest(".mp-lb-mdkit-toolbar")) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
editor.commands.blur();
|
|
211
|
+
};
|
|
212
|
+
document.addEventListener("pointerdown", blurEditorOnExternalPointerDown, {
|
|
213
|
+
capture: true,
|
|
214
|
+
});
|
|
215
|
+
return () => {
|
|
216
|
+
document.removeEventListener("pointerdown", blurEditorOnExternalPointerDown, {
|
|
217
|
+
capture: true,
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
}, [editor]);
|
|
194
221
|
useEffect(() => {
|
|
195
222
|
if (!editor) {
|
|
196
223
|
return;
|