@harbour-enterprises/superdoc 0.23.0-next.1 → 0.23.0-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/chunks/{PdfViewer-C9SGNZr6.cjs → PdfViewer-CxsRHFKK.cjs} +2 -2
  2. package/dist/chunks/{PdfViewer-D9atA783.es.js → PdfViewer-itEb8CY_.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-C8q6lenv.es.js → index-CTFsQkQh.es.js} +75 -28
  6. package/dist/chunks/{index-CIbe1VMu.cjs → index-DO0hDjEd.cjs} +75 -28
  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-DxScE0ep.cjs → super-editor.es-Ck_zDasU.cjs} +259 -86
  10. package/dist/chunks/{super-editor.es-Dj6Sxtr7.es.js → super-editor.es-D2K5zQwY.es.js} +259 -86
  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/comments-store.d.ts +3 -3
  20. package/dist/stores/comments-store.d.ts.map +1 -1
  21. package/dist/stores/superdoc-store.d.ts.map +1 -1
  22. package/dist/style.css +73 -54
  23. package/dist/super-editor/ai-writer.es.js +2 -2
  24. package/dist/super-editor/chunks/{converter-C08GQjNi.js → converter-ClnqoStR.js} +18 -19
  25. package/dist/super-editor/chunks/{docx-zipper-C3-uf2tI.js → docx-zipper-DC28ucAi.js} +1 -1
  26. package/dist/super-editor/chunks/{editor-C2IwVkIp.js → editor-C3VH8Ia2.js} +240 -66
  27. package/dist/super-editor/chunks/{toolbar-De8G_9NV.js → toolbar-BG1F_1RK.js} +4 -4
  28. package/dist/super-editor/converter.es.js +1 -1
  29. package/dist/super-editor/docx-zipper.es.js +2 -2
  30. package/dist/super-editor/editor.es.js +3 -3
  31. package/dist/super-editor/file-zipper.es.js +1 -1
  32. package/dist/super-editor/src/core/Attribute.d.ts +2 -2
  33. package/dist/super-editor/src/core/Schema.d.ts +2 -2
  34. package/dist/super-editor/src/extensions/comment/comments-plugin.d.ts +60 -0
  35. package/dist/super-editor/src/extensions/comment/helpers/index.d.ts +2 -0
  36. package/dist/super-editor/src/extensions/comment/helpers/normalize-comment-event-payload.d.ts +1 -0
  37. package/dist/super-editor/src/extensions/comment/helpers/update-position.d.ts +7 -0
  38. package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +4 -0
  39. package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +1 -0
  40. package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +5 -0
  41. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsByAlias.d.ts +8 -0
  42. package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
  43. package/dist/super-editor/style.css +46 -27
  44. package/dist/super-editor/super-editor.es.js +6 -6
  45. package/dist/super-editor/toolbar.es.js +2 -2
  46. package/dist/super-editor.cjs +2 -2
  47. package/dist/super-editor.es.js +2 -2
  48. package/dist/superdoc.cjs +4 -4
  49. package/dist/superdoc.es.js +4 -4
  50. package/dist/superdoc.umd.js +362 -142
  51. package/dist/superdoc.umd.js.map +1 -1
  52. package/package.json +1 -1
  53. package/dist/chunks/xml-js-CX8FH0He.cjs +0 -3
  54. package/dist/chunks/xml-js-D0tLGmKu.es.js +0 -2
@@ -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-C08GQjNi.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-C3-uf2tI.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
  }
@@ -11707,26 +11706,100 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
11707
11706
  const setEditorToolbar = ({ editor }, mainEditor) => {
11708
11707
  editor.setToolbar(mainEditor.toolbar);
11709
11708
  };
