@harbour-enterprises/superdoc 0.25.0-next.3 → 0.25.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.
Files changed (27) hide show
  1. package/dist/chunks/{PdfViewer-DDL0V0l5.cjs → PdfViewer-BETK3Bs4.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-Y13XRanw.es.js → PdfViewer-D4F3H-Ay.es.js} +1 -1
  3. package/dist/chunks/{index-Bo5YCvD5.cjs → index-BHS2aLqo.cjs} +2 -2
  4. package/dist/chunks/{index-DKNVSdr6.es.js → index-D9KYAvvg.es.js} +2 -2
  5. package/dist/chunks/{super-editor.es-Ct2sXbNV.cjs → super-editor.es-BJzqCihw.cjs} +107 -116
  6. package/dist/chunks/{super-editor.es-CYtLh0Ob.es.js → super-editor.es-Beeng5kU.es.js} +107 -116
  7. package/dist/core/types/index.d.ts.map +1 -1
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-gSy6s2VK.js → converter-DOkexB95.js} +89 -72
  10. package/dist/super-editor/chunks/{docx-zipper-CceGxV02.js → docx-zipper-Ci5JbfjE.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-CoX24lXQ.js → editor-DC9ZOqdt.js} +23 -58
  12. package/dist/super-editor/chunks/{toolbar-BTw9-jfX.js → toolbar-SPGEoEi0.js} +2 -2
  13. package/dist/super-editor/converter.es.js +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +11 -0
  18. package/dist/super-editor/super-editor/src/index.d.ts +8 -2
  19. package/dist/super-editor/super-editor.es.js +16 -12
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +107 -116
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-DKMj1I9B.cjs");
4
- const superdoc = require("./index-Bo5YCvD5.cjs");
4
+ const superdoc = require("./index-BHS2aLqo.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-ZWZLQtoU.es.js";
2
- import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-DKNVSdr6.es.js";
2
+ import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-D9KYAvvg.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-Ct2sXbNV.cjs");
2
+ const superEditor_es = require("./super-editor.es-BJzqCihw.cjs");
3
3
  const vue = require("./vue-DKMj1I9B.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-DkXkH2rT.cjs");
@@ -17164,7 +17164,7 @@ const _sfc_main = {
17164
17164
  __name: "SuperDoc",
17165
17165
  emits: ["selection-update"],
17166
17166
  setup(__props, { emit: __emit }) {
17167
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DDL0V0l5.cjs")));
17167
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-BETK3Bs4.cjs")));
17168
17168
  const superdocStore = useSuperdocStore();
17169
17169
  const commentsStore = useCommentsStore();
17170
17170
  const {
@@ -1,4 +1,4 @@
1
- import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-CYtLh0Ob.es.js";
1
+ import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-Beeng5kU.es.js";
2
2
  import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-ZWZLQtoU.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-BWEnUdTY.es.js";
@@ -17147,7 +17147,7 @@ const _sfc_main = {
17147
17147
  __name: "SuperDoc",
17148
17148
  emits: ["selection-update"],
17149
17149
  setup(__props, { emit: __emit }) {
17150
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-Y13XRanw.es.js"));
17150
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-D4F3H-Ay.es.js"));
17151
17151
  const superdocStore = useSuperdocStore();
17152
17152
  const commentsStore = useCommentsStore();
17153
17153
  const {
@@ -32332,8 +32332,7 @@ const bookmarkEndNodeHandlerEntity = {
32332
32332
  handlerName: "w:bookmarkEndTranslator",
32333
32333
  handler: handleBookmarkEndNode
32334
32334
  };
32335
- const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32336
- const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32335
+ const SUPPORTED_ALTERNATE_CONTENT_REQUIRES = /* @__PURE__ */ new Set([
32337
32336
  "wps",
32338
32337
  "wp14",
32339
32338
  "w14",
@@ -32346,22 +32345,85 @@ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32346
32345
  "w16sdtfl",
32347
32346
  "w16se"
32348
32347
  ]);
32348
+ const XML_NODE_NAME$1 = "mc:AlternateContent";
32349
+ const SD_NODE_NAME$1 = [];
32350
+ const validXmlAttributes$1 = [];
32351
+ function encode$1(params2) {
32352
+ const { nodeListHandler } = params2;
32353
+ const { node } = params2.extraParams;
32354
+ if (!node || !node.type) {
32355
+ return null;
32356
+ }
32357
+ const { branch, elements } = selectAlternateContentElements(node);
32358
+ if (!elements) {
32359
+ return null;
32360
+ }
32361
+ return nodeListHandler.handler({
32362
+ ...params2,
32363
+ nodes: elements,
32364
+ path: buildPath(params2.path, node, branch)
32365
+ });
32366
+ }
32367
+ function decode$1(params2) {
32368
+ const { node } = params2;
32369
+ const { drawingContent } = node.attrs;
32370
+ const drawing = {
32371
+ name: "w:drawing",
32372
+ elements: [...drawingContent ? [...drawingContent.elements || []] : []]
32373
+ };
32374
+ const choice = {
32375
+ name: "mc:Choice",
32376
+ attributes: { Requires: "wps" },
32377
+ elements: [drawing]
32378
+ };
32379
+ return {
32380
+ name: "mc:AlternateContent",
32381
+ elements: [choice]
32382
+ };
32383
+ }
32384
+ const config$1 = {
32385
+ xmlName: XML_NODE_NAME$1,
32386
+ sdNodeOrKeyName: SD_NODE_NAME$1,
32387
+ type: NodeTranslator.translatorTypes.NODE,
32388
+ encode: encode$1,
32389
+ decode: decode$1,
32390
+ attributes: validXmlAttributes$1
32391
+ };
32392
+ function selectAlternateContentElements(node) {
32393
+ if (!node?.elements?.length) {
32394
+ return { branch: null, elements: null };
32395
+ }
32396
+ const choices = node.elements.filter((el) => el?.name === "mc:Choice");
32397
+ const fallback = node.elements.find((el) => el?.name === "mc:Fallback");
32398
+ const supportedChoice = choices.find((choice) => {
32399
+ const requiresAttr = choice?.attributes?.Requires || choice?.attributes?.requires;
32400
+ if (!requiresAttr) return false;
32401
+ return requiresAttr.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_ALTERNATE_CONTENT_REQUIRES.has(namespace2));
32402
+ });
32403
+ const branch = supportedChoice || fallback || choices[0] || null;
32404
+ const selectedElements = branch?.elements;
32405
+ if (!selectedElements) {
32406
+ return { branch, elements: null };
32407
+ }
32408
+ return {
32409
+ branch,
32410
+ elements: carbonCopy(selectedElements)
32411
+ };
32412
+ }
32413
+ const translator$1 = NodeTranslator.from(config$1);
32414
+ function buildPath(existingPath = [], node, branch) {
32415
+ const path = [...existingPath];
32416
+ if (node) path.push(node);
32417
+ if (branch) path.push(branch);
32418
+ return path;
32419
+ }
32420
+ const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32349
32421
  const skipHandlerResponse = { nodes: [], consumed: 0 };
32350
32422
  const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
32351
- const isSupportedChoice = (choice) => {
32352
- if (!choice?.attributes) return false;
32353
- const requires = choice.attributes.Requires || choice.attributes.requires;
32354
- if (!requires) return false;
32355
- return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
32356
- };
32357
32423
  const resolveAlternateContentElements = (alternateContent) => {
32358
- if (!alternateContent?.elements?.length) return null;
32359
- const choices = alternateContent.elements.filter((el) => el.name === "mc:Choice");
32360
- const fallback = alternateContent.elements.find((el) => el.name === "mc:Fallback");
32361
- const supportedChoice = choices.find(isSupportedChoice);
32362
- const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
32363
- if (!selectedElements) return null;
32364
- return carbonCopy(selectedElements);
32424
+ const { elements } = selectAlternateContentElements(alternateContent);
32425
+ if (!elements) return null;
32426
+ return elements;
32365
32427
  };
32366
32428
  const buildNodeWithoutAlternateContent = (node) => {
32367
32429
  const { elements } = node || {};
@@ -32393,16 +32455,20 @@ const handleAlternateChoice = (params2) => {
32393
32455
  }
32394
32456
  const [currentNode] = nodes;
32395
32457
  if (isAlternateContentNode(currentNode)) {
32396
- const resolvedElements = resolveAlternateContentElements(currentNode);
32397
- if (!resolvedElements) {
32398
- return skipHandlerResponse;
32399
- }
32400
- const result2 = nodeListHandler.handler({
32458
+ const nodeForTranslator = currentNode?.type ? currentNode : {
32459
+ ...currentNode,
32460
+ type: "element"
32461
+ };
32462
+ const translated = translator$1.encode({
32401
32463
  ...params2,
32402
- nodes: resolvedElements,
32403
- path: [...params2.path || [], currentNode]
32464
+ nodes: [nodeForTranslator],
32465
+ extraParams: { ...params2.extraParams || {}, node: nodeForTranslator }
32404
32466
  });
32405
- return { nodes: result2, consumed: 1 };
32467
+ if (!translated) {
32468
+ return skipHandlerResponse;
32469
+ }
32470
+ const nodesArray = Array.isArray(translated) ? translated : [translated];
32471
+ return { nodes: nodesArray, consumed: 1 };
32406
32472
  }
32407
32473
  const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
32408
32474
  if (!sanitizedNode) {
@@ -33700,55 +33766,6 @@ function translateShapeTextbox(params2) {
33700
33766
  };
33701
33767
  return textbox;
33702
33768
  }
33703
- const XML_NODE_NAME$1 = "mc:AlternateContent";
33704
- const SD_NODE_NAME$1 = [];
33705
- const validXmlAttributes$1 = [];
33706
- function encode$1(params2) {
33707
- const { nodeListHandler } = params2;
33708
- const { node } = params2.extraParams;
33709
- if (!node || !node.type) {
33710
- return null;
33711
- }
33712
- const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
33713
- const wpsNode = node.elements.find(
33714
- (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
33715
- );
33716
- if (!wpsNode) {
33717
- return null;
33718
- }
33719
- const contents = wpsNode.elements;
33720
- return nodeListHandler.handler({
33721
- ...params2,
33722
- nodes: contents,
33723
- path: [...params2.path || [], wpsNode]
33724
- });
33725
- }
33726
- function decode$1(params2) {
33727
- const { node } = params2;
33728
- const { drawingContent } = node.attrs;
33729
- const drawing = {
33730
- name: "w:drawing",
33731
- elements: [...drawingContent ? [...drawingContent.elements || []] : []]
33732
- };
33733
- const choice = {
33734
- name: "mc:Choice",
33735
- attributes: { Requires: "wps" },
33736
- elements: [drawing]
33737
- };
33738
- return {
33739
- name: "mc:AlternateContent",
33740
- elements: [choice]
33741
- };
33742
- }
33743
- const config$1 = {
33744
- xmlName: XML_NODE_NAME$1,
33745
- sdNodeOrKeyName: SD_NODE_NAME$1,
33746
- type: NodeTranslator.translatorTypes.NODE,
33747
- encode: encode$1,
33748
- decode: decode$1,
33749
- attributes: validXmlAttributes$1
33750
- };
33751
- const translator$1 = NodeTranslator.from(config$1);
33752
33769
  function translateContentBlock(params2) {
33753
33770
  const { node } = params2;
33754
33771
  const { vmlAttributes, horizontalRule } = node.attrs;
@@ -38352,7 +38369,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
38352
38369
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
38353
38370
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
38354
38371
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
38355
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFontsWithLocalFonts_fn, determineUnsupportedFontsWithCanvas_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
38372
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
38356
38373
  var GOOD_LEAF_SIZE = 200;
38357
38374
  var RopeSequence = function RopeSequence2() {
38358
38375
  };
@@ -53535,9 +53552,6 @@ init_fn = function() {
53535
53552
  this.emit("beforeCreate", { editor: this });
53536
53553
  this.on("contentError", this.options.onContentError);
53537
53554
  this.mount(this.options.element);
53538
- if (!this.options.isHeadless) {
53539
- __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
53540
- }
53541
53555
  this.on("create", this.options.onCreate);
53542
53556
  this.on("update", this.options.onUpdate);
53543
53557
  this.on("selectionUpdate", this.options.onSelectionUpdate);
@@ -53559,8 +53573,12 @@ init_fn = function() {
53559
53573
  if (!this.options.isHeadless) {
53560
53574
  this.initializeCollaborationData();
53561
53575
  this.initDefaultStyles();
53576
+ __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
53562
53577
  }
53563
- if (!this.options.ydoc || this.options.markdown || this.options.html) {
53578
+ const shouldMigrateListsOnInit = Boolean(
53579
+ this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
53580
+ );
53581
+ if (shouldMigrateListsOnInit) {
53564
53582
  this.migrateListsToV2();
53565
53583
  }
53566
53584
  this.setDocumentMode(this.options.documentMode);
@@ -53701,52 +53719,18 @@ checkFonts_fn = async function() {
53701
53719
  if (this.options.isHeadless) {
53702
53720
  return;
53703
53721
  }
53704
- const fontsUsedInDocument = this.converter.getDocumentFonts();
53705
- if (!("queryLocalFonts" in window)) {
53706
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53707
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53708
- this.emit("fonts-resolved", {
53709
- documentFonts: fontsUsedInDocument,
53710
- unsupportedFonts
53711
- });
53712
- return;
53713
- }
53714
- const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
53715
- if (localFontAccess.state === "denied") {
53716
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53717
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53718
- this.emit("fonts-resolved", {
53719
- documentFonts: fontsUsedInDocument,
53720
- unsupportedFonts
53721
- });
53722
- return;
53723
- }
53724
53722
  try {
53725
- const localFonts = await window.queryLocalFonts();
53726
- const uniqueLocalFonts = [...new Set(localFonts.map((font) => font.family))];
53727
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
53723
+ const fontsUsedInDocument = this.converter.getDocumentFonts();
53724
+ const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
53728
53725
  this.emit("fonts-resolved", {
53729
53726
  documentFonts: fontsUsedInDocument,
53730
53727
  unsupportedFonts
53731
53728
  });
53732
53729
  } catch {
53733
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53734
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53735
- this.emit("fonts-resolved", {
53736
- documentFonts: fontsUsedInDocument,
53737
- unsupportedFonts
53738
- });
53730
+ console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
53739
53731
  }
53740
53732
  };
53741
- determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
53742
- const unsupportedFonts = fonts.filter((font) => {
53743
- const isLocalFont = localFonts.includes(font);
53744
- const isFontImported = this.fontsImported.includes(font);
53745
- return !isLocalFont && !isFontImported;
53746
- });
53747
- return unsupportedFonts;
53748
- };
53749
- determineUnsupportedFontsWithCanvas_fn = function(fonts) {
53733
+ determineUnsupportedFonts_fn = function(fonts) {
53750
53734
  const unsupportedFonts = fonts.filter((font) => {
53751
53735
  const canRender = canRenderFont(font);
53752
53736
  const isFontImported = this.fontsImported.includes(font);
@@ -53834,6 +53818,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
53834
53818
  if (this.options.collaborationIsReady) return;
53835
53819
  console.debug("🔗 [super-editor] Collaboration ready");
53836
53820
  __privateMethod$1(this, _Editor_instances, validateDocumentInit_fn).call(this);
53821
+ if (this.options.ydoc) {
53822
+ this.migrateListsToV2();
53823
+ }
53837
53824
  this.options.onCollaborationReady({ editor, ydoc });
53838
53825
  this.options.collaborationIsReady = true;
53839
53826
  this.options.initialState = this.state;
@@ -88991,8 +88978,12 @@ const Extensions = {
88991
88978
  Node: Node$1,
88992
88979
  Attribute: Attribute2,
88993
88980
  Extension,
88981
+ Mark: Mark2,
88982
+ //
88994
88983
  Plugin,
88995
- Mark: Mark2
88984
+ PluginKey,
88985
+ Decoration,
88986
+ DecorationSet
88996
88987
  };
88997
88988
  exports.AIWriter = AIWriter;
88998
88989
  exports.AnnotatorHelpers = AnnotatorHelpers;
@@ -32315,8 +32315,7 @@ const bookmarkEndNodeHandlerEntity = {
32315
32315
  handlerName: "w:bookmarkEndTranslator",
32316
32316
  handler: handleBookmarkEndNode
32317
32317
  };
32318
- const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32319
- const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32318
+ const SUPPORTED_ALTERNATE_CONTENT_REQUIRES = /* @__PURE__ */ new Set([
32320
32319
  "wps",
32321
32320
  "wp14",
32322
32321
  "w14",
@@ -32329,22 +32328,85 @@ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
32329
32328
  "w16sdtfl",
32330
32329
  "w16se"
32331
32330
  ]);
32331
+ const XML_NODE_NAME$1 = "mc:AlternateContent";
32332
+ const SD_NODE_NAME$1 = [];
32333
+ const validXmlAttributes$1 = [];
32334
+ function encode$1(params2) {
32335
+ const { nodeListHandler } = params2;
32336
+ const { node } = params2.extraParams;
32337
+ if (!node || !node.type) {
32338
+ return null;
32339
+ }
32340
+ const { branch, elements } = selectAlternateContentElements(node);
32341
+ if (!elements) {
32342
+ return null;
32343
+ }
32344
+ return nodeListHandler.handler({
32345
+ ...params2,
32346
+ nodes: elements,
32347
+ path: buildPath(params2.path, node, branch)
32348
+ });
32349
+ }
32350
+ function decode$1(params2) {
32351
+ const { node } = params2;
32352
+ const { drawingContent } = node.attrs;
32353
+ const drawing = {
32354
+ name: "w:drawing",
32355
+ elements: [...drawingContent ? [...drawingContent.elements || []] : []]
32356
+ };
32357
+ const choice = {
32358
+ name: "mc:Choice",
32359
+ attributes: { Requires: "wps" },
32360
+ elements: [drawing]
32361
+ };
32362
+ return {
32363
+ name: "mc:AlternateContent",
32364
+ elements: [choice]
32365
+ };
32366
+ }
32367
+ const config$1 = {
32368
+ xmlName: XML_NODE_NAME$1,
32369
+ sdNodeOrKeyName: SD_NODE_NAME$1,
32370
+ type: NodeTranslator.translatorTypes.NODE,
32371
+ encode: encode$1,
32372
+ decode: decode$1,
32373
+ attributes: validXmlAttributes$1
32374
+ };
32375
+ function selectAlternateContentElements(node) {
32376
+ if (!node?.elements?.length) {
32377
+ return { branch: null, elements: null };
32378
+ }
32379
+ const choices = node.elements.filter((el) => el?.name === "mc:Choice");
32380
+ const fallback = node.elements.find((el) => el?.name === "mc:Fallback");
32381
+ const supportedChoice = choices.find((choice) => {
32382
+ const requiresAttr = choice?.attributes?.Requires || choice?.attributes?.requires;
32383
+ if (!requiresAttr) return false;
32384
+ return requiresAttr.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_ALTERNATE_CONTENT_REQUIRES.has(namespace2));
32385
+ });
32386
+ const branch = supportedChoice || fallback || choices[0] || null;
32387
+ const selectedElements = branch?.elements;
32388
+ if (!selectedElements) {
32389
+ return { branch, elements: null };
32390
+ }
32391
+ return {
32392
+ branch,
32393
+ elements: carbonCopy(selectedElements)
32394
+ };
32395
+ }
32396
+ const translator$1 = NodeTranslator.from(config$1);
32397
+ function buildPath(existingPath = [], node, branch) {
32398
+ const path = [...existingPath];
32399
+ if (node) path.push(node);
32400
+ if (branch) path.push(branch);
32401
+ return path;
32402
+ }
32403
+ const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
32332
32404
  const skipHandlerResponse = { nodes: [], consumed: 0 };
32333
32405
  const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
32334
- const isSupportedChoice = (choice) => {
32335
- if (!choice?.attributes) return false;
32336
- const requires = choice.attributes.Requires || choice.attributes.requires;
32337
- if (!requires) return false;
32338
- return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
32339
- };
32340
32406
  const resolveAlternateContentElements = (alternateContent) => {
32341
- if (!alternateContent?.elements?.length) return null;
32342
- const choices = alternateContent.elements.filter((el) => el.name === "mc:Choice");
32343
- const fallback = alternateContent.elements.find((el) => el.name === "mc:Fallback");
32344
- const supportedChoice = choices.find(isSupportedChoice);
32345
- const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
32346
- if (!selectedElements) return null;
32347
- return carbonCopy(selectedElements);
32407
+ const { elements } = selectAlternateContentElements(alternateContent);
32408
+ if (!elements) return null;
32409
+ return elements;
32348
32410
  };
32349
32411
  const buildNodeWithoutAlternateContent = (node) => {
32350
32412
  const { elements } = node || {};
@@ -32376,16 +32438,20 @@ const handleAlternateChoice = (params2) => {
32376
32438
  }
32377
32439
  const [currentNode] = nodes;
32378
32440
  if (isAlternateContentNode(currentNode)) {
32379
- const resolvedElements = resolveAlternateContentElements(currentNode);
32380
- if (!resolvedElements) {
32381
- return skipHandlerResponse;
32382
- }
32383
- const result2 = nodeListHandler.handler({
32441
+ const nodeForTranslator = currentNode?.type ? currentNode : {
32442
+ ...currentNode,
32443
+ type: "element"
32444
+ };
32445
+ const translated = translator$1.encode({
32384
32446
  ...params2,
32385
- nodes: resolvedElements,
32386
- path: [...params2.path || [], currentNode]
32447
+ nodes: [nodeForTranslator],
32448
+ extraParams: { ...params2.extraParams || {}, node: nodeForTranslator }
32387
32449
  });
32388
- return { nodes: result2, consumed: 1 };
32450
+ if (!translated) {
32451
+ return skipHandlerResponse;
32452
+ }
32453
+ const nodesArray = Array.isArray(translated) ? translated : [translated];
32454
+ return { nodes: nodesArray, consumed: 1 };
32389
32455
  }
32390
32456
  const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
32391
32457
  if (!sanitizedNode) {
@@ -33683,55 +33749,6 @@ function translateShapeTextbox(params2) {
33683
33749
  };
33684
33750
  return textbox;
33685
33751
  }
33686
- const XML_NODE_NAME$1 = "mc:AlternateContent";
33687
- const SD_NODE_NAME$1 = [];
33688
- const validXmlAttributes$1 = [];
33689
- function encode$1(params2) {
33690
- const { nodeListHandler } = params2;
33691
- const { node } = params2.extraParams;
33692
- if (!node || !node.type) {
33693
- return null;
33694
- }
33695
- const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
33696
- const wpsNode = node.elements.find(
33697
- (el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
33698
- );
33699
- if (!wpsNode) {
33700
- return null;
33701
- }
33702
- const contents = wpsNode.elements;
33703
- return nodeListHandler.handler({
33704
- ...params2,
33705
- nodes: contents,
33706
- path: [...params2.path || [], wpsNode]
33707
- });
33708
- }
33709
- function decode$1(params2) {
33710
- const { node } = params2;
33711
- const { drawingContent } = node.attrs;
33712
- const drawing = {
33713
- name: "w:drawing",
33714
- elements: [...drawingContent ? [...drawingContent.elements || []] : []]
33715
- };
33716
- const choice = {
33717
- name: "mc:Choice",
33718
- attributes: { Requires: "wps" },
33719
- elements: [drawing]
33720
- };
33721
- return {
33722
- name: "mc:AlternateContent",
33723
- elements: [choice]
33724
- };
33725
- }
33726
- const config$1 = {
33727
- xmlName: XML_NODE_NAME$1,
33728
- sdNodeOrKeyName: SD_NODE_NAME$1,
33729
- type: NodeTranslator.translatorTypes.NODE,
33730
- encode: encode$1,
33731
- decode: decode$1,
33732
- attributes: validXmlAttributes$1
33733
- };
33734
- const translator$1 = NodeTranslator.from(config$1);
33735
33752
  function translateContentBlock(params2) {
33736
33753
  const { node } = params2;
33737
33754
  const { vmlAttributes, horizontalRule } = node.attrs;
@@ -38335,7 +38352,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
38335
38352
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
38336
38353
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
38337
38354
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
38338
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFontsWithLocalFonts_fn, determineUnsupportedFontsWithCanvas_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
38355
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
38339
38356
  var GOOD_LEAF_SIZE = 200;
38340
38357
  var RopeSequence = function RopeSequence2() {
38341
38358
  };
@@ -53518,9 +53535,6 @@ init_fn = function() {
53518
53535
  this.emit("beforeCreate", { editor: this });
53519
53536
  this.on("contentError", this.options.onContentError);
53520
53537
  this.mount(this.options.element);
53521
- if (!this.options.isHeadless) {
53522
- __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
53523
- }
53524
53538
  this.on("create", this.options.onCreate);
53525
53539
  this.on("update", this.options.onUpdate);
53526
53540
  this.on("selectionUpdate", this.options.onSelectionUpdate);
@@ -53542,8 +53556,12 @@ init_fn = function() {
53542
53556
  if (!this.options.isHeadless) {
53543
53557
  this.initializeCollaborationData();
53544
53558
  this.initDefaultStyles();
53559
+ __privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
53545
53560
  }
53546
- if (!this.options.ydoc || this.options.markdown || this.options.html) {
53561
+ const shouldMigrateListsOnInit = Boolean(
53562
+ this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
53563
+ );
53564
+ if (shouldMigrateListsOnInit) {
53547
53565
  this.migrateListsToV2();
53548
53566
  }
53549
53567
  this.setDocumentMode(this.options.documentMode);
@@ -53684,52 +53702,18 @@ checkFonts_fn = async function() {
53684
53702
  if (this.options.isHeadless) {
53685
53703
  return;
53686
53704
  }
53687
- const fontsUsedInDocument = this.converter.getDocumentFonts();
53688
- if (!("queryLocalFonts" in window)) {
53689
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53690
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53691
- this.emit("fonts-resolved", {
53692
- documentFonts: fontsUsedInDocument,
53693
- unsupportedFonts
53694
- });
53695
- return;
53696
- }
53697
- const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
53698
- if (localFontAccess.state === "denied") {
53699
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53700
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53701
- this.emit("fonts-resolved", {
53702
- documentFonts: fontsUsedInDocument,
53703
- unsupportedFonts
53704
- });
53705
- return;
53706
- }
53707
53705
  try {
53708
- const localFonts = await window.queryLocalFonts();
53709
- const uniqueLocalFonts = [...new Set(localFonts.map((font) => font.family))];
53710
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
53706
+ const fontsUsedInDocument = this.converter.getDocumentFonts();
53707
+ const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
53711
53708
  this.emit("fonts-resolved", {
53712
53709
  documentFonts: fontsUsedInDocument,
53713
53710
  unsupportedFonts
53714
53711
  });
53715
53712
  } catch {
53716
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
53717
- const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
53718
- this.emit("fonts-resolved", {
53719
- documentFonts: fontsUsedInDocument,
53720
- unsupportedFonts
53721
- });
53713
+ console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
53722
53714
  }
53723
53715
  };
53724
- determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
53725
- const unsupportedFonts = fonts.filter((font) => {
53726
- const isLocalFont = localFonts.includes(font);
53727
- const isFontImported = this.fontsImported.includes(font);
53728
- return !isLocalFont && !isFontImported;
53729
- });
53730
- return unsupportedFonts;
53731
- };
53732
- determineUnsupportedFontsWithCanvas_fn = function(fonts) {
53716
+ determineUnsupportedFonts_fn = function(fonts) {
53733
53717
  const unsupportedFonts = fonts.filter((font) => {
53734
53718
  const canRender = canRenderFont(font);
53735
53719
  const isFontImported = this.fontsImported.includes(font);
@@ -53817,6 +53801,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
53817
53801
  if (this.options.collaborationIsReady) return;
53818
53802
  console.debug("🔗 [super-editor] Collaboration ready");
53819
53803
  __privateMethod$1(this, _Editor_instances, validateDocumentInit_fn).call(this);
53804
+ if (this.options.ydoc) {
53805
+ this.migrateListsToV2();
53806
+ }
53820
53807
  this.options.onCollaborationReady({ editor, ydoc });
53821
53808
  this.options.collaborationIsReady = true;
53822
53809
  this.options.initialState = this.state;
@@ -88974,8 +88961,12 @@ const Extensions = {
88974
88961
  Node: Node$1,
88975
88962
  Attribute: Attribute2,
88976
88963
  Extension,
88964
+ Mark: Mark2,
88965
+ //
88977
88966
  Plugin,
88978
- Mark: Mark2
88967
+ PluginKey,
88968
+ Decoration,
88969
+ DecorationSet
88979
88970
  };
88980
88971
  export {
88981
88972
  AIWriter as A,