autumnnote 1.6.2 → 1.6.5
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 +76 -187
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.umd.js +76 -187
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/js/core/detectLang.js +1 -1
- package/src/js/core/dom.js +3 -5
- package/src/js/editing/Style.js +10 -10
- package/src/js/editing/Typing.js +5 -5
- package/src/js/index.js +1 -1
- package/src/js/module/BaseDialog.js +1 -1
- package/src/js/module/BubbleToolbar.js +2 -2
- package/src/js/module/Buttons.js +8 -8
- package/src/js/module/Editor.js +4 -4
- package/src/js/module/EmojiDialog.js +7 -44
- package/src/js/module/FindReplace.js +4 -18
- package/src/js/module/IconDialog.js +10 -42
- package/src/js/module/ImageCropOverlay.js +1 -1
- package/src/js/module/ImageResizer.js +1 -1
- package/src/js/module/Mention.js +1 -1
- package/src/js/module/ShortcutsDialog.js +20 -49
- package/src/js/module/TableTooltip.js +7 -7
- package/src/js/module/Toolbar.js +9 -11
package/dist/autumnnote.umd.js
CHANGED
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
*/
|
|
322
322
|
function underline() {
|
|
323
323
|
const sel = globalThis.getSelection();
|
|
324
|
-
if (!sel
|
|
324
|
+
if (!sel?.rangeCount) return;
|
|
325
325
|
let container = sel.getRangeAt(0).commonAncestorContainer;
|
|
326
326
|
if (container.nodeType === 3) container = container.parentElement;
|
|
327
327
|
const uEl = container?.closest("u");
|
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
*/
|
|
342
342
|
function strikethrough() {
|
|
343
343
|
const sel = globalThis.getSelection();
|
|
344
|
-
if (!sel
|
|
344
|
+
if (!sel?.rangeCount) return;
|
|
345
345
|
let sc = sel.getRangeAt(0).startContainer;
|
|
346
346
|
if (sc.nodeType === 3) sc = sc.parentElement;
|
|
347
347
|
const sEl = sc?.closest("s") || sc?.closest("strike");
|
|
@@ -385,7 +385,7 @@
|
|
|
385
385
|
*/
|
|
386
386
|
function fontSize(size, editable = document) {
|
|
387
387
|
const sel = globalThis.getSelection();
|
|
388
|
-
const wasCollapsed = !sel
|
|
388
|
+
const wasCollapsed = !sel?.rangeCount || sel.getRangeAt(0).collapsed;
|
|
389
389
|
if (wasCollapsed && sel && sel.rangeCount > 0) {
|
|
390
390
|
try {
|
|
391
391
|
const range = sel.getRangeAt(0);
|
|
@@ -460,7 +460,7 @@
|
|
|
460
460
|
*/
|
|
461
461
|
function outdent() {
|
|
462
462
|
const sel = globalThis.getSelection();
|
|
463
|
-
if (sel
|
|
463
|
+
if (sel?.rangeCount) {
|
|
464
464
|
let container = sel.getRangeAt(0).commonAncestorContainer;
|
|
465
465
|
if (container.nodeType === 3) container = container.parentElement;
|
|
466
466
|
const checkLi = container?.closest(".an-checklist li");
|
|
@@ -510,7 +510,7 @@
|
|
|
510
510
|
try {
|
|
511
511
|
const nr = document.createRange();
|
|
512
512
|
const firstChild = p.firstChild;
|
|
513
|
-
nr.setStart(firstChild
|
|
513
|
+
nr.setStart(firstChild?.nodeType === 3 ? firstChild : p, 0);
|
|
514
514
|
nr.collapse(true);
|
|
515
515
|
const s = globalThis.getSelection();
|
|
516
516
|
if (s) {
|
|
@@ -589,7 +589,7 @@
|
|
|
589
589
|
*/
|
|
590
590
|
function toggleInlineCode(_editable) {
|
|
591
591
|
const sel = globalThis.getSelection();
|
|
592
|
-
if (!sel
|
|
592
|
+
if (!sel?.rangeCount) return;
|
|
593
593
|
const range = sel.getRangeAt(0);
|
|
594
594
|
let container = range.commonAncestorContainer;
|
|
595
595
|
if (container.nodeType === 3) container = container.parentElement;
|
|
@@ -645,7 +645,7 @@
|
|
|
645
645
|
*/
|
|
646
646
|
function isInlineCode() {
|
|
647
647
|
const sel = globalThis.getSelection();
|
|
648
|
-
if (!sel
|
|
648
|
+
if (!sel?.rangeCount) return false;
|
|
649
649
|
let sc = sel.getRangeAt(0).startContainer;
|
|
650
650
|
if (sc.nodeType === 3) sc = sc.parentElement;
|
|
651
651
|
const code = sc?.closest("code");
|
|
@@ -667,7 +667,7 @@
|
|
|
667
667
|
*/
|
|
668
668
|
function toggleChecklist() {
|
|
669
669
|
const sel = globalThis.getSelection();
|
|
670
|
-
if (!sel
|
|
670
|
+
if (!sel?.rangeCount) return;
|
|
671
671
|
const range = sel.getRangeAt(0);
|
|
672
672
|
let container = range.commonAncestorContainer;
|
|
673
673
|
if (container.nodeType === 3) container = container.parentElement;
|
|
@@ -716,7 +716,7 @@
|
|
|
716
716
|
"LI"
|
|
717
717
|
]);
|
|
718
718
|
let block = container;
|
|
719
|
-
while (block
|
|
719
|
+
while (block?.parentNode && !BLOCK_TAGS.has(block.tagName)) block = block.parentNode;
|
|
720
720
|
const itemText = block && BLOCK_TAGS.has(block.tagName) ? Array.from(block.childNodes).map((n) => n.textContent).join("").replaceAll("\xA0", " ") : "";
|
|
721
721
|
const ul = document.createElement("ul");
|
|
722
722
|
ul.className = "an-checklist";
|
|
@@ -803,7 +803,7 @@
|
|
|
803
803
|
*/
|
|
804
804
|
function isInChecklist() {
|
|
805
805
|
const sel = globalThis.getSelection();
|
|
806
|
-
if (!sel
|
|
806
|
+
if (!sel?.rangeCount) return false;
|
|
807
807
|
let container = sel.getRangeAt(0).commonAncestorContainer;
|
|
808
808
|
if (container.nodeType === 3) container = container.parentElement;
|
|
809
809
|
return !!container?.closest(".an-checklist li");
|
|
@@ -889,10 +889,10 @@
|
|
|
889
889
|
var underlineBtn = btn("underline", "underline", "Underline (Ctrl+U)", () => underline(), () => {
|
|
890
890
|
if (document.queryCommandState("underline")) return true;
|
|
891
891
|
const sel = globalThis.getSelection();
|
|
892
|
-
if (!sel
|
|
892
|
+
if (!sel?.rangeCount) return false;
|
|
893
893
|
let sc = sel.getRangeAt(0).startContainer;
|
|
894
894
|
if (sc.nodeType === 3) sc = sc.parentElement;
|
|
895
|
-
return !!
|
|
895
|
+
return !!sc?.closest("u");
|
|
896
896
|
});
|
|
897
897
|
var strikeBtn = btn("strikethrough", "strikethrough", "Strikethrough", () => strikethrough(), () => document.queryCommandState("strikeThrough"));
|
|
898
898
|
var superscriptBtn = btn("superscript", "superscript", "Superscript", () => superscript(), () => document.queryCommandState("superscript"));
|
|
@@ -952,11 +952,11 @@
|
|
|
952
952
|
getValue: (ctx) => {
|
|
953
953
|
try {
|
|
954
954
|
const sel = globalThis.getSelection();
|
|
955
|
-
if (sel
|
|
955
|
+
if (sel?.rangeCount) {
|
|
956
956
|
let el = sel.getRangeAt(0).startContainer;
|
|
957
|
-
if (el
|
|
958
|
-
while (el
|
|
959
|
-
const size = el
|
|
957
|
+
if (el?.nodeType === 3) el = el.parentElement;
|
|
958
|
+
while (el?.nodeType === 1 && !el.style.fontSize) el = el.parentElement;
|
|
959
|
+
const size = el?.style.fontSize || "";
|
|
960
960
|
if (size) return size;
|
|
961
961
|
}
|
|
962
962
|
const editable = ctx?.layoutInfo?.editable;
|
|
@@ -1057,7 +1057,7 @@
|
|
|
1057
1057
|
getValue: () => {
|
|
1058
1058
|
try {
|
|
1059
1059
|
const sel = globalThis.getSelection();
|
|
1060
|
-
if (!sel
|
|
1060
|
+
if (!sel?.rangeCount) return "";
|
|
1061
1061
|
const BLOCKS = new Set([
|
|
1062
1062
|
"P",
|
|
1063
1063
|
"DIV",
|
|
@@ -1074,7 +1074,7 @@
|
|
|
1074
1074
|
"TH"
|
|
1075
1075
|
]);
|
|
1076
1076
|
let el = sel.getRangeAt(0).startContainer;
|
|
1077
|
-
if (el
|
|
1077
|
+
if (el?.nodeType === 3) el = el.parentElement;
|
|
1078
1078
|
while (el && !BLOCKS.has(
|
|
1079
1079
|
/** @type {Element} */
|
|
1080
1080
|
el.tagName
|
|
@@ -4602,7 +4602,7 @@
|
|
|
4602
4602
|
icon.remove();
|
|
4603
4603
|
textNode.remove();
|
|
4604
4604
|
const nr = document.createRange();
|
|
4605
|
-
if (prevNode
|
|
4605
|
+
if (prevNode?.nodeType === Node.TEXT_NODE) nr.setStart(prevNode, prevNode.textContent.length);
|
|
4606
4606
|
else if (prevNode) nr.setStartAfter(prevNode);
|
|
4607
4607
|
else if (parent) nr.setStart(parent, 0);
|
|
4608
4608
|
nr.collapse(true);
|
|
@@ -4674,7 +4674,7 @@
|
|
|
4674
4674
|
if (isFAIcon(next)) {
|
|
4675
4675
|
const after = next.nextSibling;
|
|
4676
4676
|
event.preventDefault();
|
|
4677
|
-
if (after
|
|
4677
|
+
if (after?.nodeType === Node.TEXT_NODE) {
|
|
4678
4678
|
const offset = (after.textContent || "").startsWith("") ? 1 : 0;
|
|
4679
4679
|
return moveCaret((nr) => nr.setStart(after, Math.min(offset, after.textContent.length)));
|
|
4680
4680
|
}
|
|
@@ -4684,7 +4684,7 @@
|
|
|
4684
4684
|
const icon = next.nextSibling;
|
|
4685
4685
|
const after = icon.nextSibling;
|
|
4686
4686
|
event.preventDefault();
|
|
4687
|
-
if (after
|
|
4687
|
+
if (after?.nodeType === Node.TEXT_NODE) {
|
|
4688
4688
|
const offset = (after.textContent || "").startsWith("") ? 1 : 0;
|
|
4689
4689
|
return moveCaret((nr) => nr.setStart(after, Math.min(offset, after.textContent.length)));
|
|
4690
4690
|
}
|
|
@@ -4786,11 +4786,11 @@
|
|
|
4786
4786
|
newLi.appendChild(cb);
|
|
4787
4787
|
if (afterFrag.textContent.replace(/[\u00a0\u200B]/g, "").length > 0) newLi.appendChild(afterFrag);
|
|
4788
4788
|
let cursorNode = newLi.childNodes[1];
|
|
4789
|
-
if (
|
|
4789
|
+
if (cursorNode?.nodeType !== Node.TEXT_NODE) {
|
|
4790
4790
|
cursorNode = document.createTextNode("");
|
|
4791
4791
|
newLi.appendChild(cursorNode);
|
|
4792
4792
|
}
|
|
4793
|
-
checkLi.
|
|
4793
|
+
checkLi.after(newLi);
|
|
4794
4794
|
const nr = document.createRange();
|
|
4795
4795
|
nr.setStart(cursorNode, 0);
|
|
4796
4796
|
nr.collapse(true);
|
|
@@ -5072,7 +5072,7 @@
|
|
|
5072
5072
|
* @returns {string|null}
|
|
5073
5073
|
*/
|
|
5074
5074
|
function detectLang(code) {
|
|
5075
|
-
if (!code
|
|
5075
|
+
if (!code?.trim()) return null;
|
|
5076
5076
|
const s = code.trim();
|
|
5077
5077
|
if (/(:\s*(string|number|boolean|void|never|any|unknown)\b|interface\s+\w+\s*\{|type\s+\w+\s*[=<(]|<\w+>\s*[;,)]|readonly\s+\w|enum\s+\w+\s*\{|\?\s*:\s*\w|as\s+\w+\s*[;,)\]])/.test(s)) return "typescript";
|
|
5078
5078
|
if (/\bprintln!\s*\(|\bprint!\s*\(|\bfn\s+\w+\s*(<[^>]*>)?\s*\(|\blet\s+mut\s|\bpub\s+fn\s|\buse\s+std::|\bimpl\s+\w+|\bOption<|\bResult<\w+/.test(s)) return "rust";
|
|
@@ -5146,7 +5146,7 @@
|
|
|
5146
5146
|
};
|
|
5147
5147
|
const fixChecklistCursor = (event) => {
|
|
5148
5148
|
const sel = globalThis.getSelection();
|
|
5149
|
-
if (!sel
|
|
5149
|
+
if (!sel?.rangeCount) return;
|
|
5150
5150
|
const r = sel.getRangeAt(0);
|
|
5151
5151
|
if (!r.collapsed) return;
|
|
5152
5152
|
const sc = r.startContainer;
|
|
@@ -5156,7 +5156,7 @@
|
|
|
5156
5156
|
if (!li) return;
|
|
5157
5157
|
const cb = li.querySelector("input[type=\"checkbox\"]");
|
|
5158
5158
|
if (!cb) return;
|
|
5159
|
-
if (event
|
|
5159
|
+
if (event?.type === "mouseup") {
|
|
5160
5160
|
let caret = null;
|
|
5161
5161
|
if (document.caretRangeFromPoint) caret = document.caretRangeFromPoint(event.clientX, event.clientY);
|
|
5162
5162
|
else if (document.caretPositionFromPoint) {
|
|
@@ -5200,7 +5200,7 @@
|
|
|
5200
5200
|
let _compositionSupSub = null;
|
|
5201
5201
|
const onCompositionStart = () => {
|
|
5202
5202
|
const sel = globalThis.getSelection();
|
|
5203
|
-
if (!sel
|
|
5203
|
+
if (!sel?.rangeCount) {
|
|
5204
5204
|
_compositionSupSub = null;
|
|
5205
5205
|
return;
|
|
5206
5206
|
}
|
|
@@ -5218,7 +5218,7 @@
|
|
|
5218
5218
|
_compositionSupSub = null;
|
|
5219
5219
|
if (!tag) return;
|
|
5220
5220
|
const sel = globalThis.getSelection();
|
|
5221
|
-
if (!sel
|
|
5221
|
+
if (!sel?.rangeCount) return;
|
|
5222
5222
|
let node = sel.getRangeAt(0).startContainer;
|
|
5223
5223
|
if (node.nodeType === Node.TEXT_NODE) node = node.parentElement;
|
|
5224
5224
|
const el = node;
|
|
@@ -6012,7 +6012,7 @@
|
|
|
6012
6012
|
let savedRange = null;
|
|
6013
6013
|
const saveSelection = () => {
|
|
6014
6014
|
const sel = globalThis.getSelection();
|
|
6015
|
-
savedRange = sel
|
|
6015
|
+
savedRange = sel?.rangeCount ? sel.getRangeAt(0).cloneRange() : null;
|
|
6016
6016
|
};
|
|
6017
6017
|
const restoreSelection = () => {
|
|
6018
6018
|
if (!savedRange) return;
|
|
@@ -6130,7 +6130,7 @@
|
|
|
6130
6130
|
select.appendChild(placeholder);
|
|
6131
6131
|
items.forEach((item) => {
|
|
6132
6132
|
const value = typeof item === "object" ? item.value : item;
|
|
6133
|
-
const label = typeof item === "object" ? def.name === "paragraphStyle" ?
|
|
6133
|
+
const label = typeof item === "object" ? def.name === "paragraphStyle" ? this.context.locale.toolbar.paragraphItems?.[item.value] || item.label : item.label : item;
|
|
6134
6134
|
const isHeader = typeof item === "object" && !!item.disabled;
|
|
6135
6135
|
const attrs = { value };
|
|
6136
6136
|
if (isHeader) attrs.disabled = "";
|
|
@@ -6142,7 +6142,7 @@
|
|
|
6142
6142
|
let _savedRange = null;
|
|
6143
6143
|
const dMousedown = on(select, "mousedown", () => {
|
|
6144
6144
|
const sel = globalThis.getSelection();
|
|
6145
|
-
_savedRange = sel
|
|
6145
|
+
_savedRange = sel?.rangeCount ? sel.getRangeAt(0).cloneRange() : null;
|
|
6146
6146
|
});
|
|
6147
6147
|
const disposer = on(select, "change", (e) => {
|
|
6148
6148
|
const value = e.target.value;
|
|
@@ -7017,7 +7017,7 @@
|
|
|
7017
7017
|
if (this._dialog) {
|
|
7018
7018
|
this._dialog.style.display = "flex";
|
|
7019
7019
|
this._removeTrap = trapFocus(this._dialog, () => this._close());
|
|
7020
|
-
setTimeout(() => this._firstInput
|
|
7020
|
+
setTimeout(() => this._firstInput?.focus(), 50);
|
|
7021
7021
|
}
|
|
7022
7022
|
}
|
|
7023
7023
|
_close() {
|
|
@@ -7097,7 +7097,7 @@
|
|
|
7097
7097
|
* LinkDialog.js - Dialog for inserting / editing hyperlinks
|
|
7098
7098
|
* Inspired by Summernote's LinkDialog — rewritten without jQuery
|
|
7099
7099
|
*/
|
|
7100
|
-
var ICON_SVG$
|
|
7100
|
+
var ICON_SVG$3 = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`;
|
|
7101
7101
|
var LinkDialog = class extends BaseDialog {
|
|
7102
7102
|
/**
|
|
7103
7103
|
* Opens the link dialog.
|
|
@@ -7110,7 +7110,7 @@
|
|
|
7110
7110
|
}
|
|
7111
7111
|
_buildDialog() {
|
|
7112
7112
|
const L = this.context.locale.linkDialog;
|
|
7113
|
-
const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$
|
|
7113
|
+
const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$3, L.title);
|
|
7114
7114
|
const urlLabel = createElement("label", { class: "an-label" });
|
|
7115
7115
|
urlLabel.textContent = L.url;
|
|
7116
7116
|
const urlInput = createElement("input", {
|
|
@@ -7213,7 +7213,7 @@
|
|
|
7213
7213
|
* ImageDialog.js - Dialog for inserting images (by URL or file upload)
|
|
7214
7214
|
* Inspired by Summernote's ImageDialog — rewritten without jQuery
|
|
7215
7215
|
*/
|
|
7216
|
-
var ICON_SVG$
|
|
7216
|
+
var ICON_SVG$2 = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`;
|
|
7217
7217
|
var ImageDialog = class extends BaseDialog {
|
|
7218
7218
|
show() {
|
|
7219
7219
|
this._saveRange();
|
|
@@ -7224,7 +7224,7 @@
|
|
|
7224
7224
|
}
|
|
7225
7225
|
_buildDialog() {
|
|
7226
7226
|
const L = this.context.locale.imageDialog;
|
|
7227
|
-
const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$
|
|
7227
|
+
const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$2, L.title);
|
|
7228
7228
|
const urlLabel = createElement("label", { class: "an-label" });
|
|
7229
7229
|
urlLabel.textContent = L.imageUrl;
|
|
7230
7230
|
const urlInput = createElement("input", {
|
|
@@ -7378,7 +7378,7 @@
|
|
|
7378
7378
|
* • Vimeo URLs → <iframe> embed
|
|
7379
7379
|
* • Direct video URLs → <video> element (.mp4 / .webm / .ogg)
|
|
7380
7380
|
*/
|
|
7381
|
-
var ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`;
|
|
7381
|
+
var ICON_SVG$1 = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`;
|
|
7382
7382
|
var VideoDialog = class extends BaseDialog {
|
|
7383
7383
|
show() {
|
|
7384
7384
|
this._saveRange();
|
|
@@ -7389,7 +7389,7 @@
|
|
|
7389
7389
|
}
|
|
7390
7390
|
_buildDialog() {
|
|
7391
7391
|
const L = this.context.locale.videoDialog;
|
|
7392
|
-
const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG, L.title);
|
|
7392
|
+
const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$1, L.title);
|
|
7393
7393
|
const urlLabel = createElement("label", { class: "an-label" });
|
|
7394
7394
|
urlLabel.textContent = L.videoUrl;
|
|
7395
7395
|
const urlInput = createElement("input", {
|
|
@@ -7669,7 +7669,7 @@
|
|
|
7669
7669
|
const containerRect = offsetParent.getBoundingClientRect();
|
|
7670
7670
|
const rect = this._activeImg.getBoundingClientRect();
|
|
7671
7671
|
const p = this._lastOverlayPos;
|
|
7672
|
-
if (p
|
|
7672
|
+
if (p?.l === rect.left && p.t === rect.top && p.w === rect.width && p.h === rect.height) return;
|
|
7673
7673
|
this._lastOverlayPos = {
|
|
7674
7674
|
l: rect.left,
|
|
7675
7675
|
t: rect.top,
|
|
@@ -8714,7 +8714,7 @@
|
|
|
8714
8714
|
vIdx += c.colSpan || 1;
|
|
8715
8715
|
if (vIdx > visualIdx) {
|
|
8716
8716
|
const next = c.nextElementSibling;
|
|
8717
|
-
return next
|
|
8717
|
+
return next?.tagName === "TD" || next?.tagName === "TH" ? next : null;
|
|
8718
8718
|
}
|
|
8719
8719
|
}
|
|
8720
8720
|
return null;
|
|
@@ -9004,9 +9004,9 @@
|
|
|
9004
9004
|
this._disposers = [];
|
|
9005
9005
|
if (this._el && this._el.parentNode) this._el.remove();
|
|
9006
9006
|
this._el = null;
|
|
9007
|
-
if (this._sizePopover
|
|
9007
|
+
if (this._sizePopover?.parentNode) this._sizePopover.remove();
|
|
9008
9008
|
this._sizePopover = null;
|
|
9009
|
-
if (this._shadePopover
|
|
9009
|
+
if (this._shadePopover?.parentNode) this._shadePopover.remove();
|
|
9010
9010
|
this._shadePopover = null;
|
|
9011
9011
|
}
|
|
9012
9012
|
_buildTooltip() {
|
|
@@ -9153,7 +9153,7 @@
|
|
|
9153
9153
|
}
|
|
9154
9154
|
_getCell() {
|
|
9155
9155
|
const sel = globalThis.getSelection();
|
|
9156
|
-
if (sel
|
|
9156
|
+
if (sel?.rangeCount) {
|
|
9157
9157
|
let container = sel.getRangeAt(0).commonAncestorContainer;
|
|
9158
9158
|
if (container.nodeType === 3) container = container.parentElement;
|
|
9159
9159
|
const cellFromSel = container?.closest("td, th");
|
|
@@ -9190,7 +9190,7 @@
|
|
|
9190
9190
|
if (!startCell) return [];
|
|
9191
9191
|
if (!endCell || startCell === endCell) return [startCell];
|
|
9192
9192
|
const table = startCell.closest("table");
|
|
9193
|
-
if (!table
|
|
9193
|
+
if (!table?.contains(endCell)) return [startCell];
|
|
9194
9194
|
const { gridMap, cellPos } = buildGridMap(table);
|
|
9195
9195
|
const sp = cellPos.get(startCell);
|
|
9196
9196
|
const ep = cellPos.get(endCell);
|
|
@@ -9270,8 +9270,8 @@
|
|
|
9270
9270
|
for (let i = 0; i < colCount; i++) {
|
|
9271
9271
|
const td = createElement("td", {}, ["\xA0"]);
|
|
9272
9272
|
const ref = refCells[i];
|
|
9273
|
-
if (ref
|
|
9274
|
-
if (ref
|
|
9273
|
+
if (ref?.style.width) td.style.width = ref.style.width;
|
|
9274
|
+
if (ref?.style.minWidth) td.style.minWidth = ref.style.minWidth;
|
|
9275
9275
|
newRow.appendChild(td);
|
|
9276
9276
|
}
|
|
9277
9277
|
if (position === "above") refRow.parentElement?.insertBefore(newRow, refRow);
|
|
@@ -12352,35 +12352,17 @@
|
|
|
12352
12352
|
"symbols"
|
|
12353
12353
|
]
|
|
12354
12354
|
];
|
|
12355
|
-
var EmojiDialog = class {
|
|
12356
|
-
|
|
12357
|
-
* @param {import('../Context.js').Context} context
|
|
12358
|
-
*/
|
|
12359
|
-
constructor(context) {
|
|
12360
|
-
this.context = context;
|
|
12361
|
-
/** @type {HTMLElement|null} */
|
|
12362
|
-
this._dialog = null;
|
|
12363
|
-
this._disposers = [];
|
|
12364
|
-
this._savedRange = null;
|
|
12365
|
-
this._activeCat = "all";
|
|
12366
|
-
}
|
|
12355
|
+
var EmojiDialog = class extends BaseDialog {
|
|
12356
|
+
_activeCat = "all";
|
|
12367
12357
|
initialize() {
|
|
12368
12358
|
return this;
|
|
12369
12359
|
}
|
|
12370
|
-
destroy() {
|
|
12371
|
-
this._disposers.forEach((d) => d());
|
|
12372
|
-
this._disposers = [];
|
|
12373
|
-
if (this._dialog && this._dialog.parentNode) this._dialog.remove();
|
|
12374
|
-
this._dialog = null;
|
|
12375
|
-
}
|
|
12376
12360
|
show() {
|
|
12377
12361
|
if (!this._dialog) {
|
|
12378
12362
|
this._dialog = this._buildDialog();
|
|
12379
12363
|
document.body.appendChild(this._dialog);
|
|
12380
12364
|
}
|
|
12381
|
-
|
|
12382
|
-
this._savedRange = range;
|
|
12383
|
-
});
|
|
12365
|
+
this._saveRange();
|
|
12384
12366
|
this._activeCat = "all";
|
|
12385
12367
|
this._searchInput.value = "";
|
|
12386
12368
|
this._updateCatTabs();
|
|
@@ -12449,6 +12431,7 @@
|
|
|
12449
12431
|
grid.appendChild(cell);
|
|
12450
12432
|
});
|
|
12451
12433
|
this._grid = grid;
|
|
12434
|
+
this._firstInput = searchInput;
|
|
12452
12435
|
const btnRow = createElement("div", { class: "an-dialog-actions" });
|
|
12453
12436
|
const cancelBtn = createElement("button", {
|
|
12454
12437
|
type: "button",
|
|
@@ -12538,21 +12521,6 @@
|
|
|
12538
12521
|
editable.focus();
|
|
12539
12522
|
this.context.invoke("editor.afterCommand");
|
|
12540
12523
|
}
|
|
12541
|
-
_open() {
|
|
12542
|
-
if (this._dialog) {
|
|
12543
|
-
this._dialog.style.display = "flex";
|
|
12544
|
-
this._removeTrap = trapFocus(this._dialog, () => this._close());
|
|
12545
|
-
setTimeout(() => this._searchInput?.focus(), 50);
|
|
12546
|
-
}
|
|
12547
|
-
}
|
|
12548
|
-
_close() {
|
|
12549
|
-
if (this._dialog) this._dialog.style.display = "none";
|
|
12550
|
-
if (this._removeTrap) {
|
|
12551
|
-
this._removeTrap();
|
|
12552
|
-
this._removeTrap = null;
|
|
12553
|
-
}
|
|
12554
|
-
this._savedRange = null;
|
|
12555
|
-
}
|
|
12556
12524
|
};
|
|
12557
12525
|
//#endregion
|
|
12558
12526
|
//#region src/js/module/IconDialog.js
|
|
@@ -12810,19 +12778,9 @@
|
|
|
12810
12778
|
["gift", "objects"],
|
|
12811
12779
|
["puzzle-piece", "objects"]
|
|
12812
12780
|
];
|
|
12813
|
-
var IconDialog = class {
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
*/
|
|
12817
|
-
constructor(context) {
|
|
12818
|
-
this.context = context;
|
|
12819
|
-
/** @type {HTMLElement|null} */
|
|
12820
|
-
this._dialog = null;
|
|
12821
|
-
this._disposers = [];
|
|
12822
|
-
this._savedRange = null;
|
|
12823
|
-
this._selectedIcon = null;
|
|
12824
|
-
this._activeCat = "all";
|
|
12825
|
-
}
|
|
12781
|
+
var IconDialog = class extends BaseDialog {
|
|
12782
|
+
_selectedIcon = null;
|
|
12783
|
+
_activeCat = "all";
|
|
12826
12784
|
initialize() {
|
|
12827
12785
|
this._ensureFontAwesome();
|
|
12828
12786
|
return this;
|
|
@@ -12846,20 +12804,12 @@
|
|
|
12846
12804
|
link.referrerPolicy = "no-referrer";
|
|
12847
12805
|
document.head.appendChild(link);
|
|
12848
12806
|
}
|
|
12849
|
-
destroy() {
|
|
12850
|
-
this._disposers.forEach((d) => d());
|
|
12851
|
-
this._disposers = [];
|
|
12852
|
-
this._dialog?.remove();
|
|
12853
|
-
this._dialog = null;
|
|
12854
|
-
}
|
|
12855
12807
|
show() {
|
|
12856
12808
|
if (!this._dialog) {
|
|
12857
12809
|
this._dialog = this._buildDialog();
|
|
12858
12810
|
document.body.appendChild(this._dialog);
|
|
12859
12811
|
}
|
|
12860
|
-
|
|
12861
|
-
this._savedRange = range;
|
|
12862
|
-
});
|
|
12812
|
+
this._saveRange();
|
|
12863
12813
|
this._selectedIcon = null;
|
|
12864
12814
|
this._activeCat = "all";
|
|
12865
12815
|
this._searchInput.value = "";
|
|
@@ -12900,6 +12850,7 @@
|
|
|
12900
12850
|
autocomplete: "off"
|
|
12901
12851
|
});
|
|
12902
12852
|
this._searchInput = searchInput;
|
|
12853
|
+
this._firstInput = searchInput;
|
|
12903
12854
|
const catBar = createElement("div", { class: "an-icon-cats" });
|
|
12904
12855
|
const allTab = createElement("button", {
|
|
12905
12856
|
type: "button",
|
|
@@ -13118,7 +13069,7 @@
|
|
|
13118
13069
|
}
|
|
13119
13070
|
range.insertNode(iconEl);
|
|
13120
13071
|
let caretTextNode = iconEl.nextSibling;
|
|
13121
|
-
if (
|
|
13072
|
+
if (caretTextNode?.nodeType !== Node.TEXT_NODE) {
|
|
13122
13073
|
caretTextNode = document.createTextNode("");
|
|
13123
13074
|
iconEl.parentNode.insertBefore(caretTextNode, iconEl.nextSibling);
|
|
13124
13075
|
} else if (!caretTextNode.textContent) caretTextNode.textContent = "";
|
|
@@ -13138,21 +13089,9 @@
|
|
|
13138
13089
|
}
|
|
13139
13090
|
this.context.invoke("editor.afterCommand");
|
|
13140
13091
|
}
|
|
13141
|
-
_open() {
|
|
13142
|
-
if (this._dialog) {
|
|
13143
|
-
this._dialog.style.display = "flex";
|
|
13144
|
-
this._removeTrap = trapFocus(this._dialog, () => this._close());
|
|
13145
|
-
setTimeout(() => this._searchInput?.focus(), 50);
|
|
13146
|
-
}
|
|
13147
|
-
}
|
|
13148
13092
|
_close() {
|
|
13149
|
-
if (this._dialog) this._dialog.style.display = "none";
|
|
13150
|
-
if (this._removeTrap) {
|
|
13151
|
-
this._removeTrap();
|
|
13152
|
-
this._removeTrap = null;
|
|
13153
|
-
}
|
|
13154
|
-
this._savedRange = null;
|
|
13155
13093
|
this._selectedIcon = null;
|
|
13094
|
+
super._close();
|
|
13156
13095
|
}
|
|
13157
13096
|
};
|
|
13158
13097
|
//#endregion
|
|
@@ -13893,59 +13832,25 @@
|
|
|
13893
13832
|
}]
|
|
13894
13833
|
}
|
|
13895
13834
|
];
|
|
13896
|
-
var
|
|
13897
|
-
|
|
13898
|
-
constructor(context) {
|
|
13899
|
-
this.context = context;
|
|
13900
|
-
this._dialog = null;
|
|
13901
|
-
this._closeBtn = null;
|
|
13902
|
-
this._disposers = [];
|
|
13903
|
-
}
|
|
13904
|
-
initialize() {
|
|
13905
|
-
this._dialog = this._buildDialog();
|
|
13906
|
-
document.body.appendChild(this._dialog);
|
|
13907
|
-
return this;
|
|
13908
|
-
}
|
|
13909
|
-
destroy() {
|
|
13910
|
-
this._disposers.forEach((d) => d());
|
|
13911
|
-
this._disposers = [];
|
|
13912
|
-
this._dialog?.remove();
|
|
13913
|
-
this._dialog = null;
|
|
13914
|
-
}
|
|
13835
|
+
var ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M6 11h.01M10 11h.01M14 11h.01M18 11h.01M6 15h.01M18 15h.01M10 15h4"/><path d="M7 3l5 4 5-4"/></svg>`;
|
|
13836
|
+
var ShortcutsDialog = class extends BaseDialog {
|
|
13915
13837
|
show() {
|
|
13916
|
-
|
|
13917
|
-
this._dialog.style.display = "flex";
|
|
13918
|
-
this._removeTrap = trapFocus(this._dialog, () => this._close());
|
|
13919
|
-
setTimeout(() => this._closeBtn?.focus(), 50);
|
|
13920
|
-
}
|
|
13921
|
-
}
|
|
13922
|
-
_close() {
|
|
13923
|
-
if (this._dialog) this._dialog.style.display = "none";
|
|
13924
|
-
if (this._removeTrap) {
|
|
13925
|
-
this._removeTrap();
|
|
13926
|
-
this._removeTrap = null;
|
|
13927
|
-
}
|
|
13838
|
+
this._open();
|
|
13928
13839
|
}
|
|
13929
13840
|
_buildDialog() {
|
|
13930
|
-
const
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
"aria-modal": "true",
|
|
13934
|
-
"aria-label": this.context.locale.shortcutsDialog.ariaLabel
|
|
13935
|
-
});
|
|
13936
|
-
const box = createElement("div", { class: "an-dialog-box an-shortcuts-box" });
|
|
13937
|
-
const titleRow = createElement("div", { class: "an-icon-title-row" });
|
|
13938
|
-
const title = createElement("h3", { class: "an-dialog-title" });
|
|
13939
|
-
title.textContent = this.context.locale.shortcutsDialog.title;
|
|
13841
|
+
const L = this.context.locale.shortcutsDialog;
|
|
13842
|
+
const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG, L.title);
|
|
13843
|
+
box.classList.add("an-shortcuts-box");
|
|
13940
13844
|
const closeBtn = createElement("button", {
|
|
13941
13845
|
type: "button",
|
|
13942
13846
|
class: "an-icon-close",
|
|
13943
|
-
"aria-label":
|
|
13847
|
+
"aria-label": L.close,
|
|
13848
|
+
style: "margin-left:auto"
|
|
13944
13849
|
});
|
|
13945
13850
|
closeBtn.textContent = "×";
|
|
13946
13851
|
this._closeBtn = closeBtn;
|
|
13947
|
-
|
|
13948
|
-
box.appendChild(
|
|
13852
|
+
this._firstInput = closeBtn;
|
|
13853
|
+
box.querySelector(".an-dialog-header").appendChild(closeBtn);
|
|
13949
13854
|
(this.context.locale.shortcutsDialog.shortcuts || SHORTCUTS).forEach(({ category, items }) => {
|
|
13950
13855
|
const catEl = createElement("div", { class: "an-shortcuts-cat" });
|
|
13951
13856
|
catEl.textContent = category;
|
|
@@ -13962,12 +13867,8 @@
|
|
|
13962
13867
|
});
|
|
13963
13868
|
box.appendChild(table);
|
|
13964
13869
|
});
|
|
13965
|
-
overlay.appendChild(box);
|
|
13966
13870
|
const d1 = on(closeBtn, "click", () => this._close());
|
|
13967
|
-
|
|
13968
|
-
if (e.target === overlay) this._close();
|
|
13969
|
-
});
|
|
13970
|
-
this._disposers.push(d1, d2);
|
|
13871
|
+
this._disposers.push(d1);
|
|
13971
13872
|
return overlay;
|
|
13972
13873
|
}
|
|
13973
13874
|
};
|
|
@@ -13981,12 +13882,10 @@
|
|
|
13981
13882
|
* for highlighting. Supports case-sensitive search, Prev/Next navigation and
|
|
13982
13883
|
* single / replace-all replacement.
|
|
13983
13884
|
*/
|
|
13984
|
-
var FindReplace = class {
|
|
13885
|
+
var FindReplace = class extends BaseDialog {
|
|
13985
13886
|
/** @param {import('../Context.js').Context} context */
|
|
13986
13887
|
constructor(context) {
|
|
13987
|
-
|
|
13988
|
-
/** @type {HTMLElement|null} */
|
|
13989
|
-
this._dialog = null;
|
|
13888
|
+
super(context);
|
|
13990
13889
|
/** @type {HTMLInputElement|null} */
|
|
13991
13890
|
this._findInput = null;
|
|
13992
13891
|
/** @type {HTMLInputElement|null} */
|
|
@@ -14007,23 +13906,13 @@
|
|
|
14007
13906
|
this._queryRegex = null;
|
|
14008
13907
|
this._lastQuery = null;
|
|
14009
13908
|
this._lastCaseSensitive = null;
|
|
14010
|
-
this._disposers = [];
|
|
14011
|
-
this._removeTrap = null;
|
|
14012
13909
|
this._focusTimer = null;
|
|
14013
13910
|
}
|
|
14014
|
-
initialize() {
|
|
14015
|
-
this._dialog = this._buildDialog();
|
|
14016
|
-
document.body.appendChild(this._dialog);
|
|
14017
|
-
return this;
|
|
14018
|
-
}
|
|
14019
13911
|
destroy() {
|
|
14020
13912
|
clearTimeout(this._focusTimer);
|
|
14021
13913
|
this._focusTimer = null;
|
|
14022
13914
|
this._clearHighlights();
|
|
14023
|
-
|
|
14024
|
-
this._disposers = [];
|
|
14025
|
-
if (this._dialog && this._dialog.parentNode) this._dialog.remove();
|
|
14026
|
-
this._dialog = null;
|
|
13915
|
+
super.destroy();
|
|
14027
13916
|
}
|
|
14028
13917
|
/**
|
|
14029
13918
|
* Opens the dialog in 'find' or 'replace' mode.
|
|
@@ -14703,7 +14592,7 @@
|
|
|
14703
14592
|
const startY = e.clientY;
|
|
14704
14593
|
const orig = { ...this._box };
|
|
14705
14594
|
const r = this._imgRect;
|
|
14706
|
-
const lockAR = this._arCheck
|
|
14595
|
+
const lockAR = this._arCheck?.checked;
|
|
14707
14596
|
const aspect = orig.w / (orig.h || 1);
|
|
14708
14597
|
const onMove = (me) => {
|
|
14709
14598
|
const dx = me.clientX - startX;
|
|
@@ -15529,14 +15418,14 @@
|
|
|
15529
15418
|
if (!this._btnCache) return;
|
|
15530
15419
|
this._btnCache.forEach((btn) => {
|
|
15531
15420
|
const activeFn = _ACTIVE[btn.dataset.name];
|
|
15532
|
-
btn.classList.toggle("an-active", !!
|
|
15421
|
+
btn.classList.toggle("an-active", !!activeFn?.());
|
|
15533
15422
|
});
|
|
15534
15423
|
}
|
|
15535
15424
|
/** Read the current selection's color and update the color-strip indicators. */
|
|
15536
15425
|
_syncColorStrips() {
|
|
15537
15426
|
if (!this._el) return;
|
|
15538
15427
|
const sel = globalThis.getSelection();
|
|
15539
|
-
if (!sel
|
|
15428
|
+
if (!sel?.rangeCount) return;
|
|
15540
15429
|
let node = sel.getRangeAt(0).startContainer;
|
|
15541
15430
|
if (node.nodeType === Node.TEXT_NODE) node = node.parentElement;
|
|
15542
15431
|
if (!node) return;
|
|
@@ -15764,7 +15653,7 @@
|
|
|
15764
15653
|
}
|
|
15765
15654
|
} catch (_) {}
|
|
15766
15655
|
const sel = globalThis.getSelection();
|
|
15767
|
-
if (!sel
|
|
15656
|
+
if (!sel?.rangeCount) return;
|
|
15768
15657
|
const rects = sel.getRangeAt(0).getClientRects();
|
|
15769
15658
|
if (rects.length > 0) this._caretRect = rects[rects.length - 1];
|
|
15770
15659
|
}
|
|
@@ -16388,7 +16277,7 @@
|
|
|
16388
16277
|
return this;
|
|
16389
16278
|
},
|
|
16390
16279
|
/** Library version */
|
|
16391
|
-
version: "1.6.
|
|
16280
|
+
version: "1.6.5"
|
|
16392
16281
|
};
|
|
16393
16282
|
/**
|
|
16394
16283
|
* @param {string|Element|NodeList|Element[]} selector
|