@harbour-enterprises/superdoc 1.0.0-beta.70 → 1.0.0-beta.72

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 (29) hide show
  1. package/dist/chunks/{PdfViewer-Li0IVylM.cjs → PdfViewer-BxCLl7Q6.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-DSqV0wBl.es.js → PdfViewer-Dg-qiC1A.es.js} +1 -1
  3. package/dist/chunks/{index-atbbnwyB.es.js → index-B1AqHbuy.es.js} +3 -3
  4. package/dist/chunks/{index-CJCOemVA.cjs → index-CAQDtLex.cjs} +3 -3
  5. package/dist/chunks/{index-DruHtc6s-CBCtA0Ud.cjs → index-qXb-Hmel-BPsIpdLY.cjs} +1 -1
  6. package/dist/chunks/{index-DruHtc6s-CPc5HSle.es.js → index-qXb-Hmel-DwJhkxdW.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-4JNmJF9G.es.js → super-editor.es-DPl3-zTR.es.js} +257 -16
  8. package/dist/chunks/{super-editor.es-CzBIlSB8.cjs → super-editor.es-DxG6ckVG.cjs} +257 -16
  9. package/dist/style.css +7 -8
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-B4HiY8pI.js → converter-JlOFMM88.js} +1 -1
  12. package/dist/super-editor/chunks/{docx-zipper-D7YJSyKT.js → docx-zipper-BVmpz1K_.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-C9smgNs-.js → editor-CNzx36Ms.js} +198 -7
  14. package/dist/super-editor/chunks/{index-DruHtc6s.js → index-qXb-Hmel.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-BuJaDiNO.js → toolbar-DAhwzyFV.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/style.css +7 -8
  21. package/dist/super-editor/super-editor.es.js +66 -16
  22. package/dist/super-editor/toolbar.es.js +2 -2
  23. package/dist/super-editor.cjs +1 -1
  24. package/dist/super-editor.es.js +1 -1
  25. package/dist/superdoc.cjs +2 -2
  26. package/dist/superdoc.es.js +2 -2
  27. package/dist/superdoc.umd.js +259 -18
  28. package/dist/superdoc.umd.js.map +1 -1
  29. package/package.json +1 -1
@@ -42327,7 +42327,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42327
42327
  static getStoredSuperdocVersion(docx) {
42328
42328
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42329
42329
  }
42330
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.70") {
42330
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.72") {
42331
42331
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42332
42332
  }
42333
42333
  /**
@@ -67373,7 +67373,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67373
67373
  const shouldSkipNodeView = (editor) => {
67374
67374
  return isHeadless(editor);
67375
67375
  };
67376
- const summaryVersion = "1.0.0-beta.70";
67376
+ const summaryVersion = "1.0.0-beta.72";
67377
67377
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67378
67378
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67379
67379
  function mapAttributes(attrs) {
@@ -68162,7 +68162,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68162
68162
  { default: remarkStringify2 },
68163
68163
  { default: remarkGfm2 }
68164
68164
  ] = await Promise.all([
68165
- Promise.resolve().then(() => indexDruHtc6s),
68165
+ Promise.resolve().then(() => indexQXbHmel),
68166
68166
  Promise.resolve().then(() => indexDRCvimau),
68167
68167
  Promise.resolve().then(() => indexC_x_N6Uh),
68168
68168
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68367,7 +68367,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68367
68367
  * Process collaboration migrations
68368
68368
  */
68369
68369
  processCollaborationMigrations() {
68370
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.70");
68370
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.72");
68371
68371
  if (!this.options.ydoc) return;
68372
68372
  const metaMap = this.options.ydoc.getMap("meta");
68373
68373
  let docVersion = metaMap.get("version");
@@ -92944,6 +92944,109 @@ ${l}
92944
92944
  const activeEditor = this.getActiveEditor();
92945
92945
  return activeEditor.commands;
92946
92946
  }
