@harbour-enterprises/superdoc 0.12.36-next.6 → 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 (31) hide show
  1. package/dist/chunks/{super-editor.es-H72UDWQx.cjs → super-editor.es-DO-kuhQq.cjs} +316 -32
  2. package/dist/chunks/{super-editor.es-C5YefmYN.es.js → super-editor.es-knUqfjv8.es.js} +316 -32
  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-DY26Bu8a.js → converter-BCnMtqK6.js} +104 -7
  6. package/dist/super-editor/chunks/{docx-zipper-B4BvVBcx.js → docx-zipper-BEWaJso4.js} +1 -1
  7. package/dist/super-editor/chunks/{editor-w6HF4T0Y.js → editor-CTFQa4G4.js} +214 -27
  8. package/dist/super-editor/chunks/{toolbar-Ctfr_bH2.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/Editor.d.ts.map +1 -1
  12. package/dist/super-editor/core/Schema.d.ts +2 -2
  13. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  14. package/dist/super-editor/core/super-converter/v2/importer/autoPageNumberImporter.d.ts.map +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/extensions/page-number/page-number.d.ts +10 -0
  18. package/dist/super-editor/extensions/page-number/page-number.d.ts.map +1 -1
  19. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +2 -1
  20. package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
  21. package/dist/super-editor/file-zipper.es.js +1 -1
  22. package/dist/super-editor/style.css +13 -0
  23. package/dist/super-editor/super-editor.es.js +6 -6
  24. package/dist/super-editor/toolbar.es.js +2 -2
  25. package/dist/super-editor.cjs +1 -1
  26. package/dist/super-editor.es.js +1 -1
  27. package/dist/superdoc.cjs +2 -2
  28. package/dist/superdoc.es.js +3 -3
  29. package/dist/superdoc.umd.js +317 -33
  30. package/dist/superdoc.umd.js.map +1 -1
  31. package/package.json +1 -1
@@ -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));
@@ -22250,15 +22327,25 @@ const processCombinedNodesForFldChar = (nodesToCombine = []) => {
22250
22327
  if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
22251
22328
  const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
22252
22329
  if (hasPageMarker) {
22253
- processedNodes.push({
22330
+ const pageNumNode = {
22254
22331
  name: "sd:autoPageNumber",
22255
22332
  type: "element"
22333
+ };
22334
+ nodesToCombine.forEach((n) => {
22335
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22336
+ if (rPrNode) pageNumNode.elements = [rPrNode];
22256
22337
  });
22338
+ processedNodes.push(pageNumNode);
22257
22339
  } else if (isNumPages) {
22258
- processedNodes.push({
22340
+ const totalPageNumNode = {
22259
22341
  name: "sd:totalPageNumber",
22260
22342
  type: "element"
22343
+ };
22344
+ nodesToCombine.forEach((n) => {
22345
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22346
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
22261
22347
  });
22348
+ processedNodes.push(totalPageNumNode);
22262
22349
  } else if (urlMatch && urlMatch?.length >= 2) {
22263
22350
  const url = urlMatch[1];
22264
22351
  const textMarks = [];
@@ -22594,8 +22681,13 @@ const handleAutoPageNumber = (params2) => {
22594
22681
  if (nodes.length === 0 || nodes[0].name !== "sd:autoPageNumber") {
22595
22682
  return { nodes: [], consumed: 0 };
22596
22683
  }
22684
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22685
+ const marks = parseMarks(rPr || { elements: [] });
22597
22686
  const processedNode = {
22598
- type: "page-number"
22687
+ type: "page-number",
22688
+ attrs: {
22689
+ marksAsAttrs: marks
22690
+ }
22599
22691
  };
22600
22692
  return { nodes: [processedNode], consumed: 1 };
22601
22693
  };
@@ -22608,8 +22700,13 @@ const handleAutoTotalPageNumber = (params2) => {
22608
22700
  if (nodes.length === 0 || nodes[0].name !== "sd:totalPageNumber") {
22609
22701
  return { nodes: [], consumed: 0 };
22610
22702
  }
22703
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22704
+ const marks = parseMarks(rPr || { elements: [] });
22611
22705
  const processedNode = {
22612
- type: "total-page-number"
22706
+ type: "total-page-number",
22707
+ attrs: {
22708
+ marksAsAttrs: marks
22709
+ }
22613
22710
  };
22614
22711
  return { nodes: [processedNode], consumed: 1 };
22615
22712
  };
@@ -23294,7 +23391,7 @@ const _SuperConverter = class _SuperConverter2 {
23294
23391
  return;
23295
23392
  }
23296
23393
  }
23297
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.36-next.6") {
23394
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.36-next.8") {
23298
23395
  const customLocation = "docProps/custom.xml";
23299
23396
  if (!docx[customLocation]) {
23300
23397
  docx[customLocation] = generateCustomXml();
@@ -23761,7 +23858,7 @@ function storeSuperdocVersion(docx) {
23761
23858
  function generateCustomXml() {
23762
23859
  return DEFAULT_CUSTOM_XML;
23763
23860
  }
23764
- function generateSuperdocVersion(pid = 2, version2 = "0.12.36-next.6") {
23861
+ function generateSuperdocVersion(pid = 2, version2 = "0.12.36-next.8") {
23765
23862
  return {
23766
23863
  type: "element",
23767
23864
  name: "property",
@@ -26294,7 +26391,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
26294
26391
  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
26392
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
26296
26393
  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;
26394
+ 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
26395
  function getMarksFromSelection(state2) {
26299
26396
  const { from: from2, to, empty: empty2 } = state2.selection;
26300
26397
  const marks = [];
@@ -39063,7 +39160,8 @@ const createHeaderFooterEditor = ({
39063
39160
  appendToBody = true,
39064
39161
  sectionId,
39065
39162
  type: type2,
39066
- availableHeight
39163
+ availableHeight,
39164
+ currentPageNumber
39067
39165
  }) => {
39068
39166
  const parentStyles = editor.converter.getDocumentDefaultStyles();
39069
39167
  const { fontSizePt, typeface } = parentStyles;
@@ -39104,6 +39202,8 @@ const createHeaderFooterEditor = ({
39104
39202
  fonts: editor.options.fonts,
39105
39203
  isHeaderOrFooter: true,
39106
39204
  annotations: true,
39205
+ currentPageNumber,
39206
+ parentEditor: editor,
39107
39207
  onCreate: (evt) => setEditorToolbar(evt, editor),
39108
39208
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type2)
39109
39209
  });
@@ -40247,9 +40347,9 @@ const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
40247
40347
  if (type2.name !== "paragraph" && type2.name !== "fieldAnnotation") return;
40248
40348
  child.children.forEach((inline) => {
40249
40349
  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;
40350
+ const isFieldType = inline.type.name === "fieldAnnotation";
40351
+ const isMatchingField = isFieldType && isFieldToDelete;
40352
+ if (!isFieldType && !isMatchingField) hasOtherNodes = true;
40253
40353
  if (isMatchingField) matchingNodesFound += 1;
40254
40354
  });
40255
40355
  });
@@ -40694,6 +40794,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
40694
40794
  __privateMethod$1(this, _Editor_instances, initMedia_fn).call(this);
40695
40795
  const doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
40696
40796
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
40797
+ tr.setMeta("replaceContent", true);
40697
40798
  this.view.dispatch(tr);
40698
40799
  }
40699
40800
  /**
@@ -41101,7 +41202,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41101
41202
  * @returns {Object | void} Migration results
41102
41203
  */
41103
41204
  processCollaborationMigrations() {
41104
- console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.6");
41205
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.8");
41105
41206
  if (!this.options.ydoc) return;
41106
41207
  const metaMap = this.options.ydoc.getMap("meta");
41107
41208
  let docVersion = metaMap.get("version");
@@ -48749,32 +48850,89 @@ const PageNumber = Node$1.create({
48749
48850
  name: "page-number",
48750
48851
  group: "inline",
48751
48852
  inline: true,
48752
- content: "text*",
48853
+ atom: true,
48854
+ selectable: false,
48855
+ draggable: false,
48856
+ selectable: false,
48857
+ defining: true,
48858
+ content: "",
48753
48859
  addOptions() {
48754
48860
  return {
48755
48861
  htmlAttributes: {
48862
+ contenteditable: false,
48756
48863
  "data-id": "auto-page-number",
48757
48864
  "aria-label": "Page number node"
48758
48865
  }
48759
48866
  };
48760
48867
  },
48868
+ addAttributes() {
48869
+ return {
48870
+ marksAsAttrs: {
48871
+ default: null,
48872
+ rendered: false
48873
+ }
48874
+ };
48875
+ },
48876
+ addNodeView() {
48877
+ return ({ node: node2, editor, getPos, decorations }) => {
48878
+ const htmlAttributes = this.options.htmlAttributes;
48879
+ return new AutoPageNumberNodeView(node2, getPos, decorations, editor, htmlAttributes);
48880
+ };
48881
+ },
48761
48882
  parseDOM() {
48762
48883
  return [{ tag: 'span[data-id="auto-page-number"' }];
48763
48884
  },
48764
48885
  renderDOM({ htmlAttributes }) {
48765
- return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48886
+ return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
48887
+ },
48888
+ addCommands() {
48889
+ return {
48890
+ addAutoPageNumber: () => ({ tr, dispatch, state: state2, editor }) => {
48891
+ const { options: options2 } = editor;
48892
+ if (!options2.isHeaderOrFooter) return false;
48893
+ const { schema } = state2;
48894
+ const pageNumberType = schema?.nodes?.["page-number"];
48895
+ if (!pageNumberType) return false;
48896
+ const pageNumberNodeJSON = { type: "page-number" };
48897
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
48898
+ if (dispatch) {
48899
+ tr.replaceSelectionWith(pageNumberNode, false);
48900
+ tr.setMeta("forceUpdatePagination", true);
48901
+ }
48902
+ return true;
48903
+ }
48904
+ };
48905
+ },
48906
+ addShortcuts() {
48907
+ return {
48908
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
48909
+ };
48766
48910
  }
48767
48911
  });
48768
48912
  const TotalPageCount = Node$1.create({
48769
48913
  name: "total-page-number",
48770
48914
  group: "inline",
48771
48915
  inline: true,
48916
+ atom: true,
48917
+ selectable: false,
48918
+ draggable: false,
48919
+ selectable: false,
48772
48920
  content: "text*",
48773
48921
  addOptions() {
48774
48922
  return {
48775
48923
  htmlAttributes: {
48924
+ contenteditable: false,
48776
48925
  "data-id": "auto-total-pages",
48777
- "aria-label": "Total page count node"
48926
+ "aria-label": "Total page count node",
48927
+ "class": "sd-editor-auto-total-pages"
48928
+ }
48929
+ };
48930
+ },
48931
+ addAttributes() {
48932
+ return {
48933
+ marksAsAttrs: {
48934
+ default: null,
48935
+ rendered: false
48778
48936
  }
48779
48937
  };
48780
48938
  },
@@ -48783,8 +48941,139 @@ const TotalPageCount = Node$1.create({
48783
48941
  },
48784
48942
  renderDOM({ htmlAttributes }) {
48785
48943
  return ["span", Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
48944
+ },
48945
+ addCommands() {
48946
+ return {
48947
+ addTotalPageCount: () => ({ tr, dispatch, state: state2, editor }) => {
48948
+ const { options: options2 } = editor;
48949
+ if (!options2.isHeaderOrFooter) return false;
48950
+ const { schema } = state2;
48951
+ const pageNumberType = schema.nodes?.["total-page-number"];
48952
+ if (!pageNumberType) return false;
48953
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
48954
+ const pageNumberNode = {
48955
+ type: "total-page-number",
48956
+ content: [{ type: "text", text: String(currentPages) }]
48957
+ };
48958
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
48959
+ if (dispatch) {
48960
+ tr.replaceSelectionWith(pageNode, false);
48961
+ }
48962
+ return true;
48963
+ }
48964
+ };
48965
+ },
48966
+ addShortcuts() {
48967
+ return {
48968
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
48969
+ };
48786
48970
  }
48787
48971
  });
48972
+ class AutoPageNumberNodeView {
48973
+ constructor(node2, getPos, decorations, editor, htmlAttributes = {}) {
48974
+ __privateAdd$1(this, _AutoPageNumberNodeView_instances);
48975
+ this.node = node2;
48976
+ this.editor = editor;
48977
+ this.view = editor.view;
48978
+ this.getPos = getPos;
48979
+ this.editor = editor;
48980
+ this.dom = __privateMethod$1(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node2, htmlAttributes);
48981
+ }
48982
+ update(node2) {
48983
+ if (node2.type !== this.node.type) return false;
48984
+ this.node = node2;
48985
+ return true;
48986
+ }
48987
+ }
48988
+ _AutoPageNumberNodeView_instances = /* @__PURE__ */ new WeakSet();
48989
+ renderDom_fn = function(node2, htmlAttributes) {
48990
+ const pageText = this.editor.options.currentPageNumber || "1";
48991
+ const content = document.createTextNode(String(pageText));
48992
+ const nodeContent = document.createElement("span");
48993
+ nodeContent.className = "sd-editor-auto-page-number";
48994
+ nodeContent.setAttribute("data-id", "auto-page-number");
48995
+ nodeContent.setAttribute("aria-label", "Page number node");
48996
+ const currentPos = this.getPos();
48997
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
48998
+ __privateMethod$1(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
48999
+ Object.assign(nodeContent.style, styles);
49000
+ nodeContent.appendChild(content);
49001
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
49002
+ if (value) nodeContent.setAttribute(key, value);
49003
+ });
49004
+ return nodeContent;
49005
+ };
49006
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
49007
+ setTimeout(() => {
49008
+ const { state: state2 } = this.editor;
49009
+ const { dispatch } = this.view;
49010
+ const node2 = state2.doc.nodeAt(pos);
49011
+ if (!node2) return;
49012
+ const currentMarks = node2.attrs.marksAsAttrs || [];
49013
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
49014
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
49015
+ if (isEqual) return;
49016
+ const newAttrs = {
49017
+ ...node2.attrs,
49018
+ marksAsAttrs: newMarks
49019
+ };
49020
+ const tr = state2.tr.setNodeMarkup(pos, void 0, newAttrs);
49021
+ dispatch(tr);
49022
+ }, 0);
49023
+ };
49024
+ const getMarksFromNeighbors = (currentPos, view) => {
49025
+ const $pos = view.state.doc.resolve(currentPos);
49026
+ const styles = {};
49027
+ const marks = [];
49028
+ const before = $pos.nodeBefore;
49029
+ if (before) {
49030
+ Object.assign(styles, processMarks(before.marks));
49031
+ marks.push(...before.marks);
49032
+ }
49033
+ const after = $pos.nodeAfter;
49034
+ if (after) {
49035
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
49036
+ marks.push(...after.marks);
49037
+ }
49038
+ return {
49039
+ styles,
49040
+ marks
49041
+ };
49042
+ };
49043
+ const processMarks = (marks) => {
49044
+ const styles = {};
49045
+ marks.forEach((mark) => {
49046
+ const { type: type2, attrs } = mark;
49047
+ switch (type2.name) {
49048
+ case "textStyle":
49049
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
49050
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
49051
+ if (attrs.color) styles["color"] = attrs.color;
49052
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
49053
+ break;
49054
+ case "bold":
49055
+ styles["font-weight"] = "bold";
49056
+ break;
49057
+ case "italic":
49058
+ styles["font-style"] = "italic";
49059
+ break;
49060
+ case "underline":
49061
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
49062
+ break;
49063
+ case "strike":
49064
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
49065
+ break;
49066
+ default:
49067
+ if (attrs?.style) {
49068
+ Object.entries(attrs.style).forEach(([key, value]) => {
49069
+ styles[key] = value;
49070
+ });
49071
+ }
49072
+ break;
49073
+ }
49074
+ });
49075
+ return styles;
49076
+ };
48788
49077
  const ShapeContainer = Node$1.create({
48789
49078
  name: "shapeContainer",
48790
49079
  group: "block",
@@ -52822,16 +53111,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52822
53111
  const decorations = [];
52823
53112
  const { pageSize, pageMargins } = editor.converter.pageStyles;
52824
53113
  const pageHeight = pageSize.height * 96;
52825
- editor.options.scale;
52826
53114
  let currentPageNumber = 1;
52827
53115
  let pageHeightThreshold = pageHeight;
52828
53116
  let footer = null, header = null;
52829
53117
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52830
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
53118
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
52831
53119
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
52832
53120
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
52833
53121
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52834
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
53122
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
52835
53123
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
52836
53124
  let coords = view?.coordsAtPos(doc2.content.size);
52837
53125
  if (!coords) return [];
@@ -52850,7 +53138,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52850
53138
  if (currentPageNumber === 1) {
52851
53139
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
52852
53140
  decorations.pop();
52853
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
53141
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52854
53142
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
52855
53143
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
52856
53144
  }
@@ -52879,7 +53167,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52879
53167
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
52880
53168
  currentPageNumber++;
52881
53169
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52882
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
53170
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
52883
53171
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
52884
53172
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
52885
53173
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
@@ -52894,7 +53182,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52894
53182
  const lastNodeCoords = view.coordsAtPos(finalPos);
52895
53183
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
52896
53184
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
52897
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
53185
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
52898
53186
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
52899
53187
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
52900
53188
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -52911,6 +53199,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
52911
53199
  totalPageNumber.innerText = currentPageNumber;
52912
53200
  }
52913
53201
  });
53202
+ editor.currentTotalPages = currentPageNumber;
52914
53203
  return decorations;
52915
53204
  }
52916
53205
  function createFinalPagePadding(bufferHeight) {
@@ -52921,7 +53210,7 @@ function createFinalPagePadding(bufferHeight) {
52921
53210
  div2.style.height = bufferHeight + "px";
52922
53211
  return { nodeHeight: bufferHeight, node: div2 };
52923
53212
  }
52924
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
53213
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
52925
53214
  const headerDef = sectionData.headers?.[headerId];
52926
53215
  const minHeaderHeight = pageMargins.top * 96;
52927
53216
  const headerMargin = pageMargins.header * 96;
@@ -52948,7 +53237,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
52948
53237
  appendToBody: false,
52949
53238
  sectionId: headerId,
52950
53239
  type: "header",
52951
- availableHeight
53240
+ availableHeight,
53241
+ currentPageNumber
52952
53242
  });
52953
53243
  editor.converter.headerEditors.push({
52954
53244
  id: headerId,
@@ -52974,13 +53264,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
52974
53264
  const minFooterHeight = pageMargins.bottom * 96;
52975
53265
  const footerPaddingFromEdge = pageMargins.footer * 96;
52976
53266
  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
53267
  const editorContainer = document.createElement("div");
52985
53268
  if (!footerId && !editor.converter.footerIds["default"]) {
52986
53269
  footerId = "rId" + generateDocxRandomId();
@@ -53000,7 +53283,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
53000
53283
  appendToBody: false,
53001
53284
  sectionId: footerId,
53002
53285
  type: "footer",
53003
- availableHeight: footerHeight
53286
+ availableHeight: footerHeight,
53287
+ currentPageNumber
53004
53288
  });
53005
53289
  editor.converter.footerEditors.push({
53006
53290
  id: footerId,
package/dist/style.css CHANGED
@@ -878,6 +878,19 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
878
878
  .sd-ai-highlight-pulse {
879
879
  animation: ai-pulse 1.5s ease-in-out infinite;
880
880
  }
881
+ .sd-editor-auto-page-number,
882
+ .sd-editor-auto-total-pages {
883
+ transition: all 250ms ease;
884
+ border-bottom: 1px solid #9A9A9A;
885
+ cursor: not-allowed;
886
+ }
887
+ .sd-editor-auto-page-numbe:hover,
888
+ .sd-editor-auto-total-pages:hover {
889
+ border-bottom: 1px solid #4f4f4f;
890
+ }
891
+ .sd-editor-auto-page-number-content {
892
+ pointer-events: none;
893
+ }
881
894
  .pagination-section-header {
882
895
  cursor: default;
883
896
  }
@@ -1,6 +1,6 @@
1
1
  import { ref, onMounted, onUnmounted, computed, createElementBlock, openBlock, withModifiers, createElementVNode, withDirectives, unref, vModelText, createCommentVNode, nextTick } from "vue";
2
- import { T as TextSelection } from "./chunks/converter-DY26Bu8a.js";
3
- import { _ as _export_sfc } from "./chunks/editor-w6HF4T0Y.js";
2
+ import { T as TextSelection } from "./chunks/converter-BCnMtqK6.js";
3
+ import { _ as _export_sfc } from "./chunks/editor-CTFQa4G4.js";
4
4
  const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
5
5
  const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
6
6
  async function baseInsightsFetch(payload, options = {}) {