autumnnote 1.6.5 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autumnnote.es.js +89 -75
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.umd.js +87 -73
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/js/Context.js +4 -4
- package/src/js/core/dom.js +3 -3
- package/src/js/core/markdown.js +2 -2
- package/src/js/core/range.js +1 -1
- package/src/js/editing/History.js +2 -2
- package/src/js/editing/Style.js +7 -5
- package/src/js/editing/Typing.js +2 -2
- package/src/js/index.js +1 -1
- package/src/js/module/AutoSaveRestore.js +3 -2
- package/src/js/module/BubbleToolbar.js +1 -1
- package/src/js/module/Clipboard.js +4 -4
- package/src/js/module/CodeTooltip.js +1 -1
- package/src/js/module/ContextMenu.js +14 -12
- package/src/js/module/Editor.js +6 -6
- package/src/js/module/EmojiDialog.js +1 -1
- package/src/js/module/FindReplace.js +6 -7
- package/src/js/module/IconDialog.js +1 -1
- package/src/js/module/ImageCropOverlay.js +1 -0
- package/src/js/module/ImageDialog.js +3 -3
- package/src/js/module/ImageResizer.js +2 -2
- package/src/js/module/ImageTooltip.js +5 -3
- package/src/js/module/LinkDialog.js +1 -1
- package/src/js/module/LinkTooltip.js +3 -3
- package/src/js/module/Mention.js +2 -2
- package/src/js/module/TableTooltip.js +50 -32
- package/src/js/module/Toolbar.js +13 -10
- package/src/js/module/VideoDialog.js +5 -2
- package/src/js/renderer.js +2 -2
package/dist/autumnnote.es.js
CHANGED
|
@@ -145,9 +145,9 @@ function rect2bnd(rect) {
|
|
|
145
145
|
var ELEMENT_NODE = 1;
|
|
146
146
|
var TEXT_NODE = 3;
|
|
147
147
|
/** @param {Node} node */
|
|
148
|
-
var isElement = (node) => node
|
|
148
|
+
var isElement = (node) => node?.nodeType === 1;
|
|
149
149
|
/** @param {Node} node */
|
|
150
|
-
var isText = (node) => node
|
|
150
|
+
var isText = (node) => node?.nodeType === 3;
|
|
151
151
|
/** @param {Node} node */
|
|
152
152
|
var isVoid = (node) => isElement(node) && /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i.test(node.nodeName);
|
|
153
153
|
/** @param {Node} node */
|
|
@@ -252,7 +252,7 @@ function createElement(tag, attrs = {}, childNodes = []) {
|
|
|
252
252
|
* @param {Node} node
|
|
253
253
|
*/
|
|
254
254
|
function remove(node) {
|
|
255
|
-
if (node
|
|
255
|
+
if (node?.parentNode)
|
|
256
256
|
/** @type {ChildNode} */ node.remove();
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
@@ -673,7 +673,7 @@ var fontName = (name) => execCommand("fontName", name);
|
|
|
673
673
|
function fontSize(size, editable = document) {
|
|
674
674
|
const sel = globalThis.getSelection();
|
|
675
675
|
const wasCollapsed = !sel?.rangeCount || sel.getRangeAt(0).collapsed;
|
|
676
|
-
if (wasCollapsed && sel
|
|
676
|
+
if (wasCollapsed && sel?.rangeCount > 0) {
|
|
677
677
|
try {
|
|
678
678
|
const range = sel.getRangeAt(0);
|
|
679
679
|
const span = document.createElement("span");
|
|
@@ -4503,7 +4503,7 @@ function renderLayout(targetEl, options) {
|
|
|
4503
4503
|
}
|
|
4504
4504
|
if (options.focusColor) container.style.setProperty("--an-focus-color", options.focusColor);
|
|
4505
4505
|
targetEl.style.display = "none";
|
|
4506
|
-
targetEl.
|
|
4506
|
+
targetEl.after(container);
|
|
4507
4507
|
return {
|
|
4508
4508
|
container,
|
|
4509
4509
|
editable
|
|
@@ -4943,7 +4943,7 @@ function handleKeydown(event, editable, options = {}) {
|
|
|
4943
4943
|
const icon = textNode.nextSibling;
|
|
4944
4944
|
const after = icon.nextSibling;
|
|
4945
4945
|
event.preventDefault();
|
|
4946
|
-
if (after
|
|
4946
|
+
if (after?.nodeType === Node.TEXT_NODE) {
|
|
4947
4947
|
const offset = (after.textContent || "").startsWith("") ? 1 : 0;
|
|
4948
4948
|
return moveCaret((nr) => nr.setStart(after, Math.min(offset, after.textContent.length)));
|
|
4949
4949
|
}
|
|
@@ -4953,7 +4953,7 @@ function handleKeydown(event, editable, options = {}) {
|
|
|
4953
4953
|
const icon = textNode.nextSibling.nextSibling;
|
|
4954
4954
|
const after = icon.nextSibling;
|
|
4955
4955
|
event.preventDefault();
|
|
4956
|
-
if (after
|
|
4956
|
+
if (after?.nodeType === Node.TEXT_NODE) {
|
|
4957
4957
|
const offset = (after.textContent || "").startsWith("") ? 1 : 0;
|
|
4958
4958
|
return moveCaret((nr) => nr.setStart(after, Math.min(offset, after.textContent.length)));
|
|
4959
4959
|
}
|
|
@@ -5182,7 +5182,7 @@ function _domToMd(node, depth = 0) {
|
|
|
5182
5182
|
return `\`${inner()}\``;
|
|
5183
5183
|
case "pre": {
|
|
5184
5184
|
const codeEl = el.querySelector("code");
|
|
5185
|
-
const langMatch = /language-(\S+)/.exec(codeEl
|
|
5185
|
+
const langMatch = /language-(\S+)/.exec(codeEl?.className || "");
|
|
5186
5186
|
return `\n\n\`\`\`${langMatch ? langMatch[1] : ""}\n${(codeEl || el).textContent || ""}\n\`\`\`\n\n`;
|
|
5187
5187
|
}
|
|
5188
5188
|
case "blockquote": return `\n\n${inner().trim().split("\n").map((l) => `> ${l}`).join("\n")}\n\n`;
|
|
@@ -5213,7 +5213,7 @@ function _domToMd(node, depth = 0) {
|
|
|
5213
5213
|
case "table": {
|
|
5214
5214
|
const rows = Array.from(el.querySelectorAll("tr"));
|
|
5215
5215
|
if (!rows.length) return inner();
|
|
5216
|
-
const cellTexts = rows.map((tr) => Array.from(tr.querySelectorAll("th, td")).map((c) => c.textContent.trim().replaceAll("|",
|
|
5216
|
+
const cellTexts = rows.map((tr) => Array.from(tr.querySelectorAll("th, td")).map((c) => c.textContent.trim().replaceAll("|", String.raw`\|`)));
|
|
5217
5217
|
const cols = Math.max(...cellTexts.map((r) => r.length));
|
|
5218
5218
|
const padRow = (row) => {
|
|
5219
5219
|
const r = [...row];
|
|
@@ -5440,7 +5440,7 @@ var Editor = class {
|
|
|
5440
5440
|
const onSelChange = () => {
|
|
5441
5441
|
if (!this.context._alive) return;
|
|
5442
5442
|
const sel = globalThis.getSelection();
|
|
5443
|
-
if (sel
|
|
5443
|
+
if (sel?.rangeCount > 0 && editable.contains(sel.anchorNode)) {
|
|
5444
5444
|
this.context.invoke("toolbar.refresh");
|
|
5445
5445
|
if (typeof this.options.onSelectionChange === "function") this.options.onSelectionChange(this.context);
|
|
5446
5446
|
}
|
|
@@ -5856,7 +5856,7 @@ var Editor = class {
|
|
|
5856
5856
|
formatBlock(tagName);
|
|
5857
5857
|
if (tagName === "pre") {
|
|
5858
5858
|
const sel = globalThis.getSelection();
|
|
5859
|
-
if (sel
|
|
5859
|
+
if (sel?.rangeCount > 0) {
|
|
5860
5860
|
const container = sel.getRangeAt(0).commonAncestorContainer;
|
|
5861
5861
|
const pre = container.nodeType === 1 ? container.closest("pre") : container.parentElement?.closest("pre");
|
|
5862
5862
|
if (pre && !pre.dataset.language) {
|
|
@@ -5916,10 +5916,7 @@ var Editor = class {
|
|
|
5916
5916
|
if (!sel || sel.rangeCount === 0) return;
|
|
5917
5917
|
const safeUrl = sanitiseUrl(url);
|
|
5918
5918
|
if (!safeUrl) return;
|
|
5919
|
-
if (
|
|
5920
|
-
const displayText = this._escapeAttr(text || safeUrl);
|
|
5921
|
-
execCommand("insertHTML", `<a href="${this._escapeAttr(safeUrl)}"${openInNewTab ? " target=\"_blank\" rel=\"noopener noreferrer\"" : ""}>${displayText}</a>`);
|
|
5922
|
-
} else {
|
|
5919
|
+
if (sel.toString().trim().length > 0) {
|
|
5923
5920
|
execCommand("createLink", safeUrl);
|
|
5924
5921
|
if (openInNewTab) {
|
|
5925
5922
|
const link = this._getClosestAnchor();
|
|
@@ -5928,6 +5925,9 @@ var Editor = class {
|
|
|
5928
5925
|
/** @type {Element} */ link.setAttribute("rel", "noopener noreferrer");
|
|
5929
5926
|
}
|
|
5930
5927
|
}
|
|
5928
|
+
} else {
|
|
5929
|
+
const displayText = this._escapeAttr(text || safeUrl);
|
|
5930
|
+
execCommand("insertHTML", `<a href="${this._escapeAttr(safeUrl)}"${openInNewTab ? " target=\"_blank\" rel=\"noopener noreferrer\"" : ""}>${displayText}</a>`);
|
|
5931
5931
|
}
|
|
5932
5932
|
this.afterCommand();
|
|
5933
5933
|
}
|
|
@@ -6105,7 +6105,7 @@ var Toolbar = class {
|
|
|
6105
6105
|
this._refreshRaf = null;
|
|
6106
6106
|
this._disposers.forEach((d) => d());
|
|
6107
6107
|
this._disposers = [];
|
|
6108
|
-
if (this.el
|
|
6108
|
+
if (this.el?.parentNode) this.el.remove();
|
|
6109
6109
|
this.el = null;
|
|
6110
6110
|
}
|
|
6111
6111
|
_buildButtons() {
|
|
@@ -6434,7 +6434,10 @@ var Toolbar = class {
|
|
|
6434
6434
|
select.appendChild(placeholder);
|
|
6435
6435
|
items.forEach((item) => {
|
|
6436
6436
|
const value = typeof item === "object" ? item.value : item;
|
|
6437
|
-
|
|
6437
|
+
let label;
|
|
6438
|
+
if (typeof item !== "object") label = item;
|
|
6439
|
+
else if (def.name === "paragraphStyle") label = this.context.locale.toolbar.paragraphItems?.[item.value] || item.label;
|
|
6440
|
+
else label = item.label;
|
|
6438
6441
|
const isHeader = typeof item === "object" && !!item.disabled;
|
|
6439
6442
|
const attrs = { value };
|
|
6440
6443
|
if (isHeader) attrs.disabled = "";
|
|
@@ -6534,9 +6537,9 @@ var Toolbar = class {
|
|
|
6534
6537
|
);
|
|
6535
6538
|
if (!def || typeof def.getValue !== "function") return;
|
|
6536
6539
|
let raw = (def.getValue(this.context) || "").replace(/["']/g, "").trim();
|
|
6537
|
-
if (!raw) raw = this.options.defaultFontFamily || this.options.fontFamilies
|
|
6540
|
+
if (!raw) raw = this.options.defaultFontFamily || this.options.fontFamilies?.[0] || "";
|
|
6538
6541
|
const sel = select;
|
|
6539
|
-
const matched = Array.from(sel.options).find((opt) => opt.value
|
|
6542
|
+
const matched = Array.from(sel.options).find((opt) => opt.value?.toLowerCase() === raw.toLowerCase());
|
|
6540
6543
|
sel.value = matched ? matched.value : "";
|
|
6541
6544
|
});
|
|
6542
6545
|
}
|
|
@@ -6795,7 +6798,7 @@ var Clipboard = class {
|
|
|
6795
6798
|
* @param {Node} node
|
|
6796
6799
|
*/
|
|
6797
6800
|
_revokeRemovedBlobs(node) {
|
|
6798
|
-
if (!this._blobRegistry
|
|
6801
|
+
if (!this._blobRegistry?.size) return;
|
|
6799
6802
|
const imgs = [];
|
|
6800
6803
|
if (node.nodeName === "IMG") imgs.push(node);
|
|
6801
6804
|
else if (node.querySelectorAll) imgs.push(...node.querySelectorAll("img"));
|
|
@@ -6933,7 +6936,7 @@ var Clipboard = class {
|
|
|
6933
6936
|
}
|
|
6934
6937
|
_onDrop(event) {
|
|
6935
6938
|
const dt = event.dataTransfer;
|
|
6936
|
-
if (!dt
|
|
6939
|
+
if (!dt?.files?.length) return;
|
|
6937
6940
|
const imageFiles = Array.from(dt.files).filter((f) => f.type.startsWith("image/"));
|
|
6938
6941
|
if (imageFiles.length === 0) return;
|
|
6939
6942
|
event.preventDefault();
|
|
@@ -6962,7 +6965,7 @@ var Clipboard = class {
|
|
|
6962
6965
|
]);
|
|
6963
6966
|
const maxBytes = (this.options.maxImageSize || 5) * 1024 * 1024;
|
|
6964
6967
|
files.forEach((file) => {
|
|
6965
|
-
if (!file
|
|
6968
|
+
if (!file?.type?.startsWith("image/")) return;
|
|
6966
6969
|
if (UNSUPPORTED.has(file.type)) {
|
|
6967
6970
|
const message = `Image format "${file.type}" is not supported for display in web browsers. Please convert to PNG, JPEG, or WebP first.`;
|
|
6968
6971
|
this.context.triggerEvent("imageError", {
|
|
@@ -7005,7 +7008,7 @@ var Clipboard = class {
|
|
|
7005
7008
|
* @returns {string}
|
|
7006
7009
|
*/
|
|
7007
7010
|
resolveImages(html) {
|
|
7008
|
-
if (!this._blobRegistry
|
|
7011
|
+
if (!this._blobRegistry?.size) return html;
|
|
7009
7012
|
return html.replace(/blob:[^"'> \t\n\r]*/g, (url) => this._blobRegistry.get(url) || url);
|
|
7010
7013
|
}
|
|
7011
7014
|
/**
|
|
@@ -7467,7 +7470,7 @@ var LinkDialog = class extends BaseDialog {
|
|
|
7467
7470
|
_prefill() {
|
|
7468
7471
|
const sel = globalThis.getSelection();
|
|
7469
7472
|
let anchor = null;
|
|
7470
|
-
if (sel
|
|
7473
|
+
if (sel?.rangeCount > 0) {
|
|
7471
7474
|
let node = sel.getRangeAt(0).startContainer;
|
|
7472
7475
|
while (node) {
|
|
7473
7476
|
if (node.nodeName === "A") {
|
|
@@ -7620,8 +7623,8 @@ var ImageDialog = class extends BaseDialog {
|
|
|
7620
7623
|
return overlay;
|
|
7621
7624
|
}
|
|
7622
7625
|
_onFileChange() {
|
|
7623
|
-
const file = this._fileInput
|
|
7624
|
-
if (!file
|
|
7626
|
+
const file = this._fileInput?.files?.[0];
|
|
7627
|
+
if (!file?.type?.startsWith("image/")) return;
|
|
7625
7628
|
if (!new Set([
|
|
7626
7629
|
"image/jpeg",
|
|
7627
7630
|
"image/png",
|
|
@@ -7661,7 +7664,7 @@ var ImageDialog = class extends BaseDialog {
|
|
|
7661
7664
|
_onInsert() {
|
|
7662
7665
|
const src = this._urlInput.value.trim();
|
|
7663
7666
|
const alt = this._altInput.value.trim();
|
|
7664
|
-
const alignRadio = this._alignRow
|
|
7667
|
+
const alignRadio = this._alignRow?.querySelector("input[name=\"an-img-align\"]:checked");
|
|
7665
7668
|
const align = alignRadio ? alignRadio.value : "";
|
|
7666
7669
|
if (!src) {
|
|
7667
7670
|
this._urlInput.focus();
|
|
@@ -7721,7 +7724,10 @@ var VideoDialog = class extends BaseDialog {
|
|
|
7721
7724
|
box.append(urlLabel, urlInput, hintEl, widthLabel, widthInput, btnRow);
|
|
7722
7725
|
const d0 = on(urlInput, "input", () => {
|
|
7723
7726
|
const info = this._parseVideoUrl(urlInput.value.trim());
|
|
7724
|
-
|
|
7727
|
+
let hint = "";
|
|
7728
|
+
if (info) hint = this.context.locale.videoDialog.detected(info.type);
|
|
7729
|
+
else if (urlInput.value) hint = this.context.locale.videoDialog.unknownFormat;
|
|
7730
|
+
hintEl.textContent = hint;
|
|
7725
7731
|
});
|
|
7726
7732
|
const d4 = on(urlInput, "keydown", (e) => {
|
|
7727
7733
|
if (e.key === "Enter") {
|
|
@@ -7801,7 +7807,7 @@ var VideoDialog = class extends BaseDialog {
|
|
|
7801
7807
|
const iframeTitle = `${info.type} video player`;
|
|
7802
7808
|
return `<div class="an-video-wrapper" style="position:relative;display:block;width:${width}px;max-width:100%"><iframe src="${info.embedUrl}" width="${width}" height="${height}" title="${iframeTitle}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" style="display:block;max-width:100%"></iframe><div class="an-video-shield"></div></div>`;
|
|
7803
7809
|
}
|
|
7804
|
-
if (info
|
|
7810
|
+
if (info?.type === "Direct video") return `<div class="an-video-wrapper" style="position:relative;display:block;width:${width}px;max-width:100%"><video src="${info.embedUrl.replaceAll("\"", "%22")}" width="${width}" height="${height}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`;
|
|
7805
7811
|
const safeSrc = (() => {
|
|
7806
7812
|
try {
|
|
7807
7813
|
const p = new URL(url);
|
|
@@ -7898,7 +7904,7 @@ var ImageResizer = class {
|
|
|
7898
7904
|
this._positionRaf = null;
|
|
7899
7905
|
}
|
|
7900
7906
|
this._deselect();
|
|
7901
|
-
if (this._overlay
|
|
7907
|
+
if (this._overlay?.parentNode) this._overlay.remove();
|
|
7902
7908
|
this._overlay = null;
|
|
7903
7909
|
}
|
|
7904
7910
|
/** @returns {HTMLImageElement|null} */
|
|
@@ -7941,7 +7947,7 @@ var ImageResizer = class {
|
|
|
7941
7947
|
_onDocClick(e) {
|
|
7942
7948
|
if (!this._activeImg) return;
|
|
7943
7949
|
if (e.target === this._activeImg) return;
|
|
7944
|
-
if (this._overlay
|
|
7950
|
+
if (this._overlay?.contains(e.target)) return;
|
|
7945
7951
|
if (e.target.closest(".an-contextmenu")) return;
|
|
7946
7952
|
this._deselect();
|
|
7947
7953
|
}
|
|
@@ -8303,7 +8309,7 @@ var LinkTooltip = class {
|
|
|
8303
8309
|
this._clearTimers();
|
|
8304
8310
|
this._disposers.forEach((d) => d());
|
|
8305
8311
|
this._disposers = [];
|
|
8306
|
-
if (this._el
|
|
8312
|
+
if (this._el?.parentNode) this._el.remove();
|
|
8307
8313
|
this._el = null;
|
|
8308
8314
|
}
|
|
8309
8315
|
_buildTooltip() {
|
|
@@ -8397,7 +8403,7 @@ var LinkTooltip = class {
|
|
|
8397
8403
|
_truncateUrl(url) {
|
|
8398
8404
|
try {
|
|
8399
8405
|
const u = new URL(url);
|
|
8400
|
-
const display = u.host + (u.pathname
|
|
8406
|
+
const display = u.host + (u.pathname === "/" ? "" : u.pathname);
|
|
8401
8407
|
return display.length > 48 ? display.slice(0, 48) + "…" : display;
|
|
8402
8408
|
} catch {
|
|
8403
8409
|
return url.length > 48 ? url.slice(0, 48) + "…" : url;
|
|
@@ -8422,7 +8428,7 @@ var LinkTooltip = class {
|
|
|
8422
8428
|
});
|
|
8423
8429
|
if (this._copyBtn) {
|
|
8424
8430
|
this._copyBtn.classList.add("an-link-tooltip-btn--copied");
|
|
8425
|
-
setTimeout(() => this._copyBtn
|
|
8431
|
+
setTimeout(() => this._copyBtn?.classList.remove("an-link-tooltip-btn--copied"), 1e3);
|
|
8426
8432
|
}
|
|
8427
8433
|
}
|
|
8428
8434
|
_editLink() {
|
|
@@ -8657,7 +8663,8 @@ var ImageTooltip = class {
|
|
|
8657
8663
|
const match = /rotate\((-?[\d.]+)deg\)/.exec(current);
|
|
8658
8664
|
const next = ((match ? Number.parseFloat(match[1]) : 0) + delta + 360) % 360;
|
|
8659
8665
|
const cleaned = current.replace(/rotate\(-?[\d.]+deg\)/, "").trim();
|
|
8660
|
-
img.style.transform =
|
|
8666
|
+
if (cleaned) img.style.transform = `${cleaned} rotate(${next}deg)`;
|
|
8667
|
+
else img.style.transform = next === 0 ? "" : `rotate(${next}deg)`;
|
|
8661
8668
|
this.context.invoke("editor.afterCommand");
|
|
8662
8669
|
this.context.invoke("imageResizer.updateOverlay");
|
|
8663
8670
|
requestAnimationFrame(() => {
|
|
@@ -9160,8 +9167,7 @@ var TableTooltip = class {
|
|
|
9160
9167
|
const onSelMouseup = () => {
|
|
9161
9168
|
this._selectDragging = false;
|
|
9162
9169
|
};
|
|
9163
|
-
this._disposers.push(on(editable, "mousedown", onSelMousedown), on(editable, "mousemove", onSelMousemove), on(document, "mouseup", onSelMouseup))
|
|
9164
|
-
this._disposers.push(on(editable, "mouseover", (e) => {
|
|
9170
|
+
this._disposers.push(on(editable, "mousedown", onSelMousedown), on(editable, "mousemove", onSelMousemove), on(document, "mouseup", onSelMouseup), on(editable, "mouseover", (e) => {
|
|
9165
9171
|
if (this.context.layoutInfo.container.classList.contains("an-disabled")) return;
|
|
9166
9172
|
const table = e.target?.closest("table");
|
|
9167
9173
|
if (table && editable.contains(table)) {
|
|
@@ -9249,12 +9255,14 @@ var TableTooltip = class {
|
|
|
9249
9255
|
_startY = e.clientY;
|
|
9250
9256
|
_table = _nearCell.closest("table");
|
|
9251
9257
|
if (_edge === "col") {
|
|
9252
|
-
|
|
9253
|
-
_colIdx = getVisualColIndex(_nearCell);
|
|
9258
|
+
_colIdx = getVisualColIndex(_nearCell) + (_nearCell.colSpan || 1) - 1;
|
|
9254
9259
|
_colCells = _colIdx >= 0 ? Array.from(_table.querySelectorAll("tr")).map((r) => getCellAtVisualCol(r, _colIdx)).filter(Boolean).filter((c) => (c.colSpan || 1) === 1) : [];
|
|
9260
|
+
_startW = _colCells.length > 0 ? _colCells[0].offsetWidth : Math.max(30, Math.round(_nearCell.offsetWidth / (_nearCell.colSpan || 1)));
|
|
9255
9261
|
document.body.style.cursor = "col-resize";
|
|
9256
9262
|
} else {
|
|
9257
|
-
|
|
9263
|
+
const tr = _nearCell.closest("tr");
|
|
9264
|
+
const lastRowIdx = (tr ? Array.from(_table.rows).indexOf(tr) : 0) + (_nearCell.rowSpan || 1) - 1;
|
|
9265
|
+
_row = _table.rows[lastRowIdx] || tr;
|
|
9258
9266
|
_startH = _row ? _row.offsetHeight : 40;
|
|
9259
9267
|
document.body.style.cursor = "row-resize";
|
|
9260
9268
|
}
|
|
@@ -9306,7 +9314,7 @@ var TableTooltip = class {
|
|
|
9306
9314
|
this._clearTimers();
|
|
9307
9315
|
this._disposers.forEach((d) => d());
|
|
9308
9316
|
this._disposers = [];
|
|
9309
|
-
if (this._el
|
|
9317
|
+
if (this._el?.parentNode) this._el.remove();
|
|
9310
9318
|
this._el = null;
|
|
9311
9319
|
if (this._sizePopover?.parentNode) this._sizePopover.remove();
|
|
9312
9320
|
this._sizePopover = null;
|
|
@@ -9566,7 +9574,8 @@ var TableTooltip = class {
|
|
|
9566
9574
|
const refRow = selectedRows.reduce((best, r) => {
|
|
9567
9575
|
const bi = allRows.indexOf(best);
|
|
9568
9576
|
const ri = allRows.indexOf(r);
|
|
9569
|
-
|
|
9577
|
+
if (position === "above") return ri < bi ? r : best;
|
|
9578
|
+
return ri > bi ? r : best;
|
|
9570
9579
|
}, selectedRows[0]);
|
|
9571
9580
|
const colCount = Array.from(refRow.cells).reduce((sum, c) => sum + (c.colSpan || 1), 0);
|
|
9572
9581
|
const newRow = document.createElement("tr");
|
|
@@ -9579,7 +9588,7 @@ var TableTooltip = class {
|
|
|
9579
9588
|
newRow.appendChild(td);
|
|
9580
9589
|
}
|
|
9581
9590
|
if (position === "above") refRow.parentElement?.insertBefore(newRow, refRow);
|
|
9582
|
-
else refRow.
|
|
9591
|
+
else refRow.after(newRow);
|
|
9583
9592
|
requestAnimationFrame(() => this._positionNear(this._activeTable));
|
|
9584
9593
|
this.context.invoke("editor.afterCommand");
|
|
9585
9594
|
}
|
|
@@ -9684,8 +9693,15 @@ var TableTooltip = class {
|
|
|
9684
9693
|
first.colSpan = maxC - minC + 1;
|
|
9685
9694
|
first.rowSpan = maxR - minR + 1;
|
|
9686
9695
|
first.style.verticalAlign = "middle";
|
|
9687
|
-
first.
|
|
9688
|
-
|
|
9696
|
+
first.style.height = "";
|
|
9697
|
+
first.style.minHeight = "";
|
|
9698
|
+
const parts = rectCells.map((c) => c.innerHTML.replace(/^(<br\s*\/?>|\s)+$/i, "").trim()).filter((h) => h !== "");
|
|
9699
|
+
first.innerHTML = parts.length ? parts.join("<br>") : "<br>";
|
|
9700
|
+
rectCells.slice(1).forEach((c) => {
|
|
9701
|
+
const row = c.parentElement;
|
|
9702
|
+
c.remove();
|
|
9703
|
+
if (row && row.cells.length === 0) row.remove();
|
|
9704
|
+
});
|
|
9689
9705
|
this._clearSelection();
|
|
9690
9706
|
this.context.invoke("editor.afterCommand");
|
|
9691
9707
|
}
|
|
@@ -9737,12 +9753,9 @@ var TableTooltip = class {
|
|
|
9737
9753
|
const targetRow = tableRows[r + dr];
|
|
9738
9754
|
if (!targetRow) continue;
|
|
9739
9755
|
let ref = null;
|
|
9740
|
-
for (const tc of targetRow.cells) {
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
ref = tc;
|
|
9744
|
-
break;
|
|
9745
|
-
}
|
|
9756
|
+
for (const tc of targetRow.cells) if (cellPos.get(tc)?.c > c) {
|
|
9757
|
+
ref = tc;
|
|
9758
|
+
break;
|
|
9746
9759
|
}
|
|
9747
9760
|
for (let dc = 0; dc < cs; dc++) targetRow.insertBefore(createElement(tag, {}, ["\xA0"]), ref);
|
|
9748
9761
|
}
|
|
@@ -9837,7 +9850,11 @@ var TableTooltip = class {
|
|
|
9837
9850
|
this._sizeTitleEl.textContent = isCol ? this.context.locale.tooltips.table.columnWidthPx : this.context.locale.tooltips.table.rowHeightPx;
|
|
9838
9851
|
this._sizeInputEl.min = "1";
|
|
9839
9852
|
this._sizeInputEl.max = "2000";
|
|
9840
|
-
this._sizeInputEl.value =
|
|
9853
|
+
if (isCol) this._sizeInputEl.value = cell.offsetWidth || 120;
|
|
9854
|
+
else {
|
|
9855
|
+
const refRow = cell.closest("tr");
|
|
9856
|
+
this._sizeInputEl.value = refRow ? refRow.offsetHeight || 40 : 40;
|
|
9857
|
+
}
|
|
9841
9858
|
this._sizeApply = (val) => {
|
|
9842
9859
|
const table = cell.closest("table");
|
|
9843
9860
|
if (!table) return;
|
|
@@ -9925,8 +9942,7 @@ var TableTooltip = class {
|
|
|
9925
9942
|
customRow.appendChild(colorInput);
|
|
9926
9943
|
customRow.appendChild(customLabel);
|
|
9927
9944
|
pop.appendChild(customRow);
|
|
9928
|
-
this._disposers.push(on(pop, "mousedown", (e) => e.preventDefault()), on(pop, "mouseenter", () => this._clearTimers()), on(pop, "mouseleave", () => this._scheduleHide()))
|
|
9929
|
-
this._disposers.push(on(document, "click", (e) => {
|
|
9945
|
+
this._disposers.push(on(pop, "mousedown", (e) => e.preventDefault()), on(pop, "mouseenter", () => this._clearTimers()), on(pop, "mouseleave", () => this._scheduleHide()), on(document, "click", (e) => {
|
|
9930
9946
|
const et = e.target;
|
|
9931
9947
|
if (this._shadePopover && this._shadePopover.style.display !== "none" && !this._shadePopover.contains(et) && !this._el?.contains(et)) this._hideCellShadePopover();
|
|
9932
9948
|
}));
|
|
@@ -12800,7 +12816,7 @@ var EmojiDialog = class extends BaseDialog {
|
|
|
12800
12816
|
const editable = this.context.layoutInfo.editable;
|
|
12801
12817
|
if (savedRange) savedRange.select();
|
|
12802
12818
|
const sel = globalThis.getSelection();
|
|
12803
|
-
let range = sel
|
|
12819
|
+
let range = sel?.rangeCount > 0 ? sel.getRangeAt(0) : null;
|
|
12804
12820
|
if (!range) {
|
|
12805
12821
|
range = document.createRange();
|
|
12806
12822
|
range.selectNodeContents(editable);
|
|
@@ -13367,7 +13383,7 @@ var IconDialog = class extends BaseDialog {
|
|
|
13367
13383
|
const _sc = range.startContainer;
|
|
13368
13384
|
const _tdAnchor = (_sc.nodeType === 1 ? _sc : _sc.parentElement)?.closest("td, th");
|
|
13369
13385
|
range.deleteContents();
|
|
13370
|
-
if (_tdAnchor
|
|
13386
|
+
if (_tdAnchor?.isConnected && !_tdAnchor.contains(range.startContainer)) {
|
|
13371
13387
|
range.setStart(_tdAnchor, 0);
|
|
13372
13388
|
range.collapse(true);
|
|
13373
13389
|
}
|
|
@@ -13593,7 +13609,7 @@ var ContextMenu = class {
|
|
|
13593
13609
|
constructor(context) {
|
|
13594
13610
|
this.context = context;
|
|
13595
13611
|
this.options = context.options || {};
|
|
13596
|
-
this._items = this.options.contextMenu
|
|
13612
|
+
this._items = this.options.contextMenu?.items || defaultItems;
|
|
13597
13613
|
this.el = null;
|
|
13598
13614
|
this._disposers = [];
|
|
13599
13615
|
this._menuDisposers = [];
|
|
@@ -13613,11 +13629,9 @@ var ContextMenu = class {
|
|
|
13613
13629
|
this._renderItems(this._items);
|
|
13614
13630
|
const editable = this.context.layoutInfo?.editable;
|
|
13615
13631
|
if (editable) this._disposers.push(on(editable, "contextmenu", (e) => this._onContextMenu(e)));
|
|
13616
|
-
this._disposers.push(on(document, "click", (e) => this._maybeHide(e)))
|
|
13617
|
-
this._disposers.push(on(document, "keydown", (e) => {
|
|
13632
|
+
this._disposers.push(on(document, "click", (e) => this._maybeHide(e)), on(document, "keydown", (e) => {
|
|
13618
13633
|
if (e.key === "Escape") this.hide();
|
|
13619
|
-
}));
|
|
13620
|
-
this._disposers.push(on(globalThis, "scroll", () => this.hide(), { passive: true }));
|
|
13634
|
+
}), on(globalThis, "scroll", () => this.hide(), { passive: true }));
|
|
13621
13635
|
return this;
|
|
13622
13636
|
}
|
|
13623
13637
|
destroy() {
|
|
@@ -13882,7 +13896,7 @@ var ContextMenu = class {
|
|
|
13882
13896
|
if (this.context.layoutInfo.container.classList.contains("an-disabled")) return;
|
|
13883
13897
|
event.preventDefault();
|
|
13884
13898
|
const winSel = globalThis.getSelection();
|
|
13885
|
-
this._savedRange = winSel
|
|
13899
|
+
this._savedRange = winSel?.rangeCount > 0 ? winSel.getRangeAt(0).cloneRange() : null;
|
|
13886
13900
|
this._renderItems(this._items);
|
|
13887
13901
|
const openX = event.clientX;
|
|
13888
13902
|
let openY = event.clientY;
|
|
@@ -13907,8 +13921,8 @@ var ContextMenu = class {
|
|
|
13907
13921
|
}
|
|
13908
13922
|
_reposition(x, y) {
|
|
13909
13923
|
if (!this.el) return;
|
|
13910
|
-
const rx = x
|
|
13911
|
-
const ry = y
|
|
13924
|
+
const rx = x === void 0 ? this._lastX : x;
|
|
13925
|
+
const ry = y === void 0 ? this._lastY : y;
|
|
13912
13926
|
const w = this.el.offsetWidth;
|
|
13913
13927
|
const h = this.el.offsetHeight;
|
|
13914
13928
|
let left = rx;
|
|
@@ -13964,7 +13978,7 @@ var ContextMenu = class {
|
|
|
13964
13978
|
const editable = this.context.layoutInfo?.editable;
|
|
13965
13979
|
let node = range.startContainer;
|
|
13966
13980
|
if (node.nodeType === Node.TEXT_NODE) node = node.parentElement;
|
|
13967
|
-
if (!node || !editable
|
|
13981
|
+
if (!node || !editable?.contains(node)) return;
|
|
13968
13982
|
const cs = globalThis.getComputedStyle(node);
|
|
13969
13983
|
const explicitFontFamily = this._findExplicitStyle(node, editable, "fontFamily");
|
|
13970
13984
|
const explicitFontSize = this._findExplicitStyle(node, editable, "fontSize");
|
|
@@ -13983,7 +13997,7 @@ var ContextMenu = class {
|
|
|
13983
13997
|
_findExplicitStyle(node, boundary, prop) {
|
|
13984
13998
|
let el = node;
|
|
13985
13999
|
while (el && el !== boundary && el !== document.body) {
|
|
13986
|
-
if (el.style
|
|
14000
|
+
if (el.style?.[prop]) return el.style[prop];
|
|
13987
14001
|
if (el.nodeName === "FONT") {
|
|
13988
14002
|
if (prop === "fontFamily" && el.getAttribute("face")) return el.getAttribute("face");
|
|
13989
14003
|
if (prop === "fontSize" && el.getAttribute("size")) return null;
|
|
@@ -14432,7 +14446,7 @@ var FindReplace = class extends BaseDialog {
|
|
|
14432
14446
|
this._matches = this._matches.filter((m) => m.mark);
|
|
14433
14447
|
this._currentIndex = 0;
|
|
14434
14448
|
if (this._matches.length === 0) return;
|
|
14435
|
-
if (this._matches[0]
|
|
14449
|
+
if (this._matches[0]?.mark) {
|
|
14436
14450
|
this._matches[0].mark.className = "an-highlight an-highlight-current";
|
|
14437
14451
|
this._matches[0].mark.scrollIntoView({
|
|
14438
14452
|
block: "center",
|
|
@@ -14450,7 +14464,7 @@ var FindReplace = class extends BaseDialog {
|
|
|
14450
14464
|
const results = [];
|
|
14451
14465
|
if (this._lastQuery !== query || this._lastCaseSensitive !== this._caseSensitive) {
|
|
14452
14466
|
const flags = this._caseSensitive ? "g" : "gi";
|
|
14453
|
-
const escaped = query.replace(/[.*+?^${}()|[\]\\]/g,
|
|
14467
|
+
const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
|
14454
14468
|
this._queryRegex = new RegExp(escaped, flags);
|
|
14455
14469
|
this._lastQuery = query;
|
|
14456
14470
|
this._lastCaseSensitive = this._caseSensitive;
|
|
@@ -14488,7 +14502,7 @@ var FindReplace = class extends BaseDialog {
|
|
|
14488
14502
|
}
|
|
14489
14503
|
_scrollToMatch(index) {
|
|
14490
14504
|
const match = this._matches[index];
|
|
14491
|
-
if (!match
|
|
14505
|
+
if (!match?.mark) return;
|
|
14492
14506
|
this._matches.forEach((m, i) => {
|
|
14493
14507
|
if (m.mark) m.mark.className = i === index ? "an-highlight an-highlight-current" : "an-highlight";
|
|
14494
14508
|
});
|
|
@@ -14500,7 +14514,7 @@ var FindReplace = class extends BaseDialog {
|
|
|
14500
14514
|
_replace() {
|
|
14501
14515
|
if (this._matches.length === 0 || this._currentIndex < 0) return;
|
|
14502
14516
|
const match = this._matches[this._currentIndex];
|
|
14503
|
-
if (!match
|
|
14517
|
+
if (!match?.mark?.parentNode) return;
|
|
14504
14518
|
const replacement = this._replaceInput ? this._replaceInput.value : "";
|
|
14505
14519
|
const parent = match.mark.parentNode;
|
|
14506
14520
|
const textNode = document.createTextNode(replacement);
|
|
@@ -14520,7 +14534,7 @@ var FindReplace = class extends BaseDialog {
|
|
|
14520
14534
|
if (this._matches.length === 0) return;
|
|
14521
14535
|
const replacement = this._replaceInput ? this._replaceInput.value : "";
|
|
14522
14536
|
this._matches.forEach(({ mark }) => {
|
|
14523
|
-
if (!mark
|
|
14537
|
+
if (!mark?.parentNode) return;
|
|
14524
14538
|
const textNode = document.createTextNode(replacement);
|
|
14525
14539
|
mark.parentNode.insertBefore(textNode, mark);
|
|
14526
14540
|
mark.remove();
|
|
@@ -15963,7 +15977,7 @@ var Mention = class {
|
|
|
15963
15977
|
}
|
|
15964
15978
|
_getQueryAtCursor() {
|
|
15965
15979
|
const sel = globalThis.getSelection();
|
|
15966
|
-
if (!sel
|
|
15980
|
+
if (!sel?.rangeCount) return null;
|
|
15967
15981
|
const range = sel.getRangeAt(0);
|
|
15968
15982
|
if (!range.collapsed) return null;
|
|
15969
15983
|
const node = range.startContainer;
|
|
@@ -16081,12 +16095,12 @@ var Context = class {
|
|
|
16081
16095
|
this.layoutInfo.editable = editable;
|
|
16082
16096
|
this._registerModules();
|
|
16083
16097
|
const toolbar = this._modules.get("toolbar");
|
|
16084
|
-
if (toolbar
|
|
16098
|
+
if (toolbar?.el) {
|
|
16085
16099
|
container.insertBefore(toolbar.el, editable);
|
|
16086
16100
|
this.layoutInfo.toolbar = toolbar.el;
|
|
16087
16101
|
}
|
|
16088
16102
|
const statusbar = this._modules.get("statusbar");
|
|
16089
|
-
if (statusbar
|
|
16103
|
+
if (statusbar?.el) {
|
|
16090
16104
|
container.appendChild(statusbar.el);
|
|
16091
16105
|
this.layoutInfo.statusbar = statusbar.el;
|
|
16092
16106
|
}
|
|
@@ -16707,7 +16721,7 @@ var AutumnNote = {
|
|
|
16707
16721
|
return this;
|
|
16708
16722
|
},
|
|
16709
16723
|
/** Library version */
|
|
16710
|
-
version: "1.6.
|
|
16724
|
+
version: "1.6.7"
|
|
16711
16725
|
};
|
|
16712
16726
|
/**
|
|
16713
16727
|
* @param {string|Element|NodeList|Element[]} selector
|