@harbour-enterprises/superdoc 0.12.36 → 0.12.37-next.1

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.
Files changed (62) hide show
  1. package/dist/chunks/{eventemitter3-Dq2TEegt.es.js → eventemitter3-BrspJk8q.es.js} +1 -1
  2. package/dist/chunks/{eventemitter3-DuScojUH.cjs → eventemitter3-DfVviFzP.cjs} +1 -1
  3. package/dist/chunks/{index-CMBtuT02.cjs → index-B4J7wgs6.cjs} +2 -2
  4. package/dist/chunks/{index-B1MhwjTC.cjs → index-Cdsq63Xq.cjs} +4 -4
  5. package/dist/chunks/{index-SKpROzLW.es.js → index-Diu6UKHt.es.js} +4 -4
  6. package/dist/chunks/{index-BrSjd1Id.es.js → index-Hr3Um-Bg.es.js} +2 -2
  7. package/dist/chunks/{jszip-Bwu_om3F.cjs → jszip-BTAcmbVg.cjs} +1 -1
  8. package/dist/chunks/{jszip-BmWWPxfF.es.js → jszip-DckFs3A7.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-BtKVLpiq.es.js → super-editor.es-DYzhjqc5.es.js} +1767 -278
  10. package/dist/chunks/{super-editor.es-akFFn4Ld.cjs → super-editor.es-DmBtUqwe.cjs} +1767 -278
  11. package/dist/chunks/{url-DuggQ5JR.cjs → url-BIzg4y2i.cjs} +2 -2
  12. package/dist/chunks/{url-CAZQTNP3.es.js → url-CHayXMZH.es.js} +2 -2
  13. package/dist/chunks/{vue-IIIZMHTg.es.js → vue-Bi1uWinj.es.js} +17 -11
  14. package/dist/chunks/{vue-DPZkajuO.cjs → vue-HIY1g7dm.cjs} +17 -11
  15. package/dist/chunks/{xml-js-B7Vccv2s.cjs → xml-js-BjqmFOSP.cjs} +2 -2
  16. package/dist/chunks/{xml-js-BV-kCPOA.es.js → xml-js-CfClL-1b.es.js} +2 -2
  17. package/dist/core/SuperDoc.d.ts +0 -6
  18. package/dist/core/SuperDoc.d.ts.map +1 -1
  19. package/dist/core/collaboration/collaboration.d.ts +0 -9
  20. package/dist/core/collaboration/collaboration.d.ts.map +1 -1
  21. package/dist/core/collaboration/helpers.d.ts.map +1 -1
  22. package/dist/style.css +36 -7
  23. package/dist/super-editor/ai-writer.es.js +2 -2
  24. package/dist/super-editor/chunks/{converter-BSl_E2ED.js → converter-ffnCghzo.js} +109 -10
  25. package/dist/super-editor/chunks/{docx-zipper-USmuqzmo.js → docx-zipper-BvIz98Bh.js} +1 -1
  26. package/dist/super-editor/chunks/{editor-C0hNf44Q.js → editor-BCC23g3q.js} +1687 -297
  27. package/dist/super-editor/chunks/{toolbar-IN0IJC2L.js → toolbar-BZxPbO0T.js} +2 -2
  28. package/dist/super-editor/components/pagination-helpers.d.ts.map +1 -1
  29. package/dist/super-editor/converter.es.js +1 -1
  30. package/dist/super-editor/core/Attribute.d.ts +2 -2
  31. package/dist/super-editor/core/Editor.d.ts.map +1 -1
  32. package/dist/super-editor/core/InputRule.d.ts +7 -0
  33. package/dist/super-editor/core/InputRule.d.ts.map +1 -1
  34. package/dist/super-editor/core/Schema.d.ts +2 -2
  35. package/dist/super-editor/core/helpers/findWordBounds.d.ts +5 -0
  36. package/dist/super-editor/core/helpers/findWordBounds.d.ts.map +1 -0
  37. package/dist/super-editor/core/helpers/setWordSelection.d.ts +2 -0
  38. package/dist/super-editor/core/helpers/setWordSelection.d.ts.map +1 -0
  39. package/dist/super-editor/core/inputRules/docx-paste/docx-paste.d.ts.map +1 -1
  40. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  41. package/dist/super-editor/core/super-converter/v2/importer/autoPageNumberImporter.d.ts.map +1 -1
  42. package/dist/super-editor/core/super-converter/v2/importer/listImporter.d.ts.map +1 -1
  43. package/dist/super-editor/docx-zipper.es.js +2 -2
  44. package/dist/super-editor/editor.es.js +3 -3
  45. package/dist/super-editor/extensions/field-annotation/FieldAnnotationView.d.ts.map +1 -1
  46. package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
  47. package/dist/super-editor/extensions/page-number/page-number.d.ts +10 -0
  48. package/dist/super-editor/extensions/page-number/page-number.d.ts.map +1 -1
  49. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +2 -1
  50. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
  51. package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
  52. package/dist/super-editor/file-zipper.es.js +1 -1
  53. package/dist/super-editor/style.css +36 -7
  54. package/dist/super-editor/super-editor.es.js +7 -7
  55. package/dist/super-editor/toolbar.es.js +2 -2
  56. package/dist/super-editor.cjs +2 -2
  57. package/dist/super-editor.es.js +2 -2
  58. package/dist/superdoc.cjs +1587 -366
  59. package/dist/superdoc.es.js +1572 -367
  60. package/dist/superdoc.umd.js +3325 -630
  61. package/dist/superdoc.umd.js.map +1 -1
  62. package/package.json +3 -2
@@ -9,12 +9,12 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn;
12
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep, f as Slice, o as objectIncludes, g as deleteProps, D as DOMParser$1, h as ReplaceStep, k as NodeRange, m as findWrapping, n as isMacOS, p as isIOS, q as generateDocxRandomId, s as minMax, t as generateRandom32BitHex, u as DOMSerializer, v as Mark$1, w as dropPoint, x as process$1, B as Buffer2, y as isRegExp, z as TrackDeleteMarkName, C as TrackInsertMarkName, E as v4, G as TrackFormatMarkName, H as comments_module_events, I as AddMarkStep, J as RemoveMarkStep, K as twipsToLines, L as pixelsToTwips, O as SuperConverter, Q as EditorState, U as hasSomeParentWithClass, V as parseSizeUnit, W as getLineHeightValueString, X as toKebabCase, Y as kebabCase, Z as getColStyleDeclaration, _ as SelectionRange, $ as Transform, a0 as createColGroup } from "./converter-BSl_E2ED.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep, f as Slice, o as objectIncludes, g as deleteProps, D as DOMParser$1, h as ReplaceStep, k as NodeRange, m as findWrapping, n as isMacOS, p as isIOS, q as generateDocxRandomId, s as minMax, t as generateRandom32BitHex, u as DOMSerializer, v as Mark$1, w as dropPoint, x as process$1, B as Buffer2, y as isRegExp, z as TrackDeleteMarkName, C as TrackInsertMarkName, E as v4, G as TrackFormatMarkName, H as comments_module_events, I as AddMarkStep, J as RemoveMarkStep, K as twipsToLines, L as pixelsToTwips, O as SuperConverter, Q as EditorState, U as hasSomeParentWithClass, V as parseSizeUnit, W as getLineHeightValueString, X as toKebabCase, Y as kebabCase, Z as getColStyleDeclaration, _ as SelectionRange, $ as Transform, a0 as createColGroup } from "./converter-ffnCghzo.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-USmuqzmo.js";
17
+ import { D as DocxZipper } from "./docx-zipper-BvIz98Bh.js";
18
18
  function getMarksFromSelection(state) {
19
19
  const { from: from2, to, empty: empty2 } = state.selection;
20
20
  const marks = [];
@@ -4281,6 +4281,7 @@ const isEquivalentPosition = function(node, off, targetNode, targetOff) {
4281
4281
  };
4282
4282
  const atomElements = /^(img|br|input|textarea|hr)$/i;
4283
4283
  function scanFor(node, off, targetNode, targetOff, dir) {
4284
+ var _a;
4284
4285
  for (; ; ) {
4285
4286
  if (node == targetNode && off == targetOff)
4286
4287
  return true;
@@ -4291,10 +4292,16 @@ function scanFor(node, off, targetNode, targetOff, dir) {
4291
4292
  off = domIndex(node) + (dir < 0 ? 0 : 1);
4292
4293
  node = parent;
4293
4294
  } else if (node.nodeType == 1) {
4294
- node = node.childNodes[off + (dir < 0 ? -1 : 0)];
4295
- if (node.contentEditable == "false")
4296
- return false;
4297
- off = dir < 0 ? nodeSize(node) : 0;
4295
+ let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
4296
+ if (child.nodeType == 1 && child.contentEditable == "false") {
4297
+ if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection)
4298
+ off += dir;
4299
+ else
4300
+ return false;
4301
+ } else {
4302
+ node = child;
4303
+ off = dir < 0 ? nodeSize(node) : 0;
4304
+ }
4298
4305
  } else {
4299
4306
  return false;
4300
4307
  }
@@ -4423,7 +4430,7 @@ function windowRect(doc2) {
4423
4430
  bottom: doc2.documentElement.clientHeight
4424
4431
  };
4425
4432
  }
4426
- function getSide(value, side) {
4433
+ function getSide$1(value, side) {
4427
4434
  return typeof value == "number" ? value : value[side];
4428
4435
  }
4429
4436
  function clientRect(node) {
@@ -4451,14 +4458,14 @@ function scrollRectIntoView(view, rect, startDOM) {
4451
4458
  let atTop = elt == doc2.body;
4452
4459
  let bounding = atTop ? windowRect(doc2) : clientRect(elt);
4453
4460
  let moveX = 0, moveY = 0;
4454
- if (rect.top < bounding.top + getSide(scrollThreshold, "top"))
4455
- moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
4456
- else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom"))
4457
- moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
4458
- if (rect.left < bounding.left + getSide(scrollThreshold, "left"))
4459
- moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left"));
4460
- else if (rect.right > bounding.right - getSide(scrollThreshold, "right"))
4461
- moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
4461
+ if (rect.top < bounding.top + getSide$1(scrollThreshold, "top"))
4462
+ moveY = -(bounding.top - rect.top + getSide$1(scrollMargin, "top"));
4463
+ else if (rect.bottom > bounding.bottom - getSide$1(scrollThreshold, "bottom"))
4464
+ moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide$1(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide$1(scrollMargin, "bottom");
4465
+ if (rect.left < bounding.left + getSide$1(scrollThreshold, "left"))
4466
+ moveX = -(bounding.left - rect.left + getSide$1(scrollMargin, "left"));
4467
+ else if (rect.right > bounding.right - getSide$1(scrollThreshold, "right"))
4468
+ moveX = rect.right - bounding.right + getSide$1(scrollMargin, "right");
4462
4469
  if (moveX || moveY) {
4463
4470
  if (atTop) {
4464
4471
  doc2.defaultView.scrollBy(moveX, moveY);
@@ -5253,6 +5260,9 @@ class ViewDesc {
5253
5260
  get ignoreForCoords() {
5254
5261
  return false;
5255
5262
  }
5263
+ get ignoreForSelection() {
5264
+ return false;
5265
+ }
5256
5266
  isText(text) {
5257
5267
  return false;
5258
5268
  }
@@ -5301,6 +5311,9 @@ class WidgetViewDesc extends ViewDesc {
5301
5311
  get domAtom() {
5302
5312
  return true;
5303
5313
  }
5314
+ get ignoreForSelection() {
5315
+ return !!this.widget.type.spec.relaxedSide;
5316
+ }
5304
5317
  get side() {
5305
5318
  return this.widget.type.side;
5306
5319
  }
@@ -7081,8 +7094,9 @@ editHandlers.keypress = (view, _event) => {
7081
7094
  let sel = view.state.selection;
7082
7095
  if (!(sel instanceof TextSelection) || !sel.$from.sameParent(sel.$to)) {
7083
7096
  let text = String.fromCharCode(event.charCode);
7084
- if (!/[\r\n]/.test(text) && !view.someProp("handleTextInput", (f) => f(view, sel.$from.pos, sel.$to.pos, text)))
7085
- view.dispatch(view.state.tr.insertText(text).scrollIntoView());
7097
+ let deflt = () => view.state.tr.insertText(text).scrollIntoView();
7098
+ if (!/[\r\n]/.test(text) && !view.someProp("handleTextInput", (f) => f(view, sel.$from.pos, sel.$to.pos, text, deflt)))
7099
+ view.dispatch(deflt());
7086
7100
  event.preventDefault();
7087
7101
  }
7088
7102
  };
@@ -8654,14 +8668,14 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
8654
8668
  if (newSel && !view.state.selection.eq(newSel)) {
8655
8669
  if (chrome && android && view.input.lastKeyCode === 13 && Date.now() - 100 < view.input.lastKeyCodeTime && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter"))))
8656
8670
  return;
8657
- let tr2 = view.state.tr.setSelection(newSel);
8671
+ let tr = view.state.tr.setSelection(newSel);
8658
8672
  if (origin == "pointer")
8659
- tr2.setMeta("pointer", true);
8673
+ tr.setMeta("pointer", true);
8660
8674
  else if (origin == "key")
8661
- tr2.scrollIntoView();
8675
+ tr.scrollIntoView();
8662
8676
  if (compositionID)
8663
- tr2.setMeta("composition", compositionID);
8664
- view.dispatch(tr2);
8677
+ tr.setMeta("composition", compositionID);
8678
+ view.dispatch(tr);
8665
8679
  }
8666
8680
  return;
8667
8681
  }
@@ -8695,10 +8709,10 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
8695
8709
  if (parse.sel) {
8696
8710
  let sel2 = resolveSelection(view, view.state.doc, parse.sel);
8697
8711
  if (sel2 && !sel2.eq(view.state.selection)) {
8698
- let tr2 = view.state.tr.setSelection(sel2);
8712
+ let tr = view.state.tr.setSelection(sel2);
8699
8713
  if (compositionID)
8700
- tr2.setMeta("composition", compositionID);
8701
- view.dispatch(tr2);
8714
+ tr.setMeta("composition", compositionID);
8715
+ view.dispatch(tr);
8702
8716
  }
8703
8717
  }
8704
8718
  return;
@@ -8743,43 +8757,48 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
8743
8757
  }, 20);
8744
8758
  }
8745
8759
  let chFrom = change.start, chTo = change.endA;
8746
- let tr, storedMarks, markChange;
8760
+ let mkTr = (base2) => {
8761
+ let tr = base2 || view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));
8762
+ if (parse.sel) {
8763
+ let sel2 = resolveSelection(view, tr.doc, parse.sel);
8764
+ if (sel2 && !(chrome && view.composing && sel2.empty && (change.start != change.endB || view.input.lastChromeDelete < Date.now() - 100) && (sel2.head == chFrom || sel2.head == tr.mapping.map(chTo) - 1) || ie$1 && sel2.empty && sel2.head == chFrom))
8765
+ tr.setSelection(sel2);
8766
+ }
8767
+ if (compositionID)
8768
+ tr.setMeta("composition", compositionID);
8769
+ return tr.scrollIntoView();
8770
+ };
8771
+ let markChange;
8747
8772
  if (inlineChange) {
8748
8773
  if ($from.pos == $to.pos) {
8749
8774
  if (ie$1 && ie_version <= 11 && $from.parentOffset == 0) {
8750
8775
  view.domObserver.suppressSelectionUpdates();
8751
8776
  setTimeout(() => selectionToDOM(view), 20);
8752
8777
  }
8753
- tr = view.state.tr.delete(chFrom, chTo);
8754
- storedMarks = doc2.resolve(change.start).marksAcross(doc2.resolve(change.endA));
8778
+ let tr = mkTr(view.state.tr.delete(chFrom, chTo));
8779
+ let marks = doc2.resolve(change.start).marksAcross(doc2.resolve(change.endA));
8780
+ if (marks)
8781
+ tr.ensureMarks(marks);
8782
+ view.dispatch(tr);
8755
8783
  } else if (
8756
8784
  // Adding or removing a mark
8757
8785
  change.endA == change.endB && (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset), $fromA.parent.content.cut($fromA.parentOffset, change.endA - $fromA.start())))
8758
8786
  ) {
8759
- tr = view.state.tr;
8787
+ let tr = mkTr(view.state.tr);
8760
8788
  if (markChange.type == "add")
8761
8789
  tr.addMark(chFrom, chTo, markChange.mark);
8762
8790
  else
8763
8791
  tr.removeMark(chFrom, chTo, markChange.mark);
8792
+ view.dispatch(tr);
8764
8793
  } else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {
8765
8794
  let text = $from.parent.textBetween($from.parentOffset, $to.parentOffset);
8766
- if (view.someProp("handleTextInput", (f) => f(view, chFrom, chTo, text)))
8767
- return;
8768
- tr = view.state.tr.insertText(text, chFrom, chTo);
8795
+ let deflt = () => mkTr(view.state.tr.insertText(text, chFrom, chTo));
8796
+ if (!view.someProp("handleTextInput", (f) => f(view, chFrom, chTo, text, deflt)))
8797
+ view.dispatch(deflt());
8769
8798
  }
8799
+ } else {
8800
+ view.dispatch(mkTr());
8770
8801
  }
8771
- if (!tr)
8772
- tr = view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));
8773
- if (parse.sel) {
8774
- let sel2 = resolveSelection(view, tr.doc, parse.sel);
8775
- if (sel2 && !(chrome && view.composing && sel2.empty && (change.start != change.endB || view.input.lastChromeDelete < Date.now() - 100) && (sel2.head == chFrom || sel2.head == tr.mapping.map(chTo) - 1) || ie$1 && sel2.empty && sel2.head == chFrom))
8776
- tr.setSelection(sel2);
8777
- }
8778
- if (storedMarks)
8779
- tr.ensureMarks(storedMarks);
8780
- if (compositionID)
8781
- tr.setMeta("composition", compositionID);
8782
- view.dispatch(tr.scrollIntoView());
8783
8802
  }
