@harbour-enterprises/superdoc 0.12.36-next.7 → 0.12.36-next.8

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 (30) hide show
  1. package/dist/chunks/{super-editor.es-X2sJyEa5.cjs → super-editor.es-DO-kuhQq.cjs} +312 -29
  2. package/dist/chunks/{super-editor.es-u7Bq9xUN.es.js → super-editor.es-knUqfjv8.es.js} +312 -29
  3. package/dist/style.css +13 -0
  4. package/dist/super-editor/ai-writer.es.js +2 -2
  5. package/dist/super-editor/chunks/{converter-wbU2SP4i.js → converter-BCnMtqK6.js} +104 -7
  6. package/dist/super-editor/chunks/{docx-zipper-BL3thpAA.js → docx-zipper-BEWaJso4.js} +1 -1
  7. package/dist/super-editor/chunks/{editor-CrElllON.js → editor-CTFQa4G4.js} +210 -24
  8. package/dist/super-editor/chunks/{toolbar-DJBp5g7l.js → toolbar-CJt0mQxX.js} +2 -2
  9. package/dist/super-editor/converter.es.js +1 -1
  10. package/dist/super-editor/core/Attribute.d.ts +2 -2
  11. package/dist/super-editor/core/Schema.d.ts +2 -2
  12. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  13. package/dist/super-editor/core/super-converter/v2/importer/autoPageNumberImporter.d.ts.map +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/extensions/page-number/page-number.d.ts +10 -0
  17. package/dist/super-editor/extensions/page-number/page-number.d.ts.map +1 -1
  18. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +2 -1
  19. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/style.css +13 -0
  22. package/dist/super-editor/super-editor.es.js +6 -6
  23. package/dist/super-editor/toolbar.es.js +2 -2
  24. package/dist/super-editor.cjs +1 -1
  25. package/dist/super-editor.es.js +1 -1
  26. package/dist/superdoc.cjs +2 -2
  27. package/dist/superdoc.es.js +3 -3
  28. package/dist/superdoc.umd.js +313 -30
  29. package/dist/superdoc.umd.js.map +1 -1
  30. package/package.json +1 -1
@@ -18862,7 +18862,9 @@ function exportSchemaToJson(params2) {
18862
18862
  shapeContainer: translateShapeContainer,
18863
18863
  shapeTextbox: translateShapeTextbox,
18864
18864
  contentBlock: translateContentBlock,
18865
- structuredContent: translateStructuredContent
18865
+ structuredContent: translateStructuredContent,
18866
+ "page-number": translatePageNumberNode,
18867
+ "total-page-number": translateTotalPageNumberNode
18866
18868
  };
18867
18869
  if (!router[type2]) {
18868
18870
  console.error("No translation function found for node type:", type2);
@@ -20559,6 +20561,81 @@ function translateStructuredContent(params2) {
20559
20561
  elements: nodeElements
20560
20562
  };
20561
20563
  }
