@harbour-enterprises/superdoc 0.22.1 → 0.23.0-next.10

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 (77) hide show
  1. package/dist/chunks/{PdfViewer-D2BPnEBG.cjs → PdfViewer-BsnSIYxD.cjs} +2 -2
  2. package/dist/chunks/{PdfViewer-CBmOiHsj.es.js → PdfViewer-CPZ7QD5u.es.js} +2 -2
  3. package/dist/chunks/{eventemitter3-CZv6vEhA.es.js → eventemitter3-CR2eBWft.es.js} +1 -1
  4. package/dist/chunks/{eventemitter3-B_kO1Pxm.cjs → eventemitter3-DSRogsNq.cjs} +1 -1
  5. package/dist/chunks/{index-BSDcfSFc.es.js → index-Cd9h9gMj.es.js} +32 -22
  6. package/dist/chunks/{index-B0CI50e4.cjs → index-DOd9uvCv.cjs} +32 -22
  7. package/dist/chunks/{jszip-b7l8QkfH.cjs → jszip-B4LDL19y.cjs} +1 -1
  8. package/dist/chunks/{jszip-B8KIZSNe.es.js → jszip-DAXEPCUv.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-DOOwW-Iv.cjs → super-editor.es-DAS3_Nt9.cjs} +1786 -1085
  10. package/dist/chunks/{super-editor.es-BW1T3N2-.es.js → super-editor.es-l3dTZlZX.es.js} +1786 -1085
  11. package/dist/chunks/{vue-DWle4Cai.cjs → vue-DKMj1I9B.cjs} +39 -42
  12. package/dist/chunks/{vue-CXxsqYcP.es.js → vue-ZWZLQtoU.es.js} +39 -42
  13. package/dist/chunks/xml-js-Bbc0NeKa.es.js +2 -0
  14. package/dist/chunks/xml-js-CWV8R-ek.cjs +3 -0
  15. package/dist/core/SuperDoc.d.ts +5 -18
  16. package/dist/core/SuperDoc.d.ts.map +1 -1
  17. package/dist/core/types/index.d.ts +29 -1
  18. package/dist/core/types/index.d.ts.map +1 -1
  19. package/dist/stores/superdoc-store.d.ts.map +1 -1
  20. package/dist/style.css +76 -54
  21. package/dist/super-editor/ai-writer.es.js +2 -2
  22. package/dist/super-editor/chunks/{converter-UuZxU-p8.js → converter-ClnqoStR.js} +1476 -1043
  23. package/dist/super-editor/chunks/{docx-zipper-Bss48sB0.js → docx-zipper-DC28ucAi.js} +1 -1
  24. package/dist/super-editor/chunks/{editor--v3HbUU0.js → editor-B2aHhS9B.js} +310 -42
  25. package/dist/super-editor/chunks/{toolbar-BeXlvdV8.js → toolbar-Cgyf_4bW.js} +4 -4
  26. package/dist/super-editor/converter.es.js +1 -1
  27. package/dist/super-editor/docx-zipper.es.js +2 -2
  28. package/dist/super-editor/editor.es.js +3 -3
  29. package/dist/super-editor/file-zipper.es.js +1 -1
  30. package/dist/super-editor/src/core/Attribute.d.ts +2 -2
  31. package/dist/super-editor/src/core/Schema.d.ts +2 -2
  32. package/dist/super-editor/src/core/super-converter/exporter.d.ts +4 -4
  33. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/hyperlink-preprocessor.d.ts +9 -0
  34. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/index.d.ts +2 -0
  35. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +9 -0
  36. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +9 -0
  37. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +9 -0
  38. package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/toc-preprocessor.d.ts +8 -0
  39. package/dist/super-editor/src/core/super-converter/field-references/index.d.ts +1 -0
  40. package/dist/super-editor/src/core/super-converter/field-references/preProcessNodesForFldChar.d.ts +21 -0
  41. package/dist/super-editor/src/core/super-converter/v2/exporter/helpers/translateChildNodes.d.ts +3 -3
  42. package/dist/super-editor/src/core/super-converter/v2/importer/pageReferenceImporter.d.ts +4 -0
  43. package/dist/super-editor/src/core/super-converter/v2/importer/tableOfContentsImporter.d.ts +4 -0
  44. package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +7 -1
  45. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/index.d.ts +1 -0
  46. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/pageReference-translator.d.ts +7 -0
  47. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/index.d.ts +1 -0
  48. package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/tableOfContents-translator.d.ts +10 -0
  49. package/dist/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +7 -0
  50. package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -2
  51. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/handle-doc-part-obj.d.ts +9 -1
  52. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.d.ts +6 -0
  53. package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -2
  54. package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +4 -0
  55. package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +1 -0
  56. package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +5 -0
  57. package/dist/super-editor/src/extensions/page-reference/index.d.ts +1 -0
  58. package/dist/super-editor/src/extensions/page-reference/page-reference.d.ts +2 -0
  59. package/dist/super-editor/src/extensions/structured-content/document-part-object.d.ts +2 -0
  60. package/dist/super-editor/src/extensions/structured-content/index.d.ts +1 -0
  61. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsByAlias.d.ts +8 -0
  62. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
  63. package/dist/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +2 -2
  64. package/dist/super-editor/src/extensions/table-of-contents/index.d.ts +1 -0
  65. package/dist/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +2 -0
  66. package/dist/super-editor/style.css +49 -27
  67. package/dist/super-editor/super-editor.es.js +10 -8
  68. package/dist/super-editor/toolbar.es.js +2 -2
  69. package/dist/super-editor.cjs +2 -2
  70. package/dist/super-editor.es.js +2 -2
  71. package/dist/superdoc.cjs +4 -4
  72. package/dist/superdoc.es.js +4 -4
  73. package/dist/superdoc.umd.js +1846 -1135
  74. package/dist/superdoc.umd.js.map +1 -1
  75. package/package.json +1 -1
  76. package/dist/chunks/xml-js-CX8FH0He.cjs +0 -3
  77. package/dist/chunks/xml-js-D0tLGmKu.es.js +0 -2
