@usememos/editor 26.10.5 → 26.10.7
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.
- package/dist/index.js +14 -0
- package/dist/index.js.map +2 -2
- package/dist/style.css +6 -2
- package/dist/theme.css +3 -2
- package/dist/types/editor.d.ts +2 -0
- package/dist/types/ui/handle.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6369,6 +6369,10 @@ var BlockHandle = class {
|
|
|
6369
6369
|
this.el.style.left = `${Math.round(rect.left - (this.el.offsetWidth || 20) - 6 - offset.x)}px`;
|
|
6370
6370
|
this.el.style.top = `${Math.round(rect.top + firstLine / 2 - size / 2 - offset.y)}px`;
|
|
6371
6371
|
}
|
|
6372
|
+
/** True when `node` is the handle or inside it. */
|
|
6373
|
+
contains(node) {
|
|
6374
|
+
return this.el.contains(node);
|
|
6375
|
+
}
|
|
6372
6376
|
hide() {
|
|
6373
6377
|
this.cancelHide();
|
|
6374
6378
|
this.el.hidden = true;
|
|
@@ -6747,6 +6751,7 @@ var Editor = class {
|
|
|
6747
6751
|
this.listen(root.ownerDocument, "selectionchange", () => this.onSelectionChange());
|
|
6748
6752
|
this.listen(root.ownerDocument, "mouseup", () => this.onMouseUp());
|
|
6749
6753
|
this.listen(root.ownerDocument, "scroll", () => this.onScroll(), true);
|
|
6754
|
+
this.listen(root.ownerDocument, "pointerdown", (e) => this.onDocumentPointerDown(e), true);
|
|
6750
6755
|
this.paint(true, true);
|
|
6751
6756
|
this.afterRender();
|
|
6752
6757
|
for (const ext of this.extensions) {
|
|
@@ -8430,6 +8435,8 @@ var Editor = class {
|
|
|
8430
8435
|
const start = startOf(block3);
|
|
8431
8436
|
this.current = { ...this.state, selection: { anchor: start, focus: start } };
|
|
8432
8437
|
this.focus();
|
|
8438
|
+
} else if (!this.hasFocus()) {
|
|
8439
|
+
this.focus();
|
|
8433
8440
|
}
|
|
8434
8441
|
this.blockMenu.setSections(this.blockMenuSections(blockId));
|
|
8435
8442
|
const rect = anchor ?? this.blockElement(blockId)?.getBoundingClientRect();
|
|
@@ -8440,6 +8447,13 @@ var Editor = class {
|
|
|
8440
8447
|
this.blockMenu.hide();
|
|
8441
8448
|
this.syncActiveDescendant();
|
|
8442
8449
|
}
|
|
8450
|
+
/** A press anywhere but the block menu or the block handle closes the menu, in the editor's text too. */
|
|
8451
|
+
onDocumentPointerDown(e) {
|
|
8452
|
+
if (!this.blockMenu.isOpen) return;
|
|
8453
|
+
const target = e.target;
|
|
8454
|
+
if (target && (this.blockMenu.popup.el.contains(target) || this.handle.contains(target))) return;
|
|
8455
|
+
this.closeBlockMenu();
|
|
8456
|
+
}
|
|
8443
8457
|
// -------------------------------------------------------------------------
|
|
8444
8458
|
// Toolbar and link popover (see ui/toolbar.ts)
|
|
8445
8459
|
/** @internal Opens the link popover for the selection, as Mod+K does. */
|