92947
+ /**
92948
+ * Get the ProseMirror editor state for the currently active editor (header/footer-aware).
92949
+ *
92950
+ * This property dynamically returns the state from the appropriate editor instance:
92951
+ * - In body mode, returns the main editor's state
92952
+ * - In header/footer mode, returns the active header/footer editor's state
92953
+ *
92954
+ * This enables components like SlashMenu and context menus to access document
92955
+ * state, selection, and schema information in the correct editing context.
92956
+ *
92957
+ * @returns The EditorState for the active editor
92958
+ *
92959
+ * @example
92960
+ * ```typescript
92961
+ * const { selection, doc } = presentationEditor.state;
92962
+ * const selectedText = doc.textBetween(selection.from, selection.to);
92963
+ * ```
92964
+ */
92965
+ get state() {
92966
+ return this.getActiveEditor().state;
92967
+ }
92968
+ /**
92969
+ * Check if the editor is currently editable (header/footer-aware).
92970
+ *
92971
+ * This property checks the editable state of the currently active editor:
92972
+ * - In body mode, returns whether the main editor is editable
92973
+ * - In header/footer mode, returns whether the header/footer editor is editable
92974
+ *
92975
+ * The editor may be non-editable due to:
92976
+ * - Document mode set to 'viewing'
92977
+ * - Explicit `editable: false` option
92978
+ * - Editor not fully initialized
92979
+ *
92980
+ * @returns true if the active editor accepts input, false otherwise
92981
+ *
92982
+ * @example
92983
+ * ```typescript
92984
+ * if (presentationEditor.isEditable) {
92985
+ * presentationEditor.commands.insertText('Hello');
92986
+ * }
92987
+ * ```
92988
+ */
92989
+ get isEditable() {
92990
+ return this.getActiveEditor().isEditable;
92991
+ }
92992
+ /**
92993
+ * Get the editor options for the currently active editor (header/footer-aware).
92994
+ *
92995
+ * This property returns the options object from the appropriate editor instance,
92996
+ * providing access to configuration like document mode, AI settings, and custom
92997
+ * slash menu configuration.
92998
+ *
92999
+ * @returns The options object for the active editor
93000
+ *
93001
+ * @example
93002
+ * ```typescript
93003
+ * const { documentMode, isAiEnabled } = presentationEditor.options;
93004
+ * ```
93005
+ */
93006
+ get options() {
93007
+ return this.getActiveEditor().options;
93008
+ }
93009
+ /**
93010
+ * Dispatch a ProseMirror transaction to the currently active editor (header/footer-aware).
93011
+ *
93012
+ * This method routes transactions to the appropriate editor instance:
93013
+ * - In body mode, dispatches to the main editor
93014
+ * - In header/footer mode, dispatches to the active header/footer editor
93015
+ *
93016
+ * Use this for direct state manipulation when commands are insufficient.
93017
+ * For most use cases, prefer using `commands` or `dispatchInActiveEditor`.
93018
+ *
93019
+ * @param tr - The ProseMirror transaction to dispatch
93020
+ *
93021
+ * @example
93022
+ * ```typescript
93023
+ * const { state } = presentationEditor;
93024
+ * const tr = state.tr.insertText('Hello', state.selection.from);
93025
+ * presentationEditor.dispatch(tr);
93026
+ * ```
93027
+ */
93028
+ dispatch(tr) {
93029
+ const activeEditor = this.getActiveEditor();
93030
+ activeEditor.view?.dispatch(tr);
93031
+ }
93032
+ /**
93033
+ * Focus the editor, routing focus to the appropriate editing surface.
93034
+ *
93035
+ * In PresentationEditor, the actual ProseMirror EditorView is hidden and input
93036
+ * is bridged from the visible layout surface. This method focuses the hidden
93037
+ * editor view to enable keyboard input while the visual focus remains on the
93038
+ * rendered presentation.
93039
+ *
93040
+ * @example
93041
+ * ```typescript
93042
+ * // After closing a modal, restore focus to the editor
93043
+ * presentationEditor.focus();
93044
+ * ```
93045
+ */
93046
+ focus() {
93047
+ const activeEditor = this.getActiveEditor();
93048
+ activeEditor.view?.focus();
93049
+ }
92947
93050
  /**
92948
93051
  * Returns the currently active editor (body or header/footer session).
92949
93052
  *
@@ -93409,6 +93512,74 @@ ${l}
93409
93512
  getLayoutOptions() {
93410
93513
  return { ...__privateGet$1(this, _layoutOptions) };
93411
93514
  }
93515
+ /**
93516
+ * Get the page styles for the section containing the current caret position.
93517
+ *
93518
+ * In multi-section documents, different sections can have different page sizes,
93519
+ * margins, and orientations. This method returns the styles for the section
93520
+ * where the caret is currently located, enabling section-aware UI components
93521
+ * like rulers to display accurate information.
93522
+ *
93523
+ * @returns Object containing:
93524
+ * - pageSize: { width, height } in inches
93525
+ * - pageMargins: { left, right, top, bottom } in inches
93526
+ * - sectionIndex: The current section index (0-based)
93527
+ * - orientation: 'portrait' or 'landscape'
93528
+ *
93529
+ * Falls back to document-level defaults if section info is unavailable.
93530
+ *
93531
+ * @example
93532
+ * ```typescript
93533
+ * const sectionStyles = presentation.getCurrentSectionPageStyles();
93534
+ * console.log(`Section ${sectionStyles.sectionIndex}: ${sectionStyles.pageSize.width}" x ${sectionStyles.pageSize.height}"`);
93535
+ * ```
93536
+ */
93537
+ getCurrentSectionPageStyles() {
93538
+ const PPI2 = 96;
93539
+ const layout = __privateGet$1(this, _layoutState).layout;
93540
+ const pageIndex = __privateMethod$1(this, _PresentationEditor_instances, getCurrentPageIndex_fn).call(this);
93541
+ const page = layout?.pages?.[pageIndex];
93542
+ const converterStyles = __privateGet$1(this, _editor3).converter?.pageStyles ?? {};
93543
+ const defaultMargins = converterStyles.pageMargins ?? { left: 1, right: 1, top: 1, bottom: 1 };
93544
+ const safeMargins = {
93545
+ left: typeof defaultMargins.left === "number" ? defaultMargins.left : 1,
93546
+ right: typeof defaultMargins.right === "number" ? defaultMargins.right : 1,
93547
+ top: typeof defaultMargins.top === "number" ? defaultMargins.top : 1,
93548
+ bottom: typeof defaultMargins.bottom === "number" ? defaultMargins.bottom : 1
93549
+ };
93550
+ if (!page) {
93551
+ return {
93552
+ pageSize: { width: 8.5, height: 11 },
93553
+ pageMargins: safeMargins,
93554
+ sectionIndex: 0,
93555
+ orientation: "portrait"
93556
+ };
93557
+ }
93558
+ const pageOrientation = page.orientation === "landscape" || page.orientation === "portrait" ? page.orientation : "portrait";
93559
+ const standardPortrait = { w: 8.5 * PPI2, h: 11 * PPI2 };
93560
+ const standardLandscape = { w: 11 * PPI2, h: 8.5 * PPI2 };
93561
+ const orientationDefault = pageOrientation === "landscape" ? standardLandscape : standardPortrait;
93562
+ const pageWidthPx = page.size?.w ?? orientationDefault.w;
93563
+ const pageHeightPx = page.size?.h ?? orientationDefault.h;
93564
+ const marginLeftPx = page.margins?.left ?? safeMargins.left * PPI2;
93565
+ const marginRightPx = page.margins?.right ?? safeMargins.right * PPI2;
93566
+ const marginTopPx = page.margins?.top ?? safeMargins.top * PPI2;
93567
+ const marginBottomPx = page.margins?.bottom ?? safeMargins.bottom * PPI2;
93568
+ return {
93569
+ pageSize: {
93570
+ width: pageWidthPx / PPI2,
93571
+ height: pageHeightPx / PPI2
93572
+ },
93573
+ pageMargins: {
93574
+ left: marginLeftPx / PPI2,
93575
+ right: marginRightPx / PPI2,
93576
+ top: marginTopPx / PPI2,
93577
+ bottom: marginBottomPx / PPI2
93578
+ },
93579
+ sectionIndex: page.sectionIndex ?? 0,
93580
+ orientation: pageOrientation
93581
+ };
93582
+ }
93412
93583
  /**
93413
93584
  * Get current remote cursor states (normalized to absolute PM positions).
93414
93585
  * Returns an array of cursor states for all remote collaborators, excluding the local user.
@@ -96303,9 +96474,26 @@ ${l}
96303
96474
  }
96304
96475
  const layout = __privateGet$1(this, _layoutState).layout;
96305
96476
  const selection = __privateGet$1(this, _editor3).state?.selection;
96306
- if (!layout || !selection) return 0;
96477
+ if (!layout || !selection) {
96478
+ return 0;
96479
+ }
96307
96480
  const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, selection.from, selection.to) ?? [];
96308
- return rects[0]?.pageIndex ?? 0;
96481
+ if (rects.length > 0) {
96482
+ return rects[0]?.pageIndex ?? 0;
96483
+ }
96484
+ const pos = selection.from;
96485
+ for (let pageIdx = 0; pageIdx < layout.pages.length; pageIdx++) {
96486
+ const page = layout.pages[pageIdx];
96487
+ for (const fragment of page.fragments) {
96488
+ const frag = fragment;
96489
+ if (frag.pmStart != null && frag.pmEnd != null) {
96490
+ if (pos >= frag.pmStart && pos <= frag.pmEnd) {
96491
+ return pageIdx;
96492
+ }
96493
+ }
96494
+ }
96495
+ }
96496
+ return 0;
96309
96497
  };
96310
96498
  findRegionForPage_fn = function(kind, pageIndex) {
96311
96499
  const map2 = kind === "header" ? __privateGet$1(this, _headerRegions) : __privateGet$1(this, _footerRegions);
@@ -97723,6 +97911,9 @@ ${l}
97723
97911
  };
97724
97912
  function getEditorSurfaceElement(editor) {
97725
97913
  if (!editor) return null;
97914
+ if (typeof editor.hitTest === "function" && editor.element instanceof HTMLElement) {
97915
+ return editor.element;
97916
+ }
97726
97917
  return editor.presentationEditor?.element ?? editor.view?.dom ?? editor.options?.element ?? null;
97727
97918
  }
97728
97919
  function getSurfaceRelativePoint(editor, eventLocation = {}) {
@@ -130867,7 +131058,7 @@ ${style2}
130867
131058
  onMounted(() => {
130868
131059
  if (!props.editor) return;
130869
131060
  document.addEventListener("keydown", handleGlobalKeyDown);
130870
- document.addEventListener("mousedown", handleGlobalOutsideClick);
131061
+ document.addEventListener("pointerdown", handleGlobalOutsideClick);
130871
131062
  props.editor.on("update", handleEditorUpdate);
130872
131063
  slashMenuOpenHandler = async (event) => {
130873
131064
  const readOnly = !props.editor?.isEditable;
@@ -130901,7 +131092,7 @@ ${style2}
130901
131092
  });
130902
131093
  onBeforeUnmount(() => {
130903
131094
  document.removeEventListener("keydown", handleGlobalKeyDown);
130904
- document.removeEventListener("mousedown", handleGlobalOutsideClick);
131095
+ document.removeEventListener("pointerdown", handleGlobalOutsideClick);
130905
131096
  cleanupCustomItems();
130906
131097
  if (props.editor) {
130907
131098
  try {
@@ -130925,7 +131116,7 @@ ${style2}
130925
131116
  ref: menuRef,
130926
131117
  class: "slash-menu",
130927
131118
  style: normalizeStyle(menuPosition.value),
130928
- onMousedown: _cache[2] || (_cache[2] = withModifiers(() => {
131119
+ onPointerdown: _cache[2] || (_cache[2] = withModifiers(() => {
130929
131120
  }, ["stop"]))
130930
131121
  }, [
130931
131122
  withDirectives(createBaseVNode("input", {
@@ -131010,6 +131201,7 @@ ${style2}
131010
131201
  const rulerHandleActiveColor = ref("#2563EB66");
131011
131202
  const pageSize = ref(null);
131012
131203
  const pageMargins = ref(null);
131204
+ const currentSectionIndex = ref(0);
131013
131205
  const isDragging = ref(false);
131014
131206
  const currentHandle = ref(null);
131015
131207
  const leftHandle = reactive({ side: "left", x: 0 });
@@ -131017,9 +131209,29 @@ ${style2}
131017
131209
  const showVerticalIndicator = ref(false);
131018
131210
  const initialX = ref(0);
131019
131211
  let offsetX = 0;
131020
- const initRuler = () => {
131021
- if (props.editor.options.mode !== "docx") return null;
131022
- const { pageMargins: docMargins, pageSize: docSize } = props.editor.getPageStyles();
131212
+ let selectionUpdateHandler = null;
131213
+ const getPresentationEditor = () => {
131214
+ return props.editor?.presentationEditor ?? null;
131215
+ };
131216
+ const updateRulerForCurrentSection = () => {
131217
+ if (!props.editor || props.editor.options?.mode !== "docx") return;
131218
+ const presentationEditor = getPresentationEditor();
131219
+ let docSize, docMargins, sectionIndex;
131220
+ if (presentationEditor && typeof presentationEditor.getCurrentSectionPageStyles === "function") {
131221
+ const sectionStyles = presentationEditor.getCurrentSectionPageStyles();
131222
+ docSize = sectionStyles.pageSize;
131223
+ docMargins = sectionStyles.pageMargins;
131224
+ sectionIndex = sectionStyles.sectionIndex;
131225
+ } else {
131226
+ const styles = props.editor.getPageStyles();
131227
+ docSize = styles.pageSize ?? { width: 8.5, height: 11 };
131228
+ docMargins = styles.pageMargins ?? { left: 1, right: 1, top: 1, bottom: 1 };
131229
+ sectionIndex = 0;
131230
+ }
131231
+ if (pageSize.value && currentSectionIndex.value === sectionIndex) {
131232
+ return;
131233
+ }
131234
+ currentSectionIndex.value = sectionIndex;
131023
131235
  pageSize.value = docSize;
131024
131236
  pageMargins.value = docMargins;
131025
131237
  const definition2 = generateRulerDefinition({
@@ -131033,7 +131245,7 @@ ${style2}
131033
131245
  });
131034
131246
  leftHandle.x = definition2.leftMarginPx;
131035
131247
  rightHandle.x = definition2.rightMarginPx;
131036
- return definition2;
131248
+ rulerDefinition.value = definition2;
131037
131249
  };
131038
131250
  const getTickStyle = computed(() => (tick) => {
131039
131251
  return {
@@ -131087,7 +131299,8 @@ ${style2}
131087
131299
  const marginValue = getNewMarginValue();
131088
131300
  emit2("margin-change", {
131089
131301
  side: currentHandle.value.side,
131090
- value: marginValue
131302
+ value: marginValue,
131303
+ sectionIndex: currentSectionIndex.value
131091
131304
  });
131092
131305
  }
131093
131306
  };
@@ -131111,12 +131324,40 @@ ${style2}
131111
131324
  "--ruler-width": `${width}px`
131112
131325
  };
131113
131326
  });
131327
+ const handleSelectionUpdate = () => {
131328
+ if (isDragging.value) return;
131329
+ updateRulerForCurrentSection();
131330
+ };
131331
+ const setupEditorListeners = () => {
131332
+ if (!props.editor) return;
131333
+ selectionUpdateHandler = handleSelectionUpdate;
131334
+ props.editor.on("selectionUpdate", selectionUpdateHandler);
131335
+ };
131336
+ const cleanupEditorListeners = () => {
131337
+ if (!props.editor || !selectionUpdateHandler) return;
131338
+ props.editor.off("selectionUpdate", selectionUpdateHandler);
131339
+ selectionUpdateHandler = null;
131340
+ };
131341
+ watch(
131342
+ () => props.editor,
131343
+ (newEditor, oldEditor) => {
131344
+ if (oldEditor && selectionUpdateHandler) {
131345
+ oldEditor.off("selectionUpdate", selectionUpdateHandler);
131346
+ }
131347
+ if (newEditor) {
131348
+ setupEditorListeners();
131349
+ updateRulerForCurrentSection();
131350
+ }
131351
+ }
131352
+ );
131114
131353
  onMounted(() => {
131115
- rulerDefinition.value = initRuler();
131354
+ updateRulerForCurrentSection();
131355
+ setupEditorListeners();
131116
131356
  window.addEventListener("mousemove", handleMouseMove2);
131117
131357
  window.addEventListener("mouseup", handleMouseUp);
131118
131358
  });
131119
131359
  onUnmounted(() => {
131360
+ cleanupEditorListeners();
131120
131361
  window.removeEventListener("mousemove", handleMouseMove2);
131121
131362
  window.removeEventListener("mouseup", handleMouseUp);
131122
131363
  });
@@ -131157,7 +131398,7 @@ ${style2}
131157
131398
  };
131158
131399
  }
131159
131400
  };
131160
- const Ruler = /* @__PURE__ */ _export_sfc$1(_sfc_main$6$1, [["__scopeId", "data-v-b9f4f30a"]]);
131401
+ const Ruler = /* @__PURE__ */ _export_sfc$1(_sfc_main$6$1, [["__scopeId", "data-v-0d1b9cd1"]]);
131161
131402
  const _sfc_main$5$1 = {
131162
131403
  __name: "GenericPopover",
131163
131404
  props: {
@@ -150147,7 +150388,7 @@ ${style2}
150147
150388
  this.config.colors = shuffleArray(this.config.colors);
150148
150389
  this.userColorMap = /* @__PURE__ */ new Map();
150149
150390
  this.colorIndex = 0;
150150
- this.version = "1.0.0-beta.70";
150391
+ this.version = "1.0.0-beta.72";
150151
150392
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
150152
150393
  this.superdocId = config2.superdocId || v4();
150153
150394
  this.colors = this.config.colors;
@@ -152619,7 +152860,7 @@ ${style2}
152619
152860
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
152620
152861
  );
152621
152862
  }
152622
- const indexDruHtc6s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
152863
+ const indexQXbHmel = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
152623
152864
  __proto__: null,
152624
152865
  unified
152625
152866
  }, Symbol.toStringTag, { value: "Module" }));