8784
8803
  function resolveSelection(view, doc2, parsedSel) {
8785
8804
  if (Math.max(parsedSel.anchor, parsedSel.head) > doc2.content.size)
@@ -9301,22 +9320,6 @@ class EditorView {
9301
9320
  return dispatchEvent(this, event);
9302
9321
  }
9303
9322
  /**
9304
- Dispatch a transaction. Will call
9305
- [`dispatchTransaction`](https://prosemirror.net/docs/ref/#view.DirectEditorProps.dispatchTransaction)
9306
- when given, and otherwise defaults to applying the transaction to
9307
- the current state and calling
9308
- [`updateState`](https://prosemirror.net/docs/ref/#view.EditorView.updateState) with the result.
9309
- This method is bound to the view instance, so that it can be
9310
- easily passed around.
9311
- */
9312
- dispatch(tr) {
9313
- let dispatchTransaction = this._props.dispatchTransaction;
9314
- if (dispatchTransaction)
9315
- dispatchTransaction.call(this, tr);
9316
- else
9317
- this.updateState(this.state.apply(tr));
9318
- }
9319
- /**
9320
9323
  @internal
9321
9324
  */
9322
9325
  domSelectionRange() {
@@ -9332,6 +9335,13 @@ class EditorView {
9332
9335
  return this.root.getSelection();
9333
9336
  }
9334
9337
  }
9338
+ EditorView.prototype.dispatch = function(tr) {
9339
+ let dispatchTransaction = this._props.dispatchTransaction;
9340
+ if (dispatchTransaction)
9341
+ dispatchTransaction.call(this, tr);
9342
+ else
9343
+ this.updateState(this.state.apply(tr));
9344
+ };
9335
9345
  function computeDocDeco(view) {
9336
9346
  let attrs = /* @__PURE__ */ Object.create(null);
9337
9347
  attrs.class = "ProseMirror";
@@ -9397,10 +9407,10 @@ function checkStateComponent(plugin) {
9397
9407
  if (plugin.spec.state || plugin.spec.filterTransaction || plugin.spec.appendTransaction)
9398
9408
  throw new RangeError("Plugins passed directly to the view must not have a state component");
9399
9409
  }
9400
- const floor = Math.floor;
9410
+ const floor$1 = Math.floor;
9401
9411
  const abs = Math.abs;
9402
- const min$1 = (a, b) => a < b ? a : b;
9403
- const max$1 = (a, b) => a > b ? a : b;
9412
+ const min$2 = (a, b) => a < b ? a : b;
9413
+ const max$2 = (a, b) => a > b ? a : b;
9404
9414
  const isNegativeZero = (n) => n !== 0 ? n < 0 : 1 / n < 0;
9405
9415
  const BIT7 = 64;
9406
9416
  const BIT8 = 128;
@@ -9408,7 +9418,7 @@ const BIT30 = 1 << 29;
9408
9418
  const BITS6 = 63;
9409
9419
  const BITS7 = 127;
9410
9420
  const BITS31 = 2147483647;
9411
- const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
9421
+ const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor$1(num) === num);
9412
9422
  const create$2 = () => /* @__PURE__ */ new Set();
9413
9423
  const isArray = Array.isArray;
9414
9424
  const fromCharCode = String.fromCharCode;
@@ -9472,7 +9482,7 @@ const verifyLen = (encoder, len) => {
9472
9482
  const bufferLen = encoder.cbuf.length;
9473
9483
  if (bufferLen - encoder.cpos < len) {
9474
9484
  encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos));
9475
- encoder.cbuf = new Uint8Array(max$1(bufferLen, len) * 2);
9485
+ encoder.cbuf = new Uint8Array(max$2(bufferLen, len) * 2);
9476
9486
  encoder.cpos = 0;
9477
9487
  }
9478
9488
  };
@@ -9488,7 +9498,7 @@ const write$1 = (encoder, num) => {
9488
9498
  const writeVarUint = (encoder, num) => {
9489
9499
  while (num > BITS7) {
9490
9500
  write$1(encoder, BIT8 | BITS7 & num);
9491
- num = floor(num / 128);
9501
+ num = floor$1(num / 128);
9492
9502
  }
9493
9503
  write$1(encoder, BITS7 & num);
9494
9504
  };
@@ -9498,10 +9508,10 @@ const writeVarInt = (encoder, num) => {
9498
9508
  num = -num;
9499
9509
  }
9500
9510
  write$1(encoder, (num > BITS6 ? BIT8 : 0) | (isNegative ? BIT7 : 0) | BITS6 & num);
9501
- num = floor(num / 64);
9511
+ num = floor$1(num / 64);
9502
9512
  while (num > 0) {
9503
9513
  write$1(encoder, (num > BITS7 ? BIT8 : 0) | BITS7 & num);
9504
- num = floor(num / 128);
9514
+ num = floor$1(num / 128);
9505
9515
  }
9506
9516
  };
9507
9517
  const _strBuffer = new Uint8Array(3e4);
