@harbour-enterprises/superdoc 0.14.0-next.4 → 0.14.0-next.6

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 (39) hide show
  1. package/dist/chunks/{eventemitter3-DfVviFzP.cjs → eventemitter3-CHxWXmuK.cjs} +1 -1
  2. package/dist/chunks/{eventemitter3-BrspJk8q.es.js → eventemitter3-KKY27oz-.es.js} +1 -1
  3. package/dist/chunks/{index-Cdsq63Xq.cjs → index-BABtK_9p.cjs} +4 -4
  4. package/dist/chunks/{index-B4J7wgs6.cjs → index-BOOtEcgZ.cjs} +2 -2
  5. package/dist/chunks/{index-Hr3Um-Bg.es.js → index-ClYNVXDv.es.js} +2 -2
  6. package/dist/chunks/{index-Diu6UKHt.es.js → index-DRG7AiQg.es.js} +4 -4
  7. package/dist/chunks/{jszip-BTAcmbVg.cjs → jszip-9bCX1h2W.cjs} +1 -1
  8. package/dist/chunks/{jszip-DckFs3A7.es.js → jszip-Cl3s9njw.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-DyUoKmkO.cjs → super-editor.es-CETApTAM.cjs} +69 -35
  10. package/dist/chunks/{super-editor.es-BpHrUdJQ.es.js → super-editor.es-PFHHaxd8.es.js} +69 -35
  11. package/dist/chunks/{url-BIzg4y2i.cjs → url-BmSVZ-b1.cjs} +2 -2
  12. package/dist/chunks/{url-CHayXMZH.es.js → url-DtyZlUvQ.es.js} +2 -2
  13. package/dist/chunks/{vue-Bi1uWinj.es.js → vue-BBJVqxjL.es.js} +10 -3
  14. package/dist/chunks/{vue-HIY1g7dm.cjs → vue-BBjMeYfo.cjs} +10 -3
  15. package/dist/chunks/{xml-js-BjqmFOSP.cjs → xml-js-PTtx0UCg.cjs} +2 -2
  16. package/dist/chunks/{xml-js-CfClL-1b.es.js → xml-js-uhSaCX_L.es.js} +2 -2
  17. package/dist/core/SuperDoc.d.ts +5 -0
  18. package/dist/core/SuperDoc.d.ts.map +1 -1
  19. package/dist/super-editor/ai-writer.es.js +2 -2
  20. package/dist/super-editor/chunks/{converter-DjWoCkni.js → converter-DXxu8c9w.js} +2 -2
  21. package/dist/super-editor/chunks/{docx-zipper-CpyrpKcO.js → docx-zipper-DjxR5LqI.js} +1 -1
  22. package/dist/super-editor/chunks/{editor-BY9zLJjg.js → editor-DQyfLPCk.js} +68 -33
  23. package/dist/super-editor/chunks/{toolbar-BrTH3DZU.js → toolbar-LIs10qdJ.js} +2 -3
  24. package/dist/super-editor/converter.es.js +1 -1
  25. package/dist/super-editor/core/Editor.d.ts +11 -4
  26. package/dist/super-editor/core/Editor.d.ts.map +1 -1
  27. package/dist/super-editor/docx-zipper.es.js +2 -2
  28. package/dist/super-editor/editor.es.js +3 -3
  29. package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
  30. package/dist/super-editor/file-zipper.es.js +1 -1
  31. package/dist/super-editor/super-editor.es.js +6 -6
  32. package/dist/super-editor/toolbar.es.js +2 -2
  33. package/dist/super-editor.cjs +2 -2
  34. package/dist/super-editor.es.js +2 -2
  35. package/dist/superdoc.cjs +21 -9
  36. package/dist/superdoc.es.js +22 -10
  37. package/dist/superdoc.umd.js +92 -39
  38. package/dist/superdoc.umd.js.map +1 -1
  39. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const jszip = require("./jszip-BTAcmbVg.cjs");
2
+ const jszip = require("./jszip-9bCX1h2W.cjs");
3
3
  var eventemitter3 = { exports: {} };
