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.
@@ -608,7 +608,7 @@ var italic = () => execCommand("italic");
608
608
  */
609
609
  function underline() {
610
610
  const sel = globalThis.getSelection();
611
- if (!sel || !sel.rangeCount) return;
611
+ if (!sel?.rangeCount) return;
612
612
  let container = sel.getRangeAt(0).commonAncestorContainer;
613
613
  if (container.nodeType === 3) container = container.parentElement;
614
614
  const uEl = container?.closest("u");
@@ -628,7 +628,7 @@ function underline() {
628
628
  */
629
629
  function strikethrough() {
630
630
  const sel = globalThis.getSelection();
631
- if (!sel || !sel.rangeCount) return;
631
+ if (!sel?.rangeCount) return;
632
632
  let sc = sel.getRangeAt(0).startContainer;
633
633
  if (sc.nodeType === 3) sc = sc.parentElement;
634
634
  const sEl = sc?.closest("s") || sc?.closest("strike");
@@ -672,7 +672,7 @@ var fontName = (name) => execCommand("fontName", name);
672
672
  */
673
673
  function fontSize(size, editable = document) {
674
674
  const sel = globalThis.getSelection();
675
- const wasCollapsed = !sel || !sel.rangeCount || sel.getRangeAt(0).collapsed;
675
+ const wasCollapsed = !sel?.rangeCount || sel.getRangeAt(0).collapsed;
676
676
  if (wasCollapsed && sel && sel.rangeCount > 0) {
677
677
  try {
678
678
  const range = sel.getRangeAt(0);
@@ -747,7 +747,7 @@ var indent = () => execCommand("indent");
747
747
  */
748
748
  function outdent() {
749
749
  const sel = globalThis.getSelection();
750
- if (sel && sel.rangeCount) {
750
+ if (sel?.rangeCount) {
751
751
  let container = sel.getRangeAt(0).commonAncestorContainer;
752
752
  if (container.nodeType === 3) container = container.parentElement;
753
753
  const checkLi = container?.closest(".an-checklist li");
@@ -797,7 +797,7 @@ function _checklistItemToP(checkLi) {
797
797
  try {
798
798
  const nr = document.createRange();
799
799
  const firstChild = p.firstChild;
800
- nr.setStart(firstChild && firstChild.nodeType === 3 ? firstChild : p, 0);
800
+ nr.setStart(firstChild?.nodeType === 3 ? firstChild : p, 0);
801
801
  nr.collapse(true);
802
802
  const s = globalThis.getSelection();
803
803
  if (s) {
@@ -876,7 +876,7 @@ function lineHeight(value) {
876
876
  */
877
877
  function toggleInlineCode(_editable) {
878
878
  const sel = globalThis.getSelection();
879
- if (!sel || !sel.rangeCount) return;
879
+ if (!sel?.rangeCount) return;
880
880
  const range = sel.getRangeAt(0);
881
881
  let container = range.commonAncestorContainer;
882
882
  if (container.nodeType === 3) container = container.parentElement;
@@ -932,7 +932,7 @@ function toggleInlineCode(_editable) {
932
932
  */
933
933
  function isInlineCode() {
934
934
  const sel = globalThis.getSelection();
935
- if (!sel || !sel.rangeCount) return false;
935
+ if (!sel?.rangeCount) return false;
936
936
  let sc = sel.getRangeAt(0).startContainer;
937
937
  if (sc.nodeType === 3) sc = sc.parentElement;
938
938
  const code = sc?.closest("code");
@@ -954,7 +954,7 @@ function isInlineCode() {
954
954
  */
955
955
  function toggleChecklist() {
956
956
  const sel = globalThis.getSelection();
957
- if (!sel || !sel.rangeCount) return;
957
+ if (!sel?.rangeCount) return;
958
958
  const range = sel.getRangeAt(0);
959
959
  let container = range.commonAncestorContainer;
960
960
  if (container.nodeType === 3) container = container.parentElement;
@@ -1003,7 +1003,7 @@ function toggleChecklist() {
1003
1003
  "LI"
1004
1004
  ]);
1005
1005
  let block = container;
1006
- while (block && block.parentNode && !BLOCK_TAGS.has(block.tagName)) block = block.parentNode;
1006
+ while (block?.parentNode && !BLOCK_TAGS.has(block.tagName)) block = block.parentNode;
1007
1007
  const itemText = block && BLOCK_TAGS.has(block.tagName) ? Array.from(block.childNodes).map((n) => n.textContent).join("").replaceAll("\xA0", " ") : "";
1008
1008
  const ul = document.createElement("ul");
1009
1009
  ul.className = "an-checklist";
@@ -1090,7 +1090,7 @@ function toggleChecklist() {
1090
1090
  */
1091
1091
  function isInChecklist() {
1092
1092
  const sel = globalThis.getSelection();
1093
- if (!sel || !sel.rangeCount) return false;
1093
+ if (!sel?.rangeCount) return false;
1094
1094
  let container = sel.getRangeAt(0).commonAncestorContainer;
1095
1095
  if (container.nodeType === 3) container = container.parentElement;
1096
1096
  return !!container?.closest(".an-checklist li");
@@ -1176,10 +1176,10 @@ var italicBtn = btn("italic", "italic", "Italic (Ctrl+I)", () => italic(), () =>
1176
1176
  var underlineBtn = btn("underline", "underline", "Underline (Ctrl+U)", () => underline(), () => {
1177
1177
  if (document.queryCommandState("underline")) return true;
1178
1178
  const sel = globalThis.getSelection();
1179
- if (!sel || !sel.rangeCount) return false;
1179
+ if (!sel?.rangeCount) return false;
1180
1180
  let sc = sel.getRangeAt(0).startContainer;
1181
1181
  if (sc.nodeType === 3) sc = sc.parentElement;
1182
- return !!(sc && sc.closest("u"));
1182
+ return !!sc?.closest("u");
1183
1183
  });
1184
1184
  var strikeBtn = btn("strikethrough", "strikethrough", "Strikethrough", () => strikethrough(), () => document.queryCommandState("strikeThrough"));
1185
1185
  var superscriptBtn = btn("superscript", "superscript", "Superscript", () => superscript(), () => document.queryCommandState("superscript"));
@@ -1239,11 +1239,11 @@ var fontSizeBtn = {
1239
1239
  getValue: (ctx) => {
1240
1240
  try {
1241
1241
  const sel = globalThis.getSelection();
1242
- if (sel && sel.rangeCount) {
1242
+ if (sel?.rangeCount) {
1243
1243
  let el = sel.getRangeAt(0).startContainer;
1244
- if (el && el.nodeType === 3) el = el.parentElement;
1245
- while (el && el.nodeType === 1 && !el.style.fontSize) el = el.parentElement;
1246
- const size = el && el.style.fontSize ? el.style.fontSize : "";
1244
+ if (el?.nodeType === 3) el = el.parentElement;
1245
+ while (el?.nodeType === 1 && !el.style.fontSize) el = el.parentElement;
1246
+ const size = el?.style.fontSize || "";
1247
1247
  if (size) return size;
1248
1248
  }
1249
1249
  const editable = ctx?.layoutInfo?.editable;
@@ -1351,7 +1351,7 @@ var lineHeightBtn = {
1351
1351
  getValue: () => {
1352
1352
  try {
1353
1353
  const sel = globalThis.getSelection();
1354
- if (!sel || !sel.rangeCount) return "";
1354
+ if (!sel?.rangeCount) return "";
1355
1355
  const BLOCKS = new Set([
1356
1356
  "P",
1357
1357
  "DIV",
@@ -1368,7 +1368,7 @@ var lineHeightBtn = {
1368
1368
  "TH"
1369
1369
  ]);
1370
1370
  let el = sel.getRangeAt(0).startContainer;
1371
- if (el && el.nodeType === 3) el = el.parentElement;
1371
+ if (el?.nodeType === 3) el = el.parentElement;
1372
1372
  while (el && !BLOCKS.has(
1373
1373
  /** @type {Element} */
1374
1374
  el.tagName
@@ -4906,7 +4906,7 @@ function handleKeydown(event, editable, options = {}) {
4906
4906
  icon.remove();
4907
4907
  textNode.remove();
4908
4908
  const nr = document.createRange();
4909
- if (prevNode && prevNode.nodeType === Node.TEXT_NODE) nr.setStart(prevNode, prevNode.textContent.length);
4909
+ if (prevNode?.nodeType === Node.TEXT_NODE) nr.setStart(prevNode, prevNode.textContent.length);
4910
4910
  else if (prevNode) nr.setStartAfter(prevNode);
4911
4911
  else if (parent) nr.setStart(parent, 0);
4912
4912
  nr.collapse(true);
@@ -4978,7 +4978,7 @@ function handleKeydown(event, editable, options = {}) {
4978
4978
  if (isFAIcon(next)) {
4979
4979
  const after = next.nextSibling;
4980
4980
  event.preventDefault();
4981
- if (after && after.nodeType === Node.TEXT_NODE) {
4981
+ if (after?.nodeType === Node.TEXT_NODE) {
4982
4982
  const offset = (after.textContent || "").startsWith("​") ? 1 : 0;
4983
4983
  return moveCaret((nr) => nr.setStart(after, Math.min(offset, after.textContent.length)));
4984
4984
  }
@@ -4988,7 +4988,7 @@ function handleKeydown(event, editable, options = {}) {
4988
4988
  const icon = next.nextSibling;
4989
4989
  const after = icon.nextSibling;
4990
4990
  event.preventDefault();
4991
- if (after && after.nodeType === Node.TEXT_NODE) {
4991
+ if (after?.nodeType === Node.TEXT_NODE) {
4992
4992
  const offset = (after.textContent || "").startsWith("​") ? 1 : 0;
4993
4993
  return moveCaret((nr) => nr.setStart(after, Math.min(offset, after.textContent.length)));
4994
4994
  }
@@ -5090,11 +5090,11 @@ function handleKeydown(event, editable, options = {}) {
5090
5090
  newLi.appendChild(cb);
5091
5091
  if (afterFrag.textContent.replace(/[\u00a0\u200B]/g, "").length > 0) newLi.appendChild(afterFrag);
5092
5092
  let cursorNode = newLi.childNodes[1];
5093
- if (!cursorNode || cursorNode.nodeType !== Node.TEXT_NODE) {
5093
+ if (cursorNode?.nodeType !== Node.TEXT_NODE) {
5094
5094
  cursorNode = document.createTextNode("​");
5095
5095
  newLi.appendChild(cursorNode);
5096
5096
  }
5097
- checkLi.insertAdjacentElement("afterend", newLi);
5097
+ checkLi.after(newLi);
5098
5098
  const nr = document.createRange();
5099
5099
  nr.setStart(cursorNode, 0);
5100
5100
  nr.collapse(true);
@@ -5376,7 +5376,7 @@ function _escAttr(v) {
5376
5376
  * @returns {string|null}
5377
5377
  */
5378
5378
  function detectLang(code) {
5379
- if (!code || !code.trim()) return null;
5379
+ if (!code?.trim()) return null;
5380
5380
  const s = code.trim();
5381
5381
  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";
5382
5382
  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";
@@ -5450,7 +5450,7 @@ var Editor = class {
5450
5450
  };
5451
5451
  const fixChecklistCursor = (event) => {
5452
5452
  const sel = globalThis.getSelection();
5453
- if (!sel || !sel.rangeCount) return;
5453
+ if (!sel?.rangeCount) return;
5454
5454
  const r = sel.getRangeAt(0);
5455
5455
  if (!r.collapsed) return;
5456
5456
  const sc = r.startContainer;
@@ -5460,7 +5460,7 @@ var Editor = class {
5460
5460
  if (!li) return;
5461
5461
  const cb = li.querySelector("input[type=\"checkbox\"]");
5462
5462
  if (!cb) return;
5463
- if (event && event.type === "mouseup") {
5463
+ if (event?.type === "mouseup") {
5464
5464
  let caret = null;
5465
5465
  if (document.caretRangeFromPoint) caret = document.caretRangeFromPoint(event.clientX, event.clientY);
5466
5466
  else if (document.caretPositionFromPoint) {
@@ -5504,7 +5504,7 @@ var Editor = class {
5504
5504
  let _compositionSupSub = null;
5505
5505
  const onCompositionStart = () => {
5506
5506
  const sel = globalThis.getSelection();
5507
- if (!sel || !sel.rangeCount) {
5507
+ if (!sel?.rangeCount) {
5508
5508
  _compositionSupSub = null;
5509
5509
  return;
5510
5510
  }
@@ -5522,7 +5522,7 @@ var Editor = class {
5522
5522
  _compositionSupSub = null;
5523
5523
  if (!tag) return;
5524
5524
  const sel = globalThis.getSelection();
5525
- if (!sel || !sel.rangeCount) return;
5525
+ if (!sel?.rangeCount) return;
5526
5526
  let node = sel.getRangeAt(0).startContainer;
5527
5527
  if (node.nodeType === Node.TEXT_NODE) node = node.parentElement;
5528
5528
  const el = node;
@@ -6316,7 +6316,7 @@ var Toolbar = class {
6316
6316
  let savedRange = null;
6317
6317
  const saveSelection = () => {
6318
6318
  const sel = globalThis.getSelection();
6319
- savedRange = sel && sel.rangeCount ? sel.getRangeAt(0).cloneRange() : null;
6319
+ savedRange = sel?.rangeCount ? sel.getRangeAt(0).cloneRange() : null;
6320
6320
  };
6321
6321
  const restoreSelection = () => {
6322
6322
  if (!savedRange) return;
@@ -6434,7 +6434,7 @@ var Toolbar = class {
6434
6434
  select.appendChild(placeholder);
6435
6435
  items.forEach((item) => {
6436
6436
  const value = typeof item === "object" ? item.value : item;
6437
- const label = typeof item === "object" ? def.name === "paragraphStyle" ? (this.context.locale.toolbar.paragraphItems || {})[item.value] || item.label : item.label : item;
6437
+ const label = typeof item === "object" ? def.name === "paragraphStyle" ? this.context.locale.toolbar.paragraphItems?.[item.value] || item.label : item.label : item;
6438
6438
  const isHeader = typeof item === "object" && !!item.disabled;
6439
6439
  const attrs = { value };
6440
6440
  if (isHeader) attrs.disabled = "";
@@ -6446,7 +6446,7 @@ var Toolbar = class {
6446
6446
  let _savedRange = null;
6447
6447
  const dMousedown = on(select, "mousedown", () => {
6448
6448
  const sel = globalThis.getSelection();
6449
- _savedRange = sel && sel.rangeCount ? sel.getRangeAt(0).cloneRange() : null;
6449
+ _savedRange = sel?.rangeCount ? sel.getRangeAt(0).cloneRange() : null;
6450
6450
  });
6451
6451
  const disposer = on(select, "change", (e) => {
6452
6452
  const value = e.target.value;
@@ -7321,7 +7321,7 @@ var BaseDialog = class {
7321
7321
  if (this._dialog) {
7322
7322
  this._dialog.style.display = "flex";
7323
7323
  this._removeTrap = trapFocus(this._dialog, () => this._close());
7324
- setTimeout(() => this._firstInput && this._firstInput.focus(), 50);
7324
+ setTimeout(() => this._firstInput?.focus(), 50);
7325
7325
  }
7326
7326
  }
7327
7327
  _close() {
@@ -7401,7 +7401,7 @@ var BaseDialog = class {
7401
7401
  * LinkDialog.js - Dialog for inserting / editing hyperlinks
7402
7402
  * Inspired by Summernote's LinkDialog — rewritten without jQuery
7403
7403
  */
7404
- 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"><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>`;
7404
+ 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>`;
7405
7405
  var LinkDialog = class extends BaseDialog {
7406
7406
  /**
7407
7407
  * Opens the link dialog.
@@ -7414,7 +7414,7 @@ var LinkDialog = class extends BaseDialog {
7414
7414
  }
7415
7415
  _buildDialog() {
7416
7416
  const L = this.context.locale.linkDialog;
7417
- const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$2, L.title);
7417
+ const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$3, L.title);
7418
7418
  const urlLabel = createElement("label", { class: "an-label" });
7419
7419
  urlLabel.textContent = L.url;
7420
7420
  const urlInput = createElement("input", {
@@ -7517,7 +7517,7 @@ var LinkDialog = class extends BaseDialog {
7517
7517
  * ImageDialog.js - Dialog for inserting images (by URL or file upload)
7518
7518
  * Inspired by Summernote's ImageDialog — rewritten without jQuery
7519
7519
  */
7520
- 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"><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>`;
7520
+ 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>`;
7521
7521
  var ImageDialog = class extends BaseDialog {
7522
7522
  show() {
7523
7523
  this._saveRange();
@@ -7528,7 +7528,7 @@ var ImageDialog = class extends BaseDialog {
7528
7528
  }
7529
7529
  _buildDialog() {
7530
7530
  const L = this.context.locale.imageDialog;
7531
- const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$1, L.title);
7531
+ const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$2, L.title);
7532
7532
  const urlLabel = createElement("label", { class: "an-label" });
7533
7533
  urlLabel.textContent = L.imageUrl;
7534
7534
  const urlInput = createElement("input", {
@@ -7682,7 +7682,7 @@ var ImageDialog = class extends BaseDialog {
7682
7682
  * • Vimeo URLs → <iframe> embed
7683
7683
  * • Direct video URLs → <video> element (.mp4 / .webm / .ogg)
7684
7684
  */
7685
- 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>`;
7685
+ 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>`;
7686
7686
  var VideoDialog = class extends BaseDialog {
7687
7687
  show() {
7688
7688
  this._saveRange();
@@ -7693,7 +7693,7 @@ var VideoDialog = class extends BaseDialog {
7693
7693
  }
7694
7694
  _buildDialog() {
7695
7695
  const L = this.context.locale.videoDialog;
7696
- const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG, L.title);
7696
+ const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG$1, L.title);
7697
7697
  const urlLabel = createElement("label", { class: "an-label" });
7698
7698
  urlLabel.textContent = L.videoUrl;
7699
7699
  const urlInput = createElement("input", {
@@ -7973,7 +7973,7 @@ var ImageResizer = class {
7973
7973
  const containerRect = offsetParent.getBoundingClientRect();
7974
7974
  const rect = this._activeImg.getBoundingClientRect();
7975
7975
  const p = this._lastOverlayPos;
7976
- if (p && p.l === rect.left && p.t === rect.top && p.w === rect.width && p.h === rect.height) return;
7976
+ if (p?.l === rect.left && p.t === rect.top && p.w === rect.width && p.h === rect.height) return;
7977
7977
  this._lastOverlayPos = {
7978
7978
  l: rect.left,
7979
7979
  t: rect.top,
@@ -9018,7 +9018,7 @@ function getCellAfterVisualCol(row, visualIdx) {
9018
9018
  vIdx += c.colSpan || 1;
9019
9019
  if (vIdx > visualIdx) {
9020
9020
  const next = c.nextElementSibling;
9021
- return next && next.tagName === "TD" || next && next.tagName === "TH" ? next : null;
9021
+ return next?.tagName === "TD" || next?.tagName === "TH" ? next : null;
9022
9022
  }
9023
9023
  }
9024
9024
  return null;
@@ -9308,9 +9308,9 @@ var TableTooltip = class {
9308
9308
  this._disposers = [];
9309
9309
  if (this._el && this._el.parentNode) this._el.remove();
9310
9310
  this._el = null;
9311
- if (this._sizePopover && this._sizePopover.parentNode) this._sizePopover.remove();
9311
+ if (this._sizePopover?.parentNode) this._sizePopover.remove();
9312
9312
  this._sizePopover = null;
9313
- if (this._shadePopover && this._shadePopover.parentNode) this._shadePopover.remove();
9313
+ if (this._shadePopover?.parentNode) this._shadePopover.remove();
9314
9314
  this._shadePopover = null;
9315
9315
  }
9316
9316
  _buildTooltip() {
@@ -9457,7 +9457,7 @@ var TableTooltip = class {
9457
9457
  }
9458
9458
  _getCell() {
9459
9459
  const sel = globalThis.getSelection();
9460
- if (sel && sel.rangeCount) {
9460
+ if (sel?.rangeCount) {
9461
9461
  let container = sel.getRangeAt(0).commonAncestorContainer;
9462
9462
  if (container.nodeType === 3) container = container.parentElement;
9463
9463
  const cellFromSel = container?.closest("td, th");
@@ -9494,7 +9494,7 @@ var TableTooltip = class {
9494
9494
  if (!startCell) return [];
9495
9495
  if (!endCell || startCell === endCell) return [startCell];
9496
9496
  const table = startCell.closest("table");
9497
- if (!table || !table.contains(endCell)) return [startCell];
9497
+ if (!table?.contains(endCell)) return [startCell];
9498
9498
  const { gridMap, cellPos } = buildGridMap(table);
9499
9499
  const sp = cellPos.get(startCell);
9500
9500
  const ep = cellPos.get(endCell);
@@ -9574,8 +9574,8 @@ var TableTooltip = class {
9574
9574
  for (let i = 0; i < colCount; i++) {
9575
9575
  const td = createElement("td", {}, ["\xA0"]);
9576
9576
  const ref = refCells[i];
9577
- if (ref && ref.style.width) td.style.width = ref.style.width;
9578
- if (ref && ref.style.minWidth) td.style.minWidth = ref.style.minWidth;
9577
+ if (ref?.style.width) td.style.width = ref.style.width;
9578
+ if (ref?.style.minWidth) td.style.minWidth = ref.style.minWidth;
9579
9579
  newRow.appendChild(td);
9580
9580
  }
9581
9581
  if (position === "above") refRow.parentElement?.insertBefore(newRow, refRow);
@@ -12656,35 +12656,17 @@ var EMOJI_LIST = [
12656
12656
  "symbols"
12657
12657
  ]
12658
12658
  ];
12659
- var EmojiDialog = class {
12660
- /**
12661
- * @param {import('../Context.js').Context} context
12662
- */
12663
- constructor(context) {
12664
- this.context = context;
12665
- /** @type {HTMLElement|null} */
12666
- this._dialog = null;
12667
- this._disposers = [];
12668
- this._savedRange = null;
12669
- this._activeCat = "all";
12670
- }
12659
+ var EmojiDialog = class extends BaseDialog {
12660
+ _activeCat = "all";
12671
12661
  initialize() {
12672
12662
  return this;
12673
12663
  }
12674
- destroy() {
12675
- this._disposers.forEach((d) => d());
12676
- this._disposers = [];
12677
- if (this._dialog && this._dialog.parentNode) this._dialog.remove();
12678
- this._dialog = null;
12679
- }
12680
12664
  show() {
12681
12665
  if (!this._dialog) {
12682
12666
  this._dialog = this._buildDialog();
12683
12667
  document.body.appendChild(this._dialog);
12684
12668
  }
12685
- withSavedRange((range) => {
12686
- this._savedRange = range;
12687
- });
12669
+ this._saveRange();
12688
12670
  this._activeCat = "all";
12689
12671
  this._searchInput.value = "";
12690
12672
  this._updateCatTabs();
@@ -12753,6 +12735,7 @@ var EmojiDialog = class {
12753
12735
  grid.appendChild(cell);
12754
12736
  });
12755
12737
  this._grid = grid;
12738
+ this._firstInput = searchInput;
12756
12739
  const btnRow = createElement("div", { class: "an-dialog-actions" });
12757
12740
  const cancelBtn = createElement("button", {
12758
12741
  type: "button",
@@ -12842,21 +12825,6 @@ var EmojiDialog = class {
12842
12825
  editable.focus();
12843
12826
  this.context.invoke("editor.afterCommand");
12844
12827
  }
12845
- _open() {
12846
- if (this._dialog) {
12847
- this._dialog.style.display = "flex";
12848
- this._removeTrap = trapFocus(this._dialog, () => this._close());
12849
- setTimeout(() => this._searchInput?.focus(), 50);
12850
- }
12851
- }
12852
- _close() {
12853
- if (this._dialog) this._dialog.style.display = "none";
12854
- if (this._removeTrap) {
12855
- this._removeTrap();
12856
- this._removeTrap = null;
12857
- }
12858
- this._savedRange = null;
12859
- }
12860
12828
  };
12861
12829
  //#endregion
12862
12830
  //#region src/js/module/IconDialog.js
@@ -13114,19 +13082,9 @@ var ICON_LIST = [
13114
13082
  ["gift", "objects"],
13115
13083
  ["puzzle-piece", "objects"]
13116
13084
  ];
13117
- var IconDialog = class {
13118
- /**
13119
- * @param {import('../Context.js').Context} context
13120
- */
13121
- constructor(context) {
13122
- this.context = context;
13123
- /** @type {HTMLElement|null} */
13124
- this._dialog = null;
13125
- this._disposers = [];
13126
- this._savedRange = null;
13127
- this._selectedIcon = null;
13128
- this._activeCat = "all";
13129
- }
13085
+ var IconDialog = class extends BaseDialog {
13086
+ _selectedIcon = null;
13087
+ _activeCat = "all";
13130
13088
  initialize() {
13131
13089
  this._ensureFontAwesome();
13132
13090
  return this;
@@ -13150,20 +13108,12 @@ var IconDialog = class {
13150
13108
  link.referrerPolicy = "no-referrer";
13151
13109
  document.head.appendChild(link);
13152
13110
  }
13153
- destroy() {
13154
- this._disposers.forEach((d) => d());
13155
- this._disposers = [];
13156
- this._dialog?.remove();
13157
- this._dialog = null;
13158
- }
13159
13111
  show() {
13160
13112
  if (!this._dialog) {
13161
13113
  this._dialog = this._buildDialog();
13162
13114
  document.body.appendChild(this._dialog);
13163
13115
  }
13164
- withSavedRange((range) => {
13165
- this._savedRange = range;
13166
- });
13116
+ this._saveRange();
13167
13117
  this._selectedIcon = null;
13168
13118
  this._activeCat = "all";
13169
13119
  this._searchInput.value = "";
@@ -13204,6 +13154,7 @@ var IconDialog = class {
13204
13154
  autocomplete: "off"
13205
13155
  });
13206
13156
  this._searchInput = searchInput;
13157
+ this._firstInput = searchInput;
13207
13158
  const catBar = createElement("div", { class: "an-icon-cats" });
13208
13159
  const allTab = createElement("button", {
13209
13160
  type: "button",
@@ -13422,7 +13373,7 @@ var IconDialog = class {
13422
13373
  }
13423
13374
  range.insertNode(iconEl);
13424
13375
  let caretTextNode = iconEl.nextSibling;
13425
- if (!caretTextNode || caretTextNode.nodeType !== Node.TEXT_NODE) {
13376
+ if (caretTextNode?.nodeType !== Node.TEXT_NODE) {
13426
13377
  caretTextNode = document.createTextNode("​");
13427
13378
  iconEl.parentNode.insertBefore(caretTextNode, iconEl.nextSibling);
13428
13379
  } else if (!caretTextNode.textContent) caretTextNode.textContent = "​";
@@ -13442,21 +13393,9 @@ var IconDialog = class {
13442
13393
  }
13443
13394
  this.context.invoke("editor.afterCommand");
13444
13395
  }
13445
- _open() {
13446
- if (this._dialog) {
13447
- this._dialog.style.display = "flex";
13448
- this._removeTrap = trapFocus(this._dialog, () => this._close());
13449
- setTimeout(() => this._searchInput?.focus(), 50);
13450
- }
13451
- }
13452
13396
  _close() {
13453
- if (this._dialog) this._dialog.style.display = "none";
13454
- if (this._removeTrap) {
13455
- this._removeTrap();
13456
- this._removeTrap = null;
13457
- }
13458
- this._savedRange = null;
13459
13397
  this._selectedIcon = null;
13398
+ super._close();
13460
13399
  }
13461
13400
  };
13462
13401
  //#endregion
@@ -14197,59 +14136,25 @@ var SHORTCUTS = [
14197
14136
  }]
14198
14137
  }
14199
14138
  ];
14200
- var ShortcutsDialog = class {
14201
- /** @param {import('../Context.js').Context} context */
14202
- constructor(context) {
14203
- this.context = context;
14204
- this._dialog = null;
14205
- this._closeBtn = null;
14206
- this._disposers = [];
14207
- }
14208
- initialize() {
14209
- this._dialog = this._buildDialog();
14210
- document.body.appendChild(this._dialog);
14211
- return this;
14212
- }
14213
- destroy() {
14214
- this._disposers.forEach((d) => d());
14215
- this._disposers = [];
14216
- this._dialog?.remove();
14217
- this._dialog = null;
14218
- }
14139
+ 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>`;
14140
+ var ShortcutsDialog = class extends BaseDialog {
14219
14141
  show() {
14220
- if (this._dialog) {
14221
- this._dialog.style.display = "flex";
14222
- this._removeTrap = trapFocus(this._dialog, () => this._close());
14223
- setTimeout(() => this._closeBtn?.focus(), 50);
14224
- }
14225
- }
14226
- _close() {
14227
- if (this._dialog) this._dialog.style.display = "none";
14228
- if (this._removeTrap) {
14229
- this._removeTrap();
14230
- this._removeTrap = null;
14231
- }
14142
+ this._open();
14232
14143
  }
14233
14144
  _buildDialog() {
14234
- const overlay = createElement("div", {
14235
- class: "an-dialog-overlay",
14236
- role: "dialog",
14237
- "aria-modal": "true",
14238
- "aria-label": this.context.locale.shortcutsDialog.ariaLabel
14239
- });
14240
- const box = createElement("div", { class: "an-dialog-box an-shortcuts-box" });
14241
- const titleRow = createElement("div", { class: "an-icon-title-row" });
14242
- const title = createElement("h3", { class: "an-dialog-title" });
14243
- title.textContent = this.context.locale.shortcutsDialog.title;
14145
+ const L = this.context.locale.shortcutsDialog;
14146
+ const { overlay, box } = this._buildDialogShell(L.ariaLabel, ICON_SVG, L.title);
14147
+ box.classList.add("an-shortcuts-box");
14244
14148
  const closeBtn = createElement("button", {
14245
14149
  type: "button",
14246
14150
  class: "an-icon-close",
14247
- "aria-label": this.context.locale.shortcutsDialog.close
14151
+ "aria-label": L.close,
14152
+ style: "margin-left:auto"
14248
14153
  });
14249
14154
  closeBtn.textContent = "×";
14250
14155
  this._closeBtn = closeBtn;
14251
- titleRow.append(title, closeBtn);
14252
- box.appendChild(titleRow);
14156
+ this._firstInput = closeBtn;
14157
+ box.querySelector(".an-dialog-header").appendChild(closeBtn);
14253
14158
  (this.context.locale.shortcutsDialog.shortcuts || SHORTCUTS).forEach(({ category, items }) => {
14254
14159
  const catEl = createElement("div", { class: "an-shortcuts-cat" });
14255
14160
  catEl.textContent = category;
@@ -14266,12 +14171,8 @@ var ShortcutsDialog = class {
14266
14171
  });
14267
14172
  box.appendChild(table);
14268
14173
  });
14269
- overlay.appendChild(box);
14270
14174
  const d1 = on(closeBtn, "click", () => this._close());
14271
- const d2 = on(overlay, "click", (e) => {
14272
- if (e.target === overlay) this._close();
14273
- });
14274
- this._disposers.push(d1, d2);
14175
+ this._disposers.push(d1);
14275
14176
  return overlay;
14276
14177
  }
14277
14178
  };
@@ -14285,12 +14186,10 @@ var ShortcutsDialog = class {
14285
14186
  * for highlighting. Supports case-sensitive search, Prev/Next navigation and
14286
14187
  * single / replace-all replacement.
14287
14188
  */
14288
- var FindReplace = class {
14189
+ var FindReplace = class extends BaseDialog {
14289
14190
  /** @param {import('../Context.js').Context} context */
14290
14191
  constructor(context) {
14291
- this.context = context;
14292
- /** @type {HTMLElement|null} */
14293
- this._dialog = null;
14192
+ super(context);
14294
14193
  /** @type {HTMLInputElement|null} */
14295
14194
  this._findInput = null;
14296
14195
  /** @type {HTMLInputElement|null} */
@@ -14311,23 +14210,13 @@ var FindReplace = class {
14311
14210
  this._queryRegex = null;
14312
14211
  this._lastQuery = null;
14313
14212
  this._lastCaseSensitive = null;
14314
- this._disposers = [];
14315
- this._removeTrap = null;
14316
14213
  this._focusTimer = null;
14317
14214
  }
14318
- initialize() {
14319
- this._dialog = this._buildDialog();
14320
- document.body.appendChild(this._dialog);
14321
- return this;
14322
- }
14323
14215
  destroy() {
14324
14216
  clearTimeout(this._focusTimer);
14325
14217
  this._focusTimer = null;
14326
14218
  this._clearHighlights();
14327
- this._disposers.forEach((d) => d());
14328
- this._disposers = [];
14329
- if (this._dialog && this._dialog.parentNode) this._dialog.remove();
14330
- this._dialog = null;
14219
+ super.destroy();
14331
14220
  }
14332
14221
  /**
14333
14222
  * Opens the dialog in 'find' or 'replace' mode.
@@ -15007,7 +14896,7 @@ var ImageCropOverlay = class {
15007
14896
  const startY = e.clientY;
15008
14897
  const orig = { ...this._box };
15009
14898
  const r = this._imgRect;
15010
- const lockAR = this._arCheck && this._arCheck.checked;
14899
+ const lockAR = this._arCheck?.checked;
15011
14900
  const aspect = orig.w / (orig.h || 1);
15012
14901
  const onMove = (me) => {
15013
14902
  const dx = me.clientX - startX;
@@ -15833,14 +15722,14 @@ var BubbleToolbar = class {
15833
15722
  if (!this._btnCache) return;
15834
15723
  this._btnCache.forEach((btn) => {
15835
15724
  const activeFn = _ACTIVE[btn.dataset.name];
15836
- btn.classList.toggle("an-active", !!(activeFn && activeFn()));
15725
+ btn.classList.toggle("an-active", !!activeFn?.());
15837
15726
  });
15838
15727
  }
15839
15728
  /** Read the current selection's color and update the color-strip indicators. */
15840
15729
  _syncColorStrips() {
15841
15730
  if (!this._el) return;
15842
15731
  const sel = globalThis.getSelection();
15843
- if (!sel || !sel.rangeCount) return;
15732
+ if (!sel?.rangeCount) return;
15844
15733
  let node = sel.getRangeAt(0).startContainer;
15845
15734
  if (node.nodeType === Node.TEXT_NODE) node = node.parentElement;
15846
15735
  if (!node) return;
@@ -16068,7 +15957,7 @@ var Mention = class {
16068
15957
  }
16069
15958
  } catch (_) {}
16070
15959
  const sel = globalThis.getSelection();
16071
- if (!sel || !sel.rangeCount) return;
15960
+ if (!sel?.rangeCount) return;
16072
15961
  const rects = sel.getRangeAt(0).getClientRects();
16073
15962
  if (rects.length > 0) this._caretRect = rects[rects.length - 1];
16074
15963
  }
@@ -16818,7 +16707,7 @@ var AutumnNote = {
16818
16707
  return this;
16819
16708
  },
16820
16709
  /** Library version */
16821
- version: "1.6.2"
16710
+ version: "1.6.5"
16822
16711
  };
16823
16712
  /**
16824
16713
  * @param {string|Element|NodeList|Element[]} selector