11709
+ const normalizeCommentEventPayload = ({ conversation, editorOptions, fallbackCommentId, fallbackInternal }) => {
11710
+ const { user, documentId } = editorOptions || {};
11711
+ const normalized = {
11712
+ ...conversation,
11713
+ commentId: conversation?.commentId ?? fallbackCommentId,
11714
+ isInternal: conversation?.isInternal ?? fallbackInternal
11715
+ };
11716
+ if (!normalized.commentText && normalized.text) {
11717
+ normalized.commentText = normalized.text;
11718
+ delete normalized.text;
11719
+ }
11720
+ if ("skipEmit" in normalized) delete normalized.skipEmit;
11721
+ if (!normalized.creatorName && user?.name) {
11722
+ normalized.creatorName = user.name;
11723
+ }
11724
+ if (!normalized.creatorEmail && user?.email) {
11725
+ normalized.creatorEmail = user.email;
11726
+ }
11727
+ if (!normalized.createdTime) {
11728
+ normalized.createdTime = Date.now();
11729
+ }
11730
+ if (!normalized.fileId && documentId) {
11731
+ normalized.fileId = documentId;
11732
+ }
11733
+ if (!normalized.documentId && documentId) {
11734
+ normalized.documentId = documentId;
11735
+ }
11736
+ return normalized;
11737
+ };
11738
+ const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, node }) => {
11739
+ let bounds = {};
11740
+ if (currentBounds instanceof DOMRect) {
11741
+ bounds = {
11742
+ top: currentBounds.top,
11743
+ bottom: currentBounds.bottom,
11744
+ left: currentBounds.left,
11745
+ right: currentBounds.right
11746
+ };
11747
+ } else {
11748
+ bounds = { ...currentBounds };
11749
+ }
11750
+ if (!allCommentPositions[threadId]) {
11751
+ allCommentPositions[threadId] = {
11752
+ threadId,
11753
+ start: pos,
11754
+ end: pos + node.nodeSize,
11755
+ bounds
11756
+ };
11757
+ } else {
11758
+ const existing = allCommentPositions[threadId];
11759
+ existing.start = Math.min(existing.start, pos);
11760
+ existing.end = Math.max(existing.end, pos + node.nodeSize);
11761
+ existing.bounds.top = Math.min(existing.bounds.top, currentBounds.top);
11762
+ existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
11763
+ }
11764
+ };
11710
11765
  const TRACK_CHANGE_MARKS = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
11711
11766
  const CommentsPluginKey = new PluginKey("comments");
