monobill-mintui 0.6.736 → 0.6.737
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/editor/Editor.d.ts +2 -0
- package/dist/components/editor/Editor.d.ts.map +1 -1
- package/dist/components/editor/browser.js +52 -48
- package/dist/components/editor/index.cjs +2 -2
- package/dist/components/editor/index.js +52 -48
- package/dist/index.cjs +2 -2
- package/dist/index.js +52 -48
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15575,7 +15575,7 @@ function Xr(e) {
|
|
|
15575
15575
|
}
|
|
15576
15576
|
var Zr = class extends HTMLElement {
|
|
15577
15577
|
constructor(...e) {
|
|
15578
|
-
super(...e), this.editor = null, this.editorFrame = null, this.pendingValue = 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) => {
|
|
15578
|
+
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) => {
|
|
15579
15579
|
if (e.button !== 0) return;
|
|
15580
15580
|
e.preventDefault(), e.stopPropagation(), this.stageResizeState = {
|
|
15581
15581
|
stage: t,
|
|
@@ -15681,10 +15681,10 @@ var Zr = class extends HTMLElement {
|
|
|
15681
15681
|
}
|
|
15682
15682
|
setValue(e) {
|
|
15683
15683
|
if (!this.editor) {
|
|
15684
|
-
this.pendingValue = e, this.getAttribute("value") !== e && this.setAttribute("value", e);
|
|
15684
|
+
this.pendingValue = e, this.preservedContent = e, this.getAttribute("value") !== e && this.setAttribute("value", e);
|
|
15685
15685
|
return;
|
|
15686
15686
|
}
|
|
15687
|
-
this.editor.innerHTML = this.format === "markdown" ? Q(e) : e, this.clearInlineTypingState(), this.source && (this.source.value = e), this.updateWordCount();
|
|
15687
|
+
this.editor.innerHTML = this.format === "markdown" ? Q(e) : e, this.preservedContent = e, this.clearInlineTypingState(), this.source && (this.source.value = e), this.updateWordCount();
|
|
15688
15688
|
}
|
|
15689
15689
|
insertResource(e) {
|
|
15690
15690
|
let t = typeof e == "string" ? { url: e } : e, n = t.url || t.src;
|
|
@@ -15702,21 +15702,23 @@ var Zr = class extends HTMLElement {
|
|
|
15702
15702
|
this.selectImage(i), this.emitChange();
|
|
15703
15703
|
}
|
|
15704
15704
|
render() {
|
|
15705
|
-
let e = this.
|
|
15705
|
+
let e = this.getAttribute("value"), t = this.editor?.innerHTML ?? this.pendingValue ?? e ?? this.preservedContent ?? this.innerHTML;
|
|
15706
|
+
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 = t) : this.preservedContent = e : this.preservedContent = this.pendingValue;
|
|
15707
|
+
let n = this.editor ? t : this.format === "markdown" ? Q(t) : t;
|
|
15706
15708
|
this.observer?.disconnect(), this.inlineButtons.clear(), this.colorTriggers.clear(), this.colorRecentSwatches.clear(), this.clearInlineTypingState(), this.editor = null, this.selectedImage = null;
|
|
15707
|
-
let
|
|
15709
|
+
let r = this.hasAttribute("disabled") && this.getAttribute("disabled") !== "false", i = this.editorHeight === null ? this.getAttribute("height") || "300px" : `${this.editorHeight}px`, a = this.getAttribute("label") || "";
|
|
15708
15710
|
this.innerHTML = "";
|
|
15709
|
-
let
|
|
15710
|
-
if (
|
|
15711
|
+
let o = document.createElement("div");
|
|
15712
|
+
if (o.className = "mint-editor-root", this.hasAttribute("error") && o.classList.add("mint-editor-has-error"), this.hasAttribute("compact") && o.classList.add("mint-editor-compact"), a) {
|
|
15711
15713
|
let e = document.createElement("label");
|
|
15712
|
-
e.className = "mint-editor-label", e.textContent =
|
|
15714
|
+
e.className = "mint-editor-label", e.textContent = a, e.id = `${this.id || "mint-editor"}-label`, o.append(e);
|
|
15713
15715
|
}
|
|
15714
|
-
let o = document.createElement("div");
|
|
15715
|
-
o.className = "mint-editor-shell";
|
|
15716
15716
|
let s = document.createElement("div");
|
|
15717
|
-
s.className = "mint-editor-
|
|
15717
|
+
s.className = "mint-editor-shell";
|
|
15718
15718
|
let c = document.createElement("div");
|
|
15719
|
-
c.className = "mint-editor-
|
|
15719
|
+
c.className = "mint-editor-toolbar", c.setAttribute("role", "toolbar"), c.setAttribute("aria-label", "Text formatting"), this.toolbar = c, this.buildToolbar(c);
|
|
15720
|
+
let l = document.createElement("div");
|
|
15721
|
+
l.className = "mint-editor-inline-table-tools", l.setAttribute("role", "toolbar"), l.setAttribute("aria-label", "Table tools"), l.hidden = !0;
|
|
15720
15722
|
for (let [e, t] of [
|
|
15721
15723
|
["Add row above", "arrow-up"],
|
|
15722
15724
|
["Add row below", "arrow-down"],
|
|
@@ -15729,12 +15731,12 @@ var Zr = class extends HTMLElement {
|
|
|
15729
15731
|
let n = document.createElement("button");
|
|
15730
15732
|
n.type = "button", n.className = "mint-editor-table-tool-button", this.setTooltip(n, e), n.append(this.icon(t)), n.addEventListener("pointerdown", (e) => {
|
|
15731
15733
|
e.preventDefault(), this.saveSelection();
|
|
15732
|
-
}), n.addEventListener("click", () => this.applyTableAction(e)),
|
|
15734
|
+
}), n.addEventListener("click", () => this.applyTableAction(e)), l.append(n);
|
|
15733
15735
|
}
|
|
15734
|
-
let
|
|
15735
|
-
|
|
15736
|
-
let
|
|
15737
|
-
|
|
15736
|
+
let u = document.createElement("button");
|
|
15737
|
+
u.type = "button", u.className = "mint-editor-table-resize-handle", this.setTooltip(u, "Resize table"), u.addEventListener("pointerdown", (e) => this.startTableResize(e)), this.inlineTableTools = l, this.tableResizeHandle = u;
|
|
15738
|
+
let d = document.createElement("iframe");
|
|
15739
|
+
d.className = "mint-editor-frame", d.title = a ? `${a} editor` : "Rich text editor", d.setAttribute("sandbox", "allow-same-origin"), d.style.height = "100%", d.srcdoc = `<!doctype html><html><head><meta charset="utf-8"><style>
|
|
15738
15740
|
html,body{box-sizing:border-box;width:100%;height:100%;min-width:0;margin:0;overflow:hidden}
|
|
15739
15741
|
.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}
|
|
15740
15742
|
.editor:empty:before{content:attr(data-placeholder);color:var(--mint-color-text-muted,#7b8492);pointer-events:none}
|
|
@@ -15747,52 +15749,54 @@ var Zr = class extends HTMLElement {
|
|
|
15747
15749
|
.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}
|
|
15748
15750
|
.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}
|
|
15749
15751
|
@media(max-width:640px){.editor{padding:.75rem}}
|
|
15750
|
-
</style></head><body><div class="editor" contenteditable="${!
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
let p =
|
|
15752
|
+
</style></head><body><div class="editor" contenteditable="${!r}" role="textbox" aria-multiline="true" aria-label="${Z(a || "Rich text editor")}" data-placeholder="${Z(this.getAttribute("placeholder") || "Start writing…")}"></div></body></html>`, d.addEventListener("load", () => {
|
|
15753
|
+
!this.isConnected || this.editorFrame !== d || this.bindEditorFrame(n, r);
|
|
15754
|
+
}), this.editorFrame = d;
|
|
15755
|
+
let f = document.createElement("textarea");
|
|
15756
|
+
f.className = "mint-editor-source", f.style.height = "100%", f.setAttribute("aria-label", `Editor ${this.format.toUpperCase()} source`), f.hidden = !0, f.value = this.format === "markdown" ? t : n, f.addEventListener("input", () => {
|
|
15757
|
+
this.editor && (this.editor.innerHTML = this.format === "markdown" ? Q(f.value) : f.value), this.updateWordCount(), this.emitChange();
|
|
15758
|
+
}), this.source = f;
|
|
15759
|
+
let p = document.createElement("div");
|
|
15760
|
+
p.className = "mint-editor-stage", p.style.height = i, p.append(d, f);
|
|
15761
|
+
let m = null;
|
|
15758
15762
|
[
|
|
15759
15763
|
"false",
|
|
15760
15764
|
"0",
|
|
15761
15765
|
"off",
|
|
15762
15766
|
"no"
|
|
15763
|
-
].includes((this.getAttribute("resizable") || "").trim().toLowerCase()) || (
|
|
15764
|
-
let
|
|
15765
|
-
|
|
15766
|
-
let
|
|
15767
|
-
|
|
15767
|
+
].includes((this.getAttribute("resizable") || "").trim().toLowerCase()) || (m = document.createElement("button"), m.type = "button", m.className = "mint-editor-stage-resize-handle", this.setTooltip(m, "Resize editor"), m.addEventListener("pointerdown", (e) => this.onStageResizeStart(e, p))), s.append(c, p, l, u);
|
|
15768
|
+
let h = document.createElement("div");
|
|
15769
|
+
h.className = "mint-editor-image-tools", h.hidden = !0, h.innerHTML = "<span>Image width</span><mint-input type=\"number\" min=\"10\" max=\"100\" value=\"100\" aria-label=\"Image width percent\"></mint-input><span>%</span><mint-button variant=\"ghost\" data-align=\"left\">Left</mint-button><mint-button variant=\"ghost\" data-align=\"center\">Center</mint-button><mint-button variant=\"ghost\" data-align=\"right\">Right</mint-button><mint-button variant=\"ghost\" data-remove=\"image\">Remove</mint-button>", h.querySelectorAll("[data-align]").forEach((e) => this.setTooltip(e, `Align image ${e.dataset.align}`));
|
|
15770
|
+
let g = h.querySelector("[data-remove=\"image\"]");
|
|
15771
|
+
g && this.setTooltip(g, "Remove image"), h.querySelector("mint-input")?.addEventListener("input", (e) => {
|
|
15768
15772
|
if (!this.selectedImage) return;
|
|
15769
15773
|
let t = Number(e.target.value);
|
|
15770
15774
|
this.selectedImage.style.width = `${Math.max(10, Math.min(100, t))}%`, this.emitChange();
|
|
15771
|
-
}),
|
|
15775
|
+
}), h.querySelectorAll("[data-align]").forEach((e) => e.addEventListener("click", () => {
|
|
15772
15776
|
this.selectedImage && (this.selectedImage.style.marginLeft = e.dataset.align === "right" || e.dataset.align === "center" ? "auto" : "0", this.selectedImage.style.marginRight = e.dataset.align === "left" || e.dataset.align === "center" ? "auto" : "0", this.emitChange());
|
|
15773
|
-
})),
|
|
15777
|
+
})), h.querySelector("[data-remove=\"image\"]")?.addEventListener("click", () => {
|
|
15774
15778
|
this.selectedImage?.remove(), this.selectImage(null), this.emitChange();
|
|
15775
|
-
}),
|
|
15776
|
-
let
|
|
15777
|
-
|
|
15778
|
-
let _ = document.createElement("span");
|
|
15779
|
-
_.className = "mint-editor-mode", _.textContent = "p";
|
|
15779
|
+
}), o.append(s, h);
|
|
15780
|
+
let _ = document.createElement("div");
|
|
15781
|
+
_.className = "mint-editor-footer";
|
|
15780
15782
|
let v = document.createElement("span");
|
|
15781
|
-
v.className = "mint-editor-
|
|
15782
|
-
let y = document.createElement("
|
|
15783
|
-
y.className = "mint-editor-
|
|
15784
|
-
let b =
|
|
15785
|
-
|
|
15783
|
+
v.className = "mint-editor-mode", v.textContent = "p";
|
|
15784
|
+
let y = document.createElement("span");
|
|
15785
|
+
y.className = "mint-editor-word-count", this.count = y;
|
|
15786
|
+
let b = document.createElement("div");
|
|
15787
|
+
b.className = "mint-editor-footer-end", b.append(y), m && b.append(m), _.append(v, b), this.footerMode = v, s.append(_);
|
|
15788
|
+
let x = this.getAttribute("error");
|
|
15789
|
+
if (x) {
|
|
15786
15790
|
let e = document.createElement("div");
|
|
15787
|
-
e.className = "mint-editor-error", e.textContent =
|
|
15791
|
+
e.className = "mint-editor-error", e.textContent = x, o.append(e);
|
|
15788
15792
|
}
|
|
15789
|
-
this.append(
|
|
15790
|
-
let
|
|
15791
|
-
if (
|
|
15793
|
+
this.append(o);
|
|
15794
|
+
let S = this.querySelector(".mint-editor-stage");
|
|
15795
|
+
if (S && typeof ResizeObserver < "u" && (this.frameResizeObserver?.disconnect(), this.frameResizeObserver = new ResizeObserver(([e]) => {
|
|
15792
15796
|
if (!e || !this.editorFrame) return;
|
|
15793
15797
|
let t = Math.max(0, e.contentRect.width), n = Math.max(0, e.contentRect.height);
|
|
15794
15798
|
this.editorFrame.style.width = `${t}px`, this.editorFrame.style.height = `${n}px`;
|
|
15795
|
-
}), this.frameResizeObserver.observe(
|
|
15799
|
+
}), this.frameResizeObserver.observe(S)), this.toolbar && typeof ResizeObserver < "u") {
|
|
15796
15800
|
this.toolbarResizeObserver?.disconnect(), this.toolbarResizeObserver = new ResizeObserver(() => this.updateToolbarOverflow()), this.toolbarResizeObserver.observe(this.toolbar);
|
|
15797
15801
|
let e = this.toolbar.querySelector(".mint-editor-toolbar-actions");
|
|
15798
15802
|
e && this.toolbarResizeObserver.observe(e), requestAnimationFrame(() => this.updateToolbarOverflow());
|
|
@@ -16757,7 +16761,7 @@ var Zr = class extends HTMLElement {
|
|
|
16757
16761
|
syncSource() {
|
|
16758
16762
|
if (this.source && this.editor) {
|
|
16759
16763
|
let e = this.cleanEditorCopy();
|
|
16760
|
-
this.source.value = this.format === "markdown" ? Xr(e) : e.innerHTML;
|
|
16764
|
+
this.source.value = this.format === "markdown" ? Xr(e) : e.innerHTML, this.preservedContent = this.format === "markdown" ? this.source.value : this.editor.innerHTML;
|
|
16761
16765
|
}
|
|
16762
16766
|
this.updateWordCount();
|
|
16763
16767
|
}
|