superdoc 2.12.0-next.2 → 2.12.0-next.4

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.
@@ -19,7 +19,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
19
19
  var PRIVATE_ENGINE_INFO = (0, _superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
20
20
  var ENGINE_INFO = Object.freeze({
21
21
  ...PRIVATE_ENGINE_INFO,
22
- superdocVersion: "2.12.0-next.2",
22
+ superdocVersion: "2.12.0-next.4",
23
23
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
24
24
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
25
25
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -18,7 +18,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
18
18
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
19
19
  var ENGINE_INFO = Object.freeze({
20
20
  ...PRIVATE_ENGINE_INFO,
21
- superdocVersion: "2.12.0-next.2",
21
+ superdocVersion: "2.12.0-next.4",
22
22
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
23
23
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
24
24
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
package/dist/superdoc.cjs CHANGED
@@ -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.12.0-next.2";
319
+ return "2.12.0-next.4";
320
320
  } catch {
321
321
  return "unknown";
322
322
  }
@@ -16137,6 +16137,8 @@ function useCommentSmallScreen({ commentsModuleConfig, superdocRoot, layers }) {
16137
16137
  const isCompactCommentsMode = (0, vue.ref)(false);
16138
16138
  let commentsContainerResizeObserver = null;
16139
16139
  let compactMeasurementTarget = null;
16140
+ let documentWidthResizeObserver = null;
16141
+ let documentWidthTargets = [];
16140
16142
  const isValidMeasurementTarget = (element) => {
16141
16143
  if (!(element instanceof HTMLElement)) return false;
16142
16144
  if ((typeof window !== "undefined" ? window.getComputedStyle(element) : null)?.display === "contents") return false;
@@ -16190,7 +16192,25 @@ function useCommentSmallScreen({ commentsModuleConfig, superdocRoot, layers }) {
16190
16192
  if (Number.isFinite(rectWidth) && rectWidth > 0) return rectWidth;
16191
16193
  return 0;
16192
16194
  };
16195
+ const ensureDocumentWidthObserver = () => {
16196
+ const ResizeObserverClass = typeof window !== "undefined" ? window.ResizeObserver : void 0;
16197
+ if (typeof ResizeObserverClass === "undefined") return;
16198
+ const documentElement = superdocRoot.value?.querySelector?.(SUPERDOC_DOCUMENT_SELECTOR) ?? null;
16199
+ const nextTargets = [layers.value, documentElement].filter((el, index, all) => el instanceof HTMLElement && all.indexOf(el) === index);
16200
+ if (nextTargets.length === documentWidthTargets.length && nextTargets.every((el, index) => el === documentWidthTargets[index])) return;
16201
+ if (documentWidthResizeObserver) {
16202
+ documentWidthResizeObserver.disconnect();
16203
+ documentWidthResizeObserver = null;
16204
+ }
16205
+ documentWidthTargets = nextTargets;
16206
+ if (!nextTargets.length) return;
16207
+ documentWidthResizeObserver = new ResizeObserverClass(() => {
16208
+ recalculateCompactCommentsMode();
16209
+ });
16210
+ nextTargets.forEach((el) => documentWidthResizeObserver.observe(el));
16211
+ };
16193
16212
  const getMeasuredDocumentWidth = () => {
16213
+ ensureDocumentWidthObserver();
16194
16214
  const documentElement = superdocRoot.value?.querySelector?.(SUPERDOC_DOCUMENT_SELECTOR);
16195
16215
  const layersElement = layers.value;
16196
16216
  const measuredFromDocument = Number(documentElement?.clientWidth ?? documentElement?.getBoundingClientRect?.().width ?? 0);
@@ -16229,6 +16249,11 @@ function useCommentSmallScreen({ commentsModuleConfig, superdocRoot, layers }) {
16229
16249
  commentsContainerResizeObserver = null;
16230
16250
  }
16231
16251
  compactMeasurementTarget = null;
16252
+ if (documentWidthResizeObserver) {
16253
+ documentWidthResizeObserver.disconnect();
16254
+ documentWidthResizeObserver = null;
16255
+ }
16256
+ documentWidthTargets = [];
16232
16257
  });
16233
16258
  return {
16234
16259
  superdocContainerWidth,
@@ -45188,7 +45213,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
45188
45213
  this.config.colors = shuffleArray(this.config.colors);
45189
45214
  this.userColorMap = /* @__PURE__ */ new Map();
45190
45215
  this.colorIndex = 0;
45191
- this.version = "2.12.0-next.2";
45216
+ this.version = "2.12.0-next.4";
45192
45217
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45193
45218
  this.superdocId = config.superdocId || require_uuid.v4();
45194
45219
  this.colors = this.config.colors ?? [];
@@ -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.12.0-next.2";
318
+ return "2.12.0-next.4";
319
319
  } catch {
320
320
  return "unknown";
321
321
  }
@@ -16122,6 +16122,8 @@ function useCommentSmallScreen({ commentsModuleConfig, superdocRoot, layers }) {
16122
16122
  const isCompactCommentsMode = ref(false);
16123
16123
  let commentsContainerResizeObserver = null;
16124
16124
  let compactMeasurementTarget = null;
16125
+ let documentWidthResizeObserver = null;
16126
+ let documentWidthTargets = [];
16125
16127
  const isValidMeasurementTarget = (element) => {
16126
16128
  if (!(element instanceof HTMLElement)) return false;
16127
16129
  if ((typeof window !== "undefined" ? window.getComputedStyle(element) : null)?.display === "contents") return false;
@@ -16175,7 +16177,25 @@ function useCommentSmallScreen({ commentsModuleConfig, superdocRoot, layers }) {
16175
16177
  if (Number.isFinite(rectWidth) && rectWidth > 0) return rectWidth;
16176
16178
  return 0;
16177
16179
  };
16180
+ const ensureDocumentWidthObserver = () => {
16181
+ const ResizeObserverClass = typeof window !== "undefined" ? window.ResizeObserver : void 0;
16182
+ if (typeof ResizeObserverClass === "undefined") return;
16183
+ const documentElement = superdocRoot.value?.querySelector?.(SUPERDOC_DOCUMENT_SELECTOR) ?? null;
16184
+ const nextTargets = [layers.value, documentElement].filter((el, index, all) => el instanceof HTMLElement && all.indexOf(el) === index);
16185
+ if (nextTargets.length === documentWidthTargets.length && nextTargets.every((el, index) => el === documentWidthTargets[index])) return;
16186
+ if (documentWidthResizeObserver) {
16187
+ documentWidthResizeObserver.disconnect();
16188
+ documentWidthResizeObserver = null;
16189
+ }
16190
+ documentWidthTargets = nextTargets;
16191
+ if (!nextTargets.length) return;
16192
+ documentWidthResizeObserver = new ResizeObserverClass(() => {
16193
+ recalculateCompactCommentsMode();
16194
+ });
16195
+ nextTargets.forEach((el) => documentWidthResizeObserver.observe(el));
16196
+ };
16178
16197
  const getMeasuredDocumentWidth = () => {
16198
+ ensureDocumentWidthObserver();
16179
16199
  const documentElement = superdocRoot.value?.querySelector?.(SUPERDOC_DOCUMENT_SELECTOR);
16180
16200
  const layersElement = layers.value;
16181
16201
  const measuredFromDocument = Number(documentElement?.clientWidth ?? documentElement?.getBoundingClientRect?.().width ?? 0);
@@ -16214,6 +16234,11 @@ function useCommentSmallScreen({ commentsModuleConfig, superdocRoot, layers }) {
16214
16234
  commentsContainerResizeObserver = null;
16215
16235
  }
16216
16236
  compactMeasurementTarget = null;
16237
+ if (documentWidthResizeObserver) {
16238
+ documentWidthResizeObserver.disconnect();
16239
+ documentWidthResizeObserver = null;
16240
+ }
16241
+ documentWidthTargets = [];
16217
16242
  });
16218
16243
  return {
16219
16244
  superdocContainerWidth,
@@ -45119,7 +45144,7 @@ var SuperDoc = class extends import_eventemitter3.default {
45119
45144
  this.config.colors = shuffleArray(this.config.colors);
45120
45145
  this.userColorMap = /* @__PURE__ */ new Map();
45121
45146
  this.colorIndex = 0;
45122
- this.version = "2.12.0-next.2";
45147
+ this.version = "2.12.0-next.4";
45123
45148
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45124
45149
  this.superdocId = config.superdocId || v4();
45125
45150
  this.colors = this.config.colors ?? [];