4
4
  (function(module2) {
5
5
  var has = Object.prototype.hasOwnProperty, prefix = "~";
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs } from "./jszip-DckFs3A7.es.js";
1
+ import { g as getDefaultExportFromCjs } from "./jszip-Cl3s9njw.es.js";
2
2
  var eventemitter3 = { exports: {} };
3
3
  (function(module) {
4
4
  var has = Object.prototype.hasOwnProperty, prefix = "~";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
- const jszip = require("./jszip-BTAcmbVg.cjs");
3
- const vue = require("./vue-HIY1g7dm.cjs");
4
- const xmlJs = require("./xml-js-BjqmFOSP.cjs");
5
- const url = require("./url-BIzg4y2i.cjs");
2
+ const jszip = require("./jszip-9bCX1h2W.cjs");
3
+ const vue = require("./vue-BBjMeYfo.cjs");
4
+ const xmlJs = require("./xml-js-PTtx0UCg.cjs");
5
+ const url = require("./url-BmSVZ-b1.cjs");
6
6
  function _mergeNamespaces(n, m) {
7
7
  for (var i = 0; i < m.length; i++) {
8
8
  const e = m[i];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const jszip = require("./jszip-BTAcmbVg.cjs");
3
- const index$2 = require("./index-Cdsq63Xq.cjs");
2
+ const jszip = require("./jszip-9bCX1h2W.cjs");
3
+ const index$2 = require("./index-BABtK_9p.cjs");
4
4
  function _mergeNamespaces(n, m) {
5
5
  for (var i = 0; i < m.length; i++) {
6
6
  const e = m[i];
@@ -1,5 +1,5 @@
1
- import { g as getDefaultExportFromCjs } from "./jszip-DckFs3A7.es.js";
2
- import { s as streamHttp, r as require$$1 } from "./index-Diu6UKHt.es.js";
1
+ import { g as getDefaultExportFromCjs } from "./jszip-Cl3s9njw.es.js";
2
+ import { s as streamHttp, r as require$$1 } from "./index-DRG7AiQg.es.js";
3
3
  function _mergeNamespaces(n, m) {
4
4
  for (var i = 0; i < m.length; i++) {
5
5
  const e = m[i];
@@ -1,7 +1,7 @@
1
- import { c as commonjsGlobal, B as Buffer, a as getAugmentedNamespace, g as getDefaultExportFromCjs } from "./jszip-DckFs3A7.es.js";
2
- import { p as process$1 } from "./vue-Bi1uWinj.es.js";
3
- import { e as eventsExports, r as require$$2, u as util, i as inherits_browserExports, b as browser$1, a as requireString_decoder } from "./xml-js-CfClL-1b.es.js";
4
- import { u as url } from "./url-CHayXMZH.es.js";
1
+ import { c as commonjsGlobal, B as Buffer, a as getAugmentedNamespace, g as getDefaultExportFromCjs } from "./jszip-Cl3s9njw.es.js";
2
+ import { p as process$1 } from "./vue-BBJVqxjL.es.js";
3
+ import { e as eventsExports, r as require$$2, u as util, i as inherits_browserExports, b as browser$1, a as requireString_decoder } from "./xml-js-uhSaCX_L.es.js";
4
+ import { u as url } from "./url-DtyZlUvQ.es.js";
5
5
  function _mergeNamespaces(n, m) {
6
6
  for (var i = 0; i < m.length; i++) {
7
7
  const e = m[i];
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- require("./vue-HIY1g7dm.cjs");
2
+ require("./vue-BBjMeYfo.cjs");
3
3
  var buffer = {};
4
4
  var base64Js = {};
5
5
  base64Js.byteLength = byteLength;
@@ -1,4 +1,4 @@
1
- import "./vue-Bi1uWinj.es.js";
1
+ import "./vue-BBJVqxjL.es.js";
2
2
  var buffer = {};
3
3
  var base64Js = {};
4
4
  base64Js.byteLength = byteLength;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const vue = require("./vue-HIY1g7dm.cjs");
2
+ const vue = require("./vue-BBjMeYfo.cjs");
3
3
  const Y = require("yjs");
4
4
  function _interopNamespaceDefault(e) {
5
5
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -24252,7 +24252,7 @@ const _SuperConverter = class _SuperConverter2 {
24252
24252
  return;
24253
24253
  }
24254
24254
  }
24255
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.0-next.4") {
24255
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.0-next.6") {
24256
24256
  const customLocation = "docProps/custom.xml";
24257
24257
  if (!docx[customLocation]) {
24258
24258
  docx[customLocation] = generateCustomXml();
@@ -24720,7 +24720,7 @@ function storeSuperdocVersion(docx) {
24720
24720
  function generateCustomXml() {
24721
24721
  return DEFAULT_CUSTOM_XML;
24722
24722
  }
24723
- function generateSuperdocVersion(pid = 2, version2 = "0.14.0-next.4") {
24723
+ function generateSuperdocVersion(pid = 2, version2 = "0.14.0-next.6") {
24724
24724
  return {
24725
24725
  type: "element",
24726
24726
  name: "property",
@@ -27253,7 +27253,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
27253
27253
  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);
27254
27254
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
27255
27255
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
27256
- 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, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
27256
+ 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, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
27257
27257
  function getMarksFromSelection(state2) {
27258
27258
  const { from: from2, to, empty: empty2 } = state2.selection;
27259
27259
  const marks = [];
@@ -37518,7 +37518,8 @@ const restoreRelativeSelection = (tr, relSel, binding) => {
37518
37518
  binding.mapping
37519
37519
  );
37520
37520
  if (anchor !== null && head !== null) {
37521
- tr.setSelection(TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head)));
37521
+ const sel = TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head));
37522
+ tr.setSelection(sel);
37522
37523
  }
37523
37524
  }
37524
37525
  }
@@ -38299,7 +38300,7 @@ const setMeta = (view, key, value) => {
38299
38300
  };
38300
38301
  const absolutePositionToRelativePosition = (pos, type2, mapping) => {
38301
38302
  if (pos === 0) {
38302
- return Y__namespace.createRelativePositionFromTypeIndex(type2, 0, -1);
38303
+ return Y__namespace.createRelativePositionFromTypeIndex(type2, 0, type2.length === 0 ? -1 : 0);
38303
38304
  }
38304
38305
  let n = type2._first === null ? null : (
38305
38306
  /** @type {Y.ContentType} */
@@ -38308,7 +38309,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
38308
38309
  while (n !== null && type2 !== n) {
38309
38310
  if (n instanceof Y__namespace.XmlText) {
38310
38311
  if (n._length >= pos) {
38311
- return Y__namespace.createRelativePositionFromTypeIndex(n, pos, -1);
38312
+ return Y__namespace.createRelativePositionFromTypeIndex(n, pos, type2.length === 0 ? -1 : 0);
38312
38313
  } else {
38313
38314
  pos -= n._length;
38314
38315
  }
@@ -38372,7 +38373,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
38372
38373
  return createRelativePosition(n._item.parent, n._item);
38373
38374
  }
38374
38375
  }
38375
- return Y__namespace.createRelativePositionFromTypeIndex(type2, type2._length, -1);
38376
+ return Y__namespace.createRelativePositionFromTypeIndex(type2, type2._length, type2.length === 0 ? -1 : 0);
38376
38377
  };
38377
38378
  const createRelativePosition = (type2, item) => {
38378
38379
  let typeid = null;
@@ -41528,10 +41529,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41528
41529
  }
41529
41530
  /**
41530
41531
  * Unregister a PM plugin
41531
- * @param {string|Object} nameOrPlugin - Plugin name or plugin instance
41532
+ * @param {string|Object} nameOrPluginKey - Plugin name or plugin instance
41532
41533
  * @returns {void}
41533
41534
  */
41534
- unregisterPlugin(nameOrPlugin) {
41535
+ unregisterPlugin(nameOrPluginKey) {
41535
41536
  if (this.isDestroyed) return;
41536
41537
  const name = typeof nameOrPluginKey === "string" ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
41537
41538
  const state2 = this.state.reconfigure({
@@ -41609,7 +41610,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41609
41610
  /**
41610
41611
  * Attach styles and attributes to the editor element
41611
41612
  */
41612
- updateEditorStyles(element, proseMirror) {
41613
+ updateEditorStyles(element, proseMirror, hasPaginationEnabled = true) {
41613
41614
  const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
41614
41615
  if (!proseMirror || !element) {
41615
41616
  return;
@@ -41643,9 +41644,12 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41643
41644
  element.style.webkitOverflowScrolling = "touch";
41644
41645
  const defaultLineHeight = 1.2;
41645
41646
  proseMirror.style.lineHeight = defaultLineHeight;
41646
- if (!this.options.extensions.find((e) => e.name === "pagination")) {
41647
+ if (!hasPaginationEnabled) {
41647
41648
  proseMirror.style.paddingTop = "1in";
41648
41649
  proseMirror.style.paddingBottom = "1in";
41650
+ } else {
41651
+ proseMirror.style.paddingTop = "0";
41652
+ proseMirror.style.paddingBottom = "0";
41649
41653
  }
41650
41654
  }
41651
41655
  /**
@@ -41656,10 +41660,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41656
41660
  * @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
41657
41661
  * @returns {void}
41658
41662
  */
41659
- initDefaultStyles(element = this.element) {
41663
+ initDefaultStyles(element = this.element, isPaginationEnabled = true) {
41660
41664
  if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
41661
41665
  const proseMirror = element?.querySelector(".ProseMirror");
41662
- this.updateEditorStyles(element, proseMirror);
41666
+ this.updateEditorStyles(element, proseMirror, isPaginationEnabled);
41663
41667
  this.initMobileStyles(element);
41664
41668
  }
41665
41669
  /**
@@ -41707,6 +41711,25 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41707
41711
  }
41708
41712
  window.addEventListener("resize", () => handleResize);
41709
41713
  }
41714
+ /**
41715
+ * Initialize pagination, if the pagination extension is enabled.
41716
+ * @private
41717
+ * @async
41718
+ * @returns {Promise<void>}
41719
+ */
41720
+ async initPagination() {
41721
+ if (this.options.isHeadless || !this.extensionService || this.options.isHeaderOrFooter) {
41722
+ return;
41723
+ }
41724
+ const pagination = this.options.extensions.find((e) => e.name === "pagination");
41725
+ if (pagination && this.options.pagination) {
41726
+ const sectionData = await initPaginationData(this);
41727
+ this.storage.pagination.sectionData = sectionData;
41728
+ const { state: state2, dispatch } = this.view;
41729
+ const tr = state2.tr.setMeta(PaginationPluginKey, { isReadyToInit: true });
41730
+ dispatch(tr);
41731
+ }
41732
+ }
41710
41733
  /**
41711
41734
  * Get attrs of the currently selected node or mark.
41712
41735
  * @param {String} nameOrType
@@ -41916,7 +41939,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41916
41939
  * @returns {Object | void} Migration results
41917
41940
  */
41918
41941
  processCollaborationMigrations() {
41919
- console.debug("[checkVersionMigrations] Current editor version", "0.14.0-next.4");
41942
+ console.debug("[checkVersionMigrations] Current editor version", "0.14.0-next.6");
41920
41943
  if (!this.options.ydoc) return;
41921
41944
  const metaMap = this.options.ydoc.getMap("meta");
41922
41945
  let docVersion = metaMap.get("version");
@@ -41966,7 +41989,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41966
41989
  __privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
41967
41990
  }
41968
41991
  if (!this.options.ydoc) {
41969
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
41992
+ this.initPagination();
41970
41993
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
41971
41994
  }
41972
41995
  }
@@ -42133,7 +42156,7 @@ init_fn = function(options2) {
42133
42156
  this.on("comment-positions", this.options.onCommentLocationsUpdate);
42134
42157
  this.initializeCollaborationData();
42135
42158
  if (!this.options.ydoc) {
42136
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
42159
+ this.initPagination();
42137
42160
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
42138
42161
  }
42139
42162
  };
@@ -42180,7 +42203,7 @@ insertNewFileData_fn = function() {
42180
42203
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
42181
42204
  this.view.dispatch(tr);
42182
42205
  setTimeout(() => {
42183
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
42206
+ this.initPagination();
42184
42207
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
42185
42208
  }, 50);
42186
42209
  };
@@ -42326,7 +42349,7 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
42326
42349
  this.options.onCollaborationReady({ editor, ydoc });
42327
42350
  this.options.collaborationIsReady = true;
42328
42351
  if (!this.options.isNewFile) {
42329
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
42352
+ this.initPagination();
42330
42353
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
42331
42354
  }
42332
42355
  };
@@ -42343,19 +42366,6 @@ initComments_fn = function() {
42343
42366
  dispatch(tr);
42344
42367
  }, 50);
42345
42368
  };
42346
- initPagination_fn = async function() {
42347
- if (this.options.isHeadless || !this.extensionService || this.options.isHeaderOrFooter) {
42348
- return;
42349
- }
42350
- const pagination = this.options.extensions.find((e) => e.name === "pagination");
42351
- if (pagination && this.options.pagination) {
42352
- const sectionData = await initPaginationData(this);
42353
- this.storage.pagination.sectionData = sectionData;
42354
- const { state: state2, dispatch } = this.view;
42355
- const tr = state2.tr.setMeta(PaginationPluginKey, { isReadyToInit: true });
42356
- dispatch(tr);
42357
- }
42358
- };
42359
42369
  dispatchTransaction_fn = function(transaction) {
42360
42370
  if (this.isDestroyed) return;
42361
42371
  let state2;
@@ -54979,6 +54989,19 @@ const Pagination = Extension.create({
54979
54989
  return commands2.insertContent({
54980
54990
  type: "hardBreak"
54981
54991
  });
54992
+ },
54993
+ /**
54994
+ * Toggle pagination on/off
54995
+ * @returns {void}
54996
+ */
54997
+ togglePagination: () => ({ tr, state: state2, dispatch, editor }) => {
54998
+ const isEnabled = PaginationPluginKey.getState(state2)?.isEnabled;
54999
+ tr.setMeta(PaginationPluginKey, { isEnabled: !isEnabled });
55000
+ if (dispatch) {
55001
+ dispatch(tr);
55002
+ editor.initDefaultStyles(editor.element, !isEnabled);
55003
+ return true;
55004
+ }
54982
55005
  }
54983
55006
  };
54984
55007
  },
@@ -55004,11 +55027,21 @@ const Pagination = Extension.create({
55004
55027
  return {
55005
55028
  isReadyToInit: false,
55006
55029
  decorations: DecorationSet.empty,
55007
- isDebugging
55030
+ isDebugging,
55031
+ isEnabled: editor.options.pagination
55008
55032
  };
55009
55033
  },
55010
55034
  apply(tr, oldState, prevEditorState, newEditorState) {
55011
55035
  const meta = tr.getMeta(PaginationPluginKey);
55036
+ if (meta && "isEnabled" in meta) {
55037
+ const newEnabled = meta.isEnabled;
55038
+ if (newEnabled) shouldUpdate = true;
55039
+ return {
55040
+ ...oldState,
55041
+ decorations: newEnabled ? oldState.decorations : DecorationSet.empty,
55042
+ isEnabled: newEnabled
55043
+ };
55044
+ }
55012
55045
  if (meta && meta.isReadyToInit) {
55013
55046
  shouldUpdate = true;
55014
55047
  shouldInitialize = meta.isReadyToInit;
@@ -55058,6 +55091,7 @@ const Pagination = Extension.create({
55058
55091
  let previousDecorations = DecorationSet.empty;
55059
55092
  return {
55060
55093
  update: (view2, prevState) => {
55094
+ if (!PaginationPluginKey.getState(view2.state)?.isEnabled) return;
55061
55095
  if (!shouldUpdate || isUpdating) return;
55062
55096
  isUpdating = true;
55063
55097
  hasInitialized = true;
@@ -55069,7 +55103,8 @@ const Pagination = Extension.create({
55069
55103
  },
55070
55104
  props: {
55071
55105
  decorations(state2) {
55072
- return PaginationPluginKey.getState(state2).decorations;
55106
+ const pluginState = PaginationPluginKey.getState(state2);
55107
+ return pluginState.isEnabled ? pluginState.decorations : DecorationSet.empty;
55073
55108
  }
55074
55109
  }
55075
55110
  });
@@ -64880,7 +64915,6 @@ const style$2 = cB("icon", `
64880
64915
  display: inline-block;
64881
64916
  position: relative;
64882
64917
  fill: currentColor;
64883
- transform: translateZ(0);
64884
64918
  `, [cM("color-transition", {
64885
64919
  transition: "color .3s var(--n-bezier)"
64886
64920
  }), cM("depth", {
@@ -1,4 +1,4 @@
1
- import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-Bi1uWinj.es.js";
1
+ import { g as global$2, r as ref$1, c as createApp, a as computed, b as createElementBlock, o as openBlock, F as Fragment$1, d as renderList, n as normalizeClass, w as withModifiers, e as createCommentVNode, t as toDisplayString, f as createBaseVNode, i as inject, h as onBeforeMount, j as onMounted, k as onBeforeUnmount, l as watch, m as defineComponent, q as getCurrentInstance, s as onDeactivated, u as nextTick, v as createBlock, x as createVNode, y as unref, z as withCtx, A as createTextVNode, B as normalizeStyle, C as h, D as toRef, E as provide, G as mergeProps, H as cloneVNode, T as Text$2, I as withDirectives, J as watchEffect, K as shallowRef, L as vModelText, M as withKeys, N as reactive, O as readonly, P as Transition, Q as vShow, R as Comment, S as renderSlot, U as onActivated, V as Teleport, W as isVNode, X as onUnmounted } from "./vue-BBJVqxjL.es.js";
2
2
  import * as Y from "yjs";
3
3
  import { UndoManager, Item as Item$2, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
4
4
  var __defProp$2 = Object.defineProperty;
@@ -24235,7 +24235,7 @@ const _SuperConverter = class _SuperConverter2 {
24235
24235
  return;
24236
24236
  }
24237
24237
  }
24238
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.0-next.4") {
24238
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.0-next.6") {
24239
24239
  const customLocation = "docProps/custom.xml";
24240
24240
  if (!docx[customLocation]) {
24241
24241
  docx[customLocation] = generateCustomXml();
@@ -24703,7 +24703,7 @@ function storeSuperdocVersion(docx) {
24703
24703
  function generateCustomXml() {
24704
24704
  return DEFAULT_CUSTOM_XML;
24705
24705
  }
24706
- function generateSuperdocVersion(pid = 2, version2 = "0.14.0-next.4") {
24706
+ function generateSuperdocVersion(pid = 2, version2 = "0.14.0-next.6") {
24707
24707
  return {
24708
24708
  type: "element",
24709
24709
  name: "property",
@@ -27236,7 +27236,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
27236
27236
  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);
27237
27237
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
27238
27238
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
27239
- 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, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
27239
+ 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, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
27240
27240
  function getMarksFromSelection(state2) {
27241
27241
  const { from: from2, to, empty: empty2 } = state2.selection;
27242
27242
  const marks = [];
@@ -37501,7 +37501,8 @@ const restoreRelativeSelection = (tr, relSel, binding) => {
37501
37501
  binding.mapping
37502
37502
  );
37503
37503
  if (anchor !== null && head !== null) {
37504
- tr.setSelection(TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head)));
37504
+ const sel = TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head));
37505
+ tr.setSelection(sel);
37505
37506
  }
37506
37507
  }
37507
37508
  }
@@ -38282,7 +38283,7 @@ const setMeta = (view, key, value) => {
38282
38283
  };
38283
38284
  const absolutePositionToRelativePosition = (pos, type2, mapping) => {
38284
38285
  if (pos === 0) {
38285
- return Y.createRelativePositionFromTypeIndex(type2, 0, -1);
38286
+ return Y.createRelativePositionFromTypeIndex(type2, 0, type2.length === 0 ? -1 : 0);
38286
38287
  }
38287
38288
  let n = type2._first === null ? null : (
38288
38289
  /** @type {Y.ContentType} */
@@ -38291,7 +38292,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
38291
38292
  while (n !== null && type2 !== n) {
38292
38293
  if (n instanceof Y.XmlText) {
38293
38294
  if (n._length >= pos) {
38294
- return Y.createRelativePositionFromTypeIndex(n, pos, -1);
38295
+ return Y.createRelativePositionFromTypeIndex(n, pos, type2.length === 0 ? -1 : 0);
38295
38296
  } else {
38296
38297
  pos -= n._length;
38297
38298
  }
@@ -38355,7 +38356,7 @@ const absolutePositionToRelativePosition = (pos, type2, mapping) => {
38355
38356
  return createRelativePosition(n._item.parent, n._item);
38356
38357
  }
38357
38358
  }
38358
- return Y.createRelativePositionFromTypeIndex(type2, type2._length, -1);
38359
+ return Y.createRelativePositionFromTypeIndex(type2, type2._length, type2.length === 0 ? -1 : 0);
38359
38360
  };
38360
38361
  const createRelativePosition = (type2, item) => {
38361
38362
  let typeid = null;
@@ -41511,10 +41512,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41511
41512
  }
41512
41513
  /**
41513
41514
  * Unregister a PM plugin
41514
- * @param {string|Object} nameOrPlugin - Plugin name or plugin instance
41515
+ * @param {string|Object} nameOrPluginKey - Plugin name or plugin instance
41515
41516
  * @returns {void}
41516
41517
  */
41517
- unregisterPlugin(nameOrPlugin) {
41518
+ unregisterPlugin(nameOrPluginKey) {
41518
41519
  if (this.isDestroyed) return;
41519
41520
  const name = typeof nameOrPluginKey === "string" ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
41520
41521
  const state2 = this.state.reconfigure({
@@ -41592,7 +41593,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41592
41593
  /**
41593
41594
  * Attach styles and attributes to the editor element
41594
41595
  */
41595
- updateEditorStyles(element, proseMirror) {
41596
+ updateEditorStyles(element, proseMirror, hasPaginationEnabled = true) {
41596
41597
  const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
41597
41598
  if (!proseMirror || !element) {
41598
41599
  return;
@@ -41626,9 +41627,12 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41626
41627
  element.style.webkitOverflowScrolling = "touch";
41627
41628
  const defaultLineHeight = 1.2;
41628
41629
  proseMirror.style.lineHeight = defaultLineHeight;
41629
- if (!this.options.extensions.find((e) => e.name === "pagination")) {
41630
+ if (!hasPaginationEnabled) {
41630
41631
  proseMirror.style.paddingTop = "1in";
41631
41632
  proseMirror.style.paddingBottom = "1in";
41633
+ } else {
41634
+ proseMirror.style.paddingTop = "0";
41635
+ proseMirror.style.paddingBottom = "0";
41632
41636
  }
41633
41637
  }
41634
41638
  /**
@@ -41639,10 +41643,10 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41639
41643
  * @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
41640
41644
  * @returns {void}
41641
41645
  */
41642
- initDefaultStyles(element = this.element) {
41646
+ initDefaultStyles(element = this.element, isPaginationEnabled = true) {
41643
41647
  if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
41644
41648
  const proseMirror = element?.querySelector(".ProseMirror");
41645
- this.updateEditorStyles(element, proseMirror);
41649
+ this.updateEditorStyles(element, proseMirror, isPaginationEnabled);
41646
41650
  this.initMobileStyles(element);
41647
41651
  }
41648
41652
  /**
@@ -41690,6 +41694,25 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41690
41694
  }
41691
41695
  window.addEventListener("resize", () => handleResize);
41692
41696
  }
41697
+ /**
41698
+ * Initialize pagination, if the pagination extension is enabled.
41699
+ * @private
41700
+ * @async
41701
+ * @returns {Promise<void>}
41702
+ */
41703
+ async initPagination() {
41704
+ if (this.options.isHeadless || !this.extensionService || this.options.isHeaderOrFooter) {
41705
+ return;
41706
+ }
41707
+ const pagination = this.options.extensions.find((e) => e.name === "pagination");
41708
+ if (pagination && this.options.pagination) {
41709
+ const sectionData = await initPaginationData(this);
41710
+ this.storage.pagination.sectionData = sectionData;
41711
+ const { state: state2, dispatch } = this.view;
41712
+ const tr = state2.tr.setMeta(PaginationPluginKey, { isReadyToInit: true });
41713
+ dispatch(tr);
41714
+ }
41715
+ }
41693
41716
  /**
41694
41717
  * Get attrs of the currently selected node or mark.
41695
41718
  * @param {String} nameOrType
@@ -41899,7 +41922,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41899
41922
  * @returns {Object | void} Migration results
41900
41923
  */
41901
41924
  processCollaborationMigrations() {
41902
- console.debug("[checkVersionMigrations] Current editor version", "0.14.0-next.4");
41925
+ console.debug("[checkVersionMigrations] Current editor version", "0.14.0-next.6");
41903
41926
  if (!this.options.ydoc) return;
41904
41927
  const metaMap = this.options.ydoc.getMap("meta");
41905
41928
  let docVersion = metaMap.get("version");
@@ -41949,7 +41972,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
41949
41972
  __privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
41950
41973
  }
41951
41974
  if (!this.options.ydoc) {
41952
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
41975
+ this.initPagination();
41953
41976
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
41954
41977
  }
41955
41978
  }
@@ -42116,7 +42139,7 @@ init_fn = function(options2) {
42116
42139
  this.on("comment-positions", this.options.onCommentLocationsUpdate);
42117
42140
  this.initializeCollaborationData();
42118
42141
  if (!this.options.ydoc) {
42119
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
42142
+ this.initPagination();
42120
42143
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
42121
42144
  }
42122
42145
  };
@@ -42163,7 +42186,7 @@ insertNewFileData_fn = function() {
42163
42186
  const tr = this.state.tr.replaceWith(0, this.state.doc.content.size, doc2);
42164
42187
  this.view.dispatch(tr);
42165
42188
  setTimeout(() => {
42166
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
42189
+ this.initPagination();
42167
42190
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
42168
42191
  }, 50);
42169
42192
  };
@@ -42309,7 +42332,7 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
42309
42332
  this.options.onCollaborationReady({ editor, ydoc });
42310
42333
  this.options.collaborationIsReady = true;
42311
42334
  if (!this.options.isNewFile) {
42312
- __privateMethod$1(this, _Editor_instances, initPagination_fn).call(this);
42335
+ this.initPagination();
42313
42336
  __privateMethod$1(this, _Editor_instances, initComments_fn).call(this);
42314
42337
  }
42315
42338
  };
@@ -42326,19 +42349,6 @@ initComments_fn = function() {
42326
42349
  dispatch(tr);
42327
42350
  }, 50);
42328
42351
  };
42329
- initPagination_fn = async function() {
42330
- if (this.options.isHeadless || !this.extensionService || this.options.isHeaderOrFooter) {
42331
- return;
42332
- }
42333
- const pagination = this.options.extensions.find((e) => e.name === "pagination");
42334
- if (pagination && this.options.pagination) {
42335
- const sectionData = await initPaginationData(this);
42336
- this.storage.pagination.sectionData = sectionData;
42337
- const { state: state2, dispatch } = this.view;
42338
- const tr = state2.tr.setMeta(PaginationPluginKey, { isReadyToInit: true });
42339
- dispatch(tr);
42340
- }
42341
- };
42342
42352
  dispatchTransaction_fn = function(transaction) {
42343
42353
  if (this.isDestroyed) return;
42344
42354
  let state2;
@@ -54962,6 +54972,19 @@ const Pagination = Extension.create({
54962
54972
  return commands2.insertContent({
54963
54973
  type: "hardBreak"
54964
54974
  });
54975
+ },
54976
+ /**
54977
+ * Toggle pagination on/off
54978
+ * @returns {void}
54979
+ */
54980
+ togglePagination: () => ({ tr, state: state2, dispatch, editor }) => {
54981
+ const isEnabled = PaginationPluginKey.getState(state2)?.isEnabled;
54982
+ tr.setMeta(PaginationPluginKey, { isEnabled: !isEnabled });
54983
+ if (dispatch) {
54984
+ dispatch(tr);
54985
+ editor.initDefaultStyles(editor.element, !isEnabled);
54986
+ return true;
54987
+ }
54965
54988
  }
54966
54989
  };
54967
54990
  },
@@ -54987,11 +55010,21 @@ const Pagination = Extension.create({
54987
55010
  return {
54988
55011
  isReadyToInit: false,
54989
55012
  decorations: DecorationSet.empty,
54990
- isDebugging
55013
+ isDebugging,
55014
+ isEnabled: editor.options.pagination
54991
55015
  };
54992
55016
  },
54993
55017
  apply(tr, oldState, prevEditorState, newEditorState) {
54994
55018
  const meta = tr.getMeta(PaginationPluginKey);
55019
+ if (meta && "isEnabled" in meta) {
55020
+ const newEnabled = meta.isEnabled;
55021
+ if (newEnabled) shouldUpdate = true;
55022
+ return {
55023
+ ...oldState,
55024
+ decorations: newEnabled ? oldState.decorations : DecorationSet.empty,
55025
+ isEnabled: newEnabled
55026
+ };
55027
+ }
54995
55028
  if (meta && meta.isReadyToInit) {
54996
55029
  shouldUpdate = true;
54997
55030
  shouldInitialize = meta.isReadyToInit;
@@ -55041,6 +55074,7 @@ const Pagination = Extension.create({
55041
55074
  let previousDecorations = DecorationSet.empty;
55042
55075
  return {
55043
55076
  update: (view2, prevState) => {
55077
+ if (!PaginationPluginKey.getState(view2.state)?.isEnabled) return;
55044
55078
  if (!shouldUpdate || isUpdating) return;
55045
55079
  isUpdating = true;
55046
55080
  hasInitialized = true;
@@ -55052,7 +55086,8 @@ const Pagination = Extension.create({
55052
55086
  },
55053
55087
  props: {
55054
55088
  decorations(state2) {
55055
- return PaginationPluginKey.getState(state2).decorations;
55089
+ const pluginState = PaginationPluginKey.getState(state2);
55090
+ return pluginState.isEnabled ? pluginState.decorations : DecorationSet.empty;
55056
55091
  }
55057
55092
  }
55058
55093
  });
@@ -64863,7 +64898,6 @@ const style$2 = cB("icon", `
64863
64898
  display: inline-block;
64864
64899
  position: relative;
64865
64900
  fill: currentColor;
64866
- transform: translateZ(0);
64867
64901
  `, [cM("color-transition", {
64868
64902
  transition: "color .3s var(--n-bezier)"
64869
64903
  }), cM("depth", {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const jszip = require("./jszip-BTAcmbVg.cjs");
3
- const xmlJs = require("./xml-js-BjqmFOSP.cjs");
2
+ const jszip = require("./jszip-9bCX1h2W.cjs");
3
+ const xmlJs = require("./xml-js-PTtx0UCg.cjs");
4
4
  const __viteBrowserExternal = require("./__vite-browser-external-DWbQq7bv.cjs");
5
5
  var punycode$1 = { exports: {} };
6
6
  /*! https://mths.be/punycode v1.4.1 by @mathias */
@@ -1,5 +1,5 @@
1
- import { c as commonjsGlobal, g as getDefaultExportFromCjs, a as getAugmentedNamespace } from "./jszip-DckFs3A7.es.js";
2
- import { t as type, g as getIntrinsic, c as callBound$2 } from "./xml-js-CfClL-1b.es.js";
1
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs, a as getAugmentedNamespace } from "./jszip-Cl3s9njw.es.js";
2
+ import { t as type, g as getIntrinsic, c as callBound$2 } from "./xml-js-uhSaCX_L.es.js";
3
3
  import { _ as __viteBrowserExternal } from "./__vite-browser-external-CURh0WXD.es.js";
4
4
  var punycode$1 = { exports: {} };
5
5
  /*! https://mths.be/punycode v1.4.1 by @mathias */