UNPKG

mind-elixir

Version:

Mind elixir is a free open source mind map core.

575 lines (574 loc) • 23.8 kB
//#region src/utils/index.ts var e = function(t, n) { if (n.id === t) return n; if (n.children && n.children.length) { for (let r = 0; r < n.children.length; r++) { let i = e(t, n.children[r]); if (i) return i; } return null; } return null; }; function t() { return Date.now().toString(36) + Math.random().toString(36).substring(2, 8); } //#endregion //#region src/outliner/icons.ts var n = { home: "<path d=\"M3 9.5 12 3l9 6.5\"/><path d=\"M5 10v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V10\"/><path d=\"M9 21v-6h6v6\"/>", ellipsis: "<circle cx=\"12\" cy=\"12\" r=\"1\"/><circle cx=\"19\" cy=\"12\" r=\"1\"/><circle cx=\"5\" cy=\"12\" r=\"1\"/>", chevronDown: "<path d=\"m6 9 6 6 6-6\"/>", chevronRight: "<path d=\"m9 18 6-6-6-6\"/>", arrowLeft: "<path d=\"m12 19-7-7 7-7\"/><path d=\"M19 12H5\"/>", arrowRight: "<path d=\"M5 12h14\"/><path d=\"m12 5 7 7-7 7\"/>", trash: "<path d=\"M3 6h18\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\"/><path d=\"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"/><path d=\"M10 11v6\"/><path d=\"M14 11v6\"/>" }, r = (e, t) => `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${n[e] ?? ""}</svg>`, i = /* @__PURE__ */ new Map(); function a(e, t = 16) { let n = `${e}:${t}`, a = i.get(n); return a === void 0 && (a = r(e, t), i.set(n, a)), a; } //#endregion //#region src/outliner/types.ts var o = { menuTitle: "操作菜单", outdent: "取消缩进", indent: "缩进", delete: "删除", untitled: "(无标题)", zoomInAndDrag: "点击进入 / 拖拽移动" }, s = (e) => { e.children ||= [], e.children.forEach(s); }, c = class { el; breadcrumbEl; itemsEl; root; history; mei; suppressSync = !1; syncDirty = !1; syncQueued = !1; readonly; markdown; i18n; fileName; onChange; zoomedId = null; editingId = null; compositionJustEnded = !1; openMenuId = null; draggedId = null; draggedContainer = null; dropIndicator = null; views = /* @__PURE__ */ new Map(); seen = /* @__PURE__ */ new Set(); breadcrumbSig = ""; disposers = []; constructor(e) { let t = typeof e.el == "string" ? document.querySelector(e.el) : e.el; if (!t) throw Error("Outliner: el is not a valid element"); if (this.el = t, this.el.innerHTML = "", this.mei = e.mei, !this.mei.historyStack) throw Error("Outliner: mei.historyStack is missing — create the MindElixir instance with `allowUndo: true` and await `init`"); this.history = this.mei.historyStack, this.readonly = e.readonly ?? !1, this.markdown = e.markdown, this.i18n = { ...o, ...e.i18n }, this.fileName = e.fileName, this.onChange = e.onChange, this.bindRoot(), this.breadcrumbEl = document.createElement("div"), this.breadcrumbEl.className = "outliner-breadcrumb", this.itemsEl = document.createElement("div"), this.itemsEl.className = "outliner-items"; let n = document.createElement("div"); n.className = "outliner-container", n.appendChild(this.breadcrumbEl), n.appendChild(this.itemsEl), this.el.appendChild(n), this.disposers.push(this.history.subscribe(this.requestSync)); let r = (e) => { e.silent && this.scheduleSync(); }, i = this.mei.bus; i.addListener("operation", r), this.disposers.push(() => i.removeListener("operation", r)), document.addEventListener("keydown", this.handleGlobalKeydown), this.disposers.push(() => document.removeEventListener("keydown", this.handleGlobalKeydown)), document.addEventListener("mousedown", this.handleDocumentMousedown), this.disposers.push(() => document.removeEventListener("mousedown", this.handleDocumentMousedown)), this.el.addEventListener("keydown", this.handleTopicKeydown), this.el.addEventListener("compositionend", this.handleCompositionEnd), this.disposers.push(() => this.el.removeEventListener("compositionend", this.handleCompositionEnd)), this.el.addEventListener("click", this.handleClick), this.el.addEventListener("focusin", this.handleFocusIn), this.el.addEventListener("focusout", this.handleFocusOut), this.el.addEventListener("dragstart", this.handleDragStart), this.el.addEventListener("dragend", this.handleDragEnd), this.el.addEventListener("dragover", this.handleDragOver), this.el.addEventListener("dragleave", this.handleDragLeave), this.el.addEventListener("drop", this.handleDrop), this.render(); } getData() { return JSON.parse(this.mei.stringifyData(this.root)); } addChild(e) { let n = this.meiEle(e); if (!n) return; this.flushEditingText(); let r = t(); this.mei.addChild(n, { id: r, topic: "", children: [] }), this.focusItem(r); } destroy() { this.disposers.forEach((e) => e()), this.disposers = [], this.el.removeEventListener("keydown", this.handleTopicKeydown), this.el.removeEventListener("keydown", this.handleGlobalKeydown), this.el.removeEventListener("click", this.handleClick), this.el.removeEventListener("focusin", this.handleFocusIn), this.el.removeEventListener("focusout", this.handleFocusOut), this.el.removeEventListener("dragstart", this.handleDragStart), this.el.removeEventListener("dragend", this.handleDragEnd), this.el.removeEventListener("dragover", this.handleDragOver), this.el.removeEventListener("dragleave", this.handleDragLeave), this.el.removeEventListener("drop", this.handleDrop), this.views.clear(), this.seen.clear(), this.dropIndicator = null, this.draggedContainer = null, this.syncDirty = !1, this.el.innerHTML = ""; } focusItem(e) { let t = this.itemsEl.querySelector(`[data-outline-item][data-item-id="${CSS.escape(e)}"]`); if (!t) return; let n = document.activeElement === t; t.focus(), n && this.placeCaretAtEnd(t); } bindRoot() { let e = this.mei.nodeData; this.root !== e && (this.root = e), s(e); } byId(t) { return e(t, this.root); } isRoot(e) { return this.root.id === e; } parentOf(e) { return this.byId(e)?.parent ?? null; } prevSiblingOf(e) { let t = this.byId(e), n = t?.parent?.children; if (!t || !n) return null; let r = n.indexOf(t); return r > 0 ? n[r - 1] : null; } pathTo(e) { let t = [], n = this.byId(e); for (; n && (t.unshift({ id: n.id, topic: n.topic }), n.id !== this.root.id);) n = n.parent ?? null; return t; } meiEle(e) { try { return this.mei.findEle(e); } catch { return null; } } requestSync = () => { this.suppressSync || (this.syncDirty = !1, this.rerenderFromMei()); }; scheduleSync = () => { this.suppressSync || (this.syncDirty = !0, !this.syncQueued && (this.syncQueued = !0, queueMicrotask(() => { this.syncQueued = !1, this.syncDirty && (this.syncDirty = !1, this.rerenderFromMei()); }))); }; rerenderFromMei() { if (this.suppressSync) return; this.bindRoot(), this.zoomedId && !this.byId(this.zoomedId) && (this.zoomedId = null), this.flushEditingText(); let e = this.editingId ? this.views.get(this.editingId) : null; this.openMenuId = null, this.render(), this.editingId && this.views.get(this.editingId) !== e && (this.editingId = null), this.emitChange(); } emitChange() { this.onChange?.(this.getData()); } flushEditingText() { let e = this.liveEditingText(); if (!e) return; let t = this.byId(e.id); t && t.topic !== e.text && this.setNodeTopicBound(e.id, e.text); } setNodeTopicBound(e, t) { let n = this.meiEle(e); if (n) { this.suppressSync = !0; try { this.mei.reshapeNode(n, { topic: t }); } finally { this.suppressSync = !1; } } } expandBound(e, t) { let n = this.meiEle(e); n && this.mei.expandNode(n, t); } applyOperation(e) { if (this.readonly || this.isRoot(e.id)) return; this.flushEditingText(); let n = this.meiEle(e.id); if (!n) return; let r = e.type === "addSibling" || e.type === "addSiblingBefore" ? t() : null, i = r ? { id: r, topic: e.newNodeContent ?? "", children: [] } : void 0; switch (e.type) { case "addSibling": this.mei.insertSibling("after", n, i); break; case "addSiblingBefore": this.mei.insertSibling("before", n, i); break; case "indent": { let t = this.prevSiblingOf(e.id), r = t ? this.meiEle(t.id) : null; r && this.mei.moveNodesIn([n], r); break; } case "outdent": { let t = this.parentOf(e.id), r = t && !this.isRoot(t.id) ? this.meiEle(t.id) : null; r && this.mei.moveNodesAfter([n], r); break; } case "moveUp": this.mei.moveUpNode(n); break; case "moveDown": this.mei.moveDownNode(n); break; case "moveTo": { let t = e.targetId ? this.meiEle(e.targetId) : null; if (!t || this.isRoot(e.targetId) && e.dropPosition !== "inside") break; e.dropPosition === "before" ? this.mei.moveNodesBefore([n], t) : e.dropPosition === "after" ? this.mei.moveNodesAfter([n], t) : this.mei.moveNodesIn([n], t); break; } } r ? this.focusItem(r) : e.shouldFocusCurrent && this.focusItem(e.id); } deleteItem(e) { if (this.readonly || this.isRoot(e)) return; let t = this.getTopicEl(e), n = null; if (t) { let r = Array.from(this.itemsEl.querySelectorAll("[data-outline-item]")), i = r.indexOf(t); n = i > 0 ? r[i - 1].getAttribute("data-item-id") : this.parentOf(e)?.id ?? null; } this.flushEditingText(); let r = this.meiEle(e); r && (this.mei.removeNodes([r]), n && this.focusItem(n)); } render() { this.zoomedId && !this.byId(this.zoomedId) && (this.zoomedId = null), this.renderBreadcrumb(); let e = this.zoomedId ? this.byId(this.zoomedId) : null, t = e ? e.children : [this.root]; this.seen.clear(); let n = null; for (let e of t) n = this.syncItem(e, 0, this.zoomedId ?? void 0, t.length, this.itemsEl, n); this.unmountUnseen(); } renderBreadcrumb() { let e = this.zoomedId ? this.pathTo(this.zoomedId) : [], t = `${this.fileName ?? ""}\u0000${e.map((e) => `${e.id}:${e.topic}`).join("\0")}`; if (t === this.breadcrumbSig) return; this.breadcrumbSig = t, this.breadcrumbEl.innerHTML = ""; let n = document.createElement("button"); n.className = "breadcrumb-item breadcrumb-root", n.innerHTML = `${a("home")}<span class="breadcrumb-text">${this.escapeText(this.fileName ?? "")}</span>`, n.addEventListener("click", () => this.zoomTo(null)), this.breadcrumbEl.appendChild(n), e.forEach((t, n) => { let r = document.createElement("span"); r.className = "breadcrumb-segment"; let i = n === e.length - 1, a = this.escapeText(t.topic || this.i18n.untitled); if (i) r.innerHTML = `<span class="breadcrumb-separator">/</span><span class="breadcrumb-item breadcrumb-current">${a}</span>`; else { let e = document.createElement("button"); e.className = "breadcrumb-item", e.innerHTML = a, e.addEventListener("click", () => this.zoomTo(t.id)), r.innerHTML = "<span class=\"breadcrumb-separator\">/</span>", r.appendChild(e); } this.breadcrumbEl.appendChild(r); }); } syncItem(e, t, n, r, i, a) { let o = this.views.get(e.id); o ? this.patchItemView(o, e, t, n, r) : (o = this.createItemView(e, t, n, r), this.views.set(e.id, o)); let s = a ? a.nextSibling : i.firstChild; if (s !== o.container && i.insertBefore(o.container, s), this.seen.add(e.id), e.expanded !== !1) { let n = o.wrapper; for (let r of e.children) n = this.syncItem(r, t + 1, e.id, e.children.length, o.container, n); } return o.container; } unmountUnseen() { for (let [e, t] of this.views) this.seen.has(e) || (t.container.remove(), this.views.delete(e), this.openMenuId === e && (this.openMenuId = null)); } createItemView(e, t, n, r) { let i = document.createElement("div"); i.className = "outline-item-container", i.dataset.itemId = e.id, this.readonly && (i.style.pointerEvents = "none"); let o = null; t > 0 && (o = document.createElement("div"), o.className = "outline-item-vertical-line", o.style.left = `${t * 24 - 13}px`, o.style.height = "100%", i.appendChild(o)); let s = document.createElement("div"); s.className = "outline-item-wrapper", s.dataset.itemId = e.id, s.style.marginLeft = `${t * 24}px`, i.appendChild(s); let c = document.createElement("div"); c.className = "outline-item-front"; let l = document.createElement("div"); l.className = `outline-item-dot${this.readonly ? "" : " outline-item-dot-zoomable"}`, l.title = this.i18n.zoomInAndDrag, this.readonly || (l.draggable = !0), c.appendChild(l), s.appendChild(c); let u = document.createElement("div"); u.className = "outline-item-topic", u.dataset.outlineItem = "", u.dataset.itemId = e.id, this.readonly || (u.contentEditable = "plaintext-only"), this.writeTopicHtml(u, e.topic, e), s.appendChild(u); let d = document.createElement("div"); d.className = "outline-item-btn-group"; let f = null, p = null; this.readonly || (f = document.createElement("div"), f.className = "outline-item-menu-wrapper", p = document.createElement("button"), p.className = "outline-item-menu-btn", p.title = this.i18n.menuTitle, p.draggable = !1, p.innerHTML = a("ellipsis", 12), f.appendChild(p), d.appendChild(f)); let m = document.createElement("button"); return m.className = "outline-item-collapse-btn", m.dataset.state = e.children.length === 0 ? "hidden" : e.expanded === !1 ? "collapsed" : "expanded", m.innerHTML = a(e.expanded === !1 ? "chevronRight" : "chevronDown"), d.appendChild(m), s.appendChild(d), { container: i, wrapper: s, line: o, dot: l, topic: u, btnGroup: d, menuWrapper: f, menuBtn: p, dropdown: null, menuOpen: !1, collapse: m, topicText: e.topic, topicDirty: !1, item: e, level: t, parentId: n, siblingCount: r }; } patchItemView(e, t, n, r, i) { let o = e.level !== n; e.item = t, e.level = n, e.parentId = r, e.siblingCount = i, o && (e.wrapper.style.marginLeft = `${n * 24}px`, e.line && (e.line.style.left = `${n * 24 - 13}px`)), this.editingId !== t.id && (e.topicDirty || e.topicText !== t.topic) && (this.writeTopicHtml(e.topic, t.topic, t), e.topicText = t.topic, e.topicDirty = !1); let s = t.children.length === 0 ? "hidden" : t.expanded === !1 ? "collapsed" : "expanded"; e.collapse.dataset.state !== s && (e.collapse.dataset.state = s, e.collapse.innerHTML = a(t.expanded === !1 ? "chevronRight" : "chevronDown")), this.syncDropdown(e); } syncDropdown(e) { let t = !!e.menuWrapper && this.openMenuId === e.item.id; t && !e.dropdown ? (e.dropdown = this.createDropdown(e), e.menuWrapper.appendChild(e.dropdown)) : !t && e.dropdown && (e.dropdown.remove(), e.dropdown = null), e.menuOpen !== t && (e.wrapper.classList.toggle("menu-open", t), e.menuOpen = t); } createDropdown(e) { let t = document.createElement("div"); t.className = "outline-item-menu-dropdown"; let n = (e, n, r, i = !1) => { let o = document.createElement("button"); o.className = `outline-item-menu-item${i ? " outline-item-menu-item-danger" : ""}`, o.dataset.action = r, o.innerHTML = `${a(n, 12)}<span>${e}</span>`, t.appendChild(o); }; return n(this.i18n.outdent, "arrowLeft", "outdent"), n(this.i18n.indent, "arrowRight", "indent"), (e.level > 0 || e.siblingCount > 1) && n(this.i18n.delete, "trash", "delete", !0), t; } toggleMenu(e) { this.setOpenMenu(this.openMenuId === e ? null : e); } setOpenMenu(e) { let t = this.openMenuId; if (t !== e) { if (this.openMenuId = e, t) { let e = this.views.get(t); e && this.syncDropdown(e); } if (e) { let t = this.views.get(e); t && this.syncDropdown(t); } } } runMenuAction(e) { let t = this.openMenuId; if (!t) return; let n = this.views.get(t); if (!n) return; let { item: r, level: i, siblingCount: a } = n; this.setOpenMenu(null), e === "outdent" ? this.applyOperation({ type: "outdent", id: r.id, shouldFocusCurrent: !0 }) : e === "indent" ? this.applyOperation({ type: "indent", id: r.id, shouldFocusCurrent: !0 }) : e === "delete" && (i > 0 || a > 1) && this.deleteItem(r.id); } handleDragStart = (e) => { let t = e.target; if (!t.closest?.(".outline-item-dot")) return; let n = t.closest(".outline-item-container"), r = n?.dataset.itemId; !n || !r || (e.stopPropagation(), this.draggedId = r, this.draggedContainer = n, e.dataTransfer && (e.dataTransfer.effectAllowed = "move"), n.style.opacity = "0.4"); }; handleDragEnd = () => { this.clearDropIndicator(), this.draggedId = null, this.draggedContainer &&= (this.draggedContainer.style.opacity = "", null); }; handleDragOver = (e) => { let t = e.target.closest?.(".outline-item-wrapper"); if (!t) return; e.stopPropagation(), e.preventDefault(); let n = () => t.classList.remove("drag-over", "drag-over-bottom", "drag-over-inside"), r = this.views.get(t.dataset.itemId ?? ""); if (!r || !this.draggedId || this.draggedId === r.item.id) { n(); return; } let i = t.closest(".outline-item-container"); if (!this.draggedContainer || !i || this.draggedContainer.contains(i)) { n(), e.dataTransfer && (e.dataTransfer.dropEffect = "none"); return; } e.dataTransfer && (e.dataTransfer.dropEffect = "move"); let a = t.getBoundingClientRect(), o = e.clientY - a.top, s = o < a.height * .25 ? "before" : o > a.height * .75 ? "after" : "inside"; (this.dropIndicator?.el !== t || this.dropIndicator.position !== s) && (this.clearDropIndicator(), t.classList.add(s === "before" ? "drag-over" : s === "after" ? "drag-over-bottom" : "drag-over-inside"), this.dropIndicator = { el: t, position: s }); }; handleDragLeave = (e) => { let t = e.target.closest?.(".outline-item-wrapper"); t && (e.stopPropagation(), t.contains(e.relatedTarget) || t.classList.remove("drag-over", "drag-over-bottom", "drag-over-inside")); }; handleDrop = (e) => { let t = e.target.closest?.(".outline-item-wrapper"); if (!t) return; e.preventDefault(), e.stopPropagation(); let n = this.dropIndicator?.el === t ? this.dropIndicator.position : null; this.clearDropIndicator(); let r = this.views.get(t.dataset.itemId ?? ""), i = this.draggedId; !r || !i || i === r.item.id || !n || this.applyOperation({ type: "moveTo", id: i, targetId: r.item.id, dropPosition: n, shouldFocusCurrent: !0 }); }; clearDropIndicator() { this.dropIndicator &&= (this.dropIndicator.el.classList.remove("drag-over", "drag-over-bottom", "drag-over-inside"), null); } writeTopicHtml(e, t, n) { this.markdown ? e.innerHTML = this.markdown(t, n) : e.textContent = t; } escapeText(e) { let t = document.createElement("div"); return t.textContent = e, t.innerHTML; } getTopicEl(e) { return this.itemsEl.querySelector(`[data-outline-item][data-item-id="${CSS.escape(e)}"]`); } liveEditingText() { if (!this.editingId) return null; let e = this.getTopicEl(this.editingId); return e ? { id: this.editingId, text: e.textContent ?? "" } : null; } handleFocusIn = (e) => { let t = e.target; if (!t.matches?.("[data-outline-item]")) return; let n = t.getAttribute("data-item-id"), r = this.byId(n); if (!r) return; this.editingId = n, t.textContent = r.topic; let i = this.views.get(n); i && (i.topicDirty = !0), this.placeCaretAtEnd(t); }; placeCaretAtEnd(e) { let t = document.createRange(); t.selectNodeContents(e), t.collapse(!1); let n = window.getSelection(); n?.removeAllRanges(), n?.addRange(t); } markTopicClean(e, t) { let n = this.views.get(e); n && (n.topicText = t, n.topicDirty = !1); } handleFocusOut = (e) => { let t = e.target; if (!t.matches?.("[data-outline-item]")) return; let n = t.getAttribute("data-item-id"); if (this.editingId !== n) return; this.editingId = null; let r = t.textContent ?? "", i = this.byId(n); i && i.topic !== r && this.setNodeTopicBound(n, r); let a = this.byId(n); a && this.writeTopicHtml(t, a.topic, a), this.markTopicClean(n, a?.topic ?? r); }; handleCompositionEnd = () => { this.compositionJustEnded = !0, setTimeout(() => { this.compositionJustEnded = !1; }, 0); }; handleTopicKeydown = (e) => { if (e.isComposing || e.keyCode === 229 || this.compositionJustEnded && (e.key === "Enter" || e.key === "Escape")) return; let n = e.target.closest?.("[data-outline-item]"); if (!n || this.readonly) return; let r = n.getAttribute("data-item-id"), i = n.textContent?.trim(); if (e.key === "ArrowUp" && e.altKey) e.preventDefault(), this.applyOperation({ type: "moveUp", id: r, shouldFocusCurrent: !0 }); else if (e.key === "ArrowDown" && e.altKey) e.preventDefault(), this.applyOperation({ type: "moveDown", id: r, shouldFocusCurrent: !0 }); else if (e.key === "ArrowUp" || e.key === "ArrowDown") { e.preventDefault(); let t = Array.from(this.itemsEl.querySelectorAll("[data-outline-item]")), r = t.indexOf(n); if (r === -1) return; let i = t[r + (e.key === "ArrowUp" ? -1 : 1)]; i && (n.blur(), i.focus()); } else if (e.key === "Enter") { if (e.preventDefault(), this.isRoot(r)) return; if (e.shiftKey) { this.applyOperation({ type: "addSiblingBefore", id: r }); return; } let i = n.textContent ?? "", a = window.getSelection(), o = i.length; if (a && a.rangeCount > 0) { let e = a.getRangeAt(0), t = e.cloneRange(); t.selectNodeContents(n), t.setEnd(e.endContainer, e.endOffset), o = t.toString().length; } let s = i.substring(0, o), c = i.substring(o); if (s.trim() === "" && c.trim() === "") this.applyOperation({ type: "outdent", id: r, shouldFocusCurrent: !0 }); else if (c.trim() !== "") { let e = this.meiEle(r); if (!e) return; let i = t(), a = this.byId(r); n.textContent = s, s !== (a?.topic ?? "") && this.setNodeTopicBound(r, s), this.mei.insertSibling("after", e, { id: i, topic: c, children: [] }), this.focusItem(i); } else this.applyOperation({ type: "addSibling", id: r }); } else e.key === "Tab" ? (e.preventDefault(), this.applyOperation({ type: e.shiftKey ? "outdent" : "indent", id: r, shouldFocusCurrent: !0 })) : e.key === "Backspace" && i === "" && !this.isRoot(r) && (e.preventDefault(), this.deleteItem(r)); }; handleClick = (e) => { let t = e.target; if (!t.closest || t.closest(".breadcrumb-item")) return; let n = t.closest(".outline-item-container")?.dataset.itemId, r = t.closest(".outline-item-menu-item"); if (r) { e.stopPropagation(), this.runMenuAction(r.dataset.action ?? ""); return; } if (t.closest(".outline-item-menu-btn")) { e.stopPropagation(), n && this.toggleMenu(n); return; } if (t.closest(".outline-item-collapse-btn")) { e.stopPropagation(); let t = n ? this.views.get(n) : void 0; t && this.expandBound(t.item.id, t.item.expanded === !1); return; } if (t.closest(".outline-item-dot")) { e.stopPropagation(), n && this.zoomTo(n); return; } this.setOpenMenu(null); }; handleDocumentMousedown = (e) => { this.openMenuId && (e.target.closest?.(".outline-item-menu-wrapper") || this.setOpenMenu(null)); }; handleGlobalKeydown = (e) => { if (this.mei.container?.contains(e.target)) return; let t = document.activeElement, n = !!t && (t.getAttribute("contenteditable") === "true" || t.isContentEditable), r = !!t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA"), i = e.metaKey || e.ctrlKey, a = e.key.toLowerCase(); if (n && i && a === "z" && !e.shiftKey) { e.preventDefault(); let n = t.textContent || "", r = !1; try { r = document.execCommand("undo"); } catch { r = !1; } setTimeout(() => { let e = t.textContent || ""; (!r || n === e) && this.mei.undo(); }, 0); return; } r || n || (i && a === "z" && !e.shiftKey ? (e.preventDefault(), this.mei.undo()) : i && (a === "y" || a === "z" && e.shiftKey) && (e.preventDefault(), this.mei.redo())); }; zoomTo(e) { this.setOpenMenu(null), this.zoomedId = e, this.syncDirty = !1, this.render(); } }; //#endregion export { c as Outliner, o as defaultI18n };