@@ -1,4 +1,4 @@
1
- import { p as process$1, aw as commonjsGlobal, B as Buffer, ax as getDefaultExportFromCjs, ay as getContentTypesFromXml, az as xmljs } from "./converter-UuZxU-p8.js";
1
+ import { p as process$1, aw as commonjsGlobal, B as Buffer, ax as getDefaultExportFromCjs, ay as getContentTypesFromXml, az as xmljs } from "./converter-ClnqoStR.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
  }
@@ -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, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_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 updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as SelectionRange, as as Transform, at as isInTable$1, au as generateDocxRandomId, av as insertNewRelationship } from "./converter-UuZxU-p8.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 updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as SelectionRange, as as Transform, at as isInTable$1, au as generateDocxRandomId, av as insertNewRelationship } from "./converter-ClnqoStR.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-Bss48sB0.js";
17
+ import { D as DocxZipper } from "./docx-zipper-DC28ucAi.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -5034,8 +5034,7 @@ function readDOMChange(view, from2, to, typeOver, addedNodes) {
5034
5034
  let $to = parse.doc.resolveNoCache(change.endB - parse.from);
5035
5035
  let $fromA = doc2.resolve(change.start);
5036
5036
  let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
5037
- let nextSel;
5038
- if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")) && (nextSel = Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) && nextSel.head > $from.pos) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
5037
+ if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
5039
5038
  view.input.lastIOSEnter = 0;
5040
5039
  return;
5041
5040
  }
@@ -17357,6 +17356,17 @@ function getStructuredContentTagsById(idOrIds, state) {
17357
17356
  });
17358
17357
  return result;
17359
17358
  }
17359
+ function getStructuredContentTagsByAlias(aliasOrAliases, state) {
17360
+ const result = findChildren$5(state.doc, (node) => {
17361
+ const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
17362
+ if (Array.isArray(aliasOrAliases)) {
17363
+ return isStructuredContent && aliasOrAliases.includes(node.attrs.alias);
17364
+ } else {
17365
+ return isStructuredContent && node.attrs.alias === aliasOrAliases;
17366
+ }
17367
+ });
17368
+ return result;
17369
+ }
17360
17370
  function getStructuredContentTags(state) {
17361
17371
  const result = findChildren$5(state.doc, (node) => {
17362
17372
  return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
@@ -17376,6 +17386,7 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
17376
17386
  getStructuredContentBlockTags,
17377
17387
  getStructuredContentInlineTags,
17378
17388
  getStructuredContentTags,
17389
+ getStructuredContentTagsByAlias,
17379
17390
  getStructuredContentTagsById
17380
17391
  }, Symbol.toStringTag, { value: "Module" }));
17381
17392
  const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