11712
11767
  const CommentsPlugin = Extension.create({
11713
11768
  name: "comments",
11714
11769
  addCommands() {
11715
11770
  return {
11716
- insertComment: (conversation) => ({ tr, dispatch }) => {
11771
+ insertComment: (conversation = {}) => ({ tr, dispatch }) => {
11717
11772
  const { selection } = tr;
11718
11773
  const { $from, $to } = selection;
11719
- const { commentId, isInternal } = conversation;
11774
+ const skipEmit = conversation?.skipEmit;
11775
+ const resolvedCommentId = conversation?.commentId ?? v4();
11776
+ const resolvedInternal = conversation?.isInternal ?? false;
11720
11777
  tr.setMeta(CommentsPluginKey, { event: "add" });
11721
11778
  tr.addMark(
11722
11779
  $from.pos,
11723
11780
  $to.pos,
11724
11781
  this.editor.schema.marks[CommentMarkName].create({
11725
- commentId,
11726
- internal: isInternal
11782
+ commentId: resolvedCommentId,
11783
+ internal: resolvedInternal
11727
11784
  })
11728
11785
  );
11729
- dispatch(tr);
11786
+ if (dispatch) dispatch(tr);
11787
+ const shouldEmit = !skipEmit && resolvedCommentId !== "pending";
11788
+ if (shouldEmit) {
11789
+ const commentPayload = normalizeCommentEventPayload({
11790
+ conversation,
11791
+ editorOptions: this.editor.options,
11792
+ fallbackCommentId: resolvedCommentId,
11793
+ fallbackInternal: resolvedInternal
11794
+ });
11795
+ const activeCommentId = commentPayload.commentId || commentPayload.importedId || null;
11796
+ const event = {
11797
+ type: comments_module_events.ADD,
11798
+ comment: commentPayload,
11799
+ ...activeCommentId && { activeCommentId }
11800
+ };
11801
+ this.editor.emit("commentsUpdate", event);
11802
+ }
11730
11803
  return true;
11731
11804
  },
11732
11805
  removeComment: ({ commentId, importedId }) => ({ tr, dispatch, state }) => {
@@ -11962,33 +12035,6 @@ const CommentsPlugin = Extension.create({
11962
12035
  return [commentsPlugin];
11963
12036
  }
11964
12037
  });
11965
- const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, node }) => {
11966
- let bounds = {};
11967
- if (currentBounds instanceof DOMRect) {
11968
- bounds = {
11969
- top: currentBounds.top,
11970
- bottom: currentBounds.bottom,
11971
- left: currentBounds.left,
11972
- right: currentBounds.right
11973
- };
11974
- } else {
11975
- bounds = { ...currentBounds };
11976
- }
11977
- if (!allCommentPositions[threadId]) {
11978
- allCommentPositions[threadId] = {
11979
- threadId,
11980
- start: pos,
11981
- end: pos + node.nodeSize,
11982
- bounds
11983
- };
11984
- } else {
11985
- const existing = allCommentPositions[threadId];
11986
- existing.start = Math.min(existing.start, pos);
11987
- existing.end = Math.max(existing.end, pos + node.nodeSize);
11988
- existing.bounds.top = Math.min(existing.bounds.top, currentBounds.top);
11989
- existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
11990
- }
11991
- };
11992
12038
  const getActiveCommentId = (doc2, selection) => {
11993
12039
  if (!selection) return;
11994
12040
  const { $from, $to } = selection;
@@ -17357,6 +17403,17 @@ function getStructuredContentTagsById(idOrIds, state) {
17357
17403
  });
17358
17404
  return result;
17359
17405
  }
17406
+ function getStructuredContentTagsByAlias(aliasOrAliases, state) {
17407
+ const result = findChildren$5(state.doc, (node) => {
17408
+ const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
17409
+ if (Array.isArray(aliasOrAliases)) {
17410
+ return isStructuredContent && aliasOrAliases.includes(node.attrs.alias);
17411
+ } else {
17412
+ return isStructuredContent && node.attrs.alias === aliasOrAliases;
17413
+ }
17414
+ });
17415
+ return result;
17416
+ }
17360
17417
  function getStructuredContentTags(state) {
17361
17418
  const result = findChildren$5(state.doc, (node) => {
17362
17419
  return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
@@ -17376,6 +17433,7 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
17376
17433
  getStructuredContentBlockTags,
17377
17434
  getStructuredContentInlineTags,
17378
17435
  getStructuredContentTags,
17436
+ getStructuredContentTagsByAlias,
17379
17437
  getStructuredContentTagsById
17380
17438
  }, Symbol.toStringTag, { value: "Module" }));
17381
17439
  const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
@@ -17464,10 +17522,11 @@ const StructuredContentCommands = Extension.create({
17464
17522
  return true;
17465
17523
  },
17466
17524
  /**
17467
- * Updates a structured content attributes or content.
17525
+ * Updates a single structured content field by its unique ID.
17526
+ * IDs are unique identifiers, so this will update at most one field.
17468
17527
  * If the updated node does not match the schema, it will not be updated.
17469
17528
  * @category Command
17470
- * @param {string} id
17529
+ * @param {string} id - Unique identifier of the field
17471
17530
  * @param {StructuredContentUpdate} options
17472
17531
  */
17473
17532
  updateStructuredContentById: (id, options = {}) => ({ editor, dispatch, state, tr }) => {
@@ -17507,6 +17566,58 @@ const StructuredContentCommands = Extension.create({
17507
17566
  }
17508
17567
  return true;
17509
17568
  },
17569
+ /**
17570
+ * Updates all structured content fields with the same alias.
17571
+ * Unlike IDs (which are unique), aliases can be shared across multiple fields.
17572
+ * This will update every field that matches the given alias.
17573
+ * If any updated node does not match the schema, no updates will be applied.
17574
+ * @category Command
17575
+ * @param {string | string[]} alias - Shared identifier for fields (e.g., "customer_name")
17576
+ * @param {StructuredContentUpdate} options
17577
+ */
17578
+ updateStructuredContentByAlias: (alias, options = {}) => ({ editor, dispatch, state, tr }) => {
17579
+ const structuredContentTags = getStructuredContentTagsByAlias(alias, state);
17580
+ if (!structuredContentTags.length) {
17581
+ return true;
17582
+ }
17583
+ const { schema } = editor;
17584
+ const createContent = (node) => {
17585
+ if (options.text) {
17586
+ return schema.text(options.text);
17587
+ }
17588
+ if (options.html) {
17589
+ const html = htmlHandler(options.html, editor);
17590
+ const doc2 = DOMParser$1.fromSchema(schema).parse(html);
17591
+ return doc2.content;
17592
+ }
17593
+ if (options.json) {
17594
+ return schema.nodeFromJSON(options.json);
17595
+ }
17596
+ return node.content;
17597
+ };
17598
+ for (const { node } of structuredContentTags) {
17599
+ const content = createContent(node);
17600
+ const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
17601
+ try {
17602
+ updatedNode.check();
17603
+ } catch {
17604
+ console.error("Updated node does not conform to the schema");
17605
+ return false;
17606
+ }
17607
+ }
17608
+ if (dispatch) {
17609
+ structuredContentTags.forEach(({ pos, node }) => {
17610
+ const mappedPos = tr.mapping.map(pos);
17611
+ const currentNode = tr.doc.nodeAt(mappedPos);
17612
+ if (currentNode && node.eq(currentNode)) {
17613
+ const content = createContent(node);
17614
+ const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
17615
+ tr.replaceWith(mappedPos, mappedPos + node.nodeSize, updatedNode);
17616
+ }
17617
+ });
17618
+ }
17619
+ return true;
17620
+ },
17510
17621
  /**
17511
17622
  * Removes a structured content.
17512
17623
  * @category Command
@@ -25648,6 +25759,7 @@ function getFormatAttrsFromMarks(marks) {
25648
25759
  }
25649
25760
  return formatAttrs;
25650
25761
  }
25762
+ const DEFAULT_MIME_TYPE = "application/octet-stream";
25651
25763
  const simpleHash = (str) => {
25652
25764
  let hash2 = 0;
25653
25765
  for (let i = 0; i < str.length; i++) {
@@ -25657,21 +25769,40 @@ const simpleHash = (str) => {
25657
25769
  }
25658
25770
  return Math.abs(hash2).toString();
25659
25771
  };
25660
- const base64ToFile = (base64String) => {
25661
- const arr = base64String.split(",");
25662
- const mimeMatch = arr[0].match(/:(.*?);/);
25663
- const mimeType = mimeMatch ? mimeMatch[1] : "";
25664
- const data = arr[1];
25665
- const binaryString = atob(data);
25772
+ const decodeBase64ToBinaryString = (data) => {
25773
+ if (!data) return "";
25774
+ if (typeof atob === "function") {
25775
+ return atob(data);
25776
+ }
25777
+ if (typeof Buffer2 !== "undefined" && typeof Buffer2.from === "function") {
25778
+ return Buffer2.from(data, "base64").toString("binary");
25779
+ }
25780
+ throw new Error("Unable to decode base64 payload in the current environment.");
25781
+ };
25782
+ const extractBase64Meta = (base64String) => {
25783
+ const [meta = "", payload = ""] = base64String.split(",");
25784
+ const mimeMatch = meta.match(/:(.*?);/);
25785
+ const rawMimeType = mimeMatch ? mimeMatch[1] : "";
25786
+ const mimeType = rawMimeType || DEFAULT_MIME_TYPE;
25787
+ const binaryString = decodeBase64ToBinaryString(payload);
25666
25788
  const hash2 = simpleHash(binaryString);
25667
25789
  const extension = mimeType.split("/")[1] || "bin";
25668
25790
  const filename = `image-${hash2}.${extension}`;
25791
+ return { mimeType, binaryString, filename };
25792
+ };
25793
+ const getBase64FileMeta = (base64String) => {
25794
+ const { mimeType, filename } = extractBase64Meta(base64String);
25795
+ return { mimeType, filename };
25796
+ };
25797
+ const base64ToFile = (base64String) => {
25798
+ const { mimeType, binaryString, filename } = extractBase64Meta(base64String);
25799
+ const fileType = mimeType || DEFAULT_MIME_TYPE;
25669
25800
  const bytes = new Uint8Array(binaryString.length);
25670
25801
  for (let i = 0; i < binaryString.length; i++) {
25671
25802
  bytes[i] = binaryString.charCodeAt(i);
25672
25803
  }
25673
- const blob = new Blob([bytes], { type: mimeType });
25674
- return new File([blob], filename, { type: mimeType });
25804
+ const blob = new Blob([bytes], { type: fileType });
25805
+ return new File([blob], filename, { type: fileType });
25675
25806
  };
25676
25807
  const urlToFile = async (url, filename, mimeType) => {
25677
25808
  try {
@@ -26047,6 +26178,7 @@ function addImageRelationship({ editor, path }) {
26047
26178
  }
26048
26179
  }
26049
26180
  const key = new PluginKey("ImageRegistration");
26181
+ const WORD_MEDIA_PREFIX = "word/";
26050
26182
  const ImageRegistrationPlugin = ({ editor }) => {
26051
26183
  const { view } = editor;
26052
26184
  return new Plugin({
@@ -26067,16 +26199,16 @@ const ImageRegistrationPlugin = ({ editor }) => {
26067
26199
  },
26068
26200
  appendTransaction: (trs, _oldState, state) => {
26069
26201
  let foundImages = [];
26070
- trs.forEach((tr2) => {
26071
- if (tr2.docChanged) {
26072
- tr2.steps.forEach((step, index2) => {
26202
+ trs.forEach((tr) => {
26203
+ if (tr.docChanged) {
26204
+ tr.steps.forEach((step, index2) => {
26073
26205
  const stepMap = step.getMap();
26074
26206
  foundImages = foundImages.map(({ node, pos, id }) => {
26075
26207
  const mappedPos = stepMap.map(pos, -1);
26076
26208
  return { node, pos: mappedPos, id };
26077
26209
  });
26078
26210
  if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
26079
- (tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
26211
+ (tr.docs[index2 + 1] || tr.doc).nodesBetween(
26080
26212
  stepMap.map(step.from, -1),
26081
26213
  stepMap.map(step.to, 1),
26082
26214
  (node, pos) => {
@@ -26095,22 +26227,10 @@ const ImageRegistrationPlugin = ({ editor }) => {
26095
26227
  if (!foundImages || foundImages.length === 0) {
26096
26228
  return null;
26097
26229
  }
26098
- registerImages(foundImages, editor, view);
26099
- const tr = state.tr;
26100
- let { set } = key.getState(state);
26101
- foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
26102
- let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
26103
- side: -1,
26104
- id
26105
- });
26106
- set = set.add(tr.doc, [deco]);
26107
- });
26108
- foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
26109
- tr.delete(pos, pos + node.nodeSize);
26110
- });
26111
- set = set.map(tr.mapping, tr.doc);
26112
- tr.setMeta(key, { set });
26113
- return tr;
26230
+ if (editor.options.isHeadless) {
26231
+ return handleNodePath(foundImages, editor, state);
26232
+ }
26233
+ return handleBrowserPath(foundImages, editor, view, state);
26114
26234
  },
26115
26235
  props: {
26116
26236
  decorations(state) {
@@ -26120,6 +26240,59 @@ const ImageRegistrationPlugin = ({ editor }) => {
26120
26240
  }
26121
26241
  });
26122
26242
  };
26243
+ const derivePreferredFileName = (src) => {
26244
+ if (typeof src !== "string" || src.length === 0) {
26245
+ return "image.bin";
26246
+ }
26247
+ if (src.startsWith("data:")) {
26248
+ return getBase64FileMeta(src).filename;
26249
+ }
26250
+ const lastSegment = src.split("/").pop() ?? "";
26251
+ const trimmed = lastSegment.split(/[?#]/)[0];
26252
+ return trimmed || "image.bin";
26253
+ };
26254
+ const handleNodePath = (foundImages, editor, state) => {
26255
+ const { tr } = state;
26256
+ const mediaStore = editor.storage.image.media ?? {};
26257
+ if (!editor.storage.image.media) {
26258
+ editor.storage.image.media = mediaStore;
26259
+ }
26260
+ const existingFileNames = new Set(Object.keys(mediaStore).map((key2) => key2.split("/").pop()));
26261
+ foundImages.forEach(({ node, pos }) => {
26262
+ const { src } = node.attrs;
26263
+ const preferredFileName = derivePreferredFileName(src);
26264
+ const uniqueFileName = ensureUniqueFileName(preferredFileName, existingFileNames);
26265
+ existingFileNames.add(uniqueFileName);
26266
+ const mediaPath = buildMediaPath(uniqueFileName);
26267
+ mediaStore[mediaPath] = src;
26268
+ const path = mediaPath.startsWith(WORD_MEDIA_PREFIX) ? mediaPath.slice(WORD_MEDIA_PREFIX.length) : mediaPath;
26269
+ const rId = addImageRelationship({ editor, path });
26270
+ tr.setNodeMarkup(pos, void 0, {
26271
+ ...node.attrs,
26272
+ src: mediaPath,
26273
+ rId
26274
+ });
26275
+ });
26276
+ return tr;
26277
+ };
26278
+ const handleBrowserPath = (foundImages, editor, view, state) => {
26279
+ registerImages(foundImages, editor, view);
26280
+ const tr = state.tr;
26281
+ let { set } = key.getState(state);
26282
+ foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
26283
+ let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
26284
+ side: -1,
26285
+ id
26286
+ });
26287
+ set = set.add(tr.doc, [deco]);
26288
+ });
26289
+ foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
26290
+ tr.delete(pos, pos + node.nodeSize);
26291
+ });
26292
+ set = set.map(tr.mapping, tr.doc);
26293
+ tr.setMeta(key, { set });
26294
+ return tr;
26295
+ };
26123
26296
  const findPlaceholder = (state, id) => {
26124
26297
  let { set } = key.getState(state);
26125
26298
  let found = set?.find(null, null, (spec) => spec.id === id);
@@ -33237,6 +33410,7 @@ function getActualBreakCoords(view, pos, calculatedThreshold) {
33237
33410
  return actualBreak;
33238
33411
  }
33239
33412
  const onImageLoad = (editor) => {
33413
+ if (typeof requestAnimationFrame !== "function") return;
33240
33414
  requestAnimationFrame(() => {
33241
33415
  const newTr = editor.view.state.tr;
33242
33416
  newTr.setMeta("forceUpdatePagination", true);
@@ -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-C08GQjNi.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-C2IwVkIp.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-C3VH8Ia2.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-C08GQjNi.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-C08GQjNi.js";
2
- import { D } from "./chunks/docx-zipper-C3-uf2tI.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-C2IwVkIp.js";
2
- import "./chunks/converter-C08GQjNi.js";
3
- import "./chunks/docx-zipper-C3-uf2tI.js";
1
+ import { E } from "./chunks/editor-C3VH8Ia2.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-C3-uf2tI.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
  }
@@ -1,4 +1,64 @@
1
1
  export const CommentsPluginKey: PluginKey<any>;
2
2
  export const CommentsPlugin: Extension;
3
+ export namespace __test__ {
4
+ export { getActiveCommentId };
5
+ export { findTrackedMark };
6
+ export { handleTrackedChangeTransaction };
7
+ export { getTrackedChangeText };
8
+ export { createOrUpdateTrackedChangeComment };
9
+ export { findRangeById };
10
+ }
3
11
  import { PluginKey } from 'prosemirror-state';
4
12
  import { Extension } from '@core/Extension.js';
13
+ /**
14
+ * This is run when a new selection is set (tr.selectionSet) to return the active comment ID, if any
15
+ * If there are multiple, only return the first one
16
+ *
17
+ * @param {Object} doc The current document
18
+ * @param {Selection} selection The current selection
19
+ * @returns {String | null} The active comment ID, if any
20
+ */
21
+ declare function getActiveCommentId(doc: any, selection: Selection): string | null;
22
+ declare function findTrackedMark({ doc, from, to, offset, }: {
23
+ doc: any;
24
+ from: any;
25
+ to: any;
26
+ offset?: number;
27
+ }): undefined;
28
+ declare function handleTrackedChangeTransaction(trackedChangeMeta: any, trackedChanges: any, newEditorState: any, editor: any): any;
29
+ declare function getTrackedChangeText({ nodes, mark, trackedChangeType, isDeletionInsertion }: {
30
+ nodes: any;
31
+ mark: any;
32
+ trackedChangeType: any;
33
+ isDeletionInsertion: any;
34
+ }): {
35
+ deletionText: string;
36
+ trackedChangeText: string;
37
+ };
38
+ declare function createOrUpdateTrackedChangeComment({ event, marks, deletionNodes, nodes, newEditorState, documentId }: {
39
+ event: any;
40
+ marks: any;
41
+ deletionNodes: any;
42
+ nodes: any;
43
+ newEditorState: any;
44
+ documentId: any;
45
+ }): {
46
+ importedAuthor: {
47
+ name: any;
48
+ };
49
+ event: "add";
50
+ type: string;
51
+ documentId: any;
52
+ changeId: any;
53
+ trackedChangeType: any;
54
+ trackedChangeText: string;
55
+ deletedText: string;
56
+ author: any;
57
+ authorEmail: any;
58
+ date: any;
59
+ };
60
+ declare function findRangeById(doc: any, id: any): {
61
+ from: any;
62
+ to: any;
63
+ };
64
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./normalize-comment-event-payload.js";
2
+ export * from "./update-position.js";
@@ -0,0 +1 @@
1
+ export function normalizeCommentEventPayload({ conversation, editorOptions, fallbackCommentId, fallbackInternal }: any): any;
@@ -0,0 +1,7 @@
1
+ export function updatePosition({ allCommentPositions, threadId, pos, currentBounds, node }: {
2
+ allCommentPositions: any;
3
+ threadId: string;
4
+ pos: number;
5
+ currentBounds: DOMRect | any;
6
+ node: any;
7
+ }): void;
@@ -1 +1,5 @@
1
+ export function getBase64FileMeta(base64String: any): {
2
+ mimeType: any;
3
+ filename: any;
4
+ };
1
5
  export function base64ToFile(base64String: any): File;
@@ -3,6 +3,7 @@ export function ImageRegistrationPlugin({ editor }: {
3
3
  }): Plugin<{
4
4
  set: DecorationSet;
5
5
  }>;
6
+ export function handleNodePath(foundImages: any[], editor: any, state: import("prosemirror-state").EditorState): import("prosemirror-state").Transaction;
6
7
  export function findPlaceholder(state: any, id: any): any;
7
8
  export function removeImagePlaceholder(state: any, tr: any, id: any): any;
8
9
  export function addImagePlaceholder(state: any, tr: any, id: any, pos: any): any;
@@ -10,6 +10,10 @@ export function uploadAndInsertImage({ editor, view, file, size, id }: {
10
10
  size: any;
11
11
  id: any;
12
12
  }): Promise<void>;
13
+ export function addImageRelationship({ editor, path }: {
14
+ editor: any;
15
+ path: any;
16
+ }): string;
13
17
  export function checkAndProcessImage({ getMaxContentSize, file }: {
14
18
  getMaxContentSize: any;
15
19
  file: any;
@@ -20,3 +24,4 @@ export function checkAndProcessImage({ getMaxContentSize, file }: {
20
24
  height: any;
21
25
  };
22
26
  }>;
27
+ export function generateUniqueDocPrId(editor: any): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Gets structured content tags by alias in the state.
3
+ * @param {string | string[]} aliasOrAliases
4
+ * @param {EditorState} state Editor state.
5
+ * @returns {Array}
6
+ */
7
+ export function getStructuredContentTagsByAlias(aliasOrAliases: string | string[], state: EditorState): any[];
8
+ import { EditorState } from 'prosemirror-state';