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

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 (72) 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-akFFn4Ld.cjs → super-editor.es-3IGIxgjF.cjs} +2139 -422
  10. package/dist/chunks/{super-editor.es-BtKVLpiq.es.js → super-editor.es-WrgX5vxB.es.js} +2139 -422
  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 +112 -7
  23. package/dist/super-editor/ai-writer.es.js +2 -2
  24. package/dist/super-editor/chunks/{converter-BSl_E2ED.js → converter-RpLHCUPf.js} +109 -10
  25. package/dist/super-editor/chunks/{docx-zipper-USmuqzmo.js → docx-zipper-V5sLSr7T.js} +1 -1
  26. package/dist/super-editor/chunks/{editor-C0hNf44Q.js → editor-CAT1dxaK.js} +2103 -350
  27. package/dist/super-editor/chunks/{toolbar-IN0IJC2L.js → toolbar-Cts0XR5V.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/image/imageHelpers/imagePositionPlugin.d.ts.map +1 -1
  48. package/dist/super-editor/extensions/image/imageHelpers/index.d.ts +1 -0
  49. package/dist/super-editor/extensions/image/imageHelpers/processUploadedImage.d.ts.map +1 -1
  50. package/dist/super-editor/extensions/image/index.d.ts +1 -0
  51. package/dist/super-editor/extensions/index.d.ts +2 -1
  52. package/dist/super-editor/extensions/index.d.ts.map +1 -1
  53. package/dist/super-editor/extensions/noderesizer/index.d.ts +2 -0
  54. package/dist/super-editor/extensions/noderesizer/index.d.ts.map +1 -0
  55. package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts +7 -0
  56. package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -0
  57. package/dist/super-editor/extensions/page-number/page-number.d.ts +10 -0
  58. package/dist/super-editor/extensions/page-number/page-number.d.ts.map +1 -1
  59. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +2 -1
  60. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
  61. package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
  62. package/dist/super-editor/file-zipper.es.js +1 -1
  63. package/dist/super-editor/style.css +112 -7
  64. package/dist/super-editor/super-editor.es.js +8 -142
  65. package/dist/super-editor/toolbar.es.js +2 -2
  66. package/dist/super-editor.cjs +2 -2
  67. package/dist/super-editor.es.js +2 -2
  68. package/dist/superdoc.cjs +1587 -366
  69. package/dist/superdoc.es.js +1572 -367
  70. package/dist/superdoc.umd.js +3697 -774
  71. package/dist/superdoc.umd.js.map +1 -1
  72. package/package.json +3 -2
@@ -1,6 +1,6 @@
1
+ import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-Bi1uWinj.es.js";
1
2
  import * as Y from "yjs";
2
3
  import { UndoManager, Item as Item$2, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
3
- import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-IIIZMHTg.es.js";
4
4
  var __defProp$2 = Object.defineProperty;
5
5
  var __typeError$2 = (msg2) => {
6
6
  throw TypeError(msg2);
@@ -2556,29 +2556,29 @@ function requireAbs() {
2556
2556
  abs$1 = Math.abs;
2557
2557
  return abs$1;
2558
2558
  }
2559
- var floor$1;
2559
+ var floor$2;
2560
2560
  var hasRequiredFloor;
2561
2561
  function requireFloor() {
2562
- if (hasRequiredFloor) return floor$1;
2562
+ if (hasRequiredFloor) return floor$2;
2563
2563
  hasRequiredFloor = 1;
2564
- floor$1 = Math.floor;
2565
- return floor$1;
2564
+ floor$2 = Math.floor;
2565
+ return floor$2;
2566
2566
  }
2567
- var max$2;
2567
+ var max$3;
2568
2568
  var hasRequiredMax;
2569
2569
  function requireMax() {
2570
- if (hasRequiredMax) return max$2;
2570
+ if (hasRequiredMax) return max$3;
2571
2571
  hasRequiredMax = 1;
2572
- max$2 = Math.max;
2573
- return max$2;
2572
+ max$3 = Math.max;
2573
+ return max$3;
2574
2574
  }
2575
- var min$2;
2575
+ var min$3;
2576
2576
  var hasRequiredMin;
2577
2577
  function requireMin() {
2578
- if (hasRequiredMin) return min$2;
2578
+ if (hasRequiredMin) return min$3;
2579
2579
  hasRequiredMin = 1;
2580
- min$2 = Math.min;
2581
- return min$2;
2580
+ min$3 = Math.min;
2581
+ return min$3;
2582
2582
  }
2583
2583
  var pow;
2584
2584
  var hasRequiredPow;
@@ -2588,13 +2588,13 @@ function requirePow() {
2588
2588
  pow = Math.pow;
2589
2589
  return pow;
2590
2590
  }
2591
- var round$1;
2591
+ var round$2;
2592
2592
  var hasRequiredRound;
2593
2593
  function requireRound() {
2594
- if (hasRequiredRound) return round$1;
2594
+ if (hasRequiredRound) return round$2;
2595
2595
  hasRequiredRound = 1;
2596
- round$1 = Math.round;
2597
- return round$1;
2596
+ round$2 = Math.round;
2597
+ return round$2;
2598
2598
  }
2599
2599
  var _isNaN;
2600
2600
  var hasRequired_isNaN;
@@ -12419,7 +12419,7 @@ const OPT_PRESERVE_WS = 1, OPT_PRESERVE_WS_FULL = 2, OPT_OPEN_LEFT = 4;
12419
12419
  function wsOptionsFor(type2, preserveWhitespace, base2) {
12420
12420
  if (preserveWhitespace != null)
12421
12421
  return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0);
12422
- return type2 && type2.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base2 & -5;
12422
+ return type2 && type2.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base2 & ~OPT_OPEN_LEFT;
12423
12423
  }
12424
12424
  class NodeContext {
12425
12425
  constructor(type2, attrs, marks, solid, match, options2) {
@@ -15390,7 +15390,7 @@ class Transaction extends Transform {
15390
15390
  throw new RangeError("Selection passed to setSelection must point at the current document");
15391
15391
  this.curSelection = selection;
15392
15392
  this.curSelectionFor = this.steps.length;
15393
- this.updated = (this.updated | UPDATED_SEL) & -3;
15393
+ this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;
15394
15394
  this.storedMarks = null;
15395
15395
  return this;
15396
15396
  }
@@ -15441,7 +15441,7 @@ class Transaction extends Transform {
15441
15441
  */
15442
15442
  addStep(step, doc2) {
15443
15443
  super.addStep(step, doc2);
15444
- this.updated = this.updated & -3;
15444
+ this.updated = this.updated & ~UPDATED_MARKS;
15445
15445
  this.storedMarks = null;
15446
15446
  }
15447
15447
  /**
@@ -18845,7 +18845,9 @@ function exportSchemaToJson(params2) {
18845
18845
  shapeContainer: translateShapeContainer,
18846
18846
  shapeTextbox: translateShapeTextbox,
18847
18847
  contentBlock: translateContentBlock,
18848
- structuredContent: translateStructuredContent
18848
+ structuredContent: translateStructuredContent,
18849
+ "page-number": translatePageNumberNode,
18850
+ "total-page-number": translateTotalPageNumberNode
18849
18851
  };
18850
18852
  if (!router[type2]) {
18851
18853
  console.error("No translation function found for node type:", type2);
@@ -20542,6 +20544,81 @@ function translateStructuredContent(params2) {
20542
20544
  elements: nodeElements
20543
20545
  };
20544
20546
  }
20547
+ const translatePageNumberNode = (params2) => {
20548
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20549
+ return getAutoPageJson("PAGE", outputMarks);
20550
+ };
20551
+ const translateTotalPageNumberNode = (params2) => {
20552
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20553
+ return getAutoPageJson("NUMPAGES", outputMarks);
20554
+ };
20555
+ const getAutoPageJson = (type2, outputMarks = []) => {
20556
+ return [
20557
+ {
20558
+ "name": "w:r",
20559
+ "elements": [
20560
+ {
20561
+ "name": "w:rPr",
20562
+ "elements": outputMarks
20563
+ },
20564
+ {
20565
+ "name": "w:fldChar",
20566
+ "attributes": {
20567
+ "w:fldCharType": "begin"
20568
+ }
20569
+ }
20570
+ ]
20571
+ },
20572
+ {
20573
+ "name": "w:r",
20574
+ "elements": [
20575
+ {
20576
+ "name": "w:rPr",
20577
+ "elements": outputMarks
20578
+ },
20579
+ {
20580
+ "name": "w:instrText",
20581
+ "elements": [
20582
+ {
20583
+ "type": "text",
20584
+ "text": ` ${type2}`
20585
+ }
20586
+ ]
20587
+ }
20588
+ ]
20589
+ },
20590
+ {
20591
+ "name": "w:r",
20592
+ "elements": [
20593
+ {
20594
+ "name": "w:rPr",
20595
+ "elements": outputMarks
20596
+ },
20597
+ {
20598
+ "name": "w:fldChar",
20599
+ "attributes": {
20600
+ "w:fldCharType": "separate"
20601
+ }
20602
+ }
20603
+ ]
20604
+ },
20605
+ {
20606
+ "name": "w:r",
20607
+ "elements": [
20608
+ {
20609
+ "name": "w:rPr",
20610
+ "elements": outputMarks
20611
+ },
20612
+ {
20613
+ "name": "w:fldChar",
20614
+ "attributes": {
20615
+ "w:fldCharType": "end"
20616
+ }
20617
+ }
20618
+ ]
20619
+ }
20620
+ ];
20621
+ };
20545
20622
  const defaultInitialXml = `<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14"><w:body></w:body></w:document>`;
20546
20623
  const parseXmlToJson = (xml) => {
20547
20624
  return JSON.parse(xmljs.xml2json(xml, null, 2));
@@ -21440,6 +21517,8 @@ const handleListNode = (params2) => {
21440
21517
  listItems.push(possibleList);
21441
21518
  possibleList = siblings.shift();
21442
21519
  if (possibleList?.elements && !hasTextNode(possibleList.elements)) {
21520
+ const { name } = possibleList;
21521
+ if (name === "w:tbl") continue;
21443
21522
  listItems.push(possibleList);
21444
21523
  possibleList = siblings.shift();
21445
21524
  }
@@ -22250,15 +22329,25 @@ const processCombinedNodesForFldChar = (nodesToCombine = []) => {
22250
22329
  if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
22251
22330
  const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
22252
22331
  if (hasPageMarker) {
22253
- processedNodes.push({
22332
+ const pageNumNode = {
22254
22333
  name: "sd:autoPageNumber",
22255
22334
  type: "element"
22335
+ };
22336
+ nodesToCombine.forEach((n) => {
22337
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22338
+ if (rPrNode) pageNumNode.elements = [rPrNode];
22256
22339
  });
22340
+ processedNodes.push(pageNumNode);
22257
22341
  } else if (isNumPages) {
22258
- processedNodes.push({
22342
+ const totalPageNumNode = {
22259
22343
  name: "sd:totalPageNumber",
22260
22344
  type: "element"
22345
+ };
22346
+ nodesToCombine.forEach((n) => {
22347
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22348
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
22261
22349
  });
22350
+ processedNodes.push(totalPageNumNode);
22262
22351
  } else if (urlMatch && urlMatch?.length >= 2) {
22263
22352
  const url = urlMatch[1];
22264
22353
  const textMarks = [];
@@ -22594,8 +22683,13 @@ const handleAutoPageNumber = (params2) => {
22594
22683
  if (nodes.length === 0 || nodes[0].name !== "sd:autoPageNumber") {
22595
22684
  return { nodes: [], consumed: 0 };
22596
22685
  }
22686
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22687
+ const marks = parseMarks(rPr || { elements: [] });
22597
22688
  const processedNode = {
22598
- type: "page-number"
22689
+ type: "page-number",
22690
+ attrs: {
22691
+ marksAsAttrs: marks
22692
+ }
22599
22693
  };
22600
22694
  return { nodes: [processedNode], consumed: 1 };
22601
22695
  };
@@ -22608,8 +22702,13 @@ const handleAutoTotalPageNumber = (params2) => {
22608
22702
  if (nodes.length === 0 || nodes[0].name !== "sd:totalPageNumber") {
22609
22703
  return { nodes: [], consumed: 0 };
22610
22704
  }
22705
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22706
+ const marks = parseMarks(rPr || { elements: [] });
22611
22707
  const processedNode = {
22612
- type: "total-page-number"
22708
+ type: "total-page-number",
22709
+ attrs: {
22710
+ marksAsAttrs: marks
22711
+ }
22613
22712
  };
22614
22713
  return { nodes: [processedNode], consumed: 1 };
22615
22714
  };
@@ -23294,7 +23393,7 @@ const _SuperConverter = class _SuperConverter2 {
23294
23393
  return;
23295
23394
  }
23296
23395
  }
23297
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.36") {
23396
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.37-next.2") {
23298
23397
  const customLocation = "docProps/custom.xml";
23299
23398
  if (!docx[customLocation]) {
23300
23399
  docx[customLocation] = generateCustomXml();
@@ -23761,7 +23860,7 @@ function storeSuperdocVersion(docx) {
23761
23860
  function generateCustomXml() {
23762
23861
  return DEFAULT_CUSTOM_XML;
23763
23862
  }
23764
- function generateSuperdocVersion(pid = 2, version2 = "0.12.36") {
23863
+ function generateSuperdocVersion(pid = 2, version2 = "0.12.37-next.2") {
23765
23864
  return {
23766
23865
  type: "element",
23767
23866
  name: "property",
@@ -26294,7 +26393,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
26294
26393
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
26295
26394
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
26296
26395
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
26297
- 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;
26396
+ 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;
26298
26397
  function getMarksFromSelection(state2) {
26299
26398
  const { from: from2, to, empty: empty2 } = state2.selection;
26300
26399
  const marks = [];
@@ -30561,6 +30660,7 @@ const isEquivalentPosition = function(node2, off2, targetNode, targetOff) {
30561
30660
  };
30562
30661
  const atomElements = /^(img|br|input|textarea|hr)$/i;
30563
30662
  function scanFor(node2, off2, targetNode, targetOff, dir) {
30663
+ var _a;
30564
30664
  for (; ; ) {
30565
30665
  if (node2 == targetNode && off2 == targetOff)
30566
30666
  return true;
@@ -30571,10 +30671,16 @@ function scanFor(node2, off2, targetNode, targetOff, dir) {
30571
30671
  off2 = domIndex(node2) + (dir < 0 ? 0 : 1);
30572
30672
  node2 = parent;
30573
30673
  } else if (node2.nodeType == 1) {
30574
- node2 = node2.childNodes[off2 + (dir < 0 ? -1 : 0)];
30575
- if (node2.contentEditable == "false")
30576
- return false;
30577
- off2 = dir < 0 ? nodeSize(node2) : 0;
30674
+ let child = node2.childNodes[off2 + (dir < 0 ? -1 : 0)];
30675
+ if (child.nodeType == 1 && child.contentEditable == "false") {
30676
+ if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection)
30677
+ off2 += dir;
30678
+ else
30679
+ return false;
30680
+ } else {
30681
+ node2 = child;
30682
+ off2 = dir < 0 ? nodeSize(node2) : 0;
30683
+ }
30578
30684
  } else {
30579
30685
  return false;
30580
30686
  }
@@ -30703,7 +30809,7 @@ function windowRect(doc2) {
30703
30809
  bottom: doc2.documentElement.clientHeight
30704
30810
  };
30705
30811
  }
30706
- function getSide(value, side) {
30812
+ function getSide$1(value, side) {
30707
30813
  return typeof value == "number" ? value : value[side];
30708
30814
  }
30709
30815
  function clientRect(node2) {
@@ -30731,14 +30837,14 @@ function scrollRectIntoView(view, rect, startDOM) {
30731
30837
  let atTop = elt == doc2.body;
30732
30838
  let bounding = atTop ? windowRect(doc2) : clientRect(elt);
30733
30839
  let moveX = 0, moveY = 0;
30734
- if (rect.top < bounding.top + getSide(scrollThreshold, "top"))
30735
- moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
30736
- else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom"))
30737
- moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
30738
- if (rect.left < bounding.left + getSide(scrollThreshold, "left"))
30739
- moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left"));
30740
- else if (rect.right > bounding.right - getSide(scrollThreshold, "right"))
30741
- moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
30840
+ if (rect.top < bounding.top + getSide$1(scrollThreshold, "top"))
30841
+ moveY = -(bounding.top - rect.top + getSide$1(scrollMargin, "top"));
30842
+ else if (rect.bottom > bounding.bottom - getSide$1(scrollThreshold, "bottom"))
30843
+ 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");
30844
+ if (rect.left < bounding.left + getSide$1(scrollThreshold, "left"))
30845
+ moveX = -(bounding.left - rect.left + getSide$1(scrollMargin, "left"));
30846
+ else if (rect.right > bounding.right - getSide$1(scrollThreshold, "right"))
30847
+ moveX = rect.right - bounding.right + getSide$1(scrollMargin, "right");
30742
30848
  if (moveX || moveY) {
30743
30849
  if (atTop) {
30744
30850
  doc2.defaultView.scrollBy(moveX, moveY);
@@ -31533,6 +31639,9 @@ class ViewDesc {
31533
31639
  get ignoreForCoords() {
31534
31640
  return false;
31535
31641
  }
31642
+ get ignoreForSelection() {
31643
+ return false;
31644
+ }
31536
31645
  isText(text) {
31537
31646
  return false;
31538
31647
  }
@@ -31581,6 +31690,9 @@ class WidgetViewDesc extends ViewDesc {
31581
31690
  get domAtom() {
31582
31691
  return true;
31583
31692
  }
31693
+ get ignoreForSelection() {
31694
+ return !!this.widget.type.spec.relaxedSide;
31695
+ }
31584
31696
  get side() {
31585
31697
  return this.widget.type.side;
31586
31698
  }
@@ -33361,8 +33473,9 @@ editHandlers.keypress = (view, _event) => {
33361
33473
  let sel = view.state.selection;
33362
33474
  if (!(sel instanceof TextSelection) || !sel.$from.sameParent(sel.$to)) {
33363
33475
  let text = String.fromCharCode(event.charCode);
33364
- if (!/[\r\n]/.test(text) && !view.someProp("handleTextInput", (f) => f(view, sel.$from.pos, sel.$to.pos, text)))
33365
- view.dispatch(view.state.tr.insertText(text).scrollIntoView());
33476
+ let deflt = () => view.state.tr.insertText(text).scrollIntoView();
33477
+ if (!/[\r\n]/.test(text) && !view.someProp("handleTextInput", (f) => f(view, sel.$from.pos, sel.$to.pos, text, deflt)))
33478
+ view.dispatch(deflt());
33366
33479
  event.preventDefault();
33367
33480
  }
33368
33481
  };
@@ -34934,14 +35047,14 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
34934
35047
  if (newSel && !view.state.selection.eq(newSel)) {
34935
35048
  if (chrome && android && view.input.lastKeyCode === 13 && Date.now() - 100 < view.input.lastKeyCodeTime && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter"))))
34936
35049
  return;
34937
- let tr2 = view.state.tr.setSelection(newSel);
35050
+ let tr = view.state.tr.setSelection(newSel);
34938
35051
  if (origin == "pointer")
34939
- tr2.setMeta("pointer", true);
35052
+ tr.setMeta("pointer", true);
34940
35053
  else if (origin == "key")
34941
- tr2.scrollIntoView();
35054
+ tr.scrollIntoView();
34942
35055
  if (compositionID)
34943
- tr2.setMeta("composition", compositionID);
34944
- view.dispatch(tr2);
35056
+ tr.setMeta("composition", compositionID);
35057
+ view.dispatch(tr);
34945
35058
  }
34946
35059
  return;
34947
35060
  }
@@ -34975,10 +35088,10 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
34975
35088
  if (parse.sel) {
34976
35089
  let sel2 = resolveSelection(view, view.state.doc, parse.sel);
34977
35090
  if (sel2 && !sel2.eq(view.state.selection)) {
34978
- let tr2 = view.state.tr.setSelection(sel2);
35091
+ let tr = view.state.tr.setSelection(sel2);
34979
35092
  if (compositionID)
34980
- tr2.setMeta("composition", compositionID);
34981
- view.dispatch(tr2);
35093
+ tr.setMeta("composition", compositionID);
35094
+ view.dispatch(tr);
34982
35095
  }
34983
35096
  }
34984
35097
  return;
@@ -35023,43 +35136,48 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
35023
35136
  }, 20);
35024
35137
  }
35025
35138
  let chFrom = change.start, chTo = change.endA;
35026
- let tr, storedMarks, markChange;
35139
+ let mkTr = (base2) => {
35140
+ let tr = base2 || view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));
35141
+ if (parse.sel) {
35142
+ let sel2 = resolveSelection(view, tr.doc, parse.sel);
35143
+ 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))
35144
+ tr.setSelection(sel2);
35145
+ }
35146
+ if (compositionID)
35147
+ tr.setMeta("composition", compositionID);
35148
+ return tr.scrollIntoView();
35149
+ };
35150
+ let markChange;
35027
35151
  if (inlineChange) {
35028
35152
  if ($from.pos == $to.pos) {
35029
35153
  if (ie$1 && ie_version <= 11 && $from.parentOffset == 0) {
35030
35154
  view.domObserver.suppressSelectionUpdates();
35031
35155
  setTimeout(() => selectionToDOM(view), 20);
35032
35156
  }
35033
- tr = view.state.tr.delete(chFrom, chTo);
35034
- storedMarks = doc2.resolve(change.start).marksAcross(doc2.resolve(change.endA));
35157
+ let tr = mkTr(view.state.tr.delete(chFrom, chTo));
35158
+ let marks = doc2.resolve(change.start).marksAcross(doc2.resolve(change.endA));
35159
+ if (marks)
35160
+ tr.ensureMarks(marks);
35161
+ view.dispatch(tr);
35035
35162
  } else if (
35036
35163
  // Adding or removing a mark
35037
35164
  change.endA == change.endB && (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset), $fromA.parent.content.cut($fromA.parentOffset, change.endA - $fromA.start())))
35038
35165
  ) {
35039
- tr = view.state.tr;
35166
+ let tr = mkTr(view.state.tr);
35040
35167
  if (markChange.type == "add")
35041
35168
  tr.addMark(chFrom, chTo, markChange.mark);
35042
35169
  else
35043
35170
  tr.removeMark(chFrom, chTo, markChange.mark);
35171
+ view.dispatch(tr);
35044
35172
  } else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {
35045
35173
  let text = $from.parent.textBetween($from.parentOffset, $to.parentOffset);
35046
- if (view.someProp("handleTextInput", (f) => f(view, chFrom, chTo, text)))
35047
- return;
35048
- tr = view.state.tr.insertText(text, chFrom, chTo);
35174
+ let deflt = () => mkTr(view.state.tr.insertText(text, chFrom, chTo));
35175
+ if (!view.someProp("handleTextInput", (f) => f(view, chFrom, chTo, text, deflt)))
35176
+ view.dispatch(deflt());
35049
35177
  }
35178
+ } else {
35179
+ view.dispatch(mkTr());
35050
35180
  }
35051
- if (!tr)
35052
- tr = view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));
35053
- if (parse.sel) {
35054
- let sel2 = resolveSelection(view, tr.doc, parse.sel);
35055
- 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))
35056
- tr.setSelection(sel2);
35057
- }
35058
- if (storedMarks)
35059
- tr.ensureMarks(storedMarks);
35060
- if (compositionID)
35061
- tr.setMeta("composition", compositionID);
35062
- view.dispatch(tr.scrollIntoView());
35063
35181
  }
35064
35182
  function resolveSelection(view, doc2, parsedSel) {
35065
35183
  if (Math.max(parsedSel.anchor, parsedSel.head) > doc2.content.size)
@@ -35581,22 +35699,6 @@ class EditorView {
35581
35699
  return dispatchEvent(this, event);
35582
35700
  }
35583
35701
  /**
35584
- Dispatch a transaction. Will call
35585
- [`dispatchTransaction`](https://prosemirror.net/docs/ref/#view.DirectEditorProps.dispatchTransaction)
35586
- when given, and otherwise defaults to applying the transaction to
35587
- the current state and calling
35588
- [`updateState`](https://prosemirror.net/docs/ref/#view.EditorView.updateState) with the result.
35589
- This method is bound to the view instance, so that it can be
35590
- easily passed around.
35591
- */
35592
- dispatch(tr) {
35593
- let dispatchTransaction = this._props.dispatchTransaction;
35594
- if (dispatchTransaction)
35595
- dispatchTransaction.call(this, tr);
35596
- else
35597
- this.updateState(this.state.apply(tr));
35598
- }
35599
- /**
35600
35702
  @internal
35601
35703
  */
35602
35704
  domSelectionRange() {
@@ -35612,6 +35714,13 @@ class EditorView {
35612
35714
  return this.root.getSelection();
35613
35715
  }
35614
35716
  }
35717
+ EditorView.prototype.dispatch = function(tr) {
35718
+ let dispatchTransaction = this._props.dispatchTransaction;
35719
+ if (dispatchTransaction)
35720
+ dispatchTransaction.call(this, tr);
35721
+ else
35722
+ this.updateState(this.state.apply(tr));
35723
+ };
35615
35724
  function computeDocDeco(view) {
35616
35725
  let attrs = /* @__PURE__ */ Object.create(null);
35617
35726
  attrs.class = "ProseMirror";
@@ -35677,10 +35786,10 @@ function checkStateComponent(plugin2) {
35677
35786
  if (plugin2.spec.state || plugin2.spec.filterTransaction || plugin2.spec.appendTransaction)
35678
35787
  throw new RangeError("Plugins passed directly to the view must not have a state component");
35679
35788
  }
35680
- const floor = Math.floor;
35789
+ const floor$1 = Math.floor;
35681
35790
  const abs = Math.abs;
35682
- const min$1 = (a, b) => a < b ? a : b;
35683
- const max$1 = (a, b) => a > b ? a : b;
35791
+ const min$2 = (a, b) => a < b ? a : b;
35792
+ const max$2 = (a, b) => a > b ? a : b;
35684
35793
  const isNegativeZero = (n) => n !== 0 ? n < 0 : 1 / n < 0;
35685
35794
  const BIT7 = 64;
35686
35795
  const BIT8 = 128;
@@ -35688,7 +35797,7 @@ const BIT30 = 1 << 29;
35688
35797
  const BITS6 = 63;
35689
35798
  const BITS7 = 127;
35690
35799
  const BITS31 = 2147483647;
35691
- const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor(num) === num);
35800
+ const isInteger = Number.isInteger || ((num) => typeof num === "number" && isFinite(num) && floor$1(num) === num);
35692
35801
  const create$2 = () => /* @__PURE__ */ new Set();
35693
35802
  const isArray$1 = Array.isArray;
35694
35803
  const fromCharCode = String.fromCharCode;
@@ -35752,7 +35861,7 @@ const verifyLen = (encoder, len) => {
35752
35861
  const bufferLen = encoder.cbuf.length;
35753
35862
  if (bufferLen - encoder.cpos < len) {
35754
35863
  encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos));
35755
- encoder.cbuf = new Uint8Array(max$1(bufferLen, len) * 2);
35864
+ encoder.cbuf = new Uint8Array(max$2(bufferLen, len) * 2);
35756
35865
  encoder.cpos = 0;
35757
35866
  }
35758
35867
  };
@@ -35768,7 +35877,7 @@ const write$1 = (encoder, num) => {
35768
35877
  const writeVarUint = (encoder, num) => {
35769
35878
  while (num > BITS7) {
35770
35879
  write$1(encoder, BIT8 | BITS7 & num);
35771
- num = floor(num / 128);
35880
+ num = floor$1(num / 128);
35772
35881
  }
35773
35882
  write$1(encoder, BITS7 & num);
35774
35883
  };
@@ -35778,10 +35887,10 @@ const writeVarInt = (encoder, num) => {
35778
35887
  num = -num;
35779
35888
  }
35780
35889
  write$1(encoder, (num > BITS6 ? BIT8 : 0) | (isNegative ? BIT7 : 0) | BITS6 & num);
35781
- num = floor(num / 64);
35890
+ num = floor$1(num / 64);
35782
35891
  while (num > 0) {
35783
35892
  write$1(encoder, (num > BITS7 ? BIT8 : 0) | BITS7 & num);
35784
- num = floor(num / 128);
35893
+ num = floor$1(num / 128);
35785
35894
  }
35786
35895
  };
35787
35896
  const _strBuffer = new Uint8Array(3e4);
@@ -35814,13 +35923,13 @@ utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
35814
35923
  const writeUint8Array = (encoder, uint8Array) => {
35815
35924
  const bufferLen = encoder.cbuf.length;
35816
35925
  const cpos = encoder.cpos;
35817
- const leftCopyLen = min$1(bufferLen - cpos, uint8Array.length);
35926
+ const leftCopyLen = min$2(bufferLen - cpos, uint8Array.length);
35818
35927
  const rightCopyLen = uint8Array.length - leftCopyLen;
35819
35928
  encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
35820
35929
  encoder.cpos += leftCopyLen;
35821
35930
  if (rightCopyLen > 0) {
35822
35931
  encoder.bufs.push(encoder.cbuf);
35823
- encoder.cbuf = new Uint8Array(max$1(bufferLen * 2, rightCopyLen));
35932
+ encoder.cbuf = new Uint8Array(max$2(bufferLen * 2, rightCopyLen));
35824
35933
  encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
35825
35934
  encoder.cpos = rightCopyLen;
35826
35935
  }
@@ -35962,7 +36071,7 @@ const ySyncPluginKey = new PluginKey("y-sync");
35962
36071
  const yUndoPluginKey = new PluginKey("y-undo");
35963
36072
  const yCursorPluginKey = new PluginKey("yjs-cursor");
35964
36073
  const rand = Math.random;
35965
- const oneOf = (arr) => arr[floor(rand() * arr.length)];
36074
+ const oneOf = (arr) => arr[floor$1(rand() * arr.length)];
35966
36075
  const undefinedToNull = (v) => v === void 0 ? null : v;
35967
36076
  class VarStoragePolyfill {
35968
36077
  constructor() {
@@ -35992,12 +36101,12 @@ try {
35992
36101
  } catch (e) {
35993
36102
  }
35994
36103
  const varStorage = _localStorage;
35995
- const isNode = typeof process$1$1 !== "undefined" && process$1$1.release && /node|io\.js/.test(process$1$1.release.name) && Object.prototype.toString.call(typeof process$1$1 !== "undefined" ? process$1$1 : 0) === "[object process]";
35996
- const isBrowser$1$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode;
36104
+ const isNode$1 = typeof process$1$1 !== "undefined" && process$1$1.release && /node|io\.js/.test(process$1$1.release.name) && Object.prototype.toString.call(typeof process$1$1 !== "undefined" ? process$1$1 : 0) === "[object process]";
36105
+ const isBrowser$1$1 = typeof window !== "undefined" && typeof document !== "undefined" && !isNode$1;
35997
36106
  let params;
35998
36107
  const computeParams = () => {
35999
36108
  if (params === void 0) {
36000
- if (isNode) {
36109
+ if (isNode$1) {
36001
36110
  params = create();
36002
36111
  const pargs = process$1$1.argv;
36003
36112
  let currParamName = null;
@@ -36034,12 +36143,12 @@ const computeParams = () => {
36034
36143
  return params;
36035
36144
  };
36036
36145
  const hasParam = (name) => computeParams().has(name);
36037
- const getVariable = (name) => isNode ? undefinedToNull(process$1$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
36146
+ const getVariable = (name) => isNode$1 ? undefinedToNull(process$1$1.env[name.toUpperCase().replaceAll("-", "_")]) : undefinedToNull(varStorage.getItem(name));
36038
36147
  const hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
36039
36148
  hasConf("production");
36040
- const forceColor = isNode && isOneOf(process$1$1.env.FORCE_COLOR, ["true", "1", "2"]);
36149
+ const forceColor = isNode$1 && isOneOf(process$1$1.env.FORCE_COLOR, ["true", "1", "2"]);
36041
36150
  forceColor || !hasParam("--no-colors") && // @todo deprecate --no-colors
36042
- !hasConf("no-color") && (!isNode || process$1$1.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
36151
+ !hasConf("no-color") && (!isNode$1 || process$1$1.stdout.isTTY) && (!isNode$1 || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
36043
36152
  const doc = (
36044
36153
  /** @type {Document} */
36045
36154
  typeof document !== "undefined" ? document : {}
@@ -36548,8 +36657,8 @@ class ProsemirrorBinding {
36548
36657
  new Slice(Fragment.from(fragmentContent), 0, 0)
36549
36658
  );
36550
36659
  if (sel) {
36551
- const clampedAnchor = min$1(max$1(sel.anchor, 0), tr.doc.content.size);
36552
- const clampedHead = min$1(max$1(sel.head, 0), tr.doc.content.size);
36660
+ const clampedAnchor = min$2(max$2(sel.anchor, 0), tr.doc.content.size);
36661
+ const clampedHead = min$2(max$2(sel.head, 0), tr.doc.content.size);
36553
36662
  tr.setSelection(TextSelection.create(tr.doc, clampedAnchor, clampedHead));
36554
36663
  }
36555
36664
  this.prosemirrorView.dispatch(
@@ -36946,7 +37055,7 @@ const computeChildEqualityFactor = (ytype, pnode, meta) => {
36946
37055
  const pChildren = normalizePNodeContent(pnode);
36947
37056
  const pChildCnt = pChildren.length;
36948
37057
  const yChildCnt = yChildren.length;
36949
- const minCnt = min$1(yChildCnt, pChildCnt);
37058
+ const minCnt = min$2(yChildCnt, pChildCnt);
36950
37059
  let left2 = 0;
36951
37060
  let right2 = 0;
36952
37061
  let foundMappedChild = false;
@@ -37058,7 +37167,7 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
37058
37167
  const pChildCnt = pChildren.length;
37059
37168
  const yChildren = yDomFragment.toArray();
37060
37169
  const yChildCnt = yChildren.length;
37061
- const minCnt = min$1(pChildCnt, yChildCnt);
37170
+ const minCnt = min$2(pChildCnt, yChildCnt);
37062
37171
  let left2 = 0;
37063
37172
  let right2 = 0;
37064
37173
  for (; left2 < minCnt; left2++) {
@@ -37431,17 +37540,17 @@ const createDecorations = (state2, awareness, awarenessFilter, createCursor, cre
37431
37540
  ystate.binding.mapping
37432
37541
  );
37433
37542
  if (anchor !== null && head !== null) {
37434
- const maxsize = max$1(state2.doc.content.size - 1, 0);
37435
- anchor = min$1(anchor, maxsize);
37436
- head = min$1(head, maxsize);
37543
+ const maxsize = max$2(state2.doc.content.size - 1, 0);
37544
+ anchor = min$2(anchor, maxsize);
37545
+ head = min$2(head, maxsize);
37437
37546
  decorations.push(
37438
37547
  Decoration.widget(head, () => createCursor(user, clientId), {
37439
37548
  key: clientId + "",
37440
37549
  side: 10
37441
37550
  })
37442
37551
  );
37443
- const from2 = min$1(anchor, head);
37444
- const to = max$1(anchor, head);
37552
+ const from2 = min$2(anchor, head);
37553
+ const to = max$2(anchor, head);
37445
37554
  decorations.push(
37446
37555
  Decoration.inline(from2, to, createSelection(user, clientId), {
37447
37556
  inclusiveEnd: true,
@@ -37895,7 +38004,8 @@ const getTextContentFromNodes = ($from, maxMatch = 500) => {
37895
38004
  const handleDocxPaste = (html, editor, view, plugin2) => {
37896
38005
  const { converter } = editor;
37897
38006
  if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin2);
37898
- const cleanedHtml = convertEmToPt(html);
38007
+ let cleanedHtml = convertEmToPt(html);
38008
+ cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
37899
38009
  const tempDiv = document.createElement("div");
37900
38010
  tempDiv.innerHTML = cleanedHtml;
37901
38011
  const paragraphs = tempDiv.querySelectorAll("p");
@@ -38266,6 +38376,9 @@ const convertEmToPt = (html) => {
38266
38376
  }
38267
38377
  );
38268
38378
  };
38379
+ function cleanHtmlUnnecessaryTags(html) {
38380
+ return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/&nbsp;/gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
38381
+ }
38269
38382
  const _ExtensionService = class _ExtensionService2 {
38270
38383
  constructor(extensions, userExtensions, editor) {
38271
38384
  __privateAdd$1(this, _ExtensionService_instances);
@@ -39063,7 +39176,8 @@ const createHeaderFooterEditor = ({
39063
39176
  appendToBody = true,
39064
39177
  sectionId,
39065
39178
  type: type2,
39066
- availableHeight
39179
+ availableHeight,
39180
+ currentPageNumber
39067
39181
  }) => {
39068
39182
  const parentStyles = editor.converter.getDocumentDefaultStyles();
39069
39183
  const { fontSizePt, typeface } = parentStyles;
@@ -39104,6 +39218,8 @@ const createHeaderFooterEditor = ({
39104
39218
  fonts: editor.options.fonts,
39105
39219
  isHeaderOrFooter: true,
39106
39220
  annotations: true,
39221
+ currentPageNumber,
39222
+ parentEditor: editor,
39107
39223
  onCreate: (evt) => setEditorToolbar(evt, editor),
39108
39224
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
39109
39225
  });
@@ -40247,9 +40363,9 @@ const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
40247
40363
  if (type2.name !== "paragraph" && type2.name !== "fieldAnnotation") return;
40248
40364
  child.children.forEach((inline) => {
40249
40365
  const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
40250
- const isMatchingField = inline.type.name === "fieldAnnotation" && isFieldToDelete;
40251
- const isEmpty2 = inline.childCount === 0;
40252
- if (!isEmpty2 && !isMatchingField) hasOtherNodes = true;
40366
+ const isFieldType = inline.type.name === "fieldAnnotation";
40367
+ const isMatchingField = isFieldType && isFieldToDelete;
40368
+ if (!isFieldType && !isMatchingField) hasOtherNodes = true;
40253
40369
  if (isMatchingField) matchingNodesFound += 1;
40254
40370
  });
40255
40371
  });
@@ -40451,6 +40567,25 @@ function useHighContrastMode() {
40451
40567
  setHighContrastMode
40452
40568
  };
40453
40569
  }
40570
+ const findWordBounds = (doc2, pos) => {
40571
+ const $pos = doc2.resolve(pos);
40572
+ const parent = $pos.parent;
40573
+ const offset2 = $pos.parentOffset;
40574
+ const text = parent.textContent;
40575
+ if (!text) return { from: pos, to: pos };
40576
+ let start2 = offset2, end2 = offset2;
40577
+ while (start2 > 0 && /\w/.test(text[start2 - 1])) start2--;
40578
+ while (end2 < text.length && /\w/.test(text[end2])) end2++;
40579
+ const from2 = $pos.start() + start2;
40580
+ const to = $pos.start() + end2;
40581
+ return { from: from2, to };
40582
+ };
40583
+ const setWordSelection = (view, pos) => {
40584
+ const { state: state2, dispatch } = view;
40585
+ const word = findWordBounds(state2.doc, pos);
40586
+ const tr = state2.tr.setSelection(TextSelection.create(state2.doc, word.from, word.to));
40587
+ dispatch(tr);
40588
+ };
40454
40589
  const _Editor = class _Editor2 extends EventEmitter$1 {
40455
40590
  /**
40456
40591
  * Create a new Editor instance
@@ -40694,6 +40829,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
40694
40829
  __privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
40695
40830
  const doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
40696
40831
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
40832
+ tr.setMeta("replaceContent", true);
40697
40833
  this.view.dispatch(tr);
40698
40834
  }
40699
40835
  /**
@@ -41101,7 +41237,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41101
41237
  * @returns {Object | void} Migration results
41102
41238
  */
41103
41239
  processCollaborationMigrations() {
41104
- console.debug("[checkVersionMigrations] Current editor version", "0.12.36");
41240
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.37-next.2");
41105
41241
  if (!this.options.ydoc) return;
41106
41242
  const metaMap = this.options.ydoc.getMap("meta");
41107
41243
  let docVersion = metaMap.get("version");
@@ -41456,6 +41592,7 @@ createView_fn = function() {
41456
41592
  if (isHeader || isFooter) {
41457
41593
  const eventClone = new event.constructor(event.type);
41458
41594
  event.target.dispatchEvent(eventClone);
41595
+ if (this.options.isHeaderOrFooter && this.options.editable) setWordSelection(view, pos);
41459
41596
  return;
41460
41597
  }
41461
41598
  event.stopPropagation();
@@ -41466,6 +41603,7 @@ createView_fn = function() {
41466
41603
  pm.classList.remove("header-footer-edit");
41467
41604
  pm.setAttribute("aria-readonly", false);
41468
41605
  }
41606
+ setWordSelection(view, pos);
41469
41607
  }
41470
41608
  });
41471
41609
  const newState = this.state.reconfigure({
@@ -46637,7 +46775,7 @@ const Table = Node$1.create({
46637
46775
  if (!borders) return {};
46638
46776
  const style2 = Object.entries(borders).reduce(
46639
46777
  (acc, [key, { size: size2, color }]) => {
46640
- return `${acc}border-${key}: ${size2}px solid ${color || "black"};`;
46778
+ return `${acc}border-${key}: ${Math.ceil(size2)}px solid ${color || "black"};`;
46641
46779
  },
46642
46780
  ""
46643
46781
  );
@@ -46977,8 +47115,8 @@ const TableCell = Node$1.create({
46977
47115
  cellMargins: {
46978
47116
  renderDOM({ cellMargins }) {
46979
47117
  if (!cellMargins) return {};
46980
- const sides = ["top", "right", "bottom", "left"];
46981
- const style2 = sides.map((side) => {
47118
+ const sides2 = ["top", "right", "bottom", "left"];
47119
+ const style2 = sides2.map((side) => {
46982
47120
  const margin = cellMargins?.[side];
46983
47121
  if (margin) return `padding-${side}: ${margin}px;`;
46984
47122
  return "";
@@ -46990,11 +47128,11 @@ const TableCell = Node$1.create({
46990
47128
  default: () => createCellBorders(),
46991
47129
  renderDOM({ borders }) {
46992
47130
  if (!borders) return {};
46993
- const sides = ["top", "right", "bottom", "left"];
46994
- const style2 = sides.map((side) => {
47131
+ const sides2 = ["top", "right", "bottom", "left"];
47132
+ const style2 = sides2.map((side) => {
46995
47133
  const border = borders?.[side];
46996
47134
  if (border && border.val === "none") return `border-${side}: ${border.val};`;
46997
- if (border) return `border-${side}: ${border.size}px solid ${border.color || "black"};`;
47135
+ if (border) return `border-${side}: ${Math.ceil(border.size)}px solid ${border.color || "black"};`;
46998
47136
  return "";
46999
47137
  }).join(" ");
47000
47138
  return { style: style2 };
@@ -47220,7 +47358,7 @@ class FieldAnnotationView {
47220
47358
  }
47221
47359
  _FieldAnnotationView_instances = /* @__PURE__ */ new WeakSet();
47222
47360
  createAnnotation_fn = function({ displayLabel } = {}) {
47223
- let { highlighted } = this.node.attrs;
47361
+ let { highlighted, rawHtml } = this.node.attrs;
47224
47362
  let annotation = document.createElement("span");
47225
47363
  annotation.classList.add(this.annotationClass);
47226
47364
  let content = document.createElement("span");
@@ -47232,7 +47370,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
47232
47370
  }
47233
47371
  annotation.append(content);
47234
47372
  let omitHighlight = highlighted === false;
47235
- let annotationStyle = [`border: 2px solid ${this.borderColor}`, `border-radius: 2px`, `padding: 1px 2px`, `box-sizing: border-box`].join(
47373
+ let styles = [`border: 2px solid ${this.borderColor}`, `border-radius: 2px`, `padding: 1px 2px`, `box-sizing: border-box`];
47374
+ if (rawHtml) {
47375
+ styles.push("font-weight: normal");
47376
+ }
47377
+ let annotationStyle = styles.join(
47236
47378
  "; "
47237
47379
  );
47238
47380
  let mergedAttrs = Attribute2.mergeAttributes(this.htmlAttributes, {
@@ -47787,6 +47929,12 @@ const FieldAnnotation = Node$1.create({
47787
47929
  parseDOM: (elem) => elem.getAttribute("data-bold") === "true",
47788
47930
  renderDOM: (attrs) => {
47789
47931
  if (!attrs.bold) return {};
47932
+ if (attrs.rawHtml) {
47933
+ return {
47934
+ "data-bold": "false",
47935
+ style: "font-weight: normal"
47936
+ };
47937
+ }
47790
47938
  return {
47791
47939
  "data-bold": "true",
47792
47940
  style: "font-weight: bold"
@@ -47797,7 +47945,7 @@ const FieldAnnotation = Node$1.create({
47797
47945
  default: false,
47798
47946
  parseDOM: (elem) => elem.getAttribute("data-italic") === "true",
47799
47947
  renderDOM: (attrs) => {
47800
- if (!attrs.italic) return {};
47948
+ if (!attrs.italic || attrs.rawHtml) return {};
47801
47949
  return {
47802
47950
  "data-italic": "true",
47803
47951
  style: "font-style: italic"
@@ -47808,7 +47956,7 @@ const FieldAnnotation = Node$1.create({
47808
47956
  default: false,
47809
47957
  parseDOM: (elem) => elem.getAttribute("data-underline") === "true",
47810
47958
  renderDOM: (attrs) => {
47811
- if (!attrs.underline) return {};
47959
+ if (!attrs.underline || attrs.rawHtml) return {};
47812
47960
  return {
47813
47961
  "data-underline": "true",
47814
47962
  style: "text-decoration: underline"
@@ -47830,7 +47978,7 @@ const FieldAnnotation = Node$1.create({
47830
47978
  default: null,
47831
47979
  parseDOM: (elem) => elem.getAttribute("data-font-size") || elem.style.fontSize || null,
47832
47980
  renderDOM: (attrs) => {
47833
- if (!attrs.fontSize) return {};
47981
+ if (!attrs.fontSize || attrs.rawHtml) return {};
47834
47982
  let [value, unit] = parseSizeUnit(attrs.fontSize);
47835
47983
  if (Number.isNaN(value)) return {};
47836
47984
  unit = unit ? unit : "pt";
@@ -48472,10 +48620,7 @@ const ImagePositionPlugin = ({ editor }) => {
48472
48620
  if (shouldUpdate) {
48473
48621
  shouldUpdate = false;
48474
48622
  const decorations = getImagePositionDecorations(lastState, view3);
48475
- const updateTransaction = view3.state.tr.setMeta(
48476
- ImagePositionPluginKey,
48477
- { decorations }
48478
- );
48623
+ const updateTransaction = view3.state.tr.setMeta(ImagePositionPluginKey, { decorations });
48479
48624
  view3.dispatch(updateTransaction);
48480
48625
  }
48481
48626
  if (pagination?.isReadyToInit) {
@@ -48607,16 +48752,16 @@ const Image = Node$1.create({
48607
48752
  default: {},
48608
48753
  renderDOM: ({ size: size2 }) => {
48609
48754
  let style2 = "";
48610
- let { width, height } = size2 ?? {};
48755
+ const { width, height } = size2 ?? {};
48611
48756
  if (width) style2 += `width: ${width}px;`;
48612
- if (height) style2 += `height: auto;`;
48757
+ if (height) style2 += "height: auto;";
48613
48758
  return { style: style2 };
48614
48759
  }
48615
48760
  },
48616
48761
  padding: {
48617
48762
  default: {},
48618
48763
  renderDOM: ({ padding, marginOffset }) => {
48619
- let { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
48764
+ const { left: left2 = 0, top: top2 = 0, bottom: bottom2 = 0, right: right2 = 0 } = padding ?? {};
48620
48765
  let style2 = "";
48621
48766
  if (left2 && !marginOffset?.left) style2 += `margin-left: ${left2}px;`;
48622
48767
  if (top2 && !marginOffset?.top) style2 += `margin-top: ${top2}px;`;
@@ -48628,7 +48773,7 @@ const Image = Node$1.create({
48628
48773
  marginOffset: {
48629
48774
  default: {},
48630
48775
  renderDOM: ({ marginOffset }) => {
48631
- let { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
48776
+ const { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
48632
48777
  let style2 = "";
48633
48778
  if (left2) style2 += `margin-left: ${left2}px;`;
48634
48779
  if (top2) style2 += `margin-top: ${top2}px;`;
@@ -48669,6 +48814,136 @@ const Image = Node$1.create({
48669
48814
  return [ImagePlaceholderPlugin(), ImagePositionPlugin({ editor: this.editor })];
48670
48815
  }
48671
48816
  });
48817
+ const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
48818
+ const getFileOpener = () => {
48819
+ let fileInput = document.createElement("input");
48820
+ fileInput.type = "file";
48821
+ let acceptTypes = ACCEPT_IMAGE_TYPES;
48822
+ fileInput.accept = acceptTypes.join(",");
48823
+ const openFile = () => {
48824
+ return new Promise((resolve, reject) => {
48825
+ fileInput.onchange = async () => {
48826
+ const files = fileInput.files;
48827
+ if (!files) return resolve(null);
48828
+ const file = files.item(0);
48829
+ if (!file) return resolve(null);
48830
+ return resolve({ file });
48831
+ };
48832
+ fileInput.oncancel = () => resolve(null);
48833
+ fileInput.onerror = reject;
48834
+ fileInput.click();
48835
+ });
48836
+ };
48837
+ return openFile;
48838
+ };
48839
+ const handleImageUpload = (file) => {
48840
+ return new Promise((resolve, reject) => {
48841
+ let reader = new FileReader();
48842
+ reader.onload = (event) => resolve(event.target.result);
48843
+ reader.onerror = reject;
48844
+ setTimeout(() => reader.readAsDataURL(file), 250);
48845
+ });
48846
+ };
48847
+ const processUploadedImage = (fileData, editor) => {
48848
+ return new Promise((resolve, reject) => {
48849
+ const img = new window.Image();
48850
+ img.onload = () => {
48851
+ const canvas = document.createElement("canvas");
48852
+ const { width, height } = getAllowedImageDimensions(img.width, img.height, editor);
48853
+ canvas.width = width;
48854
+ canvas.height = height;
48855
+ const ctx2 = canvas.getContext("2d");
48856
+ ctx2.drawImage(img, 0, 0, width, height);
48857
+ if (typeof fileData === "string") {
48858
+ const resizedBase64 = canvas.toDataURL();
48859
+ resolve(resizedBase64);
48860
+ } else {
48861
+ canvas.toBlob((blob) => {
48862
+ const updatedFile = new File([blob], fileData.name, {
48863
+ type: fileData.type,
48864
+ lastModified: Date.now()
48865
+ });
48866
+ resolve({ file: updatedFile, width, height });
48867
+ });
48868
+ }
48869
+ };
48870
+ img.onerror = (error) => reject(error);
48871
+ img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
48872
+ });
48873
+ };
48874
+ const getAllowedImageDimensions = (width, height, editor) => {
48875
+ const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
48876
+ if (!maxWidth || !maxHeight) return { width, height };
48877
+ let adjustedWidth = width;
48878
+ let adjustedHeight = height;
48879
+ const aspectRatio = width / height;
48880
+ if (height > maxHeight) {
48881
+ adjustedHeight = maxHeight;
48882
+ adjustedWidth = Math.round(maxHeight * aspectRatio);
48883
+ }
48884
+ if (adjustedWidth > maxWidth) {
48885
+ adjustedWidth = maxWidth;
48886
+ adjustedHeight = Math.round(maxWidth / aspectRatio);
48887
+ }
48888
+ return { width: adjustedWidth, height: adjustedHeight };
48889
+ };
48890
+ const startImageUpload = async ({ editor, view, file }) => {
48891
+ let imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
48892
+ let fileSizeMb = (file.size / (1024 * 1024)).toFixed(4);
48893
+ if (fileSizeMb > 5) {
48894
+ window.alert("Image size must be less than 5MB");
48895
+ return;
48896
+ }
48897
+ let width;
48898
+ let height;
48899
+ try {
48900
+ const processedImageResult = await processUploadedImage(file, editor);
48901
+ width = processedImageResult.width;
48902
+ height = processedImageResult.height;
48903
+ file = processedImageResult.file;
48904
+ } catch (err) {
48905
+ console.warn("Error processing image:", err);
48906
+ return;
48907
+ }
48908
+ let id = {};
48909
+ let { tr, schema } = view.state;
48910
+ if (!tr.selection.empty) {
48911
+ tr.deleteSelection();
48912
+ }
48913
+ let imageMeta = {
48914
+ type: "add",
48915
+ pos: tr.selection.from,
48916
+ id
48917
+ };
48918
+ tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
48919
+ view.dispatch(tr);
48920
+ imageUploadHandler(file).then(
48921
+ (url) => {
48922
+ let fileName = file.name.replace(" ", "_");
48923
+ let placeholderPos = findPlaceholder(view.state, id);
48924
+ if (placeholderPos == null) {
48925
+ return;
48926
+ }
48927
+ let removeMeta = { type: "remove", id };
48928
+ let mediaPath = `word/media/${fileName}`;
48929
+ let imageNode = schema.nodes.image.create({
48930
+ src: mediaPath,
48931
+ size: { width, height }
48932
+ });
48933
+ editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
48934
+ if (editor.options.ydoc) {
48935
+ editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
48936
+ }
48937
+ view.dispatch(
48938
+ view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
48939
+ );
48940
+ },
48941
+ () => {
48942
+ let removeMeta = { type: "remove", id };
48943
+ view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
48944
+ }
48945
+ );
48946
+ };
48672
48947
  const BookmarkStart = Node$1.create({
48673
48948
  name: "bookmarkStart",
48674
48949
  group: "inline",
@@ -48749,32 +49024,89 @@ const PageNumber = Node$1.create({
48749
49024
  name: "page-number",
48750
49025
  group: "inline",
48751
49026
  inline: true,
48752
- content: "text*",
49027
+ atom: true,
49028
+ selectable: false,
49029
+ draggable: false,
49030
+ selectable: false,
49031
+ defining: true,
49032
+ content: "",
48753
49033
  addOptions() {
48754
49034
  return {
48755
49035
  htmlAttributes: {
49036
+ contenteditable: false,
48756
49037
  "data-id": "auto-page-number",
48757
49038
  "aria-label": "Page number node"
48758
49039
  }
48759
49040
  };
48760
49041
  },
49042
+ addAttributes() {
49043
+ return {
49044
+ marksAsAttrs: {
49045
+ default: null,
49046
+ rendered: false
49047
+ }
49048
+ };
49049
+ },
49050
+ addNodeView() {
49051
+ return ({ node: node2, editor, getPos, decorations }) => {
49052
+ const htmlAttributes = this.options.htmlAttributes;
49053
+ return new AutoPageNumberNodeView(node2, getPos, decorations, editor, htmlAttributes);
49054
+ };
49055
+ },
48761
49056
  parseDOM() {
48762
49057
  return [{ tag: 'span[data-id="auto-page-number"' }];
48763
49058
  },
48764
49059
  renderDOM({ htmlAttributes }) {
48765
- return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
49060
+ return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
49061
+ },
49062
+ addCommands() {
49063
+ return {
49064
+ addAutoPageNumber: () => ({ tr, dispatch, state: state2, editor }) => {
49065
+ const { options: options2 } = editor;
49066
+ if (!options2.isHeaderOrFooter) return false;
49067
+ const { schema } = state2;
49068
+ const pageNumberType = schema?.nodes?.["page-number"];
49069
+ if (!pageNumberType) return false;
49070
+ const pageNumberNodeJSON = { type: "page-number" };
49071
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
49072
+ if (dispatch) {
49073
+ tr.replaceSelectionWith(pageNumberNode, false);
49074
+ tr.setMeta("forceUpdatePagination", true);
49075
+ }
49076
+ return true;
49077
+ }
49078
+ };
49079
+ },
49080
+ addShortcuts() {
49081
+ return {
49082
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
49083
+ };
48766
49084
  }
48767
49085
  });
48768
49086
  const TotalPageCount = Node$1.create({
48769
49087
  name: "total-page-number",
48770
49088
  group: "inline",
48771
49089
  inline: true,
49090
+ atom: true,
49091
+ selectable: false,
49092
+ draggable: false,
49093
+ selectable: false,
48772
49094
  content: "text*",
48773
49095
  addOptions() {
48774
49096
  return {
48775
49097
  htmlAttributes: {
49098
+ contenteditable: false,
48776
49099
  "data-id": "auto-total-pages",
48777
- "aria-label": "Total page count node"
49100
+ "aria-label": "Total page count node",
49101
+ "class": "sd-editor-auto-total-pages"
49102
+ }
49103
+ };
49104
+ },
49105
+ addAttributes() {
49106
+ return {
49107
+ marksAsAttrs: {
49108
+ default: null,
49109
+ rendered: false
48778
49110
  }
48779
49111
  };
48780
49112
  },
@@ -48783,8 +49115,139 @@ const TotalPageCount = Node$1.create({
48783
49115
  },
48784
49116
  renderDOM({ htmlAttributes }) {
48785
49117
  return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
49118
+ },
49119
+ addCommands() {
49120
+ return {
49121
+ addTotalPageCount: () => ({ tr, dispatch, state: state2, editor }) => {
49122
+ const { options: options2 } = editor;
49123
+ if (!options2.isHeaderOrFooter) return false;
49124
+ const { schema } = state2;
49125
+ const pageNumberType = schema.nodes?.["total-page-number"];
49126
+ if (!pageNumberType) return false;
49127
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
49128
+ const pageNumberNode = {
49129
+ type: "total-page-number",
49130
+ content: [{ type: "text", text: String(currentPages) }]
49131
+ };
49132
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
49133
+ if (dispatch) {
49134
+ tr.replaceSelectionWith(pageNode, false);
49135
+ }
49136
+ return true;
49137
+ }
49138
+ };
49139
+ },
49140
+ addShortcuts() {
49141
+ return {
49142
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
49143
+ };
48786
49144
  }
48787
49145
  });
49146
+ class AutoPageNumberNodeView {
49147
+ constructor(node2, getPos, decorations, editor, htmlAttributes = {}) {
49148
+ __privateAdd$1(this, _AutoPageNumberNodeView_instances);
49149
+ this.node = node2;
49150
+ this.editor = editor;
49151
+ this.view = editor.view;
49152
+ this.getPos = getPos;
49153
+ this.editor = editor;
49154
+ this.dom = __privateMethod$1(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node2, htmlAttributes);
49155
+ }
49156
+ update(node2) {
49157
+ if (node2.type !== this.node.type) return false;
49158
+ this.node = node2;
49159
+ return true;
49160
+ }
49161
+ }
49162
+ _AutoPageNumberNodeView_instances = /* @__PURE__ */ new WeakSet();
49163
+ renderDom_fn = function(node2, htmlAttributes) {
49164
+ const pageText = this.editor.options.currentPageNumber || "1";
49165
+ const content = document.createTextNode(String(pageText));
49166
+ const nodeContent = document.createElement("span");
49167
+ nodeContent.className = "sd-editor-auto-page-number";
49168
+ nodeContent.setAttribute("data-id", "auto-page-number");
49169
+ nodeContent.setAttribute("aria-label", "Page number node");
49170
+ const currentPos = this.getPos();
49171
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
49172
+ __privateMethod$1(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
49173
+ Object.assign(nodeContent.style, styles);
49174
+ nodeContent.appendChild(content);
49175
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
49176
+ if (value) nodeContent.setAttribute(key, value);
49177
+ });
49178
+ return nodeContent;
49179
+ };
49180
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
49181
+ setTimeout(() => {
49182
+ const { state: state2 } = this.editor;
49183
+ const { dispatch } = this.view;
49184
+ const node2 = state2.doc.nodeAt(pos);
49185
+ if (!node2) return;
49186
+ const currentMarks = node2.attrs.marksAsAttrs || [];
49187
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
49188
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
49189
+ if (isEqual) return;
49190
+ const newAttrs = {
49191
+ ...node2.attrs,
49192
+ marksAsAttrs: newMarks
49193
+ };
49194
+ const tr = state2.tr.setNodeMarkup(pos, void 0, newAttrs);
49195
+ dispatch(tr);
49196
+ }, 0);
49197
+ };
49198
+ const getMarksFromNeighbors = (currentPos, view) => {
49199
+ const $pos = view.state.doc.resolve(currentPos);
49200
+ const styles = {};
49201
+ const marks = [];
49202
+ const before = $pos.nodeBefore;
49203
+ if (before) {
49204
+ Object.assign(styles, processMarks(before.marks));
49205
+ marks.push(...before.marks);
49206
+ }
49207
+ const after = $pos.nodeAfter;
49208
+ if (after) {
49209
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
49210
+ marks.push(...after.marks);
49211
+ }
49212
+ return {
49213
+ styles,
49214
+ marks
49215
+ };
49216
+ };
49217
+ const processMarks = (marks) => {
49218
+ const styles = {};
49219
+ marks.forEach((mark) => {
49220
+ const { type: type2, attrs } = mark;
49221
+ switch (type2.name) {
49222
+ case "textStyle":
49223
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
49224
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
49225
+ if (attrs.color) styles["color"] = attrs.color;
49226
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
49227
+ break;
49228
+ case "bold":
49229
+ styles["font-weight"] = "bold";
49230
+ break;
49231
+ case "italic":
49232
+ styles["font-style"] = "italic";
49233
+ break;
49234
+ case "underline":
49235
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
49236
+ break;
49237
+ case "strike":
49238
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
49239
+ break;
49240
+ default:
49241
+ if (attrs?.style) {
49242
+ Object.entries(attrs.style).forEach(([key, value]) => {
49243
+ styles[key] = value;
49244
+ });
49245
+ }
49246
+ break;
49247
+ }
49248
+ });
49249
+ return styles;
49250
+ };
48788
49251
  const ShapeContainer = Node$1.create({
48789
49252
  name: "shapeContainer",
48790
49253
  group: "block",
@@ -49797,10 +50260,10 @@ var beforeWrite = "beforeWrite";
49797
50260
  var write = "write";
49798
50261
  var afterWrite = "afterWrite";
49799
50262
  var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
49800
- function getNodeName(element) {
50263
+ function getNodeName$1(element) {
49801
50264
  return element ? (element.nodeName || "").toLowerCase() : null;
49802
50265
  }
49803
- function getWindow(node2) {
50266
+ function getWindow$1(node2) {
49804
50267
  if (node2 == null) {
49805
50268
  return window;
49806
50269
  }
@@ -49810,19 +50273,19 @@ function getWindow(node2) {
49810
50273
  }
49811
50274
  return node2;
49812
50275
  }
49813
- function isElement$1(node2) {
49814
- var OwnElement = getWindow(node2).Element;
50276
+ function isElement$2(node2) {
50277
+ var OwnElement = getWindow$1(node2).Element;
49815
50278
  return node2 instanceof OwnElement || node2 instanceof Element;
49816
50279
  }
49817
50280
  function isHTMLElement$1(node2) {
49818
- var OwnElement = getWindow(node2).HTMLElement;
50281
+ var OwnElement = getWindow$1(node2).HTMLElement;
49819
50282
  return node2 instanceof OwnElement || node2 instanceof HTMLElement;
49820
50283
  }
49821
- function isShadowRoot(node2) {
50284
+ function isShadowRoot$1(node2) {
49822
50285
  if (typeof ShadowRoot === "undefined") {
49823
50286
  return false;
49824
50287
  }
49825
- var OwnElement = getWindow(node2).ShadowRoot;
50288
+ var OwnElement = getWindow$1(node2).ShadowRoot;
49826
50289
  return node2 instanceof OwnElement || node2 instanceof ShadowRoot;
49827
50290
  }
49828
50291
  function applyStyles(_ref) {
@@ -49831,7 +50294,7 @@ function applyStyles(_ref) {
49831
50294
  var style2 = state2.styles[name] || {};
49832
50295
  var attributes = state2.attributes[name] || {};
49833
50296
  var element = state2.elements[name];
49834
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
50297
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
49835
50298
  return;
49836
50299
  }
49837
50300
  Object.assign(element.style, style2);
@@ -49873,7 +50336,7 @@ function effect$2(_ref2) {
49873
50336
  style22[property2] = "";
49874
50337
  return style22;
49875
50338
  }, {});
49876
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
50339
+ if (!isHTMLElement$1(element) || !getNodeName$1(element)) {
49877
50340
  return;
49878
50341
  }
49879
50342
  Object.assign(element.style, style2);
@@ -49894,9 +50357,9 @@ const applyStyles$1 = {
49894
50357
  function getBasePlacement$1(placement) {
49895
50358
  return placement.split("-")[0];
49896
50359
  }
49897
- var max = Math.max;
49898
- var min = Math.min;
49899
- var round = Math.round;
50360
+ var max$1 = Math.max;
50361
+ var min$1 = Math.min;
50362
+ var round$1 = Math.round;
49900
50363
  function getUAString() {
49901
50364
  var uaData = navigator.userAgentData;
49902
50365
  if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
@@ -49909,7 +50372,7 @@ function getUAString() {
49909
50372
  function isLayoutViewport() {
49910
50373
  return !/^((?!chrome|android).)*safari/i.test(getUAString());
49911
50374
  }
49912
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
50375
+ function getBoundingClientRect$1(element, includeScale, isFixedStrategy) {
49913
50376
  if (includeScale === void 0) {
49914
50377
  includeScale = false;
49915
50378
  }
@@ -49920,10 +50383,10 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
49920
50383
  var scaleX = 1;
49921
50384
  var scaleY = 1;
49922
50385
  if (includeScale && isHTMLElement$1(element)) {
49923
- scaleX = element.offsetWidth > 0 ? round(clientRect2.width) / element.offsetWidth || 1 : 1;
49924
- scaleY = element.offsetHeight > 0 ? round(clientRect2.height) / element.offsetHeight || 1 : 1;
50386
+ scaleX = element.offsetWidth > 0 ? round$1(clientRect2.width) / element.offsetWidth || 1 : 1;
50387
+ scaleY = element.offsetHeight > 0 ? round$1(clientRect2.height) / element.offsetHeight || 1 : 1;
49925
50388
  }
49926
- var _ref = isElement$1(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
50389
+ var _ref = isElement$2(element) ? getWindow$1(element) : window, visualViewport = _ref.visualViewport;
49927
50390
  var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
49928
50391
  var x = (clientRect2.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
49929
50392
  var y = (clientRect2.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
@@ -49941,7 +50404,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
49941
50404
  };
49942
50405
  }
49943
50406
  function getLayoutRect(element) {
49944
- var clientRect2 = getBoundingClientRect(element);
50407
+ var clientRect2 = getBoundingClientRect$1(element);
49945
50408
  var width = element.offsetWidth;
49946
50409
  var height = element.offsetHeight;
49947
50410
  if (Math.abs(clientRect2.width - width) <= 1) {
@@ -49961,7 +50424,7 @@ function contains$1(parent, child) {
49961
50424
  var rootNode = child.getRootNode && child.getRootNode();
49962
50425
  if (parent.contains(child)) {
49963
50426
  return true;
49964
- } else if (rootNode && isShadowRoot(rootNode)) {
50427
+ } else if (rootNode && isShadowRoot$1(rootNode)) {
49965
50428
  var next = child;
49966
50429
  do {
49967
50430
  if (next && parent.isSameNode(next)) {
@@ -49972,20 +50435,20 @@ function contains$1(parent, child) {
49972
50435
  }
49973
50436
  return false;
49974
50437
  }
49975
- function getComputedStyle$1(element) {
49976
- return getWindow(element).getComputedStyle(element);
50438
+ function getComputedStyle$2(element) {
50439
+ return getWindow$1(element).getComputedStyle(element);
49977
50440
  }
49978
- function isTableElement(element) {
49979
- return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
50441
+ function isTableElement$1(element) {
50442
+ return ["table", "td", "th"].indexOf(getNodeName$1(element)) >= 0;
49980
50443
  }
49981
- function getDocumentElement(element) {
49982
- return ((isElement$1(element) ? element.ownerDocument : (
50444
+ function getDocumentElement$1(element) {
50445
+ return ((isElement$2(element) ? element.ownerDocument : (
49983
50446
  // $FlowFixMe[prop-missing]
49984
50447
  element.document
49985
50448
  )) || window.document).documentElement;
49986
50449
  }
49987
50450
  function getParentNode$1(element) {
49988
- if (getNodeName(element) === "html") {
50451
+ if (getNodeName$1(element) === "html") {
49989
50452
  return element;
49990
50453
  }
49991
50454
  return (
@@ -49994,33 +50457,33 @@ function getParentNode$1(element) {
49994
50457
  // $FlowFixMe[prop-missing]
49995
50458
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
49996
50459
  element.parentNode || // DOM Element detected
49997
- (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
50460
+ (isShadowRoot$1(element) ? element.host : null) || // ShadowRoot detected
49998
50461
  // $FlowFixMe[incompatible-call]: HTMLElement is a Node
49999
- getDocumentElement(element)
50462
+ getDocumentElement$1(element)
50000
50463
  );
50001
50464
  }
50002
- function getTrueOffsetParent(element) {
50465
+ function getTrueOffsetParent$1(element) {
50003
50466
  if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
50004
- getComputedStyle$1(element).position === "fixed") {
50467
+ getComputedStyle$2(element).position === "fixed") {
50005
50468
  return null;
50006
50469
  }
50007
50470
  return element.offsetParent;
50008
50471
  }
50009
- function getContainingBlock(element) {
50472
+ function getContainingBlock$1(element) {
50010
50473
  var isFirefox = /firefox/i.test(getUAString());
50011
50474
  var isIE = /Trident/i.test(getUAString());
50012
50475
  if (isIE && isHTMLElement$1(element)) {
50013
- var elementCss = getComputedStyle$1(element);
50476
+ var elementCss = getComputedStyle$2(element);
50014
50477
  if (elementCss.position === "fixed") {
50015
50478
  return null;
50016
50479
  }
50017
50480
  }
50018
50481
  var currentNode = getParentNode$1(element);
50019
- if (isShadowRoot(currentNode)) {
50482
+ if (isShadowRoot$1(currentNode)) {
50020
50483
  currentNode = currentNode.host;
50021
50484
  }
50022
- while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
50023
- var css = getComputedStyle$1(currentNode);
50485
+ while (isHTMLElement$1(currentNode) && ["html", "body"].indexOf(getNodeName$1(currentNode)) < 0) {
50486
+ var css = getComputedStyle$2(currentNode);
50024
50487
  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") {
50025
50488
  return currentNode;
50026
50489
  } else {
@@ -50029,22 +50492,22 @@ function getContainingBlock(element) {
50029
50492
  }
50030
50493
  return null;
50031
50494
  }
50032
- function getOffsetParent(element) {
50033
- var window2 = getWindow(element);
50034
- var offsetParent = getTrueOffsetParent(element);
50035
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
50036
- offsetParent = getTrueOffsetParent(offsetParent);
50495
+ function getOffsetParent$1(element) {
50496
+ var window2 = getWindow$1(element);
50497
+ var offsetParent = getTrueOffsetParent$1(element);
50498
+ while (offsetParent && isTableElement$1(offsetParent) && getComputedStyle$2(offsetParent).position === "static") {
50499
+ offsetParent = getTrueOffsetParent$1(offsetParent);
50037
50500
  }
50038
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
50501
+ if (offsetParent && (getNodeName$1(offsetParent) === "html" || getNodeName$1(offsetParent) === "body" && getComputedStyle$2(offsetParent).position === "static")) {
50039
50502
  return window2;
50040
50503
  }
50041
- return offsetParent || getContainingBlock(element) || window2;
50504
+ return offsetParent || getContainingBlock$1(element) || window2;
50042
50505
  }
50043
50506
  function getMainAxisFromPlacement(placement) {
50044
50507
  return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
50045
50508
  }
50046
- function within(min$12, value, max$12) {
50047
- return max(min$12, min(value, max$12));
50509
+ function within(min2, value, max2) {
50510
+ return max$1(min2, min$1(value, max2));
50048
50511
  }
50049
50512
  function withinMaxClamp(min2, value, max2) {
50050
50513
  var v = within(min2, value, max2);
@@ -50091,7 +50554,7 @@ function arrow(_ref) {
50091
50554
  var maxProp = axis === "y" ? bottom : right;
50092
50555
  var endDiff = state2.rects.reference[len] + state2.rects.reference[axis] - popperOffsets2[axis] - state2.rects.popper[len];
50093
50556
  var startDiff = popperOffsets2[axis] - state2.rects.reference[axis];
50094
- var arrowOffsetParent = getOffsetParent(arrowElement);
50557
+ var arrowOffsetParent = getOffsetParent$1(arrowElement);
50095
50558
  var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
50096
50559
  var centerToReference = endDiff / 2 - startDiff / 2;
50097
50560
  var min2 = paddingObject[minProp];
@@ -50140,8 +50603,8 @@ function roundOffsetsByDPR(_ref, win) {
50140
50603
  var x = _ref.x, y = _ref.y;
50141
50604
  var dpr = win.devicePixelRatio || 1;
50142
50605
  return {
50143
- x: round(x * dpr) / dpr || 0,
50144
- y: round(y * dpr) / dpr || 0
50606
+ x: round$1(x * dpr) / dpr || 0,
50607
+ y: round$1(y * dpr) / dpr || 0
50145
50608
  };
50146
50609
  }
50147
50610
  function mapToStyles(_ref2) {
@@ -50163,12 +50626,12 @@ function mapToStyles(_ref2) {
50163
50626
  var sideY = top;
50164
50627
  var win = window;
50165
50628
  if (adaptive) {
50166
- var offsetParent = getOffsetParent(popper2);
50629
+ var offsetParent = getOffsetParent$1(popper2);
50167
50630
  var heightProp = "clientHeight";
50168
50631
  var widthProp = "clientWidth";
50169
- if (offsetParent === getWindow(popper2)) {
50170
- offsetParent = getDocumentElement(popper2);
50171
- if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
50632
+ if (offsetParent === getWindow$1(popper2)) {
50633
+ offsetParent = getDocumentElement$1(popper2);
50634
+ if (getComputedStyle$2(offsetParent).position !== "static" && position === "absolute") {
50172
50635
  heightProp = "scrollHeight";
50173
50636
  widthProp = "scrollWidth";
50174
50637
  }
@@ -50199,7 +50662,7 @@ function mapToStyles(_ref2) {
50199
50662
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
50200
50663
  x,
50201
50664
  y
50202
- }, getWindow(popper2)) : {
50665
+ }, getWindow$1(popper2)) : {
50203
50666
  x,
50204
50667
  y
50205
50668
  };
@@ -50255,7 +50718,7 @@ var passive = {
50255
50718
  function effect(_ref) {
50256
50719
  var state2 = _ref.state, instance = _ref.instance, options2 = _ref.options;
50257
50720
  var _options$scroll = options2.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options2.resize, resize = _options$resize === void 0 ? true : _options$resize;
50258
- var window2 = getWindow(state2.elements.popper);
50721
+ var window2 = getWindow$1(state2.elements.popper);
50259
50722
  var scrollParents = [].concat(state2.scrollParents.reference, state2.scrollParents.popper);
50260
50723
  if (scroll) {
50261
50724
  scrollParents.forEach(function(scrollParent) {
@@ -50306,7 +50769,7 @@ function getOppositeVariationPlacement(placement) {
50306
50769
  });
50307
50770
  }
50308
50771
  function getWindowScroll(node2) {
50309
- var win = getWindow(node2);
50772
+ var win = getWindow$1(node2);
50310
50773
  var scrollLeft = win.pageXOffset;
50311
50774
  var scrollTop = win.pageYOffset;
50312
50775
  return {
@@ -50314,12 +50777,12 @@ function getWindowScroll(node2) {
50314
50777
  scrollTop
50315
50778
  };
50316
50779
  }
50317
- function getWindowScrollBarX(element) {
50318
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
50780
+ function getWindowScrollBarX$1(element) {
50781
+ return getBoundingClientRect$1(getDocumentElement$1(element)).left + getWindowScroll(element).scrollLeft;
50319
50782
  }
50320
- function getViewportRect(element, strategy) {
50321
- var win = getWindow(element);
50322
- var html = getDocumentElement(element);
50783
+ function getViewportRect$1(element, strategy) {
50784
+ var win = getWindow$1(element);
50785
+ var html = getDocumentElement$1(element);
50323
50786
  var visualViewport = win.visualViewport;
50324
50787
  var width = html.clientWidth;
50325
50788
  var height = html.clientHeight;
@@ -50337,21 +50800,21 @@ function getViewportRect(element, strategy) {
50337
50800
  return {
50338
50801
  width,
50339
50802
  height,
50340
- x: x + getWindowScrollBarX(element),
50803
+ x: x + getWindowScrollBarX$1(element),
50341
50804
  y
50342
50805
  };
50343
50806
  }
50344
- function getDocumentRect(element) {
50807
+ function getDocumentRect$1(element) {
50345
50808
  var _element$ownerDocumen;
50346
- var html = getDocumentElement(element);
50809
+ var html = getDocumentElement$1(element);
50347
50810
  var winScroll = getWindowScroll(element);
50348
50811
  var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
50349
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
50350
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
50351
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
50812
+ var width = max$1(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
50813
+ var height = max$1(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
50814
+ var x = -winScroll.scrollLeft + getWindowScrollBarX$1(element);
50352
50815
  var y = -winScroll.scrollTop;
50353
- if (getComputedStyle$1(body || html).direction === "rtl") {
50354
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
50816
+ if (getComputedStyle$2(body || html).direction === "rtl") {
50817
+ x += max$1(html.clientWidth, body ? body.clientWidth : 0) - width;
50355
50818
  }
50356
50819
  return {
50357
50820
  width,
@@ -50361,11 +50824,11 @@ function getDocumentRect(element) {
50361
50824
  };
50362
50825
  }
50363
50826
  function isScrollParent(element) {
50364
- var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
50827
+ var _getComputedStyle = getComputedStyle$2(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
50365
50828
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
50366
50829
  }
50367
50830
  function getScrollParent$1(node2) {
50368
- if (["html", "body", "#document"].indexOf(getNodeName(node2)) >= 0) {
50831
+ if (["html", "body", "#document"].indexOf(getNodeName$1(node2)) >= 0) {
50369
50832
  return node2.ownerDocument.body;
50370
50833
  }
50371
50834
  if (isHTMLElement$1(node2) && isScrollParent(node2)) {
@@ -50380,7 +50843,7 @@ function listScrollParents(element, list) {
50380
50843
  }
50381
50844
  var scrollParent = getScrollParent$1(element);
50382
50845
  var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
50383
- var win = getWindow(scrollParent);
50846
+ var win = getWindow$1(scrollParent);
50384
50847
  var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
50385
50848
  var updatedList = list.concat(target);
50386
50849
  return isBody ? updatedList : (
@@ -50388,7 +50851,7 @@ function listScrollParents(element, list) {
50388
50851
  updatedList.concat(listScrollParents(getParentNode$1(target)))
50389
50852
  );
50390
50853
  }
50391
- function rectToClientRect(rect) {
50854
+ function rectToClientRect$1(rect) {
50392
50855
  return Object.assign({}, rect, {
50393
50856
  left: rect.x,
50394
50857
  top: rect.y,
@@ -50396,8 +50859,8 @@ function rectToClientRect(rect) {
50396
50859
  bottom: rect.y + rect.height
50397
50860
  });
50398
50861
  }
50399
- function getInnerBoundingClientRect(element, strategy) {
50400
- var rect = getBoundingClientRect(element, false, strategy === "fixed");
50862
+ function getInnerBoundingClientRect$1(element, strategy) {
50863
+ var rect = getBoundingClientRect$1(element, false, strategy === "fixed");
50401
50864
  rect.top = rect.top + element.clientTop;
50402
50865
  rect.left = rect.left + element.clientLeft;
50403
50866
  rect.bottom = rect.top + element.clientHeight;
@@ -50409,29 +50872,29 @@ function getInnerBoundingClientRect(element, strategy) {
50409
50872
  return rect;
50410
50873
  }
50411
50874
  function getClientRectFromMixedType(element, clippingParent, strategy) {
50412
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
50875
+ return clippingParent === viewport ? rectToClientRect$1(getViewportRect$1(element, strategy)) : isElement$2(clippingParent) ? getInnerBoundingClientRect$1(clippingParent, strategy) : rectToClientRect$1(getDocumentRect$1(getDocumentElement$1(element)));
50413
50876
  }
50414
50877
  function getClippingParents(element) {
50415
50878
  var clippingParents2 = listScrollParents(getParentNode$1(element));
50416
- var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
50417
- var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent(element) : element;
50418
- if (!isElement$1(clipperElement)) {
50879
+ var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$2(element).position) >= 0;
50880
+ var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent$1(element) : element;
50881
+ if (!isElement$2(clipperElement)) {
50419
50882
  return [];
50420
50883
  }
50421
50884
  return clippingParents2.filter(function(clippingParent) {
50422
- return isElement$1(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
50885
+ return isElement$2(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName$1(clippingParent) !== "body";
50423
50886
  });
50424
50887
  }
50425
- function getClippingRect(element, boundary, rootBoundary, strategy) {
50888
+ function getClippingRect$1(element, boundary, rootBoundary, strategy) {
50426
50889
  var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
50427
50890
  var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
50428
50891
  var firstClippingParent = clippingParents2[0];
50429
50892
  var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
50430
50893
  var rect = getClientRectFromMixedType(element, clippingParent, strategy);
50431
- accRect.top = max(rect.top, accRect.top);
50432
- accRect.right = min(rect.right, accRect.right);
50433
- accRect.bottom = min(rect.bottom, accRect.bottom);
50434
- accRect.left = max(rect.left, accRect.left);
50894
+ accRect.top = max$1(rect.top, accRect.top);
50895
+ accRect.right = min$1(rect.right, accRect.right);
50896
+ accRect.bottom = min$1(rect.bottom, accRect.bottom);
50897
+ accRect.left = max$1(rect.left, accRect.left);
50435
50898
  return accRect;
50436
50899
  }, getClientRectFromMixedType(element, firstClippingParent, strategy));
50437
50900
  clippingRect.width = clippingRect.right - clippingRect.left;
@@ -50492,7 +50955,7 @@ function computeOffsets(_ref) {
50492
50955
  }
50493
50956
  return offsets;
50494
50957
  }
50495
- function detectOverflow(state2, options2) {
50958
+ function detectOverflow$1(state2, options2) {
50496
50959
  if (options2 === void 0) {
50497
50960
  options2 = {};
50498
50961
  }
@@ -50501,14 +50964,14 @@ function detectOverflow(state2, options2) {
50501
50964
  var altContext = elementContext === popper ? reference : popper;
50502
50965
  var popperRect = state2.rects.popper;
50503
50966
  var element = state2.elements[altBoundary ? altContext : elementContext];
50504
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state2.elements.popper), boundary, rootBoundary, strategy);
50505
- var referenceClientRect = getBoundingClientRect(state2.elements.reference);
50967
+ var clippingClientRect = getClippingRect$1(isElement$2(element) ? element : element.contextElement || getDocumentElement$1(state2.elements.popper), boundary, rootBoundary, strategy);
50968
+ var referenceClientRect = getBoundingClientRect$1(state2.elements.reference);
50506
50969
  var popperOffsets2 = computeOffsets({
50507
50970
  reference: referenceClientRect,
50508
50971
  element: popperRect,
50509
50972
  placement
50510
50973
  });
50511
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
50974
+ var popperClientRect = rectToClientRect$1(Object.assign({}, popperRect, popperOffsets2));
50512
50975
  var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
50513
50976
  var overflowOffsets = {
50514
50977
  top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
@@ -50543,7 +51006,7 @@ function computeAutoPlacement(state2, options2) {
50543
51006
  allowedPlacements = placements$1;
50544
51007
  }
50545
51008
  var overflows = allowedPlacements.reduce(function(acc, placement2) {
50546
- acc[placement2] = detectOverflow(state2, {
51009
+ acc[placement2] = detectOverflow$1(state2, {
50547
51010
  placement: placement2,
50548
51011
  boundary,
50549
51012
  rootBoundary,
@@ -50593,7 +51056,7 @@ function flip(_ref) {
50593
51056
  var isStartVariation = getVariation(placement) === start;
50594
51057
  var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
50595
51058
  var len = isVertical ? "width" : "height";
50596
- var overflow = detectOverflow(state2, {
51059
+ var overflow = detectOverflow$1(state2, {
50597
51060
  placement,
50598
51061
  boundary,
50599
51062
  rootBoundary,
@@ -50658,7 +51121,7 @@ const flip$1 = {
50658
51121
  _skip: false
50659
51122
  }
50660
51123
  };
50661
- function getSideOffsets(overflow, rect, preventedOffsets) {
51124
+ function getSideOffsets$1(overflow, rect, preventedOffsets) {
50662
51125
  if (preventedOffsets === void 0) {
50663
51126
  preventedOffsets = {
50664
51127
  x: 0,
@@ -50672,26 +51135,26 @@ function getSideOffsets(overflow, rect, preventedOffsets) {
50672
51135
  left: overflow.left - rect.width - preventedOffsets.x
50673
51136
  };
50674
51137
  }
50675
- function isAnySideFullyClipped(overflow) {
51138
+ function isAnySideFullyClipped$1(overflow) {
50676
51139
  return [top, right, bottom, left].some(function(side) {
50677
51140
  return overflow[side] >= 0;
50678
51141
  });
50679
51142
  }
50680
- function hide(_ref) {
51143
+ function hide$2(_ref) {
50681
51144
  var state2 = _ref.state, name = _ref.name;
50682
51145
  var referenceRect = state2.rects.reference;
50683
51146
  var popperRect = state2.rects.popper;
50684
51147
  var preventedOffsets = state2.modifiersData.preventOverflow;
50685
- var referenceOverflow = detectOverflow(state2, {
51148
+ var referenceOverflow = detectOverflow$1(state2, {
50686
51149
  elementContext: "reference"
50687
51150
  });
50688
- var popperAltOverflow = detectOverflow(state2, {
51151
+ var popperAltOverflow = detectOverflow$1(state2, {
50689
51152
  altBoundary: true
50690
51153
  });
50691
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
50692
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
50693
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
50694
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
51154
+ var referenceClippingOffsets = getSideOffsets$1(referenceOverflow, referenceRect);
51155
+ var popperEscapeOffsets = getSideOffsets$1(popperAltOverflow, popperRect, preventedOffsets);
51156
+ var isReferenceHidden = isAnySideFullyClipped$1(referenceClippingOffsets);
51157
+ var hasPopperEscaped = isAnySideFullyClipped$1(popperEscapeOffsets);
50695
51158
  state2.modifiersData[name] = {
50696
51159
  referenceClippingOffsets,
50697
51160
  popperEscapeOffsets,
@@ -50703,12 +51166,12 @@ function hide(_ref) {
50703
51166
  "data-popper-escaped": hasPopperEscaped
50704
51167
  });
50705
51168
  }
50706
- const hide$1 = {
51169
+ const hide$3 = {
50707
51170
  name: "hide",
50708
51171
  enabled: true,
50709
51172
  phase: "main",
50710
51173
  requiresIfExists: ["preventOverflow"],
50711
- fn: hide
51174
+ fn: hide$2
50712
51175
  };
50713
51176
  function distanceAndSkiddingToXY(placement, rects, offset2) {
50714
51177
  var basePlacement = getBasePlacement$1(placement);
@@ -50768,7 +51231,7 @@ function getAltAxis(axis) {
50768
51231
  function preventOverflow(_ref) {
50769
51232
  var state2 = _ref.state, options2 = _ref.options, name = _ref.name;
50770
51233
  var _options$mainAxis = options2.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options2.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options2.boundary, rootBoundary = options2.rootBoundary, altBoundary = options2.altBoundary, padding = options2.padding, _options$tether = options2.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options2.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
50771
- var overflow = detectOverflow(state2, {
51234
+ var overflow = detectOverflow$1(state2, {
50772
51235
  boundary,
50773
51236
  rootBoundary,
50774
51237
  padding,
@@ -50806,8 +51269,8 @@ function preventOverflow(_ref) {
50806
51269
  var altSide = mainAxis === "y" ? bottom : right;
50807
51270
  var len = mainAxis === "y" ? "height" : "width";
50808
51271
  var offset2 = popperOffsets2[mainAxis];
50809
- var min$12 = offset2 + overflow[mainSide];
50810
- var max$12 = offset2 - overflow[altSide];
51272
+ var min2 = offset2 + overflow[mainSide];
51273
+ var max2 = offset2 - overflow[altSide];
50811
51274
  var additive = tether ? -popperRect[len] / 2 : 0;
50812
51275
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
50813
51276
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
@@ -50822,12 +51285,12 @@ function preventOverflow(_ref) {
50822
51285
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
50823
51286
  var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
50824
51287
  var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
50825
- var arrowOffsetParent = state2.elements.arrow && getOffsetParent(state2.elements.arrow);
51288
+ var arrowOffsetParent = state2.elements.arrow && getOffsetParent$1(state2.elements.arrow);
50826
51289
  var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
50827
51290
  var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
50828
51291
  var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
50829
51292
  var tetherMax = offset2 + maxOffset - offsetModifierValue;
50830
- var preventedOffset = within(tether ? min(min$12, tetherMin) : min$12, offset2, tether ? max(max$12, tetherMax) : max$12);
51293
+ var preventedOffset = within(tether ? min$1(min2, tetherMin) : min2, offset2, tether ? max$1(max2, tetherMax) : max2);
50831
51294
  popperOffsets2[mainAxis] = preventedOffset;
50832
51295
  data[mainAxis] = preventedOffset - offset2;
50833
51296
  }
@@ -50862,8 +51325,8 @@ function getHTMLElementScroll(element) {
50862
51325
  scrollTop: element.scrollTop
50863
51326
  };
50864
51327
  }
50865
- function getNodeScroll(node2) {
50866
- if (node2 === getWindow(node2) || !isHTMLElement$1(node2)) {
51328
+ function getNodeScroll$1(node2) {
51329
+ if (node2 === getWindow$1(node2) || !isHTMLElement$1(node2)) {
50867
51330
  return getWindowScroll(node2);
50868
51331
  } else {
50869
51332
  return getHTMLElementScroll(node2);
@@ -50871,8 +51334,8 @@ function getNodeScroll(node2) {
50871
51334
  }
50872
51335
  function isElementScaled(element) {
50873
51336
  var rect = element.getBoundingClientRect();
50874
- var scaleX = round(rect.width) / element.offsetWidth || 1;
50875
- var scaleY = round(rect.height) / element.offsetHeight || 1;
51337
+ var scaleX = round$1(rect.width) / element.offsetWidth || 1;
51338
+ var scaleY = round$1(rect.height) / element.offsetHeight || 1;
50876
51339
  return scaleX !== 1 || scaleY !== 1;
50877
51340
  }
50878
51341
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
@@ -50881,8 +51344,8 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
50881
51344
  }
50882
51345
  var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
50883
51346
  var offsetParentIsScaled = isHTMLElement$1(offsetParent) && isElementScaled(offsetParent);
50884
- var documentElement = getDocumentElement(offsetParent);
50885
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
51347
+ var documentElement = getDocumentElement$1(offsetParent);
51348
+ var rect = getBoundingClientRect$1(elementOrVirtualElement, offsetParentIsScaled, isFixed);
50886
51349
  var scroll = {
50887
51350
  scrollLeft: 0,
50888
51351
  scrollTop: 0
@@ -50892,16 +51355,16 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
50892
51355
  y: 0
50893
51356
  };
50894
51357
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
50895
- if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
51358
+ if (getNodeName$1(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
50896
51359
  isScrollParent(documentElement)) {
50897
- scroll = getNodeScroll(offsetParent);
51360
+ scroll = getNodeScroll$1(offsetParent);
50898
51361
  }
50899
51362
  if (isHTMLElement$1(offsetParent)) {
50900
- offsets = getBoundingClientRect(offsetParent, true);
51363
+ offsets = getBoundingClientRect$1(offsetParent, true);
50901
51364
  offsets.x += offsetParent.clientLeft;
50902
51365
  offsets.y += offsetParent.clientTop;
50903
51366
  } else if (documentElement) {
50904
- offsets.x = getWindowScrollBarX(documentElement);
51367
+ offsets.x = getWindowScrollBarX$1(documentElement);
50905
51368
  }
50906
51369
  }
50907
51370
  return {
@@ -51016,7 +51479,7 @@ function popperGenerator(generatorOptions) {
51016
51479
  cleanupModifierEffects();
51017
51480
  state2.options = Object.assign({}, defaultOptions, state2.options, options22);
51018
51481
  state2.scrollParents = {
51019
- reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
51482
+ reference: isElement$2(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
51020
51483
  popper: listScrollParents(popper2)
51021
51484
  };
51022
51485
  var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state2.options.modifiers)));
@@ -51040,7 +51503,7 @@ function popperGenerator(generatorOptions) {
51040
51503
  return;
51041
51504
  }
51042
51505
  state2.rects = {
51043
- reference: getCompositeRect(reference3, getOffsetParent(popper3), state2.options.strategy === "fixed"),
51506
+ reference: getCompositeRect(reference3, getOffsetParent$1(popper3), state2.options.strategy === "fixed"),
51044
51507
  popper: getLayoutRect(popper3)
51045
51508
  };
51046
51509
  state2.reset = false;
@@ -51111,7 +51574,7 @@ function popperGenerator(generatorOptions) {
51111
51574
  return instance;
51112
51575
  };
51113
51576
  }
51114
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
51577
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$3];
51115
51578
  var createPopper = /* @__PURE__ */ popperGenerator({
51116
51579
  defaultModifiers
51117
51580
  });
@@ -51196,7 +51659,7 @@ function removeUndefinedProps(obj) {
51196
51659
  function div() {
51197
51660
  return document.createElement("div");
51198
51661
  }
51199
- function isElement$2(value) {
51662
+ function isElement$1(value) {
51200
51663
  return ["Element", "Fragment"].some(function(type2) {
51201
51664
  return isType(value, type2);
51202
51665
  });
@@ -51211,7 +51674,7 @@ function isReferenceElement(value) {
51211
51674
  return !!(value && value._tippy && value._tippy.reference === value);
51212
51675
  }
51213
51676
  function getArrayOfElements(value) {
51214
- if (isElement$2(value)) {
51677
+ if (isElement$1(value)) {
51215
51678
  return [value];
51216
51679
  }
51217
51680
  if (isNodeList(value)) {
@@ -51520,7 +51983,7 @@ function createArrowElement(value) {
51520
51983
  arrow2.className = ARROW_CLASS;
51521
51984
  } else {
51522
51985
  arrow2.className = SVG_ARROW_CLASS;
51523
- if (isElement$2(value)) {
51986
+ if (isElement$1(value)) {
51524
51987
  arrow2.appendChild(value);
51525
51988
  } else {
51526
51989
  dangerouslySetInnerHTML(arrow2, value);
@@ -51529,7 +51992,7 @@ function createArrowElement(value) {
51529
51992
  return arrow2;
51530
51993
  }
51531
51994
  function setContent(content, props) {
51532
- if (isElement$2(props.content)) {
51995
+ if (isElement$1(props.content)) {
51533
51996
  dangerouslySetInnerHTML(content, "");
51534
51997
  content.appendChild(props.content);
51535
51998
  } else if (typeof props.content !== "function") {
@@ -52352,7 +52815,7 @@ function tippy(targets, optionalProps) {
52352
52815
  });
52353
52816
  var elements = getArrayOfElements(targets);
52354
52817
  if (process$1$1.env.NODE_ENV !== "production") {
52355
- var isSingleContentElement = isElement$2(passedProps.content);
52818
+ var isSingleContentElement = isElement$1(passedProps.content);
52356
52819
  var isMoreThanOneReferenceElement = elements.length > 1;
52357
52820
  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(" "));
52358
52821
  }
@@ -52363,7 +52826,7 @@ function tippy(targets, optionalProps) {
52363
52826
  }
52364
52827
  return acc;
52365
52828
  }, []);
52366
- return isElement$2(targets) ? instances[0] : instances;
52829
+ return isElement$1(targets) ? instances[0] : instances;
52367
52830
  }
52368
52831
  tippy.defaultProps = defaultProps;
52369
52832
  tippy.setDefaultProps = setDefaultProps;
@@ -52632,7 +53095,1067 @@ class Popover {
52632
53095
  this.popover.remove();
52633
53096
  }
52634
53097
  }
53098
+ const sides = ["top", "right", "bottom", "left"];
53099
+ const min = Math.min;
53100
+ const max = Math.max;
53101
+ const round = Math.round;
53102
+ const floor = Math.floor;
53103
+ const createCoords = (v) => ({
53104
+ x: v,
53105
+ y: v
53106
+ });
53107
+ function evaluate(value, param) {
53108
+ return typeof value === "function" ? value(param) : value;
53109
+ }
53110
+ function getSide(placement) {
53111
+ return placement.split("-")[0];
53112
+ }
53113
+ function getAlignment(placement) {
53114
+ return placement.split("-")[1];
53115
+ }
53116
+ function getOppositeAxis(axis) {
53117
+ return axis === "x" ? "y" : "x";
53118
+ }
53119
+ function getAxisLength(axis) {
53120
+ return axis === "y" ? "height" : "width";
53121
+ }
53122
+ function getSideAxis(placement) {
53123
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
53124
+ }
53125
+ function getAlignmentAxis(placement) {
53126
+ return getOppositeAxis(getSideAxis(placement));
53127
+ }
53128
+ function expandPaddingObject(padding) {
53129
+ return {
53130
+ top: 0,
53131
+ right: 0,
53132
+ bottom: 0,
53133
+ left: 0,
53134
+ ...padding
53135
+ };
53136
+ }
53137
+ function getPaddingObject(padding) {
53138
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
53139
+ top: padding,
53140
+ right: padding,
53141
+ bottom: padding,
53142
+ left: padding
53143
+ };
53144
+ }
53145
+ function rectToClientRect(rect) {
53146
+ const {
53147
+ x,
53148
+ y,
53149
+ width,
53150
+ height
53151
+ } = rect;
53152
+ return {
53153
+ width,
53154
+ height,
53155
+ top: y,
53156
+ left: x,
53157
+ right: x + width,
53158
+ bottom: y + height,
53159
+ x,
53160
+ y
53161
+ };
53162
+ }
53163
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
53164
+ let {
53165
+ reference: reference2,
53166
+ floating
53167
+ } = _ref;
53168
+ const sideAxis = getSideAxis(placement);
53169
+ const alignmentAxis = getAlignmentAxis(placement);
53170
+ const alignLength = getAxisLength(alignmentAxis);
53171
+ const side = getSide(placement);
53172
+ const isVertical = sideAxis === "y";
53173
+ const commonX = reference2.x + reference2.width / 2 - floating.width / 2;
53174
+ const commonY = reference2.y + reference2.height / 2 - floating.height / 2;
53175
+ const commonAlign = reference2[alignLength] / 2 - floating[alignLength] / 2;
53176
+ let coords;
53177
+ switch (side) {
53178
+ case "top":
53179
+ coords = {
53180
+ x: commonX,
53181
+ y: reference2.y - floating.height
53182
+ };
53183
+ break;
53184
+ case "bottom":
53185
+ coords = {
53186
+ x: commonX,
53187
+ y: reference2.y + reference2.height
53188
+ };
53189
+ break;
53190
+ case "right":
53191
+ coords = {
53192
+ x: reference2.x + reference2.width,
53193
+ y: commonY
53194
+ };
53195
+ break;
53196
+ case "left":
53197
+ coords = {
53198
+ x: reference2.x - floating.width,
53199
+ y: commonY
53200
+ };
53201
+ break;
53202
+ default:
53203
+ coords = {
53204
+ x: reference2.x,
53205
+ y: reference2.y
53206
+ };
53207
+ }
53208
+ switch (getAlignment(placement)) {
53209
+ case "start":
53210
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
53211
+ break;
53212
+ case "end":
53213
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
53214
+ break;
53215
+ }
53216
+ return coords;
53217
+ }
53218
+ const computePosition$1 = async (reference2, floating, config) => {
53219
+ const {
53220
+ placement = "bottom",
53221
+ strategy = "absolute",
53222
+ middleware = [],
53223
+ platform: platform2
53224
+ } = config;
53225
+ const validMiddleware = middleware.filter(Boolean);
53226
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
53227
+ let rects = await platform2.getElementRects({
53228
+ reference: reference2,
53229
+ floating,
53230
+ strategy
53231
+ });
53232
+ let {
53233
+ x,
53234
+ y
53235
+ } = computeCoordsFromPlacement(rects, placement, rtl);
53236
+ let statefulPlacement = placement;
53237
+ let middlewareData = {};
53238
+ let resetCount = 0;
53239
+ for (let i = 0; i < validMiddleware.length; i++) {
53240
+ const {
53241
+ name,
53242
+ fn: fn2
53243
+ } = validMiddleware[i];
53244
+ const {
53245
+ x: nextX,
53246
+ y: nextY,
53247
+ data,
53248
+ reset
53249
+ } = await fn2({
53250
+ x,
53251
+ y,
53252
+ initialPlacement: placement,
53253
+ placement: statefulPlacement,
53254
+ strategy,
53255
+ middlewareData,
53256
+ rects,
53257
+ platform: platform2,
53258
+ elements: {
53259
+ reference: reference2,
53260
+ floating
53261
+ }
53262
+ });
53263
+ x = nextX != null ? nextX : x;
53264
+ y = nextY != null ? nextY : y;
53265
+ middlewareData = {
53266
+ ...middlewareData,
53267
+ [name]: {
53268
+ ...middlewareData[name],
53269
+ ...data
53270
+ }
53271
+ };
53272
+ if (reset && resetCount <= 50) {
53273
+ resetCount++;
53274
+ if (typeof reset === "object") {
53275
+ if (reset.placement) {
53276
+ statefulPlacement = reset.placement;
53277
+ }
53278
+ if (reset.rects) {
53279
+ rects = reset.rects === true ? await platform2.getElementRects({
53280
+ reference: reference2,
53281
+ floating,
53282
+ strategy
53283
+ }) : reset.rects;
53284
+ }
53285
+ ({
53286
+ x,
53287
+ y
53288
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
53289
+ }
53290
+ i = -1;
53291
+ }
53292
+ }
53293
+ return {
53294
+ x,
53295
+ y,
53296
+ placement: statefulPlacement,
53297
+ strategy,
53298
+ middlewareData
53299
+ };
53300
+ };
53301
+ async function detectOverflow(state2, options2) {
53302
+ var _await$platform$isEle;
53303
+ if (options2 === void 0) {
53304
+ options2 = {};
53305
+ }
53306
+ const {
53307
+ x,
53308
+ y,
53309
+ platform: platform2,
53310
+ rects,
53311
+ elements,
53312
+ strategy
53313
+ } = state2;
53314
+ const {
53315
+ boundary = "clippingAncestors",
53316
+ rootBoundary = "viewport",
53317
+ elementContext = "floating",
53318
+ altBoundary = false,
53319
+ padding = 0
53320
+ } = evaluate(options2, state2);
53321
+ const paddingObject = getPaddingObject(padding);
53322
+ const altContext = elementContext === "floating" ? "reference" : "floating";
53323
+ const element = elements[altBoundary ? altContext : elementContext];
53324
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
53325
+ 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)),
53326
+ boundary,
53327
+ rootBoundary,
53328
+ strategy
53329
+ }));
53330
+ const rect = elementContext === "floating" ? {
53331
+ x,
53332
+ y,
53333
+ width: rects.floating.width,
53334
+ height: rects.floating.height
53335
+ } : rects.reference;
53336
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
53337
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
53338
+ x: 1,
53339
+ y: 1
53340
+ } : {
53341
+ x: 1,
53342
+ y: 1
53343
+ };
53344
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
53345
+ elements,
53346
+ rect,
53347
+ offsetParent,
53348
+ strategy
53349
+ }) : rect);
53350
+ return {
53351
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
53352
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
53353
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
53354
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
53355
+ };
53356
+ }
53357
+ function getSideOffsets(overflow, rect) {
53358
+ return {
53359
+ top: overflow.top - rect.height,
53360
+ right: overflow.right - rect.width,
53361
+ bottom: overflow.bottom - rect.height,
53362
+ left: overflow.left - rect.width
53363
+ };
53364
+ }
53365
+ function isAnySideFullyClipped(overflow) {
53366
+ return sides.some((side) => overflow[side] >= 0);
53367
+ }
53368
+ const hide$1 = function(options2) {
53369
+ if (options2 === void 0) {
53370
+ options2 = {};
53371
+ }
53372
+ return {
53373
+ name: "hide",
53374
+ options: options2,
53375
+ async fn(state2) {
53376
+ const {
53377
+ rects
53378
+ } = state2;
53379
+ const {
53380
+ strategy = "referenceHidden",
53381
+ ...detectOverflowOptions
53382
+ } = evaluate(options2, state2);
53383
+ switch (strategy) {
53384
+ case "referenceHidden": {
53385
+ const overflow = await detectOverflow(state2, {
53386
+ ...detectOverflowOptions,
53387
+ elementContext: "reference"
53388
+ });
53389
+ const offsets = getSideOffsets(overflow, rects.reference);
53390
+ return {
53391
+ data: {
53392
+ referenceHiddenOffsets: offsets,
53393
+ referenceHidden: isAnySideFullyClipped(offsets)
53394
+ }
53395
+ };
53396
+ }
53397
+ case "escaped": {
53398
+ const overflow = await detectOverflow(state2, {
53399
+ ...detectOverflowOptions,
53400
+ altBoundary: true
53401
+ });
53402
+ const offsets = getSideOffsets(overflow, rects.floating);
53403
+ return {
53404
+ data: {
53405
+ escapedOffsets: offsets,
53406
+ escaped: isAnySideFullyClipped(offsets)
53407
+ }
53408
+ };
53409
+ }
53410
+ default: {
53411
+ return {};
53412
+ }
53413
+ }
53414
+ }
53415
+ };
53416
+ };
53417
+ function hasWindow() {
53418
+ return typeof window !== "undefined";
53419
+ }
53420
+ function getNodeName(node2) {
53421
+ if (isNode(node2)) {
53422
+ return (node2.nodeName || "").toLowerCase();
53423
+ }
53424
+ return "#document";
53425
+ }
53426
+ function getWindow(node2) {
53427
+ var _node$ownerDocument;
53428
+ return (node2 == null || (_node$ownerDocument = node2.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
53429
+ }
53430
+ function getDocumentElement(node2) {
53431
+ var _ref;
53432
+ return (_ref = (isNode(node2) ? node2.ownerDocument : node2.document) || window.document) == null ? void 0 : _ref.documentElement;
53433
+ }
53434
+ function isNode(value) {
53435
+ if (!hasWindow()) {
53436
+ return false;
53437
+ }
53438
+ return value instanceof Node || value instanceof getWindow(value).Node;
53439
+ }
53440
+ function isElement$3(value) {
53441
+ if (!hasWindow()) {
53442
+ return false;
53443
+ }
53444
+ return value instanceof Element || value instanceof getWindow(value).Element;
53445
+ }
53446
+ function isHTMLElement$2(value) {
53447
+ if (!hasWindow()) {
53448
+ return false;
53449
+ }
53450
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
53451
+ }
53452
+ function isShadowRoot(value) {
53453
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
53454
+ return false;
53455
+ }
53456
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
53457
+ }
53458
+ function isOverflowElement(element) {
53459
+ const {
53460
+ overflow,
53461
+ overflowX,
53462
+ overflowY,
53463
+ display
53464
+ } = getComputedStyle$1(element);
53465
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
53466
+ }
53467
+ function isTableElement(element) {
53468
+ return ["table", "td", "th"].includes(getNodeName(element));
53469
+ }
53470
+ function isTopLayer(element) {
53471
+ return [":popover-open", ":modal"].some((selector) => {
53472
+ try {
53473
+ return element.matches(selector);
53474
+ } catch (e) {
53475
+ return false;
53476
+ }
53477
+ });
53478
+ }
53479
+ function isContainingBlock(elementOrCss) {
53480
+ const webkit2 = isWebKit();
53481
+ const css = isElement$3(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
53482
+ 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));
53483
+ }
53484
+ function getContainingBlock(element) {
53485
+ let currentNode = getParentNode$2(element);
53486
+ while (isHTMLElement$2(currentNode) && !isLastTraversableNode(currentNode)) {
53487
+ if (isContainingBlock(currentNode)) {
53488
+ return currentNode;
53489
+ } else if (isTopLayer(currentNode)) {
53490
+ return null;
53491
+ }
53492
+ currentNode = getParentNode$2(currentNode);
53493
+ }
53494
+ return null;
53495
+ }
53496
+ function isWebKit() {
53497
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
53498
+ return CSS.supports("-webkit-backdrop-filter", "none");
53499
+ }
53500
+ function isLastTraversableNode(node2) {
53501
+ return ["html", "body", "#document"].includes(getNodeName(node2));
53502
+ }
53503
+ function getComputedStyle$1(element) {
53504
+ return getWindow(element).getComputedStyle(element);
53505
+ }
53506
+ function getNodeScroll(element) {
53507
+ if (isElement$3(element)) {
53508
+ return {
53509
+ scrollLeft: element.scrollLeft,
53510
+ scrollTop: element.scrollTop
53511
+ };
53512
+ }
53513
+ return {
53514
+ scrollLeft: element.scrollX,
53515
+ scrollTop: element.scrollY
53516
+ };
53517
+ }
53518
+ function getParentNode$2(node2) {
53519
+ if (getNodeName(node2) === "html") {
53520
+ return node2;
53521
+ }
53522
+ const result = (
53523
+ // Step into the shadow DOM of the parent of a slotted node.
53524
+ node2.assignedSlot || // DOM Element detected.
53525
+ node2.parentNode || // ShadowRoot detected.
53526
+ isShadowRoot(node2) && node2.host || // Fallback.
53527
+ getDocumentElement(node2)
53528
+ );
53529
+ return isShadowRoot(result) ? result.host : result;
53530
+ }
53531
+ function getNearestOverflowAncestor(node2) {
53532
+ const parentNode2 = getParentNode$2(node2);
53533
+ if (isLastTraversableNode(parentNode2)) {
53534
+ return node2.ownerDocument ? node2.ownerDocument.body : node2.body;
53535
+ }
53536
+ if (isHTMLElement$2(parentNode2) && isOverflowElement(parentNode2)) {
53537
+ return parentNode2;
53538
+ }
53539
+ return getNearestOverflowAncestor(parentNode2);
53540
+ }
53541
+ function getOverflowAncestors(node2, list, traverseIframes) {
53542
+ var _node$ownerDocument2;
53543
+ if (list === void 0) {
53544
+ list = [];
53545
+ }
53546
+ if (traverseIframes === void 0) {
53547
+ traverseIframes = true;
53548
+ }
53549
+ const scrollableAncestor = getNearestOverflowAncestor(node2);
53550
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node2.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
53551
+ const win = getWindow(scrollableAncestor);
53552
+ if (isBody) {
53553
+ const frameElement = getFrameElement(win);
53554
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
53555
+ }
53556
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
53557
+ }
53558
+ function getFrameElement(win) {
53559
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
53560
+ }
53561
+ function getCssDimensions(element) {
53562
+ const css = getComputedStyle$1(element);
53563
+ let width = parseFloat(css.width) || 0;
53564
+ let height = parseFloat(css.height) || 0;
53565
+ const hasOffset = isHTMLElement$2(element);
53566
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
53567
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
53568
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
53569
+ if (shouldFallback) {
53570
+ width = offsetWidth;
53571
+ height = offsetHeight;
53572
+ }
53573
+ return {
53574
+ width,
53575
+ height,
53576
+ $: shouldFallback
53577
+ };
53578
+ }
53579
+ function unwrapElement(element) {
53580
+ return !isElement$3(element) ? element.contextElement : element;
53581
+ }
53582
+ function getScale(element) {
53583
+ const domElement = unwrapElement(element);
53584
+ if (!isHTMLElement$2(domElement)) {
53585
+ return createCoords(1);
53586
+ }
53587
+ const rect = domElement.getBoundingClientRect();
53588
+ const {
53589
+ width,
53590
+ height,
53591
+ $
53592
+ } = getCssDimensions(domElement);
53593
+ let x = ($ ? round(rect.width) : rect.width) / width;
53594
+ let y = ($ ? round(rect.height) : rect.height) / height;
53595
+ if (!x || !Number.isFinite(x)) {
53596
+ x = 1;
53597
+ }
53598
+ if (!y || !Number.isFinite(y)) {
53599
+ y = 1;
53600
+ }
53601
+ return {
53602
+ x,
53603
+ y
53604
+ };
53605
+ }
53606
+ const noOffsets = /* @__PURE__ */ createCoords(0);
53607
+ function getVisualOffsets(element) {
53608
+ const win = getWindow(element);
53609
+ if (!isWebKit() || !win.visualViewport) {
53610
+ return noOffsets;
53611
+ }
53612
+ return {
53613
+ x: win.visualViewport.offsetLeft,
53614
+ y: win.visualViewport.offsetTop
53615
+ };
53616
+ }
53617
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
53618
+ if (isFixed === void 0) {
53619
+ isFixed = false;
53620
+ }
53621
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
53622
+ return false;
53623
+ }
53624
+ return isFixed;
53625
+ }
53626
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
53627
+ if (includeScale === void 0) {
53628
+ includeScale = false;
53629
+ }
53630
+ if (isFixedStrategy === void 0) {
53631
+ isFixedStrategy = false;
53632
+ }
53633
+ const clientRect2 = element.getBoundingClientRect();
53634
+ const domElement = unwrapElement(element);
53635
+ let scale = createCoords(1);
53636
+ if (includeScale) {
53637
+ if (offsetParent) {
53638
+ if (isElement$3(offsetParent)) {
53639
+ scale = getScale(offsetParent);
53640
+ }
53641
+ } else {
53642
+ scale = getScale(element);
53643
+ }
53644
+ }
53645
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
53646
+ let x = (clientRect2.left + visualOffsets.x) / scale.x;
53647
+ let y = (clientRect2.top + visualOffsets.y) / scale.y;
53648
+ let width = clientRect2.width / scale.x;
53649
+ let height = clientRect2.height / scale.y;
53650
+ if (domElement) {
53651
+ const win = getWindow(domElement);
53652
+ const offsetWin = offsetParent && isElement$3(offsetParent) ? getWindow(offsetParent) : offsetParent;
53653
+ let currentWin = win;
53654
+ let currentIFrame = getFrameElement(currentWin);
53655
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
53656
+ const iframeScale = getScale(currentIFrame);
53657
+ const iframeRect = currentIFrame.getBoundingClientRect();
53658
+ const css = getComputedStyle$1(currentIFrame);
53659
+ const left2 = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
53660
+ const top2 = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
53661
+ x *= iframeScale.x;
53662
+ y *= iframeScale.y;
53663
+ width *= iframeScale.x;
53664
+ height *= iframeScale.y;
53665
+ x += left2;
53666
+ y += top2;
53667
+ currentWin = getWindow(currentIFrame);
53668
+ currentIFrame = getFrameElement(currentWin);
53669
+ }
53670
+ }
53671
+ return rectToClientRect({
53672
+ width,
53673
+ height,
53674
+ x,
53675
+ y
53676
+ });
53677
+ }
53678
+ function getWindowScrollBarX(element, rect) {
53679
+ const leftScroll = getNodeScroll(element).scrollLeft;
53680
+ if (!rect) {
53681
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
53682
+ }
53683
+ return rect.left + leftScroll;
53684
+ }
53685
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
53686
+ if (ignoreScrollbarX === void 0) {
53687
+ ignoreScrollbarX = false;
53688
+ }
53689
+ const htmlRect = documentElement.getBoundingClientRect();
53690
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
53691
+ // RTL <body> scrollbar.
53692
+ getWindowScrollBarX(documentElement, htmlRect)
53693
+ ));
53694
+ const y = htmlRect.top + scroll.scrollTop;
53695
+ return {
53696
+ x,
53697
+ y
53698
+ };
53699
+ }
53700
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
53701
+ let {
53702
+ elements,
53703
+ rect,
53704
+ offsetParent,
53705
+ strategy
53706
+ } = _ref;
53707
+ const isFixed = strategy === "fixed";
53708
+ const documentElement = getDocumentElement(offsetParent);
53709
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
53710
+ if (offsetParent === documentElement || topLayer && isFixed) {
53711
+ return rect;
53712
+ }
53713
+ let scroll = {
53714
+ scrollLeft: 0,
53715
+ scrollTop: 0
53716
+ };
53717
+ let scale = createCoords(1);
53718
+ const offsets = createCoords(0);
53719
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
53720
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
53721
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
53722
+ scroll = getNodeScroll(offsetParent);
53723
+ }
53724
+ if (isHTMLElement$2(offsetParent)) {
53725
+ const offsetRect = getBoundingClientRect(offsetParent);
53726
+ scale = getScale(offsetParent);
53727
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
53728
+ offsets.y = offsetRect.y + offsetParent.clientTop;
53729
+ }
53730
+ }
53731
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
53732
+ return {
53733
+ width: rect.width * scale.x,
53734
+ height: rect.height * scale.y,
53735
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
53736
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
53737
+ };
53738
+ }
53739
+ function getClientRects(element) {
53740
+ return Array.from(element.getClientRects());
53741
+ }
53742
+ function getDocumentRect(element) {
53743
+ const html = getDocumentElement(element);
53744
+ const scroll = getNodeScroll(element);
53745
+ const body = element.ownerDocument.body;
53746
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
53747
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
53748
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
53749
+ const y = -scroll.scrollTop;
53750
+ if (getComputedStyle$1(body).direction === "rtl") {
53751
+ x += max(html.clientWidth, body.clientWidth) - width;
53752
+ }
53753
+ return {
53754
+ width,
53755
+ height,
53756
+ x,
53757
+ y
53758
+ };
53759
+ }
53760
+ function getViewportRect(element, strategy) {
53761
+ const win = getWindow(element);
53762
+ const html = getDocumentElement(element);
53763
+ const visualViewport = win.visualViewport;
53764
+ let width = html.clientWidth;
53765
+ let height = html.clientHeight;
53766
+ let x = 0;
53767
+ let y = 0;
53768
+ if (visualViewport) {
53769
+ width = visualViewport.width;
53770
+ height = visualViewport.height;
53771
+ const visualViewportBased = isWebKit();
53772
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
53773
+ x = visualViewport.offsetLeft;
53774
+ y = visualViewport.offsetTop;
53775
+ }
53776
+ }
53777
+ return {
53778
+ width,
53779
+ height,
53780
+ x,
53781
+ y
53782
+ };
53783
+ }
53784
+ function getInnerBoundingClientRect(element, strategy) {
53785
+ const clientRect2 = getBoundingClientRect(element, true, strategy === "fixed");
53786
+ const top2 = clientRect2.top + element.clientTop;
53787
+ const left2 = clientRect2.left + element.clientLeft;
53788
+ const scale = isHTMLElement$2(element) ? getScale(element) : createCoords(1);
53789
+ const width = element.clientWidth * scale.x;
53790
+ const height = element.clientHeight * scale.y;
53791
+ const x = left2 * scale.x;
53792
+ const y = top2 * scale.y;
53793
+ return {
53794
+ width,
53795
+ height,
53796
+ x,
53797
+ y
53798
+ };
53799
+ }
53800
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
53801
+ let rect;
53802
+ if (clippingAncestor === "viewport") {
53803
+ rect = getViewportRect(element, strategy);
53804
+ } else if (clippingAncestor === "document") {
53805
+ rect = getDocumentRect(getDocumentElement(element));
53806
+ } else if (isElement$3(clippingAncestor)) {
53807
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
53808
+ } else {
53809
+ const visualOffsets = getVisualOffsets(element);
53810
+ rect = {
53811
+ x: clippingAncestor.x - visualOffsets.x,
53812
+ y: clippingAncestor.y - visualOffsets.y,
53813
+ width: clippingAncestor.width,
53814
+ height: clippingAncestor.height
53815
+ };
53816
+ }
53817
+ return rectToClientRect(rect);
53818
+ }
53819
+ function hasFixedPositionAncestor(element, stopNode) {
53820
+ const parentNode2 = getParentNode$2(element);
53821
+ if (parentNode2 === stopNode || !isElement$3(parentNode2) || isLastTraversableNode(parentNode2)) {
53822
+ return false;
53823
+ }
53824
+ return getComputedStyle$1(parentNode2).position === "fixed" || hasFixedPositionAncestor(parentNode2, stopNode);
53825
+ }
53826
+ function getClippingElementAncestors(element, cache2) {
53827
+ const cachedResult2 = cache2.get(element);
53828
+ if (cachedResult2) {
53829
+ return cachedResult2;
53830
+ }
53831
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement$3(el) && getNodeName(el) !== "body");
53832
+ let currentContainingBlockComputedStyle = null;
53833
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
53834
+ let currentNode = elementIsFixed ? getParentNode$2(element) : element;
53835
+ while (isElement$3(currentNode) && !isLastTraversableNode(currentNode)) {
53836
+ const computedStyle = getComputedStyle$1(currentNode);
53837
+ const currentNodeIsContaining = isContainingBlock(currentNode);
53838
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
53839
+ currentContainingBlockComputedStyle = null;
53840
+ }
53841
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
53842
+ if (shouldDropCurrentNode) {
53843
+ result = result.filter((ancestor) => ancestor !== currentNode);
53844
+ } else {
53845
+ currentContainingBlockComputedStyle = computedStyle;
53846
+ }
53847
+ currentNode = getParentNode$2(currentNode);
53848
+ }
53849
+ cache2.set(element, result);
53850
+ return result;
53851
+ }
53852
+ function getClippingRect(_ref) {
53853
+ let {
53854
+ element,
53855
+ boundary,
53856
+ rootBoundary,
53857
+ strategy
53858
+ } = _ref;
53859
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
53860
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
53861
+ const firstClippingAncestor = clippingAncestors[0];
53862
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
53863
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
53864
+ accRect.top = max(rect.top, accRect.top);
53865
+ accRect.right = min(rect.right, accRect.right);
53866
+ accRect.bottom = min(rect.bottom, accRect.bottom);
53867
+ accRect.left = max(rect.left, accRect.left);
53868
+ return accRect;
53869
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
53870
+ return {
53871
+ width: clippingRect.right - clippingRect.left,
53872
+ height: clippingRect.bottom - clippingRect.top,
53873
+ x: clippingRect.left,
53874
+ y: clippingRect.top
53875
+ };
53876
+ }
53877
+ function getDimensions(element) {
53878
+ const {
53879
+ width,
53880
+ height
53881
+ } = getCssDimensions(element);
53882
+ return {
53883
+ width,
53884
+ height
53885
+ };
53886
+ }
53887
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
53888
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
53889
+ const documentElement = getDocumentElement(offsetParent);
53890
+ const isFixed = strategy === "fixed";
53891
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
53892
+ let scroll = {
53893
+ scrollLeft: 0,
53894
+ scrollTop: 0
53895
+ };
53896
+ const offsets = createCoords(0);
53897
+ function setLeftRTLScrollbarOffset() {
53898
+ offsets.x = getWindowScrollBarX(documentElement);
53899
+ }
53900
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
53901
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
53902
+ scroll = getNodeScroll(offsetParent);
53903
+ }
53904
+ if (isOffsetParentAnElement) {
53905
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
53906
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
53907
+ offsets.y = offsetRect.y + offsetParent.clientTop;
53908
+ } else if (documentElement) {
53909
+ setLeftRTLScrollbarOffset();
53910
+ }
53911
+ }
53912
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
53913
+ setLeftRTLScrollbarOffset();
53914
+ }
53915
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
53916
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
53917
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
53918
+ return {
53919
+ x,
53920
+ y,
53921
+ width: rect.width,
53922
+ height: rect.height
53923
+ };
53924
+ }
53925
+ function isStaticPositioned(element) {
53926
+ return getComputedStyle$1(element).position === "static";
53927
+ }
53928
+ function getTrueOffsetParent(element, polyfill) {
53929
+ if (!isHTMLElement$2(element) || getComputedStyle$1(element).position === "fixed") {
53930
+ return null;
53931
+ }
53932
+ if (polyfill) {
53933
+ return polyfill(element);
53934
+ }
53935
+ let rawOffsetParent = element.offsetParent;
53936
+ if (getDocumentElement(element) === rawOffsetParent) {
53937
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
53938
+ }
53939
+ return rawOffsetParent;
53940
+ }
53941
+ function getOffsetParent(element, polyfill) {
53942
+ const win = getWindow(element);
53943
+ if (isTopLayer(element)) {
53944
+ return win;
53945
+ }
53946
+ if (!isHTMLElement$2(element)) {
53947
+ let svgOffsetParent = getParentNode$2(element);
53948
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
53949
+ if (isElement$3(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
53950
+ return svgOffsetParent;
53951
+ }
53952
+ svgOffsetParent = getParentNode$2(svgOffsetParent);
53953
+ }
53954
+ return win;
53955
+ }
53956
+ let offsetParent = getTrueOffsetParent(element, polyfill);
53957
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
53958
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
53959
+ }
53960
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
53961
+ return win;
53962
+ }
53963
+ return offsetParent || getContainingBlock(element) || win;
53964
+ }
53965
+ const getElementRects = async function(data) {
53966
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
53967
+ const getDimensionsFn = this.getDimensions;
53968
+ const floatingDimensions = await getDimensionsFn(data.floating);
53969
+ return {
53970
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
53971
+ floating: {
53972
+ x: 0,
53973
+ y: 0,
53974
+ width: floatingDimensions.width,
53975
+ height: floatingDimensions.height
53976
+ }
53977
+ };
53978
+ };
53979
+ function isRTL(element) {
53980
+ return getComputedStyle$1(element).direction === "rtl";
53981
+ }
53982
+ const platform = {
53983
+ convertOffsetParentRelativeRectToViewportRelativeRect,
53984
+ getDocumentElement,
53985
+ getClippingRect,
53986
+ getOffsetParent,
53987
+ getElementRects,
53988
+ getClientRects,
53989
+ getDimensions,
53990
+ getScale,
53991
+ isElement: isElement$3,
53992
+ isRTL
53993
+ };
53994
+ function rectsAreEqual(a, b) {
53995
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
53996
+ }
53997
+ function observeMove(element, onMove) {
53998
+ let io = null;
53999
+ let timeoutId;
54000
+ const root2 = getDocumentElement(element);
54001
+ function cleanup() {
54002
+ var _io;
54003
+ clearTimeout(timeoutId);
54004
+ (_io = io) == null || _io.disconnect();
54005
+ io = null;
54006
+ }
54007
+ function refresh(skip, threshold) {
54008
+ if (skip === void 0) {
54009
+ skip = false;
54010
+ }
54011
+ if (threshold === void 0) {
54012
+ threshold = 1;
54013
+ }
54014
+ cleanup();
54015
+ const elementRectForRootMargin = element.getBoundingClientRect();
54016
+ const {
54017
+ left: left2,
54018
+ top: top2,
54019
+ width,
54020
+ height
54021
+ } = elementRectForRootMargin;
54022
+ if (!skip) {
54023
+ onMove();
54024
+ }
54025
+ if (!width || !height) {
54026
+ return;
54027
+ }
54028
+ const insetTop = floor(top2);
54029
+ const insetRight = floor(root2.clientWidth - (left2 + width));
54030
+ const insetBottom = floor(root2.clientHeight - (top2 + height));
54031
+ const insetLeft = floor(left2);
54032
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
54033
+ const options2 = {
54034
+ rootMargin,
54035
+ threshold: max(0, min(1, threshold)) || 1
54036
+ };
54037
+ let isFirstUpdate = true;
54038
+ function handleObserve(entries) {
54039
+ const ratio = entries[0].intersectionRatio;
54040
+ if (ratio !== threshold) {
54041
+ if (!isFirstUpdate) {
54042
+ return refresh();
54043
+ }
54044
+ if (!ratio) {
54045
+ timeoutId = setTimeout(() => {
54046
+ refresh(false, 1e-7);
54047
+ }, 1e3);
54048
+ } else {
54049
+ refresh(false, ratio);
54050
+ }
54051
+ }
54052
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
54053
+ refresh();
54054
+ }
54055
+ isFirstUpdate = false;
54056
+ }
54057
+ try {
54058
+ io = new IntersectionObserver(handleObserve, {
54059
+ ...options2,
54060
+ // Handle <iframe>s
54061
+ root: root2.ownerDocument
54062
+ });
54063
+ } catch (_e) {
54064
+ io = new IntersectionObserver(handleObserve, options2);
54065
+ }
54066
+ io.observe(element);
54067
+ }
54068
+ refresh(true);
54069
+ return cleanup;
54070
+ }
54071
+ function autoUpdate(reference2, floating, update, options2) {
54072
+ if (options2 === void 0) {
54073
+ options2 = {};
54074
+ }
54075
+ const {
54076
+ ancestorScroll = true,
54077
+ ancestorResize = true,
54078
+ elementResize = typeof ResizeObserver === "function",
54079
+ layoutShift = typeof IntersectionObserver === "function",
54080
+ animationFrame = false
54081
+ } = options2;
54082
+ const referenceEl = unwrapElement(reference2);
54083
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
54084
+ ancestors.forEach((ancestor) => {
54085
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
54086
+ passive: true
54087
+ });
54088
+ ancestorResize && ancestor.addEventListener("resize", update);
54089
+ });
54090
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
54091
+ let reobserveFrame = -1;
54092
+ let resizeObserver = null;
54093
+ if (elementResize) {
54094
+ resizeObserver = new ResizeObserver((_ref) => {
54095
+ let [firstEntry] = _ref;
54096
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
54097
+ resizeObserver.unobserve(floating);
54098
+ cancelAnimationFrame(reobserveFrame);
54099
+ reobserveFrame = requestAnimationFrame(() => {
54100
+ var _resizeObserver;
54101
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
54102
+ });
54103
+ }
54104
+ update();
54105
+ });
54106
+ if (referenceEl && !animationFrame) {
54107
+ resizeObserver.observe(referenceEl);
54108
+ }
54109
+ resizeObserver.observe(floating);
54110
+ }
54111
+ let frameId;
54112
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference2) : null;
54113
+ if (animationFrame) {
54114
+ frameLoop();
54115
+ }
54116
+ function frameLoop() {
54117
+ const nextRefRect = getBoundingClientRect(reference2);
54118
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
54119
+ update();
54120
+ }
54121
+ prevRefRect = nextRefRect;
54122
+ frameId = requestAnimationFrame(frameLoop);
54123
+ }
54124
+ update();
54125
+ return () => {
54126
+ var _resizeObserver2;
54127
+ ancestors.forEach((ancestor) => {
54128
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
54129
+ ancestorResize && ancestor.removeEventListener("resize", update);
54130
+ });
54131
+ cleanupIo == null || cleanupIo();
54132
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
54133
+ resizeObserver = null;
54134
+ if (animationFrame) {
54135
+ cancelAnimationFrame(frameId);
54136
+ }
54137
+ };
54138
+ }
54139
+ const hide = hide$1;
54140
+ const computePosition = (reference2, floating, options2) => {
54141
+ const cache2 = /* @__PURE__ */ new Map();
54142
+ const mergedOptions = {
54143
+ platform,
54144
+ ...options2
54145
+ };
54146
+ const platformWithCache = {
54147
+ ...mergedOptions.platform,
54148
+ _c: cache2
54149
+ };
54150
+ return computePosition$1(reference2, floating, {
54151
+ ...mergedOptions,
54152
+ platform: platformWithCache
54153
+ });
54154
+ };
54155
+ const SEPARATOR_CLASS = "pagination-separator";
54156
+ const SEPARATOR_FLOATING_CLASS = "pagination-separator-floating";
52635
54157
  const isDebugging = false;
54158
+ const cleanupFunctions = /* @__PURE__ */ new Set();
52636
54159
  const Pagination = Extension.create({
52637
54160
  name: "pagination",
52638
54161
  addStorage() {
@@ -52722,7 +54245,7 @@ const Pagination = Extension.create({
52722
54245
  view: (view) => {
52723
54246
  let previousDecorations = DecorationSet.empty;
52724
54247
  return {
52725
- update: (view2) => {
54248
+ update: (view2, prevState) => {
52726
54249
  if (!shouldUpdate || isUpdating) return;
52727
54250
  isUpdating = true;
52728
54251
  hasInitialized = true;
@@ -52739,6 +54262,9 @@ const Pagination = Extension.create({
52739
54262
  }
52740
54263
  });
52741
54264
  return [paginationPlugin];
54265
+ },
54266
+ onDestroy() {
54267
+ cleanupFloatingSeparators();
52742
54268
  }
52743
54269
  });
52744
54270
  const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null) => {
@@ -52776,12 +54302,23 @@ const getHeaderFooterId = (currentPageNumber, sectionType, editor, node2 = null)
52776
54302
  const performUpdate = (editor, view, previousDecorations) => {
52777
54303
  const sectionData = editor.storage.pagination.sectionData;
52778
54304
  const newDecorations = calculatePageBreaks(view, editor, sectionData);
54305
+ const editorElement = editor.options.element;
52779
54306
  if (!previousDecorations.eq(newDecorations)) {
52780
54307
  const updateTransaction = view.state.tr.setMeta(
52781
54308
  PaginationPluginKey,
52782
54309
  { decorations: newDecorations }
52783
54310
  );
52784
54311
  view.dispatch(updateTransaction);
54312
+ requestAnimationFrame(() => {
54313
+ requestAnimationFrame(() => {
54314
+ cleanupFloatingSeparators();
54315
+ const separators = [...editorElement.querySelectorAll(`.${SEPARATOR_CLASS}--table`)];
54316
+ separators.forEach((separator) => {
54317
+ const { cleanup } = createFloatingSeparator(separator, editor);
54318
+ cleanupFunctions.add(cleanup);
54319
+ });
54320
+ });
54321
+ });
52785
54322
  }
52786
54323
  editor.emit("paginationUpdate");
52787
54324
  };
@@ -52822,16 +54359,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52822
54359
  const decorations = [];
52823
54360
  const { pageSize, pageMargins } = editor.converter.pageStyles;
52824
54361
  const pageHeight = pageSize.height * 96;
52825
- editor.options.scale;
52826
54362
  let currentPageNumber = 1;
52827
54363
  let pageHeightThreshold = pageHeight;
52828
54364
  let footer = null, header = null;
52829
54365
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52830
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
54366
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
52831
54367
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
52832
54368
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
52833
54369
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52834
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
54370
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
52835
54371
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
52836
54372
  let coords = view?.coordsAtPos(doc2.content.size);
52837
54373
  if (!coords) return [];
@@ -52850,7 +54386,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52850
54386
  if (currentPageNumber === 1) {
52851
54387
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
52852
54388
  decorations.pop();
52853
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
54389
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52854
54390
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
52855
54391
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
52856
54392
  }
@@ -52866,7 +54402,9 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52866
54402
  }
52867
54403
  if (isHardBreakNode || shouldAddPageBreak) {
52868
54404
  const $currentPos = view.state.doc.resolve(currentPos);
54405
+ const table = findParentNodeClosestToPos($currentPos, (node22) => node22.type.name === "table");
52869
54406
  const tableRow = findParentNodeClosestToPos($currentPos, (node22) => node22.type.name === "tableRow");
54407
+ let isInTable2 = table || tableRow ? true : false;
52870
54408
  if (tableRow) {
52871
54409
  currentNode = tableRow.node;
52872
54410
  currentPos = tableRow.pos;
@@ -52879,13 +54417,13 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52879
54417
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
52880
54418
  currentPageNumber++;
52881
54419
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52882
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
54420
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52883
54421
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
52884
54422
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
52885
54423
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
52886
54424
  const pageSpacer2 = Decoration.widget(breakPos, spacingNode2, { key: "stable-key" });
52887
54425
  decorations.push(pageSpacer2);
52888
- const pageBreak2 = createPageBreak({ editor, header, footer });
54426
+ const pageBreak2 = createPageBreak({ editor, header, footer, isInTable: isInTable2 });
52889
54427
  decorations.push(Decoration.widget(breakPos, pageBreak2, { key: "stable-key" }));
52890
54428
  pageHeightThreshold = actualBreakBottom + (pageHeight - header.headerHeight - footer.footerHeight);
52891
54429
  }
@@ -52894,7 +54432,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52894
54432
  const lastNodeCoords = view.coordsAtPos(finalPos);
52895
54433
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52896
54434
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52897
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
54435
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
52898
54436
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
52899
54437
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
52900
54438
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -52911,6 +54449,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52911
54449
  totalPageNumber.innerText = currentPageNumber;
52912
54450
  }
52913
54451
  });
54452
+ editor.currentTotalPages = currentPageNumber;
52914
54453
  return decorations;
52915
54454
  }
52916
54455
  function createFinalPagePadding(bufferHeight) {
@@ -52921,7 +54460,7 @@ function createFinalPagePadding(bufferHeight) {
52921
54460
  div2.style.height = bufferHeight + "px";
52922
54461
  return { nodeHeight: bufferHeight, node: div2 };
52923
54462
  }
52924
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
54463
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
52925
54464
  const headerDef = sectionData.headers?.[headerId];
52926
54465
  const minHeaderHeight = pageMargins.top * 96;
52927
54466
  const headerMargin = pageMargins.header * 96;
@@ -52948,7 +54487,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
52948
54487
  appendToBody: false,
52949
54488
  sectionId: headerId,
52950
54489
  type: "header",
52951
- availableHeight
54490
+ availableHeight,
54491
+ currentPageNumber
52952
54492
  });
52953
54493
  editor.converter.headerEditors.push({
52954
54494
  id: headerId,
@@ -52974,13 +54514,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
52974
54514
  const minFooterHeight = pageMargins.bottom * 96;
52975
54515
  const footerPaddingFromEdge = pageMargins.footer * 96;
52976
54516
  const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
52977
- const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
52978
- const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
52979
- if (autoPageNumber) {
52980
- const fontSize2 = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
52981
- if (fontSize2) autoPageNumber.style.fontSize = fontSize2;
52982
- autoPageNumber.innerText = currentPageNumber;
52983
- }
52984
54517
  const editorContainer = document.createElement("div");
52985
54518
  if (!footerId && !editor.converter.footerIds["default"]) {
52986
54519
  footerId = "rId" + generateDocxRandomId();
@@ -53000,7 +54533,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
53000
54533
  appendToBody: false,
53001
54534
  sectionId: footerId,
53002
54535
  type: "footer",
53003
- availableHeight: footerHeight
54536
+ availableHeight: footerHeight,
54537
+ currentPageNumber
53004
54538
  });
53005
54539
  editor.converter.footerEditors.push({
53006
54540
  id: footerId,
@@ -53026,7 +54560,7 @@ const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
53026
54560
  editor.setEditable(false, false);
53027
54561
  toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
53028
54562
  };
53029
- function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter }) {
54563
+ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
53030
54564
  const { pageSize, pageMargins } = editor.converter.pageStyles;
53031
54565
  let sectionHeight = 0;
53032
54566
  const paginationDiv = document.createElement("div");
@@ -53045,7 +54579,10 @@ function createPageBreak({ editor, header, footer, footerBottom = null, isFirstH
53045
54579
  const separatorHeight = 20;
53046
54580
  sectionHeight += separatorHeight;
53047
54581
  const separator = document.createElement("div");
53048
- separator.className = "pagination-separator";
54582
+ separator.classList.add(SEPARATOR_CLASS);
54583
+ if (isInTable2) {
54584
+ separator.classList.add(`${SEPARATOR_CLASS}--table`);
54585
+ }
53049
54586
  innerDiv.appendChild(separator);
53050
54587
  }
53051
54588
  if (header) {
@@ -53084,6 +54621,85 @@ const onImageLoad = (editor) => {
53084
54621
  editor.view.dispatch(newTr);
53085
54622
  });
53086
54623
  };
54624
+ function createFloatingSeparator(separator, editor) {
54625
+ const floatingSeparator = document.createElement("div");
54626
+ floatingSeparator.classList.add(SEPARATOR_FLOATING_CLASS);
54627
+ floatingSeparator.dataset.floatingSeparator = "";
54628
+ const editorElement = editor.options.element;
54629
+ editorElement.append(floatingSeparator);
54630
+ const updatePosition2 = () => {
54631
+ computePosition(separator, floatingSeparator, {
54632
+ strategy: "absolute",
54633
+ placement: "top-start",
54634
+ middleware: [
54635
+ hide(),
54636
+ {
54637
+ name: "copy",
54638
+ fn: ({ elements }) => {
54639
+ const rect = elements.reference.getBoundingClientRect();
54640
+ const containerRect = editorElement.getBoundingClientRect();
54641
+ const scaleFactor = getScaleFactor(editorElement);
54642
+ const x = Math.round((rect.left - containerRect.left) / scaleFactor);
54643
+ const y = Math.round((rect.top - containerRect.top) / scaleFactor);
54644
+ const width = Math.round(rect.width / scaleFactor);
54645
+ const height = Math.round(rect.height / scaleFactor);
54646
+ return {
54647
+ x,
54648
+ y,
54649
+ data: { width, height }
54650
+ };
54651
+ }
54652
+ }
54653
+ ]
54654
+ }).then(({ x, y, middlewareData }) => {
54655
+ Object.assign(floatingSeparator.style, {
54656
+ top: `${y}px`,
54657
+ left: `${x}px`,
54658
+ width: `${middlewareData.copy.width}px`,
54659
+ height: `${middlewareData.copy.height}px`,
54660
+ visibility: middlewareData.hide?.referenceHidden ? "hidden" : "visible"
54661
+ });
54662
+ });
54663
+ };
54664
+ const cleanup = autoUpdate(
54665
+ separator,
54666
+ floatingSeparator,
54667
+ updatePosition2
54668
+ );
54669
+ const extendedCleanup = () => {
54670
+ floatingSeparator?.remove();
54671
+ cleanup();
54672
+ };
54673
+ return {
54674
+ cleanup: extendedCleanup,
54675
+ updatePosition: updatePosition2
54676
+ };
54677
+ }
54678
+ function cleanupFloatingSeparators() {
54679
+ cleanupFunctions.forEach((cleanup) => cleanup());
54680
+ cleanupFunctions.clear();
54681
+ }
54682
+ function getScaleFactor(element) {
54683
+ let scale = 1;
54684
+ let currentElement2 = element;
54685
+ while (currentElement2 && currentElement2 !== document.documentElement) {
54686
+ let zoomStyle = currentElement2.style.zoom;
54687
+ if (zoomStyle) {
54688
+ let zoom = parseFloat(zoomStyle) || 1;
54689
+ scale *= zoom;
54690
+ }
54691
+ let transformStyle = currentElement2.style.transform;
54692
+ if (transformStyle) {
54693
+ let scaleMatch = transformStyle.match(/scale\(([^)]+)\)/);
54694
+ if (scaleMatch) {
54695
+ let scaleValue = parseFloat(scaleMatch[1]) || 1;
54696
+ scale *= scaleValue;
54697
+ }
54698
+ }
54699
+ currentElement2 = currentElement2.parentElement;
54700
+ }
54701
+ return scale;
54702
+ }
53087
54703
  class SearchQuery {
53088
54704
  /**
53089
54705
  Create a query object.
@@ -53496,6 +55112,239 @@ const Search = Extension.create({
53496
55112
  };
53497
55113
  }
53498
55114
  });
55115
+ const NodeResizerKey = new PluginKey("node-resizer");
55116
+ const nodeResizer = (nodeNames = ["image"]) => {
55117
+ let resizeState = {
55118
+ dragging: false,
55119
+ startX: 0,
55120
+ startY: 0,
55121
+ startWidth: 0,
55122
+ handle: null,
55123
+ pos: null,
55124
+ resizableElement: null,
55125
+ aspectRatio: 1
55126
+ };
55127
+ let resizeContainer = null;
55128
+ let editorView = null;
55129
+ let globalClickHandler = null;
55130
+ let globalMousedownHandler = null;
55131
+ return new Plugin({
55132
+ key: NodeResizerKey,
55133
+ state: {
55134
+ init() {
55135
+ return DecorationSet.empty;
55136
+ },
55137
+ apply(tr, oldState, _, newState) {
55138
+ if (tr.getMeta(NodeResizerKey)) {
55139
+ return oldState;
55140
+ }
55141
+ const decorations = [];
55142
+ const { selection } = newState;
55143
+ if (nodeNames.includes(selection.node?.type.name)) {
55144
+ decorations.push(
55145
+ Decoration.node(selection.from, selection.to, {
55146
+ nodeName: "span",
55147
+ class: "sd-editor-resizable-wrapper",
55148
+ "data-pos": selection.from
55149
+ })
55150
+ );
55151
+ }
55152
+ return DecorationSet.create(newState.doc, decorations);
55153
+ }
55154
+ },
55155
+ props: {
55156
+ decorations(state2) {
55157
+ return this.getState(state2);
55158
+ }
55159
+ },
55160
+ view(view) {
55161
+ editorView = view;
55162
+ globalClickHandler = (event) => {
55163
+ if (!event.target.closest(".sd-editor-resizable-wrapper") && !event.target.closest(".sd-editor-resize-container")) {
55164
+ hideResizeHandles();
55165
+ }
55166
+ };
55167
+ document.addEventListener("click", globalClickHandler);
55168
+ globalMousedownHandler = (event) => {
55169
+ if (event.target.closest(".sd-editor-resize-handle")) {
55170
+ event.preventDefault();
55171
+ event.stopPropagation();
55172
+ startResize(editorView, event, event.target);
55173
+ return true;
55174
+ }
55175
+ };
55176
+ document.addEventListener("mousedown", globalMousedownHandler);
55177
+ return {
55178
+ update(view2, prevState) {
55179
+ const { selection } = view2.state;
55180
+ const prevSelection = prevState.selection;
55181
+ if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
55182
+ setTimeout(() => {
55183
+ const selectedResizableWrapper = document.querySelector(".sd-editor-resizable-wrapper");
55184
+ if (selectedResizableWrapper) {
55185
+ showResizeHandles(view2, selectedResizableWrapper);
55186
+ } else {
55187
+ hideResizeHandles();
55188
+ }
55189
+ }, 10);
55190
+ }
55191
+ },
55192
+ destroy() {
55193
+ hideResizeHandles();
55194
+ cleanupEventListeners();
55195
+ if (globalClickHandler) {
55196
+ document.removeEventListener("click", globalClickHandler);
55197
+ globalClickHandler = null;
55198
+ }
55199
+ if (globalMousedownHandler) {
55200
+ document.removeEventListener("mousedown", globalMousedownHandler);
55201
+ globalMousedownHandler = null;
55202
+ }
55203
+ editorView = null;
55204
+ }
55205
+ };
55206
+ }
55207
+ });
55208
+ function showResizeHandles(view, wrapper) {
55209
+ hideResizeHandles();
55210
+ const pos = Number.parseInt(wrapper.getAttribute("data-pos"), 10);
55211
+ const node2 = view.state.doc.nodeAt(pos);
55212
+ if (!nodeNames.includes(node2?.type.name)) return;
55213
+ resizeContainer = document.createElement("div");
55214
+ resizeContainer.className = "sd-editor-resize-container";
55215
+ resizeContainer.style.position = "absolute";
55216
+ resizeContainer.style.pointerEvents = "none";
55217
+ resizeContainer.style.zIndex = "1000";
55218
+ const handles = ["nw", "ne", "sw", "se"];
55219
+ for (const handle of handles) {
55220
+ const handleEl = document.createElement("div");
55221
+ handleEl.className = `sd-editor-resize-handle sd-editor-resize-handle-${handle}`;
55222
+ handleEl.setAttribute("data-handle", handle);
55223
+ handleEl.setAttribute("data-pos", pos);
55224
+ handleEl.style.pointerEvents = "auto";
55225
+ resizeContainer.appendChild(handleEl);
55226
+ }
55227
+ document.body.appendChild(resizeContainer);
55228
+ updateHandlePositions(wrapper.firstElementChild);
55229
+ }
55230
+ function hideResizeHandles() {
55231
+ if (resizeContainer?.parentNode) {
55232
+ resizeContainer.parentNode.removeChild(resizeContainer);
55233
+ resizeContainer = null;
55234
+ }
55235
+ }
55236
+ function updateHandlePositions(resizableElement) {
55237
+ if (!resizeContainer || !resizableElement) return;
55238
+ const rect = resizableElement.getBoundingClientRect();
55239
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
55240
+ const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
55241
+ resizeContainer.style.left = `${rect.left + scrollLeft}px`;
55242
+ resizeContainer.style.top = `${rect.top + scrollTop}px`;
55243
+ resizeContainer.style.width = `${rect.width}px`;
55244
+ resizeContainer.style.height = `${rect.height}px`;
55245
+ }
55246
+ function startResize(view, event, handleElement) {
55247
+ if (!view.hasFocus()) return;
55248
+ const handle = handleElement.getAttribute("data-handle");
55249
+ const pos = Number.parseInt(handleElement.getAttribute("data-pos"), 10);
55250
+ if (view.state.selection.from !== pos || !nodeNames.includes(view.state.selection.node?.type.name)) return;
55251
+ const resizableElement = view.nodeDOM(pos);
55252
+ if (!resizableElement) return;
55253
+ const rect = resizableElement.getBoundingClientRect();
55254
+ resizeState = {
55255
+ dragging: true,
55256
+ startX: event.clientX,
55257
+ startY: event.clientY,
55258
+ startWidth: rect.width,
55259
+ startHeight: rect.height,
55260
+ handle,
55261
+ pos,
55262
+ resizableElement,
55263
+ aspectRatio: rect.width / rect.height
55264
+ };
55265
+ document.addEventListener("mousemove", handleMouseMove2);
55266
+ document.addEventListener("mouseup", handleMouseUp);
55267
+ document.body.style.cursor = getResizeCursor(handle);
55268
+ document.body.style.userSelect = "none";
55269
+ }
55270
+ function handleMouseMove2(event) {
55271
+ if (!resizeState.dragging) return;
55272
+ event.preventDefault();
55273
+ event.stopPropagation();
55274
+ let deltaX = event.clientX - resizeState.startX;
55275
+ event.clientY - resizeState.startY;
55276
+ if (resizeState.handle.includes("w")) deltaX = -deltaX;
55277
+ if (resizeState.handle.includes("n")) ;
55278
+ const newWidth = Math.max(20, resizeState.startWidth + deltaX);
55279
+ if (resizeState.resizableElement) {
55280
+ resizeState.resizableElement.style.width = `${newWidth}px`;
55281
+ resizeState.resizableElement.style.height = "auto";
55282
+ updateHandlePositions(resizeState.resizableElement);
55283
+ }
55284
+ }
55285
+ function handleMouseUp(event) {
55286
+ if (!resizeState.dragging) return;
55287
+ cleanupEventListeners();
55288
+ let deltaX = event.clientX - resizeState.startX;
55289
+ event.clientY - resizeState.startY;
55290
+ if (resizeState.handle.includes("w")) deltaX = -deltaX;
55291
+ if (resizeState.handle.includes("n")) ;
55292
+ const newWidth = Math.max(20, resizeState.startWidth + deltaX);
55293
+ const newHeight = newWidth / resizeState.aspectRatio;
55294
+ if (editorView && resizeState.pos < editorView.state.doc.content.size) {
55295
+ const tr = editorView.state.tr;
55296
+ const node2 = tr.doc.nodeAt(resizeState.pos);
55297
+ if (nodeNames.includes(node2?.type.name)) {
55298
+ const attrs = {
55299
+ ...node2.attrs,
55300
+ size: {
55301
+ ...node2.attrs.size,
55302
+ width: Math.round(newWidth),
55303
+ height: Math.round(newHeight)
55304
+ }
55305
+ };
55306
+ tr.setNodeMarkup(resizeState.pos, null, attrs);
55307
+ tr.setMeta(NodeResizerKey, { action: "resize" });
55308
+ editorView.dispatch(tr);
55309
+ }
55310
+ }
55311
+ resizeState = {
55312
+ dragging: false,
55313
+ startX: 0,
55314
+ startY: 0,
55315
+ startWidth: 0,
55316
+ startHeight: 0,
55317
+ handle: null,
55318
+ pos: null,
55319
+ resizableElement: null,
55320
+ aspectRatio: 1
55321
+ };
55322
+ }
55323
+ function cleanupEventListeners() {
55324
+ document.removeEventListener("mousemove", handleMouseMove2);
55325
+ document.removeEventListener("mouseup", handleMouseUp);
55326
+ document.body.style.cursor = "";
55327
+ document.body.style.userSelect = "";
55328
+ }
55329
+ function getResizeCursor(handle) {
55330
+ switch (handle) {
55331
+ case "nw":
55332
+ case "se":
55333
+ return "nwse-resize";
55334
+ case "ne":
55335
+ case "sw":
55336
+ return "nesw-resize";
55337
+ default:
55338
+ return "default";
55339
+ }
55340
+ }
55341
+ };
55342
+ const NodeResizer = Extension.create({
55343
+ name: "nodeResizer",
55344
+ addPmPlugins() {
55345
+ return [nodeResizer(["image"])];
55346
+ }
55347
+ });
53499
55348
  const getRichTextExtensions = () => {
53500
55349
  return [
53501
55350
  Bold,
@@ -53533,7 +55382,8 @@ const getRichTextExtensions = () => {
53533
55382
  TrackDelete,
53534
55383
  TrackFormat,
53535
55384
  AiPlugin,
53536
- Image
55385
+ Image,
55386
+ NodeResizer
53537
55387
  ];
53538
55388
  };
53539
55389
  const getStarterExtensions = () => {
@@ -53597,7 +55447,8 @@ const getStarterExtensions = () => {
53597
55447
  ShapeTextbox,
53598
55448
  ContentBlock,
53599
55449
  Search,
53600
- StructuredContent
55450
+ StructuredContent,
55451
+ NodeResizer
53601
55452
  ];
53602
55453
  };
53603
55454
  const sanitizeNumber = (value, defaultNumber) => {
@@ -57123,7 +58974,7 @@ var ResizeObserverController = function() {
57123
58974
  };
57124
58975
  return ResizeObserverController2;
57125
58976
  }();
57126
- var ResizeObserver = function() {
58977
+ var ResizeObserver$1 = function() {
57127
58978
  function ResizeObserver2(callback) {
57128
58979
  if (arguments.length === 0) {
57129
58980
  throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
@@ -57162,7 +59013,7 @@ var ResizeObserver = function() {
57162
59013
  class ResizeObserverDelegate {
57163
59014
  constructor() {
57164
59015
  this.handleResize = this.handleResize.bind(this);
57165
- this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver)(this.handleResize);
59016
+ this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver$1)(this.handleResize);
57166
59017
  this.elHandlersMap = /* @__PURE__ */ new Map();
57167
59018
  }
57168
59019
  handleResize(entries) {
@@ -66307,140 +68158,6 @@ const makeDefaultItems = ({
66307
68158
  overflowItems: overflowItems.filter((item) => item.type !== "separator")
66308
68159
  };
66309
68160
  };
66310
- const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
66311
- const getFileOpener = () => {
66312
- let fileInput = document.createElement("input");
66313
- fileInput.type = "file";
66314
- let acceptTypes = ACCEPT_IMAGE_TYPES;
66315
- fileInput.accept = acceptTypes.join(",");
66316
- const openFile = () => {
66317
- return new Promise((resolve, reject) => {
66318
- fileInput.onchange = async () => {
66319
- const files = fileInput.files;
66320
- if (!files) return resolve(null);
66321
- const file = files.item(0);
66322
- if (!file) return resolve(null);
66323
- return resolve({ file });
66324
- };
66325
- fileInput.oncancel = () => resolve(null);
66326
- fileInput.onerror = reject;
66327
- fileInput.click();
66328
- });
66329
- };
66330
- return openFile;
66331
- };
66332
- const handleImageUpload = (file) => {
66333
- return new Promise((resolve, reject) => {
66334
- let reader = new FileReader();
66335
- reader.onload = (event) => resolve(event.target.result);
66336
- reader.onerror = reject;
66337
- setTimeout(() => reader.readAsDataURL(file), 250);
66338
- });
66339
- };
66340
- const processUploadedImage = (fileData, editor) => {
66341
- return new Promise((resolve, reject) => {
66342
- const img = new window.Image();
66343
- img.onload = () => {
66344
- const canvas = document.createElement("canvas");
66345
- const { width, height } = getAllowedImageDimensions(
66346
- img.width,
66347
- img.height,
66348
- editor
66349
- );
66350
- canvas.width = width;
66351
- canvas.height = height;
66352
- const ctx2 = canvas.getContext("2d");
66353
- ctx2.drawImage(img, 0, 0, width, height);
66354
- if (typeof fileData === "string") {
66355
- const resizedBase64 = canvas.toDataURL();
66356
- resolve(resizedBase64);
66357
- } else {
66358
- canvas.toBlob((blob) => {
66359
- const updatedFile = new File([blob], fileData.name, {
66360
- type: fileData.type,
66361
- lastModified: Date.now()
66362
- });
66363
- resolve({ file: updatedFile, width, height });
66364
- });
66365
- }
66366
- };
66367
- img.onerror = (error) => reject(error);
66368
- img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
66369
- });
66370
- };
66371
- const getAllowedImageDimensions = (width, height, editor) => {
66372
- const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
66373
- if (!maxWidth || !maxHeight) return { width, height };
66374
- let adjustedWidth = width;
66375
- let adjustedHeight = height;
66376
- const aspectRatio = width / height;
66377
- if (height > maxHeight) {
66378
- adjustedHeight = maxHeight;
66379
- adjustedWidth = Math.round(maxHeight * aspectRatio);
66380
- }
66381
- if (adjustedWidth > maxWidth) {
66382
- adjustedWidth = maxWidth;
66383
- adjustedHeight = Math.round(maxWidth / aspectRatio);
66384
- }
66385
- return { width: adjustedWidth, height: adjustedHeight };
66386
- };
66387
- const startImageUpload = async ({ editor, view, file }) => {
66388
- let imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
66389
- let fileSizeMb = (file.size / (1024 * 1024)).toFixed(4);
66390
- if (fileSizeMb > 5) {
66391
- window.alert("Image size must be less than 5MB");
66392
- return;
66393
- }
66394
- let width;
66395
- let height;
66396
- try {
66397
- const processedImageResult = await processUploadedImage(file, editor);
66398
- width = processedImageResult.width;
66399
- height = processedImageResult.height;
66400
- file = processedImageResult.file;
66401
- } catch (err) {
66402
- console.warn("Error processing image:", err);
66403
- return;
66404
- }
66405
- let id = {};
66406
- let { tr, schema } = view.state;
66407
- if (!tr.selection.empty) {
66408
- tr.deleteSelection();
66409
- }
66410
- let imageMeta = {
66411
- type: "add",
66412
- pos: tr.selection.from,
66413
- id
66414
- };
66415
- tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
66416
- view.dispatch(tr);
66417
- imageUploadHandler(file).then(
66418
- (url) => {
66419
- let fileName = file.name.replace(" ", "_");
66420
- let placeholderPos = findPlaceholder(view.state, id);
66421
- if (placeholderPos == null) {
66422
- return;
66423
- }
66424
- let removeMeta = { type: "remove", id };
66425
- let mediaPath = `word/media/${fileName}`;
66426
- let imageNode = schema.nodes.image.create({
66427
- src: mediaPath,
66428
- size: { width, height }
66429
- });
66430
- editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
66431
- if (editor.options.ydoc) {
66432
- editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
66433
- }
66434
- view.dispatch(
66435
- view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
66436
- );
66437
- },
66438
- () => {
66439
- let removeMeta = { type: "remove", id };
66440
- view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
66441
- }
66442
- );
66443
- };
66444
68161
  const toolbarTexts = {
66445
68162
  bold: "Bold",
66446
68163
  fontFamily: "Font",
@@ -67568,7 +69285,7 @@ const _sfc_main$2 = {
67568
69285
  };
67569
69286
  }
67570
69287
  };
67571
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-199a4ecf"]]);
69288
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-4b700df1"]]);
67572
69289
  const _sfc_main$1 = {
67573
69290
  __name: "BasicUpload",
67574
69291
  emits: ["file-change"],