@@ -17464,10 +17475,11 @@ const StructuredContentCommands = Extension.create({
17464
17475
  return true;
17465
17476
  },
17466
17477
  /**
17467
- * Updates a structured content attributes or content.
17478
+ * Updates a single structured content field by its unique ID.
17479
+ * IDs are unique identifiers, so this will update at most one field.
17468
17480
  * If the updated node does not match the schema, it will not be updated.
17469
17481
  * @category Command
17470
- * @param {string} id
17482
+ * @param {string} id - Unique identifier of the field
17471
17483
  * @param {StructuredContentUpdate} options
17472
17484
  */
17473
17485
  updateStructuredContentById: (id, options = {}) => ({ editor, dispatch, state, tr }) => {
@@ -17507,6 +17519,58 @@ const StructuredContentCommands = Extension.create({
17507
17519
  }
17508
17520
  return true;
17509
17521
  },
17522
+ /**
17523
+ * Updates all structured content fields with the same alias.
17524
+ * Unlike IDs (which are unique), aliases can be shared across multiple fields.
17525
+ * This will update every field that matches the given alias.
17526
+ * If any updated node does not match the schema, no updates will be applied.
17527
+ * @category Command
17528
+ * @param {string | string[]} alias - Shared identifier for fields (e.g., "customer_name")
17529
+ * @param {StructuredContentUpdate} options
17530
+ */
17531
+ updateStructuredContentByAlias: (alias, options = {}) => ({ editor, dispatch, state, tr }) => {
17532
+ const structuredContentTags = getStructuredContentTagsByAlias(alias, state);
17533
+ if (!structuredContentTags.length) {
17534
+ return true;
17535
+ }
17536
+ const { schema } = editor;
17537
+ const createContent = (node) => {
17538
+ if (options.text) {
17539
+ return schema.text(options.text);
17540
+ }
17541
+ if (options.html) {
17542
+ const html = htmlHandler(options.html, editor);
17543
+ const doc2 = DOMParser$1.fromSchema(schema).parse(html);
17544
+ return doc2.content;
17545
+ }
17546
+ if (options.json) {
17547
+ return schema.nodeFromJSON(options.json);
17548
+ }
17549
+ return node.content;
17550
+ };
17551
+ for (const { node } of structuredContentTags) {
17552
+ const content = createContent(node);
17553
+ const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
17554
+ try {
17555
+ updatedNode.check();
17556
+ } catch {
17557
+ console.error("Updated node does not conform to the schema");
17558
+ return false;
17559
+ }
17560
+ }
17561
+ if (dispatch) {
17562
+ structuredContentTags.forEach(({ pos, node }) => {
17563
+ const mappedPos = tr.mapping.map(pos);
17564
+ const currentNode = tr.doc.nodeAt(mappedPos);
17565
+ if (currentNode && node.eq(currentNode)) {
17566
+ const content = createContent(node);
17567
+ const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
17568
+ tr.replaceWith(mappedPos, mappedPos + node.nodeSize, updatedNode);
17569
+ }
17570
+ });
17571
+ }
17572
+ return true;
17573
+ },
17510
17574
  /**
17511
17575
  * Removes a structured content.
17512
17576
  * @category Command
@@ -17960,6 +18024,48 @@ const DocumentSection = Node$1.create({
17960
18024
  };
17961
18025
  }
17962
18026
  });
18027
+ const DocumentPartObject = Node$1.create({
18028
+ name: "documentPartObject",
18029
+ group: "block",
18030
+ content: "block*",
18031
+ isolating: true,
18032
+ addOptions() {
18033
+ return {
18034
+ htmlAttributes: {
18035
+ class: "sd-document-part-object-block",
18036
+ "aria-label": "Structured document part block"
18037
+ }
18038
+ };
18039
+ },
18040
+ parseDOM() {
18041
+ return [
18042
+ {
18043
+ tag: "div.sd-document-part-object-block",
18044
+ priority: 60
18045
+ }
18046
+ ];
18047
+ },
18048
+ renderDOM({ htmlAttributes }) {
18049
+ return ["div", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
18050
+ },
18051
+ addAttributes() {
18052
+ return {
18053
+ sdBlockId: {
18054
+ default: null,
18055
+ keepOnSplit: false,
18056
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
18057
+ renderDOM: (attrs) => {
18058
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
18059
+ }
18060
+ },
18061
+ id: {},
18062
+ docPartGallery: {},
18063
+ docPartUnique: {
18064
+ default: true
18065
+ }
18066
+ };
18067
+ }
18068
+ });
17963
18069
  const Document = Node$1.create({
17964
18070
  name: "doc",
17965
18071
  topNode: true,
@@ -19096,7 +19202,12 @@ const generateDecorations = (state, styles) => {
19096
19202
  return { ...base2, ...linkedStyle.definition?.styles || {} };
19097
19203
  };
19098
19204
  const pMap = buildStyleMap(paragraphStyleId);
19099
- const tMap = buildStyleMap(inlineTextStyleId);
19205
+ let tMap;
19206
+ if (paragraphStyleId?.startsWith("TOC")) {
19207
+ tMap = {};
19208
+ } else {
19209
+ tMap = buildStyleMap(inlineTextStyleId);
19210
+ }
19100
19211
  const rMap = buildStyleMap(runStyleId);
19101
19212
  const finalStyles = { ...pMap, ...tMap, ...rMap };
19102
19213
  if (Object.keys(finalStyles).length === 0) return;
@@ -20393,7 +20504,7 @@ const CommentsMark = Mark.create({
20393
20504
  });
20394
20505
  const defaultTabDistance = 48;
20395
20506
  const defaultLineLength = 816;
20396
- const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
20507
+ const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
20397
20508
  const decorations = [];
20398
20509
  const paragraphCache = /* @__PURE__ */ new Map();
20399
20510
  const end2 = to ?? doc2.content.size;
@@ -20401,7 +20512,7 @@ const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
20401
20512
  if (node.type.name !== "tab") return;
20402
20513
  let extraStyles = "";
20403
20514
  const $pos = doc2.resolve(pos);
20404
- const paragraphContext = getParagraphContext($pos, paragraphCache);
20515
+ const paragraphContext = getParagraphContext($pos, paragraphCache, helpers2);
20405
20516
  if (!paragraphContext) return;
20406
20517
  try {
20407
20518
  const { tabStops, flattened, startPos } = paragraphContext;
@@ -20456,18 +20567,27 @@ const getTabDecorations = (doc2, view, from2 = 0, to = null) => {
20456
20567
  });
20457
20568
  return decorations;
20458
20569
  };
20459
- function getParagraphContext($pos, cache) {
20570
+ function getParagraphContext($pos, cache, helpers2) {
20460
20571
  for (let depth = $pos.depth; depth >= 0; depth--) {
20461
20572
  const node = $pos.node(depth);
20462
20573
  if (node?.type?.name === "paragraph") {
20463
20574
  const startPos = $pos.start(depth);
20464
20575
  if (!cache.has(startPos)) {
20576
+ let tabStops = [];
20577
+ if (Array.isArray(node.attrs?.tabStops)) {
20578
+ tabStops = node.attrs.tabStops;
20579
+ } else {
20580
+ const style = helpers2.linkedStyles.getStyleById(node.attrs?.styleId);
20581
+ if (Array.isArray(style?.definition?.styles?.tabStops)) {
20582
+ tabStops = style.definition.styles.tabStops;
20583
+ }
20584
+ }
20465
20585
  cache.set(startPos, {
20466
20586
  paragraph: node,
20467
20587
  paragraphDepth: depth,
20468
20588
  startPos,
20469
20589
  indent: node.attrs?.indent || {},
20470
- tabStops: Array.isArray(node.attrs?.tabStops) ? node.attrs.tabStops : [],
20590
+ tabStops,
20471
20591
  flattened: flattenParagraph(node, startPos),
20472
20592
  accumulatedTabWidth: 0
20473
20593
  });
@@ -20633,7 +20753,7 @@ const TabNode = Node$1.create({
20633
20753
  };
20634
20754
  },
20635
20755
  addPmPlugins() {
20636
- const { view } = this.editor;
20756
+ const { view, helpers: helpers2 } = this.editor;
20637
20757
  const tabPlugin = new Plugin({
20638
20758
  name: "tabPlugin",
20639
20759
  key: new PluginKey("tabPlugin"),
@@ -20643,7 +20763,7 @@ const TabNode = Node$1.create({
20643
20763
  },
20644
20764
  apply(tr, { decorations }, _oldState, newState) {
20645
20765
  if (!decorations) {
20646
- decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view));
20766
+ decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view, helpers2));
20647
20767
  }
20648
20768
  if (!tr.docChanged) {
20649
20769
  return { decorations };
@@ -20683,7 +20803,7 @@ const TabNode = Node$1.create({
20683
20803
  rangesToRecalculate.forEach(([start2, end2]) => {
20684
20804
  const oldDecorations = decorations.find(start2, end2);
20685
20805
  decorations = decorations.remove(oldDecorations);
20686
- const newDecorations = getTabDecorations(newState.doc, view, start2, end2);
20806
+ const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
20687
20807
  decorations = decorations.add(newState.doc, newDecorations);
20688
20808
  });
20689
20809
  return { decorations };
@@ -25592,6 +25712,7 @@ function getFormatAttrsFromMarks(marks) {
25592
25712
  }
25593
25713
  return formatAttrs;
25594
25714
  }
25715
+ const DEFAULT_MIME_TYPE = "application/octet-stream";
25595
25716
  const simpleHash = (str) => {
25596
25717
  let hash2 = 0;
25597
25718
  for (let i = 0; i < str.length; i++) {
@@ -25601,21 +25722,40 @@ const simpleHash = (str) => {
25601
25722
  }
25602
25723
  return Math.abs(hash2).toString();
25603
25724
  };
25604
- const base64ToFile = (base64String) => {
25605
- const arr = base64String.split(",");
25606
- const mimeMatch = arr[0].match(/:(.*?);/);
25607
- const mimeType = mimeMatch ? mimeMatch[1] : "";
25608
- const data = arr[1];
25609
- const binaryString = atob(data);
25725
+ const decodeBase64ToBinaryString = (data) => {
25726
+ if (!data) return "";
25727
+ if (typeof atob === "function") {
25728
+ return atob(data);
25729
+ }
25730
+ if (typeof Buffer2 !== "undefined" && typeof Buffer2.from === "function") {
25731
+ return Buffer2.from(data, "base64").toString("binary");
25732
+ }
25733
+ throw new Error("Unable to decode base64 payload in the current environment.");
25734
+ };
25735
+ const extractBase64Meta = (base64String) => {
25736
+ const [meta = "", payload = ""] = base64String.split(",");
25737
+ const mimeMatch = meta.match(/:(.*?);/);
25738
+ const rawMimeType = mimeMatch ? mimeMatch[1] : "";
25739
+ const mimeType = rawMimeType || DEFAULT_MIME_TYPE;
25740
+ const binaryString = decodeBase64ToBinaryString(payload);
25610
25741
  const hash2 = simpleHash(binaryString);
25611
25742
  const extension = mimeType.split("/")[1] || "bin";
25612
25743
  const filename = `image-${hash2}.${extension}`;
25744
+ return { mimeType, binaryString, filename };
25745
+ };
25746
+ const getBase64FileMeta = (base64String) => {
25747
+ const { mimeType, filename } = extractBase64Meta(base64String);
25748
+ return { mimeType, filename };
25749
+ };
25750
+ const base64ToFile = (base64String) => {
25751
+ const { mimeType, binaryString, filename } = extractBase64Meta(base64String);
25752
+ const fileType = mimeType || DEFAULT_MIME_TYPE;
25613
25753
  const bytes = new Uint8Array(binaryString.length);
25614
25754
  for (let i = 0; i < binaryString.length; i++) {
25615
25755
  bytes[i] = binaryString.charCodeAt(i);
25616
25756
  }
25617
- const blob = new Blob([bytes], { type: mimeType });
25618
- return new File([blob], filename, { type: mimeType });
25757
+ const blob = new Blob([bytes], { type: fileType });
25758
+ return new File([blob], filename, { type: fileType });
25619
25759
  };
25620
25760
  const urlToFile = async (url, filename, mimeType) => {
25621
25761
  try {
@@ -25991,6 +26131,7 @@ function addImageRelationship({ editor, path }) {
25991
26131
  }
25992
26132
  }
25993
26133
  const key = new PluginKey("ImageRegistration");
26134
+ const WORD_MEDIA_PREFIX = "word/";
25994
26135
  const ImageRegistrationPlugin = ({ editor }) => {
25995
26136
  const { view } = editor;
25996
26137
  return new Plugin({
@@ -26011,16 +26152,16 @@ const ImageRegistrationPlugin = ({ editor }) => {
26011
26152
  },
26012
26153
  appendTransaction: (trs, _oldState, state) => {
26013
26154
  let foundImages = [];
26014
- trs.forEach((tr2) => {
26015
- if (tr2.docChanged) {
26016
- tr2.steps.forEach((step, index2) => {
26155
+ trs.forEach((tr) => {
26156
+ if (tr.docChanged) {
26157
+ tr.steps.forEach((step, index2) => {
26017
26158
  const stepMap = step.getMap();
26018
26159
  foundImages = foundImages.map(({ node, pos, id }) => {
26019
26160
  const mappedPos = stepMap.map(pos, -1);
26020
26161
  return { node, pos: mappedPos, id };
26021
26162
  });
26022
26163
  if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
26023
- (tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
26164
+ (tr.docs[index2 + 1] || tr.doc).nodesBetween(
26024
26165
  stepMap.map(step.from, -1),
26025
26166
  stepMap.map(step.to, 1),
26026
26167
  (node, pos) => {
@@ -26039,22 +26180,10 @@ const ImageRegistrationPlugin = ({ editor }) => {
26039
26180
  if (!foundImages || foundImages.length === 0) {
26040
26181
  return null;
26041
26182
  }
26042
- registerImages(foundImages, editor, view);
26043
- const tr = state.tr;
26044
- let { set } = key.getState(state);
26045
- foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
26046
- let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
26047
- side: -1,
26048
- id
26049
- });
26050
- set = set.add(tr.doc, [deco]);
26051
- });
26052
- foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
26053
- tr.delete(pos, pos + node.nodeSize);
26054
- });
26055
- set = set.map(tr.mapping, tr.doc);
26056
- tr.setMeta(key, { set });
26057
- return tr;
26183
+ if (editor.options.isHeadless) {
26184
+ return handleNodePath(foundImages, editor, state);
26185
+ }
26186
+ return handleBrowserPath(foundImages, editor, view, state);
26058
26187
  },
26059
26188
  props: {
26060
26189
  decorations(state) {
@@ -26064,6 +26193,59 @@ const ImageRegistrationPlugin = ({ editor }) => {
26064
26193
  }
26065
26194
  });
26066
26195
  };
26196
+ const derivePreferredFileName = (src) => {
26197
+ if (typeof src !== "string" || src.length === 0) {
26198
+ return "image.bin";
26199
+ }
26200
+ if (src.startsWith("data:")) {
26201
+ return getBase64FileMeta(src).filename;
26202
+ }
26203
+ const lastSegment = src.split("/").pop() ?? "";
26204
+ const trimmed = lastSegment.split(/[?#]/)[0];
26205
+ return trimmed || "image.bin";
26206
+ };
26207
+ const handleNodePath = (foundImages, editor, state) => {
26208
+ const { tr } = state;
26209
+ const mediaStore = editor.storage.image.media ?? {};
26210
+ if (!editor.storage.image.media) {
26211
+ editor.storage.image.media = mediaStore;
26212
+ }
26213
+ const existingFileNames = new Set(Object.keys(mediaStore).map((key2) => key2.split("/").pop()));
26214
+ foundImages.forEach(({ node, pos }) => {
26215
+ const { src } = node.attrs;
26216
+ const preferredFileName = derivePreferredFileName(src);
26217
+ const uniqueFileName = ensureUniqueFileName(preferredFileName, existingFileNames);
26218
+ existingFileNames.add(uniqueFileName);
26219
+ const mediaPath = buildMediaPath(uniqueFileName);
26220
+ mediaStore[mediaPath] = src;
26221
+ const path = mediaPath.startsWith(WORD_MEDIA_PREFIX) ? mediaPath.slice(WORD_MEDIA_PREFIX.length) : mediaPath;
26222
+ const rId = addImageRelationship({ editor, path });
26223
+ tr.setNodeMarkup(pos, void 0, {
26224
+ ...node.attrs,
26225
+ src: mediaPath,
26226
+ rId
26227
+ });
26228
+ });
26229
+ return tr;
26230
+ };
26231
+ const handleBrowserPath = (foundImages, editor, view, state) => {
26232
+ registerImages(foundImages, editor, view);
26233
+ const tr = state.tr;
26234
+ let { set } = key.getState(state);
26235
+ foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
26236
+ let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
26237
+ side: -1,
26238
+ id
26239
+ });
26240
+ set = set.add(tr.doc, [deco]);
26241
+ });
26242
+ foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
26243
+ tr.delete(pos, pos + node.nodeSize);
26244
+ });
26245
+ set = set.map(tr.mapping, tr.doc);
26246
+ tr.setMeta(key, { set });
26247
+ return tr;
26248
+ };
26067
26249
  const findPlaceholder = (state, id) => {
26068
26250
  let { set } = key.getState(state);
26069
26251
  let found = set?.find(null, null, (spec) => spec.id === id);
@@ -26964,6 +27146,43 @@ const processMarks = (marks) => {
26964
27146
  });
26965
27147
  return styles;
26966
27148
  };
27149
+ const PageReference = Node$1.create({
27150
+ name: "pageReference",
27151
+ group: "inline",
27152
+ inline: true,
27153
+ atom: true,
27154
+ draggable: false,
27155
+ selectable: false,
27156
+ content: "inline*",
27157
+ addOptions() {
27158
+ return {
27159
+ htmlAttributes: {
27160
+ contenteditable: false,
27161
+ "data-id": "auto-page-reference",
27162
+ "aria-label": "Page reference node",
27163
+ class: "sd-editor-page-reference"
27164
+ }
27165
+ };
27166
+ },
27167
+ addAttributes() {
27168
+ return {
27169
+ marksAsAttrs: {
27170
+ default: null,
27171
+ rendered: false
27172
+ },
27173
+ instruction: {
27174
+ default: "",
27175
+ rendered: false
27176
+ }
27177
+ };
27178
+ },
27179
+ parseDOM() {
27180
+ return [{ tag: 'span[data-id="auto-page-reference"]' }];
27181
+ },
27182
+ renderDOM({ htmlAttributes }) {
27183
+ return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
27184
+ }
27185
+ });
26967
27186
  const ShapeContainer = Node$1.create({
26968
27187
  name: "shapeContainer",
26969
27188
  group: "block",
@@ -27377,6 +27596,51 @@ const checkForNewBlockNodesInTrs = (transactions) => {
27377
27596
  });
27378
27597
  });
27379
27598
  };
27599
+ const TableOfContents = Node$1.create({
27600
+ name: "tableOfContents",
27601
+ group: "block",
27602
+ content: "paragraph+",
27603
+ inline: false,
27604
+ addOptions() {
27605
+ return {
27606
+ htmlAttributes: {
27607
+ "data-id": "table-of-contents",
27608
+ "aria-label": "Table of Contents"
27609
+ }
27610
+ };
27611
+ },
27612
+ parseDOM() {
27613
+ return [
27614
+ {
27615
+ tag: 'div[data-id="table-of-contents"]'
27616
+ }
27617
+ ];
27618
+ },
27619
+ renderDOM({ htmlAttributes }) {
27620
+ return ["div", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
27621
+ },
27622
+ addAttributes() {
27623
+ return {
27624
+ instruction: {
27625
+ default: null,
27626
+ rendered: false
27627
+ },
27628
+ /**
27629
+ * @private
27630
+ * @category Attribute
27631
+ * @param {string} [sdBlockId] - Internal block tracking ID (not user-configurable)
27632
+ */
27633
+ sdBlockId: {
27634
+ default: null,
27635
+ keepOnSplit: false,
27636
+ parseDOM: (elem) => elem.getAttribute("data-sd-block-id"),
27637
+ renderDOM: (attrs) => {
27638
+ return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
27639
+ }
27640
+ }
27641
+ };
27642
+ }
27643
+ });
27380
27644
  const TextStyle = Mark.create({
27381
27645
  name: "textStyle",
27382
27646
  addOptions() {
@@ -33099,6 +33363,7 @@ function getActualBreakCoords(view, pos, calculatedThreshold) {
33099
33363
  return actualBreak;
33100
33364
  }
33101
33365
  const onImageLoad = (editor) => {
33366
+ if (typeof requestAnimationFrame !== "function") return;
33102
33367
  requestAnimationFrame(() => {
33103
33368
  const newTr = editor.view.state.tr;
33104
33369
  newTr.setMeta("forceUpdatePagination", true);
@@ -33983,6 +34248,7 @@ const getStarterExtensions = () => {
33983
34248
  SlashMenu,
33984
34249
  Strike,
33985
34250
  TabNode,
34251
+ TableOfContents,
33986
34252
  Text,
33987
34253
  TextAlign,
33988
34254
  TextIndent,
@@ -34017,6 +34283,7 @@ const getStarterExtensions = () => {
34017
34283
  AiLoaderNode,
34018
34284
  PageNumber,
34019
34285
  TotalPageCount,
34286
+ PageReference,
34020
34287
  ShapeContainer,
34021
34288
  ShapeTextbox,
34022
34289
  ContentBlock,
@@ -34025,6 +34292,7 @@ const getStarterExtensions = () => {
34025
34292
  StructuredContentBlock,
34026
34293
  StructuredContentCommands,
34027
34294
  DocumentSection,
34295
+ DocumentPartObject,
34028
34296
  NodeResizer,
34029
34297
  CustomSelection,
34030
34298
  TextTransform
@@ -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-UuZxU-p8.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor--v3HbUU0.js";
2
+ import { p as process$1 } from "./converter-ClnqoStR.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-B2aHhS9B.js";
4
4
  const sanitizeNumber = (value, defaultNumber) => {
5
5
  let sanitized = value.replace(/[^0-9.]/g, "");
6
6
  sanitized = parseFloat(sanitized);
@@ -278,7 +278,7 @@ const _sfc_main$4 = {
278
278
  };
279
279
  const handleInputSubmit = () => {
280
280
  const value = inlineTextInput.value;
281
- const cleanValue = value.replace(/[^0-9]/g, "");
281
+ const cleanValue = value.match(/^\d+(\.5)?$/) ? value : Math.floor(parseFloat(value)).toString();
282
282
  emit("textSubmit", cleanValue);
283
283
  inlineTextInput.value = cleanValue;
284
284
  };
@@ -360,7 +360,7 @@ const _sfc_main$4 = {
360
360
  };
361
361
  }
362
362
  };
363
- const ToolbarButton = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-303b3245"]]);
363
+ const ToolbarButton = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-cea02a58"]]);
364
364
  const _hoisted_1$2 = {
365
365
  class: "toolbar-separator",
366
366
  role: "separator",
@@ -1,4 +1,4 @@
1
- import { a5 } from "./chunks/converter-UuZxU-p8.js";
1
+ import { a5 } from "./chunks/converter-ClnqoStR.js";
2
2
  import "vue";
3
3
  export {
4
4
  a5 as SuperConverter
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-UuZxU-p8.js";
2
- import { D } from "./chunks/docx-zipper-Bss48sB0.js";
1
+ import "./chunks/converter-ClnqoStR.js";
2
+ import { D } from "./chunks/docx-zipper-DC28ucAi.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor--v3HbUU0.js";
2
- import "./chunks/converter-UuZxU-p8.js";
3
- import "./chunks/docx-zipper-Bss48sB0.js";
1
+ import { E } from "./chunks/editor-B2aHhS9B.js";
2
+ import "./chunks/converter-ClnqoStR.js";
3
+ import "./chunks/docx-zipper-DC28ucAi.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-Bss48sB0.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-DC28ucAi.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {
@@ -15,14 +15,14 @@ export class Attribute {
15
15
  * @param defaultAttribute Default attribute.
16
16
  * @returns Global extension attributes.
17
17
  */
18
- static #getGlobalAttributes(extensions: any, defaultAttribute: any): any[];
18
+ static "__#private@#getGlobalAttributes"(extensions: any, defaultAttribute: any): any[];
19
19
  /**
20
20
  * Get a list of attributes defined in the Node and Mark extensions.
21
21
  * @param extensions List of all extensions.
22
22
  * @param defaultAttribute Default attribute.
23
23
  * @returns Node and Mark extension attributes.
24
24
  */
25
- static #getNodeAndMarksAttributes(extensions: any, defaultAttribute: any): {
25
+ static "__#private@#getNodeAndMarksAttributes"(extensions: any, defaultAttribute: any): {
26
26
  type: any;
27
27
  name: string;
28
28
  attribute: any;
@@ -16,7 +16,7 @@ export class Schema {
16
16
  * @param editor Editor instance.
17
17
  * @returns Nodes schema.
18
18
  */
19
- static #createNodesSchema(nodeExtensions: any, attributes: any, editor: any): {
19
+ static "__#private@#createNodesSchema"(nodeExtensions: any, attributes: any, editor: any): {
20
20
  [k: string]: any;
21
21
  };
22
22
  /**
@@ -26,7 +26,7 @@ export class Schema {
26
26
  * @param editor Editor instance.
27
27
  * @returns Marks schema.
28
28
  */
29
- static #createMarksSchema(markExtensions: any, attributes: any, editor: any): {
29
+ static "__#private@#createMarksSchema"(markExtensions: any, attributes: any, editor: any): {
30
30
  [k: string]: any;
31
31
  };
32
32
  }