@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
@@ -18864,7 +18864,9 @@ function exportSchemaToJson(params) {
18864
18864
  shapeContainer: translateShapeContainer,
18865
18865
  shapeTextbox: translateShapeTextbox,
18866
18866
  contentBlock: translateContentBlock,
18867
- structuredContent: translateStructuredContent
18867
+ structuredContent: translateStructuredContent,
18868
+ "page-number": translatePageNumberNode,
18869
+ "total-page-number": translateTotalPageNumberNode
18868
18870
  };
18869
18871
  if (!router[type2]) {
18870
18872
  console.error("No translation function found for node type:", type2);
@@ -20561,6 +20563,81 @@ function translateStructuredContent(params) {
20561
20563
  elements: nodeElements
20562
20564
  };
20563
20565
  }
20566
+ const translatePageNumberNode = (params) => {
20567
+ const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
20568
+ return getAutoPageJson("PAGE", outputMarks);
20569
+ };
20570
+ const translateTotalPageNumberNode = (params) => {
20571
+ const outputMarks = processOutputMarks(params.node.attrs?.marksAsAttrs || []);
20572
+ return getAutoPageJson("NUMPAGES", outputMarks);
20573
+ };
20574
+ const getAutoPageJson = (type2, outputMarks = []) => {
20575
+ return [
20576
+ {
20577
+ "name": "w:r",
20578
+ "elements": [
20579
+ {
20580
+ "name": "w:rPr",
20581
+ "elements": outputMarks
20582
+ },
20583
+ {
20584
+ "name": "w:fldChar",
20585
+ "attributes": {
20586
+ "w:fldCharType": "begin"
20587
+ }
20588
+ }
20589
+ ]
20590
+ },
20591
+ {
20592
+ "name": "w:r",
20593
+ "elements": [
20594
+ {
20595
+ "name": "w:rPr",
20596
+ "elements": outputMarks
20597
+ },
20598
+ {
20599
+ "name": "w:instrText",
20600
+ "elements": [
20601
+ {
20602
+ "type": "text",
20603
+ "text": ` ${type2}`
20604
+ }
20605
+ ]
20606
+ }
20607
+ ]
20608
+ },
20609
+ {
20610
+ "name": "w:r",
20611
+ "elements": [
20612
+ {
20613
+ "name": "w:rPr",
20614
+ "elements": outputMarks
20615
+ },
20616
+ {
20617
+ "name": "w:fldChar",
20618
+ "attributes": {
20619
+ "w:fldCharType": "separate"
20620
+ }
20621
+ }
20622
+ ]
20623
+ },
20624
+ {
20625
+ "name": "w:r",
20626
+ "elements": [
20627
+ {
20628
+ "name": "w:rPr",
20629
+ "elements": outputMarks
20630
+ },
20631
+ {
20632
+ "name": "w:fldChar",
20633
+ "attributes": {
20634
+ "w:fldCharType": "end"
20635
+ }
20636
+ }
20637
+ ]
20638
+ }
20639
+ ];
20640
+ };
20564
20641
  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>`;
20565
20642
  const parseXmlToJson = (xml) => {
20566
20643
  return JSON.parse(xmljs.xml2json(xml, null, 2));
@@ -22269,15 +22346,25 @@ const processCombinedNodesForFldChar = (nodesToCombine = []) => {
22269
22346
  if (!isNumPages) isNumPages = instrText?.trim().startsWith("NUMPAGES");
22270
22347
  const urlMatch = instrText?.match(/HYPERLINK\s+"([^"]+)"/);
22271
22348
  if (hasPageMarker) {
22272
- processedNodes.push({
22349
+ const pageNumNode = {
22273
22350
  name: "sd:autoPageNumber",
22274
22351
  type: "element"
22352
+ };
22353
+ nodesToCombine.forEach((n) => {
22354
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22355
+ if (rPrNode) pageNumNode.elements = [rPrNode];
22275
22356
  });
22357
+ processedNodes.push(pageNumNode);
22276
22358
  } else if (isNumPages) {
22277
- processedNodes.push({
22359
+ const totalPageNumNode = {
22278
22360
  name: "sd:totalPageNumber",
22279
22361
  type: "element"
22362
+ };
22363
+ nodesToCombine.forEach((n) => {
22364
+ const rPrNode = n.elements.find((el) => el.name === "w:rPr");
22365
+ if (rPrNode) totalPageNumNode.elements = [rPrNode];
22280
22366
  });
22367
+ processedNodes.push(totalPageNumNode);
22281
22368
  } else if (urlMatch && urlMatch?.length >= 2) {
22282
22369
  const url = urlMatch[1];
22283
22370
  const textMarks = [];
@@ -22613,8 +22700,13 @@ const handleAutoPageNumber = (params) => {
22613
22700
  if (nodes.length === 0 || nodes[0].name !== "sd:autoPageNumber") {
22614
22701
  return { nodes: [], consumed: 0 };
22615
22702
  }
22703
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22704
+ const marks = parseMarks(rPr || { elements: [] });
22616
22705
  const processedNode = {
22617
- type: "page-number"
22706
+ type: "page-number",
22707
+ attrs: {
22708
+ marksAsAttrs: marks
22709
+ }
22618
22710
  };
22619
22711
  return { nodes: [processedNode], consumed: 1 };
22620
22712
  };
@@ -22627,8 +22719,13 @@ const handleAutoTotalPageNumber = (params) => {
22627
22719
  if (nodes.length === 0 || nodes[0].name !== "sd:totalPageNumber") {
22628
22720
  return { nodes: [], consumed: 0 };
22629
22721
  }
22722
+ const rPr = nodes[0].elements?.find((el) => el.name === "w:rPr");
22723
+ const marks = parseMarks(rPr || { elements: [] });
22630
22724
  const processedNode = {
22631
- type: "total-page-number"
22725
+ type: "total-page-number",
22726
+ attrs: {
22727
+ marksAsAttrs: marks
22728
+ }
22632
22729
  };
22633
22730
  return { nodes: [processedNode], consumed: 1 };
22634
22731
  };
@@ -23313,7 +23410,7 @@ const _SuperConverter = class _SuperConverter {
23313
23410
  return;
23314
23411
  }
23315
23412
  }
23316
- static updateDocumentVersion(docx = this.convertedXml, version = "0.12.36-next.7") {
23413
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.12.36-next.8") {
23317
23414
  const customLocation = "docProps/custom.xml";
23318
23415
  if (!docx[customLocation]) {
23319
23416
  docx[customLocation] = generateCustomXml();
@@ -23783,7 +23880,7 @@ function storeSuperdocVersion(docx) {
23783
23880
  function generateCustomXml() {
23784
23881
  return DEFAULT_CUSTOM_XML;
23785
23882
  }
23786
- function generateSuperdocVersion(pid = 2, version = "0.12.36-next.7") {
23883
+ function generateSuperdocVersion(pid = 2, version = "0.12.36-next.8") {
23787
23884
  return {
23788
23885
  type: "element",
23789
23886
  name: "property",
@@ -1,4 +1,4 @@
1
- import { x as process$1, a1 as commonjsGlobal, B as Buffer, a2 as getDefaultExportFromCjs, a3 as getContentTypesFromXml, a4 as xmljs } from "./converter-wbU2SP4i.js";
1
+ import { x as process$1, a1 as commonjsGlobal, B as Buffer, a2 as getDefaultExportFromCjs, a3 as getContentTypesFromXml, a4 as xmljs } from "./converter-BCnMtqK6.js";
2
2
  function commonjsRequire(path) {
3
3
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
4
4
  }
@@ -9,12 +9,12 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn;
12
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep, f as Slice, o as objectIncludes, g as deleteProps, D as DOMParser$1, h as ReplaceStep, k as NodeRange, m as findWrapping, n as isMacOS, p as isIOS, q as generateDocxRandomId, s as minMax, t as generateRandom32BitHex, u as DOMSerializer, v as Mark$1, w as dropPoint, x as process$1, B as Buffer2, y as isRegExp, z as TrackDeleteMarkName, C as TrackInsertMarkName, E as v4, G as TrackFormatMarkName, H as comments_module_events, I as AddMarkStep, J as RemoveMarkStep, K as twipsToLines, L as pixelsToTwips, O as SuperConverter, Q as EditorState, U as hasSomeParentWithClass, V as parseSizeUnit, W as getLineHeightValueString, X as toKebabCase, Y as kebabCase, Z as getColStyleDeclaration, _ as SelectionRange, $ as Transform, a0 as createColGroup } from "./converter-wbU2SP4i.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep, f as Slice, o as objectIncludes, g as deleteProps, D as DOMParser$1, h as ReplaceStep, k as NodeRange, m as findWrapping, n as isMacOS, p as isIOS, q as generateDocxRandomId, s as minMax, t as generateRandom32BitHex, u as DOMSerializer, v as Mark$1, w as dropPoint, x as process$1, B as Buffer2, y as isRegExp, z as TrackDeleteMarkName, C as TrackInsertMarkName, E as v4, G as TrackFormatMarkName, H as comments_module_events, I as AddMarkStep, J as RemoveMarkStep, K as twipsToLines, L as pixelsToTwips, O as SuperConverter, Q as EditorState, U as hasSomeParentWithClass, V as parseSizeUnit, W as getLineHeightValueString, X as toKebabCase, Y as kebabCase, Z as getColStyleDeclaration, _ as SelectionRange, $ as Transform, a0 as createColGroup } from "./converter-BCnMtqK6.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-BL3thpAA.js";
17
+ import { D as DocxZipper } from "./docx-zipper-BEWaJso4.js";
18
18
  function getMarksFromSelection(state) {
19
19
  const { from: from2, to, empty: empty2 } = state.selection;
20
20
  const marks = [];
@@ -12792,7 +12792,8 @@ const createHeaderFooterEditor = ({
12792
12792
  appendToBody = true,
12793
12793
  sectionId,
12794
12794
  type,
12795
- availableHeight
12795
+ availableHeight,
12796
+ currentPageNumber
12796
12797
  }) => {
12797
12798
  const parentStyles = editor.converter.getDocumentDefaultStyles();
12798
12799
  const { fontSizePt, typeface } = parentStyles;
@@ -12833,6 +12834,8 @@ const createHeaderFooterEditor = ({
12833
12834
  fonts: editor.options.fonts,
12834
12835
  isHeaderOrFooter: true,
12835
12836
  annotations: true,
12837
+ currentPageNumber,
12838
+ parentEditor: editor,
12836
12839
  onCreate: (evt) => setEditorToolbar(evt, editor),
12837
12840
  onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type)
12838
12841
  });
@@ -14859,7 +14862,7 @@ const _Editor = class _Editor extends EventEmitter {
14859
14862
  * @returns {Object | void} Migration results
14860
14863
  */
14861
14864
  processCollaborationMigrations() {
14862
- console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.7");
14865
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.36-next.8");
14863
14866
  if (!this.options.ydoc) return;
14864
14867
  const metaMap = this.options.ydoc.getMap("meta");
14865
14868
  let docVersion = metaMap.get("version");
@@ -22641,32 +22644,89 @@ const PageNumber = Node$1.create({
22641
22644
  name: "page-number",
22642
22645
  group: "inline",
22643
22646
  inline: true,
22644
- content: "text*",
22647
+ atom: true,
22648
+ selectable: false,
22649
+ draggable: false,
22650
+ selectable: false,
22651
+ defining: true,
22652
+ content: "",
22645
22653
  addOptions() {
22646
22654
  return {
22647
22655
  htmlAttributes: {
22656
+ contenteditable: false,
22648
22657
  "data-id": "auto-page-number",
22649
22658
  "aria-label": "Page number node"
22650
22659
  }
22651
22660
  };
22652
22661
  },
22662
+ addAttributes() {
22663
+ return {
22664
+ marksAsAttrs: {
22665
+ default: null,
22666
+ rendered: false
22667
+ }
22668
+ };
22669
+ },
22670
+ addNodeView() {
22671
+ return ({ node, editor, getPos, decorations }) => {
22672
+ const htmlAttributes = this.options.htmlAttributes;
22673
+ return new AutoPageNumberNodeView(node, getPos, decorations, editor, htmlAttributes);
22674
+ };
22675
+ },
22653
22676
  parseDOM() {
22654
22677
  return [{ tag: 'span[data-id="auto-page-number"' }];
22655
22678
  },
22656
22679
  renderDOM({ htmlAttributes }) {
22657
- return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
22680
+ return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
22681
+ },
22682
+ addCommands() {
22683
+ return {
22684
+ addAutoPageNumber: () => ({ tr, dispatch, state, editor }) => {
22685
+ const { options } = editor;
22686
+ if (!options.isHeaderOrFooter) return false;
22687
+ const { schema } = state;
22688
+ const pageNumberType = schema?.nodes?.["page-number"];
22689
+ if (!pageNumberType) return false;
22690
+ const pageNumberNodeJSON = { type: "page-number" };
22691
+ const pageNumberNode = schema.nodeFromJSON(pageNumberNodeJSON);
22692
+ if (dispatch) {
22693
+ tr.replaceSelectionWith(pageNumberNode, false);
22694
+ tr.setMeta("forceUpdatePagination", true);
22695
+ }
22696
+ return true;
22697
+ }
22698
+ };
22699
+ },
22700
+ addShortcuts() {
22701
+ return {
22702
+ "Mod-Shift-alt-p": () => this.editor.commands.addAutoPageNumber()
22703
+ };
22658
22704
  }
22659
22705
  });
22660
22706
  const TotalPageCount = Node$1.create({
22661
22707
  name: "total-page-number",
22662
22708
  group: "inline",
22663
22709
  inline: true,
22710
+ atom: true,
22711
+ selectable: false,
22712
+ draggable: false,
22713
+ selectable: false,
22664
22714
  content: "text*",
22665
22715
  addOptions() {
22666
22716
  return {
22667
22717
  htmlAttributes: {
22718
+ contenteditable: false,
22668
22719
  "data-id": "auto-total-pages",
22669
- "aria-label": "Total page count node"
22720
+ "aria-label": "Total page count node",
22721
+ "class": "sd-editor-auto-total-pages"
22722
+ }
22723
+ };
22724
+ },
22725
+ addAttributes() {
22726
+ return {
22727
+ marksAsAttrs: {
22728
+ default: null,
22729
+ rendered: false
22670
22730
  }
22671
22731
  };
22672
22732
  },
@@ -22675,8 +22735,139 @@ const TotalPageCount = Node$1.create({
22675
22735
  },
22676
22736
  renderDOM({ htmlAttributes }) {
22677
22737
  return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
22738
+ },
22739
+ addCommands() {
22740
+ return {
22741
+ addTotalPageCount: () => ({ tr, dispatch, state, editor }) => {
22742
+ const { options } = editor;
22743
+ if (!options.isHeaderOrFooter) return false;
22744
+ const { schema } = state;
22745
+ const pageNumberType = schema.nodes?.["total-page-number"];
22746
+ if (!pageNumberType) return false;
22747
+ const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
22748
+ const pageNumberNode = {
22749
+ type: "total-page-number",
22750
+ content: [{ type: "text", text: String(currentPages) }]
22751
+ };
22752
+ const pageNode = schema.nodeFromJSON(pageNumberNode);
22753
+ if (dispatch) {
22754
+ tr.replaceSelectionWith(pageNode, false);
22755
+ }
22756
+ return true;
22757
+ }
22758
+ };
22759
+ },
22760
+ addShortcuts() {
22761
+ return {
22762
+ "Mod-Shift-alt-c": () => this.editor.commands.addTotalPageCount()
22763
+ };
22678
22764
  }
22679
22765
  });
22766
+ class AutoPageNumberNodeView {
22767
+ constructor(node, getPos, decorations, editor, htmlAttributes = {}) {
22768
+ __privateAdd(this, _AutoPageNumberNodeView_instances);
22769
+ this.node = node;
22770
+ this.editor = editor;
22771
+ this.view = editor.view;
22772
+ this.getPos = getPos;
22773
+ this.editor = editor;
22774
+ this.dom = __privateMethod(this, _AutoPageNumberNodeView_instances, renderDom_fn).call(this, node, htmlAttributes);
22775
+ }
22776
+ update(node) {
22777
+ if (node.type !== this.node.type) return false;
22778
+ this.node = node;
22779
+ return true;
22780
+ }
22781
+ }
22782
+ _AutoPageNumberNodeView_instances = new WeakSet();
22783
+ renderDom_fn = function(node, htmlAttributes) {
22784
+ const pageText = this.editor.options.currentPageNumber || "1";
22785
+ const content = document.createTextNode(String(pageText));
22786
+ const nodeContent = document.createElement("span");
22787
+ nodeContent.className = "sd-editor-auto-page-number";
22788
+ nodeContent.setAttribute("data-id", "auto-page-number");
22789
+ nodeContent.setAttribute("aria-label", "Page number node");
22790
+ const currentPos = this.getPos();
22791
+ const { styles, marks } = getMarksFromNeighbors(currentPos, this.view);
22792
+ __privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
22793
+ Object.assign(nodeContent.style, styles);
22794
+ nodeContent.appendChild(content);
22795
+ Object.entries(htmlAttributes).forEach(([key, value]) => {
22796
+ if (value) nodeContent.setAttribute(key, value);
22797
+ });
22798
+ return nodeContent;
22799
+ };
22800
+ scheduleUpdateNodeStyle_fn = function(pos, marks) {
22801
+ setTimeout(() => {
22802
+ const { state } = this.editor;
22803
+ const { dispatch } = this.view;
22804
+ const node = state.doc.nodeAt(pos);
22805
+ if (!node) return;
22806
+ const currentMarks = node.attrs.marksAsAttrs || [];
22807
+ const newMarks = marks.map((m) => ({ type: m.type.name, attrs: m.attrs }));
22808
+ const isEqual = JSON.stringify(currentMarks) === JSON.stringify(newMarks);
22809
+ if (isEqual) return;
22810
+ const newAttrs = {
22811
+ ...node.attrs,
22812
+ marksAsAttrs: newMarks
22813
+ };
22814
+ const tr = state.tr.setNodeMarkup(pos, void 0, newAttrs);
22815
+ dispatch(tr);
22816
+ }, 0);
22817
+ };
22818
+ const getMarksFromNeighbors = (currentPos, view) => {
22819
+ const $pos = view.state.doc.resolve(currentPos);
22820
+ const styles = {};
22821
+ const marks = [];
22822
+ const before = $pos.nodeBefore;
22823
+ if (before) {
22824
+ Object.assign(styles, processMarks(before.marks));
22825
+ marks.push(...before.marks);
22826
+ }
22827
+ const after = $pos.nodeAfter;
22828
+ if (after) {
22829
+ Object.assign(styles, { ...styles, ...processMarks(after.marks) });
22830
+ marks.push(...after.marks);
22831
+ }
22832
+ return {
22833
+ styles,
22834
+ marks
22835
+ };
22836
+ };
22837
+ const processMarks = (marks) => {
22838
+ const styles = {};
22839
+ marks.forEach((mark) => {
22840
+ const { type, attrs } = mark;
22841
+ switch (type.name) {
22842
+ case "textStyle":
22843
+ if (attrs.fontFamily) styles["font-family"] = attrs.fontFamily;
22844
+ if (attrs.fontSize) styles["font-size"] = attrs.fontSize;
22845
+ if (attrs.color) styles["color"] = attrs.color;
22846
+ if (attrs.backgroundColor) styles["background-color"] = attrs.backgroundColor;
22847
+ break;
22848
+ case "bold":
22849
+ styles["font-weight"] = "bold";
22850
+ break;
22851
+ case "italic":
22852
+ styles["font-style"] = "italic";
22853
+ break;
22854
+ case "underline":
22855
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " underline";
22856
+ break;
22857
+ case "strike":
22858
+ styles["text-decoration"] = (styles["text-decoration"] || "") + " line-through";
22859
+ break;
22860
+ default:
22861
+ if (attrs?.style) {
22862
+ Object.entries(attrs.style).forEach(([key, value]) => {
22863
+ styles[key] = value;
22864
+ });
22865
+ }
22866
+ break;
22867
+ }
22868
+ });
22869
+ return styles;
22870
+ };
22680
22871
  const ShapeContainer = Node$1.create({
22681
22872
  name: "shapeContainer",
22682
22873
  group: "block",
@@ -26714,16 +26905,15 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26714
26905
  const decorations = [];
26715
26906
  const { pageSize, pageMargins } = editor.converter.pageStyles;
26716
26907
  const pageHeight = pageSize.height * 96;
26717
- editor.options.scale;
26718
26908
  let currentPageNumber = 1;
26719
26909
  let pageHeightThreshold = pageHeight;
26720
26910
  let footer = null, header = null;
26721
26911
  const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26722
- const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor);
26912
+ const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
26723
26913
  const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
26724
26914
  decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
26725
26915
  const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
26726
- const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor);
26916
+ const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
26727
26917
  pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
26728
26918
  let coords = view?.coordsAtPos(doc2.content.size);
26729
26919
  if (!coords) return [];
@@ -26742,7 +26932,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26742
26932
  if (currentPageNumber === 1) {
26743
26933
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
26744
26934
  decorations.pop();
26745
- const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
26935
+ const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
26746
26936
  const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
26747
26937
  decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
26748
26938
  }
@@ -26771,7 +26961,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26771
26961
  const footerId2 = getHeaderFooterId(currentPageNumber, "footerIds", editor, currentNode);
26772
26962
  currentPageNumber++;
26773
26963
  const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26774
- header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
26964
+ header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
26775
26965
  footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
26776
26966
  const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
26777
26967
  const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
@@ -26786,7 +26976,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26786
26976
  const lastNodeCoords = view.coordsAtPos(finalPos);
26787
26977
  const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
26788
26978
  const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
26789
- header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
26979
+ header = createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber);
26790
26980
  footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
26791
26981
  const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
26792
26982
  const { node: spacingNode } = createFinalPagePadding(bufferHeight);
@@ -26803,6 +26993,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
26803
26993
  totalPageNumber.innerText = currentPageNumber;
26804
26994
  }
26805
26995
  });
26996
+ editor.currentTotalPages = currentPageNumber;
26806
26997
  return decorations;
26807
26998
  }
26808
26999
  function createFinalPagePadding(bufferHeight) {
@@ -26813,7 +27004,7 @@ function createFinalPagePadding(bufferHeight) {
26813
27004
  div2.style.height = bufferHeight + "px";
26814
27005
  return { nodeHeight: bufferHeight, node: div2 };
26815
27006
  }
26816
- function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
27007
+ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
26817
27008
  const headerDef = sectionData.headers?.[headerId];
26818
27009
  const minHeaderHeight = pageMargins.top * 96;
26819
27010
  const headerMargin = pageMargins.header * 96;
@@ -26840,7 +27031,8 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
26840
27031
  appendToBody: false,
26841
27032
  sectionId: headerId,
26842
27033
  type: "header",
26843
- availableHeight
27034
+ availableHeight,
27035
+ currentPageNumber
26844
27036
  });
26845
27037
  editor.converter.headerEditors.push({
26846
27038
  id: headerId,
@@ -26866,13 +27058,6 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
26866
27058
  const minFooterHeight = pageMargins.bottom * 96;
26867
27059
  const footerPaddingFromEdge = pageMargins.footer * 96;
26868
27060
  const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
26869
- const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
26870
- const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
26871
- if (autoPageNumber) {
26872
- const fontSize = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
26873
- if (fontSize) autoPageNumber.style.fontSize = fontSize;
26874
- autoPageNumber.innerText = currentPageNumber;
26875
- }
26876
27061
  const editorContainer = document.createElement("div");
26877
27062
  if (!footerId && !editor.converter.footerIds["default"]) {
26878
27063
  footerId = "rId" + generateDocxRandomId();
@@ -26892,7 +27077,8 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
26892
27077
  appendToBody: false,
26893
27078
  sectionId: footerId,
26894
27079
  type: "footer",
26895
- availableHeight: footerHeight
27080
+ availableHeight: footerHeight,
27081
+ currentPageNumber
26896
27082
  });
26897
27083
  editor.converter.footerEditors.push({
26898
27084
  id: footerId,
@@ -1,6 +1,6 @@
1
1
  import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, nextTick, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
2
- import { x as process$1 } from "./converter-wbU2SP4i.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-CrElllON.js";
2
+ import { x as process$1 } from "./converter-BCnMtqK6.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-CTFQa4G4.js";
4
4
  const sanitizeNumber = (value, defaultNumber) => {
5
5
  let sanitized = value.replace(/[^0-9.]/g, "");
6
6
  sanitized = parseFloat(sanitized);
@@ -1,4 +1,4 @@
1
- import { O } from "./chunks/converter-wbU2SP4i.js";
1
+ import { O } from "./chunks/converter-BCnMtqK6.js";
2
2
  export {
3
3
  O as SuperConverter
4
4
  };
@@ -15,14 +15,14 @@ export class Attribute {
15
15
  * @param defaultAttribute Default attribute.
16
16
  * @returns Global extension attributes.
17
17
  */
18
- static "__#5@#getGlobalAttributes"(extensions: any, defaultAttribute: any): any[];
18
+ static "__#6@#getGlobalAttributes"(extensions: any, defaultAttribute: any): any[];
19
19
  /**
20
20
  * Get a list of attributes defined in the Node and Mark extensions.
21
21
  * @param extensions List of all extensions.
22
22
  * @param defaultAttribute Default attribute.
23
23
  * @returns Node and Mark extension attributes.
24
24
  */
25
- static "__#5@#getNodeAndMarksAttributes"(extensions: any, defaultAttribute: any): {
25
+ static "__#6@#getNodeAndMarksAttributes"(extensions: any, defaultAttribute: any): {
26
26
  type: any;
27
27
  name: string;
28
28
  attribute: any;
@@ -16,7 +16,7 @@ export class Schema {
16
16
  * @param editor Editor instance.
17
17
  * @returns Nodes schema.
18
18
  */
19
- static "__#6@#createNodesSchema"(nodeExtensions: any, attributes: any, editor: any): {
19
+ static "__#7@#createNodesSchema"(nodeExtensions: any, attributes: any, editor: any): {
20
20
  [k: string]: any;
21
21
  };
22
22
  /**
@@ -26,7 +26,7 @@ export class Schema {
26
26
  * @param editor Editor instance.
27
27
  * @returns Marks schema.
28
28
  */
29
- static "__#6@#createMarksSchema"(markExtensions: any, attributes: any, editor: any): {
29
+ static "__#7@#createMarksSchema"(markExtensions: any, attributes: any, editor: any): {
30
30
  [k: string]: any;
31
31
  };
32
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../../src/core/super-converter/exporter.js"],"names":[],"mappings":"AAwBA;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AACH,2CAHW,YAAY,GACV,YAAY,CAsCxB;AA+DD;;;;;GAKG;AACH,qDAFa,YAAY,CAyBxB;AAs5DD;;;;;;;;;EAcC;AA+FD;IACE,4BAEC;IADC,eAA0B;IAG5B,gDAGC;;CAwEF;;;;;;;;;;;;;mBA1vEa,KAAQ;;;;;;UAKR,MAAM;;;;aACN,KAAK,CAAC,UAAU,CAAC;;;;;;;;;;;;;UAMjB,MAAM;;;;cACN,KAAK,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;UAgBnB,MAAM"}
1
+ {"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../../src/core/super-converter/exporter.js"],"names":[],"mappings":"AAwBA;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AACH,2CAHW,YAAY,GACV,YAAY,CAwCxB;AA+DD;;;;;GAKG;AACH,qDAFa,YAAY,CAyBxB;AAs5DD;;;;;;;;;EAcC;AA+FD;IACE,4BAEC;IADC,eAA0B;IAG5B,gDAGC;;CAwEF;;;;;;;;;;;;;mBA5vEa,KAAQ;;;;;;UAKR,MAAM;;;;aACN,KAAK,CAAC,UAAU,CAAC;;;;;;;;;;;;;UAMjB,MAAM;;;;cACN,KAAK,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;UAgBnB,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"autoPageNumberImporter.d.ts","sourceRoot":"","sources":["../../../../../src/core/super-converter/v2/importer/autoPageNumberImporter.js"],"names":[],"mappings":"AAeA;;GAEG;AACH,wCAGE;AAiBF;;GAEG;AACH,2CAGE"}
1
+ {"version":3,"file":"autoPageNumberImporter.d.ts","sourceRoot":"","sources":["../../../../../src/core/super-converter/v2/importer/autoPageNumberImporter.js"],"names":[],"mappings":"AAsBA;;GAEG;AACH,wCAGE;AAsBF;;GAEG;AACH,2CAGE"}
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-wbU2SP4i.js";
2
- import { D } from "./chunks/docx-zipper-BL3thpAA.js";
1
+ import "./chunks/converter-BCnMtqK6.js";
2
+ import { D } from "./chunks/docx-zipper-BEWaJso4.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-CrElllON.js";
2
- import "./chunks/converter-wbU2SP4i.js";
3
- import "./chunks/docx-zipper-BL3thpAA.js";
1
+ import { E } from "./chunks/editor-CTFQa4G4.js";
2
+ import "./chunks/converter-BCnMtqK6.js";
3
+ import "./chunks/docx-zipper-BEWaJso4.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,3 +1,13 @@
1
1
  export const PageNumber: any;
2
2
  export const TotalPageCount: any;
3
+ export class AutoPageNumberNodeView {
4
+ constructor(node: any, getPos: any, decorations: any, editor: any, htmlAttributes?: {});
5
+ node: any;
6
+ editor: any;
7
+ view: any;
8
+ getPos: any;
9
+ dom: HTMLSpanElement;
10
+ update(node: any): boolean;
11
+ #private;
12
+ }
3
13
  //# sourceMappingURL=page-number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-number.d.ts","sourceRoot":"","sources":["../../../src/extensions/page-number/page-number.js"],"names":[],"mappings":"AAEA,6BAuBG;AAEH,iCAuBG"}
1
+ {"version":3,"file":"page-number.d.ts","sourceRoot":"","sources":["../../../src/extensions/page-number/page-number.js"],"names":[],"mappings":"AAEA,6BAyEG;AAEH,iCAoEG;AAGH;IACE,wFAQC;IAPC,UAAgB;IAChB,YAAoB;IACpB,UAAuB;IACvB,YAAoB;IAGpB,qBAAgD;IAmDlD,2BAIC;;CACF"}