monobill-mintui 0.6.737 → 0.6.739
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/bin/component-dependencies.json +2 -1
- package/dist/components/alert/browser.js +4 -4
- package/dist/components/alert/index.cjs +1 -1
- package/dist/components/alert/index.js +4 -4
- package/dist/components/back-button/browser.js +1 -1
- package/dist/components/back-button/index.cjs +1 -1
- package/dist/components/back-button/index.js +1 -1
- package/dist/components/bottom-navigation/browser.js +2 -2
- package/dist/components/bottom-navigation/index.cjs +1 -1
- package/dist/components/bottom-navigation/index.js +2 -2
- package/dist/components/button/browser.js +1 -1
- package/dist/components/button/index.cjs +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/checkbox/browser.js +1 -1
- package/dist/components/checkbox/index.cjs +1 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/chip/browser.js +1 -1
- package/dist/components/chip/index.cjs +1 -1
- package/dist/components/chip/index.js +1 -1
- package/dist/components/chunks/ScrollFade-58GqgRLY.js +1 -0
- package/dist/components/chunks/ScrollFade-kpfpO4Zb.js +160 -0
- package/dist/components/chunks/{back-button-C_aLMNZE.js → back-button-CQ3ZKGa1.js} +1 -1
- package/dist/components/chunks/{back-button-CMZR-p_D.js → back-button-DpPfWpAh.js} +2 -2
- package/dist/components/chunks/{button-THsh4Svz.js → button-CIuVIyLf.js} +2 -2
- package/dist/components/chunks/{button-CELyLLtj.js → button-CgymemwA.js} +1 -1
- package/dist/components/chunks/{caret-down-DUfiCBEs.js → caret-down-CikQdiAu.js} +1 -1
- package/dist/components/chunks/caret-down-DZinO2Vg.js +1 -0
- package/dist/components/chunks/caret-right-CMZIcNYV.js +1 -0
- package/dist/components/chunks/{caret-right-CppgjbLX.js → caret-right-ZvpF7jIK.js} +1 -1
- package/dist/components/chunks/{checkbox-d5UlscqI.js → checkbox-98ctQydC.js} +1 -1
- package/dist/components/chunks/{checkbox-CZViKLNo.js → checkbox-B8VzPrhn.js} +2 -2
- package/dist/components/chunks/{chip-G6SRCgLq.js → chip-Cqm_NPF5.js} +3 -3
- package/dist/components/chunks/{chip-DJ_kZURn.js → chip-dVw8BZP7.js} +1 -1
- package/dist/components/chunks/{close-ChHICicN.js → close-DtRLefjU.js} +1 -1
- package/dist/components/chunks/close-DuS1TdUB.js +1 -0
- package/dist/components/chunks/{confirm-action-BSHfjDfA.js → confirm-action-8Yx0K5j1.js} +1 -1
- package/dist/components/chunks/{confirm-action-CRZMTjpd.js → confirm-action-C0XX_TyJ.js} +2 -2
- package/dist/components/chunks/{date-picker-CTtYAkmM.js → date-picker-BJ_82oRR.js} +1 -1
- package/dist/components/chunks/{date-picker-CUf5eJR3.js → date-picker-BuJJ8gvT.js} +5 -5
- package/dist/components/chunks/icon-Cmx9FTmb.js +1 -0
- package/dist/components/chunks/{icon-1cs-hcBy.js → icon-CuRTWM4k.js} +67 -57
- package/dist/components/chunks/icon-pgeP1zxb.js +51 -0
- package/dist/components/chunks/icon-rdeLRs-R.js +1 -0
- package/dist/components/chunks/{input-Bu4xPosP.js → input-BpcFd35m.js} +3 -3
- package/dist/components/chunks/{input-Zqw53jts.js → input-DJaqPjMg.js} +1 -1
- package/dist/components/chunks/{modal-CL5EStu0.js → modal-BJtuPK1b.js} +1 -1
- package/dist/components/chunks/{modal-ss_OTDJJ.js → modal-BzRle8yT.js} +2 -2
- package/dist/components/chunks/{popover-DD7uyRXy.js → popover-BcN2LEbO.js} +15 -3
- package/dist/components/chunks/popover-N3cKN8iW.js +1 -0
- package/dist/components/chunks/search-DA6dk5kF.js +1 -0
- package/dist/components/chunks/{search-DKHcIR2F.js → search-Dw9cb1wC.js} +1 -1
- package/dist/components/chunks/{select-CX9oOwl5.js → select-Ctps8gPL.js} +1 -1
- package/dist/components/chunks/{select-DOMW7Plx.js → select-DPERiupq.js} +3 -3
- package/dist/components/chunks/sortable-Bj0VTUqS.js +1 -0
- package/dist/components/chunks/{sortable-CQtdBuGw.js → sortable-DWfdFpgA.js} +59 -22
- package/dist/components/chunks/{table-HnSpIfny.js → table-C4xUMQw6.js} +1 -1
- package/dist/components/chunks/{table-IU2Vmjwk.js → table-k97RfsAA.js} +1 -1
- package/dist/components/chunks/{time-picker-C7pJvGSM.js → time-picker-Bl8KsaJj.js} +3 -3
- package/dist/components/chunks/{time-picker-BaoT0NtA.js → time-picker-D74vZTpL.js} +1 -1
- package/dist/components/chunks/{warning-gkij2FhS.js → warning-B1-z7ww9.js} +1 -1
- package/dist/components/chunks/{warning-Cf8ePVsQ.js → warning-CfJwI6nV.js} +1 -1
- package/dist/components/confirm-action/browser.js +1 -1
- package/dist/components/confirm-action/index.cjs +1 -1
- package/dist/components/confirm-action/index.js +1 -1
- package/dist/components/date-picker/browser.js +1 -1
- package/dist/components/date-picker/index.cjs +1 -1
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/datetime-picker/browser.js +3 -3
- package/dist/components/datetime-picker/index.cjs +1 -1
- package/dist/components/datetime-picker/index.js +3 -3
- package/dist/components/dropzone/browser.js +4 -4
- package/dist/components/dropzone/index.cjs +1 -1
- package/dist/components/dropzone/index.js +4 -4
- package/dist/components/editor/Editor.d.ts +29 -2
- package/dist/components/editor/Editor.d.ts.map +1 -1
- package/dist/components/editor/browser.js +583 -232
- package/dist/components/editor/index.cjs +14 -8
- package/dist/components/editor/index.d.ts +2 -0
- package/dist/components/editor/index.d.ts.map +1 -1
- package/dist/components/editor/index.js +583 -232
- package/dist/components/form/Form.d.ts +5 -1
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/components/form/browser.js +52 -40
- package/dist/components/form/index.cjs +1 -1
- package/dist/components/form/index.js +52 -40
- package/dist/components/icon/browser.js +1 -1
- package/dist/components/icon/icons/index.d.ts +1 -0
- package/dist/components/icon/icons/index.d.ts.map +1 -1
- package/dist/components/icon/icons/play.d.ts +3 -0
- package/dist/components/icon/icons/play.d.ts.map +1 -0
- package/dist/components/icon/index.cjs +1 -1
- package/dist/components/icon/index.js +1 -1
- package/dist/components/input/browser.js +1 -1
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.js +1 -1
- package/dist/components/link/browser.js +1 -1
- package/dist/components/link/index.cjs +1 -1
- package/dist/components/link/index.js +1 -1
- package/dist/components/modal/browser.js +1 -1
- package/dist/components/modal/index.cjs +1 -1
- package/dist/components/modal/index.js +1 -1
- package/dist/components/navigation/browser.js +4 -4
- package/dist/components/navigation/index.cjs +1 -1
- package/dist/components/navigation/index.js +4 -4
- package/dist/components/off-canvas/browser.js +2 -2
- package/dist/components/off-canvas/index.cjs +1 -1
- package/dist/components/off-canvas/index.js +2 -2
- package/dist/components/page/browser.js +4 -4
- package/dist/components/page/index.cjs +1 -1
- package/dist/components/page/index.js +4 -4
- package/dist/components/popover/Popover.d.ts +4 -0
- package/dist/components/popover/Popover.d.ts.map +1 -1
- package/dist/components/popover/browser.js +1 -1
- package/dist/components/popover/index.cjs +1 -1
- package/dist/components/popover/index.js +1 -1
- package/dist/components/resource-table/browser.js +11 -11
- package/dist/components/resource-table/index.cjs +1 -1
- package/dist/components/resource-table/index.js +11 -11
- package/dist/components/scroll-fade/ScrollFade.d.ts.map +1 -1
- package/dist/components/scroll-fade/browser.js +1 -1
- package/dist/components/scroll-fade/index.cjs +1 -1
- package/dist/components/scroll-fade/index.js +1 -1
- package/dist/components/search/browser.js +7 -7
- package/dist/components/search/index.cjs +1 -1
- package/dist/components/search/index.js +7 -7
- package/dist/components/select/browser.js +1 -1
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +1 -1
- package/dist/components/side-navigation/browser.js +6 -6
- package/dist/components/side-navigation/index.cjs +1 -1
- package/dist/components/side-navigation/index.js +6 -6
- package/dist/components/sortable/Sortable.d.ts +8 -0
- package/dist/components/sortable/Sortable.d.ts.map +1 -1
- package/dist/components/sortable/browser.js +1 -1
- package/dist/components/sortable/index.cjs +1 -1
- package/dist/components/sortable/index.js +1 -1
- package/dist/components/switch/browser.js +2 -2
- package/dist/components/switch/index.cjs +1 -1
- package/dist/components/switch/index.js +2 -2
- package/dist/components/table/browser.js +1 -1
- package/dist/components/table/index.cjs +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/tabs/browser.js +1 -1
- package/dist/components/tabs/index.cjs +1 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/tags/Tags.d.ts.map +1 -1
- package/dist/components/tags/browser.js +8 -17
- package/dist/components/tags/index.cjs +1 -1
- package/dist/components/tags/index.js +8 -17
- package/dist/components/time-picker/browser.js +1 -1
- package/dist/components/time-picker/index.cjs +1 -1
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/tree/browser.js +5 -5
- package/dist/components/tree/index.cjs +1 -1
- package/dist/components/tree/index.js +5 -5
- package/dist/editor.css +1 -1
- package/dist/icons/play.svg +3 -0
- package/dist/index.cjs +19 -13
- package/dist/index.css +3 -3
- package/dist/index.js +1080 -595
- package/dist/navigation-search.json +8 -1
- package/dist/scroll-fade.css +1 -1
- package/dist/tags.css +1 -1
- package/package.json +1 -1
- package/dist/components/chunks/ScrollFade-DOnPtfC2.js +0 -85
- package/dist/components/chunks/ScrollFade-FBvsnQ1i.js +0 -1
- package/dist/components/chunks/caret-down-BiAVkpX7.js +0 -1
- package/dist/components/chunks/caret-right-8n-rhz51.js +0 -1
- package/dist/components/chunks/close-CuYimzX0.js +0 -1
- package/dist/components/chunks/icon-Bv1J3LwC.js +0 -51
- package/dist/components/chunks/icon-C-6HOPtI.js +0 -1
- package/dist/components/chunks/icon-aNwWb0hA.js +0 -1
- package/dist/components/chunks/popover-2Cnva3AN.js +0 -1
- package/dist/components/chunks/search-BXku4V9r.js +0 -1
- package/dist/components/chunks/sortable-Brecvk9d.js +0 -1
- /package/dist/components/chunks/{link-B_fNmwOk.js → link-B4Hdsb2b.js} +0 -0
- /package/dist/components/chunks/{link-BxTQfAW9.js → link-rv2WDJw2.js} +0 -0
|
@@ -19,46 +19,93 @@ __mintLoadStyle('stack', '../../stack.css')
|
|
|
19
19
|
__mintLoadStyle('modal', '../../modal.css')
|
|
20
20
|
__mintLoadStyle('text', '../../text.css')
|
|
21
21
|
__mintLoadStyle('input', '../../input.css')
|
|
22
|
+
__mintLoadStyle('select', '../../select.css')
|
|
22
23
|
__mintLoadStyle('editor', '../../editor.css')
|
|
23
24
|
import { t as e } from "../chunks/register-element-BFYmIynH.js";
|
|
24
|
-
import "../chunks/icon-
|
|
25
|
-
import "../chunks/button-
|
|
26
|
-
import "../chunks/modal-
|
|
27
|
-
import "../chunks/input-
|
|
28
|
-
import "../chunks/popover-
|
|
25
|
+
import "../chunks/icon-Cmx9FTmb.js";
|
|
26
|
+
import "../chunks/button-CIuVIyLf.js";
|
|
27
|
+
import "../chunks/modal-BzRle8yT.js";
|
|
28
|
+
import "../chunks/input-BpcFd35m.js";
|
|
29
|
+
import "../chunks/popover-BcN2LEbO.js";
|
|
30
|
+
import "../scroll-fade/index.js";
|
|
31
|
+
import "../chunks/select-DPERiupq.js";
|
|
29
32
|
//#region src/components/editor/Editor.ts
|
|
30
33
|
function t(e) {
|
|
31
34
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """);
|
|
32
35
|
}
|
|
33
36
|
function n(e) {
|
|
37
|
+
return e.replace(/\r\n?/g, "\n").split("\n").map((e) => e.replace(/[\t ]+$/g, "")).join("\n").trim().replace(/\n{3,}/g, "\n\n");
|
|
38
|
+
}
|
|
39
|
+
function r(e, n) {
|
|
40
|
+
let r = n.createElement("template");
|
|
41
|
+
r.innerHTML = e.trim();
|
|
42
|
+
let i = new Set(/* @__PURE__ */ "address.article.aside.blockquote.body.caption.dd.details.dialog.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.summary.table.tbody.td.tfoot.th.thead.tr.ul".split(".")), a = new Set([
|
|
43
|
+
"area",
|
|
44
|
+
"base",
|
|
45
|
+
"br",
|
|
46
|
+
"col",
|
|
47
|
+
"embed",
|
|
48
|
+
"hr",
|
|
49
|
+
"img",
|
|
50
|
+
"input",
|
|
51
|
+
"link",
|
|
52
|
+
"meta",
|
|
53
|
+
"param",
|
|
54
|
+
"source",
|
|
55
|
+
"track",
|
|
56
|
+
"wbr"
|
|
57
|
+
]), o = (e) => " ".repeat(e), s = (e) => Array.from(e.attributes).map((e) => ` ${e.name}="${t(e.value)}"`).join(""), c = (e) => {
|
|
58
|
+
if (e.nodeType === Node.TEXT_NODE) return t(e.textContent || "");
|
|
59
|
+
if (e.nodeType === Node.COMMENT_NODE) return `<!--${e.nodeValue || ""}-->`;
|
|
60
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return "";
|
|
61
|
+
let n = e, r = n.tagName.toLowerCase(), i = `<${r}${s(n)}>`;
|
|
62
|
+
return a.has(r) ? i : `${i}${Array.from(n.childNodes).map(c).join("")}</${r}>`;
|
|
63
|
+
}, l = (e, n) => {
|
|
64
|
+
if (e.nodeType === Node.TEXT_NODE) return t(e.textContent || "");
|
|
65
|
+
if (e.nodeType === Node.COMMENT_NODE) return `${o(n)}<!--${e.nodeValue || ""}-->`;
|
|
66
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return "";
|
|
67
|
+
let r = e, u = r.tagName.toLowerCase(), d = `<${u}${s(r)}>`;
|
|
68
|
+
if (a.has(u)) return `${o(n)}${d}`;
|
|
69
|
+
let f = Array.from(r.childNodes);
|
|
70
|
+
if (u === "pre" || f.every((e) => e.nodeType === Node.TEXT_NODE || e.nodeType === Node.ELEMENT_NODE && !i.has(e.tagName.toLowerCase()))) return `${o(n)}${d}${f.map(c).join("")}</${u}>`;
|
|
71
|
+
let p = f.flatMap((e) => {
|
|
72
|
+
if (e.nodeType === Node.TEXT_NODE && !(e.textContent || "").trim()) return [];
|
|
73
|
+
let t = l(e, n + 1);
|
|
74
|
+
return t ? [t] : [];
|
|
75
|
+
});
|
|
76
|
+
return p.length ? `${o(n)}${d}\n${p.join("\n")}\n${o(n)}</${u}>` : `${o(n)}${d}</${u}>`;
|
|
77
|
+
};
|
|
78
|
+
return Array.from(r.content.childNodes).map((e) => l(e, 0)).filter(Boolean).join("\n");
|
|
79
|
+
}
|
|
80
|
+
function i(e) {
|
|
34
81
|
return e.replace(/\r\n?/g, "\n").split(/\n{2,}/).map((e) => {
|
|
35
82
|
let n = e.trim();
|
|
36
83
|
if (!n) return "";
|
|
37
|
-
let
|
|
38
|
-
if (
|
|
39
|
-
let
|
|
40
|
-
if (
|
|
41
|
-
if (/^>\s?/.test(n)) return `<blockquote><p>${
|
|
84
|
+
let r = n.match(/^```(\w*)\n([\s\S]*?)\n```$/);
|
|
85
|
+
if (r) return `<pre><code${r[1] ? ` class=\"language-${t(r[1])}\"` : ""}>${t(r[2])}</code></pre>`;
|
|
86
|
+
let i = n.match(/^(#{1,6})\s+([\s\S]+)$/);
|
|
87
|
+
if (i) return `<h${i[1].length}>${a(i[2])}</h${i[1].length}>`;
|
|
88
|
+
if (/^>\s?/.test(n)) return `<blockquote><p>${a(n.replace(/^>\s?/gm, "").replace(/\n/g, " "))}</p></blockquote>`;
|
|
42
89
|
let o = n.split("\n").map((e) => e.trim()).filter(Boolean);
|
|
43
90
|
if (o.length >= 2 && /^\|?\s*:?-{3,}/.test(o[1]) && o[0].includes("|")) {
|
|
44
91
|
let e = [o[0], ...o.slice(2)].map((e) => e.replace(/^\|/, "").replace(/\|$/, "").split("|").map((e) => e.trim()));
|
|
45
|
-
return `<table><thead><tr>${(e.shift() || []).map((e) => `<th>${
|
|
92
|
+
return `<table><thead><tr>${(e.shift() || []).map((e) => `<th>${a(e)}</th>`).join("")}</tr></thead><tbody>${e.map((e) => `<tr>${e.map((e) => `<td>${a(e)}</td>`).join("")}</tr>`).join("")}</tbody></table>`;
|
|
46
93
|
}
|
|
47
94
|
if (/^[-*+]\s+\[[ xX]\]\s/.test(n)) return `<ul data-mint-task-list="true">${n.split("\n").map((e) => {
|
|
48
95
|
let t = e.match(/^[-*+]\s+\[([ xX])\]\s+(.*)$/);
|
|
49
|
-
return t ? `<li><input type="checkbox"${t[1].toLowerCase() === "x" ? " checked" : ""} contenteditable="false"><span>${
|
|
96
|
+
return t ? `<li><input type="checkbox"${t[1].toLowerCase() === "x" ? " checked" : ""} contenteditable="false"><span>${a(t[2])}</span></li>` : "";
|
|
50
97
|
}).join("")}</ul>`;
|
|
51
98
|
if (/^([-*+]\s|\d+\.\s)/.test(n)) {
|
|
52
99
|
let e = n.split("\n"), t = /^\d+\./.test(e[0]);
|
|
53
|
-
return `<${t ? "ol" : "ul"}>${e.map((e) => `<li>${
|
|
100
|
+
return `<${t ? "ol" : "ul"}>${e.map((e) => `<li>${a(e.replace(/^(?:[-*+]\s|\d+\.\s)/, ""))}</li>`).join("")}</${t ? "ol" : "ul"}>`;
|
|
54
101
|
}
|
|
55
|
-
return `<p>${
|
|
102
|
+
return `<p>${a(n.replace(/\n/g, " "))}</p>`;
|
|
56
103
|
}).join("");
|
|
57
104
|
}
|
|
58
|
-
function
|
|
105
|
+
function a(e) {
|
|
59
106
|
return t(e).replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/__(.+?)__/g, "<strong>$1</strong>").replace(/\*(.+?)\*/g, "<em>$1</em>").replace(/_(.+?)_/g, "<em>$1</em>").replace(/~~(.+?)~~/g, "<s>$1</s>").replace(/!\[([^\]]*)\]\(([^)]+)\)/g, "<img alt=\"$1\" src=\"$2\">").replace(/\[([^\]]+)\]\(([^)]+)\)/g, "<a href=\"$2\">$1</a>");
|
|
60
107
|
}
|
|
61
|
-
function
|
|
108
|
+
function o(e) {
|
|
62
109
|
let t = (e) => {
|
|
63
110
|
if (e.nodeType === Node.TEXT_NODE) return e.textContent || "";
|
|
64
111
|
if (e.nodeType !== Node.ELEMENT_NODE) return "";
|
|
@@ -89,9 +136,9 @@ function i(e) {
|
|
|
89
136
|
};
|
|
90
137
|
return Array.from(e.childNodes).map(t).join("").trim();
|
|
91
138
|
}
|
|
92
|
-
var
|
|
139
|
+
var s = class extends HTMLElement {
|
|
93
140
|
constructor(...e) {
|
|
94
|
-
super(...e), this.editor = null, this.editorFrame = null, this.pendingValue = null, this.preservedContent = null, this.source = null, this.toolbar = null, this.count = null, this.selectedImage = null, this.sourceMode = !1, this.observer = null, this.frameResizeObserver = null, this.resizeState = null, this.stageResizeState = null, this.editorHeight = null, this.sourceButton = null, this.blockButton = null, this.blockPopover = null, this.tablePopover = null, this.tableTrigger = null, this.selectedTableElement = null, this.inlineTableTools = null, this.tableResizeHandle = null, this.tableResizeState = null, this.gridResizeState = null, this.footerMode = null, this.inlineButtons = /* @__PURE__ */ new Map(), this.inlineOverrides = /* @__PURE__ */ new Map(), this.inlineStyleOverrides = /* @__PURE__ */ new Map(), this.preserveInlineOverridesOnNextEditorClick = !1, this.toolbarResizeObserver = null, this.overflowPopover = null, this.overflowTrigger = null, this.overflowGroups = [], this.tooltipPopup = null, this.fontSizeDisplay = null, this.lastTextColor = "#202833", this.lastBackgroundColor = "#fff2a8", this.colorTriggers = /* @__PURE__ */ new Map(), this.colorRecentSwatches = /* @__PURE__ */ new Map(), this.alignmentTrigger = null, this.onStageResizeStart = (e, t) => {
|
|
141
|
+
super(...e), this.editor = null, this.editorFrame = null, this.pendingValue = null, this.preservedContent = null, this.history = [], this.historyIndex = -1, this.applyingHistory = !1, this.historyTransactionDepth = 0, this.historyTransactionPending = !1, this.undoButton = null, this.redoButton = null, this.source = null, this.toolbar = null, this.count = null, this.selectedImage = null, this.sourceMode = !1, this.observer = null, this.frameResizeObserver = null, this.resizeState = null, this.stageResizeState = null, this.editorHeight = null, this.sourceButton = null, this.blockButton = null, this.blockPopover = null, this.tablePopover = null, this.tableTrigger = null, this.selectedTableElement = null, this.inlineTableTools = null, this.tableResizeHandle = null, this.tableResizeState = null, this.gridResizeState = null, this.footerMode = null, this.inlineButtons = /* @__PURE__ */ new Map(), this.inlineOverrides = /* @__PURE__ */ new Map(), this.inlineStyleOverrides = /* @__PURE__ */ new Map(), this.preserveInlineOverridesOnNextEditorClick = !1, this.toolbarResizeObserver = null, this.overflowPopover = null, this.overflowTrigger = null, this.overflowGroups = [], this.tooltipPopup = null, this.fontSizeDisplay = null, this.lastTextColor = "#202833", this.lastBackgroundColor = "#fff2a8", this.colorTriggers = /* @__PURE__ */ new Map(), this.colorRecentSwatches = /* @__PURE__ */ new Map(), this.alignmentTrigger = null, this.onStageResizeStart = (e, t) => {
|
|
95
142
|
if (e.button !== 0) return;
|
|
96
143
|
e.preventDefault(), e.stopPropagation(), this.stageResizeState = {
|
|
97
144
|
stage: t,
|
|
@@ -167,14 +214,14 @@ var a = class extends HTMLElement {
|
|
|
167
214
|
let e = this.editor?.ownerDocument.defaultView;
|
|
168
215
|
e?.removeEventListener("pointermove", this.onGridResizeMove), e?.removeEventListener("pointerup", this.onGridResizeEnd), this.removeStageResizeListeners();
|
|
169
216
|
}
|
|
170
|
-
attributeChangedCallback(e, t,
|
|
217
|
+
attributeChangedCallback(e, t, n) {
|
|
171
218
|
if (this.isConnected) {
|
|
172
219
|
if (e === "format") {
|
|
173
|
-
t !==
|
|
220
|
+
t !== n && (this.updateFormatUI(), this.sourceMode && this.source && this.editor ? this.editor.innerHTML = n === "markdown" ? i(this.source.value) : this.source.value : n === "markdown" && t !== "markdown" && this.editor && (this.editor.innerHTML = i(this.editor.innerHTML)), this.syncSource());
|
|
174
221
|
return;
|
|
175
222
|
}
|
|
176
223
|
if (e === "value") {
|
|
177
|
-
this.setValue(
|
|
224
|
+
this.setValue(n || "");
|
|
178
225
|
return;
|
|
179
226
|
}
|
|
180
227
|
e === "height" && (this.editorHeight = null), this.render();
|
|
@@ -190,17 +237,21 @@ var a = class extends HTMLElement {
|
|
|
190
237
|
if (this.sourceMode && this.source) return this.source.value;
|
|
191
238
|
if (!this.editor) return "";
|
|
192
239
|
let e = this.cleanEditorCopy();
|
|
193
|
-
return this.format === "markdown" ?
|
|
240
|
+
return this.format === "markdown" ? o(e) : e.innerHTML;
|
|
194
241
|
}
|
|
195
242
|
set value(e) {
|
|
196
243
|
this.setValue(e || "");
|
|
197
244
|
}
|
|
198
245
|
setValue(e) {
|
|
199
246
|
if (!this.editor) {
|
|
200
|
-
this.pendingValue = e, this.preservedContent = e, this.getAttribute("value") !== e && this.setAttribute("value", e);
|
|
247
|
+
this.pendingValue = e, this.preservedContent = e, this.history = [], this.historyIndex = -1, this.updateHistoryButtons(), this.getAttribute("value") !== e && this.setAttribute("value", e);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (this.value === e) {
|
|
251
|
+
this.source && (this.source.value = e), this.updateHistoryButtons();
|
|
201
252
|
return;
|
|
202
253
|
}
|
|
203
|
-
this.editor.innerHTML = this.format === "markdown" ?
|
|
254
|
+
this.editor.innerHTML = this.format === "markdown" ? i(e) : e, this.preservedContent = e, this.clearInlineTypingState(), this.source && (this.source.value = e), this.updateWordCount(), this.resetHistory();
|
|
204
255
|
}
|
|
205
256
|
insertResource(e) {
|
|
206
257
|
let t = typeof e == "string" ? { url: e } : e, n = t.url || t.src;
|
|
@@ -218,9 +269,9 @@ var a = class extends HTMLElement {
|
|
|
218
269
|
this.selectImage(i), this.emitChange();
|
|
219
270
|
}
|
|
220
271
|
render() {
|
|
221
|
-
let e = this.getAttribute("value"),
|
|
222
|
-
this.editor ? this.preservedContent = this.format === "markdown" && this.source ? this.source.value : this.editor.innerHTML : this.pendingValue === null ? e === null ? this.preservedContent === null && (this.preservedContent =
|
|
223
|
-
let
|
|
272
|
+
let e = this.getAttribute("value"), n = this.editor?.innerHTML ?? this.pendingValue ?? e ?? this.preservedContent ?? this.innerHTML;
|
|
273
|
+
this.editor ? this.preservedContent = this.format === "markdown" && this.source ? this.source.value : this.editor.innerHTML : this.pendingValue === null ? e === null ? this.preservedContent === null && (this.preservedContent = n) : this.preservedContent = e : this.preservedContent = this.pendingValue;
|
|
274
|
+
let r = this.editor ? n : this.format === "markdown" ? i(n) : n;
|
|
224
275
|
this.observer?.disconnect(), this.inlineButtons.clear(), this.colorTriggers.clear(), this.colorRecentSwatches.clear(), this.clearInlineTypingState(), this.editor = null, this.selectedImage = null;
|
|
225
276
|
let a = this.hasAttribute("disabled") && this.getAttribute("disabled") !== "false", o = this.editorHeight === null ? this.getAttribute("height") || "300px" : `${this.editorHeight}px`, s = this.getAttribute("label") || "";
|
|
226
277
|
this.innerHTML = "";
|
|
@@ -252,7 +303,7 @@ var a = class extends HTMLElement {
|
|
|
252
303
|
let f = document.createElement("button");
|
|
253
304
|
f.type = "button", f.className = "mint-editor-table-resize-handle", this.setTooltip(f, "Resize table"), f.addEventListener("pointerdown", (e) => this.startTableResize(e)), this.inlineTableTools = d, this.tableResizeHandle = f;
|
|
254
305
|
let p = document.createElement("iframe");
|
|
255
|
-
p.className = "mint-editor-frame", p.title = s ? `${s} editor` : "Rich text editor", p.setAttribute("sandbox", "allow-same-origin"), p.style.height = "100%", p.srcdoc = `<!doctype html><html><head><meta charset="utf-8"><style>
|
|
306
|
+
p.className = "mint-editor-frame", p.title = s ? `${s} editor` : "Rich text editor", p.setAttribute("sandbox", "allow-same-origin allow-popups allow-popups-to-escape-sandbox"), p.style.height = "100%", p.srcdoc = `<!doctype html><html><head><meta charset="utf-8"><style>
|
|
256
307
|
html,body{box-sizing:border-box;width:100%;height:100%;min-width:0;margin:0;overflow:hidden}
|
|
257
308
|
.editor{box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;overflow:auto;overflow-wrap:anywhere;padding:1rem;outline:0;color:var(--mint-color-text,#202833);background:var(--mint-color-surface,#fff);font:inherit;line-height:1.55}
|
|
258
309
|
.editor:empty:before{content:attr(data-placeholder);color:var(--mint-color-text-muted,#7b8492);pointer-events:none}
|
|
@@ -261,17 +312,16 @@ var a = class extends HTMLElement {
|
|
|
261
312
|
.editor :where(p,ul,ol,blockquote,table){max-width:100%;overflow-wrap:anywhere;margin:.65em 0}.editor a{color:var(--mint-color-primary,#1e5bff);text-decoration:underline}
|
|
262
313
|
.editor table{width:100%;border-collapse:collapse;table-layout:fixed}.editor table.is-selected{outline:2px solid var(--mint-color-primary,#1e5bff);outline-offset:2px}.editor :where(td,th){box-sizing:border-box;min-width:3rem;max-width:none;overflow-wrap:anywhere;padding:.5rem;border:1px solid var(--mint-color-border,#dfe3e9);text-align:left;vertical-align:top}.editor th{background:var(--mint-color-surface-subtle,#f8f9fb);font-weight:600}
|
|
263
314
|
.editor ul[data-mint-task-list]{padding-left:1.6rem;list-style:none}.editor ul[data-mint-task-list] li{display:flex;align-items:flex-start;gap:.5rem}.editor ul[data-mint-task-list] input[type=checkbox]{flex:0 0 auto;margin:.45em 0 0;accent-color:var(--mint-color-primary,#1e5bff)}
|
|
264
|
-
.editor .mint-editor-comment{border-radius:.15rem;background:rgb(255 224 130 / 45%);box-shadow:0 1px 0 rgb(198 120 0 / 65%);cursor:help}
|
|
265
315
|
.mint-editor-image-frame{position:relative;display:inline-block;max-width:100%;margin:.5rem 0;vertical-align:middle}.mint-editor-image-frame img{display:block;width:100%;height:auto;max-height:none;border-radius:.25rem;object-fit:contain}.mint-editor-image-frame.is-selected{outline:2px solid var(--mint-color-primary,#1e5bff);outline-offset:2px}
|
|
266
316
|
.mint-editor-resize-handle{position:absolute;right:-.45rem;bottom:-.45rem;width:.9rem;height:.9rem;padding:0;border:2px solid var(--mint-color-surface,#fff);border-radius:50%;background:var(--mint-color-primary,#1e5bff);cursor:nwse-resize;touch-action:none}
|
|
267
317
|
@media(max-width:640px){.editor{padding:.75rem}}
|
|
268
318
|
</style></head><body><div class="editor" contenteditable="${!a}" role="textbox" aria-multiline="true" aria-label="${t(s || "Rich text editor")}" data-placeholder="${t(this.getAttribute("placeholder") || "Start writing…")}"></div></body></html>`, p.addEventListener("load", () => {
|
|
269
|
-
!this.isConnected || this.editorFrame !== p || this.bindEditorFrame(
|
|
319
|
+
!this.isConnected || this.editorFrame !== p || this.bindEditorFrame(r, a);
|
|
270
320
|
}), this.editorFrame = p;
|
|
271
321
|
let m = document.createElement("textarea");
|
|
272
|
-
m.className = "mint-editor-source", m.style.height = "100%", m.setAttribute("aria-label", `Editor ${this.format.toUpperCase()} source`), m.hidden = !0, m.value = this.format === "markdown" ?
|
|
273
|
-
this.editor && (this.editor.innerHTML = this.format === "markdown" ?
|
|
274
|
-
}), this.source = m;
|
|
322
|
+
m.className = "mint-editor-source", m.style.height = "100%", m.setAttribute("aria-label", `Editor ${this.format.toUpperCase()} source`), m.hidden = !0, m.value = this.format === "markdown" ? n : r, m.addEventListener("input", (e) => {
|
|
323
|
+
this.editor && (this.editor.innerHTML = this.format === "markdown" ? i(m.value) : m.value), this.updateWordCount(), this.emitChange(e.inputType);
|
|
324
|
+
}), m.addEventListener("keydown", (e) => this.handleHistoryKeydown(e)), m.addEventListener("beforeinput", (e) => this.handleHistoryBeforeInput(e)), this.source = m;
|
|
275
325
|
let h = document.createElement("div");
|
|
276
326
|
h.className = "mint-editor-stage", h.style.height = o, h.append(p, m);
|
|
277
327
|
let g = null;
|
|
@@ -328,11 +378,11 @@ var a = class extends HTMLElement {
|
|
|
328
378
|
e?.removeEventListener("pointermove", this.onStageResizeMove), e?.removeEventListener("pointerup", this.onStageResizeEnd), e?.removeEventListener("pointercancel", this.onStageResizeEnd), this.stageResizeState = null;
|
|
329
379
|
}
|
|
330
380
|
bindEditorFrame(e, t) {
|
|
331
|
-
let
|
|
332
|
-
if (!
|
|
333
|
-
|
|
334
|
-
let a = getComputedStyle(this), o =
|
|
335
|
-
o.style.font = a.font, o.style.color = a.color, o.style.background = a.backgroundColor, getComputedStyle(
|
|
381
|
+
let n = this.editorFrame?.contentDocument, r = n?.querySelector(".editor");
|
|
382
|
+
if (!n || !r) return;
|
|
383
|
+
r.contentEditable = String(!t), r.innerHTML = this.pendingValue === null ? e : this.format === "markdown" ? i(this.pendingValue) : this.pendingValue, this.pendingValue = null;
|
|
384
|
+
let a = getComputedStyle(this), o = n.body;
|
|
385
|
+
o.style.font = a.font, o.style.color = a.color, o.style.background = a.backgroundColor, getComputedStyle(r), r.style.font = a.font, r.style.background = a.backgroundColor, [
|
|
336
386
|
"text",
|
|
337
387
|
"text-muted",
|
|
338
388
|
"surface",
|
|
@@ -342,19 +392,20 @@ var a = class extends HTMLElement {
|
|
|
342
392
|
"focus"
|
|
343
393
|
].forEach((e) => {
|
|
344
394
|
let t = a.getPropertyValue(`--mint-color-${e}`).trim();
|
|
345
|
-
t &&
|
|
346
|
-
}), this.editor =
|
|
347
|
-
this.normalizeTaskListItems(), this.
|
|
348
|
-
}),
|
|
395
|
+
t && r.style.setProperty(`--mint-color-${e}`, t);
|
|
396
|
+
}), this.editor = r, r.addEventListener("input", (e) => {
|
|
397
|
+
this.normalizeTaskListItems(), this.emitChange(e.inputType), this.updateSelectionUI();
|
|
398
|
+
}), r.addEventListener("keydown", (e) => this.handleHistoryKeydown(e)), r.addEventListener("change", (e) => {
|
|
349
399
|
let t = e.target;
|
|
350
400
|
t.matches("ul[data-mint-task-list] input[type=\"checkbox\"]") && (t.toggleAttribute("checked", t.checked), this.emitChange());
|
|
351
|
-
}),
|
|
401
|
+
}), r.addEventListener("paste", (e) => {
|
|
352
402
|
let t = e.clipboardData?.getData("text/html") || "";
|
|
353
403
|
if (!t || !this.editor?.contains(this.selection?.anchorNode || null)) return;
|
|
354
404
|
let n = this.sanitizePastedHtml(t);
|
|
355
405
|
n && (e.preventDefault(), this.clearInlineTypingState(), this.insertPastedHtml(n), this.normalizeTaskListItems(), this.emitChange(), this.updateSelectionUI());
|
|
356
|
-
}),
|
|
406
|
+
}), r.addEventListener("beforeinput", (e) => {
|
|
357
407
|
let t = e;
|
|
408
|
+
if (this.handleHistoryBeforeInput(t)) return;
|
|
358
409
|
t.inputType.startsWith("insert") && (this.preserveInlineOverridesOnNextEditorClick = !1);
|
|
359
410
|
let n = t.shiftKey;
|
|
360
411
|
if ((t.inputType === "insertParagraph" || t.inputType === "insertLineBreak" && !n) && !t.isComposing) {
|
|
@@ -365,7 +416,7 @@ var a = class extends HTMLElement {
|
|
|
365
416
|
}
|
|
366
417
|
}
|
|
367
418
|
this.applyInlineTypingState(t);
|
|
368
|
-
}),
|
|
419
|
+
}), r.addEventListener("keyup", (e) => {
|
|
369
420
|
[
|
|
370
421
|
"ArrowLeft",
|
|
371
422
|
"ArrowRight",
|
|
@@ -376,15 +427,26 @@ var a = class extends HTMLElement {
|
|
|
376
427
|
"PageUp",
|
|
377
428
|
"PageDown"
|
|
378
429
|
].includes(e.key) && this.clearInlineTypingState(), this.updateSelectedImage(), this.updateSelectionUI();
|
|
379
|
-
}),
|
|
430
|
+
}), r.addEventListener("mouseup", () => {
|
|
380
431
|
this.updateSelectedImage(), this.updateSelectionUI();
|
|
381
|
-
}),
|
|
432
|
+
}), n.addEventListener("selectionchange", () => this.updateSelectionUI()), n.addEventListener("pointerover", (e) => {
|
|
433
|
+
let t = e.target;
|
|
434
|
+
if (!t || t.nodeType !== Node.ELEMENT_NODE) return;
|
|
435
|
+
let n = t.closest("a[href]"), r = e.relatedTarget;
|
|
436
|
+
!n || r && r.nodeType && n.contains(r) || (this.bindEditorLinkTooltip(n), this.showTooltip(n));
|
|
437
|
+
}), r.addEventListener("scroll", () => this.positionTableTools()), r.addEventListener("pointermove", (e) => this.updateGridResizeCursor(e)), n.addEventListener("pointerdown", (e) => this.startGridResize(e), !0), r.addEventListener("click", (e) => {
|
|
382
438
|
this.closeEditorPopovers(), this.preserveInlineOverridesOnNextEditorClick ? this.preserveInlineOverridesOnNextEditorClick = !1 : this.clearInlineTypingState();
|
|
383
439
|
let t = e.target, n = t.closest(".mint-editor-image-frame");
|
|
384
440
|
n ? this.selectImage(n) : t.closest(".mint-editor-image-tools") || this.selectImage(null);
|
|
385
441
|
let r = t.closest("table");
|
|
386
|
-
this.selectTable(r)
|
|
387
|
-
|
|
442
|
+
this.selectTable(r);
|
|
443
|
+
let i = t.closest("a[href]");
|
|
444
|
+
if (i) if (e.preventDefault(), this.isOpenLinkModifier(e)) this.openEditorLink(i, "new-tab");
|
|
445
|
+
else {
|
|
446
|
+
let e = i.getAttribute("data-mint-editor-open");
|
|
447
|
+
e && e !== "same-tab" && this.openEditorLink(i, e);
|
|
448
|
+
}
|
|
449
|
+
}), r.addEventListener("keydown", (e) => {
|
|
388
450
|
if (e.key === "Enter" && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey && !e.isComposing) {
|
|
389
451
|
let t = this.selection, n = t?.anchorNode, r = (n?.nodeType === Node.ELEMENT_NODE ? n : n?.parentElement)?.closest("li"), i = r?.parentElement;
|
|
390
452
|
if (t?.isCollapsed && r && i?.tagName === "UL" && i.hasAttribute("data-mint-task-list") && this.editor?.contains(r)) {
|
|
@@ -393,26 +455,26 @@ var a = class extends HTMLElement {
|
|
|
393
455
|
}
|
|
394
456
|
}
|
|
395
457
|
(e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "b" && (e.preventDefault(), this.toggleInline("bold")), (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "i" && (e.preventDefault(), this.toggleInline("italic")), (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "u" && (e.preventDefault(), this.toggleInline("underline"));
|
|
396
|
-
}), this.observer && this.observer.observe(
|
|
458
|
+
}), this.observer && this.observer.observe(r, {
|
|
397
459
|
childList: !0,
|
|
398
460
|
subtree: !0,
|
|
399
461
|
characterData: !0
|
|
400
|
-
}), this.updateWordCount(), this.updateSelectionUI();
|
|
462
|
+
}), this.updateWordCount(), this.updateSelectionUI(), this.history.length === 0 ? this.resetHistory() : this.updateHistoryButtons();
|
|
401
463
|
}
|
|
402
464
|
buildToolbar(e) {
|
|
403
465
|
let t = (t, n, r, i = e) => {
|
|
404
466
|
let a = document.createElement("button");
|
|
405
467
|
return a.type = "button", a.className = `mint-editor-tool-button mint-editor-toolbar-${n}`, this.setTooltip(a, t), a.append(this.icon(n)), a.addEventListener("pointerdown", () => this.saveSelection()), a.addEventListener("click", (e) => {
|
|
406
|
-
e.preventDefault(), r
|
|
468
|
+
e.preventDefault(), this.runHistoryTransaction(r);
|
|
407
469
|
}), i.append(a), a;
|
|
408
470
|
}, n = (e, t, n) => {
|
|
409
471
|
let r = document.createElement("mint-popover");
|
|
410
472
|
return r.id = `${e.id}-menu`, r.setAttribute("trigger-id", e.id), r.setAttribute("padding", "0.25rem"), r.setAttribute("direction", "down"), r.className = `mint-editor-menu-popover ${t}`, n.append(r), r;
|
|
411
473
|
}, r = (e, t, n, r) => {
|
|
412
474
|
let i = this.createMenuOption(t, n);
|
|
413
|
-
return i.addEventListener("click", r), e.append(i), i;
|
|
475
|
+
return i.addEventListener("click", () => this.runHistoryTransaction(r)), e.append(i), i;
|
|
414
476
|
};
|
|
415
|
-
t("Undo", "undo", () => this.
|
|
477
|
+
this.undoButton = t("Undo", "undo", () => this.undo()), this.redoButton = t("Redo", "redo", () => this.redo()), this.updateHistoryButtons();
|
|
416
478
|
let i = document.createElement("button");
|
|
417
479
|
i.type = "button", i.className = "mint-editor-tool-button mint-editor-block-trigger", this.setTooltip(i, "Text style"), i.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-block-trigger`;
|
|
418
480
|
let a = document.createElement("span");
|
|
@@ -463,7 +525,9 @@ var a = class extends HTMLElement {
|
|
|
463
525
|
l.textContent = "16px", c.append(l, this.icon("caret-down")), c.addEventListener("pointerdown", () => this.saveSelection()), s.append(c), t("Increase font size", "plus", () => this.applyFontSize(this.readFontSize() + 1), s), this.fontSizeDisplay = l;
|
|
464
526
|
let u = document.createElement("div");
|
|
465
527
|
u.className = "mint-editor-toolbar-actions", e.append(u), u.append(s);
|
|
466
|
-
let d = n(c, "mint-editor-font-size-popover", u), f =
|
|
528
|
+
let d = n(c, "mint-editor-font-size-popover", u), f = document.createElement("mint-scroll-fade");
|
|
529
|
+
f.className = "mint-editor-font-size-options", f.setAttribute("axis", "vertical"), f.setAttribute("fade-size", "1rem"), d.append(f);
|
|
530
|
+
let p = [[s, d]];
|
|
467
531
|
[
|
|
468
532
|
8,
|
|
469
533
|
9,
|
|
@@ -484,44 +548,44 @@ var a = class extends HTMLElement {
|
|
|
484
548
|
let t = document.createElement("button");
|
|
485
549
|
t.type = "button", t.className = "mint-editor-menu-option mint-editor-font-size-option", t.textContent = `${e}px`, t.addEventListener("click", () => {
|
|
486
550
|
this.applyFontSize(e), d.close();
|
|
487
|
-
}),
|
|
551
|
+
}), f.append(t);
|
|
488
552
|
});
|
|
489
|
-
let
|
|
553
|
+
let m = (e, n, r) => {
|
|
490
554
|
let i = t(e, n, r, u);
|
|
491
555
|
return [
|
|
492
556
|
"bold",
|
|
493
557
|
"italic",
|
|
494
558
|
"underline"
|
|
495
559
|
].includes(n) && (i.setAttribute("aria-pressed", "false"), this.inlineButtons.set(n, i)), i;
|
|
496
|
-
},
|
|
560
|
+
}, h = (e) => {
|
|
497
561
|
let t = e.querySelector(":scope > mint-icon");
|
|
498
562
|
if (!t) return;
|
|
499
563
|
let n = document.createElement("span");
|
|
500
564
|
n.className = "mint-editor-color-icon", e.insertBefore(n, t), n.append(t);
|
|
501
|
-
},
|
|
565
|
+
}, g = () => {
|
|
502
566
|
let e = this.separator();
|
|
503
|
-
return u.append(e),
|
|
504
|
-
},
|
|
505
|
-
|
|
506
|
-
let
|
|
507
|
-
u.append(
|
|
508
|
-
let
|
|
509
|
-
|
|
510
|
-
let
|
|
511
|
-
this.buildColorPopover(
|
|
512
|
-
let
|
|
513
|
-
|
|
514
|
-
let
|
|
515
|
-
this.buildColorPopover(
|
|
516
|
-
y,
|
|
567
|
+
return u.append(e), p.push([e]), e;
|
|
568
|
+
}, _ = m("Bold", "bold", () => this.toggleInline("bold")), v = m("Italic", "italic", () => this.toggleInline("italic")), y = m("Underline", "underline", () => this.toggleInline("underline"));
|
|
569
|
+
p.push([_], [v], [y]);
|
|
570
|
+
let b = this.separator();
|
|
571
|
+
u.append(b);
|
|
572
|
+
let x = m("Text color", "text-color", () => {});
|
|
573
|
+
x.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-text-color-trigger`, x.append(this.icon("caret-down")), x.classList.add("mint-editor-color-trigger"), h(x), x.style.setProperty("--editor-color", this.lastTextColor);
|
|
574
|
+
let S = n(x, "mint-editor-color-popover", u);
|
|
575
|
+
this.buildColorPopover(S, "text", x), this.colorTriggers.set("text", x);
|
|
576
|
+
let C = m("Highlight color", "highlight", () => {});
|
|
577
|
+
C.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-highlight-trigger`, C.append(this.icon("caret-down")), C.classList.add("mint-editor-color-trigger"), h(C), C.style.setProperty("--editor-color", this.lastBackgroundColor);
|
|
578
|
+
let w = n(C, "mint-editor-color-popover", u);
|
|
579
|
+
this.buildColorPopover(w, "background", C), this.colorTriggers.set("background", C), p.push([
|
|
517
580
|
b,
|
|
518
581
|
x,
|
|
519
582
|
S,
|
|
520
|
-
C
|
|
583
|
+
C,
|
|
584
|
+
w
|
|
521
585
|
]);
|
|
522
|
-
let
|
|
523
|
-
|
|
524
|
-
let
|
|
586
|
+
let T = m("Font family", "font-family", () => {});
|
|
587
|
+
T.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-font-family-trigger`, T.append(this.icon("caret-down"));
|
|
588
|
+
let E = n(T, "mint-editor-font-family-popover", u);
|
|
525
589
|
[
|
|
526
590
|
["Arial", "Arial, sans-serif"],
|
|
527
591
|
["Helvetica", "Helvetica, sans-serif"],
|
|
@@ -530,14 +594,14 @@ var a = class extends HTMLElement {
|
|
|
530
594
|
["Courier New", "\"Courier New\", monospace"],
|
|
531
595
|
["System UI", "system-ui, sans-serif"]
|
|
532
596
|
].forEach(([e, t]) => {
|
|
533
|
-
r(
|
|
534
|
-
this.applyFontFamily(t),
|
|
597
|
+
r(E, e, "font-family", () => {
|
|
598
|
+
this.applyFontFamily(t), E.close();
|
|
535
599
|
});
|
|
536
|
-
}),
|
|
537
|
-
let
|
|
538
|
-
|
|
539
|
-
let
|
|
540
|
-
this.tablePopover =
|
|
600
|
+
}), p.push([T, E]), g();
|
|
601
|
+
let D = m("Insert link", "link", () => this.openLinkModal()), O = m("Insert image", "image", () => this.requestResource()), k = m("Insert table", "table", () => this.openTableModal()), A = document.createElement("button");
|
|
602
|
+
A.type = "button", A.className = "mint-editor-tool-button", this.setTooltip(A, "Table options"), A.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-table-trigger`, A.append(this.icon("caret-down")), A.hidden = !0, u.append(A);
|
|
603
|
+
let j = n(A, "", u);
|
|
604
|
+
this.tablePopover = j, [
|
|
541
605
|
["Add row below", "table-row"],
|
|
542
606
|
["Add column right", "table-column"],
|
|
543
607
|
["Delete row", "table-row-delete"],
|
|
@@ -546,16 +610,14 @@ var a = class extends HTMLElement {
|
|
|
546
610
|
].forEach(([e, t]) => {
|
|
547
611
|
let n = this.createMenuOption(e, t);
|
|
548
612
|
n.addEventListener("click", () => {
|
|
549
|
-
this.applyTableAction(e),
|
|
550
|
-
}),
|
|
551
|
-
}),
|
|
552
|
-
O,
|
|
613
|
+
this.applyTableAction(e), j.close();
|
|
614
|
+
}), j.append(n);
|
|
615
|
+
}), A.addEventListener("pointerdown", () => this.saveSelection()), this.tableTrigger = A, p.push([D], [O], [
|
|
553
616
|
k,
|
|
554
|
-
A
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
let M = p("Text alignment", "align-left", () => {});
|
|
617
|
+
A,
|
|
618
|
+
j
|
|
619
|
+
]), g();
|
|
620
|
+
let M = m("Text alignment", "align-left", () => {});
|
|
559
621
|
M.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-alignment-trigger`, M.append(this.icon("caret-down")), this.alignmentTrigger = M;
|
|
560
622
|
let N = n(M, "mint-editor-alignment-popover", u);
|
|
561
623
|
[
|
|
@@ -583,8 +645,8 @@ var a = class extends HTMLElement {
|
|
|
583
645
|
r(N, e, t, () => {
|
|
584
646
|
this.command(n), N.close(), this.updateTooltipLabel(M, `Text alignment: ${e}`);
|
|
585
647
|
});
|
|
586
|
-
}),
|
|
587
|
-
let P =
|
|
648
|
+
}), p.push([M, N]), g();
|
|
649
|
+
let P = m("Bulleted list", "list", () => this.command("insertUnorderedList")), F = document.createElement("button");
|
|
588
650
|
F.type = "button", F.className = "mint-editor-tool-button mint-editor-list-options-trigger", F.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-bullet-options-trigger`, this.setTooltip(F, "Bulleted list style"), F.append(this.icon("caret-down")), F.addEventListener("pointerdown", () => this.saveSelection()), u.append(F);
|
|
589
651
|
let I = n(F, "mint-editor-list-popover", u);
|
|
590
652
|
[
|
|
@@ -594,7 +656,7 @@ var a = class extends HTMLElement {
|
|
|
594
656
|
].forEach(([e, t]) => r(I, e, "list", () => {
|
|
595
657
|
this.applyListStyle("ul", t), I.close();
|
|
596
658
|
}));
|
|
597
|
-
let L =
|
|
659
|
+
let L = m("Numbered list", "numbered-list", () => this.command("insertOrderedList")), R = document.createElement("button");
|
|
598
660
|
R.type = "button", R.className = "mint-editor-tool-button mint-editor-list-options-trigger", R.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-numbered-options-trigger`, this.setTooltip(R, "Numbered list style"), R.append(this.icon("caret-down")), R.addEventListener("pointerdown", () => this.saveSelection()), u.append(R);
|
|
599
661
|
let z = n(R, "mint-editor-list-popover", u);
|
|
600
662
|
[
|
|
@@ -606,8 +668,8 @@ var a = class extends HTMLElement {
|
|
|
606
668
|
].forEach(([e, t]) => r(z, e, "numbered-list", () => {
|
|
607
669
|
this.applyListStyle("ol", t), z.close();
|
|
608
670
|
}));
|
|
609
|
-
let B =
|
|
610
|
-
|
|
671
|
+
let B = m("Checklist", "checklist", () => this.toggleChecklist());
|
|
672
|
+
p.push([
|
|
611
673
|
P,
|
|
612
674
|
F,
|
|
613
675
|
I
|
|
@@ -615,15 +677,15 @@ var a = class extends HTMLElement {
|
|
|
615
677
|
L,
|
|
616
678
|
R,
|
|
617
679
|
z
|
|
618
|
-
], [B]),
|
|
619
|
-
let V =
|
|
620
|
-
|
|
621
|
-
let H =
|
|
622
|
-
|
|
680
|
+
], [B]), g();
|
|
681
|
+
let V = m("HTML source", "code", () => this.toggleSource());
|
|
682
|
+
p.push([V]), this.sourceButton = e.querySelector(".mint-editor-toolbar-code");
|
|
683
|
+
let H = m("Clear formatting", "clear-formatting", () => this.clearFormatting());
|
|
684
|
+
p.push([H]);
|
|
623
685
|
let U = document.createElement("button");
|
|
624
686
|
U.type = "button", U.className = "mint-editor-tool-button mint-editor-overflow-trigger", this.setTooltip(U, "More formatting options"), U.id = `${this.id || `mint-editor-${Math.random().toString(36).slice(2)}`}-overflow-trigger`, U.append(this.icon("ellipsis"));
|
|
625
687
|
let W = document.createElement("mint-popover");
|
|
626
|
-
W.setAttribute("trigger-id", U.id), W.setAttribute("padding", "0.25rem"), W.setAttribute("direction", "down"), W.className = "mint-editor-menu-popover mint-editor-overflow-popover", e.append(U, W), this.overflowTrigger = U, this.overflowPopover = W, this.overflowGroups =
|
|
688
|
+
W.setAttribute("trigger-id", U.id), W.setAttribute("padding", "0.25rem"), W.setAttribute("direction", "down"), W.className = "mint-editor-menu-popover mint-editor-overflow-popover", e.append(U, W), this.overflowTrigger = U, this.overflowPopover = W, this.overflowGroups = p;
|
|
627
689
|
}
|
|
628
690
|
buildColorPopover(e, t, n) {
|
|
629
691
|
let r = [
|
|
@@ -694,7 +756,9 @@ var a = class extends HTMLElement {
|
|
|
694
756
|
this.inlineStyleOverrides.set(e === "text" ? "color" : "backgroundColor", i), this.preserveInlineOverridesOnNextEditorClick = !0, e === "text" && t && (this.lastTextColor = t), e === "background" && t && (this.lastBackgroundColor = t), this.colorTriggers.get(e)?.style.setProperty("--editor-color", e === "text" ? this.lastTextColor : this.lastBackgroundColor), this.emitChange(), this.updateSelectionUI();
|
|
695
757
|
return;
|
|
696
758
|
}
|
|
697
|
-
this.inlineStyleOverrides.delete(e === "text" ? "color" : "backgroundColor"),
|
|
759
|
+
this.inlineStyleOverrides.delete(e === "text" ? "color" : "backgroundColor"), this.runHistoryTransaction(() => {
|
|
760
|
+
e === "text" ? (n.execCommand("foreColor", !1, i), t && (this.lastTextColor = t), this.colorTriggers.get("text")?.style.setProperty("--editor-color", this.lastTextColor)) : (n.execCommand("hiliteColor", !1, i) || n.execCommand("backColor", !1, i), t && (this.lastBackgroundColor = t), this.colorTriggers.get("background")?.style.setProperty("--editor-color", this.lastBackgroundColor)), this.emitChange();
|
|
761
|
+
}), this.updateSelectionUI();
|
|
698
762
|
}
|
|
699
763
|
readFontSize() {
|
|
700
764
|
let e = this.selection, t = e?.isCollapsed ? Number.parseFloat(this.inlineStyleOverrides.get("fontSize") || "") : NaN;
|
|
@@ -711,58 +775,63 @@ var a = class extends HTMLElement {
|
|
|
711
775
|
this.inlineStyleOverrides.set("fontSize", `${t}px`), this.preserveInlineOverridesOnNextEditorClick = !0, this.emitChange(), this.updateSelectionUI();
|
|
712
776
|
return;
|
|
713
777
|
}
|
|
714
|
-
this.inlineStyleOverrides.delete("fontSize")
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
778
|
+
this.inlineStyleOverrides.delete("fontSize"), this.runHistoryTransaction(() => {
|
|
779
|
+
let e = new Set(Array.from(this.editor.querySelectorAll("font[size=\"7\"]")));
|
|
780
|
+
n.execCommand("fontSize", !1, "7"), this.editor.querySelectorAll("font[size=\"7\"]").forEach((r) => {
|
|
781
|
+
if (e.has(r)) return;
|
|
782
|
+
let i = n.createElement("span");
|
|
783
|
+
i.style.fontSize = `${t}px`, r.getAttribute("face") && (i.style.fontFamily = r.getAttribute("face") || ""), r.getAttribute("color") && (i.style.color = r.getAttribute("color") || ""), i.append(...Array.from(r.childNodes)), r.replaceWith(i);
|
|
784
|
+
}), this.emitChange();
|
|
785
|
+
}), this.updateSelectionUI();
|
|
721
786
|
}
|
|
722
787
|
applyFontFamily(e) {
|
|
723
|
-
if (!this.editor || this.sourceMode)
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
788
|
+
if (!(!this.editor || this.sourceMode)) {
|
|
789
|
+
if (this.editor.focus(), this.restoreSelection(), this.selection?.isCollapsed) {
|
|
790
|
+
this.inlineStyleOverrides.set("fontFamily", e), this.preserveInlineOverridesOnNextEditorClick = !0, this.emitChange(), this.updateSelectionUI();
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
this.inlineStyleOverrides.delete("fontFamily"), this.runHistoryTransaction(() => {
|
|
794
|
+
let t = this.editor.ownerDocument, n = new Set(Array.from(this.editor.querySelectorAll("font[face]")));
|
|
795
|
+
t.execCommand("fontName", !1, e), this.editor.querySelectorAll("font[face]").forEach((r) => {
|
|
796
|
+
if (n.has(r)) return;
|
|
797
|
+
let i = t.createElement("span");
|
|
798
|
+
i.style.fontFamily = r.getAttribute("face") || e, i.append(...Array.from(r.childNodes)), r.replaceWith(i);
|
|
799
|
+
}), this.emitChange();
|
|
800
|
+
}), this.updateSelectionUI();
|
|
727
801
|
}
|
|
728
|
-
this.inlineStyleOverrides.delete("fontFamily");
|
|
729
|
-
let t = this.editor.ownerDocument, n = new Set(Array.from(this.editor.querySelectorAll("font[face]")));
|
|
730
|
-
t.execCommand("fontName", !1, e), this.editor.querySelectorAll("font[face]").forEach((r) => {
|
|
731
|
-
if (n.has(r)) return;
|
|
732
|
-
let i = t.createElement("span");
|
|
733
|
-
i.style.fontFamily = r.getAttribute("face") || e, i.append(...Array.from(r.childNodes)), r.replaceWith(i);
|
|
734
|
-
}), this.emitChange(), this.updateSelectionUI();
|
|
735
802
|
}
|
|
736
803
|
applyListStyle(e, t) {
|
|
737
804
|
if (!this.editor || this.sourceMode) return;
|
|
738
805
|
this.editor.focus(), this.restoreSelection();
|
|
739
806
|
let n = this.selection?.anchorNode, r = (n?.nodeType === Node.ELEMENT_NODE ? n : n?.parentElement)?.closest(e), i = r && this.editor.contains(r) ? r : null;
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
807
|
+
this.runHistoryTransaction(() => {
|
|
808
|
+
if (!i) {
|
|
809
|
+
this.editor.ownerDocument.execCommand(e === "ul" ? "insertUnorderedList" : "insertOrderedList", !1);
|
|
810
|
+
let t = this.selection?.anchorNode, n = (t?.nodeType === Node.ELEMENT_NODE ? t : t?.parentElement)?.closest(e);
|
|
811
|
+
i = n && this.editor.contains(n) ? n : null;
|
|
812
|
+
}
|
|
813
|
+
i && (i.style.listStyleType = t), this.emitChange();
|
|
814
|
+
}), this.updateSelectionUI();
|
|
746
815
|
}
|
|
747
816
|
toggleChecklist() {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
817
|
+
!this.editor || this.sourceMode || (this.editor.focus(), this.restoreSelection(), this.runHistoryTransaction(() => {
|
|
818
|
+
let e = this.editor.ownerDocument, t = this.selection?.anchorNode, n = t?.nodeType === Node.ELEMENT_NODE ? t : t?.parentElement, r = n?.closest("ul[data-mint-task-list]"), i = n?.closest("ul");
|
|
819
|
+
if (r) r.removeAttribute("data-mint-task-list"), r.querySelectorAll("input[type=\"checkbox\"]").forEach((e) => e.remove());
|
|
820
|
+
else {
|
|
821
|
+
i || (n?.closest("h1,h2,h3,h4,h5,h6") && e.execCommand("formatBlock", !1, "p"), e.execCommand("insertUnorderedList", !1));
|
|
822
|
+
let t = this.selection?.anchorNode, r = t?.nodeType === Node.ELEMENT_NODE ? t : t?.parentElement, a = i || r?.closest("ul");
|
|
823
|
+
if (a && this.editor.contains(a)) {
|
|
824
|
+
a.setAttribute("data-mint-task-list", "true"), a.querySelectorAll("li").forEach((t, n) => {
|
|
825
|
+
if (t.querySelector("input[type=\"checkbox\"]")) return;
|
|
826
|
+
let r = e.createElement("input");
|
|
827
|
+
r.type = "checkbox", r.setAttribute("contenteditable", "false"), r.setAttribute("aria-label", `Task ${n + 1} complete`), t.insertBefore(r, t.firstChild);
|
|
828
|
+
});
|
|
829
|
+
let t = a.parentElement;
|
|
830
|
+
t && t !== this.editor && /^(P|H[1-6])$/.test(t.tagName) && t.parentElement === this.editor && (Array.from(t.childNodes).filter((e) => e === a ? !1 : e.nodeType === Node.TEXT_NODE ? !!e.textContent?.trim() : e.nodeType === Node.ELEMENT_NODE && !e.matches("br")).length === 0 ? t.replaceWith(a) : t.parentNode?.insertBefore(a, t.nextSibling));
|
|
831
|
+
}
|
|
763
832
|
}
|
|
764
|
-
|
|
765
|
-
|
|
833
|
+
this.emitChange();
|
|
834
|
+
}), this.updateSelectionUI());
|
|
766
835
|
}
|
|
767
836
|
splitTaskItem(e, t) {
|
|
768
837
|
if (!this.editor) return;
|
|
@@ -815,44 +884,6 @@ var a = class extends HTMLElement {
|
|
|
815
884
|
let a = this.selection, o = this.editor.ownerDocument.createRange();
|
|
816
885
|
o.setStart(i, 0), o.collapse(!0), a?.removeAllRanges(), a?.addRange(o), this.syncSource(), this.emitChange(), this.updateSelectionUI();
|
|
817
886
|
}
|
|
818
|
-
openCommentModal() {
|
|
819
|
-
this.saveSelection();
|
|
820
|
-
let e = this._savedRange?.toString() || "", t = document.createElement("mint-modal");
|
|
821
|
-
t.setAttribute("heading", "Add comment"), t.setAttribute("size", "small");
|
|
822
|
-
let n = document.createElement("div");
|
|
823
|
-
n.setAttribute("slot", "body"), n.className = "mint-editor-modal-fields";
|
|
824
|
-
let r = document.createElement("p");
|
|
825
|
-
r.className = "mint-editor-comment-hint", r.textContent = e ? `Comment on: “${e.slice(0, 120)}${e.length > 120 ? "…" : ""}”` : "Select some text in the document before adding a comment.";
|
|
826
|
-
let i = document.createElement("textarea");
|
|
827
|
-
i.className = "mint-editor-comment-input", i.setAttribute("aria-label", "Comment"), i.setAttribute("placeholder", "Write a comment…"), i.rows = 4, n.append(r, i);
|
|
828
|
-
let a = document.createElement("div");
|
|
829
|
-
a.setAttribute("slot", "actions"), a.className = "mint-editor-modal-actions";
|
|
830
|
-
let o = document.createElement("mint-button");
|
|
831
|
-
o.textContent = "Cancel", o.setAttribute("variant", "ghost"), this.setTooltip(o, "Cancel"), o.addEventListener("click", () => t.close());
|
|
832
|
-
let s = document.createElement("mint-button");
|
|
833
|
-
s.textContent = "Add comment", s.setAttribute("tone", "action"), s.toggleAttribute("disabled", !e), this.setTooltip(s, "Add comment"), s.addEventListener("click", () => {
|
|
834
|
-
let n = i.value.trim();
|
|
835
|
-
!n || !e || (this.insertComment(n, e), t.close());
|
|
836
|
-
}), a.append(o, s), t.append(n, a), this.append(t), t.open();
|
|
837
|
-
}
|
|
838
|
-
insertComment(e, t) {
|
|
839
|
-
let n = this._savedRange;
|
|
840
|
-
if (this.editor && n && !n.collapsed && this.editor.contains(n.commonAncestorContainer) && this.format === "html") {
|
|
841
|
-
let t = this.editor.ownerDocument.createElement("span");
|
|
842
|
-
t.className = "mint-editor-comment", t.setAttribute("data-mint-comment", e), t.title = `Comment: ${e}`, t.append(n.extractContents()), n.insertNode(t);
|
|
843
|
-
let r = this.selection;
|
|
844
|
-
n.selectNodeContents(t), r?.removeAllRanges(), r?.addRange(n);
|
|
845
|
-
}
|
|
846
|
-
this.dispatchEvent(new CustomEvent("mint-editor-comment-request", {
|
|
847
|
-
bubbles: !0,
|
|
848
|
-
composed: !0,
|
|
849
|
-
detail: {
|
|
850
|
-
selectedText: t,
|
|
851
|
-
comment: e,
|
|
852
|
-
format: this.format
|
|
853
|
-
}
|
|
854
|
-
})), this.emitChange();
|
|
855
|
-
}
|
|
856
887
|
updateToolbarOverflow() {
|
|
857
888
|
let e = this.toolbar, t = this.overflowTrigger, n = this.overflowPopover;
|
|
858
889
|
if (!e || !t || !n) return;
|
|
@@ -868,7 +899,9 @@ var a = class extends HTMLElement {
|
|
|
868
899
|
t.hidden = n.childElementCount === 0;
|
|
869
900
|
}
|
|
870
901
|
clearFormatting() {
|
|
871
|
-
!this.editor || this.sourceMode || (this.editor.focus(), this.restoreSelection(), this.
|
|
902
|
+
!this.editor || this.sourceMode || (this.editor.focus(), this.restoreSelection(), this.runHistoryTransaction(() => {
|
|
903
|
+
this.editor.ownerDocument.execCommand("removeFormat", !1), this.editor.ownerDocument.execCommand("formatBlock", !1, "p"), this.clearInlineTypingState(), this.emitChange();
|
|
904
|
+
}), this.updateSelectionUI());
|
|
872
905
|
}
|
|
873
906
|
icon(e) {
|
|
874
907
|
let t = document.createElement("mint-icon");
|
|
@@ -877,6 +910,48 @@ var a = class extends HTMLElement {
|
|
|
877
910
|
setTooltip(e, t) {
|
|
878
911
|
this.updateTooltipLabel(e, t), e.dataset.editorTooltipBound !== "true" && (e.dataset.editorTooltipBound = "true", e.addEventListener("pointerenter", () => this.showTooltip(e)), e.addEventListener("pointerleave", () => this.hideTooltip()), e.addEventListener("focus", () => this.showTooltip(e)), e.addEventListener("blur", () => this.hideTooltip()));
|
|
879
912
|
}
|
|
913
|
+
linkOpenModifier() {
|
|
914
|
+
let e = navigator.userAgentData?.platform || navigator.platform || "";
|
|
915
|
+
return /mac|iphone|ipad|ipod/i.test(e) ? "⌘" : "Ctrl";
|
|
916
|
+
}
|
|
917
|
+
isOpenLinkModifier(e) {
|
|
918
|
+
return this.linkOpenModifier() === "⌘" ? e.metaKey : e.ctrlKey;
|
|
919
|
+
}
|
|
920
|
+
openEditorLink(e, t) {
|
|
921
|
+
if (t === "same-tab") {
|
|
922
|
+
this.ownerDocument.defaultView?.location.assign(e.href);
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (t === "new-tab") {
|
|
926
|
+
window.open(e.href, "_blank", "noopener,noreferrer");
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
let n = t === "popup", r = n ? [
|
|
930
|
+
"popup=yes",
|
|
931
|
+
`width=${this.normalizePopupNumber(e.dataset.mintPopupWidth || "", 200, 4e3, "800")}`,
|
|
932
|
+
`height=${this.normalizePopupNumber(e.dataset.mintPopupHeight || "", 150, 4e3, "600")}`,
|
|
933
|
+
e.dataset.mintPopupLeft ? `left=${this.normalizePopupNumber(e.dataset.mintPopupLeft, 0, 1e4, "")}` : "",
|
|
934
|
+
e.dataset.mintPopupTop ? `top=${this.normalizePopupNumber(e.dataset.mintPopupTop, 0, 1e4, "")}` : "",
|
|
935
|
+
`resizable=${e.dataset.mintPopupResizable === "no" ? "no" : "yes"}`,
|
|
936
|
+
`scrollbars=${e.dataset.mintPopupScrollbars === "no" ? "no" : "yes"}`
|
|
937
|
+
].filter(Boolean).join(",") : "popup=no", i = n ? "mint-editor-popup" : "mint-editor-window", a = window.open(e.href, i, r);
|
|
938
|
+
if (!a) return;
|
|
939
|
+
try {
|
|
940
|
+
a.opener = null;
|
|
941
|
+
} catch {}
|
|
942
|
+
let o = e.dataset.mintPopupTitle?.trim();
|
|
943
|
+
if (n && o) {
|
|
944
|
+
let e = () => {
|
|
945
|
+
try {
|
|
946
|
+
a.document.title = o;
|
|
947
|
+
} catch {}
|
|
948
|
+
};
|
|
949
|
+
e(), a.addEventListener("load", e, { once: !0 });
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
bindEditorLinkTooltip(e) {
|
|
953
|
+
e.dataset.editorTooltipBound !== "true" && (e.dataset.editorTooltipBound = "true", e.setAttribute("data-editor-tooltip", `${this.linkOpenModifier()} + click to open`), e.addEventListener("pointerenter", () => this.showTooltip(e)), e.addEventListener("pointerleave", () => this.hideTooltip()), e.addEventListener("focus", () => this.showTooltip(e)), e.addEventListener("blur", () => this.hideTooltip()));
|
|
954
|
+
}
|
|
880
955
|
updateTooltipLabel(e, t) {
|
|
881
956
|
e.setAttribute("data-editor-tooltip", t);
|
|
882
957
|
let n = t.indexOf(":"), r = n < 0 ? t : `${t.slice(0, n + 1)}\n${t.slice(n + 1).trim()}`;
|
|
@@ -903,8 +978,23 @@ var a = class extends HTMLElement {
|
|
|
903
978
|
}), document.body.append(n), this.tooltipPopup = n;
|
|
904
979
|
}
|
|
905
980
|
n.textContent = t, n.setAttribute("aria-hidden", "false"), n.style.visibility = "hidden", n.style.display = "block";
|
|
906
|
-
let r = e.getBoundingClientRect(), i =
|
|
907
|
-
|
|
981
|
+
let r = e.getBoundingClientRect(), i = {
|
|
982
|
+
left: r.left,
|
|
983
|
+
top: r.top,
|
|
984
|
+
width: r.width,
|
|
985
|
+
bottom: r.bottom
|
|
986
|
+
}, a = e.ownerDocument.defaultView?.frameElement;
|
|
987
|
+
if (a) {
|
|
988
|
+
let e = a.getBoundingClientRect(), t = a.clientWidth ? e.width / a.clientWidth : 1, n = a.clientHeight ? e.height / a.clientHeight : 1;
|
|
989
|
+
i = {
|
|
990
|
+
left: e.left + r.left * t,
|
|
991
|
+
top: e.top + r.top * n,
|
|
992
|
+
width: r.width * t,
|
|
993
|
+
bottom: e.top + r.bottom * n
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
let o = n.getBoundingClientRect(), s = Math.max(8, Math.min(window.innerWidth - o.width - 8, i.left + i.width / 2 - o.width / 2)), c = i.top >= o.height + 6 + 8 ? i.top - o.height - 6 : Math.min(window.innerHeight - o.height - 8, i.bottom + 6);
|
|
997
|
+
n.style.left = `${s}px`, n.style.top = `${c}px`, n.style.visibility = "visible";
|
|
908
998
|
}
|
|
909
999
|
hideTooltip() {
|
|
910
1000
|
this.tooltipPopup && (this.tooltipPopup.style.display = "none", this.tooltipPopup.setAttribute("aria-hidden", "true"));
|
|
@@ -940,7 +1030,9 @@ var a = class extends HTMLElement {
|
|
|
940
1030
|
return e.className = "mint-editor-separator", e.setAttribute("aria-hidden", "true"), e;
|
|
941
1031
|
}
|
|
942
1032
|
command(e, t) {
|
|
943
|
-
!this.editor || this.sourceMode || (this.
|
|
1033
|
+
!this.editor || this.sourceMode || (this.runHistoryTransaction(() => {
|
|
1034
|
+
this.editor.focus(), this.restoreSelection(), this.editor.ownerDocument.execCommand(e, !1, t), this.clearInlineTypingState(), this.emitChange();
|
|
1035
|
+
}), this.updateSelectionUI());
|
|
944
1036
|
}
|
|
945
1037
|
toggleInline(e) {
|
|
946
1038
|
if (!this.editor || this.sourceMode) return;
|
|
@@ -952,7 +1044,9 @@ var a = class extends HTMLElement {
|
|
|
952
1044
|
this.inlineOverrides.set(e, r), this.preserveInlineOverridesOnNextEditorClick = !0, this.emitChange(), this.updateSelectionUI();
|
|
953
1045
|
return;
|
|
954
1046
|
}
|
|
955
|
-
this.
|
|
1047
|
+
this.runHistoryTransaction(() => {
|
|
1048
|
+
this.clearInlineTypingState(), i.execCommand(e, !1), this.emitChange();
|
|
1049
|
+
}), this.updateSelectionUI();
|
|
956
1050
|
}
|
|
957
1051
|
inlineStateAtSelection(e, t) {
|
|
958
1052
|
let n = this.selection, r = this.inlineOverrides.get(e);
|
|
@@ -1223,24 +1317,7 @@ var a = class extends HTMLElement {
|
|
|
1223
1317
|
e.replaceWith(...Array.from(e.childNodes));
|
|
1224
1318
|
};
|
|
1225
1319
|
for (let e of Array.from(i.querySelectorAll("*"))) e.tagName.includes(":") && l(e);
|
|
1226
|
-
let u = new Set(
|
|
1227
|
-
"href",
|
|
1228
|
-
"src",
|
|
1229
|
-
"alt",
|
|
1230
|
-
"title",
|
|
1231
|
-
"colspan",
|
|
1232
|
-
"rowspan",
|
|
1233
|
-
"start",
|
|
1234
|
-
"value",
|
|
1235
|
-
"type",
|
|
1236
|
-
"width",
|
|
1237
|
-
"height",
|
|
1238
|
-
"border",
|
|
1239
|
-
"cellpadding",
|
|
1240
|
-
"cellspacing",
|
|
1241
|
-
"scope",
|
|
1242
|
-
"dir"
|
|
1243
|
-
]), d = (e, t = !1) => {
|
|
1320
|
+
let u = new Set(/* @__PURE__ */ "href.src.alt.title.target.rel.data-mint-editor-open.data-mint-popup-title.data-mint-popup-width.data-mint-popup-height.data-mint-popup-left.data-mint-popup-top.data-mint-popup-resizable.data-mint-popup-scrollbars.colspan.rowspan.start.value.type.width.height.border.cellpadding.cellspacing.scope.dir".split(".")), d = (e, t = !1) => {
|
|
1244
1321
|
let n = e.trim();
|
|
1245
1322
|
if (/^#[-\w:.]+$/.test(n) || t && /^data:image\/(?:png|gif|jpe?g|webp);base64,/i.test(n)) return !0;
|
|
1246
1323
|
try {
|
|
@@ -1259,7 +1336,17 @@ var a = class extends HTMLElement {
|
|
|
1259
1336
|
if (n === "style") {
|
|
1260
1337
|
let n = o(t.value);
|
|
1261
1338
|
n ? e.setAttribute("style", n) : e.removeAttribute(t.name);
|
|
1262
|
-
} else u.has(n)
|
|
1339
|
+
} else if (!u.has(n)) e.removeAttribute(t.name);
|
|
1340
|
+
else if ((n === "href" || n === "src") && !d(t.value, n === "src")) e.removeAttribute(t.name);
|
|
1341
|
+
else if (n === "target" && !/^(_self|_blank|mint-editor-window|mint-editor-popup)$/i.test(t.value.trim())) e.removeAttribute(t.name);
|
|
1342
|
+
else if (n === "rel") {
|
|
1343
|
+
let n = t.value.toLowerCase().split(/\s+/).filter((e) => ["noopener", "noreferrer"].includes(e));
|
|
1344
|
+
n.length ? e.setAttribute("rel", Array.from(new Set(n)).join(" ")) : e.removeAttribute(t.name);
|
|
1345
|
+
} else if (n === "data-mint-editor-open" && !/^(same-tab|new-tab|new-window|popup)$/.test(t.value)) e.removeAttribute(t.name);
|
|
1346
|
+
else if (/^data-mint-popup-(width|height|left|top)$/.test(n)) {
|
|
1347
|
+
let r = Number.parseInt(t.value, 10), i = /width|height/.test(n) ? 150 : 0;
|
|
1348
|
+
!Number.isFinite(r) || r < i || r > 1e4 ? e.removeAttribute(t.name) : e.setAttribute(t.name, String(r));
|
|
1349
|
+
} else /^data-mint-popup-(resizable|scrollbars)$/.test(n) && !/^(yes|no)$/.test(t.value) ? e.removeAttribute(t.name) : n === "data-mint-popup-title" && t.value.length > 120 ? e.setAttribute(n, t.value.slice(0, 120)) : ([
|
|
1263
1350
|
"colspan",
|
|
1264
1351
|
"rowspan",
|
|
1265
1352
|
"start",
|
|
@@ -1269,20 +1356,34 @@ var a = class extends HTMLElement {
|
|
|
1269
1356
|
"border",
|
|
1270
1357
|
"cellpadding",
|
|
1271
1358
|
"cellspacing"
|
|
1272
|
-
].includes(n) && !/^\d+(?:%|px)?$/i.test(t.value.trim()) || n === "scope" && !/^(row|col|rowgroup|colgroup)$/i.test(t.value) || n === "dir" && !/^(ltr|rtl|auto)$/i.test(t.value) || n === "type" && !/^(1|a|A|i|I)$/i.test(t.value)) && e.removeAttribute(t.name)
|
|
1359
|
+
].includes(n) && !/^\d+(?:%|px)?$/i.test(t.value.trim()) || n === "scope" && !/^(row|col|rowgroup|colgroup)$/i.test(t.value) || n === "dir" && !/^(ltr|rtl|auto)$/i.test(t.value) || n === "type" && !/^(1|a|A|i|I)$/i.test(t.value)) && e.removeAttribute(t.name);
|
|
1273
1360
|
}
|
|
1274
1361
|
for (let e of Array.from(i.querySelectorAll("span"))) e.attributes.length || l(e);
|
|
1275
1362
|
return i.innerHTML.trim();
|
|
1276
1363
|
}
|
|
1277
1364
|
syncSource() {
|
|
1278
1365
|
if (this.source && this.editor) {
|
|
1279
|
-
let e = this.cleanEditorCopy();
|
|
1280
|
-
this.source.value = this.
|
|
1366
|
+
let e = this.cleanEditorCopy(), t = this.format === "markdown" ? o(e) : e.innerHTML;
|
|
1367
|
+
this.sourceMode || (this.source.value = t), this.preservedContent = this.sourceMode && this.source ? this.source.value : this.format === "markdown" ? t : this.editor.innerHTML;
|
|
1281
1368
|
}
|
|
1282
1369
|
this.updateWordCount();
|
|
1283
1370
|
}
|
|
1284
|
-
emitChange() {
|
|
1285
|
-
this.
|
|
1371
|
+
emitChange(e) {
|
|
1372
|
+
if (this.historyTransactionDepth > 0) {
|
|
1373
|
+
this.historyTransactionPending = !0;
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
this.syncSource(), this.applyingHistory || this.recordHistory(e || null), this.dispatchValueEvents();
|
|
1377
|
+
}
|
|
1378
|
+
runHistoryTransaction(e) {
|
|
1379
|
+
this.historyTransactionDepth += 1;
|
|
1380
|
+
try {
|
|
1381
|
+
e();
|
|
1382
|
+
} finally {
|
|
1383
|
+
--this.historyTransactionDepth, this.historyTransactionDepth === 0 && this.historyTransactionPending && (this.historyTransactionPending = !1, this.syncSource(), this.recordHistory(null), this.dispatchValueEvents());
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
dispatchValueEvents() {
|
|
1286
1387
|
let e = this.value;
|
|
1287
1388
|
this.dispatchEvent(new CustomEvent("input", {
|
|
1288
1389
|
bubbles: !0,
|
|
@@ -1294,6 +1395,119 @@ var a = class extends HTMLElement {
|
|
|
1294
1395
|
detail: { value: e }
|
|
1295
1396
|
}));
|
|
1296
1397
|
}
|
|
1398
|
+
resetHistory() {
|
|
1399
|
+
this.history = [], this.historyIndex = -1, this.editor && this.recordHistory(null), this.updateHistoryButtons();
|
|
1400
|
+
}
|
|
1401
|
+
refreshCurrentHistorySnapshot() {
|
|
1402
|
+
if (this.historyIndex < 0) return;
|
|
1403
|
+
let e = this.captureHistorySnapshot(null);
|
|
1404
|
+
e && (this.history[this.historyIndex] = e);
|
|
1405
|
+
}
|
|
1406
|
+
captureHistoryPoint(e, t) {
|
|
1407
|
+
let n = this.editor;
|
|
1408
|
+
if (!n || !e || e !== n && !n.contains(e)) return null;
|
|
1409
|
+
let r = [], i = e;
|
|
1410
|
+
for (; i && i !== n;) {
|
|
1411
|
+
let e = i.parentNode;
|
|
1412
|
+
if (!e) return null;
|
|
1413
|
+
r.unshift(Array.prototype.indexOf.call(e.childNodes, i)), i = e;
|
|
1414
|
+
}
|
|
1415
|
+
return i === n ? {
|
|
1416
|
+
path: r,
|
|
1417
|
+
offset: Math.max(0, Math.min(t, e.nodeType === Node.TEXT_NODE ? (e.textContent || "").length : e.childNodes.length))
|
|
1418
|
+
} : null;
|
|
1419
|
+
}
|
|
1420
|
+
resolveHistoryPoint(e) {
|
|
1421
|
+
let t = this.editor;
|
|
1422
|
+
if (!t || !e) return null;
|
|
1423
|
+
let n = t;
|
|
1424
|
+
for (let t of e.path) {
|
|
1425
|
+
let e = n.childNodes[Math.max(0, Math.min(t, n.childNodes.length - 1))];
|
|
1426
|
+
if (!e) break;
|
|
1427
|
+
n = e;
|
|
1428
|
+
}
|
|
1429
|
+
let r = n.nodeType === Node.TEXT_NODE ? (n.textContent || "").length : n.childNodes.length;
|
|
1430
|
+
return {
|
|
1431
|
+
node: n,
|
|
1432
|
+
offset: Math.max(0, Math.min(e.offset, r))
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
captureHistorySnapshot(e) {
|
|
1436
|
+
if (!this.editor) return null;
|
|
1437
|
+
let t = this.selection, n = this.sourceMode && this.source ? {
|
|
1438
|
+
start: this.source.selectionStart,
|
|
1439
|
+
end: this.source.selectionEnd,
|
|
1440
|
+
direction: this.source.selectionDirection
|
|
1441
|
+
} : null, r = this.cleanEditorCopy(), i = this.sourceMode && this.source ? this.source.value : this.format === "markdown" ? o(r) : r.innerHTML;
|
|
1442
|
+
return {
|
|
1443
|
+
html: r.innerHTML,
|
|
1444
|
+
source: i,
|
|
1445
|
+
anchor: this.captureHistoryPoint(t?.anchorNode || null, t?.anchorOffset || 0),
|
|
1446
|
+
focus: this.captureHistoryPoint(t?.focusNode || null, t?.focusOffset || 0),
|
|
1447
|
+
sourceSelection: n,
|
|
1448
|
+
group: e,
|
|
1449
|
+
time: Date.now()
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
recordHistory(e) {
|
|
1453
|
+
if (!this.editor || this.applyingHistory) return;
|
|
1454
|
+
let t = e === "insertText" || e === "insertCompositionText" ? "typing" : e === "deleteContentBackward" || e === "deleteContentForward" || e === "deleteByCut" ? "deleting" : null, n = this.captureHistorySnapshot(t);
|
|
1455
|
+
if (!n) return;
|
|
1456
|
+
if (this.historyIndex < 0) {
|
|
1457
|
+
this.history = [n], this.historyIndex = 0, this.updateHistoryButtons();
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
let r = this.history[this.historyIndex];
|
|
1461
|
+
if (n.html === r.html && n.source === r.source) {
|
|
1462
|
+
n.group = t, this.history[this.historyIndex] = n, this.updateHistoryButtons();
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
t !== null && r.group === t && n.time - r.time <= 900 ? this.history[this.historyIndex] = n : (this.history = this.history.slice(0, this.historyIndex + 1), this.history.push(n), this.historyIndex = this.history.length - 1, this.history.length > 100 && (this.history.shift(), this.historyIndex = this.history.length - 1)), this.updateHistoryButtons();
|
|
1466
|
+
}
|
|
1467
|
+
updateHistoryButtons() {
|
|
1468
|
+
let e = this.historyIndex > 0 && this.historyIndex < this.history.length, t = this.historyIndex >= 0 && this.historyIndex < this.history.length - 1;
|
|
1469
|
+
this.undoButton && (this.undoButton.disabled = !e), this.redoButton && (this.redoButton.disabled = !t);
|
|
1470
|
+
}
|
|
1471
|
+
restoreHistorySelection(e) {
|
|
1472
|
+
if (this.sourceMode && this.source && e.sourceSelection) {
|
|
1473
|
+
let t = Math.min(e.sourceSelection.start, this.source.value.length), n = Math.min(e.sourceSelection.end, this.source.value.length);
|
|
1474
|
+
this.source.setSelectionRange(t, n, e.sourceSelection.direction), this.source.focus();
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
let t = this.selection, n = this.resolveHistoryPoint(e.anchor), r = this.resolveHistoryPoint(e.focus);
|
|
1478
|
+
if (!(!t || !n || !r)) if (t.removeAllRanges(), typeof t.setBaseAndExtent == "function") t.setBaseAndExtent(n.node, n.offset, r.node, r.offset);
|
|
1479
|
+
else {
|
|
1480
|
+
let e = this.editor.ownerDocument.createRange();
|
|
1481
|
+
e.setStart(n.node, n.offset), e.setEnd(r.node, r.offset), t.addRange(e);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
applyHistorySnapshot(e) {
|
|
1485
|
+
if (!(!this.editor || !this.source)) {
|
|
1486
|
+
this.applyingHistory = !0;
|
|
1487
|
+
try {
|
|
1488
|
+
this.editor.innerHTML = e.html, this.source.value = e.source, this.editor.querySelectorAll(".mint-editor-image-frame").forEach((e) => {
|
|
1489
|
+
e.querySelectorAll(".mint-editor-resize-handle").forEach((e) => e.remove()), e.append(this.createResizeHandle());
|
|
1490
|
+
}), this.selectImage(null), this.selectTable(null), this.clearInlineTypingState(), this.preservedContent = this.format === "markdown" ? e.source : e.html, this.updateWordCount(), this.restoreHistorySelection(e), this.updateSelectedImage(), this.updateSelectionUI(), this.updateHistoryButtons();
|
|
1491
|
+
} finally {
|
|
1492
|
+
this.applyingHistory = !1;
|
|
1493
|
+
}
|
|
1494
|
+
this.dispatchValueEvents();
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
undo() {
|
|
1498
|
+
this.historyIndex <= 0 || (--this.historyIndex, this.applyHistorySnapshot(this.history[this.historyIndex]));
|
|
1499
|
+
}
|
|
1500
|
+
redo() {
|
|
1501
|
+
this.historyIndex >= this.history.length - 1 || (this.historyIndex += 1, this.applyHistorySnapshot(this.history[this.historyIndex]));
|
|
1502
|
+
}
|
|
1503
|
+
handleHistoryKeydown(e) {
|
|
1504
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey) return;
|
|
1505
|
+
let t = e.key.toLowerCase();
|
|
1506
|
+
t === "z" ? (e.preventDefault(), e.shiftKey ? this.redo() : this.undo()) : t === "y" && !e.shiftKey && (e.preventDefault(), this.redo());
|
|
1507
|
+
}
|
|
1508
|
+
handleHistoryBeforeInput(e) {
|
|
1509
|
+
return e.inputType === "historyUndo" ? (e.preventDefault(), this.undo(), !0) : e.inputType === "historyRedo" ? (e.preventDefault(), this.redo(), !0) : !1;
|
|
1510
|
+
}
|
|
1297
1511
|
updateWordCount() {
|
|
1298
1512
|
if (!this.editor || !this.count) return;
|
|
1299
1513
|
let e = (this.editor.innerText || "").trim().split(/\s+/).filter(Boolean).length;
|
|
@@ -1395,21 +1609,158 @@ var a = class extends HTMLElement {
|
|
|
1395
1609
|
}
|
|
1396
1610
|
openLinkModal() {
|
|
1397
1611
|
this.saveSelection();
|
|
1398
|
-
let e = document.createElement("mint-modal");
|
|
1399
|
-
|
|
1400
|
-
let t = document.createElement("div");
|
|
1401
|
-
t.setAttribute("slot", "body");
|
|
1402
|
-
let n = document.createElement("mint-input");
|
|
1403
|
-
n.setAttribute("type", "url"), n.setAttribute("label", "Link URL"), n.setAttribute("placeholder", "https://example.com"), t.append(n);
|
|
1612
|
+
let e = this._savedRange, t = e && !e.collapsed ? e.toString() : "", n = document.createElement("mint-modal");
|
|
1613
|
+
n.setAttribute("heading", "Insert link"), n.setAttribute("size", "small");
|
|
1404
1614
|
let r = document.createElement("div");
|
|
1405
|
-
r.setAttribute("slot", "
|
|
1406
|
-
let i = document.createElement("mint-
|
|
1407
|
-
i.
|
|
1408
|
-
let a = document.createElement("mint-
|
|
1409
|
-
a.
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1615
|
+
r.setAttribute("slot", "body"), r.className = "mint-editor-modal-fields";
|
|
1616
|
+
let i = document.createElement("mint-input");
|
|
1617
|
+
i.setAttribute("type", "text"), i.setAttribute("label", "Link text"), i.setAttribute("placeholder", "Text to display"), t && i.setAttribute("value", t);
|
|
1618
|
+
let a = document.createElement("mint-input");
|
|
1619
|
+
a.setAttribute("type", "url"), a.setAttribute("label", "Link URL"), a.setAttribute("placeholder", "https://example.com"), r.append(i, a);
|
|
1620
|
+
let o = document.createElement("mint-select");
|
|
1621
|
+
o.className = "mint-editor-link-target", o.setAttribute("label", "Open in"), o.setAttribute("value", "same-tab"), [
|
|
1622
|
+
["same-tab", "Same tab"],
|
|
1623
|
+
["new-tab", "New tab"],
|
|
1624
|
+
["new-window", "New window"],
|
|
1625
|
+
["popup", "Popup"]
|
|
1626
|
+
].forEach(([e, t]) => {
|
|
1627
|
+
let n = document.createElement("option");
|
|
1628
|
+
n.value = e, n.textContent = t, o.append(n);
|
|
1629
|
+
}), r.append(o);
|
|
1630
|
+
let s = document.createElement("mint-button");
|
|
1631
|
+
s.className = "mint-editor-link-advanced", s.textContent = "Advanced settings", s.setAttribute("variant", "ghost"), s.setAttribute("aria-expanded", "false"), s.hidden = !0;
|
|
1632
|
+
let c = document.createElement("div");
|
|
1633
|
+
c.className = "mint-editor-popup-settings", c.id = `${this.id || "mint-editor"}-popup-settings`, c.hidden = !0, s.setAttribute("aria-controls", c.id);
|
|
1634
|
+
let l = document.createElement("mint-input");
|
|
1635
|
+
l.setAttribute("type", "text"), l.setAttribute("label", "Window title"), l.setAttribute("placeholder", "Link popup");
|
|
1636
|
+
let u = document.createElement("mint-input");
|
|
1637
|
+
u.setAttribute("type", "number"), u.setAttribute("label", "Width"), u.setAttribute("min", "200"), u.setAttribute("max", "4000"), u.setAttribute("value", "800");
|
|
1638
|
+
let d = document.createElement("mint-input");
|
|
1639
|
+
d.setAttribute("type", "number"), d.setAttribute("label", "Height"), d.setAttribute("min", "150"), d.setAttribute("max", "4000"), d.setAttribute("value", "600");
|
|
1640
|
+
let f = document.createElement("mint-input");
|
|
1641
|
+
f.setAttribute("type", "number"), f.setAttribute("label", "Left position"), f.setAttribute("min", "0"), f.setAttribute("max", "10000"), f.setAttribute("placeholder", "Automatic");
|
|
1642
|
+
let p = document.createElement("mint-input");
|
|
1643
|
+
p.setAttribute("type", "number"), p.setAttribute("label", "Top position"), p.setAttribute("min", "0"), p.setAttribute("max", "10000"), p.setAttribute("placeholder", "Automatic");
|
|
1644
|
+
let m = document.createElement("mint-select");
|
|
1645
|
+
m.setAttribute("label", "Resizable"), m.setAttribute("value", "yes");
|
|
1646
|
+
let h = document.createElement("mint-select");
|
|
1647
|
+
h.setAttribute("label", "Scrollbars"), h.setAttribute("value", "yes"), [
|
|
1648
|
+
[
|
|
1649
|
+
m,
|
|
1650
|
+
"yes",
|
|
1651
|
+
"Yes"
|
|
1652
|
+
],
|
|
1653
|
+
[
|
|
1654
|
+
m,
|
|
1655
|
+
"no",
|
|
1656
|
+
"No"
|
|
1657
|
+
],
|
|
1658
|
+
[
|
|
1659
|
+
h,
|
|
1660
|
+
"yes",
|
|
1661
|
+
"Yes"
|
|
1662
|
+
],
|
|
1663
|
+
[
|
|
1664
|
+
h,
|
|
1665
|
+
"no",
|
|
1666
|
+
"No"
|
|
1667
|
+
]
|
|
1668
|
+
].forEach(([e, t, n]) => {
|
|
1669
|
+
let r = document.createElement("option");
|
|
1670
|
+
r.value = String(t), r.textContent = String(n), e.append(r);
|
|
1671
|
+
}), c.append(l, u, d, f, p, m, h), s.addEventListener("click", () => {
|
|
1672
|
+
c.hidden = !c.hidden, s.setAttribute("aria-expanded", String(!c.hidden));
|
|
1673
|
+
}), o.addEventListener("change", (e) => {
|
|
1674
|
+
let t = String(e.detail?.value || o.value);
|
|
1675
|
+
s.hidden = t !== "popup", t !== "popup" && (c.hidden = !0, s.setAttribute("aria-expanded", "false"));
|
|
1676
|
+
}), r.append(s, c);
|
|
1677
|
+
let g = document.createElement("div");
|
|
1678
|
+
g.setAttribute("slot", "actions"), g.className = "mint-editor-modal-actions";
|
|
1679
|
+
let _ = document.createElement("mint-button");
|
|
1680
|
+
_.textContent = "Cancel", _.setAttribute("variant", "ghost"), this.setTooltip(_, "Cancel"), _.addEventListener("click", () => n.close());
|
|
1681
|
+
let v = document.createElement("mint-button");
|
|
1682
|
+
v.textContent = "Insert link", v.setAttribute("tone", "action"), this.setTooltip(v, "Insert link"), v.addEventListener("click", () => {
|
|
1683
|
+
let e = String(a.value || "").trim(), t = String(i.value || ""), r = String(o.value || "same-tab"), s = {
|
|
1684
|
+
title: String(l.value || ""),
|
|
1685
|
+
width: String(u.value || "800"),
|
|
1686
|
+
height: String(d.value || "600"),
|
|
1687
|
+
left: String(f.value || ""),
|
|
1688
|
+
top: String(p.value || ""),
|
|
1689
|
+
resizable: String(m.value || "yes"),
|
|
1690
|
+
scrollbars: String(h.value || "yes")
|
|
1691
|
+
};
|
|
1692
|
+
e && t.trim() && (this.insertLink(e, t, r, s), n.close());
|
|
1693
|
+
}), g.append(_, v), n.append(r, g), this.append(n), n.open();
|
|
1694
|
+
}
|
|
1695
|
+
insertLink(e, t, n, r) {
|
|
1696
|
+
let i = this.editor, a = this._savedRange;
|
|
1697
|
+
if (!i || this.sourceMode || !a || !i.contains(a.commonAncestorContainer)) return;
|
|
1698
|
+
let o = a.collapsed ? "" : a.toString();
|
|
1699
|
+
if (o && o === t) {
|
|
1700
|
+
let t = a.cloneRange();
|
|
1701
|
+
this.runHistoryTransaction(() => {
|
|
1702
|
+
this.command("createLink", e);
|
|
1703
|
+
let a = Array.from(i.querySelectorAll("a[href]")).filter((e) => {
|
|
1704
|
+
try {
|
|
1705
|
+
return t.intersectsNode(e);
|
|
1706
|
+
} catch {
|
|
1707
|
+
return !1;
|
|
1708
|
+
}
|
|
1709
|
+
}), o = this.selection?.anchorNode, s = (o?.nodeType === Node.ELEMENT_NODE ? o : o?.parentElement)?.closest("a[href]");
|
|
1710
|
+
(a.length ? a : s ? [s] : []).forEach((e) => this.configureLinkTarget(e, n, r)), this.emitChange();
|
|
1711
|
+
}), this.updateSelectionUI();
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
this.runHistoryTransaction(() => {
|
|
1715
|
+
i.focus(), this.restoreSelection();
|
|
1716
|
+
let a = this.selection;
|
|
1717
|
+
if (!a?.rangeCount) return;
|
|
1718
|
+
let o = a.getRangeAt(0);
|
|
1719
|
+
if (!i.contains(o.commonAncestorContainer)) return;
|
|
1720
|
+
let s = (e) => {
|
|
1721
|
+
let t = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest("a[href]");
|
|
1722
|
+
return t && i.contains(t) ? t : null;
|
|
1723
|
+
}, c = s(o.startContainer), l = s(o.endContainer), u, d;
|
|
1724
|
+
if (c && c === l) {
|
|
1725
|
+
if (d = c, o.collapsed) d.textContent = t, u = d;
|
|
1726
|
+
else {
|
|
1727
|
+
o.deleteContents();
|
|
1728
|
+
let e = i.ownerDocument.createTextNode(t);
|
|
1729
|
+
o.insertNode(e), u = e;
|
|
1730
|
+
}
|
|
1731
|
+
d.href = e;
|
|
1732
|
+
} else {
|
|
1733
|
+
d = i.ownerDocument.createElement("a"), d.href = e, o.deleteContents();
|
|
1734
|
+
let n = i.ownerDocument.createTextNode(t);
|
|
1735
|
+
d.append(n), o.insertNode(d), u = d;
|
|
1736
|
+
}
|
|
1737
|
+
this.configureLinkTarget(d, n, r), o.setStartAfter(u), o.collapse(!0), a.removeAllRanges(), a.addRange(o), this.emitChange();
|
|
1738
|
+
}), this.updateSelectionUI();
|
|
1739
|
+
}
|
|
1740
|
+
configureLinkTarget(e, t, n) {
|
|
1741
|
+
e.setAttribute("target", {
|
|
1742
|
+
"same-tab": "_self",
|
|
1743
|
+
"new-tab": "_blank",
|
|
1744
|
+
"new-window": "mint-editor-window",
|
|
1745
|
+
popup: "mint-editor-popup"
|
|
1746
|
+
}[t]), e.setAttribute("data-mint-editor-open", t), t === "same-tab" ? e.removeAttribute("rel") : e.setAttribute("rel", "noopener noreferrer");
|
|
1747
|
+
let r = {
|
|
1748
|
+
"data-mint-popup-title": n.title.trim().slice(0, 120),
|
|
1749
|
+
"data-mint-popup-width": this.normalizePopupNumber(n.width, 200, 4e3, "800"),
|
|
1750
|
+
"data-mint-popup-height": this.normalizePopupNumber(n.height, 150, 4e3, "600"),
|
|
1751
|
+
"data-mint-popup-left": this.normalizePopupNumber(n.left, 0, 1e4, ""),
|
|
1752
|
+
"data-mint-popup-top": this.normalizePopupNumber(n.top, 0, 1e4, ""),
|
|
1753
|
+
"data-mint-popup-resizable": n.resizable === "no" ? "no" : "yes",
|
|
1754
|
+
"data-mint-popup-scrollbars": n.scrollbars === "no" ? "no" : "yes"
|
|
1755
|
+
};
|
|
1756
|
+
Object.entries(r).forEach(([n, r]) => {
|
|
1757
|
+
t === "popup" && r ? e.setAttribute(n, r) : e.removeAttribute(n);
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
normalizePopupNumber(e, t, n, r) {
|
|
1761
|
+
if (!e.trim()) return r;
|
|
1762
|
+
let i = Number.parseInt(e, 10);
|
|
1763
|
+
return Number.isFinite(i) ? String(Math.max(t, Math.min(n, i))) : r;
|
|
1413
1764
|
}
|
|
1414
1765
|
selectedTable() {
|
|
1415
1766
|
let e = this._savedRange?.startContainer || this.selection?.anchorNode, t = (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement)?.closest("table");
|
|
@@ -1512,9 +1863,9 @@ var a = class extends HTMLElement {
|
|
|
1512
1863
|
toggleSource() {
|
|
1513
1864
|
if (!(!this.editor || !this.source)) {
|
|
1514
1865
|
if (this.sourceMode = !this.sourceMode, this.clearInlineTypingState(), this.source.hidden = !this.sourceMode, this.editor.hidden = this.sourceMode, this.sourceMode) {
|
|
1515
|
-
let e = this.cleanEditorCopy();
|
|
1516
|
-
this.source.value = this.format === "markdown" ?
|
|
1517
|
-
} else this.editor.innerHTML = this.format === "markdown" ?
|
|
1866
|
+
let e = this.cleanEditorCopy(), t = this.format === "markdown" ? o(e) : e.innerHTML;
|
|
1867
|
+
this.source.value = this.format === "markdown" ? n(t) : r(t, this.editor.ownerDocument), this.refreshCurrentHistorySnapshot(), this.preservedContent = this.source.value, this.dispatchValueEvents();
|
|
1868
|
+
} else this.editor.innerHTML = this.format === "markdown" ? i(this.source.value) : this.source.value, this.syncSource(), this.emitChange();
|
|
1518
1869
|
this.toolbar?.classList.toggle("mint-editor-source-active", this.sourceMode), this.updateWordCount(), this.sourceMode ? this.selectTable(null) : this.updateSelectionUI();
|
|
1519
1870
|
}
|
|
1520
1871
|
}
|
|
@@ -1543,6 +1894,6 @@ var a = class extends HTMLElement {
|
|
|
1543
1894
|
t && this.selectImage(t);
|
|
1544
1895
|
}
|
|
1545
1896
|
};
|
|
1546
|
-
customElements.get("mint-editor") || e("mint-editor",
|
|
1897
|
+
customElements.get("mint-editor") || e("mint-editor", s);
|
|
1547
1898
|
//#endregion
|
|
1548
|
-
export {
|
|
1899
|
+
export { s as default };
|