20564
+ const translatePageNumberNode = (params2) => {
20565
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20566
+ return getAutoPageJson("PAGE", outputMarks);
20567
+ };
20568
+ const translateTotalPageNumberNode = (params2) => {
20569
+ const outputMarks = processOutputMarks(params2.node.attrs?.marksAsAttrs || []);
20570
+ return getAutoPageJson("NUMPAGES", outputMarks);
20571
+ };
20572
+ const getAutoPageJson = (type2, outputMarks = []) => {
20573
+ return [
20574
+ {
20575
+ "name": "w:r",
20576
+ "elements": [
20577
+ {
20578
+ "name": "w:rPr",
20579
+ "elements": outputMarks
20580
+ },
20581
+ {
20582
+ "name": "w:fldChar",
20583
+ "attributes": {
20584
+ "w:fldCharType": "begin"
20585
+ }
20586
+ }
20587
+ ]
20588
+ },
20589
+ {
20590
+ "name": "w:r",
20591
+ "elements": [
20592
+ {
20593
+ "name": "w:rPr",
20594
+ "elements": outputMarks
20595
+ },
20596
+ {
20597
+ "name": "w:instrText",
20598
+ "elements": [
20599
+ {
20600
+ "type": "text",
20601
+ "text": ` ${type2}`
20602
+ }
20603
+ ]
20604
+ }
20605
+ ]
20606
+ },
20607
+ {
20608
+ "name": "w:r",
20609
+ "elements": [
20610
+ {
20611
+ "name": "w:rPr",
20612
+ "elements": outputMarks
20613
+ },
20614
+ {
20615
+ "name": "w:fldChar",
20616
+ "attributes": {
20617
+ "w:fldCharType": "separate"
20618
+ }
20619
+ }
20620
+ ]
20621
+ },
20622
+ {
20623
+ "name": "w:r",
20624
+ "elements": [
20625
+ {
20626
+ "name": "w:rPr",
20627
+ "elements": outputMarks
20628
+ },
20629
+ {
20630
+ "name": "w:fldChar",
20631
+ "attributes": {
20632
+ "w:fldCharType": "end"
20633
+ }
20634
+ }
20635
+ ]
20636
+ }
20637
+ ];
20638
+ };
20562
20639
  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>`;
20563
20640
  const parseXmlToJson = (xml) => {
20564
20641
  return JSON.parse(xmljs.xml2json(xml, null, 2));
@@ -22267,15 +22344,25 @@ const processCombinedNodesForFldChar = (nodesToCombine = []) => {
22267
22344
  if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
22268
22345
  const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
22269
22346
  if (hasPageMarker) {
22270
- processedNodes.push({
22347
+ const pageNumNode = {
22271
22348
  name: "sd:autoPageNumber",
22272
22349
  type: "element"
22350
+ };
22351
+ nodesToCombine.forEach((n) => {
22352
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22353
+ if (rPrNode) pageNumNode.elements = [rPrNode];
22273
22354
  });
22355
+ processedNodes.push(pageNumNode);
22274
22356
  } else if (isNumPages) {
22275
- processedNodes.push({
22357
+ const totalPageNumNode = {
22276
22358
  name: "sd:totalPageNumber",
22277
22359
  type: "element"
22360
+ };
22361
+ nodesToCombine.forEach((n) => {
22362
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22363
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
22278
22364
  });
22365
+ processedNodes.push(totalPageNumNode);
22279
22366
  } else if (urlMatch && urlMatch?.length >= 2) {
22280
22367
  const url = urlMatch[1];
22281
22368
  const textMarks = [];
@@ -22611,8 +22698,13 @@ const handleAutoPageNumber = (params2) => {
22611
22698
  if (nodes.length === 0 || nodes[0].name !== "sd:autoPageNumber") {
22612
22699
  return { nodes: [], consumed: 0 };
22613
22700
  }
22701
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22702
+ const marks = parseMarks(rPr || { elements: [] });
22614
22703
  const processedNode = {
22615
- type: "page-number"
22704
+ type: "page-number",
22705
+ attrs: {
22706
+ marksAsAttrs: marks
22707
+ }
22616
22708
  };
22617
22709
  return { nodes: [processedNode], consumed: 1 };
22618
22710
  };
@@ -22625,8 +22717,13 @@ const handleAutoTotalPageNumber = (params2) => {
22625
22717
  if (nodes.length === 0 || nodes[0].name !== "sd:totalPageNumber") {
22626
22718
  return { nodes: [], consumed: 0 };
22627
22719
  }
22720
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22721
+ const marks = parseMarks(rPr || { elements: [] });
22628
22722
  const processedNode = {
22629
- type: "total-page-number"
22723
+ type: "total-page-number",
22724
+ attrs: {
22725
+ marksAsAttrs: marks
22726
+ }
22630
22727
  };
22631
22728
  return { nodes: [processedNode], consumed: 1 };
22632
22729
  };
@@ -23311,7 +23408,7 @@ const _SuperConverter = class _SuperConverter2 {
23311
23408
  return;
23312
23409
  }
23313
23410
  }
23314
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.36-next.7") {
23411
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.36-next.8") {
23315
23412
  const customLocation = "docProps/custom.xml";
23316
23413
  if (!docx[customLocation]) {
23317
23414
  docx[customLocation] = generateCustomXml();
@@ -23778,7 +23875,7 @@ function storeSuperdocVersion(docx) {
23778
23875
  function generateCustomXml() {
23779
23876
  return DEFAULT_CUSTOM_XML;
23780
23877
  }
23781
- function generateSuperdocVersion(pid = 2, version2 = "0.12.36-next.7") {
23878
+ function generateSuperdocVersion(pid = 2, version2 = "0.12.36-next.8") {
23782
23879
  return {
23783
23880
  type: "element",
23784
23881
  name: "property",
@@ -26311,7 +26408,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
26311
26408
  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);
26312
26409
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
26313
26410
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
26314
- 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;
26411
+ 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;
26315
26412
  function getMarksFromSelection(state2) {
26316
26413
  const { from: from2, to, empty: empty2 } = state2.selection;
26317
26414
  const marks = [];
@@ -39080,7 +39177,8 @@ const createHeaderFooterEditor = ({
39080
39177
  appendToBody = true,
39081
39178
  sectionId,
39082
39179
  type: type2,
39083
- availableHeight
39180
+ availableHeight,
39181
+ currentPageNumber
39084
39182
  }) => {
39085
39183
  const parentStyles = editor.converter.getDocumentDefaultStyles();
39086
39184
  const { fontSizePt, typeface } = parentStyles;
@@ -39121,6 +39219,8 @@ const createHeaderFooterEditor = ({
39121
39219
  fonts: editor.options.fonts,
39122
39220
  isHeaderOrFooter: true,
39123
39221
  annotations: true,
39222
+ currentPageNumber,
39223
+ parentEditor: editor,
39124
39224
  onCreate: (evt) => setEditorToolbar(evt, editor),
39125
39225
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
39126
39226
  });
@@ -41119,7 +41219,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41119
41219
  * @returns {Object | void} Migration results
41120
41220
  */
41121
41221
  processCollaborationMigrations() {
41122
- console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.7");
41222
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.8");
41123
41223
  if (!this.options.ydoc) return;
41124
41224
  const metaMap = this.options.ydoc.getMap("meta");
41125
41225
  let docVersion = metaMap.get("version");
@@ -48767,32 +48867,89 @@ const PageNumber = Node$1.create({
48767
48867
  name: "page-number",
48768
48868
  group: "inline",
48769
48869
  inline: true,
48770
- content: "text*",
48870
+ atom: true,
48871
+ selectable: false,
48872
+ draggable: false,
48873
+ selectable: false,
48874
+ defining: true,
48875
+ content: "",
48771
48876
  addOptions() {
48772
48877
  return {
48773
48878
  htmlAttributes: {
48879
+ contenteditable: false,
48774
48880
  "data-id": "auto-page-number",
48775
48881
  "aria-label": "Page number node"
48776
48882
  }
48777
48883
  };
48778
48884
  },
48885
+ addAttributes() {
48886
+ return {
48887
+ marksAsAttrs: {
48888
+ default: null,
48889
+ rendered: false
48890
+ }
48891
+ };
48892
+ },
48893
+ addNodeView() {
48894
+ return ({ node: node2, editor, getPos, decorations }) => {
48895
+ const htmlAttributes = this.options.htmlAttributes;
48896
+ return new AutoPageNumberNodeView(node2, getPos, decorations, editor, htmlAttributes);
48897
+ };
48898
+ },
48779
48899
  parseDOM() {
48780
48900
  return [{ tag: 'span[data-id="auto-page-number"' }];
48781
48901
  },
48782
48902
  renderDOM({ htmlAttributes }) {
48783
- return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48903
+ return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
48904
+ },
48905
+ addCommands() {
48906
+ return {
48907
+ addAutoPageNumber: () => ({ tr, dispatch, state: state2, editor }) => {
48908
+ const { options: options2 } = editor;
48909
+ if (!options2.isHeaderOrFooter) return false;
48910
+ const { schema } = state2;
48911
+ const pageNumberType = schema?.nodes?.["page-number"];
48912
+ if (!pageNumberType) return false;
48913
+ const pageNumberNodeJSON = { type: "page-number" };
48914
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
48915
+ if (dispatch) {
48916
+ tr.replaceSelectionWith(pageNumberNode, false);
48917
+ tr.setMeta("forceUpdatePagination", true);
48918
+ }
48919
+ return true;
48920
+ }
48921
+ };
48922
+ },
48923
+ addShortcuts() {
48924
+ return {
48925
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
48926
+ };
48784
48927
  }
48785
48928
  });
48786
48929
  const TotalPageCount = Node$1.create({
48787
48930
  name: "total-page-number",
48788
48931
  group: "inline",
48789
48932
  inline: true,
48933
+ atom: true,
48934
+ selectable: false,
48935
+ draggable: false,
48936
+ selectable: false,
48790
48937
  content: "text*",
48791
48938
  addOptions() {
48792
48939
  return {
48793
48940
  htmlAttributes: {
48941
+ contenteditable: false,
48794
48942
  "data-id": "auto-total-pages",
48795
- "aria-label": "Total page count node"
48943
+ "aria-label": "Total page count node",
48944
+ "class": "sd-editor-auto-total-pages"
48945
+ }
48946
+ };
48947
+ },
48948
+ addAttributes() {
48949
+ return {
48950
+ marksAsAttrs: {
48951
+ default: null,
48952
+ rendered: false
48796
48953
  }
48797
48954
  };
48798
48955
  },
@@ -48801,8 +48958,139 @@ const TotalPageCount = Node$1.create({
48801
48958
  },
48802
48959
  renderDOM({ htmlAttributes }) {
48803
48960
  return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48961
+ },
48962
+ addCommands() {
48963
+ return {
48964
+ addTotalPageCount: () => ({ tr, dispatch, state: state2, editor }) => {
48965
+ const { options: options2 } = editor;
48966
+ if (!options2.isHeaderOrFooter) return false;
48967
+ const { schema } = state2;
48968
+ const pageNumberType = schema.nodes?.["total-page-number"];
48969
+ if (!pageNumberType) return false;
48970
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
48971
+ const pageNumberNode = {
48972
+ type: "total-page-number",
48973
+ content: [{ type: "text", text: String(currentPages) }]
48974
+ };
48975
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
48976
+ if (dispatch) {
48977
+ tr.replaceSelectionWith(pageNode, false);
48978
+ }
48979
+ return true;
48980
+ }
48981
+ };
48982
+ },
48983
+ addShortcuts() {
48984
+ return {
48985
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
48986
+ };
48804
48987
  }
48805
48988
  });
48989
+ class AutoPageNumberNodeView {
48990
+ constructor(node2, getPos, decorations, editor, htmlAttributes = {}) {
48991
+ __privateAdd$1(this, _AutoPageNumberNodeView_instances);
48992
+ this.node = node2;
48993
+ this.editor = editor;
48994
+ this.view = editor.view;
48995
+ this.getPos = getPos;
48996
+ this.editor = editor;
48997
+ this.dom = __privateMethod$1(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node2, htmlAttributes);
48998
+ }
48999
+ update(node2) {
49000
+ if (node2.type !== this.node.type) return false;
49001
+ this.node = node2;
49002
+ return true;
49003
+ }
49004
+ }
49005
+ _AutoPageNumberNodeView_instances = /* @__PURE__ */ new WeakSet();
49006
+ renderDom_fn = function(node2, htmlAttributes) {
49007
+ const pageText = this.editor.options.currentPageNumber || "1";
49008
+ const content = document.createTextNode(String(pageText));
49009
+ const nodeContent = document.createElement("span");
49010
+ nodeContent.className = "sd-editor-auto-page-number";
49011
+ nodeContent.setAttribute("data-id", "auto-page-number");
49012
+ nodeContent.setAttribute("aria-label", "Page number node");
49013
+ const currentPos = this.getPos();
49014
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
49015
+ __privateMethod$1(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
49016
+ Object.assign(nodeContent.style, styles);
49017
+ nodeContent.appendChild(content);
49018
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
49019
+ if (value) nodeContent.setAttribute(key, value);
49020
+ });
49021
+ return nodeContent;
49022
+ };
49023
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
49024
+ setTimeout(() => {
49025
+ const { state: state2 } = this.editor;
49026
+ const { dispatch } = this.view;
49027
+ const node2 = state2.doc.nodeAt(pos);
49028
+ if (!node2) return;
49029
+ const currentMarks = node2.attrs.marksAsAttrs || [];
49030
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
49031
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
49032
+ if (isEqual) return;
49033
+ const newAttrs = {
49034
+ ...node2.attrs,
49035
+ marksAsAttrs: newMarks
49036
+ };
49037
+ const tr = state2.tr.setNodeMarkup(pos, void 0, newAttrs);
49038
+ dispatch(tr);
49039
+ }, 0);
49040
+ };
49041
+ const getMarksFromNeighbors = (currentPos, view) => {
49042
+ const $pos = view.state.doc.resolve(currentPos);
49043
+ const styles = {};
49044
+ const marks = [];
49045
+ const before = $pos.nodeBefore;
49046
+ if (before) {
49047
+ Object.assign(styles, processMarks(before.marks));
49048
+ marks.push(...before.marks);
49049
+ }
49050
+ const after = $pos.nodeAfter;
49051
+ if (after) {
49052
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
49053
+ marks.push(...after.marks);
49054
+ }
49055
+ return {
49056
+ styles,
49057
+ marks
49058
+ };
49059
+ };
49060
+ const processMarks = (marks) => {
49061
+ const styles = {};
49062
+ marks.forEach((mark) => {
49063
+ const { type: type2, attrs } = mark;
49064
+ switch (type2.name) {
49065
+ case "textStyle":
49066
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
49067
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
49068
+ if (attrs.color) styles["color"] = attrs.color;
49069
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
49070
+ break;
49071
+ case "bold":
49072
+ styles["font-weight"] = "bold";
49073
+ break;
49074
+ case "italic":
49075
+ styles["font-style"] = "italic";
49076
+ break;
49077
+ case "underline":
49078
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
49079
+ break;
49080
+ case "strike":
49081
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
49082
+ break;
49083
+ default:
49084
+ if (attrs?.style) {
49085
+ Object.entries(attrs.style).forEach(([key, value]) => {
49086
+ styles[key] = value;
49087
+ });
49088
+ }
49089
+ break;
49090
+ }
49091
+ });
49092
+ return styles;
49093
+ };
48806
49094
  const ShapeContainer = Node$1.create({
48807
49095
  name: "shapeContainer",
48808
49096
  group: "block",
@@ -52840,16 +53128,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52840
53128
  const decorations = [];
52841
53129
  const { pageSize, pageMargins } = editor.converter.pageStyles;
52842
53130
  const pageHeight = pageSize.height * 96;
52843
- editor.options.scale;
52844
53131
  let currentPageNumber = 1;
52845
53132
  let pageHeightThreshold = pageHeight;
52846
53133
  let footer = null, header = null;
52847
53134
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52848
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
53135
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
52849
53136
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
52850
53137
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
52851
53138
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52852
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
53139
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
52853
53140
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
52854
53141
  let coords = view?.coordsAtPos(doc2.content.size);
52855
53142
  if (!coords) return [];
@@ -52868,7 +53155,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52868
53155
  if (currentPageNumber === 1) {
52869
53156
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
52870
53157
  decorations.pop();
52871
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
53158
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52872
53159
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
52873
53160
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
52874
53161
  }
@@ -52897,7 +53184,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52897
53184
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
52898
53185
  currentPageNumber++;
52899
53186
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52900
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
53187
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52901
53188
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
52902
53189
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
52903
53190
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
@@ -52912,7 +53199,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52912
53199
  const lastNodeCoords = view.coordsAtPos(finalPos);
52913
53200
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52914
53201
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52915
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
53202
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
52916
53203
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
52917
53204
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
52918
53205
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -52929,6 +53216,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52929
53216
  totalPageNumber.innerText = currentPageNumber;
52930
53217
  }
52931
53218
  });
53219
+ editor.currentTotalPages = currentPageNumber;
52932
53220
  return decorations;
52933
53221
  }
52934
53222
  function createFinalPagePadding(bufferHeight) {
@@ -52939,7 +53227,7 @@ function createFinalPagePadding(bufferHeight) {
52939
53227
  div2.style.height = bufferHeight + "px";
52940
53228
  return { nodeHeight: bufferHeight, node: div2 };
52941
53229
  }
52942
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
53230
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
52943
53231
  const headerDef = sectionData.headers?.[headerId];
52944
53232
  const minHeaderHeight = pageMargins.top * 96;
52945
53233
  const headerMargin = pageMargins.header * 96;
@@ -52966,7 +53254,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
52966
53254
  appendToBody: false,
52967
53255
  sectionId: headerId,
52968
53256
  type: "header",
52969
- availableHeight
53257
+ availableHeight,
53258
+ currentPageNumber
52970
53259
  });
52971
53260
  editor.converter.headerEditors.push({
52972
53261
  id: headerId,
@@ -52992,13 +53281,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
52992
53281
  const minFooterHeight = pageMargins.bottom * 96;
52993
53282
  const footerPaddingFromEdge = pageMargins.footer * 96;
52994
53283
  const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
52995
- const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
52996
- const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
52997
- if (autoPageNumber) {
52998
- const fontSize2 = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
52999
- if (fontSize2) autoPageNumber.style.fontSize = fontSize2;
53000
- autoPageNumber.innerText = currentPageNumber;
53001
- }
53002
53284
  const editorContainer = document.createElement("div");
53003
53285
  if (!footerId && !editor.converter.footerIds["default"]) {
53004
53286
  footerId = "rId" + generateDocxRandomId();
@@ -53018,7 +53300,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
53018
53300
  appendToBody: false,
53019
53301
  sectionId: footerId,
53020
53302
  type: "footer",
53021
- availableHeight: footerHeight
53303
+ availableHeight: footerHeight,
53304
+ currentPageNumber
53022
53305
  });
53023
53306
  editor.converter.footerEditors.push({
53024
53307
  id: footerId,