superdoc 2.13.0-next.10 → 2.13.0-next.11

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.
package/dist/superdoc.cjs CHANGED
@@ -4,7 +4,7 @@ const require_blank_docx = require("./chunks/blank-docx-BuFAbRjs.cjs");
4
4
  const require_eventemitter3 = require("./chunks/eventemitter3-C_TAnXOl.cjs");
5
5
  const require_uuid = require("./chunks/uuid-BhG0ngwk.cjs");
6
6
  const require_jszip = require("./chunks/jszip-D8mAFF-r.cjs");
7
- const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-mHK2pqj3.cjs");
7
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-DNfQTF2k.cjs");
8
8
  const require__plugin_vue_export_helper = require("./chunks/_plugin-vue_export-helper-SDR04tiH.cjs");
9
9
  const require_constants = require("./chunks/constants-DpXuDx_g.cjs");
10
10
  let vue = require("vue");
@@ -316,7 +316,7 @@ var shuffleArray = (array) => {
316
316
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
317
317
  function getSuperdocVersion() {
318
318
  try {
319
- return "2.13.0-next.10";
319
+ return "2.13.0-next.11";
320
320
  } catch {
321
321
  return "unknown";
322
322
  }
@@ -14700,6 +14700,47 @@ var normalizePdfPageMeasurement = (measured, scaleFactor, zoomFactor) => {
14700
14700
  if (Number.isFinite(scaleFactor) && scaleFactor > 0) return measured / scaleFactor * require_constants.PDF_TO_CSS_UNITS;
14701
14701
  return zoomFactor > 0 ? measured / zoomFactor : measured;
14702
14702
  };
14703
+ var resolveV2WidestPageWidth = (snapshot) => {
14704
+ if (!snapshot || typeof snapshot !== "object") return 0;
14705
+ const published = snapshot.widestPageWidthPx;
14706
+ if (typeof published === "number" && Number.isFinite(published)) return published;
14707
+ let widestPage = 0;
14708
+ const pages = snapshot.pages;
14709
+ if (Array.isArray(pages)) for (const page of pages) {
14710
+ const width = page?.base?.widthPx;
14711
+ if (typeof width === "number" && Number.isFinite(width) && width > widestPage) widestPage = width;
14712
+ }
14713
+ return widestPage;
14714
+ };
14715
+ var resolveEditorPageWidth = (editor) => {
14716
+ if (!editor) return null;
14717
+ let widestPage = 0;
14718
+ try {
14719
+ widestPage = resolveV2WidestPageWidth(editor.pageMetrics?.getSnapshot?.());
14720
+ } catch {
14721
+ widestPage = 0;
14722
+ }
14723
+ if (widestPage > 0) return widestPage;
14724
+ try {
14725
+ const pages = editor.getPages?.();
14726
+ if (Array.isArray(pages)) for (const page of pages) {
14727
+ const width = page?.size?.w;
14728
+ if (typeof width === "number" && Number.isFinite(width) && width > widestPage) widestPage = width;
14729
+ }
14730
+ } catch {
14731
+ widestPage = 0;
14732
+ }
14733
+ if (widestPage > 0) return widestPage;
14734
+ let pageStyles = null;
14735
+ try {
14736
+ pageStyles = editor.getPageStyles?.() ?? null;
14737
+ } catch {
14738
+ pageStyles = null;
14739
+ }
14740
+ const pageWidthInches = pageStyles?.pageSize?.width;
14741
+ if (typeof pageWidthInches === "number" && Number.isFinite(pageWidthInches) && pageWidthInches > 0) return pageWidthInches * CSS_PX_PER_INCH;
14742
+ return null;
14743
+ };
14703
14744
  /**
14704
14745
  * Viewport fit tracking. Maintains pure viewport metrics (available width,
14705
14746
  * document base width, fit zoom), stores them for `getViewportMetrics()`,
@@ -14724,29 +14765,6 @@ var normalizePdfPageMeasurement = (measured, scaleFactor, zoomFactor) => {
14724
14765
  * unmount hook).
14725
14766
  */
14726
14767
  function useViewportFit({ getSuperdoc, superdocContainerWidth, isReady, activeZoom, zoomMode, viewportMetrics, showCommentsSidebar, rightSidebarRef, superdocRoot, documents }) {
14727
- const resolveEditorPageWidth = (editor) => {
14728
- if (!editor) return null;
14729
- let widestPage = 0;
14730
- try {
14731
- const pages = editor.getPages?.();
14732
- if (Array.isArray(pages)) for (const page of pages) {
14733
- const width = page?.size?.w;
14734
- if (typeof width === "number" && Number.isFinite(width) && width > widestPage) widestPage = width;
14735
- }
14736
- } catch {
14737
- widestPage = 0;
14738
- }
14739
- if (widestPage > 0) return widestPage;
14740
- let pageStyles = null;
14741
- try {
14742
- pageStyles = editor.getPageStyles?.() ?? null;
14743
- } catch {
14744
- pageStyles = null;
14745
- }
14746
- const pageWidthInches = pageStyles?.pageSize?.width;
14747
- if (typeof pageWidthInches === "number" && Number.isFinite(pageWidthInches) && pageWidthInches > 0) return pageWidthInches * CSS_PX_PER_INCH;
14748
- return null;
14749
- };
14750
14768
  const resolvePdfPageWidth = () => {
14751
14769
  if (!(documents?.value ?? []).some((doc) => doc?.type === "application/pdf")) return null;
14752
14770
  const root = superdocRoot.value;
@@ -45442,7 +45460,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
45442
45460
  this.config.colors = shuffleArray(this.config.colors);
45443
45461
  this.userColorMap = /* @__PURE__ */ new Map();
45444
45462
  this.colorIndex = 0;
45445
- this.version = "2.13.0-next.10";
45463
+ this.version = "2.13.0-next.11";
45446
45464
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45447
45465
  this.superdocId = config.superdocId || require_uuid.v4();
45448
45466
  this.colors = this.config.colors ?? [];
@@ -47296,6 +47314,13 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
47296
47314
  }
47297
47315
  if (this.superdocStore.zoomMode === mode) return;
47298
47316
  this.superdocStore.zoomMode = mode;
47317
+ if (mode === "fit-width") {
47318
+ const metrics = this.superdocStore.viewportMetrics;
47319
+ if (metrics) {
47320
+ const target = computeAppliedFitZoom(metrics.availableWidth, metrics.documentWidth, resolveFitWidthOptions(this.config.zoom?.fitWidth));
47321
+ if (target !== null) this.superdocStore.activeZoom = target;
47322
+ }
47323
+ }
47299
47324
  this.emit("zoomChange", {
47300
47325
  zoom: this.getZoom(),
47301
47326
  mode
@@ -47734,10 +47759,6 @@ var COLORS_TO_VARS = {
47734
47759
  border: "--sd-ui-border"
47735
47760
  };
47736
47761
  var themeCounter = 0;
47737
- /**
47738
- * Generate the className and CSS string from a theme config.
47739
- * Shared core used by both createTheme and buildTheme.
47740
- */
47741
47762
  function generateTheme(config) {
47742
47763
  const { name, font, radius, shadow, colors, vars } = config;
47743
47764
  const className = `sd-theme-${(name ? name.replace(/[^a-zA-Z0-9-_]/g, "-") : null) || `custom-${++themeCounter}`}`;
@@ -47803,8 +47824,8 @@ function createTheme(config) {
47803
47824
  }
47804
47825
  /**
47805
47826
  * Build a SuperDoc theme and return both the class name and raw CSS.
47806
- * Pure function — does NOT inject styles into the DOM. Use this for SSR
47807
- * or when you need to control style injection yourself (e.g., CSP nonce).
47827
+ * This function does not access the DOM. Use it for server rendering or when
47828
+ * your application controls style injection, such as with a CSP nonce.
47808
47829
  *
47809
47830
  * @example
47810
47831
  * ```ts
@@ -3,7 +3,7 @@ import { t as blank_default } from "./chunks/blank-docx-DzQccOlW.es.js";
3
3
  import { t as import_eventemitter3 } from "./chunks/eventemitter3-DEIiXiH2.es.js";
4
4
  import { t as v4 } from "./chunks/uuid-H0Xcmmhy.es.js";
5
5
  import { a as init_dist$1, i as global, n as init_dist$2, o as Buffer, r as process$1, s as init_dist, t as require_jszip_min } from "./chunks/jszip-BzJ3CyxR.es.js";
6
- import { a as DOM_CLASS_NAMES, i as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-u1giSvlm.es.js";
6
+ import { a as DOM_CLASS_NAMES, i as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-XWtQHPGP.es.js";
7
7
  import { t as _plugin_vue_export_helper_default } from "./chunks/_plugin-vue_export-helper-BOaGB7Aw.es.js";
8
8
  import { t as PDF_TO_CSS_UNITS } from "./chunks/constants-B6VBlmKp.es.js";
9
9
  import * as Vue from "vue";
@@ -315,7 +315,7 @@ var shuffleArray = (array) => {
315
315
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
316
316
  function getSuperdocVersion() {
317
317
  try {
318
- return "2.13.0-next.10";
318
+ return "2.13.0-next.11";
319
319
  } catch {
320
320
  return "unknown";
321
321
  }
@@ -14691,6 +14691,47 @@ var normalizePdfPageMeasurement = (measured, scaleFactor, zoomFactor) => {
14691
14691
  if (Number.isFinite(scaleFactor) && scaleFactor > 0) return measured / scaleFactor * PDF_TO_CSS_UNITS;
14692
14692
  return zoomFactor > 0 ? measured / zoomFactor : measured;
14693
14693
  };
14694
+ var resolveV2WidestPageWidth = (snapshot) => {
14695
+ if (!snapshot || typeof snapshot !== "object") return 0;
14696
+ const published = snapshot.widestPageWidthPx;
14697
+ if (typeof published === "number" && Number.isFinite(published)) return published;
14698
+ let widestPage = 0;
14699
+ const pages = snapshot.pages;
14700
+ if (Array.isArray(pages)) for (const page of pages) {
14701
+ const width = page?.base?.widthPx;
14702
+ if (typeof width === "number" && Number.isFinite(width) && width > widestPage) widestPage = width;
14703
+ }
14704
+ return widestPage;
14705
+ };
14706
+ var resolveEditorPageWidth = (editor) => {
14707
+ if (!editor) return null;
14708
+ let widestPage = 0;
14709
+ try {
14710
+ widestPage = resolveV2WidestPageWidth(editor.pageMetrics?.getSnapshot?.());
14711
+ } catch {
14712
+ widestPage = 0;
14713
+ }
14714
+ if (widestPage > 0) return widestPage;
14715
+ try {
14716
+ const pages = editor.getPages?.();
14717
+ if (Array.isArray(pages)) for (const page of pages) {
14718
+ const width = page?.size?.w;
14719
+ if (typeof width === "number" && Number.isFinite(width) && width > widestPage) widestPage = width;
14720
+ }
14721
+ } catch {
14722
+ widestPage = 0;
14723
+ }
14724
+ if (widestPage > 0) return widestPage;
14725
+ let pageStyles = null;
14726
+ try {
14727
+ pageStyles = editor.getPageStyles?.() ?? null;
14728
+ } catch {
14729
+ pageStyles = null;
14730
+ }
14731
+ const pageWidthInches = pageStyles?.pageSize?.width;
14732
+ if (typeof pageWidthInches === "number" && Number.isFinite(pageWidthInches) && pageWidthInches > 0) return pageWidthInches * CSS_PX_PER_INCH;
14733
+ return null;
14734
+ };
14694
14735
  /**
14695
14736
  * Viewport fit tracking. Maintains pure viewport metrics (available width,
14696
14737
  * document base width, fit zoom), stores them for `getViewportMetrics()`,
@@ -14715,29 +14756,6 @@ var normalizePdfPageMeasurement = (measured, scaleFactor, zoomFactor) => {
14715
14756
  * unmount hook).
14716
14757
  */
14717
14758
  function useViewportFit({ getSuperdoc, superdocContainerWidth, isReady, activeZoom, zoomMode, viewportMetrics, showCommentsSidebar, rightSidebarRef, superdocRoot, documents }) {
14718
- const resolveEditorPageWidth = (editor) => {
14719
- if (!editor) return null;
14720
- let widestPage = 0;
14721
- try {
14722
- const pages = editor.getPages?.();
14723
- if (Array.isArray(pages)) for (const page of pages) {
14724
- const width = page?.size?.w;
14725
- if (typeof width === "number" && Number.isFinite(width) && width > widestPage) widestPage = width;
14726
- }
14727
- } catch {
14728
- widestPage = 0;
14729
- }
14730
- if (widestPage > 0) return widestPage;
14731
- let pageStyles = null;
14732
- try {
14733
- pageStyles = editor.getPageStyles?.() ?? null;
14734
- } catch {
14735
- pageStyles = null;
14736
- }
14737
- const pageWidthInches = pageStyles?.pageSize?.width;
14738
- if (typeof pageWidthInches === "number" && Number.isFinite(pageWidthInches) && pageWidthInches > 0) return pageWidthInches * CSS_PX_PER_INCH;
14739
- return null;
14740
- };
14741
14759
  const resolvePdfPageWidth = () => {
14742
14760
  if (!(documents?.value ?? []).some((doc) => doc?.type === "application/pdf")) return null;
14743
14761
  const root = superdocRoot.value;
@@ -45373,7 +45391,7 @@ var SuperDoc = class extends import_eventemitter3.default {
45373
45391
  this.config.colors = shuffleArray(this.config.colors);
45374
45392
  this.userColorMap = /* @__PURE__ */ new Map();
45375
45393
  this.colorIndex = 0;
45376
- this.version = "2.13.0-next.10";
45394
+ this.version = "2.13.0-next.11";
45377
45395
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45378
45396
  this.superdocId = config.superdocId || v4();
45379
45397
  this.colors = this.config.colors ?? [];
@@ -47227,6 +47245,13 @@ var SuperDoc = class extends import_eventemitter3.default {
47227
47245
  }
47228
47246
  if (this.superdocStore.zoomMode === mode) return;
47229
47247
  this.superdocStore.zoomMode = mode;
47248
+ if (mode === "fit-width") {
47249
+ const metrics = this.superdocStore.viewportMetrics;
47250
+ if (metrics) {
47251
+ const target = computeAppliedFitZoom(metrics.availableWidth, metrics.documentWidth, resolveFitWidthOptions(this.config.zoom?.fitWidth));
47252
+ if (target !== null) this.superdocStore.activeZoom = target;
47253
+ }
47254
+ }
47230
47255
  this.emit("zoomChange", {
47231
47256
  zoom: this.getZoom(),
47232
47257
  mode
@@ -47665,10 +47690,6 @@ var COLORS_TO_VARS = {
47665
47690
  border: "--sd-ui-border"
47666
47691
  };
47667
47692
  var themeCounter = 0;
47668
- /**
47669
- * Generate the className and CSS string from a theme config.
47670
- * Shared core used by both createTheme and buildTheme.
47671
- */
47672
47693
  function generateTheme(config) {
47673
47694
  const { name, font, radius, shadow, colors, vars } = config;
47674
47695
  const className = `sd-theme-${(name ? name.replace(/[^a-zA-Z0-9-_]/g, "-") : null) || `custom-${++themeCounter}`}`;
@@ -47734,8 +47755,8 @@ function createTheme(config) {
47734
47755
  }
47735
47756
  /**
47736
47757
  * Build a SuperDoc theme and return both the class name and raw CSS.
47737
- * Pure function — does NOT inject styles into the DOM. Use this for SSR
47738
- * or when you need to control style injection yourself (e.g., CSP nonce).
47758
+ * This function does not access the DOM. Use it for server rendering or when
47759
+ * your application controls style injection, such as with a CSP nonce.
47739
47760
  *
47740
47761
  * @example
47741
47762
  * ```ts