@harbour-enterprises/superdoc 0.21.0 → 0.21.2

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 (49) hide show
  1. package/dist/chunks/{PdfViewer-D3zo7tPo.es.js → PdfViewer-B8NGBTSu.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-OZDJ7gwT.cjs → PdfViewer-BI_j6JKS.cjs} +1 -1
  3. package/dist/chunks/{index-MzW5BVNd.es.js → index-CBHfvgkG.es.js} +42 -21
  4. package/dist/chunks/{index-CfYf4T_z.cjs → index-tTdOfgF_.cjs} +42 -21
  5. package/dist/chunks/{super-editor.es-U-GVCd_F.cjs → super-editor.es-BHEMJ9ST.cjs} +1595 -866
  6. package/dist/chunks/{super-editor.es-Bntob7Wd.es.js → super-editor.es-BIEh7qVW.es.js} +1595 -866
  7. package/dist/core/SuperDoc.d.ts +5 -0
  8. package/dist/core/SuperDoc.d.ts.map +1 -1
  9. package/dist/core/types/index.d.ts +12 -4
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/style.css +47 -27
  12. package/dist/super-editor/ai-writer.es.js +2 -2
  13. package/dist/super-editor/chunks/{converter-3xnF_NHq.js → converter-D7lP9y8P.js} +1064 -710
  14. package/dist/super-editor/chunks/{docx-zipper-CZdELYi-.js → docx-zipper-_TMbHpUQ.js} +73 -12
  15. package/dist/super-editor/chunks/{editor-BqYH4kDD.js → editor-BuT5uWdz.js} +80 -26
  16. package/dist/super-editor/chunks/{toolbar-TkaE2kKM.js → toolbar-6ZwZPyNU.js} +2 -2
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/src/components/slash-menu/menuItems.d.ts +5 -1
  22. package/dist/super-editor/src/components/slash-menu/tests/testHelpers.d.ts +466 -0
  23. package/dist/super-editor/src/components/slash-menu/utils.d.ts +9 -2
  24. package/dist/super-editor/src/core/DocxZipper.d.ts +1 -1
  25. package/dist/super-editor/src/core/commands/__tests__/schemaWithLists.d.ts +2 -0
  26. package/dist/super-editor/src/core/commands/__tests__/testHelpers.d.ts +4 -0
  27. package/dist/super-editor/src/core/commands/__tests__/testSchema.d.ts +2 -0
  28. package/dist/super-editor/src/core/commands/tests/commandTestUtils.d.ts +7 -0
  29. package/dist/super-editor/src/core/commands/tests/test-schema.d.ts +2 -0
  30. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +1 -13
  31. package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -0
  32. package/dist/super-editor/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +6 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/index.d.ts +1 -0
  35. package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -0
  36. package/dist/super-editor/src/tests/helpers/helpers.d.ts +1 -0
  37. package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
  38. package/dist/super-editor/style.css +20 -0
  39. package/dist/super-editor/super-editor.es.js +454 -154
  40. package/dist/super-editor/toolbar.es.js +2 -2
  41. package/dist/super-editor.cjs +1 -1
  42. package/dist/super-editor.es.js +1 -1
  43. package/dist/superdoc.cjs +2 -2
  44. package/dist/superdoc.es.js +2 -2
  45. package/dist/superdoc.umd.js +1635 -885
  46. package/dist/superdoc.umd.js.map +1 -1
  47. package/package.json +2 -5
  48. package/dist/super-editor/src/extensions/run-item/index.d.ts +0 -1
  49. package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -26
@@ -1,4 +1,4 @@
1
- import { p as process$1, au as commonjsGlobal, B as Buffer, av as getDefaultExportFromCjs, aw as getContentTypesFromXml, ax as xmljs } from "./converter-3xnF_NHq.js";
1
+ import { p as process$1, au as commonjsGlobal, B as Buffer, av as getDefaultExportFromCjs, aw as getContentTypesFromXml, ax as xmljs } from "./converter-D7lP9y8P.js";
2
2
  function commonjsRequire(path) {
3
3
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
4
4
  }