@@ -9534,13 +9544,13 @@ utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
9534
9544
  const writeUint8Array = (encoder, uint8Array) => {
9535
9545
  const bufferLen = encoder.cbuf.length;
9536
9546
  const cpos = encoder.cpos;
9537
- const leftCopyLen = min$1(bufferLen - cpos, uint8Array.length);
9547
+ const leftCopyLen = min$2(bufferLen - cpos, uint8Array.length);
9538
9548
  const rightCopyLen = uint8Array.length - leftCopyLen;
9539
9549
  encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
9540
9550
  encoder.cpos += leftCopyLen;
9541
9551
  if (rightCopyLen > 0) {
9542
9552
  encoder.bufs.push(encoder.cbuf);
9543
- encoder.cbuf = new Uint8Array(max$1(bufferLen * 2, rightCopyLen));
9553
+ encoder.cbuf = new Uint8Array(max$2(bufferLen * 2, rightCopyLen));
9544
9554
  encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
9545
9555
  encoder.cpos = rightCopyLen;
9546
9556
  }
@@ -9682,7 +9692,7 @@ const ySyncPluginKey = new PluginKey("y-sync");
9682
9692
  const yUndoPluginKey = new PluginKey("y-undo");
9683
9693
  const yCursorPluginKey = new PluginKey("yjs-cursor");
9684
9694
  const rand = Math.random;
9685
- const oneOf = (arr) => arr[floor(rand() * arr.length)];
9695
+ const oneOf = (arr) => arr[floor$1(rand() * arr.length)];
9686
9696
  const undefinedToNull = (v) => v === void 0 ? null : v;
9687
9697
  class VarStoragePolyfill {
9688
9698
  constructor() {
@@ -9712,12 +9722,12 @@ try {
9712
9722
  } catch (e) {
9713
9723
  }
9714
9724
  const varStorage = _localStorage;
9715
- const isNode = typeof process$1 !== "undefined" && process$1.release && /node|io\.js/.test(process$1.release.name) && Object.prototype.toString.call(typeof process$1 !== "undefined" ? process$1 : 0) === "[object process]";
9716
- const isBrowser$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode;
9725
+ const isNode$1 = typeof process$1 !== "undefined" && process$1.release && /node|io\.js/.test(process$1.release.name) && Object.prototype.toString.call(typeof process$1 !== "undefined" ? process$1 : 0) === "[object process]";
9726
+ const isBrowser$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode$1;
9717
9727
  let params;
9718
9728
  const computeParams = () => {
9719
9729
  if (params === void 0) {
9720
- if (isNode) {
9730
+ if (isNode$1) {
9721
9731
  params = create();
9722
9732
  const pargs = process$1.argv;
9723
9733
  let currParamName = null;
@@ -9754,12 +9764,12 @@ const computeParams = () => {
9754
9764
  return params;
9755
9765
  };
9756
9766
  const hasParam = (name) => computeParams().has(name);
9757
- const getVariable = (name) => isNode ? undefinedToNull(process$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
9767
+ const getVariable = (name) => isNode$1 ? undefinedToNull(process$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
9758
9768
  const hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
9759
9769
  hasConf("production");
9760
- const forceColor = isNode && isOneOf(process$1.env.FORCE_COLOR, ["true", "1", "2"]);
9770
+ const forceColor = isNode$1 && isOneOf(process$1.env.FORCE_COLOR, ["true", "1", "2"]);
9761
9771
  forceColor || !hasParam("--no-colors") && // @todo deprecate --no-colors
9762
- !hasConf("no-color") && (!isNode || process$1.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
9772
+ !hasConf("no-color") && (!isNode$1 || process$1.stdout.isTTY) && (!isNode$1 || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
9763
9773
  const doc = (
9764
9774
  /** @type {Document} */
9765
9775
  typeof document !== "undefined" ? document : {}
@@ -10268,8 +10278,8 @@ class ProsemirrorBinding {
10268
10278
  new Slice(Fragment.from(fragmentContent), 0, 0)
10269
10279
  );
10270
10280
  if (sel) {
10271
- const clampedAnchor = min$1(max$1(sel.anchor, 0), tr.doc.content.size);
10272
- const clampedHead = min$1(max$1(sel.head, 0), tr.doc.content.size);
10281
+ const clampedAnchor = min$2(max$2(sel.anchor, 0), tr.doc.content.size);
10282
+ const clampedHead = min$2(max$2(sel.head, 0), tr.doc.content.size);
10273
10283
  tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));
10274
10284
  }
10275
10285
  this.prosemirrorView.dispatch(
@@ -10666,7 +10676,7 @@ const computeChildEqualityFactor = (ytype, pnode, meta) => {
10666
10676
  const pChildren = normalizePNodeContent(pnode);
10667
10677
  const pChildCnt = pChildren.length;
10668
10678
  const yChildCnt = yChildren.length;
10669
- const minCnt = min$1(yChildCnt, pChildCnt);
10679
+ const minCnt = min$2(yChildCnt, pChildCnt);
10670
10680
  let left2 = 0;
10671
10681
  let right2 = 0;
10672
10682
  let foundMappedChild = false;
@@ -10778,7 +10788,7 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
10778
10788
  const pChildCnt = pChildren.length;
10779
10789
  const yChildren = yDomFragment.toArray();
10780
10790
  const yChildCnt = yChildren.length;
10781
- const minCnt = min$1(pChildCnt, yChildCnt);
10791
+ const minCnt = min$2(pChildCnt, yChildCnt);
10782
10792
  let left2 = 0;
10783
10793
  let right2 = 0;
10784
10794
  for (; left2 < minCnt; left2++) {
@@ -11151,17 +11161,17 @@ const createDecorations = (state, awareness, awarenessFilter, createCursor, crea
11151
11161
  ystate.binding.mapping
11152
11162
  );
11153
11163
  if (anchor !== null && head !== null) {
11154
- const maxsize = max$1(state.doc.content.size - 1, 0);
11155
- anchor = min$1(anchor, maxsize);
11156
- head = min$1(head, maxsize);
11164
+ const maxsize = max$2(state.doc.content.size - 1, 0);
11165
+ anchor = min$2(anchor, maxsize);
11166
+ head = min$2(head, maxsize);
11157
11167
  decorations.push(
11158
11168
  Decoration.widget(head, () => createCursor(user, clientId), {
11159
11169
  key: clientId + "",
11160
11170
  side: 10
11161
11171
  })
11162
11172
  );
11163
- const from2 = min$1(anchor, head);
11164
- const to = max$1(anchor, head);
11173
+ const from2 = min$2(anchor, head);
11174
+ const to = max$2(anchor, head);
11165
11175
  decorations.push(
11166
11176
  Decoration.inline(from2, to, createSelection(user, clientId), {
11167
11177
  inclusiveEnd: true,
@@ -11615,7 +11625,8 @@ const getTextContentFromNodes = ($from, maxMatch = 500) => {
11615
11625
  const handleDocxPaste = (html, editor, view, plugin) => {
11616
11626
  const { converter } = editor;
11617
11627
  if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin);
11618
- const cleanedHtml = convertEmToPt(html);
11628
+ let cleanedHtml = convertEmToPt(html);
11629
+ cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
11619
11630
  const tempDiv = document.createElement("div");
11620
11631
  tempDiv.innerHTML = cleanedHtml;
11621
11632
  const paragraphs = tempDiv.querySelectorAll("p");
@@ -11986,6 +11997,9 @@ const convertEmToPt = (html) => {
11986
11997
  }
11987
11998
  );
11988
11999
  };
12000
+ function cleanHtmlUnnecessaryTags(html) {
12001
+ return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/&nbsp;/gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
12002
+ }
11989
12003
  const _ExtensionService = class _ExtensionService {
11990
12004
  constructor(extensions, userExtensions, editor) {
11991
12005
  __privateAdd(this, _ExtensionService_instances);
@@ -12792,7 +12806,8 @@ const createHeaderFooterEditor = ({
12792
12806
  appendToBody = true,
12793
12807
  sectionId,
12794
12808
  type,
12795
- availableHeight
12809
+ availableHeight,
12810
+ currentPageNumber
12796
12811
  }) => {
12797
12812
  const parentStyles = editor.converter.getDocumentDefaultStyles();
12798
12813
  const { fontSizePt, typeface } = parentStyles;
@@ -12833,6 +12848,8 @@ const createHeaderFooterEditor = ({
12833
12848
  fonts: editor.options.fonts,
12834
12849
  isHeaderOrFooter: true,
12835
12850
  annotations: true,
12851
+ currentPageNumber,
12852
+ parentEditor: editor,
12836
12853
  onCreate: (evt) => setEditorToolbar(evt, editor),
12837
12854
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type)
12838
12855
  });
@@ -13976,9 +13993,9 @@ const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
13976
13993
  if (type.name !== "paragraph" && type.name !== "fieldAnnotation") return;
13977
13994
  child.children.forEach((inline) => {
13978
13995
  const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
13979
- const isMatchingField = inline.type.name === "fieldAnnotation" && isFieldToDelete;
13980
- const isEmpty2 = inline.childCount === 0;
13981
- if (!isEmpty2 && !isMatchingField) hasOtherNodes = true;
13996
+ const isFieldType = inline.type.name === "fieldAnnotation";
13997
+ const isMatchingField = isFieldType && isFieldToDelete;
13998
+ if (!isFieldType && !isMatchingField) hasOtherNodes = true;
13982
13999
  if (isMatchingField) matchingNodesFound += 1;
13983
14000
  });
13984
14001
  });
@@ -14180,6 +14197,25 @@ function useHighContrastMode() {
14180
14197
  setHighContrastMode
14181
14198
  };
14182
14199
  }
14200
+ const findWordBounds = (doc2, pos) => {
14201
+ const $pos = doc2.resolve(pos);
14202
+ const parent = $pos.parent;
14203
+ const offset2 = $pos.parentOffset;
14204
+ const text = parent.textContent;
14205
+ if (!text) return { from: pos, to: pos };
14206
+ let start2 = offset2, end2 = offset2;
14207
+ while (start2 > 0 && /\w/.test(text[start2 - 1])) start2--;
14208
+ while (end2 < text.length && /\w/.test(text[end2])) end2++;
14209
+ const from2 = $pos.start() + start2;
14210
+ const to = $pos.start() + end2;
14211
+ return { from: from2, to };
14212
+ };
14213
+ const setWordSelection = (view, pos) => {
14214
+ const { state, dispatch } = view;
14215
+ const word = findWordBounds(state.doc, pos);
14216
+ const tr = state.tr.setSelection(TextSelection.create(state.doc, word.from, word.to));
14217
+ dispatch(tr);
14218
+ };
14183
14219
  const _Editor = class _Editor extends EventEmitter {
14184
14220
  /**
14185
14221
  * Create a new Editor instance
@@ -14451,6 +14487,7 @@ const _Editor = class _Editor extends EventEmitter {
14451
14487
  __privateMethod(this, _Editor_instances, initMedia_fn).call(this);
14452
14488
  const doc2 = __privateMethod(this, _Editor_instances, generatePmData_fn).call(this);
14453
14489
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
14490
+ tr.setMeta("replaceContent", true);
14454
14491
  this.view.dispatch(tr);
14455
14492
  }
14456
14493
  /**
@@ -14858,7 +14895,7 @@ const _Editor = class _Editor extends EventEmitter {
14858
14895
  * @returns {Object | void} Migration results
14859
14896
  */
14860
14897
  processCollaborationMigrations() {
14861
- console.debug("[checkVersionMigrations] Current editor version", "0.12.36");
14898
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.37-next.1");
14862
14899
  if (!this.options.ydoc) return;
14863
14900
  const metaMap = this.options.ydoc.getMap("meta");
14864
14901
  let docVersion = metaMap.get("version");
@@ -15309,6 +15346,7 @@ createView_fn = function() {
15309
15346
  if (isHeader || isFooter) {
15310
15347
  const eventClone = new event.constructor(event.type);
15311
15348
  event.target.dispatchEvent(eventClone);
15349
+ if (this.options.isHeaderOrFooter && this.options.editable) setWordSelection(view, pos);
15312
15350
  return;
15313
15351
  }
15314
15352
  event.stopPropagation();
@@ -15319,6 +15357,7 @@ createView_fn = function() {
15319
15357
  pm.classList.remove("header-footer-edit");
15320
15358
  pm.setAttribute("aria-readonly", false);
15321
15359
  }
15360
+ setWordSelection(view, pos);
15322
15361
  }
15323
15362
  });
15324
15363
  const newState = this.state.reconfigure({
@@ -20528,7 +20567,7 @@ const Table = Node$1.create({
20528
20567
  if (!borders) return {};
20529
20568
  const style = Object.entries(borders).reduce(
20530
20569
  (acc, [key, { size, color }]) => {
20531
- return `${acc}border-${key}: ${size}px solid ${color || "black"};`;
20570
+ return `${acc}border-${key}: ${Math.ceil(size)}px solid ${color || "black"};`;
20532
20571
  },
20533
20572
  ""
20534
20573
  );
@@ -20868,8 +20907,8 @@ const TableCell = Node$1.create({
20868
20907
  cellMargins: {
20869
20908
  renderDOM({ cellMargins }) {
20870
20909
  if (!cellMargins) return {};
20871
- const sides = ["top", "right", "bottom", "left"];
20872
- const style = sides.map((side) => {
20910
+ const sides2 = ["top", "right", "bottom", "left"];
20911
+ const style = sides2.map((side) => {
20873
20912
  const margin = cellMargins?.[side];
20874
20913
  if (margin) return `padding-${side}: ${margin}px;`;
20875
20914
  return "";
@@ -20881,11 +20920,11 @@ const TableCell = Node$1.create({
20881
20920
  default: () => createCellBorders(),
20882
20921
  renderDOM({ borders }) {
20883
20922
  if (!borders) return {};
20884
- const sides = ["top", "right", "bottom", "left"];
20885
- const style = sides.map((side) => {
20923
+ const sides2 = ["top", "right", "bottom", "left"];
20924
+ const style = sides2.map((side) => {
20886
20925
  const border = borders?.[side];
20887
20926
  if (border && border.val === "none") return `border-${side}: ${border.val};`;
20888
- if (border) return `border-${side}: ${border.size}px solid ${border.color || "black"};`;
20927
+ if (border) return `border-${side}: ${Math.ceil(border.size)}px solid ${border.color || "black"};`;
20889
20928
  return "";
20890
20929
  }).join(" ");
20891
20930
  return { style };
@@ -21111,7 +21150,7 @@ class FieldAnnotationView {
21111
21150
  }
21112
21151
  _FieldAnnotationView_instances = new WeakSet();
21113
21152
  createAnnotation_fn = function({ displayLabel } = {}) {
21114
- let { highlighted } = this.node.attrs;
21153
+ let { highlighted, rawHtml } = this.node.attrs;
21115
21154
  let annotation = document.createElement("span");
21116
21155
  annotation.classList.add(this.annotationClass);
21117
21156
  let content = document.createElement("span");
@@ -21123,7 +21162,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
21123
21162
  }
21124
21163
  annotation.append(content);
21125
21164
  let omitHighlight = highlighted === false;
21126
- let annotationStyle = [`border: 2px solid ${this.borderColor}`, `border-radius: 2px`, `padding: 1px 2px`, `box-sizing: border-box`].join(
21165
+ let styles = [`border: 2px solid ${this.borderColor}`, `border-radius: 2px`, `padding: 1px 2px`, `box-sizing: border-box`];
21166
+ if (rawHtml) {
21167
+ styles.push("font-weight: normal");
21168
+ }
21169
+ let annotationStyle = styles.join(
21127
21170
  "; "
21128
21171
  );
21129
21172
  let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
@@ -21678,6 +21721,12 @@ const FieldAnnotation = Node$1.create({
21678
21721
  parseDOM: (elem) => elem.getAttribute("data-bold") === "true",
21679
21722
  renderDOM: (attrs) => {
21680
21723
  if (!attrs.bold) return {};
21724
+ if (attrs.rawHtml) {
21725
+ return {
21726
+ "data-bold": "false",
21727
+ style: "font-weight: normal"
21728
+ };
21729
+ }
21681
21730
  return {
21682
21731
  "data-bold": "true",
21683
21732
  style: "font-weight: bold"
@@ -21688,7 +21737,7 @@ const FieldAnnotation = Node$1.create({
21688
21737
  default: false,
21689
21738
  parseDOM: (elem) => elem.getAttribute("data-italic") === "true",
21690
21739
  renderDOM: (attrs) => {
21691
- if (!attrs.italic) return {};
21740
+ if (!attrs.italic || attrs.rawHtml) return {};
21692
21741
  return {
21693
21742
  "data-italic": "true",
21694
21743
  style: "font-style: italic"
@@ -21699,7 +21748,7 @@ const FieldAnnotation = Node$1.create({
21699
21748
  default: false,
21700
21749
  parseDOM: (elem) => elem.getAttribute("data-underline") === "true",
21701
21750
  renderDOM: (attrs) => {
21702
- if (!attrs.underline) return {};
21751
+ if (!attrs.underline || attrs.rawHtml) return {};
21703
21752
  return {
21704
21753
  "data-underline": "true",
21705
21754
  style: "text-decoration: underline"
@@ -21721,7 +21770,7 @@ const FieldAnnotation = Node$1.create({
21721
21770
  default: null,
21722
21771
  parseDOM: (elem) => elem.getAttribute("data-font-size") || elem.style.fontSize || null,
21723
21772
  renderDOM: (attrs) => {
21724
- if (!attrs.fontSize) return {};
21773
+ if (!attrs.fontSize || attrs.rawHtml) return {};
21725
21774
  let [value, unit] = parseSizeUnit(attrs.fontSize);
21726
21775
  if (Number.isNaN(value)) return {};
21727
21776
  unit = unit ? unit : "pt";
@@ -22640,32 +22689,89 @@ const PageNumber = Node$1.create({
22640
22689
  name: "page-number",
22641
22690
  group: "inline",
22642
22691
  inline: true,
22643
- content: "text*",
22692
+ atom: true,
22693
+ selectable: false,
22694
+ draggable: false,
22695
+ selectable: false,
22696
+ defining: true,
22697
+ content: "",
22644
22698
  addOptions() {
22645
22699
  return {
22646
22700
  htmlAttributes: {
22701
+ contenteditable: false,
22647
22702
  "data-id": "auto-page-number",
22648
22703
  "aria-label": "Page number node"
22649
22704
  }
22650
22705
  };
22651
22706
  },
22707
+ addAttributes() {
22708
+ return {
22709
+ marksAsAttrs: {
22710
+ default: null,
22711
+ rendered: false
22712
+ }
22713
+ };
22714
+ },
22715
+ addNodeView() {
22716
+ return ({ node, editor, getPos, decorations }) => {
22717
+ const htmlAttributes = this.options.htmlAttributes;
22718
+ return new AutoPageNumberNodeView(node, getPos, decorations, editor, htmlAttributes);
22719
+ };
22720
+ },
22652
22721
  parseDOM() {
22653
22722
  return [{ tag: 'span[data-id="auto-page-number"' }];
22654
22723
  },
22655
22724
  renderDOM({ htmlAttributes }) {
22656
- return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
22725
+ return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
22726
+ },
22727
+ addCommands() {
22728
+ return {
22729
+ addAutoPageNumber: () => ({ tr, dispatch, state, editor }) => {
22730
+ const { options } = editor;
22731
+ if (!options.isHeaderOrFooter) return false;
22732
+ const { schema } = state;
22733
+ const pageNumberType = schema?.nodes?.["page-number"];
22734
+ if (!pageNumberType) return false;
22735
+ const pageNumberNodeJSON = { type: "page-number" };
22736
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
22737
+ if (dispatch) {
22738
+ tr.replaceSelectionWith(pageNumberNode, false);
22739
+ tr.setMeta("forceUpdatePagination", true);
22740
+ }
22741
+ return true;
22742
+ }
22743
+ };
22744
+ },
22745
+ addShortcuts() {
22746
+ return {
22747
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
22748
+ };
22657
22749
  }
22658
22750
  });
22659
22751
  const TotalPageCount = Node$1.create({
22660
22752
  name: "total-page-number",
22661
22753
  group: "inline",
22662
22754
  inline: true,
22755
+ atom: true,
22756
+ selectable: false,
22757
+ draggable: false,
22758
+ selectable: false,
22663
22759
  content: "text*",
22664
22760
  addOptions() {
22665
22761
  return {
22666
22762
  htmlAttributes: {
22763
+ contenteditable: false,
22667
22764
  "data-id": "auto-total-pages",
22668
- "aria-label": "Total page count node"
22765
+ "aria-label": "Total page count node",
22766
+ "class": "sd-editor-auto-total-pages"
22767
+ }
22768
+ };
22769
+ },
22770
+ addAttributes() {
22771
+ return {
22772
+ marksAsAttrs: {
22773
+ default: null,
22774
+ rendered: false
22669
22775
  }
22670
22776
  };
22671
22777
  },
@@ -22674,8 +22780,139 @@ const TotalPageCount = Node$1.create({
22674
22780
  },
22675
22781
  renderDOM({ htmlAttributes }) {
22676
22782
  return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
22783
+ },
22784
+ addCommands() {
22785
+ return {
22786
+ addTotalPageCount: () => ({ tr, dispatch, state, editor }) => {
22787
+ const { options } = editor;
22788
+ if (!options.isHeaderOrFooter) return false;
22789
+ const { schema } = state;
22790
+ const pageNumberType = schema.nodes?.["total-page-number"];
22791
+ if (!pageNumberType) return false;
22792
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
22793
+ const pageNumberNode = {
22794
+ type: "total-page-number",
22795
+ content: [{ type: "text", text: String(currentPages) }]
22796
+ };
22797
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
22798
+ if (dispatch) {
22799
+ tr.replaceSelectionWith(pageNode, false);
22800
+ }
22801
+ return true;
22802
+ }
22803
+ };
22804
+ },
22805
+ addShortcuts() {
22806
+ return {
22807
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
22808
+ };
22677
22809
  }
22678
22810
  });
22811
+ class AutoPageNumberNodeView {
22812
+ constructor(node, getPos, decorations, editor, htmlAttributes = {}) {
22813
+ __privateAdd(this, _AutoPageNumberNodeView_instances);
22814
+ this.node = node;
22815
+ this.editor = editor;
22816
+ this.view = editor.view;
22817
+ this.getPos = getPos;
22818
+ this.editor = editor;
22819
+ this.dom = __privateMethod(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node, htmlAttributes);
22820
+ }
22821
+ update(node) {
22822
+ if (node.type !== this.node.type) return false;
22823
+ this.node = node;
22824
+ return true;
22825
+ }
22826
+ }
22827
+ _AutoPageNumberNodeView_instances = new WeakSet();
22828
+ renderDom_fn = function(node, htmlAttributes) {
22829
+ const pageText = this.editor.options.currentPageNumber || "1";
22830
+ const content = document.createTextNode(String(pageText));
22831
+ const nodeContent = document.createElement("span");
22832
+ nodeContent.className = "sd-editor-auto-page-number";
22833
+ nodeContent.setAttribute("data-id", "auto-page-number");
22834
+ nodeContent.setAttribute("aria-label", "Page number node");
22835
+ const currentPos = this.getPos();
22836
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
22837
+ __privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
22838
+ Object.assign(nodeContent.style, styles);
22839
+ nodeContent.appendChild(content);
22840
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
22841
+ if (value) nodeContent.setAttribute(key, value);
22842
+ });
22843
+ return nodeContent;
22844
+ };
22845
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
22846
+ setTimeout(() => {
22847
+ const { state } = this.editor;
22848
+ const { dispatch } = this.view;
22849
+ const node = state.doc.nodeAt(pos);
22850
+ if (!node) return;
22851
+ const currentMarks = node.attrs.marksAsAttrs || [];
22852
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
22853
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
22854
+ if (isEqual) return;
22855
+ const newAttrs = {
22856
+ ...node.attrs,
22857
+ marksAsAttrs: newMarks
22858
+ };
22859
+ const tr = state.tr.setNodeMarkup(pos, void 0, newAttrs);
22860
+ dispatch(tr);
22861
+ }, 0);
22862
+ };
22863
+ const getMarksFromNeighbors = (currentPos, view) => {
22864
+ const $pos = view.state.doc.resolve(currentPos);
22865
+ const styles = {};
22866
+ const marks = [];
22867
+ const before = $pos.nodeBefore;
22868
+ if (before) {
22869
+ Object.assign(styles, processMarks(before.marks));
22870
+ marks.push(...before.marks);
22871
+ }
22872
+ const after = $pos.nodeAfter;
22873
+ if (after) {
22874
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
22875
+ marks.push(...after.marks);
22876
+ }
22877
+ return {
22878
+ styles,
22879
+ marks
22880
+ };
22881
+ };
22882
+ const processMarks = (marks) => {
22883
+ const styles = {};
22884
+ marks.forEach((mark) => {
22885
+ const { type, attrs } = mark;
22886
+ switch (type.name) {
22887
+ case "textStyle":
22888
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
22889
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
22890
+ if (attrs.color) styles["color"] = attrs.color;
22891
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
22892
+ break;
22893
+ case "bold":
22894
+ styles["font-weight"] = "bold";
22895
+ break;
22896
+ case "italic":
22897
+ styles["font-style"] = "italic";
22898
+ break;
22899
+ case "underline":
22900
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
22901
+ break;
22902
+ case "strike":
22903
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
22904
+ break;
22905
+ default:
22906
+ if (attrs?.style) {
22907
+ Object.entries(attrs.style).forEach(([key, value]) => {
22908
+ styles[key] = value;
22909
+ });
22910
+ }
22911
+ break;
22912
+ }
22913
+ });
22914
+ return styles;
22915
+ };
22679
22916
  const ShapeContainer = Node$1.create({
22680
22917
  name: "shapeContainer",
22681
22918
  group: "block",
@@ -23688,10 +23925,10 @@ var beforeWrite = "beforeWrite";
23688
23925
  var write = "write";
23689
23926
  var afterWrite = "afterWrite";
23690
23927
  var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
23691
- function getNodeName(element) {
23928
+ function getNodeName$1(element) {
23692
23929
  return element ? (element.nodeName || "").toLowerCase() : null;
23693
23930
  }
23694
- function getWindow(node) {
23931
+ function getWindow$1(node) {
23695
23932
  if (node == null) {
23696
23933
  return window;
23697
23934
  }
@@ -23701,19 +23938,19 @@ function getWindow(node) {
23701
23938
  }
23702
23939
  return node;
23703
23940
  }
23704
- function isElement$1(node) {
23705
- var OwnElement = getWindow(node).Element;
23941
+ function isElement$2(node) {
23942
+ var OwnElement = getWindow$1(node).Element;
23706
23943
  return node instanceof OwnElement || node instanceof Element;
23707
23944
  }
23708
- function isHTMLElement(node) {
23709
- var OwnElement = getWindow(node).HTMLElement;
23945
+ function isHTMLElement$1(node) {
23946
+ var OwnElement = getWindow$1(node).HTMLElement;
23710
23947
  return node instanceof OwnElement || node instanceof HTMLElement;
23711
23948
  }
23712
- function isShadowRoot(node) {
23949
+ function isShadowRoot$1(node) {
23713
23950
  if (typeof ShadowRoot === "undefined") {
23714
23951
  return false;
23715
23952
  }
23716
- var OwnElement = getWindow(node).ShadowRoot;
23953
+ var OwnElement = getWindow$1(node).ShadowRoot;
23717
23954
  return node instanceof OwnElement || node instanceof ShadowRoot;
23718
23955
  }
23719
23956
  function applyStyles(_ref) {
@@ -23722,7 +23959,7 @@ function applyStyles(_ref) {
23722
23959
  var style = state.styles[name] || {};
23723
23960
  var attributes = state.attributes[name] || {};
23724
23961
  var element = state.elements[name];
23725
- if (!isHTMLElement(element) || !getNodeName(element)) {
23962
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
23726
23963
  return;
23727
23964
  }
23728
23965
  Object.assign(element.style, style);
@@ -23764,7 +24001,7 @@ function effect$2(_ref2) {
23764
24001
  style2[property] = "";
23765
24002
  return style2;
23766
24003
  }, {});
23767
- if (!isHTMLElement(element) || !getNodeName(element)) {
24004
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
23768
24005
  return;
23769
24006
  }
23770
24007
  Object.assign(element.style, style);
@@ -23785,9 +24022,9 @@ const applyStyles$1 = {
23785
24022
  function getBasePlacement$1(placement) {
23786
24023
  return placement.split("-")[0];
23787
24024
  }
23788
- var max = Math.max;
23789
- var min = Math.min;
23790
- var round = Math.round;
24025
+ var max$1 = Math.max;
24026
+ var min$1 = Math.min;
24027
+ var round$1 = Math.round;
23791
24028
  function getUAString() {
23792
24029
  var uaData = navigator.userAgentData;
23793
24030
  if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
@@ -23800,7 +24037,7 @@ function getUAString() {
23800
24037
  function isLayoutViewport() {
23801
24038
  return !/^((?!chrome|android).)*safari/i.test(getUAString());
23802
24039
  }
23803
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
24040
+ function getBoundingClientRect$1(element, includeScale, isFixedStrategy) {
23804
24041
  if (includeScale === void 0) {
23805
24042
  includeScale = false;
23806
24043
  }
@@ -23810,11 +24047,11 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
23810
24047
  var clientRect2 = element.getBoundingClientRect();
23811
24048
  var scaleX = 1;
23812
24049
  var scaleY = 1;
23813
- if (includeScale && isHTMLElement(element)) {
23814
- scaleX = element.offsetWidth > 0 ? round(clientRect2.width) / element.offsetWidth || 1 : 1;
23815
- scaleY = element.offsetHeight > 0 ? round(clientRect2.height) / element.offsetHeight || 1 : 1;
24050
+ if (includeScale && isHTMLElement$1(element)) {
24051
+ scaleX = element.offsetWidth > 0 ? round$1(clientRect2.width) / element.offsetWidth || 1 : 1;
24052
+ scaleY = element.offsetHeight > 0 ? round$1(clientRect2.height) / element.offsetHeight || 1 : 1;
23816
24053
  }
23817
- var _ref = isElement$1(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
24054
+ var _ref = isElement$2(element) ? getWindow$1(element) : window, visualViewport = _ref.visualViewport;
23818
24055
  var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
23819
24056
  var x = (clientRect2.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
23820
24057
  var y = (clientRect2.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
@@ -23832,7 +24069,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
23832
24069
  };
23833
24070
  }
23834
24071
  function getLayoutRect(element) {
23835
- var clientRect2 = getBoundingClientRect(element);
24072
+ var clientRect2 = getBoundingClientRect$1(element);
23836
24073
  var width = element.offsetWidth;
23837
24074
  var height = element.offsetHeight;
23838
24075
  if (Math.abs(clientRect2.width - width) <= 1) {
@@ -23852,7 +24089,7 @@ function contains(parent, child) {
23852
24089
  var rootNode = child.getRootNode && child.getRootNode();
23853
24090
  if (parent.contains(child)) {
23854
24091
  return true;
23855
- } else if (rootNode && isShadowRoot(rootNode)) {
24092
+ } else if (rootNode && isShadowRoot$1(rootNode)) {
23856
24093
  var next = child;
23857
24094
  do {
23858
24095
  if (next && parent.isSameNode(next)) {
@@ -23863,20 +24100,20 @@ function contains(parent, child) {
23863
24100
  }
23864
24101
  return false;
23865
24102
  }
23866
- function getComputedStyle$1(element) {
23867
- return getWindow(element).getComputedStyle(element);
24103
+ function getComputedStyle$2(element) {
24104
+ return getWindow$1(element).getComputedStyle(element);
23868
24105
  }
23869
- function isTableElement(element) {
23870
- return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
24106
+ function isTableElement$1(element) {
24107
+ return ["table", "td", "th"].indexOf(getNodeName$1(element)) >= 0;
23871
24108
  }
23872
- function getDocumentElement(element) {
23873
- return ((isElement$1(element) ? element.ownerDocument : (
24109
+ function getDocumentElement$1(element) {
24110
+ return ((isElement$2(element) ? element.ownerDocument : (
23874
24111
  // $FlowFixMe[prop-missing]
23875
24112
  element.document
23876
24113
  )) || window.document).documentElement;
23877
24114
  }
23878
- function getParentNode(element) {
23879
- if (getNodeName(element) === "html") {
24115
+ function getParentNode$1(element) {
24116
+ if (getNodeName$1(element) === "html") {
23880
24117
  return element;
23881
24118
  }
23882
24119
  return (
@@ -23885,33 +24122,33 @@ function getParentNode(element) {
23885
24122
  // $FlowFixMe[prop-missing]
23886
24123
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
23887
24124
  element.parentNode || // DOM Element detected
23888
- (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
24125
+ (isShadowRoot$1(element) ? element.host : null) || // ShadowRoot detected
23889
24126
  // $FlowFixMe[incompatible-call]: HTMLElement is a Node
23890
- getDocumentElement(element)
24127
+ getDocumentElement$1(element)
23891
24128
  );
23892
24129
  }
23893
- function getTrueOffsetParent(element) {
23894
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
23895
- getComputedStyle$1(element).position === "fixed") {
24130
+ function getTrueOffsetParent$1(element) {
24131
+ if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
24132
+ getComputedStyle$2(element).position === "fixed") {
23896
24133
  return null;
23897
24134
  }
23898
24135
  return element.offsetParent;
23899
24136
  }
23900
- function getContainingBlock(element) {
24137
+ function getContainingBlock$1(element) {
23901
24138
  var isFirefox = /firefox/i.test(getUAString());
23902
24139
  var isIE = /Trident/i.test(getUAString());
23903
- if (isIE && isHTMLElement(element)) {
23904
- var elementCss = getComputedStyle$1(element);
24140
+ if (isIE && isHTMLElement$1(element)) {
24141
+ var elementCss = getComputedStyle$2(element);
23905
24142
  if (elementCss.position === "fixed") {
23906
24143
  return null;
23907
24144
  }
23908
24145
  }
23909
- var currentNode = getParentNode(element);
23910
- if (isShadowRoot(currentNode)) {
24146
+ var currentNode = getParentNode$1(element);
24147
+ if (isShadowRoot$1(currentNode)) {
23911
24148
  currentNode = currentNode.host;
23912
24149
  }
23913
- while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
23914
- var css = getComputedStyle$1(currentNode);
24150
+ while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName$1(currentNode)) < 0) {
24151
+ var css = getComputedStyle$2(currentNode);
23915
24152
  if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
23916
24153
  return currentNode;
23917
24154
  } else {
@@ -23920,22 +24157,22 @@ function getContainingBlock(element) {
23920
24157
  }
23921
24158
  return null;
23922
24159
  }
23923
- function getOffsetParent(element) {
23924
- var window2 = getWindow(element);
23925
- var offsetParent = getTrueOffsetParent(element);
23926
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
23927
- offsetParent = getTrueOffsetParent(offsetParent);
24160
+ function getOffsetParent$1(element) {
24161
+ var window2 = getWindow$1(element);
24162
+ var offsetParent = getTrueOffsetParent$1(element);
24163
+ while (offsetParent && isTableElement$1(offsetParent) && getComputedStyle$2(offsetParent).position === "static") {
24164
+ offsetParent = getTrueOffsetParent$1(offsetParent);
23928
24165
  }
23929
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
24166
+ if (offsetParent && (getNodeName$1(offsetParent) === "html" || getNodeName$1(offsetParent) === "body" && getComputedStyle$2(offsetParent).position === "static")) {
23930
24167
  return window2;
23931
24168
  }
23932
- return offsetParent || getContainingBlock(element) || window2;
24169
+ return offsetParent || getContainingBlock$1(element) || window2;
23933
24170
  }
23934
24171
  function getMainAxisFromPlacement(placement) {
23935
24172
  return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
23936
24173
  }
23937
- function within(min$12, value, max$12) {
23938
- return max(min$12, min(value, max$12));
24174
+ function within(min2, value, max2) {
24175
+ return max$1(min2, min$1(value, max2));
23939
24176
  }
23940
24177
  function withinMaxClamp(min2, value, max2) {
23941
24178
  var v = within(min2, value, max2);
@@ -23982,7 +24219,7 @@ function arrow(_ref) {
23982
24219
  var maxProp = axis === "y" ? bottom : right;
23983
24220
  var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
23984
24221
  var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
23985
- var arrowOffsetParent = getOffsetParent(arrowElement);
24222
+ var arrowOffsetParent = getOffsetParent$1(arrowElement);
23986
24223
  var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
23987
24224
  var centerToReference = endDiff / 2 - startDiff / 2;
23988
24225
  var min2 = paddingObject[minProp];
@@ -24031,8 +24268,8 @@ function roundOffsetsByDPR(_ref, win) {
24031
24268
  var x = _ref.x, y = _ref.y;
24032
24269
  var dpr = win.devicePixelRatio || 1;
24033
24270
  return {
24034
- x: round(x * dpr) / dpr || 0,
24035
- y: round(y * dpr) / dpr || 0
24271
+ x: round$1(x * dpr) / dpr || 0,
24272
+ y: round$1(y * dpr) / dpr || 0
24036
24273
  };
24037
24274
  }
24038
24275
  function mapToStyles(_ref2) {
@@ -24054,12 +24291,12 @@ function mapToStyles(_ref2) {
24054
24291
  var sideY = top;
24055
24292
  var win = window;
24056
24293
  if (adaptive) {
24057
- var offsetParent = getOffsetParent(popper2);
24294
+ var offsetParent = getOffsetParent$1(popper2);
24058
24295
  var heightProp = "clientHeight";
24059
24296
  var widthProp = "clientWidth";
24060
- if (offsetParent === getWindow(popper2)) {
24061
- offsetParent = getDocumentElement(popper2);
24062
- if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
24297
+ if (offsetParent === getWindow$1(popper2)) {
24298
+ offsetParent = getDocumentElement$1(popper2);
24299
+ if (getComputedStyle$2(offsetParent).position !== "static" && position === "absolute") {
24063
24300
  heightProp = "scrollHeight";
24064
24301
  widthProp = "scrollWidth";
24065
24302
  }
@@ -24090,7 +24327,7 @@ function mapToStyles(_ref2) {
24090
24327
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
24091
24328
  x,
24092
24329
  y
24093
- }, getWindow(popper2)) : {
24330
+ }, getWindow$1(popper2)) : {
24094
24331
  x,
24095
24332
  y
24096
24333
  };
@@ -24146,7 +24383,7 @@ var passive = {
24146
24383
  function effect(_ref) {
24147
24384
  var state = _ref.state, instance = _ref.instance, options = _ref.options;
24148
24385
  var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
24149
- var window2 = getWindow(state.elements.popper);
24386
+ var window2 = getWindow$1(state.elements.popper);
24150
24387
  var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
24151
24388
  if (scroll) {
24152
24389
  scrollParents.forEach(function(scrollParent) {
@@ -24197,7 +24434,7 @@ function getOppositeVariationPlacement(placement) {
24197
24434
  });
24198
24435
  }
24199
24436
  function getWindowScroll(node) {
24200
- var win = getWindow(node);
24437
+ var win = getWindow$1(node);
24201
24438
  var scrollLeft = win.pageXOffset;
24202
24439
  var scrollTop = win.pageYOffset;
24203
24440
  return {
@@ -24205,12 +24442,12 @@ function getWindowScroll(node) {
24205
24442
  scrollTop
24206
24443
  };
24207
24444
  }
24208
- function getWindowScrollBarX(element) {
24209
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
24445
+ function getWindowScrollBarX$1(element) {
24446
+ return getBoundingClientRect$1(getDocumentElement$1(element)).left + getWindowScroll(element).scrollLeft;
24210
24447
  }
24211
- function getViewportRect(element, strategy) {
24212
- var win = getWindow(element);
24213
- var html = getDocumentElement(element);
24448
+ function getViewportRect$1(element, strategy) {
24449
+ var win = getWindow$1(element);
24450
+ var html = getDocumentElement$1(element);
24214
24451
  var visualViewport = win.visualViewport;
24215
24452
  var width = html.clientWidth;
24216
24453
  var height = html.clientHeight;
@@ -24228,21 +24465,21 @@ function getViewportRect(element, strategy) {
24228
24465
  return {
24229
24466
  width,
24230
24467
  height,
24231
- x: x + getWindowScrollBarX(element),
24468
+ x: x + getWindowScrollBarX$1(element),
24232
24469
  y
24233
24470
  };
24234
24471
  }
24235
- function getDocumentRect(element) {
24472
+ function getDocumentRect$1(element) {
24236
24473
  var _element$ownerDocumen;
24237
- var html = getDocumentElement(element);
24474
+ var html = getDocumentElement$1(element);
24238
24475
  var winScroll = getWindowScroll(element);
24239
24476
  var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
24240
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
24241
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
24242
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
24477
+ var width = max$1(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
24478
+ var height = max$1(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
24479
+ var x = -winScroll.scrollLeft + getWindowScrollBarX$1(element);
24243
24480
  var y = -winScroll.scrollTop;
24244
- if (getComputedStyle$1(body || html).direction === "rtl") {
24245
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
24481
+ if (getComputedStyle$2(body || html).direction === "rtl") {
24482
+ x += max$1(html.clientWidth, body ? body.clientWidth : 0) - width;
24246
24483
  }
24247
24484
  return {
24248
24485
  width,
@@ -24252,17 +24489,17 @@ function getDocumentRect(element) {
24252
24489
  };
24253
24490
  }
24254
24491
  function isScrollParent(element) {
24255
- var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
24492
+ var _getComputedStyle = getComputedStyle$2(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
24256
24493
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
24257
24494
  }
24258
24495
  function getScrollParent(node) {
24259
- if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
24496
+ if (["html", "body", "#document"].indexOf(getNodeName$1(node)) >= 0) {
24260
24497
  return node.ownerDocument.body;
24261
24498
  }
24262
- if (isHTMLElement(node) && isScrollParent(node)) {
24499
+ if (isHTMLElement$1(node) && isScrollParent(node)) {
24263
24500
  return node;
24264
24501
  }
24265
- return getScrollParent(getParentNode(node));
24502
+ return getScrollParent(getParentNode$1(node));
24266
24503
  }
24267
24504
  function listScrollParents(element, list) {
24268
24505
  var _element$ownerDocumen;
@@ -24271,15 +24508,15 @@ function listScrollParents(element, list) {
24271
24508
  }
24272
24509
  var scrollParent = getScrollParent(element);
24273
24510
  var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
24274
- var win = getWindow(scrollParent);
24511
+ var win = getWindow$1(scrollParent);
24275
24512
  var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
24276
24513
  var updatedList = list.concat(target);
24277
24514
  return isBody ? updatedList : (
24278
24515
  // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
24279
- updatedList.concat(listScrollParents(getParentNode(target)))
24516
+ updatedList.concat(listScrollParents(getParentNode$1(target)))
24280
24517
  );
24281
24518
  }
24282
- function rectToClientRect(rect) {
24519
+ function rectToClientRect$1(rect) {
24283
24520
  return Object.assign({}, rect, {
24284
24521
  left: rect.x,
24285
24522
  top: rect.y,
@@ -24287,8 +24524,8 @@ function rectToClientRect(rect) {
24287
24524
  bottom: rect.y + rect.height
24288
24525
  });
24289
24526
  }
24290
- function getInnerBoundingClientRect(element, strategy) {
24291
- var rect = getBoundingClientRect(element, false, strategy === "fixed");
24527
+ function getInnerBoundingClientRect$1(element, strategy) {
24528
+ var rect = getBoundingClientRect$1(element, false, strategy === "fixed");
24292
24529
  rect.top = rect.top + element.clientTop;
24293
24530
  rect.left = rect.left + element.clientLeft;
24294
24531
  rect.bottom = rect.top + element.clientHeight;
@@ -24300,29 +24537,29 @@ function getInnerBoundingClientRect(element, strategy) {
24300
24537
  return rect;
24301
24538
  }
24302
24539
  function getClientRectFromMixedType(element, clippingParent, strategy) {
24303
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
24540
+ return clippingParent === viewport ? rectToClientRect$1(getViewportRect$1(element, strategy)) : isElement$2(clippingParent) ? getInnerBoundingClientRect$1(clippingParent, strategy) : rectToClientRect$1(getDocumentRect$1(getDocumentElement$1(element)));
24304
24541
  }
24305
24542
  function getClippingParents(element) {
24306
- var clippingParents2 = listScrollParents(getParentNode(element));
24307
- var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
24308
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
24309
- if (!isElement$1(clipperElement)) {
24543
+ var clippingParents2 = listScrollParents(getParentNode$1(element));
24544
+ var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$2(element).position) >= 0;
24545
+ var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent$1(element) : element;
24546
+ if (!isElement$2(clipperElement)) {
24310
24547
  return [];
24311
24548
  }
24312
24549
  return clippingParents2.filter(function(clippingParent) {
24313
- return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
24550
+ return isElement$2(clippingParent) && contains(clippingParent, clipperElement) && getNodeName$1(clippingParent) !== "body";
24314
24551
  });
24315
24552
  }
24316
- function getClippingRect(element, boundary, rootBoundary, strategy) {
24553
+ function getClippingRect$1(element, boundary, rootBoundary, strategy) {
24317
24554
  var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
24318
24555
  var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
24319
24556
  var firstClippingParent = clippingParents2[0];
24320
24557
  var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
24321
24558
  var rect = getClientRectFromMixedType(element, clippingParent, strategy);
24322
- accRect.top = max(rect.top, accRect.top);
24323
- accRect.right = min(rect.right, accRect.right);
24324
- accRect.bottom = min(rect.bottom, accRect.bottom);
24325
- accRect.left = max(rect.left, accRect.left);
24559
+ accRect.top = max$1(rect.top, accRect.top);
24560
+ accRect.right = min$1(rect.right, accRect.right);
24561
+ accRect.bottom = min$1(rect.bottom, accRect.bottom);
24562
+ accRect.left = max$1(rect.left, accRect.left);
24326
24563
  return accRect;
24327
24564
  }, getClientRectFromMixedType(element, firstClippingParent, strategy));
24328
24565
  clippingRect.width = clippingRect.right - clippingRect.left;
@@ -24383,7 +24620,7 @@ function computeOffsets(_ref) {
24383
24620
  }
24384
24621
  return offsets;
24385
24622
  }
24386
- function detectOverflow(state, options) {
24623
+ function detectOverflow$1(state, options) {
24387
24624
  if (options === void 0) {
24388
24625
  options = {};
24389
24626
  }
@@ -24392,14 +24629,14 @@ function detectOverflow(state, options) {
24392
24629
  var altContext = elementContext === popper ? reference : popper;
24393
24630
  var popperRect = state.rects.popper;
24394
24631
  var element = state.elements[altBoundary ? altContext : elementContext];
24395
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
24396
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
24632
+ var clippingClientRect = getClippingRect$1(isElement$2(element) ? element : element.contextElement || getDocumentElement$1(state.elements.popper), boundary, rootBoundary, strategy);
24633
+ var referenceClientRect = getBoundingClientRect$1(state.elements.reference);
24397
24634
  var popperOffsets2 = computeOffsets({
24398
24635
  reference: referenceClientRect,
24399
24636
  element: popperRect,
24400
24637
  placement
24401
24638
  });
24402
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
24639
+ var popperClientRect = rectToClientRect$1(Object.assign({}, popperRect, popperOffsets2));
24403
24640
  var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
24404
24641
  var overflowOffsets = {
24405
24642
  top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
@@ -24434,7 +24671,7 @@ function computeAutoPlacement(state, options) {
24434
24671
  allowedPlacements = placements$1;
24435
24672
  }
24436
24673
  var overflows = allowedPlacements.reduce(function(acc, placement2) {
24437
- acc[placement2] = detectOverflow(state, {
24674
+ acc[placement2] = detectOverflow$1(state, {
24438
24675
  placement: placement2,
24439
24676
  boundary,
24440
24677
  rootBoundary,
@@ -24484,7 +24721,7 @@ function flip(_ref) {
24484
24721
  var isStartVariation = getVariation(placement) === start;
24485
24722
  var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
24486
24723
  var len = isVertical ? "width" : "height";
24487
- var overflow = detectOverflow(state, {
24724
+ var overflow = detectOverflow$1(state, {
24488
24725
  placement,
24489
24726
  boundary,
24490
24727
  rootBoundary,
@@ -24549,7 +24786,7 @@ const flip$1 = {
24549
24786
  _skip: false
24550
24787
  }
24551
24788
  };
24552
- function getSideOffsets(overflow, rect, preventedOffsets) {
24789
+ function getSideOffsets$1(overflow, rect, preventedOffsets) {
24553
24790
  if (preventedOffsets === void 0) {
24554
24791
  preventedOffsets = {
24555
24792
  x: 0,
@@ -24563,26 +24800,26 @@ function getSideOffsets(overflow, rect, preventedOffsets) {
24563
24800
  left: overflow.left - rect.width - preventedOffsets.x
24564
24801
  };
24565
24802
  }
24566
- function isAnySideFullyClipped(overflow) {
24803
+ function isAnySideFullyClipped$1(overflow) {
24567
24804
  return [top, right, bottom, left].some(function(side) {
24568
24805
  return overflow[side] >= 0;
24569
24806
  });
24570
24807
  }
24571
- function hide(_ref) {
24808
+ function hide$2(_ref) {
24572
24809
  var state = _ref.state, name = _ref.name;
24573
24810
  var referenceRect = state.rects.reference;
24574
24811
  var popperRect = state.rects.popper;
24575
24812
  var preventedOffsets = state.modifiersData.preventOverflow;
24576
- var referenceOverflow = detectOverflow(state, {
24813
+ var referenceOverflow = detectOverflow$1(state, {
24577
24814
  elementContext: "reference"
24578
24815
  });
24579
- var popperAltOverflow = detectOverflow(state, {
24816
+ var popperAltOverflow = detectOverflow$1(state, {
24580
24817
  altBoundary: true
24581
24818
  });
24582
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
24583
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
24584
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
24585
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
24819
+ var referenceClippingOffsets = getSideOffsets$1(referenceOverflow, referenceRect);
24820
+ var popperEscapeOffsets = getSideOffsets$1(popperAltOverflow, popperRect, preventedOffsets);
24821
+ var isReferenceHidden = isAnySideFullyClipped$1(referenceClippingOffsets);
24822
+ var hasPopperEscaped = isAnySideFullyClipped$1(popperEscapeOffsets);
24586
24823
  state.modifiersData[name] = {
24587
24824
  referenceClippingOffsets,
24588
24825
  popperEscapeOffsets,
@@ -24594,12 +24831,12 @@ function hide(_ref) {
24594
24831
  "data-popper-escaped": hasPopperEscaped
24595
24832
  });
24596
24833
  }
24597
- const hide$1 = {
24834
+ const hide$3 = {
24598
24835
  name: "hide",
24599
24836
  enabled: true,
24600
24837
  phase: "main",
24601
24838
  requiresIfExists: ["preventOverflow"],
24602
- fn: hide
24839
+ fn: hide$2
24603
24840
  };
24604
24841
  function distanceAndSkiddingToXY(placement, rects, offset2) {
24605
24842
  var basePlacement = getBasePlacement$1(placement);
@@ -24659,7 +24896,7 @@ function getAltAxis(axis) {
24659
24896
  function preventOverflow(_ref) {
24660
24897
  var state = _ref.state, options = _ref.options, name = _ref.name;
24661
24898
  var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
24662
- var overflow = detectOverflow(state, {
24899
+ var overflow = detectOverflow$1(state, {
24663
24900
  boundary,
24664
24901
  rootBoundary,
24665
24902
  padding,
@@ -24697,8 +24934,8 @@ function preventOverflow(_ref) {
24697
24934
  var altSide = mainAxis === "y" ? bottom : right;
24698
24935
  var len = mainAxis === "y" ? "height" : "width";
24699
24936
  var offset2 = popperOffsets2[mainAxis];
24700
- var min$12 = offset2 + overflow[mainSide];
24701
- var max$12 = offset2 - overflow[altSide];
24937
+ var min2 = offset2 + overflow[mainSide];
24938
+ var max2 = offset2 - overflow[altSide];
24702
24939
  var additive = tether ? -popperRect[len] / 2 : 0;
24703
24940
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
24704
24941
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
@@ -24713,12 +24950,12 @@ function preventOverflow(_ref) {
24713
24950
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
24714
24951
  var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
24715
24952
  var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
24716
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
24953
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent$1(state.elements.arrow);
24717
24954
  var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
24718
24955
  var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
24719
24956
  var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
24720
24957
  var tetherMax = offset2 + maxOffset - offsetModifierValue;
24721
- var preventedOffset = within(tether ? min(min$12, tetherMin) : min$12, offset2, tether ? max(max$12, tetherMax) : max$12);
24958
+ var preventedOffset = within(tether ? min$1(min2, tetherMin) : min2, offset2, tether ? max$1(max2, tetherMax) : max2);
24722
24959
  popperOffsets2[mainAxis] = preventedOffset;
24723
24960
  data[mainAxis] = preventedOffset - offset2;
24724
24961
  }
@@ -24753,8 +24990,8 @@ function getHTMLElementScroll(element) {
24753
24990
  scrollTop: element.scrollTop
24754
24991
  };
24755
24992
  }
24756
- function getNodeScroll(node) {
24757
- if (node === getWindow(node) || !isHTMLElement(node)) {
24993
+ function getNodeScroll$1(node) {
24994
+ if (node === getWindow$1(node) || !isHTMLElement$1(node)) {
24758
24995
  return getWindowScroll(node);
24759
24996
  } else {
24760
24997
  return getHTMLElementScroll(node);
@@ -24762,18 +24999,18 @@ function getNodeScroll(node) {
24762
24999
  }
24763
25000
  function isElementScaled(element) {
24764
25001
  var rect = element.getBoundingClientRect();
24765
- var scaleX = round(rect.width) / element.offsetWidth || 1;
24766
- var scaleY = round(rect.height) / element.offsetHeight || 1;
25002
+ var scaleX = round$1(rect.width) / element.offsetWidth || 1;
25003
+ var scaleY = round$1(rect.height) / element.offsetHeight || 1;
24767
25004
  return scaleX !== 1 || scaleY !== 1;
24768
25005
  }
24769
25006
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
24770
25007
  if (isFixed === void 0) {
24771
25008
  isFixed = false;
24772
25009
  }
24773
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
24774
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
24775
- var documentElement = getDocumentElement(offsetParent);
24776
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
25010
+ var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
25011
+ var offsetParentIsScaled = isHTMLElement$1(offsetParent) && isElementScaled(offsetParent);
25012
+ var documentElement = getDocumentElement$1(offsetParent);
25013
+ var rect = getBoundingClientRect$1(elementOrVirtualElement, offsetParentIsScaled, isFixed);
24777
25014
  var scroll = {
24778
25015
  scrollLeft: 0,
24779
25016
  scrollTop: 0
@@ -24783,16 +25020,16 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
24783
25020
  y: 0
24784
25021
  };
24785
25022
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
24786
- if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
25023
+ if (getNodeName$1(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
24787
25024
  isScrollParent(documentElement)) {
24788
- scroll = getNodeScroll(offsetParent);
25025
+ scroll = getNodeScroll$1(offsetParent);
24789
25026
  }
24790
- if (isHTMLElement(offsetParent)) {
24791
- offsets = getBoundingClientRect(offsetParent, true);
25027
+ if (isHTMLElement$1(offsetParent)) {
25028
+ offsets = getBoundingClientRect$1(offsetParent, true);
24792
25029
  offsets.x += offsetParent.clientLeft;
24793
25030
  offsets.y += offsetParent.clientTop;
24794
25031
  } else if (documentElement) {
24795
- offsets.x = getWindowScrollBarX(documentElement);
25032
+ offsets.x = getWindowScrollBarX$1(documentElement);
24796
25033
  }
24797
25034
  }
24798
25035
  return {
@@ -24907,7 +25144,7 @@ function popperGenerator(generatorOptions) {
24907
25144
  cleanupModifierEffects();
24908
25145
  state.options = Object.assign({}, defaultOptions, state.options, options2);
24909
25146
  state.scrollParents = {
24910
- reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
25147
+ reference: isElement$2(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
24911
25148
  popper: listScrollParents(popper2)
24912
25149
  };
24913
25150
  var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
@@ -24931,7 +25168,7 @@ function popperGenerator(generatorOptions) {
24931
25168
  return;
24932
25169
  }
24933
25170
  state.rects = {
24934
- reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
25171
+ reference: getCompositeRect(reference3, getOffsetParent$1(popper3), state.options.strategy === "fixed"),
24935
25172
  popper: getLayoutRect(popper3)
24936
25173
  };
24937
25174
  state.reset = false;
@@ -25002,7 +25239,7 @@ function popperGenerator(generatorOptions) {
25002
25239
  return instance;
25003
25240
  };
25004
25241
  }
25005
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
25242
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$3];
25006
25243
  var createPopper = /* @__PURE__ */ popperGenerator({
25007
25244
  defaultModifiers
25008
25245
  });
@@ -25087,7 +25324,7 @@ function removeUndefinedProps(obj) {
25087
25324
  function div() {
25088
25325
  return document.createElement("div");
25089
25326
  }
25090
- function isElement(value) {
25327
+ function isElement$1(value) {
25091
25328
  return ["Element", "Fragment"].some(function(type) {
25092
25329
  return isType(value, type);
25093
25330
  });
@@ -25102,7 +25339,7 @@ function isReferenceElement(value) {
25102
25339
  return !!(value && value._tippy && value._tippy.reference === value);
25103
25340
  }
25104
25341
  function getArrayOfElements(value) {
25105
- if (isElement(value)) {
25342
+ if (isElement$1(value)) {
25106
25343
  return [value];
25107
25344
  }
25108
25345
  if (isNodeList(value)) {
@@ -25411,7 +25648,7 @@ function createArrowElement(value) {
25411
25648
  arrow2.className = ARROW_CLASS;
25412
25649
  } else {
25413
25650
  arrow2.className = SVG_ARROW_CLASS;
25414
- if (isElement(value)) {
25651
+ if (isElement$1(value)) {
25415
25652
  arrow2.appendChild(value);
25416
25653
  } else {
25417
25654
  dangerouslySetInnerHTML(arrow2, value);
@@ -25420,7 +25657,7 @@ function createArrowElement(value) {
25420
25657
  return arrow2;
25421
25658
  }
25422
25659
  function setContent(content, props) {
25423
- if (isElement(props.content)) {
25660
+ if (isElement$1(props.content)) {
25424
25661
  dangerouslySetInnerHTML(content, "");
25425
25662
  content.appendChild(props.content);
25426
25663
  } else if (typeof props.content !== "function") {
@@ -26243,7 +26480,7 @@ function tippy(targets, optionalProps) {
26243
26480
  });
26244
26481
  var elements = getArrayOfElements(targets);
26245
26482
  if (process$1.env.NODE_ENV !== "production") {
26246
- var isSingleContentElement = isElement(passedProps.content);
26483
+ var isSingleContentElement = isElement$1(passedProps.content);
26247
26484
  var isMoreThanOneReferenceElement = elements.length > 1;
26248
26485
  warnWhen(isSingleContentElement && isMoreThanOneReferenceElement, ["tippy() was passed an Element as the `content` prop, but more than", "one tippy instance was created by this invocation. This means the", "content element will only be appended to the last tippy instance.", "\n\n", "Instead, pass the .innerHTML of the element, or use a function that", "returns a cloned version of the element instead.", "\n\n", "1) content: element.innerHTML\n", "2) content: () => element.cloneNode(true)"].join(" "));
26249
26486
  }
@@ -26254,7 +26491,7 @@ function tippy(targets, optionalProps) {
26254
26491
  }
26255
26492
  return acc;
26256
26493
  }, []);
26257
- return isElement(targets) ? instances[0] : instances;
26494
+ return isElement$1(targets) ? instances[0] : instances;
26258
26495
  }
26259
26496
  tippy.defaultProps = defaultProps;
26260
26497
  tippy.setDefaultProps = setDefaultProps;
@@ -26523,42 +26760,1102 @@ class Popover {
26523
26760
  this.popover.remove();
26524
26761
  }
26525
26762
  }
26526
- const isDebugging = false;
26527
- const Pagination = Extension.create({
26528
- name: "pagination",
26529
- addStorage() {
26530
- return {
26531
- height: 0,
26532
- sectionData: null
26533
- };
26534
- },
26535
- addCommands() {
26536
- return {
26537
- insertPageBreak: () => ({ commands: commands2 }) => {
26538
- return commands2.insertContent({
26539
- type: "hardBreak"
26540
- });
26763
+ const sides = ["top", "right", "bottom", "left"];
26764
+ const min = Math.min;
26765
+ const max = Math.max;
26766
+ const round = Math.round;
26767
+ const floor = Math.floor;
26768
+ const createCoords = (v) => ({
26769
+ x: v,
26770
+ y: v
26771
+ });
26772
+ function evaluate(value, param) {
26773
+ return typeof value === "function" ? value(param) : value;
26774
+ }
26775
+ function getSide(placement) {
26776
+ return placement.split("-")[0];
26777
+ }
26778
+ function getAlignment(placement) {
26779
+ return placement.split("-")[1];
26780
+ }
26781
+ function getOppositeAxis(axis) {
26782
+ return axis === "x" ? "y" : "x";
26783
+ }
26784
+ function getAxisLength(axis) {
26785
+ return axis === "y" ? "height" : "width";
26786
+ }
26787
+ function getSideAxis(placement) {
26788
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
26789
+ }
26790
+ function getAlignmentAxis(placement) {
26791
+ return getOppositeAxis(getSideAxis(placement));
26792
+ }
26793
+ function expandPaddingObject(padding) {
26794
+ return {
26795
+ top: 0,
26796
+ right: 0,
26797
+ bottom: 0,
26798
+ left: 0,
26799
+ ...padding
26800
+ };
26801
+ }
26802
+ function getPaddingObject(padding) {
26803
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
26804
+ top: padding,
26805
+ right: padding,
26806
+ bottom: padding,
26807
+ left: padding
26808
+ };
26809
+ }
26810
+ function rectToClientRect(rect) {
26811
+ const {
26812
+ x,
26813
+ y,
26814
+ width,
26815
+ height
26816
+ } = rect;
26817
+ return {
26818
+ width,
26819
+ height,
26820
+ top: y,
26821
+ left: x,
26822
+ right: x + width,
26823
+ bottom: y + height,
26824
+ x,
26825
+ y
26826
+ };
26827
+ }
26828
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
26829
+ let {
26830
+ reference: reference2,
26831
+ floating
26832
+ } = _ref;
26833
+ const sideAxis = getSideAxis(placement);
26834
+ const alignmentAxis = getAlignmentAxis(placement);
26835
+ const alignLength = getAxisLength(alignmentAxis);
26836
+ const side = getSide(placement);
26837
+ const isVertical = sideAxis === "y";
26838
+ const commonX = reference2.x + reference2.width / 2 - floating.width / 2;
26839
+ const commonY = reference2.y + reference2.height / 2 - floating.height / 2;
26840
+ const commonAlign = reference2[alignLength] / 2 - floating[alignLength] / 2;
26841
+ let coords;
26842
+ switch (side) {
26843
+ case "top":
26844
+ coords = {
26845
+ x: commonX,
26846
+ y: reference2.y - floating.height
26847
+ };
26848
+ break;
26849
+ case "bottom":
26850
+ coords = {
26851
+ x: commonX,
26852
+ y: reference2.y + reference2.height
26853
+ };
26854
+ break;
26855
+ case "right":
26856
+ coords = {
26857
+ x: reference2.x + reference2.width,
26858
+ y: commonY
26859
+ };
26860
+ break;
26861
+ case "left":
26862
+ coords = {
26863
+ x: reference2.x - floating.width,
26864
+ y: commonY
26865
+ };
26866
+ break;
26867
+ default:
26868
+ coords = {
26869
+ x: reference2.x,
26870
+ y: reference2.y
26871
+ };
26872
+ }
26873
+ switch (getAlignment(placement)) {
26874
+ case "start":
26875
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
26876
+ break;
26877
+ case "end":
26878
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
26879
+ break;
26880
+ }
26881
+ return coords;
26882
+ }
26883
+ const computePosition$1 = async (reference2, floating, config) => {
26884
+ const {
26885
+ placement = "bottom",
26886
+ strategy = "absolute",
26887
+ middleware = [],
26888
+ platform: platform2
26889
+ } = config;
26890
+ const validMiddleware = middleware.filter(Boolean);
26891
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
26892
+ let rects = await platform2.getElementRects({
26893
+ reference: reference2,
26894
+ floating,
26895
+ strategy
26896
+ });
26897
+ let {
26898
+ x,
26899
+ y
26900
+ } = computeCoordsFromPlacement(rects, placement, rtl);
26901
+ let statefulPlacement = placement;
26902
+ let middlewareData = {};
26903
+ let resetCount = 0;
26904
+ for (let i = 0; i < validMiddleware.length; i++) {
26905
+ const {
26906
+ name,
26907
+ fn: fn2
26908
+ } = validMiddleware[i];
26909
+ const {
26910
+ x: nextX,
26911
+ y: nextY,
26912
+ data,
26913
+ reset
26914
+ } = await fn2({
26915
+ x,
26916
+ y,
26917
+ initialPlacement: placement,
26918
+ placement: statefulPlacement,
26919
+ strategy,
26920
+ middlewareData,
26921
+ rects,
26922
+ platform: platform2,
26923
+ elements: {
26924
+ reference: reference2,
26925
+ floating
26926
+ }
26927
+ });
26928
+ x = nextX != null ? nextX : x;
26929
+ y = nextY != null ? nextY : y;
26930
+ middlewareData = {
26931
+ ...middlewareData,
26932
+ [name]: {
26933
+ ...middlewareData[name],
26934
+ ...data
26541
26935
  }
26542
26936
  };
26543
- },
26544
- addShortcuts() {
26545
- return {
26546
- "Mod-Enter": () => this.editor.commands.insertPageBreak()
26547
- };
26548
- },
26549
- /**
26550
- * The pagination plugin is responsible for calculating page breaks, and redering them using decorations.
26551
- */
26552
- addPmPlugins() {
26553
- const editor = this.editor;
26554
- let isUpdating = false;
26555
- let shouldUpdate = false;
26556
- let hasInitialized = false;
26557
- let shouldInitialize = false;
26558
- const paginationPlugin = new Plugin({
26559
- key: PaginationPluginKey,
26560
- state: {
26561
- isReadyToInit: false,
26937
+ if (reset && resetCount <= 50) {
26938
+ resetCount++;
26939
+ if (typeof reset === "object") {
26940
+ if (reset.placement) {
26941
+ statefulPlacement = reset.placement;
26942
+ }
26943
+ if (reset.rects) {
26944
+ rects = reset.rects === true ? await platform2.getElementRects({
26945
+ reference: reference2,
26946
+ floating,
26947
+ strategy
26948
+ }) : reset.rects;
26949
+ }
26950
+ ({
26951
+ x,
26952
+ y
26953
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
26954
+ }
26955
+ i = -1;
26956
+ }
26957
+ }
26958
+ return {
26959
+ x,
26960
+ y,
26961
+ placement: statefulPlacement,
26962
+ strategy,
26963
+ middlewareData
26964
+ };
26965
+ };
26966
+ async function detectOverflow(state, options) {
26967
+ var _await$platform$isEle;
26968
+ if (options === void 0) {
26969
+ options = {};
26970
+ }
26971
+ const {
26972
+ x,
26973
+ y,
26974
+ platform: platform2,
26975
+ rects,
26976
+ elements,
26977
+ strategy
26978
+ } = state;
26979
+ const {
26980
+ boundary = "clippingAncestors",
26981
+ rootBoundary = "viewport",
26982
+ elementContext = "floating",
26983
+ altBoundary = false,
26984
+ padding = 0
26985
+ } = evaluate(options, state);
26986
+ const paddingObject = getPaddingObject(padding);
26987
+ const altContext = elementContext === "floating" ? "reference" : "floating";
26988
+ const element = elements[altBoundary ? altContext : elementContext];
26989
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
26990
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
26991
+ boundary,
26992
+ rootBoundary,
26993
+ strategy
26994
+ }));
26995
+ const rect = elementContext === "floating" ? {
26996
+ x,
26997
+ y,
26998
+ width: rects.floating.width,
26999
+ height: rects.floating.height
27000
+ } : rects.reference;
27001
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
27002
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
27003
+ x: 1,
27004
+ y: 1
27005
+ } : {
27006
+ x: 1,
27007
+ y: 1
27008
+ };
27009
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
27010
+ elements,
27011
+ rect,
27012
+ offsetParent,
27013
+ strategy
27014
+ }) : rect);
27015
+ return {
27016
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
27017
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
27018
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
27019
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
27020
+ };
27021
+ }
27022
+ function getSideOffsets(overflow, rect) {
27023
+ return {
27024
+ top: overflow.top - rect.height,
27025
+ right: overflow.right - rect.width,
27026
+ bottom: overflow.bottom - rect.height,
27027
+ left: overflow.left - rect.width
27028
+ };
27029
+ }
27030
+ function isAnySideFullyClipped(overflow) {
27031
+ return sides.some((side) => overflow[side] >= 0);
27032
+ }
27033
+ const hide$1 = function(options) {
27034
+ if (options === void 0) {
27035
+ options = {};
27036
+ }
27037
+ return {
27038
+ name: "hide",
27039
+ options,
27040
+ async fn(state) {
27041
+ const {
27042
+ rects
27043
+ } = state;
27044
+ const {
27045
+ strategy = "referenceHidden",
27046
+ ...detectOverflowOptions
27047
+ } = evaluate(options, state);
27048
+ switch (strategy) {
27049
+ case "referenceHidden": {
27050
+ const overflow = await detectOverflow(state, {
27051
+ ...detectOverflowOptions,
27052
+ elementContext: "reference"
27053
+ });
27054
+ const offsets = getSideOffsets(overflow, rects.reference);
27055
+ return {
27056
+ data: {
27057
+ referenceHiddenOffsets: offsets,
27058
+ referenceHidden: isAnySideFullyClipped(offsets)
27059
+ }
27060
+ };
27061
+ }
27062
+ case "escaped": {
27063
+ const overflow = await detectOverflow(state, {
27064
+ ...detectOverflowOptions,
27065
+ altBoundary: true
27066
+ });
27067
+ const offsets = getSideOffsets(overflow, rects.floating);
27068
+ return {
27069
+ data: {
27070
+ escapedOffsets: offsets,
27071
+ escaped: isAnySideFullyClipped(offsets)
27072
+ }
27073
+ };
27074
+ }
27075
+ default: {
27076
+ return {};
27077
+ }
27078
+ }
27079
+ }
27080
+ };
27081
+ };
27082
+ function hasWindow() {
27083
+ return typeof window !== "undefined";
27084
+ }
27085
+ function getNodeName(node) {
27086
+ if (isNode(node)) {
27087
+ return (node.nodeName || "").toLowerCase();
27088
+ }
27089
+ return "#document";
27090
+ }
27091
+ function getWindow(node) {
27092
+ var _node$ownerDocument;
27093
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
27094
+ }
27095
+ function getDocumentElement(node) {
27096
+ var _ref;
27097
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
27098
+ }
27099
+ function isNode(value) {
27100
+ if (!hasWindow()) {
27101
+ return false;
27102
+ }
27103
+ return value instanceof Node || value instanceof getWindow(value).Node;
27104
+ }
27105
+ function isElement(value) {
27106
+ if (!hasWindow()) {
27107
+ return false;
27108
+ }
27109
+ return value instanceof Element || value instanceof getWindow(value).Element;
27110
+ }
27111
+ function isHTMLElement(value) {
27112
+ if (!hasWindow()) {
27113
+ return false;
27114
+ }
27115
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
27116
+ }
27117
+ function isShadowRoot(value) {
27118
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
27119
+ return false;
27120
+ }
27121
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
27122
+ }
27123
+ function isOverflowElement(element) {
27124
+ const {
27125
+ overflow,
27126
+ overflowX,
27127
+ overflowY,
27128
+ display
27129
+ } = getComputedStyle$1(element);
27130
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
27131
+ }
27132
+ function isTableElement(element) {
27133
+ return ["table", "td", "th"].includes(getNodeName(element));
27134
+ }
27135
+ function isTopLayer(element) {
27136
+ return [":popover-open", ":modal"].some((selector) => {
27137
+ try {
27138
+ return element.matches(selector);
27139
+ } catch (e) {
27140
+ return false;
27141
+ }
27142
+ });
27143
+ }
27144
+ function isContainingBlock(elementOrCss) {
27145
+ const webkit2 = isWebKit();
27146
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
27147
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit2 && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit2 && (css.filter ? css.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
27148
+ }
27149
+ function getContainingBlock(element) {
27150
+ let currentNode = getParentNode(element);
27151
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
27152
+ if (isContainingBlock(currentNode)) {
27153
+ return currentNode;
27154
+ } else if (isTopLayer(currentNode)) {
27155
+ return null;
27156
+ }
27157
+ currentNode = getParentNode(currentNode);
27158
+ }
27159
+ return null;
27160
+ }
27161
+ function isWebKit() {
27162
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
27163
+ return CSS.supports("-webkit-backdrop-filter", "none");
27164
+ }
27165
+ function isLastTraversableNode(node) {
27166
+ return ["html", "body", "#document"].includes(getNodeName(node));
27167
+ }
27168
+ function getComputedStyle$1(element) {
27169
+ return getWindow(element).getComputedStyle(element);
27170
+ }
27171
+ function getNodeScroll(element) {
27172
+ if (isElement(element)) {
27173
+ return {
27174
+ scrollLeft: element.scrollLeft,
27175
+ scrollTop: element.scrollTop
27176
+ };
27177
+ }
27178
+ return {
27179
+ scrollLeft: element.scrollX,
27180
+ scrollTop: element.scrollY
27181
+ };
27182
+ }
27183
+ function getParentNode(node) {
27184
+ if (getNodeName(node) === "html") {
27185
+ return node;
27186
+ }
27187
+ const result = (
27188
+ // Step into the shadow DOM of the parent of a slotted node.
27189
+ node.assignedSlot || // DOM Element detected.
27190
+ node.parentNode || // ShadowRoot detected.
27191
+ isShadowRoot(node) && node.host || // Fallback.
27192
+ getDocumentElement(node)
27193
+ );
27194
+ return isShadowRoot(result) ? result.host : result;
27195
+ }
27196
+ function getNearestOverflowAncestor(node) {
27197
+ const parentNode2 = getParentNode(node);
27198
+ if (isLastTraversableNode(parentNode2)) {
27199
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
27200
+ }
27201
+ if (isHTMLElement(parentNode2) && isOverflowElement(parentNode2)) {
27202
+ return parentNode2;
27203
+ }
27204
+ return getNearestOverflowAncestor(parentNode2);
27205
+ }
27206
+ function getOverflowAncestors(node, list, traverseIframes) {
27207
+ var _node$ownerDocument2;
27208
+ if (list === void 0) {
27209
+ list = [];
27210
+ }
27211
+ if (traverseIframes === void 0) {
27212
+ traverseIframes = true;
27213
+ }
27214
+ const scrollableAncestor = getNearestOverflowAncestor(node);
27215
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
27216
+ const win = getWindow(scrollableAncestor);
27217
+ if (isBody) {
27218
+ const frameElement = getFrameElement(win);
27219
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
27220
+ }
27221
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
27222
+ }
27223
+ function getFrameElement(win) {
27224
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
27225
+ }
27226
+ function getCssDimensions(element) {
27227
+ const css = getComputedStyle$1(element);
27228
+ let width = parseFloat(css.width) || 0;
27229
+ let height = parseFloat(css.height) || 0;
27230
+ const hasOffset = isHTMLElement(element);
27231
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
27232
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
27233
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
27234
+ if (shouldFallback) {
27235
+ width = offsetWidth;
27236
+ height = offsetHeight;
27237
+ }
27238
+ return {
27239
+ width,
27240
+ height,
27241
+ $: shouldFallback
27242
+ };
27243
+ }
27244
+ function unwrapElement(element) {
27245
+ return !isElement(element) ? element.contextElement : element;
27246
+ }
27247
+ function getScale(element) {
27248
+ const domElement = unwrapElement(element);
27249
+ if (!isHTMLElement(domElement)) {
27250
+ return createCoords(1);
27251
+ }
27252
+ const rect = domElement.getBoundingClientRect();
27253
+ const {
27254
+ width,
27255
+ height,
27256
+ $
27257
+ } = getCssDimensions(domElement);
27258
+ let x = ($ ? round(rect.width) : rect.width) / width;
27259
+ let y = ($ ? round(rect.height) : rect.height) / height;
27260
+ if (!x || !Number.isFinite(x)) {
27261
+ x = 1;
27262
+ }
27263
+ if (!y || !Number.isFinite(y)) {
27264
+ y = 1;
27265
+ }
27266
+ return {
27267
+ x,
27268
+ y
27269
+ };
27270
+ }
27271
+ const noOffsets = /* @__PURE__ */ createCoords(0);
27272
+ function getVisualOffsets(element) {
27273
+ const win = getWindow(element);
27274
+ if (!isWebKit() || !win.visualViewport) {
27275
+ return noOffsets;
27276
+ }
27277
+ return {
27278
+ x: win.visualViewport.offsetLeft,
27279
+ y: win.visualViewport.offsetTop
27280
+ };
27281
+ }
27282
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
27283
+ if (isFixed === void 0) {
27284
+ isFixed = false;
27285
+ }
27286
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
27287
+ return false;
27288
+ }
27289
+ return isFixed;
27290
+ }
27291
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
27292
+ if (includeScale === void 0) {
27293
+ includeScale = false;
27294
+ }
27295
+ if (isFixedStrategy === void 0) {
27296
+ isFixedStrategy = false;
27297
+ }
27298
+ const clientRect2 = element.getBoundingClientRect();
27299
+ const domElement = unwrapElement(element);
27300
+ let scale = createCoords(1);
27301
+ if (includeScale) {
27302
+ if (offsetParent) {
27303
+ if (isElement(offsetParent)) {
27304
+ scale = getScale(offsetParent);
27305
+ }
27306
+ } else {
27307
+ scale = getScale(element);
27308
+ }
27309
+ }
27310
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
27311
+ let x = (clientRect2.left + visualOffsets.x) / scale.x;
27312
+ let y = (clientRect2.top + visualOffsets.y) / scale.y;
27313
+ let width = clientRect2.width / scale.x;
27314
+ let height = clientRect2.height / scale.y;
27315
+ if (domElement) {
27316
+ const win = getWindow(domElement);
27317
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
27318
+ let currentWin = win;
27319
+ let currentIFrame = getFrameElement(currentWin);
27320
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
27321
+ const iframeScale = getScale(currentIFrame);
27322
+ const iframeRect = currentIFrame.getBoundingClientRect();
27323
+ const css = getComputedStyle$1(currentIFrame);
27324
+ const left2 = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
27325
+ const top2 = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
27326
+ x *= iframeScale.x;
27327
+ y *= iframeScale.y;
27328
+ width *= iframeScale.x;
27329
+ height *= iframeScale.y;
27330
+ x += left2;
27331
+ y += top2;
27332
+ currentWin = getWindow(currentIFrame);
27333
+ currentIFrame = getFrameElement(currentWin);
27334
+ }
27335
+ }
27336
+ return rectToClientRect({
27337
+ width,
27338
+ height,
27339
+ x,
27340
+ y
27341
+ });
27342
+ }
27343
+ function getWindowScrollBarX(element, rect) {
27344
+ const leftScroll = getNodeScroll(element).scrollLeft;
27345
+ if (!rect) {
27346
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
27347
+ }
27348
+ return rect.left + leftScroll;
27349
+ }
27350
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
27351
+ if (ignoreScrollbarX === void 0) {
27352
+ ignoreScrollbarX = false;
27353
+ }
27354
+ const htmlRect = documentElement.getBoundingClientRect();
27355
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
27356
+ // RTL <body> scrollbar.
27357
+ getWindowScrollBarX(documentElement, htmlRect)
27358
+ ));
27359
+ const y = htmlRect.top + scroll.scrollTop;
27360
+ return {
27361
+ x,
27362
+ y
27363
+ };
27364
+ }
27365
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
27366
+ let {
27367
+ elements,
27368
+ rect,
27369
+ offsetParent,
27370
+ strategy
27371
+ } = _ref;
27372
+ const isFixed = strategy === "fixed";
27373
+ const documentElement = getDocumentElement(offsetParent);
27374
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
27375
+ if (offsetParent === documentElement || topLayer && isFixed) {
27376
+ return rect;
27377
+ }
27378
+ let scroll = {
27379
+ scrollLeft: 0,
27380
+ scrollTop: 0
27381
+ };
27382
+ let scale = createCoords(1);
27383
+ const offsets = createCoords(0);
27384
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
27385
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
27386
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
27387
+ scroll = getNodeScroll(offsetParent);
27388
+ }
27389
+ if (isHTMLElement(offsetParent)) {
27390
+ const offsetRect = getBoundingClientRect(offsetParent);
27391
+ scale = getScale(offsetParent);
27392
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
27393
+ offsets.y = offsetRect.y + offsetParent.clientTop;
27394
+ }
27395
+ }
27396
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
27397
+ return {
27398
+ width: rect.width * scale.x,
27399
+ height: rect.height * scale.y,
27400
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
27401
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
27402
+ };
27403
+ }
27404
+ function getClientRects(element) {
27405
+ return Array.from(element.getClientRects());
27406
+ }
27407
+ function getDocumentRect(element) {
27408
+ const html = getDocumentElement(element);
27409
+ const scroll = getNodeScroll(element);
27410
+ const body = element.ownerDocument.body;
27411
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
27412
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
27413
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
27414
+ const y = -scroll.scrollTop;
27415
+ if (getComputedStyle$1(body).direction === "rtl") {
27416
+ x += max(html.clientWidth, body.clientWidth) - width;
27417
+ }
27418
+ return {
27419
+ width,
27420
+ height,
27421
+ x,
27422
+ y
27423
+ };
27424
+ }
27425
+ function getViewportRect(element, strategy) {
27426
+ const win = getWindow(element);
27427
+ const html = getDocumentElement(element);
27428
+ const visualViewport = win.visualViewport;
27429
+ let width = html.clientWidth;
27430
+ let height = html.clientHeight;
27431
+ let x = 0;
27432
+ let y = 0;
27433
+ if (visualViewport) {
27434
+ width = visualViewport.width;
27435
+ height = visualViewport.height;
27436
+ const visualViewportBased = isWebKit();
27437
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
27438
+ x = visualViewport.offsetLeft;
27439
+ y = visualViewport.offsetTop;
27440
+ }
27441
+ }
27442
+ return {
27443
+ width,
27444
+ height,
27445
+ x,
27446
+ y
27447
+ };
27448
+ }
27449
+ function getInnerBoundingClientRect(element, strategy) {
27450
+ const clientRect2 = getBoundingClientRect(element, true, strategy === "fixed");
27451
+ const top2 = clientRect2.top + element.clientTop;
27452
+ const left2 = clientRect2.left + element.clientLeft;
27453
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
27454
+ const width = element.clientWidth * scale.x;
27455
+ const height = element.clientHeight * scale.y;
27456
+ const x = left2 * scale.x;
27457
+ const y = top2 * scale.y;
27458
+ return {
27459
+ width,
27460
+ height,
27461
+ x,
27462
+ y
27463
+ };
27464
+ }
27465
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
27466
+ let rect;
27467
+ if (clippingAncestor === "viewport") {
27468
+ rect = getViewportRect(element, strategy);
27469
+ } else if (clippingAncestor === "document") {
27470
+ rect = getDocumentRect(getDocumentElement(element));
27471
+ } else if (isElement(clippingAncestor)) {
27472
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
27473
+ } else {
27474
+ const visualOffsets = getVisualOffsets(element);
27475
+ rect = {
27476
+ x: clippingAncestor.x - visualOffsets.x,
27477
+ y: clippingAncestor.y - visualOffsets.y,
27478
+ width: clippingAncestor.width,
27479
+ height: clippingAncestor.height
27480
+ };
27481
+ }
27482
+ return rectToClientRect(rect);
27483
+ }
27484
+ function hasFixedPositionAncestor(element, stopNode) {
27485
+ const parentNode2 = getParentNode(element);
27486
+ if (parentNode2 === stopNode || !isElement(parentNode2) || isLastTraversableNode(parentNode2)) {
27487
+ return false;
27488
+ }
27489
+ return getComputedStyle$1(parentNode2).position === "fixed" || hasFixedPositionAncestor(parentNode2, stopNode);
27490
+ }
27491
+ function getClippingElementAncestors(element, cache) {
27492
+ const cachedResult2 = cache.get(element);
27493
+ if (cachedResult2) {
27494
+ return cachedResult2;
27495
+ }
27496
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
27497
+ let currentContainingBlockComputedStyle = null;
27498
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
27499
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
27500
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
27501
+ const computedStyle = getComputedStyle$1(currentNode);
27502
+ const currentNodeIsContaining = isContainingBlock(currentNode);
27503
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
27504
+ currentContainingBlockComputedStyle = null;
27505
+ }
27506
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
27507
+ if (shouldDropCurrentNode) {
27508
+ result = result.filter((ancestor) => ancestor !== currentNode);
27509
+ } else {
27510
+ currentContainingBlockComputedStyle = computedStyle;
27511
+ }
27512
+ currentNode = getParentNode(currentNode);
27513
+ }
27514
+ cache.set(element, result);
27515
+ return result;
27516
+ }
27517
+ function getClippingRect(_ref) {
27518
+ let {
27519
+ element,
27520
+ boundary,
27521
+ rootBoundary,
27522
+ strategy
27523
+ } = _ref;
27524
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
27525
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
27526
+ const firstClippingAncestor = clippingAncestors[0];
27527
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
27528
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
27529
+ accRect.top = max(rect.top, accRect.top);
27530
+ accRect.right = min(rect.right, accRect.right);
27531
+ accRect.bottom = min(rect.bottom, accRect.bottom);
27532
+ accRect.left = max(rect.left, accRect.left);
27533
+ return accRect;
27534
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
27535
+ return {
27536
+ width: clippingRect.right - clippingRect.left,
27537
+ height: clippingRect.bottom - clippingRect.top,
27538
+ x: clippingRect.left,
27539
+ y: clippingRect.top
27540
+ };
27541
+ }
27542
+ function getDimensions(element) {
27543
+ const {
27544
+ width,
27545
+ height
27546
+ } = getCssDimensions(element);
27547
+ return {
27548
+ width,
27549
+ height
27550
+ };
27551
+ }
27552
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
27553
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
27554
+ const documentElement = getDocumentElement(offsetParent);
27555
+ const isFixed = strategy === "fixed";
27556
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
27557
+ let scroll = {
27558
+ scrollLeft: 0,
27559
+ scrollTop: 0
27560
+ };
27561
+ const offsets = createCoords(0);
27562
+ function setLeftRTLScrollbarOffset() {
27563
+ offsets.x = getWindowScrollBarX(documentElement);
27564
+ }
27565
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
27566
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
27567
+ scroll = getNodeScroll(offsetParent);
27568
+ }
27569
+ if (isOffsetParentAnElement) {
27570
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
27571
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
27572
+ offsets.y = offsetRect.y + offsetParent.clientTop;
27573
+ } else if (documentElement) {
27574
+ setLeftRTLScrollbarOffset();
27575
+ }
27576
+ }
27577
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
27578
+ setLeftRTLScrollbarOffset();
27579
+ }
27580
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
27581
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
27582
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
27583
+ return {
27584
+ x,
27585
+ y,
27586
+ width: rect.width,
27587
+ height: rect.height
27588
+ };
27589
+ }
27590
+ function isStaticPositioned(element) {
27591
+ return getComputedStyle$1(element).position === "static";
27592
+ }
27593
+ function getTrueOffsetParent(element, polyfill) {
27594
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
27595
+ return null;
27596
+ }
27597
+ if (polyfill) {
27598
+ return polyfill(element);
27599
+ }
27600
+ let rawOffsetParent = element.offsetParent;
27601
+ if (getDocumentElement(element) === rawOffsetParent) {
27602
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
27603
+ }
27604
+ return rawOffsetParent;
27605
+ }
27606
+ function getOffsetParent(element, polyfill) {
27607
+ const win = getWindow(element);
27608
+ if (isTopLayer(element)) {
27609
+ return win;
27610
+ }
27611
+ if (!isHTMLElement(element)) {
27612
+ let svgOffsetParent = getParentNode(element);
27613
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
27614
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
27615
+ return svgOffsetParent;
27616
+ }
27617
+ svgOffsetParent = getParentNode(svgOffsetParent);
27618
+ }
27619
+ return win;
27620
+ }
27621
+ let offsetParent = getTrueOffsetParent(element, polyfill);
27622
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
27623
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
27624
+ }
27625
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
27626
+ return win;
27627
+ }
27628
+ return offsetParent || getContainingBlock(element) || win;
27629
+ }
27630
+ const getElementRects = async function(data) {
27631
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
27632
+ const getDimensionsFn = this.getDimensions;
27633
+ const floatingDimensions = await getDimensionsFn(data.floating);
27634
+ return {
27635
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
27636
+ floating: {
27637
+ x: 0,
27638
+ y: 0,
27639
+ width: floatingDimensions.width,
27640
+ height: floatingDimensions.height
27641
+ }
27642
+ };
27643
+ };
27644
+ function isRTL(element) {
27645
+ return getComputedStyle$1(element).direction === "rtl";
27646
+ }
27647
+ const platform = {
27648
+ convertOffsetParentRelativeRectToViewportRelativeRect,
27649
+ getDocumentElement,
27650
+ getClippingRect,
27651
+ getOffsetParent,
27652
+ getElementRects,
27653
+ getClientRects,
27654
+ getDimensions,
27655
+ getScale,
27656
+ isElement,
27657
+ isRTL
27658
+ };
27659
+ function rectsAreEqual(a, b) {
27660
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
27661
+ }
27662
+ function observeMove(element, onMove) {
27663
+ let io = null;
27664
+ let timeoutId;
27665
+ const root = getDocumentElement(element);
27666
+ function cleanup() {
27667
+ var _io;
27668
+ clearTimeout(timeoutId);
27669
+ (_io = io) == null || _io.disconnect();
27670
+ io = null;
27671
+ }
27672
+ function refresh(skip, threshold) {
27673
+ if (skip === void 0) {
27674
+ skip = false;
27675
+ }
27676
+ if (threshold === void 0) {
27677
+ threshold = 1;
27678
+ }
27679
+ cleanup();
27680
+ const elementRectForRootMargin = element.getBoundingClientRect();
27681
+ const {
27682
+ left: left2,
27683
+ top: top2,
27684
+ width,
27685
+ height
27686
+ } = elementRectForRootMargin;
27687
+ if (!skip) {
27688
+ onMove();
27689
+ }
27690
+ if (!width || !height) {
27691
+ return;
27692
+ }
27693
+ const insetTop = floor(top2);
27694
+ const insetRight = floor(root.clientWidth - (left2 + width));
27695
+ const insetBottom = floor(root.clientHeight - (top2 + height));
27696
+ const insetLeft = floor(left2);
27697
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
27698
+ const options = {
27699
+ rootMargin,
27700
+ threshold: max(0, min(1, threshold)) || 1
27701
+ };
27702
+ let isFirstUpdate = true;
27703
+ function handleObserve(entries) {
27704
+ const ratio = entries[0].intersectionRatio;
27705
+ if (ratio !== threshold) {
27706
+ if (!isFirstUpdate) {
27707
+ return refresh();
27708
+ }
27709
+ if (!ratio) {
27710
+ timeoutId = setTimeout(() => {
27711
+ refresh(false, 1e-7);
27712
+ }, 1e3);
27713
+ } else {
27714
+ refresh(false, ratio);
27715
+ }
27716
+ }
27717
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
27718
+ refresh();
27719
+ }
27720
+ isFirstUpdate = false;
27721
+ }
27722
+ try {
27723
+ io = new IntersectionObserver(handleObserve, {
27724
+ ...options,
27725
+ // Handle <iframe>s
27726
+ root: root.ownerDocument
27727
+ });
27728
+ } catch (_e) {
27729
+ io = new IntersectionObserver(handleObserve, options);
27730
+ }
27731
+ io.observe(element);
27732
+ }
27733
+ refresh(true);
27734
+ return cleanup;
27735
+ }
27736
+ function autoUpdate(reference2, floating, update, options) {
27737
+ if (options === void 0) {
27738
+ options = {};
27739
+ }
27740
+ const {
27741
+ ancestorScroll = true,
27742
+ ancestorResize = true,
27743
+ elementResize = typeof ResizeObserver === "function",
27744
+ layoutShift = typeof IntersectionObserver === "function",
27745
+ animationFrame = false
27746
+ } = options;
27747
+ const referenceEl = unwrapElement(reference2);
27748
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
27749
+ ancestors.forEach((ancestor) => {
27750
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
27751
+ passive: true
27752
+ });
27753
+ ancestorResize && ancestor.addEventListener("resize", update);
27754
+ });
27755
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
27756
+ let reobserveFrame = -1;
27757
+ let resizeObserver = null;
27758
+ if (elementResize) {
27759
+ resizeObserver = new ResizeObserver((_ref) => {
27760
+ let [firstEntry] = _ref;
27761
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
27762
+ resizeObserver.unobserve(floating);
27763
+ cancelAnimationFrame(reobserveFrame);
27764
+ reobserveFrame = requestAnimationFrame(() => {
27765
+ var _resizeObserver;
27766
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
27767
+ });
27768
+ }
27769
+ update();
27770
+ });
27771
+ if (referenceEl && !animationFrame) {
27772
+ resizeObserver.observe(referenceEl);
27773
+ }
27774
+ resizeObserver.observe(floating);
27775
+ }
27776
+ let frameId;
27777
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference2) : null;
27778
+ if (animationFrame) {
27779
+ frameLoop();
27780
+ }
27781
+ function frameLoop() {
27782
+ const nextRefRect = getBoundingClientRect(reference2);
27783
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
27784
+ update();
27785
+ }
27786
+ prevRefRect = nextRefRect;
27787
+ frameId = requestAnimationFrame(frameLoop);
27788
+ }
27789
+ update();
27790
+ return () => {
27791
+ var _resizeObserver2;
27792
+ ancestors.forEach((ancestor) => {
27793
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
27794
+ ancestorResize && ancestor.removeEventListener("resize", update);
27795
+ });
27796
+ cleanupIo == null || cleanupIo();
27797
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
27798
+ resizeObserver = null;
27799
+ if (animationFrame) {
27800
+ cancelAnimationFrame(frameId);
27801
+ }
27802
+ };
27803
+ }
27804
+ const hide = hide$1;
27805
+ const computePosition = (reference2, floating, options) => {
27806
+ const cache = /* @__PURE__ */ new Map();
27807
+ const mergedOptions = {
27808
+ platform,
27809
+ ...options
27810
+ };
27811
+ const platformWithCache = {
27812
+ ...mergedOptions.platform,
27813
+ _c: cache
27814
+ };
27815
+ return computePosition$1(reference2, floating, {
27816
+ ...mergedOptions,
27817
+ platform: platformWithCache
27818
+ });
27819
+ };
27820
+ const SEPARATOR_CLASS = "pagination-separator";
27821
+ const SEPARATOR_FLOATING_CLASS = "pagination-separator-floating";
27822
+ const isDebugging = false;
27823
+ const cleanupFunctions = /* @__PURE__ */ new Set();
27824
+ const Pagination = Extension.create({
27825
+ name: "pagination",
27826
+ addStorage() {
27827
+ return {
27828
+ height: 0,
27829
+ sectionData: null
27830
+ };
27831
+ },
27832
+ addCommands() {
27833
+ return {
27834
+ insertPageBreak: () => ({ commands: commands2 }) => {
27835
+ return commands2.insertContent({
27836
+ type: "hardBreak"
27837
+ });
27838
+ }
27839
+ };
27840
+ },
27841
+ addShortcuts() {
27842
+ return {
27843
+ "Mod-Enter": () => this.editor.commands.insertPageBreak()
27844
+ };
27845
+ },
27846
+ /**
27847
+ * The pagination plugin is responsible for calculating page breaks, and redering them using decorations.
27848
+ */
27849
+ addPmPlugins() {
27850
+ const editor = this.editor;
27851
+ let isUpdating = false;
27852
+ let shouldUpdate = false;
27853
+ let hasInitialized = false;
27854
+ let shouldInitialize = false;
27855
+ const paginationPlugin = new Plugin({
27856
+ key: PaginationPluginKey,
27857
+ state: {
27858
+ isReadyToInit: false,
26562
27859
  init(_, state) {
26563
27860
  return {
26564
27861
  isReadyToInit: false,
@@ -26613,7 +27910,7 @@ const Pagination = Extension.create({
26613
27910
  view: (view) => {
26614
27911
  let previousDecorations = DecorationSet.empty;
26615
27912
  return {
26616
- update: (view2) => {
27913
+ update: (view2, prevState) => {
26617
27914
  if (!shouldUpdate || isUpdating) return;
26618
27915
  isUpdating = true;
26619
27916
  hasInitialized = true;
@@ -26630,6 +27927,9 @@ const Pagination = Extension.create({
26630
27927
  }
26631
27928
  });
26632
27929
  return [paginationPlugin];
27930
+ },
27931
+ onDestroy() {
27932
+ cleanupFloatingSeparators();
26633
27933
  }
26634
27934
  });
26635
27935
  const getHeaderFooterId = (currentPageNumber, sectionType, editor, node = null) => {
@@ -26667,12 +27967,23 @@ const getHeaderFooterId = (currentPageNumber, sectionType, editor, node = null)
26667
27967
  const performUpdate = (editor, view, previousDecorations) => {
26668
27968
  const sectionData = editor.storage.pagination.sectionData;
26669
27969
  const newDecorations = calculatePageBreaks(view, editor, sectionData);
27970
+ const editorElement = editor.options.element;
26670
27971
  if (!previousDecorations.eq(newDecorations)) {
26671
27972
  const updateTransaction = view.state.tr.setMeta(
26672
27973
  PaginationPluginKey,
26673
27974
  { decorations: newDecorations }
26674
27975
  );
26675
27976
  view.dispatch(updateTransaction);
27977
+ requestAnimationFrame(() => {
27978
+ requestAnimationFrame(() => {
27979
+ cleanupFloatingSeparators();
27980
+ const separators = [...editorElement.querySelectorAll(`.${SEPARATOR_CLASS}--table`)];
27981
+ separators.forEach((separator) => {
27982
+ const { cleanup } = createFloatingSeparator(separator, editor);
27983
+ cleanupFunctions.add(cleanup);
27984
+ });
27985
+ });
27986
+ });
26676
27987
  }
26677
27988
  editor.emit("paginationUpdate");
26678
27989
  };
@@ -26713,16 +28024,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26713
28024
  const decorations = [];
26714
28025
  const { pageSize, pageMargins } = editor.converter.pageStyles;
26715
28026
  const pageHeight = pageSize.height * 96;
26716
- editor.options.scale;
26717
28027
  let currentPageNumber = 1;
26718
28028
  let pageHeightThreshold = pageHeight;
26719
28029
  let footer = null, header = null;
26720
28030
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26721
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
28031
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
26722
28032
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
26723
28033
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
26724
28034
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
26725
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
28035
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
26726
28036
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
26727
28037
  let coords = view?.coordsAtPos(doc2.content.size);
26728
28038
  if (!coords) return [];
@@ -26741,7 +28051,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26741
28051
  if (currentPageNumber === 1) {
26742
28052
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
26743
28053
  decorations.pop();
26744
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
28054
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
26745
28055
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
26746
28056
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
26747
28057
  }
@@ -26757,7 +28067,9 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26757
28067
  }
26758
28068
  if (isHardBreakNode || shouldAddPageBreak) {
26759
28069
  const $currentPos = view.state.doc.resolve(currentPos);
28070
+ const table = findParentNodeClosestToPos($currentPos, (node2) => node2.type.name === "table");
26760
28071
  const tableRow = findParentNodeClosestToPos($currentPos, (node2) => node2.type.name === "tableRow");
28072
+ let isInTable2 = table || tableRow ? true : false;
26761
28073
  if (tableRow) {
26762
28074
  currentNode = tableRow.node;
26763
28075
  currentPos = tableRow.pos;
@@ -26770,13 +28082,13 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26770
28082
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
26771
28083
  currentPageNumber++;
26772
28084
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26773
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
28085
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
26774
28086
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
26775
28087
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
26776
28088
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
26777
28089
  const pageSpacer2 = Decoration.widget(breakPos, spacingNode2, { key: "stable-key" });
26778
28090
  decorations.push(pageSpacer2);
26779
- const pageBreak2 = createPageBreak({ editor, header, footer });
28091
+ const pageBreak2 = createPageBreak({ editor, header, footer, isInTable: isInTable2 });
26780
28092
  decorations.push(Decoration.widget(breakPos, pageBreak2, { key: "stable-key" }));
26781
28093
  pageHeightThreshold = actualBreakBottom + (pageHeight - header.headerHeight - footer.footerHeight);
26782
28094
  }
@@ -26785,7 +28097,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26785
28097
  const lastNodeCoords = view.coordsAtPos(finalPos);
26786
28098
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26787
28099
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
26788
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
28100
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
26789
28101
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
26790
28102
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
26791
28103
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -26802,6 +28114,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26802
28114
  totalPageNumber.innerText = currentPageNumber;
26803
28115
  }
26804
28116
  });
28117
+ editor.currentTotalPages = currentPageNumber;
26805
28118
  return decorations;
26806
28119
  }
26807
28120
  function createFinalPagePadding(bufferHeight) {
@@ -26812,7 +28125,7 @@ function createFinalPagePadding(bufferHeight) {
26812
28125
  div2.style.height = bufferHeight + "px";
26813
28126
  return { nodeHeight: bufferHeight, node: div2 };
26814
28127
  }
26815
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
28128
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
26816
28129
  const headerDef = sectionData.headers?.[headerId];
26817
28130
  const minHeaderHeight = pageMargins.top * 96;
26818
28131
  const headerMargin = pageMargins.header * 96;
@@ -26839,7 +28152,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
26839
28152
  appendToBody: false,
26840
28153
  sectionId: headerId,
26841
28154
  type: "header",
26842
- availableHeight
28155
+ availableHeight,
28156
+ currentPageNumber
26843
28157
  });
26844
28158
  editor.converter.headerEditors.push({
26845
28159
  id: headerId,
@@ -26865,13 +28179,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
26865
28179
  const minFooterHeight = pageMargins.bottom * 96;
26866
28180
  const footerPaddingFromEdge = pageMargins.footer * 96;
26867
28181
  const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
26868
- const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
26869
- const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
26870
- if (autoPageNumber) {
26871
- const fontSize = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
26872
- if (fontSize) autoPageNumber.style.fontSize = fontSize;
26873
- autoPageNumber.innerText = currentPageNumber;
26874
- }
26875
28182
  const editorContainer = document.createElement("div");
26876
28183
  if (!footerId && !editor.converter.footerIds["default"]) {
26877
28184
  footerId = "rId" + generateDocxRandomId();
@@ -26891,7 +28198,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
26891
28198
  appendToBody: false,
26892
28199
  sectionId: footerId,
26893
28200
  type: "footer",
26894
- availableHeight: footerHeight
28201
+ availableHeight: footerHeight,
28202
+ currentPageNumber
26895
28203
  });
26896
28204
  editor.converter.footerEditors.push({
26897
28205
  id: footerId,
@@ -26917,7 +28225,7 @@ const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
26917
28225
  editor.setEditable(false, false);
26918
28226
  toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
26919
28227
  };
26920
- function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter }) {
28228
+ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
26921
28229
  const { pageSize, pageMargins } = editor.converter.pageStyles;
26922
28230
  let sectionHeight = 0;
26923
28231
  const paginationDiv = document.createElement("div");
@@ -26936,7 +28244,10 @@ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstH
26936
28244
  const separatorHeight = 20;
26937
28245
  sectionHeight += separatorHeight;
26938
28246
  const separator = document.createElement("div");
26939
- separator.className = "pagination-separator";
28247
+ separator.classList.add(SEPARATOR_CLASS);
28248
+ if (isInTable2) {
28249
+ separator.classList.add(`${SEPARATOR_CLASS}--table`);
28250
+ }
26940
28251
  innerDiv.appendChild(separator);
26941
28252
  }
26942
28253
  if (header) {
@@ -26975,6 +28286,85 @@ const onImageLoad = (editor) => {
26975
28286
  editor.view.dispatch(newTr);
26976
28287
  });
26977
28288
  };
28289
+ function createFloatingSeparator(separator, editor) {
28290
+ const floatingSeparator = document.createElement("div");
28291
+ floatingSeparator.classList.add(SEPARATOR_FLOATING_CLASS);
28292
+ floatingSeparator.dataset.floatingSeparator = "";
28293
+ const editorElement = editor.options.element;
28294
+ editorElement.append(floatingSeparator);
28295
+ const updatePosition2 = () => {
28296
+ computePosition(separator, floatingSeparator, {
28297
+ strategy: "absolute",
28298
+ placement: "top-start",
28299
+ middleware: [
28300
+ hide(),
28301
+ {
28302
+ name: "copy",
28303
+ fn: ({ elements }) => {
28304
+ const rect = elements.reference.getBoundingClientRect();
28305
+ const containerRect = editorElement.getBoundingClientRect();
28306
+ const scaleFactor = getScaleFactor(editorElement);
28307
+ const x = Math.round((rect.left - containerRect.left) / scaleFactor);
28308
+ const y = Math.round((rect.top - containerRect.top) / scaleFactor);
28309
+ const width = Math.round(rect.width / scaleFactor);
28310
+ const height = Math.round(rect.height / scaleFactor);
28311
+ return {
28312
+ x,
28313
+ y,
28314
+ data: { width, height }
28315
+ };
28316
+ }
28317
+ }
28318
+ ]
28319
+ }).then(({ x, y, middlewareData }) => {
28320
+ Object.assign(floatingSeparator.style, {
28321
+ top: `${y}px`,
28322
+ left: `${x}px`,
28323
+ width: `${middlewareData.copy.width}px`,
28324
+ height: `${middlewareData.copy.height}px`,
28325
+ visibility: middlewareData.hide?.referenceHidden ? "hidden" : "visible"
28326
+ });
28327
+ });
28328
+ };
28329
+ const cleanup = autoUpdate(
28330
+ separator,
28331
+ floatingSeparator,
28332
+ updatePosition2
28333
+ );
28334
+ const extendedCleanup = () => {
28335
+ floatingSeparator?.remove();
28336
+ cleanup();
28337
+ };
28338
+ return {
28339
+ cleanup: extendedCleanup,
28340
+ updatePosition: updatePosition2
28341
+ };
28342
+ }
28343
+ function cleanupFloatingSeparators() {
28344
+ cleanupFunctions.forEach((cleanup) => cleanup());
28345
+ cleanupFunctions.clear();
28346
+ }
28347
+ function getScaleFactor(element) {
28348
+ let scale = 1;
28349
+ let currentElement = element;
28350
+ while (currentElement && currentElement !== document.documentElement) {
28351
+ let zoomStyle = currentElement.style.zoom;
28352
+ if (zoomStyle) {
28353
+ let zoom = parseFloat(zoomStyle) || 1;
28354
+ scale *= zoom;
28355
+ }
28356
+ let transformStyle = currentElement.style.transform;
28357
+ if (transformStyle) {
28358
+ let scaleMatch = transformStyle.match(/scale\(([^)]+)\)/);
28359
+ if (scaleMatch) {
28360
+ let scaleValue = parseFloat(scaleMatch[1]) || 1;
28361
+ scale *= scaleValue;
28362
+ }
28363
+ }
28364
+ currentElement = currentElement.parentElement;
28365
+ }
28366
+ return scale;
28367
+ }
26978
28368
  class SearchQuery {
26979
28369
  /**
26980
28370
  Create a query object.