superdoc 2.13.0-next.1 → 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/chunks/{create-super-doc-ui-BWWWNPP8.cjs → create-super-doc-ui-DNfQTF2k.cjs} +66 -6
- package/dist/chunks/{create-super-doc-ui-FnwgTkUv.es.js → create-super-doc-ui-XWtQHPGP.es.js} +66 -6
- package/dist/collaboration-upgrade-engine.cjs +1 -1
- package/dist/collaboration-upgrade-engine.es.js +1 -1
- package/dist/document-api/src/blocks/blocks.d.ts +3 -1
- package/dist/document-api/src/blocks/find-text.d.ts +3 -0
- package/dist/document-api/src/content-controls/content-controls.types.d.ts +1 -1
- package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
- package/dist/document-api/src/contract/operation-definitions.d.ts +11 -1
- package/dist/document-api/src/contract/operation-registry.d.ts +7 -2
- package/dist/document-api/src/index.d.ts +7 -6
- package/dist/document-api/src/invoke/invoke.d.ts +2 -1
- package/dist/document-api/src/types/blocks.types.d.ts +38 -0
- package/dist/document-api/src/types/mutation-plan.types.d.ts +28 -4
- package/dist/document-api/src/types/table-operations.types.d.ts +2 -0
- package/dist/layout-engine/dom-contract/src/data-attrs.d.ts +3 -0
- package/dist/layout-engine/painters/dom/src/page-content.d.ts +3 -2
- package/dist/layout-engine/painters/dom/src/renderer.d.ts +1 -0
- package/dist/public/collaboration-worker.cjs +9 -0
- package/dist/public/collaboration-worker.es.js +8 -0
- package/dist/public/ui-react.cjs +1 -1
- package/dist/public/ui-react.es.js +1 -1
- package/dist/public/ui-vue.cjs +1 -1
- package/dist/public/ui-vue.es.js +1 -1
- package/dist/public/ui.cjs +1 -1
- package/dist/public/ui.es.js +1 -1
- package/dist/style.css +26 -26
- package/dist/style.layered.css +26 -26
- package/dist/superdoc/src/composables/use-viewport-fit.d.ts +1 -0
- package/dist/superdoc/src/core/collaboration/collaboration-exception.d.ts +2 -0
- package/dist/superdoc/src/core/collaboration/resolve-v2-collaboration-target.d.ts +16 -5
- package/dist/superdoc/src/core/theme/create-theme.d.ts +32 -20
- package/dist/superdoc/src/core/types/index.d.ts +59 -71
- package/dist/superdoc/src/public/collaboration-worker.d.cts +18 -0
- package/dist/superdoc/src/public/collaboration-worker.d.ts +48 -0
- package/dist/superdoc/src/public/export-types.d.ts +23 -0
- package/dist/superdoc/src/public/index.d.cts +12 -0
- package/dist/superdoc/src/public/index.d.ts +3 -0
- package/dist/superdoc/src/public/ui/types.d.ts +18 -9
- package/dist/superdoc.cjs +384 -267
- package/dist/superdoc.es.js +384 -267
- package/dist-cdn/style.layered.css +1 -1
- package/dist-cdn/superdoc.min.css +1 -1
- package/dist-cdn/superdoc.min.js +37 -37
- package/package.json +13 -2
package/dist/superdoc.es.js
CHANGED
|
@@ -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-
|
|
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.
|
|
318
|
+
return "2.13.0-next.11";
|
|
319
319
|
} catch {
|
|
320
320
|
return "unknown";
|
|
321
321
|
}
|
|
@@ -5310,6 +5310,274 @@ function storeToRefs(store) {
|
|
|
5310
5310
|
return refs;
|
|
5311
5311
|
}
|
|
5312
5312
|
//#endregion
|
|
5313
|
+
//#region src/core/collaboration/resolve-v2-collaboration-target.ts
|
|
5314
|
+
/** Select the public spelling before validation; do not merge settings from different rooms. */
|
|
5315
|
+
function readCollaborationConfig(input) {
|
|
5316
|
+
return input.collaboration !== void 0 ? input.collaboration : input.v2Collaboration;
|
|
5317
|
+
}
|
|
5318
|
+
/**
|
|
5319
|
+
* Redact a connection URL for safe inclusion in diagnostics and artifacts.
|
|
5320
|
+
*
|
|
5321
|
+
* Strips the query string, fragment, and any embedded credentials (userinfo)
|
|
5322
|
+
* because those commonly carry auth tokens. Falls back to a coarse string scrub
|
|
5323
|
+
* when the value is not a parseable absolute URL so a malformed value with an
|
|
5324
|
+
* inline `?token=...` still cannot leak.
|
|
5325
|
+
*/
|
|
5326
|
+
function redactCollaborationUrl(url) {
|
|
5327
|
+
if (typeof url !== "string" || url.length === 0) return "<none>";
|
|
5328
|
+
try {
|
|
5329
|
+
const parsed = new URL(url);
|
|
5330
|
+
parsed.search = "";
|
|
5331
|
+
parsed.hash = "";
|
|
5332
|
+
parsed.username = "";
|
|
5333
|
+
parsed.password = "";
|
|
5334
|
+
const redactedQuery = url.includes("?") ? "?<redacted>" : "";
|
|
5335
|
+
return `${parsed.toString().replace(/\?$/, "")}${redactedQuery}`;
|
|
5336
|
+
} catch {
|
|
5337
|
+
const withoutCredentials = url.replace(/\/\/[^/@]+@/, "//");
|
|
5338
|
+
const cut = withoutCredentials.search(/[?#]/);
|
|
5339
|
+
if (cut === -1) return withoutCredentials;
|
|
5340
|
+
return `${withoutCredentials.slice(0, cut)}?<redacted>`;
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
function normalizeNonEmptyString(value) {
|
|
5344
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
5345
|
+
}
|
|
5346
|
+
function normalizeWebsocketUrl(value) {
|
|
5347
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
5348
|
+
try {
|
|
5349
|
+
const parsed = new URL(value);
|
|
5350
|
+
return parsed.protocol === "ws:" || parsed.protocol === "wss:" ? value : null;
|
|
5351
|
+
} catch {
|
|
5352
|
+
return null;
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
function normalizeHttpUrl(value, baseUrl) {
|
|
5356
|
+
if (typeof value !== "string") return null;
|
|
5357
|
+
const normalized = value.trim();
|
|
5358
|
+
if (normalized.length === 0) return null;
|
|
5359
|
+
try {
|
|
5360
|
+
const parsed = new URL(normalized);
|
|
5361
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? normalized : null;
|
|
5362
|
+
} catch {
|
|
5363
|
+
if (typeof baseUrl !== "string" || baseUrl.trim().length === 0) return null;
|
|
5364
|
+
try {
|
|
5365
|
+
const parsed = new URL(normalized, baseUrl);
|
|
5366
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.href : null;
|
|
5367
|
+
} catch {
|
|
5368
|
+
return null;
|
|
5369
|
+
}
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
function normalizeParams(value) {
|
|
5373
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
5374
|
+
const params = {};
|
|
5375
|
+
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string") params[key] = raw;
|
|
5376
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
5377
|
+
}
|
|
5378
|
+
function normalizeRoomMode(value) {
|
|
5379
|
+
if (value === void 0) return "join";
|
|
5380
|
+
return value === "join" || value === "create" ? value : null;
|
|
5381
|
+
}
|
|
5382
|
+
function invalidRoomMode() {
|
|
5383
|
+
return {
|
|
5384
|
+
ok: false,
|
|
5385
|
+
reason: "invalid-room-mode",
|
|
5386
|
+
message: "SuperDoc v2 collaboration roomMode must be either \"join\" or \"create\"."
|
|
5387
|
+
};
|
|
5388
|
+
}
|
|
5389
|
+
/** Provider-family token recognized on a v2Collaboration config object. */
|
|
5390
|
+
function readProviderType(candidate) {
|
|
5391
|
+
const raw = candidate.providerType;
|
|
5392
|
+
return typeof raw === "string" && raw.length > 0 ? raw.toLowerCase() : null;
|
|
5393
|
+
}
|
|
5394
|
+
/**
|
|
5395
|
+
* Detect whether a legacy collaboration block names a provider family that the
|
|
5396
|
+
* shipped single-doc v2 runtime cannot drive. Returns the offending family name
|
|
5397
|
+
* (for diagnostics) or `null` when the block carries no recognizable family.
|
|
5398
|
+
*/
|
|
5399
|
+
function detectUnsupportedLegacyFamily(legacy) {
|
|
5400
|
+
if (!legacy || typeof legacy !== "object") return null;
|
|
5401
|
+
const providerType = typeof legacy.providerType === "string" ? legacy.providerType.toLowerCase() : "";
|
|
5402
|
+
if (providerType === "hocuspocus") return "hocuspocus";
|
|
5403
|
+
if (providerType === "liveblocks") return "liveblocks";
|
|
5404
|
+
if (providerType === "superdoc") return "superdoc";
|
|
5405
|
+
if (legacy.ydoc != null || legacy.provider != null) return "external-ydoc-provider";
|
|
5406
|
+
return null;
|
|
5407
|
+
}
|
|
5408
|
+
/** Resolve a websocket-backed family (y-websocket / Hocuspocus). */
|
|
5409
|
+
function resolveWebsocketFamily(family, candidate) {
|
|
5410
|
+
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
5411
|
+
if (!documentId) return {
|
|
5412
|
+
ok: false,
|
|
5413
|
+
reason: "invalid-document-id",
|
|
5414
|
+
message: `SuperDoc v2 collaboration requires a non-empty collaboration.documentId for the "${family}" provider.`
|
|
5415
|
+
};
|
|
5416
|
+
const rawUrl = candidate.url ?? candidate.serverUrl;
|
|
5417
|
+
const serverUrl = normalizeWebsocketUrl(rawUrl);
|
|
5418
|
+
if (!serverUrl) return {
|
|
5419
|
+
ok: false,
|
|
5420
|
+
reason: "invalid-server-url",
|
|
5421
|
+
message: `SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${family}" provider (received: ${redactCollaborationUrl(rawUrl)}).`
|
|
5422
|
+
};
|
|
5423
|
+
const params = normalizeParams(candidate.params);
|
|
5424
|
+
const token = family === "hocuspocus" && typeof candidate.token === "function" ? candidate.token : family === "hocuspocus" ? normalizeNonEmptyString(candidate.token) : null;
|
|
5425
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5426
|
+
if (!roomMode) return invalidRoomMode();
|
|
5427
|
+
return {
|
|
5428
|
+
ok: true,
|
|
5429
|
+
target: {
|
|
5430
|
+
providerFamily: family,
|
|
5431
|
+
documentId,
|
|
5432
|
+
roomMode,
|
|
5433
|
+
serverUrl,
|
|
5434
|
+
...params ? { params } : {},
|
|
5435
|
+
...token ? { token } : {}
|
|
5436
|
+
}
|
|
5437
|
+
};
|
|
5438
|
+
}
|
|
5439
|
+
function resolveProviderExtension(candidate) {
|
|
5440
|
+
const adapterId = normalizeNonEmptyString(candidate.adapterId);
|
|
5441
|
+
if (!adapterId) return {
|
|
5442
|
+
ok: false,
|
|
5443
|
+
reason: "invalid-adapter-id",
|
|
5444
|
+
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.adapterId."
|
|
5445
|
+
};
|
|
5446
|
+
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
5447
|
+
if (!documentId) return {
|
|
5448
|
+
ok: false,
|
|
5449
|
+
reason: "invalid-document-id",
|
|
5450
|
+
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.documentId."
|
|
5451
|
+
};
|
|
5452
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5453
|
+
if (!roomMode) return invalidRoomMode();
|
|
5454
|
+
if (Object.prototype.hasOwnProperty.call(candidate, "providerOptions")) try {
|
|
5455
|
+
structuredClone(candidate.providerOptions);
|
|
5456
|
+
} catch {
|
|
5457
|
+
return {
|
|
5458
|
+
ok: false,
|
|
5459
|
+
reason: "invalid-provider-options",
|
|
5460
|
+
message: "SuperDoc v2 provider extension options must be structured-clone-safe."
|
|
5461
|
+
};
|
|
5462
|
+
}
|
|
5463
|
+
const token = typeof candidate.token === "function" ? candidate.token : normalizeNonEmptyString(candidate.token);
|
|
5464
|
+
return {
|
|
5465
|
+
ok: true,
|
|
5466
|
+
target: {
|
|
5467
|
+
providerFamily: "extension",
|
|
5468
|
+
adapterId,
|
|
5469
|
+
documentId,
|
|
5470
|
+
roomMode,
|
|
5471
|
+
...Object.prototype.hasOwnProperty.call(candidate, "providerOptions") ? { providerOptions: candidate.providerOptions } : {},
|
|
5472
|
+
...token ? { token } : {}
|
|
5473
|
+
}
|
|
5474
|
+
};
|
|
5475
|
+
}
|
|
5476
|
+
/** Resolve the Liveblocks family (exactly one of publicApiKey / authEndpoint). */
|
|
5477
|
+
function resolveLiveblocksFamily(candidate, authEndpointBaseUrl) {
|
|
5478
|
+
const documentId = normalizeNonEmptyString(candidate.documentId ?? candidate.roomId);
|
|
5479
|
+
if (!documentId) return {
|
|
5480
|
+
ok: false,
|
|
5481
|
+
reason: "invalid-document-id",
|
|
5482
|
+
message: "SuperDoc v2 collaboration requires a non-empty collaboration.documentId (or roomId) for the \"liveblocks\" provider."
|
|
5483
|
+
};
|
|
5484
|
+
const publicApiKey = normalizeNonEmptyString(candidate.publicApiKey);
|
|
5485
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5486
|
+
if (!roomMode) return invalidRoomMode();
|
|
5487
|
+
const authEndpointRaw = candidate.authEndpoint;
|
|
5488
|
+
const hasAuthEndpoint = typeof authEndpointRaw === "string" && authEndpointRaw.length > 0;
|
|
5489
|
+
if (!publicApiKey && !hasAuthEndpoint) return {
|
|
5490
|
+
ok: false,
|
|
5491
|
+
reason: "missing-auth",
|
|
5492
|
+
message: "SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."
|
|
5493
|
+
};
|
|
5494
|
+
if (publicApiKey && hasAuthEndpoint) return {
|
|
5495
|
+
ok: false,
|
|
5496
|
+
reason: "mixed-auth",
|
|
5497
|
+
message: "SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."
|
|
5498
|
+
};
|
|
5499
|
+
if (publicApiKey) return {
|
|
5500
|
+
ok: true,
|
|
5501
|
+
target: {
|
|
5502
|
+
providerFamily: "liveblocks",
|
|
5503
|
+
documentId,
|
|
5504
|
+
roomMode,
|
|
5505
|
+
publicApiKey
|
|
5506
|
+
}
|
|
5507
|
+
};
|
|
5508
|
+
const authEndpoint = normalizeHttpUrl(authEndpointRaw, authEndpointBaseUrl);
|
|
5509
|
+
if (!authEndpoint) return {
|
|
5510
|
+
ok: false,
|
|
5511
|
+
reason: "invalid-auth-endpoint",
|
|
5512
|
+
message: "SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."
|
|
5513
|
+
};
|
|
5514
|
+
return {
|
|
5515
|
+
ok: true,
|
|
5516
|
+
target: {
|
|
5517
|
+
providerFamily: "liveblocks",
|
|
5518
|
+
documentId,
|
|
5519
|
+
roomMode,
|
|
5520
|
+
authEndpoint
|
|
5521
|
+
}
|
|
5522
|
+
};
|
|
5523
|
+
}
|
|
5524
|
+
/**
|
|
5525
|
+
* Resolve a constructor-time or upgrade-time collaboration request into a
|
|
5526
|
+
* supported v2 room target, or a stable redacted diagnostic.
|
|
5527
|
+
*/
|
|
5528
|
+
function resolveV2CollaborationTarget(input) {
|
|
5529
|
+
const { legacyCollaboration, documentType, documentCount, authEndpointBaseUrl } = input;
|
|
5530
|
+
const v2Collaboration = readCollaborationConfig(input);
|
|
5531
|
+
if (typeof documentCount === "number" && documentCount > 1) return {
|
|
5532
|
+
ok: false,
|
|
5533
|
+
reason: "unsupported-multi-document",
|
|
5534
|
+
message: `SuperDoc v2 collaboration supports exactly one document per room; received ${documentCount}.`
|
|
5535
|
+
};
|
|
5536
|
+
if (documentType != null && documentType !== "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return {
|
|
5537
|
+
ok: false,
|
|
5538
|
+
reason: "unsupported-document-type",
|
|
5539
|
+
message: "SuperDoc v2 collaboration supports DOCX documents only."
|
|
5540
|
+
};
|
|
5541
|
+
if (!(v2Collaboration != null && typeof v2Collaboration === "object")) {
|
|
5542
|
+
const family = detectUnsupportedLegacyFamily(legacyCollaboration);
|
|
5543
|
+
if (family) {
|
|
5544
|
+
const reason = family === "external-ydoc-provider" ? "unsupported-legacy-provider" : "unsupported-provider-family";
|
|
5545
|
+
const redactedUrl = redactCollaborationUrl(legacyCollaboration?.url);
|
|
5546
|
+
return {
|
|
5547
|
+
ok: false,
|
|
5548
|
+
reason,
|
|
5549
|
+
message: family === "external-ydoc-provider" ? "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. Provide a collaboration target (e.g. { providerType, documentId, url }) instead." : `SuperDoc v2 collaboration does not accept "${family}" through the legacy modules.collaboration block (server: ${redactedUrl}). Configure it as a document.collaboration target ({ providerType: "${family}", documentId, ... }) instead.`
|
|
5550
|
+
};
|
|
5551
|
+
}
|
|
5552
|
+
return {
|
|
5553
|
+
ok: false,
|
|
5554
|
+
reason: "missing-target",
|
|
5555
|
+
message: "SuperDoc v2 collaboration requires a collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."
|
|
5556
|
+
};
|
|
5557
|
+
}
|
|
5558
|
+
const candidate = v2Collaboration;
|
|
5559
|
+
if (Object.prototype.hasOwnProperty.call(candidate, "createIfMissing")) return {
|
|
5560
|
+
ok: false,
|
|
5561
|
+
reason: "invalid-room-mode",
|
|
5562
|
+
message: "SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: \"create\" for creation or roomMode: \"join\" for normal opens."
|
|
5563
|
+
};
|
|
5564
|
+
if (candidate.ydoc != null || candidate.provider != null) return {
|
|
5565
|
+
ok: false,
|
|
5566
|
+
reason: "unsupported-legacy-provider",
|
|
5567
|
+
message: "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. v2 owns its provider; pass a collaboration target ({ providerType, documentId, serverUrl | publicApiKey | authEndpoint }) instead."
|
|
5568
|
+
};
|
|
5569
|
+
const providerType = readProviderType(candidate);
|
|
5570
|
+
if (providerType === null || providerType === "y-websocket") return resolveWebsocketFamily("y-websocket", candidate);
|
|
5571
|
+
if (providerType === "hocuspocus") return resolveWebsocketFamily("hocuspocus", candidate);
|
|
5572
|
+
if (providerType === "liveblocks") return resolveLiveblocksFamily(candidate, authEndpointBaseUrl);
|
|
5573
|
+
if (providerType === "extension") return resolveProviderExtension(candidate);
|
|
5574
|
+
return {
|
|
5575
|
+
ok: false,
|
|
5576
|
+
reason: "unsupported-provider-family",
|
|
5577
|
+
message: `SuperDoc v2 collaboration does not support the "${providerType}" provider family. Supported families are y-websocket, hocuspocus, liveblocks, and extension.`
|
|
5578
|
+
};
|
|
5579
|
+
}
|
|
5580
|
+
//#endregion
|
|
5313
5581
|
//#region src/core/helpers/file.js
|
|
5314
5582
|
/**
|
|
5315
5583
|
* @typedef {Object} UploadWrapper
|
|
@@ -5433,6 +5701,14 @@ var GENERIC_BINARY_MIME = "application/octet-stream";
|
|
|
5433
5701
|
* @returns {DocumentEntry|any} A normalized entry, or the original value when it is unsupported or unchanged
|
|
5434
5702
|
*/
|
|
5435
5703
|
var normalizeDocumentEntry = (entry) => {
|
|
5704
|
+
if (entry && typeof entry === "object" && Object.prototype.hasOwnProperty.call(entry, "collaboration")) {
|
|
5705
|
+
const source = { ...entry };
|
|
5706
|
+
delete source.collaboration;
|
|
5707
|
+
entry = {
|
|
5708
|
+
...source,
|
|
5709
|
+
v2Collaboration: readCollaborationConfig(entry)
|
|
5710
|
+
};
|
|
5711
|
+
}
|
|
5436
5712
|
if (isDocumentByteSource(entry)) return {
|
|
5437
5713
|
type: DOCX,
|
|
5438
5714
|
data: documentByteSourceToUint8Array(entry),
|
|
@@ -5454,6 +5730,7 @@ var normalizeDocumentEntry = (entry) => {
|
|
|
5454
5730
|
});
|
|
5455
5731
|
else if (hasGenericType && inferredType && typeof Blob === "function" && maybeFile instanceof Blob) data = new Blob([maybeFile], { type });
|
|
5456
5732
|
return {
|
|
5733
|
+
...entry.v2Collaboration !== void 0 ? { v2Collaboration: entry.v2Collaboration } : {},
|
|
5457
5734
|
type,
|
|
5458
5735
|
data,
|
|
5459
5736
|
name
|
|
@@ -14414,6 +14691,47 @@ var normalizePdfPageMeasurement = (measured, scaleFactor, zoomFactor) => {
|
|
|
14414
14691
|
if (Number.isFinite(scaleFactor) && scaleFactor > 0) return measured / scaleFactor * PDF_TO_CSS_UNITS;
|
|
14415
14692
|
return zoomFactor > 0 ? measured / zoomFactor : measured;
|
|
14416
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
|
+
};
|
|
14417
14735
|
/**
|
|
14418
14736
|
* Viewport fit tracking. Maintains pure viewport metrics (available width,
|
|
14419
14737
|
* document base width, fit zoom), stores them for `getViewportMetrics()`,
|
|
@@ -14438,29 +14756,6 @@ var normalizePdfPageMeasurement = (measured, scaleFactor, zoomFactor) => {
|
|
|
14438
14756
|
* unmount hook).
|
|
14439
14757
|
*/
|
|
14440
14758
|
function useViewportFit({ getSuperdoc, superdocContainerWidth, isReady, activeZoom, zoomMode, viewportMetrics, showCommentsSidebar, rightSidebarRef, superdocRoot, documents }) {
|
|
14441
|
-
const resolveEditorPageWidth = (editor) => {
|
|
14442
|
-
if (!editor) return null;
|
|
14443
|
-
let widestPage = 0;
|
|
14444
|
-
try {
|
|
14445
|
-
const pages = editor.getPages?.();
|
|
14446
|
-
if (Array.isArray(pages)) for (const page of pages) {
|
|
14447
|
-
const width = page?.size?.w;
|
|
14448
|
-
if (typeof width === "number" && Number.isFinite(width) && width > widestPage) widestPage = width;
|
|
14449
|
-
}
|
|
14450
|
-
} catch {
|
|
14451
|
-
widestPage = 0;
|
|
14452
|
-
}
|
|
14453
|
-
if (widestPage > 0) return widestPage;
|
|
14454
|
-
let pageStyles = null;
|
|
14455
|
-
try {
|
|
14456
|
-
pageStyles = editor.getPageStyles?.() ?? null;
|
|
14457
|
-
} catch {
|
|
14458
|
-
pageStyles = null;
|
|
14459
|
-
}
|
|
14460
|
-
const pageWidthInches = pageStyles?.pageSize?.width;
|
|
14461
|
-
if (typeof pageWidthInches === "number" && Number.isFinite(pageWidthInches) && pageWidthInches > 0) return pageWidthInches * CSS_PX_PER_INCH;
|
|
14462
|
-
return null;
|
|
14463
|
-
};
|
|
14464
14759
|
const resolvePdfPageWidth = () => {
|
|
14465
14760
|
if (!(documents?.value ?? []).some((doc) => doc?.type === "application/pdf")) return null;
|
|
14466
14761
|
const root = superdocRoot.value;
|
|
@@ -20440,228 +20735,31 @@ function unmarkRuntimeRoot(root) {
|
|
|
20440
20735
|
root.removeAttribute(RUNTIME_ROOT_ATTRIBUTE);
|
|
20441
20736
|
}
|
|
20442
20737
|
//#endregion
|
|
20443
|
-
//#region src/core/collaboration/
|
|
20444
|
-
|
|
20445
|
-
|
|
20446
|
-
|
|
20447
|
-
|
|
20448
|
-
|
|
20449
|
-
|
|
20450
|
-
|
|
20451
|
-
|
|
20452
|
-
|
|
20453
|
-
|
|
20454
|
-
|
|
20455
|
-
|
|
20456
|
-
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
return `${parsed.toString().replace(/\?$/, "")}${redactedQuery}`;
|
|
20462
|
-
} catch {
|
|
20463
|
-
const withoutCredentials = url.replace(/\/\/[^/@]+@/, "//");
|
|
20464
|
-
const cut = withoutCredentials.search(/[?#]/);
|
|
20465
|
-
if (cut === -1) return withoutCredentials;
|
|
20466
|
-
return `${withoutCredentials.slice(0, cut)}?<redacted>`;
|
|
20467
|
-
}
|
|
20468
|
-
}
|
|
20469
|
-
function normalizeNonEmptyString(value) {
|
|
20470
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
20471
|
-
}
|
|
20472
|
-
function normalizeWebsocketUrl(value) {
|
|
20473
|
-
if (typeof value !== "string" || value.length === 0) return null;
|
|
20474
|
-
try {
|
|
20475
|
-
const parsed = new URL(value);
|
|
20476
|
-
return parsed.protocol === "ws:" || parsed.protocol === "wss:" ? value : null;
|
|
20477
|
-
} catch {
|
|
20478
|
-
return null;
|
|
20479
|
-
}
|
|
20480
|
-
}
|
|
20481
|
-
function normalizeHttpUrl(value, baseUrl) {
|
|
20482
|
-
if (typeof value !== "string") return null;
|
|
20483
|
-
const normalized = value.trim();
|
|
20484
|
-
if (normalized.length === 0) return null;
|
|
20485
|
-
try {
|
|
20486
|
-
const parsed = new URL(normalized);
|
|
20487
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:" ? normalized : null;
|
|
20488
|
-
} catch {
|
|
20489
|
-
if (typeof baseUrl !== "string" || baseUrl.trim().length === 0) return null;
|
|
20490
|
-
try {
|
|
20491
|
-
const parsed = new URL(normalized, baseUrl);
|
|
20492
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.href : null;
|
|
20493
|
-
} catch {
|
|
20494
|
-
return null;
|
|
20495
|
-
}
|
|
20496
|
-
}
|
|
20497
|
-
}
|
|
20498
|
-
function normalizeParams(value) {
|
|
20499
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
20500
|
-
const params = {};
|
|
20501
|
-
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string") params[key] = raw;
|
|
20502
|
-
return Object.keys(params).length > 0 ? params : void 0;
|
|
20503
|
-
}
|
|
20504
|
-
function normalizeRoomMode(value) {
|
|
20505
|
-
if (value === void 0) return "join";
|
|
20506
|
-
return value === "join" || value === "create" ? value : null;
|
|
20507
|
-
}
|
|
20508
|
-
function invalidRoomMode() {
|
|
20509
|
-
return {
|
|
20510
|
-
ok: false,
|
|
20511
|
-
reason: "invalid-room-mode",
|
|
20512
|
-
message: "SuperDoc v2 collaboration roomMode must be either \"join\" or \"create\"."
|
|
20513
|
-
};
|
|
20514
|
-
}
|
|
20515
|
-
/** Provider-family token recognized on a v2Collaboration config object. */
|
|
20516
|
-
function readProviderType(candidate) {
|
|
20517
|
-
const raw = candidate.providerType;
|
|
20518
|
-
return typeof raw === "string" && raw.length > 0 ? raw.toLowerCase() : null;
|
|
20519
|
-
}
|
|
20520
|
-
/**
|
|
20521
|
-
* Detect whether a legacy collaboration block names a provider family that the
|
|
20522
|
-
* shipped single-doc v2 runtime cannot drive. Returns the offending family name
|
|
20523
|
-
* (for diagnostics) or `null` when the block carries no recognizable family.
|
|
20524
|
-
*/
|
|
20525
|
-
function detectUnsupportedLegacyFamily(legacy) {
|
|
20526
|
-
if (!legacy || typeof legacy !== "object") return null;
|
|
20527
|
-
const providerType = typeof legacy.providerType === "string" ? legacy.providerType.toLowerCase() : "";
|
|
20528
|
-
if (providerType === "hocuspocus") return "hocuspocus";
|
|
20529
|
-
if (providerType === "liveblocks") return "liveblocks";
|
|
20530
|
-
if (providerType === "superdoc") return "superdoc";
|
|
20531
|
-
if (legacy.ydoc != null || legacy.provider != null) return "external-ydoc-provider";
|
|
20532
|
-
return null;
|
|
20533
|
-
}
|
|
20534
|
-
/** Resolve a websocket-backed family (y-websocket / Hocuspocus). */
|
|
20535
|
-
function resolveWebsocketFamily(family, candidate) {
|
|
20536
|
-
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
20537
|
-
if (!documentId) return {
|
|
20538
|
-
ok: false,
|
|
20539
|
-
reason: "invalid-document-id",
|
|
20540
|
-
message: `SuperDoc v2 collaboration requires a non-empty v2Collaboration.documentId for the "${family}" provider.`
|
|
20541
|
-
};
|
|
20542
|
-
const rawUrl = candidate.url ?? candidate.serverUrl;
|
|
20543
|
-
const serverUrl = normalizeWebsocketUrl(rawUrl);
|
|
20544
|
-
if (!serverUrl) return {
|
|
20545
|
-
ok: false,
|
|
20546
|
-
reason: "invalid-server-url",
|
|
20547
|
-
message: `SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${family}" provider (received: ${redactCollaborationUrl(rawUrl)}).`
|
|
20548
|
-
};
|
|
20549
|
-
const params = normalizeParams(candidate.params);
|
|
20550
|
-
const token = family === "hocuspocus" ? normalizeNonEmptyString(candidate.token) : null;
|
|
20551
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20552
|
-
if (!roomMode) return invalidRoomMode();
|
|
20553
|
-
return {
|
|
20554
|
-
ok: true,
|
|
20555
|
-
target: {
|
|
20556
|
-
providerFamily: family,
|
|
20557
|
-
documentId,
|
|
20558
|
-
roomMode,
|
|
20559
|
-
serverUrl,
|
|
20560
|
-
...params ? { params } : {},
|
|
20561
|
-
...token ? { token } : {}
|
|
20562
|
-
}
|
|
20563
|
-
};
|
|
20564
|
-
}
|
|
20565
|
-
/** Resolve the Liveblocks family (exactly one of publicApiKey / authEndpoint). */
|
|
20566
|
-
function resolveLiveblocksFamily(candidate, authEndpointBaseUrl) {
|
|
20567
|
-
const documentId = normalizeNonEmptyString(candidate.documentId ?? candidate.roomId);
|
|
20568
|
-
if (!documentId) return {
|
|
20569
|
-
ok: false,
|
|
20570
|
-
reason: "invalid-document-id",
|
|
20571
|
-
message: "SuperDoc v2 collaboration requires a non-empty v2Collaboration.documentId (or roomId) for the \"liveblocks\" provider."
|
|
20572
|
-
};
|
|
20573
|
-
const publicApiKey = normalizeNonEmptyString(candidate.publicApiKey);
|
|
20574
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20575
|
-
if (!roomMode) return invalidRoomMode();
|
|
20576
|
-
const authEndpointRaw = candidate.authEndpoint;
|
|
20577
|
-
const hasAuthEndpoint = typeof authEndpointRaw === "string" && authEndpointRaw.length > 0;
|
|
20578
|
-
if (!publicApiKey && !hasAuthEndpoint) return {
|
|
20579
|
-
ok: false,
|
|
20580
|
-
reason: "missing-auth",
|
|
20581
|
-
message: "SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."
|
|
20582
|
-
};
|
|
20583
|
-
if (publicApiKey && hasAuthEndpoint) return {
|
|
20584
|
-
ok: false,
|
|
20585
|
-
reason: "mixed-auth",
|
|
20586
|
-
message: "SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."
|
|
20587
|
-
};
|
|
20588
|
-
if (publicApiKey) return {
|
|
20589
|
-
ok: true,
|
|
20590
|
-
target: {
|
|
20591
|
-
providerFamily: "liveblocks",
|
|
20592
|
-
documentId,
|
|
20593
|
-
roomMode,
|
|
20594
|
-
publicApiKey
|
|
20595
|
-
}
|
|
20596
|
-
};
|
|
20597
|
-
const authEndpoint = normalizeHttpUrl(authEndpointRaw, authEndpointBaseUrl);
|
|
20598
|
-
if (!authEndpoint) return {
|
|
20599
|
-
ok: false,
|
|
20600
|
-
reason: "invalid-auth-endpoint",
|
|
20601
|
-
message: "SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."
|
|
20602
|
-
};
|
|
20603
|
-
return {
|
|
20604
|
-
ok: true,
|
|
20605
|
-
target: {
|
|
20606
|
-
providerFamily: "liveblocks",
|
|
20607
|
-
documentId,
|
|
20608
|
-
roomMode,
|
|
20609
|
-
authEndpoint
|
|
20610
|
-
}
|
|
20611
|
-
};
|
|
20612
|
-
}
|
|
20613
|
-
/**
|
|
20614
|
-
* Resolve a constructor-time or upgrade-time collaboration request into a
|
|
20615
|
-
* supported v2 room target, or a stable redacted diagnostic.
|
|
20616
|
-
*/
|
|
20617
|
-
function resolveV2CollaborationTarget(input) {
|
|
20618
|
-
const { v2Collaboration, legacyCollaboration, documentType, documentCount, authEndpointBaseUrl } = input;
|
|
20619
|
-
if (typeof documentCount === "number" && documentCount > 1) return {
|
|
20620
|
-
ok: false,
|
|
20621
|
-
reason: "unsupported-multi-document",
|
|
20622
|
-
message: `SuperDoc v2 collaboration supports exactly one document per room; received ${documentCount}.`
|
|
20623
|
-
};
|
|
20624
|
-
if (documentType != null && documentType !== "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return {
|
|
20625
|
-
ok: false,
|
|
20626
|
-
reason: "unsupported-document-type",
|
|
20627
|
-
message: "SuperDoc v2 collaboration supports DOCX documents only."
|
|
20628
|
-
};
|
|
20629
|
-
if (!(v2Collaboration != null && typeof v2Collaboration === "object")) {
|
|
20630
|
-
const family = detectUnsupportedLegacyFamily(legacyCollaboration);
|
|
20631
|
-
if (family) {
|
|
20632
|
-
const reason = family === "external-ydoc-provider" ? "unsupported-legacy-provider" : "unsupported-provider-family";
|
|
20633
|
-
const redactedUrl = redactCollaborationUrl(legacyCollaboration?.url);
|
|
20634
|
-
return {
|
|
20635
|
-
ok: false,
|
|
20636
|
-
reason,
|
|
20637
|
-
message: family === "external-ydoc-provider" ? "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. Provide a v2Collaboration target (e.g. { providerType, documentId, url }) instead." : `SuperDoc v2 collaboration does not accept "${family}" through the legacy modules.collaboration block (server: ${redactedUrl}). Configure it as a v2Collaboration target ({ providerType: "${family}", documentId, ... }) instead.`
|
|
20638
|
-
};
|
|
20639
|
-
}
|
|
20640
|
-
return {
|
|
20641
|
-
ok: false,
|
|
20642
|
-
reason: "missing-target",
|
|
20643
|
-
message: "SuperDoc v2 collaboration requires a v2Collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."
|
|
20644
|
-
};
|
|
20738
|
+
//#region src/core/collaboration/collaboration-exception.ts
|
|
20739
|
+
function createCollaborationException(code, documentId) {
|
|
20740
|
+
let collaborationReason;
|
|
20741
|
+
let message;
|
|
20742
|
+
switch (code) {
|
|
20743
|
+
case "collaboration-access-denied":
|
|
20744
|
+
collaborationReason = "access-denied";
|
|
20745
|
+
message = "The collaboration server rejected access to this room.";
|
|
20746
|
+
break;
|
|
20747
|
+
case "collaboration-connection-failed":
|
|
20748
|
+
collaborationReason = "connection-failed";
|
|
20749
|
+
message = "The collaboration connection failed.";
|
|
20750
|
+
break;
|
|
20751
|
+
case "collaboration-sync-timeout":
|
|
20752
|
+
collaborationReason = "sync-timeout";
|
|
20753
|
+
message = "The collaboration room did not finish synchronizing in time.";
|
|
20754
|
+
break;
|
|
20755
|
+
default: return null;
|
|
20645
20756
|
}
|
|
20646
|
-
const candidate = v2Collaboration;
|
|
20647
|
-
if (Object.prototype.hasOwnProperty.call(candidate, "createIfMissing")) return {
|
|
20648
|
-
ok: false,
|
|
20649
|
-
reason: "invalid-room-mode",
|
|
20650
|
-
message: "SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: \"create\" for creation or roomMode: \"join\" for normal opens."
|
|
20651
|
-
};
|
|
20652
|
-
if (candidate.ydoc != null || candidate.provider != null) return {
|
|
20653
|
-
ok: false,
|
|
20654
|
-
reason: "unsupported-legacy-provider",
|
|
20655
|
-
message: "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. v2 owns its provider; pass a v2Collaboration target ({ providerType, documentId, url | publicApiKey | authEndpoint }) instead."
|
|
20656
|
-
};
|
|
20657
|
-
const providerType = readProviderType(candidate);
|
|
20658
|
-
if (providerType === null || providerType === "y-websocket") return resolveWebsocketFamily("y-websocket", candidate);
|
|
20659
|
-
if (providerType === "hocuspocus") return resolveWebsocketFamily("hocuspocus", candidate);
|
|
20660
|
-
if (providerType === "liveblocks") return resolveLiveblocksFamily(candidate, authEndpointBaseUrl);
|
|
20661
20757
|
return {
|
|
20662
|
-
|
|
20663
|
-
|
|
20664
|
-
|
|
20758
|
+
error: new Error(message),
|
|
20759
|
+
code,
|
|
20760
|
+
collaborationReason,
|
|
20761
|
+
documentId,
|
|
20762
|
+
editor: null
|
|
20665
20763
|
};
|
|
20666
20764
|
}
|
|
20667
20765
|
//#endregion
|
|
@@ -21848,6 +21946,10 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
21848
21946
|
const clearV2RuntimeRegistration = (documentId) => {
|
|
21849
21947
|
clearV2CommandShortcutBinding(documentId);
|
|
21850
21948
|
clearV2SessionShortcutBinding(documentId);
|
|
21949
|
+
const document = getDocument(documentId);
|
|
21950
|
+
const provider = document?.provider ?? null;
|
|
21951
|
+
if (provider && proxy.$superdoc.provider === provider) proxy.$superdoc.provider = void 0;
|
|
21952
|
+
if (document && provider?.sendStateless) document.provider = null;
|
|
21851
21953
|
const entry = v2Runtimes.get(documentId);
|
|
21852
21954
|
if (!entry) return;
|
|
21853
21955
|
proxy.$superdoc.unregisterEditorRuntime(entry.runtimeId);
|
|
@@ -22036,7 +22138,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22036
22138
|
clearV2EditorFailure(payload.documentId ?? null);
|
|
22037
22139
|
clearV2AuthorRequired(payload.documentId ?? null);
|
|
22038
22140
|
clearV2EditRejected(payload.documentId ?? null);
|
|
22039
|
-
const { host, mount, documentId, capabilities, editCommands, bindEditShortcuts, bindSessionShortcuts, commentsAdapter, trackedChangesAdapter, contextMenu, documentApi, documentMutationReadiness, documentApiUnavailableReason, pageMetrics, pageLayout, pageFurniture, presence, lock, fonts, replaceFile, upgradeToCollaboration, documentOpenToken } = payload;
|
|
22141
|
+
const { host, mount, documentId, capabilities, editCommands, bindEditShortcuts, bindSessionShortcuts, commentsAdapter, trackedChangesAdapter, contextMenu, documentApi, documentMutationReadiness, documentApiUnavailableReason, pageMetrics, pageLayout, pageFurniture, presence, lock, collaborationProvider, fonts, replaceFile, upgradeToCollaboration, documentOpenToken } = payload;
|
|
22040
22142
|
documentOpenTelemetry?.trackDocumentOpen(documentOpenToken ?? null, documentId ?? null);
|
|
22041
22143
|
const saveV2Bytes = async (saveOptions = {}) => {
|
|
22042
22144
|
if (!host || typeof host.save !== "function") throw new Error("v2-editor: save unavailable");
|
|
@@ -22311,6 +22413,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22311
22413
|
pageFurniture: pageFurniture ?? null,
|
|
22312
22414
|
presence: presence ?? null,
|
|
22313
22415
|
lock: lock ?? null,
|
|
22416
|
+
provider: collaborationProvider ?? null,
|
|
22314
22417
|
reviewWindow: {
|
|
22315
22418
|
getDiagnostics: () => v2ReviewWindowController.getDiagnostics(),
|
|
22316
22419
|
getSnapshot: () => v2ReviewWindowController.getSnapshot?.() ?? null,
|
|
@@ -22345,6 +22448,11 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22345
22448
|
proxy.$superdoc.setActiveEditor(facade);
|
|
22346
22449
|
syncV2EditRejectedActiveDocument();
|
|
22347
22450
|
}
|
|
22451
|
+
if (collaborationProvider) {
|
|
22452
|
+
const provider = markRaw(collaborationProvider);
|
|
22453
|
+
proxy.$superdoc.provider = provider;
|
|
22454
|
+
if (doc) doc.provider = provider;
|
|
22455
|
+
}
|
|
22348
22456
|
proxy.$superdoc.broadcastEditorCreate(facade);
|
|
22349
22457
|
installV2CommandShortcutBinding({
|
|
22350
22458
|
documentId,
|
|
@@ -22862,7 +22970,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22862
22970
|
case "worker-init-failed": return "SuperDoc could not load the document editor because the browser worker failed to start.";
|
|
22863
22971
|
case "input-too-large-for-inline-review": return "SuperDoc could not load the document editor because this document is too large to open without the browser worker.";
|
|
22864
22972
|
case "collaboration-unsupported-huge-document": return "SuperDoc could not load the document editor because large documents cannot be opened with collaboration enabled yet.";
|
|
22865
|
-
case "collaboration-v1-config-unsupported": return "SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.
|
|
22973
|
+
case "collaboration-v1-config-unsupported": return "SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.collaboration with a v2 room instead.";
|
|
22866
22974
|
case "collaboration-room-format-unsupported": return "SuperDoc v2 cannot open this collaboration state because it is not stored in the SuperDoc v2 room format. No changes were made.";
|
|
22867
22975
|
case "collaboration-room-format-conflict": return "SuperDoc v2 found conflicting room formats in one collaboration document. No changes were made.";
|
|
22868
22976
|
case "collaboration-room-corrupt": return "SuperDoc v2 found a structurally invalid collaboration room. No changes were made.";
|
|
@@ -22880,7 +22988,8 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22880
22988
|
const reason = typeof payload?.reason === "string" && payload.reason.length > 0 ? payload.reason : "open-failed";
|
|
22881
22989
|
const detail = normalizeV2EditorFailureDetail(payload?.detail);
|
|
22882
22990
|
const documentId = typeof payload?.documentId === "string" && payload.documentId.length > 0 ? payload.documentId : null;
|
|
22883
|
-
const
|
|
22991
|
+
const collaborationException = createCollaborationException(reason, documentId);
|
|
22992
|
+
const message = collaborationException?.error.message ?? getV2EditorFailureMessage(reason);
|
|
22884
22993
|
const workerFailure = payload?.workerFailure && typeof payload.workerFailure === "object" ? payload.workerFailure : null;
|
|
22885
22994
|
setV2EditorFailure(documentId, {
|
|
22886
22995
|
reason,
|
|
@@ -22896,7 +23005,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22896
23005
|
};
|
|
22897
23006
|
if (reason === "collaboration-v1-config-unsupported" || reason === "collaboration-room-format-unsupported" || reason === "collaboration-room-format-conflict" || reason === "collaboration-room-corrupt" || reason === "collaboration-v2-room-missing" || reason === "collaboration-v2-room-already-exists" || reason === "collaboration-v2-room-initializing" || reason === "collaboration-open-intent-invalid" || reason === "collaboration-config-invalid") console.warn(`[SuperDoc] ${message}`, logContext);
|
|
22898
23007
|
else console.error(`[SuperDoc] ${message}`, logContext);
|
|
22899
|
-
proxy.$superdoc.emit("exception", {
|
|
23008
|
+
proxy.$superdoc.emit("exception", collaborationException ?? {
|
|
22900
23009
|
error: new Error(message),
|
|
22901
23010
|
code: reason,
|
|
22902
23011
|
...documentId ? { documentId } : {},
|
|
@@ -24120,7 +24229,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
24120
24229
|
], 38);
|
|
24121
24230
|
};
|
|
24122
24231
|
}
|
|
24123
|
-
}, [["__scopeId", "data-v-
|
|
24232
|
+
}, [["__scopeId", "data-v-ebe9a1fb"]]);
|
|
24124
24233
|
//#endregion
|
|
24125
24234
|
//#region src/core/create-app.js
|
|
24126
24235
|
var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
|
|
@@ -39558,7 +39667,7 @@ var OverflowMenu_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
39558
39667
|
const emit = __emit;
|
|
39559
39668
|
const props = __props;
|
|
39560
39669
|
const isOverflowMenuOpened = computed(() => props.toolbarItem.expand.value);
|
|
39561
|
-
const hasOpenDropdown =
|
|
39670
|
+
const hasOpenDropdown = computed(() => props.overflowItems.some((item) => item.type === "dropdown" && unref(item.expand)));
|
|
39562
39671
|
const overflowToolbarItem = computed(() => ({
|
|
39563
39672
|
...props.toolbarItem,
|
|
39564
39673
|
active: isOverflowMenuOpened.value
|
|
@@ -39604,8 +39713,7 @@ var OverflowMenu_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
39604
39713
|
"ui-font-family": props.uiFontFamily,
|
|
39605
39714
|
"from-overflow": "",
|
|
39606
39715
|
onMousedown: unref(preventEditorFocusTransfer),
|
|
39607
|
-
onCommand: handleCommand
|
|
39608
|
-
onDropdownUpdateShow: _cache[0] || (_cache[0] = ($event) => hasOpenDropdown.value = $event)
|
|
39716
|
+
onCommand: handleCommand
|
|
39609
39717
|
}, null, 8, [
|
|
39610
39718
|
"toolbar-items",
|
|
39611
39719
|
"ui-font-family",
|
|
@@ -39620,7 +39728,7 @@ var OverflowMenu_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
39620
39728
|
]);
|
|
39621
39729
|
};
|
|
39622
39730
|
}
|
|
39623
|
-
}, [["__scopeId", "data-v-
|
|
39731
|
+
}, [["__scopeId", "data-v-5f8ee279"]]);
|
|
39624
39732
|
//#endregion
|
|
39625
39733
|
//#region src/internal/toolbar/built-in/font-typeahead.js
|
|
39626
39734
|
/**
|
|
@@ -44932,10 +45040,6 @@ function contentControlSelectionKey(selection) {
|
|
|
44932
45040
|
function isV2ActiveEditorFacade(editor) {
|
|
44933
45041
|
return Boolean(editor && typeof editor === "object" && editor.editorVersion === 2);
|
|
44934
45042
|
}
|
|
44935
|
-
function isV2FailClosedExportError(error) {
|
|
44936
|
-
const code = error && typeof error === "object" ? error.code : null;
|
|
44937
|
-
return code === "comment-export-missing-story-reference" || code === "v2-worker-comment-export-mode-unsupported";
|
|
44938
|
-
}
|
|
44939
45043
|
function normalizeActiveEditorDocumentId(documentId) {
|
|
44940
45044
|
return typeof documentId === "string" && documentId.length > 0 ? documentId : null;
|
|
44941
45045
|
}
|
|
@@ -45287,7 +45391,7 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
45287
45391
|
this.config.colors = shuffleArray(this.config.colors);
|
|
45288
45392
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
45289
45393
|
this.colorIndex = 0;
|
|
45290
|
-
this.version = "2.13.0-next.
|
|
45394
|
+
this.version = "2.13.0-next.11";
|
|
45291
45395
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
45292
45396
|
this.superdocId = config.superdocId || v4();
|
|
45293
45397
|
this.colors = this.config.colors ?? [];
|
|
@@ -45941,6 +46045,14 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
45941
46045
|
storeDoc.v2Collaboration = value;
|
|
45942
46046
|
}
|
|
45943
46047
|
#toV2CollaborationConfig(target) {
|
|
46048
|
+
if (target.providerFamily === "extension") return {
|
|
46049
|
+
providerType: "extension",
|
|
46050
|
+
adapterId: target.adapterId,
|
|
46051
|
+
documentId: target.documentId,
|
|
46052
|
+
roomMode: target.roomMode,
|
|
46053
|
+
...target.providerOptions !== void 0 ? { providerOptions: target.providerOptions } : {},
|
|
46054
|
+
...target.token ? { token: target.token } : {}
|
|
46055
|
+
};
|
|
45944
46056
|
if (target.providerFamily === "liveblocks") return {
|
|
45945
46057
|
providerType: "liveblocks",
|
|
45946
46058
|
documentId: target.documentId,
|
|
@@ -46149,8 +46261,10 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
46149
46261
|
ydoc: options.ydoc,
|
|
46150
46262
|
provider: options.provider
|
|
46151
46263
|
} : collaborationModule ? { ...collaborationModule } : null;
|
|
46264
|
+
const v2Collaboration = options.v2Collaboration ?? this.#unwrapMaybeRef(configDoc.v2Collaboration) ?? collaborationModule?.v2Collaboration ?? collaborationModule?.v2 ?? null;
|
|
46152
46265
|
const resolution = resolveV2CollaborationTarget({
|
|
46153
|
-
|
|
46266
|
+
collaboration: options.collaboration,
|
|
46267
|
+
v2Collaboration,
|
|
46154
46268
|
legacyCollaboration,
|
|
46155
46269
|
documentType: DOCX,
|
|
46156
46270
|
documentCount: cfg.documents.length,
|
|
@@ -47131,6 +47245,13 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
47131
47245
|
}
|
|
47132
47246
|
if (this.superdocStore.zoomMode === mode) return;
|
|
47133
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
|
+
}
|
|
47134
47255
|
this.emit("zoomChange", {
|
|
47135
47256
|
zoom: this.getZoom(),
|
|
47136
47257
|
mode
|
|
@@ -47362,7 +47483,7 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
47362
47483
|
error,
|
|
47363
47484
|
document: doc
|
|
47364
47485
|
});
|
|
47365
|
-
if (isV2Editor
|
|
47486
|
+
if (isV2Editor) throw error;
|
|
47366
47487
|
}
|
|
47367
47488
|
return fallbackDocx();
|
|
47368
47489
|
});
|
|
@@ -47569,10 +47690,6 @@ var COLORS_TO_VARS = {
|
|
|
47569
47690
|
border: "--sd-ui-border"
|
|
47570
47691
|
};
|
|
47571
47692
|
var themeCounter = 0;
|
|
47572
|
-
/**
|
|
47573
|
-
* Generate the className and CSS string from a theme config.
|
|
47574
|
-
* Shared core used by both createTheme and buildTheme.
|
|
47575
|
-
*/
|
|
47576
47693
|
function generateTheme(config) {
|
|
47577
47694
|
const { name, font, radius, shadow, colors, vars } = config;
|
|
47578
47695
|
const className = `sd-theme-${(name ? name.replace(/[^a-zA-Z0-9-_]/g, "-") : null) || `custom-${++themeCounter}`}`;
|
|
@@ -47638,8 +47755,8 @@ function createTheme(config) {
|
|
|
47638
47755
|
}
|
|
47639
47756
|
/**
|
|
47640
47757
|
* Build a SuperDoc theme and return both the class name and raw CSS.
|
|
47641
|
-
*
|
|
47642
|
-
*
|
|
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.
|
|
47643
47760
|
*
|
|
47644
47761
|
* @example
|
|
47645
47762
|
* ```ts
|