@@ -2414,14 +2414,19 @@ class DocxZipper {
2414
2414
  /**
2415
2415
  * Update [Content_Types].xml with extensions of new Image annotations
2416
2416
  */
2417
- async updateContentTypes(docx, media, fromJson) {
2417
+ async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
2418
+ const additionalPartNames = Object.keys(updatedDocs || {});
2418
2419
  const newMediaTypes = Object.keys(media).map((name) => {
2419
2420
  return this.getFileExtension(name);
2420
2421
  }).filter(Boolean);
2421
2422
  const contentTypesPath = "[Content_Types].xml";
2422
2423
  let contentTypesXml;
2423
2424
  if (fromJson) {
2424
- contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
2425
+ if (Array.isArray(docx.files)) {
2426
+ contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
2427
+ } else {
2428
+ contentTypesXml = docx.files?.[contentTypesPath] || "";
2429
+ }
2425
2430
  } else contentTypesXml = await docx.file(contentTypesPath).async("string");
2426
2431
  let typesString = "";
2427
2432
  const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
@@ -2447,24 +2452,39 @@ class DocxZipper {
2447
2452
  const hasCommentsExtensible = types.elements?.some(
2448
2453
  (el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
2449
2454
  );
2450
- if (docx.files["word/comments.xml"]) {
2455
+ const hasFile = (filename) => {
2456
+ if (!docx?.files) return false;
2457
+ if (!fromJson) return Boolean(docx.files[filename]);
2458
+ if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
2459
+ return Boolean(docx.files[filename]);
2460
+ };
2461
+ if (hasFile("word/comments.xml")) {
2451
2462
  const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
2452
2463
  if (!hasComments) typesString += commentsDef;
2453
2464
  }
2454
- if (docx.files["word/commentsExtended.xml"]) {
2465
+ if (hasFile("word/commentsExtended.xml")) {
2455
2466
  const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
2456
2467
  if (!hasCommentsExtended) typesString += commentsExtendedDef;
2457
2468
  }
2458
- if (docx.files["word/commentsIds.xml"]) {
2469
+ if (hasFile("word/commentsIds.xml")) {
2459
2470
  const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
2460
2471
  if (!hasCommentsIds) typesString += commentsIdsDef;
2461
2472
  }
2462
- if (docx.files["word/commentsExtensible.xml"]) {
2473
+ if (hasFile("word/commentsExtensible.xml")) {
2463
2474
  const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
2464
2475
  if (!hasCommentsExtensible) typesString += commentsExtendedDef;
2465
2476
  }
2466
- Object.keys(docx.files).forEach((name) => {
2467
- if (name.includes(".rels") || !name.includes("header") && !name.includes("footer")) return;
2477
+ const partNames = new Set(additionalPartNames);
2478
+ if (docx?.files) {
2479
+ if (fromJson && Array.isArray(docx.files)) {
2480
+ docx.files.forEach((file) => partNames.add(file.name));
2481
+ } else {
2482
+ Object.keys(docx.files).forEach((key) => partNames.add(key));
2483
+ }
2484
+ }
2485
+ partNames.forEach((name) => {
2486
+ if (name.includes(".rels")) return;
2487
+ if (!name.includes("header") && !name.includes("footer")) return;
2468
2488
  const hasExtensible = types.elements?.some(
2469
2489
  (el) => el.name === "Override" && el.attributes.PartName === `/${name}`
2470
2490
  );
@@ -2475,7 +2495,48 @@ class DocxZipper {
2475
2495
  }
2476
2496
  });
2477
2497
  const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
2478
- const updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
2498
+ let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
2499
+ let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
2500
+ if (!relationshipsXml) {
2501
+ if (fromJson) {
2502
+ if (Array.isArray(docx.files)) {
2503
+ relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
2504
+ } else {
2505
+ relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
2506
+ }
2507
+ } else {
2508
+ relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
2509
+ }
2510
+ }
2511
+ if (relationshipsXml) {
2512
+ try {
2513
+ const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
2514
+ const relationships = relJson.elements?.find((el) => el.name === "Relationships");
2515
+ relationships?.elements?.forEach((rel) => {
2516
+ const type = rel.attributes?.Type;
2517
+ const target = rel.attributes?.Target;
2518
+ if (!type || !target) return;
2519
+ const isHeader = type.includes("/header");
2520
+ const isFooter = type.includes("/footer");
2521
+ if (!isHeader && !isFooter) return;
2522
+ let sanitizedTarget = target.replace(/^\.\//, "");
2523
+ if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
2524
+ if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
2525
+ const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
2526
+ partNames.add(partName);
2527
+ });
2528
+ } catch (error) {
2529
+ console.warn("Failed to parse document relationships while updating content types", error);
2530
+ }
2531
+ }
2532
+ partNames.forEach((name) => {
2533
+ if (name.includes(".rels")) return;
2534
+ if (!name.includes("header") && !name.includes("footer")) return;
2535
+ if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
2536
+ const type = name.includes("header") ? "header" : "footer";
2537
+ const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type}+xml"/>`;
2538
+ updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
2539
+ });
2479
2540
  if (fromJson) return updatedContentTypesXml;
2480
2541
  docx.file(contentTypesPath, updatedContentTypesXml);
2481
2542
  }
@@ -2516,7 +2577,7 @@ class DocxZipper {
2516
2577
  for (const [fontName, fontUintArray] of Object.entries(fonts)) {
2517
2578
  zip.file(fontName, fontUintArray);
2518
2579
  }
2519
- await this.updateContentTypes(zip, media);
2580
+ await this.updateContentTypes(zip, media, false, updatedDocs);
2520
2581
  return zip;
2521
2582
  }
2522
2583
  /**
@@ -2542,7 +2603,7 @@ class DocxZipper {
2542
2603
  Object.keys(media).forEach((path) => {
2543
2604
  unzippedOriginalDocx.file(path, media[path]);
2544
2605
  });
2545
- await this.updateContentTypes(unzippedOriginalDocx, media);
2606
+ await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
2546
2607
  return unzippedOriginalDocx;
2547
2608
  }
2548
2609
  }
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  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, 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, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as SelectionRange, ao as Transform, ap as isInTable$1, aq as generateDocxRandomId, ar as insertNewRelationship, as as updateDOMAttributes, at as htmlHandler } from "./converter-3xnF_NHq.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as SelectionRange, ao as Transform, ap as isInTable$1, aq as generateDocxRandomId, ar as insertNewRelationship, as as updateDOMAttributes, at as htmlHandler } from "./converter-D7lP9y8P.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-CZdELYi-.js";
17
+ import { D as DocxZipper } from "./docx-zipper-_TMbHpUQ.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -11675,9 +11675,11 @@ const toggleHeaderFooterEditMode = ({ editor, focusedSectionEditor, isEditMode,
11675
11675
  item.editor.view.dom.setAttribute("documentmode", documentMode);
11676
11676
  });
11677
11677
  if (isEditMode) {
11678
- const pm = document.querySelector(".ProseMirror");
11679
- pm.classList.add("header-footer-edit");
11680
- pm.setAttribute("aria-readonly", true);
11678
+ const pm = editor.view?.dom || editor.options.element?.querySelector?.(".ProseMirror");
11679
+ if (pm) {
11680
+ pm.classList.add("header-footer-edit");
11681
+ pm.setAttribute("aria-readonly", true);
11682
+ }
11681
11683
  }
11682
11684
  if (focusedSectionEditor) {
11683
11685
  focusedSectionEditor.view.focus();
@@ -12707,6 +12709,7 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state }) =>
12707
12709
  const mappedRowStart = tr.mapping.map(absoluteRowStart);
12708
12710
  const rowEnd = mappedRowStart + rowNode.nodeSize;
12709
12711
  tr.replaceWith(mappedRowStart, rowEnd, Fragment.from(newRows));
12712
+ tr.setMeta("tableGeneration", true);
12710
12713
  } catch (error) {
12711
12714
  console.error("Error during row generation:", error);
12712
12715
  throw error;
@@ -13111,7 +13114,7 @@ function findFieldAnnotationsBetween(from2, to, doc2) {
13111
13114
  }
13112
13115
  function findRemovedFieldAnnotations(tr) {
13113
13116
  let removedNodes = [];
13114
- if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true) {
13117
+ if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true || tr.getMeta("tableGeneration") === true) {
13115
13118
  return removedNodes;
13116
13119
  }
13117
13120
  const hasDeletion = transactionDeletedAnything(tr);
@@ -14332,7 +14335,7 @@ const _Editor = class _Editor extends EventEmitter {
14332
14335
  setDocumentMode(documentMode) {
14333
14336
  let cleanedMode = documentMode?.toLowerCase() || "editing";
14334
14337
  if (!this.extensionService || !this.state) return;
14335
- const pm = document.querySelector(".ProseMirror");
14338
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
14336
14339
  if (this.options.role === "viewer") cleanedMode = "viewing";
14337
14340
  if (this.options.role === "suggester" && cleanedMode === "editing") cleanedMode = "suggesting";
14338
14341
  if (cleanedMode === "viewing") {
@@ -14562,6 +14565,8 @@ const _Editor = class _Editor extends EventEmitter {
14562
14565
  element.style.isolation = "isolate";
14563
14566
  proseMirror.style.outline = "none";
14564
14567
  proseMirror.style.border = "none";
14568
+ element.style.backgroundColor = "#fff";
14569
+ proseMirror.style.backgroundColor = "#fff";
14565
14570
  const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
14566
14571
  const resolvedFontFamily = fontFamilyCss || typeface;
14567
14572
  if (resolvedFontFamily) {
@@ -14818,7 +14823,8 @@ const _Editor = class _Editor extends EventEmitter {
14818
14823
  files: this.options.content
14819
14824
  },
14820
14825
  media,
14821
- true
14826
+ true,
14827
+ updatedDocs
14822
14828
  );
14823
14829
  return updatedDocs;
14824
14830
  }
@@ -14884,7 +14890,7 @@ const _Editor = class _Editor extends EventEmitter {
14884
14890
  * @returns {Object | void} Migration results
14885
14891
  */
14886
14892
  processCollaborationMigrations() {
14887
- console.debug("[checkVersionMigrations] Current editor version", "0.20.2");
14893
+ console.debug("[checkVersionMigrations] Current editor version", "0.21.2");
14888
14894
  if (!this.options.ydoc) return;
14889
14895
  const metaMap = this.options.ydoc.getMap("meta");
14890
14896
  let docVersion = metaMap.get("version");
@@ -15378,9 +15384,11 @@ createView_fn = function(element) {
15378
15384
  isEditMode: false,
15379
15385
  documentMode: this.options.documentMode
15380
15386
  });
15381
- const pm = document.querySelector(".ProseMirror");
15382
- pm.classList.remove("header-footer-edit");
15383
- pm.setAttribute("aria-readonly", false);
15387
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
15388
+ if (pm) {
15389
+ pm.classList.remove("header-footer-edit");
15390
+ pm.setAttribute("aria-readonly", false);
15391
+ }
15384
15392
  }
15385
15393
  setWordSelection(view, pos);
15386
15394
  }
@@ -17478,6 +17486,30 @@ const intToJapaneseCounting = (num) => {
17478
17486
  }
17479
17487
  return result;
17480
17488
  };
17489
+ const isKeyboardInvocation = (event) => {
17490
+ return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
17491
+ };
17492
+ const prefersNativeMenu = (event) => {
17493
+ if (!event) return false;
17494
+ if (event.ctrlKey || event.metaKey) {
17495
+ return true;
17496
+ }
17497
+ return isKeyboardInvocation(event);
17498
+ };
17499
+ const shouldAllowNativeContextMenu = (event) => {
17500
+ return prefersNativeMenu(event);
17501
+ };
17502
+ const shouldBypassContextMenu = shouldAllowNativeContextMenu;
17503
+ const DEFAULT_SELECTION_STATE = Object.freeze({
17504
+ focused: false,
17505
+ preservedSelection: null,
17506
+ showVisualSelection: false,
17507
+ skipFocusReset: false
17508
+ });
17509
+ const normalizeSelectionState = (state = {}) => ({
17510
+ ...DEFAULT_SELECTION_STATE,
17511
+ ...state
17512
+ });
17481
17513
  const CustomSelectionPluginKey = new PluginKey("CustomSelection");
17482
17514
  const handleClickOutside = (event, editor) => {
17483
17515
  const editorElem = editor?.options?.element;
@@ -17515,11 +17547,7 @@ const CustomSelection = Extension.create({
17515
17547
  const customSelectionPlugin = new Plugin({
17516
17548
  key: CustomSelectionPluginKey,
17517
17549
  state: {
17518
- init: () => ({
17519
- focused: false,
17520
- preservedSelection: null,
17521
- showVisualSelection: false
17522
- }),
17550
+ init: () => ({ ...DEFAULT_SELECTION_STATE }),
17523
17551
  apply: (tr, value) => {
17524
17552
  const meta = getFocusMeta(tr);
17525
17553
  if (meta !== void 0) {
@@ -17540,6 +17568,9 @@ const CustomSelection = Extension.create({
17540
17568
  props: {
17541
17569
  handleDOMEvents: {
17542
17570
  contextmenu: (view, event) => {
17571
+ if (shouldAllowNativeContextMenu(event)) {
17572
+ return false;
17573
+ }
17543
17574
  event.preventDefault();
17544
17575
  const { selection } = view.state;
17545
17576
  if (!selection.empty) {
@@ -17547,7 +17578,8 @@ const CustomSelection = Extension.create({
17547
17578
  setFocusMeta(view.state.tr, {
17548
17579
  focused: true,
17549
17580
  preservedSelection: selection,
17550
- showVisualSelection: true
17581
+ showVisualSelection: true,
17582
+ skipFocusReset: true
17551
17583
  })
17552
17584
  );
17553
17585
  }
@@ -17558,6 +17590,9 @@ const CustomSelection = Extension.create({
17558
17590
  },
17559
17591
  mousedown: (view, event) => {
17560
17592
  if (event.button === 2) {
17593
+ if (shouldAllowNativeContextMenu(event)) {
17594
+ return false;
17595
+ }
17561
17596
  event.preventDefault();
17562
17597
  const { selection: selection2 } = view.state;
17563
17598
  if (!selection2.empty) {
@@ -17565,7 +17600,8 @@ const CustomSelection = Extension.create({
17565
17600
  setFocusMeta(view.state.tr, {
17566
17601
  focused: true,
17567
17602
  preservedSelection: selection2,
17568
- showVisualSelection: true
17603
+ showVisualSelection: true,
17604
+ skipFocusReset: true
17569
17605
  })
17570
17606
  );
17571
17607
  this.editor.setOptions({
@@ -17588,7 +17624,8 @@ const CustomSelection = Extension.create({
17588
17624
  setFocusMeta(view.state.tr, {
17589
17625
  focused: true,
17590
17626
  preservedSelection: selection,
17591
- showVisualSelection: true
17627
+ showVisualSelection: true,
17628
+ skipFocusReset: false
17592
17629
  })
17593
17630
  );
17594
17631
  this.editor.setOptions({
@@ -17606,7 +17643,8 @@ const CustomSelection = Extension.create({
17606
17643
  setFocusMeta(view.state.tr, {
17607
17644
  focused: true,
17608
17645
  preservedSelection: selection,
17609
- showVisualSelection: true
17646
+ showVisualSelection: true,
17647
+ skipFocusReset: false
17610
17648
  })
17611
17649
  );
17612
17650
  }
@@ -17617,7 +17655,8 @@ const CustomSelection = Extension.create({
17617
17655
  setFocusMeta(view.state.tr, {
17618
17656
  focused: false,
17619
17657
  preservedSelection: null,
17620
- showVisualSelection: false
17658
+ showVisualSelection: false,
17659
+ skipFocusReset: false
17621
17660
  })
17622
17661
  );
17623
17662
  if (!selection.empty && !this.editor.options.element?.contains(target)) {
@@ -17634,12 +17673,20 @@ const CustomSelection = Extension.create({
17634
17673
  const isElement2 = target instanceof Element;
17635
17674
  const isToolbarBtn = isElement2 && isToolbarButton(target);
17636
17675
  const isToolbarInp = isElement2 && isToolbarInput(target);
17676
+ const focusState = getFocusState(view.state);
17677
+ if (focusState?.skipFocusReset) {
17678
+ view.dispatch(
17679
+ setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
17680
+ );
17681
+ return false;
17682
+ }
17637
17683
  if (!isToolbarBtn && !isToolbarInp) {
17638
17684
  view.dispatch(
17639
17685
  setFocusMeta(view.state.tr, {
17640
17686
  focused: false,
17641
17687
  preservedSelection: null,
17642
- showVisualSelection: false
17688
+ showVisualSelection: false,
17689
+ skipFocusReset: false
17643
17690
  })
17644
17691
  );
17645
17692
  }
@@ -17650,12 +17697,16 @@ const CustomSelection = Extension.create({
17650
17697
  const isToolbarBtn = isElement2 && isToolbarButton(target);
17651
17698
  const isToolbarInp = isElement2 && isToolbarInput(target);
17652
17699
  const state = getFocusState(view.state);
17700
+ if (state?.skipFocusReset) {
17701
+ return false;
17702
+ }
17653
17703
  if (isToolbarBtn || isToolbarInp) {
17654
17704
  view.dispatch(
17655
17705
  setFocusMeta(view.state.tr, {
17656
17706
  focused: true,
17657
17707
  preservedSelection: state.preservedSelection || view.state.selection,
17658
- showVisualSelection: true
17708
+ showVisualSelection: true,
17709
+ skipFocusReset: false
17659
17710
  })
17660
17711
  );
17661
17712
  } else {
@@ -17663,7 +17714,8 @@ const CustomSelection = Extension.create({
17663
17714
  setFocusMeta(view.state.tr, {
17664
17715
  focused: false,
17665
17716
  preservedSelection: null,
17666
- showVisualSelection: false
17717
+ showVisualSelection: false,
17718
+ skipFocusReset: false
17667
17719
  })
17668
17720
  );
17669
17721
  }
@@ -33438,7 +33490,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
33438
33490
  const prevSelection = prevState.selection;
33439
33491
  if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
33440
33492
  setTimeout(() => {
33441
- const selectedResizableWrapper = document.querySelector(".sd-editor-resizable-wrapper");
33493
+ const searchRoot = editorView?.dom;
33494
+ const selectedResizableWrapper = searchRoot?.querySelector(".sd-editor-resizable-wrapper");
33442
33495
  if (selectedResizableWrapper) {
33443
33496
  showResizeHandles(view2, selectedResizableWrapper);
33444
33497
  } else {
@@ -33752,6 +33805,7 @@ export {
33752
33805
  SectionHelpers as o,
33753
33806
  getAllowedImageDimensions as p,
33754
33807
  replaceSelectionWithImagePlaceholder as r,
33808
+ shouldBypassContextMenu as s,
33755
33809
  useHighContrastMode as u,
33756
33810
  yUndoPluginKey as y
33757
33811
  };
@@ -1,6 +1,6 @@
1
1
  import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
2
- import { p as process$1 } from "./converter-3xnF_NHq.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-BqYH4kDD.js";
2
+ import { p as process$1 } from "./converter-D7lP9y8P.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-BuT5uWdz.js";
4
4
  const sanitizeNumber = (value, defaultNumber) => {
5
5
  let sanitized = value.replace(/[^0-9.]/g, "");
6
6
  sanitized = parseFloat(sanitized);
@@ -1,4 +1,4 @@
1
- import { a5 } from "./chunks/converter-3xnF_NHq.js";
1
+ import { a5 } from "./chunks/converter-D7lP9y8P.js";
2
2
  import "vue";
3
3
  export {
4
4
  a5 as SuperConverter
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-3xnF_NHq.js";
2
- import { D } from "./chunks/docx-zipper-CZdELYi-.js";
1
+ import "./chunks/converter-D7lP9y8P.js";
2
+ import { D } from "./chunks/docx-zipper-_TMbHpUQ.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-BqYH4kDD.js";
2
- import "./chunks/converter-3xnF_NHq.js";
3
- import "./chunks/docx-zipper-CZdELYi-.js";
1
+ import { E } from "./chunks/editor-BuT5uWdz.js";
2
+ import "./chunks/converter-D7lP9y8P.js";
3
+ import "./chunks/docx-zipper-_TMbHpUQ.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-CZdELYi-.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-_TMbHpUQ.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {
@@ -14,7 +14,9 @@
14
14
  * requiresClipboard?: boolean
15
15
  * requiresTableParent?: boolean
16
16
  * requiredSectionParent?: boolean,
17
- * requiresModule?: string
17
+ * requiresModule?: string,
18
+ * render?: (context: Object) => HTMLElement,
19
+ * showWhen?: (context: Object) => boolean
18
20
  * }>
19
21
  * }>} Array of menu sections
20
22
  */
@@ -32,5 +34,7 @@ export function getItems(context: any): Array<{
32
34
  requiresTableParent?: boolean;
33
35
  requiredSectionParent?: boolean;
34
36
  requiresModule?: string;
37
+ render?: (context: any) => HTMLElement;
38
+ showWhen?: (context: any) => boolean;
35
39
  }>;
36
40
  }>;