superdoc 0.31.0-next.5 → 0.31.0-next.7

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-DXwcotXc.cjs → PdfViewer-C_gVEaJa.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BjFaPQBd.es.js → PdfViewer-HhmcCtfd.es.js} +1 -1
  3. package/dist/chunks/{index-B7dC-H-Q-DfBEU7rR.cjs → index-BJ6cOegF-BuvRSNoV.cjs} +1 -1
  4. package/dist/chunks/{index-B7dC-H-Q-BeQx_MXI.es.js → index-BJ6cOegF-C-oX4LAe.es.js} +1 -1
  5. package/dist/chunks/{index-B6TttOzK.es.js → index-Cz10rZ5n.es.js} +3 -3
  6. package/dist/chunks/{index-BF_Yvius.cjs → index-wLtubQ87.cjs} +3 -3
  7. package/dist/chunks/{super-editor.es-CVDIAxlg.cjs → super-editor.es-Bz-s1Pw4.cjs} +351 -155
  8. package/dist/chunks/{super-editor.es-M2e4wbRW.es.js → super-editor.es-C20nShDu.es.js} +351 -155
  9. package/dist/style.css +10 -9
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-BIsS-JzD.js → converter-DVDL6NWz.js} +100 -53
  12. package/dist/super-editor/chunks/{docx-zipper-DVDiaIyD.js → docx-zipper-4ipmBNSH.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-ZbcM1RTL.js → editor-B8v33PJq.js} +253 -104
  14. package/dist/super-editor/chunks/{index-B7dC-H-Q.js → index-BJ6cOegF.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-8qqw8IXG.js → toolbar-CfUofx7k.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/style.css +10 -9
  21. package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +7 -0
  22. package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts.map +1 -1
  23. package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts +2 -1
  24. package/dist/super-editor/super-editor/src/core/super-converter/styles.d.ts.map +1 -1
  25. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/legacy-handle-paragraph-node.d.ts.map +1 -1
  26. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +14 -10
  27. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts.map +1 -1
  28. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts.map +1 -1
  29. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr/tr-translator.d.ts.map +1 -1
  30. package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts +1 -0
  31. package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts.map +1 -1
  32. package/dist/super-editor/super-editor/src/extensions/linked-styles/plugin.d.ts.map +1 -1
  33. package/dist/super-editor/super-editor/src/extensions/paragraph/paragraph.d.ts.map +1 -1
  34. package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +8 -2
  35. package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts.map +1 -1
  36. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts +19 -0
  37. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentByGroup.d.ts.map +1 -0
  38. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +2 -0
  39. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts +53 -0
  40. package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/tagUtils.d.ts.map +1 -0
  41. package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts +7 -1
  42. package/dist/super-editor/super-editor/src/extensions/table/TableView.d.ts.map +1 -1
  43. package/dist/super-editor/super-editor/src/extensions/table/table.d.ts +18 -0
  44. package/dist/super-editor/super-editor/src/extensions/table/table.d.ts.map +1 -1
  45. package/dist/super-editor/super-editor/src/extensions/table-cell/table-cell.d.ts.map +1 -1
  46. package/dist/super-editor/super-editor.es.js +7 -7
  47. package/dist/super-editor/toolbar.es.js +2 -2
  48. package/dist/super-editor.cjs +1 -1
  49. package/dist/super-editor.es.js +1 -1
  50. package/dist/superdoc.cjs +2 -2
  51. package/dist/superdoc.es.js +2 -2
  52. package/dist/superdoc.umd.js +352 -156
  53. package/dist/superdoc.umd.js.map +1 -1
  54. package/package.json +1 -1
@@ -12,8 +12,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, isElementNode_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, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, updateHTMLAttributes_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _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 htmlHandler, E as ReplaceStep, L as ListHelpers, G as updateNumberingProperties, H as changeListLevel, I as findParentNode, J as isList, K as isMacOS, O as isIOS, Q as getSchemaTypeByName, U as inputRulesPlugin, V as TrackDeleteMarkName, W as TrackInsertMarkName, X as v4, Y as TrackFormatMarkName, Z as comments_module_events, _ as findMark, $ as objectIncludes, a0 as AddMarkStep, a1 as RemoveMarkStep, a2 as twipsToLines, a3 as pixelsToTwips, a4 as helpers, a5 as posToDOMRect, a6 as CommandService, a7 as SuperConverter, a8 as createDocument, a9 as createDocFromMarkdown, aa as createDocFromHTML, ab as EditorState, ac as hasSomeParentWithClass, ad as isActive, ae as unflattenListsInHtml, af as parseSizeUnit, ag as minMax, ah as getLineHeightValueString, ai as updateDOMAttributes, aj as findChildren$5, ak as generateRandomSigned32BitIntStrId, al as kebabCase, am as twipsToPixels, an as halfPointToPixels, ao as getUnderlineCssString, ap as findParentNodeClosestToPos, aq as resolveRunProperties, ar as encodeCSSFromRPr, as as docxNumberingHelpers, at as InputRule, au as resolveParagraphProperties, av as eighthPointsToPixels, aw as linesToTwips, ax as PIXELS_PER_INCH, ay as SelectionRange, az as Transform, aA as isInTable$1, aB as generateDocxRandomId, aC as insertNewRelationship, aD as inchesToPixels } from "./converter-BIsS-JzD.js";
16
- import { D as DocxZipper } from "./docx-zipper-DVDiaIyD.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 htmlHandler, E as ReplaceStep, L as ListHelpers, G as updateNumberingProperties, H as changeListLevel, I as findParentNode, J as isList, K as isMacOS, O as isIOS, Q as getSchemaTypeByName, U as inputRulesPlugin, V as TrackDeleteMarkName, W as TrackInsertMarkName, X as v4, Y as TrackFormatMarkName, Z as comments_module_events, _ as findMark, $ as objectIncludes, a0 as AddMarkStep, a1 as RemoveMarkStep, a2 as twipsToLines, a3 as pixelsToTwips, a4 as helpers, a5 as posToDOMRect, a6 as CommandService, a7 as SuperConverter, a8 as createDocument, a9 as createDocFromMarkdown, aa as createDocFromHTML, ab as EditorState, ac as hasSomeParentWithClass, ad as isActive, ae as unflattenListsInHtml, af as parseSizeUnit, ag as minMax, ah as getLineHeightValueString, ai as updateDOMAttributes, aj as findChildren$5, ak as generateRandomSigned32BitIntStrId, al as kebabCase, am as twipsToPixels, an as halfPointToPixels, ao as getUnderlineCssString, ap as findParentNodeClosestToPos, aq as resolveRunProperties, ar as encodeCSSFromRPr, as as docxNumberingHelpers, at as InputRule, au as resolveParagraphProperties, av as eighthPointsToPixels, aw as linesToTwips, ax as convertSizeToCSS, ay as SelectionRange, az as Transform, aA as isInTable$1, aB as generateDocxRandomId, aC as insertNewRelationship, aD as inchesToPixels } from "./converter-DVDL6NWz.js";
16
+ import { D as DocxZipper } from "./docx-zipper-4ipmBNSH.js";
17
17
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
@@ -14109,7 +14109,7 @@ const _Editor = class _Editor extends EventEmitter {
14109
14109
  { default: remarkStringify },
14110
14110
  { default: remarkGfm }
14111
14111
  ] = await Promise.all([
14112
- import("./index-B7dC-H-Q.js"),
14112
+ import("./index-BJ6cOegF.js"),
14113
14113
  import("./index-DRCvimau.js"),
14114
14114
  import("./index-C_x_N6Uh.js"),
14115
14115
  import("./index-D_sWOSiG.js"),
@@ -14310,7 +14310,7 @@ const _Editor = class _Editor extends EventEmitter {
14310
14310
  * Process collaboration migrations
14311
14311
  */
14312
14312
  processCollaborationMigrations() {
14313
- console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.5");
14313
+ console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.7");
14314
14314
  if (!this.options.ydoc) return;
14315
14315
  const metaMap = this.options.ydoc.getMap("meta");
14316
14316
  let docVersion = metaMap.get("version");
@@ -16807,6 +16807,46 @@ function getStructuredContentTagsById(idOrIds, state) {
16807
16807
  });
16808
16808
  return result;
16809
16809
  }
16810
+ function createTagObject(tagData) {
16811
+ if (!tagData || typeof tagData !== "object") {
16812
+ return null;
16813
+ }
16814
+ return JSON.stringify(tagData);
16815
+ }
16816
+ function parseTagObject(tag) {
16817
+ if (typeof tag !== "string" || !tag.startsWith("{")) {
16818
+ return null;
16819
+ }
16820
+ try {
16821
+ const parsed = JSON.parse(tag);
16822
+ return parsed && typeof parsed === "object" ? parsed : null;
16823
+ } catch {
16824
+ return null;
16825
+ }
16826
+ }
16827
+ function hasGroup(tag) {
16828
+ const parsed = parseTagObject(tag);
16829
+ return parsed !== null && typeof parsed.group === "string";
16830
+ }
16831
+ function getGroup(tag) {
16832
+ const parsed = parseTagObject(tag);
16833
+ return parsed && typeof parsed.group === "string" ? parsed.group : null;
16834
+ }
16835
+ function getStructuredContentByGroup(groupOrGroups, state) {
16836
+ const searchGroups = Array.isArray(groupOrGroups) ? groupOrGroups : [groupOrGroups];
16837
+ const result = findChildren$5(state.doc, (node) => {
16838
+ const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node.type.name);
16839
+ if (!isStructuredContent) {
16840
+ return false;
16841
+ }
16842
+ const nodeGroup = getGroup(node.attrs.tag);
16843
+ if (!nodeGroup) {
16844
+ return false;
16845
+ }
16846
+ return searchGroups.includes(nodeGroup);
16847
+ });
16848
+ return result;
16849
+ }
16810
16850
  function getStructuredContentTags(state) {
16811
16851
  const result = findChildren$5(state.doc, (node) => {
16812
16852
  return node.type.name === "structuredContent" || node.type.name === "structuredContentBlock";
@@ -16839,11 +16879,16 @@ function getStructuredContentTablesById(id, state) {
16839
16879
  }
16840
16880
  const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
16841
16881
  __proto__: null,
16882
+ createTagObject,
16883
+ getGroup,
16842
16884
  getStructuredContentBlockTags,
16885
+ getStructuredContentByGroup,
16843
16886
  getStructuredContentInlineTags,
16844
16887
  getStructuredContentTablesById,
16845
16888
  getStructuredContentTags,
16846
- getStructuredContentTagsById
16889
+ getStructuredContentTagsById,
16890
+ hasGroup,
16891
+ parseTagObject
16847
16892
  }, Symbol.toStringTag, { value: "Module" }));
16848
16893
  const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
16849
16894
  const StructuredContentCommands = Extension.create({
@@ -16855,6 +16900,16 @@ const StructuredContentCommands = Extension.create({
16855
16900
  * @category Command
16856
16901
  * @param {StructuredContentInlineInsert} options
16857
16902
  * @example
16903
+ * // With group for linking multiple fields
16904
+ * editor.commands.insertStructuredContentInline({
16905
+ * attrs: {
16906
+ * group: 'customer-info',
16907
+ * alias: 'Customer Name',
16908
+ * },
16909
+ * text: 'John Doe',
16910
+ * });
16911
+ *
16912
+ * // No group
16858
16913
  * editor.commands.insertStructuredContentInline({
16859
16914
  * attrs: {
16860
16915
  * id: '123',
@@ -16883,12 +16938,17 @@ const StructuredContentCommands = Extension.create({
16883
16938
  if (!content) {
16884
16939
  content = schema.text(" ");
16885
16940
  }
16941
+ let tag = options.attrs?.tag || "inline_text_sdt";
16942
+ if (options.attrs?.group) {
16943
+ tag = createTagObject({ group: options.attrs.group });
16944
+ }
16886
16945
  const attrs = {
16887
- ...options.attrs,
16888
16946
  id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
16889
- tag: "inline_text_sdt",
16890
- alias: options.attrs?.alias || "Structured content"
16947
+ tag,
16948
+ alias: options.attrs?.alias || "Structured content",
16949
+ ...options.attrs
16891
16950
  };
16951
+ delete attrs.group;
16892
16952
  const node = schema.nodes.structuredContent.create(attrs, content, null);
16893
16953
  const parent = findParentNode((node2) => node2.type.name === "structuredContent")(state.selection);
16894
16954
  if (parent) {
@@ -16904,14 +16964,22 @@ const StructuredContentCommands = Extension.create({
16904
16964
  * @category Command
16905
16965
  * @param {StructuredContentBlockInsert} options
16906
16966
  * @example
16967
+ * // With group for linking multiple fields
16968
+ * editor.commands.insertStructuredContentBlock({
16969
+ * attrs: {
16970
+ * group: 'terms-section',
16971
+ * alias: 'Terms & Conditions',
16972
+ * },
16973
+ * html: '<p>Legal content...</p>',
16974
+ * });
16975
+ *
16976
+ * // No group
16907
16977
  * editor.commands.insertStructuredContentBlock({
16908
16978
  * attrs: {
16909
16979
  * id: '456',
16910
16980
  * alias: 'Terms & Conditions',
16911
16981
  * },
16912
16982
  * json: { type: 'paragraph', content: [{ type: 'text', text: 'Legal content...' }] }
16913
- * // or
16914
- * html: '<p>Legal content...</p>',
16915
16983
  * });
16916
16984
  */
16917
16985
  insertStructuredContentBlock: (options = {}) => ({ editor, dispatch, state, tr }) => {
@@ -16934,12 +17002,17 @@ const StructuredContentCommands = Extension.create({
16934
17002
  if (!content) {
16935
17003
  content = schema.nodeFromJSON({ type: "paragraph", content: [] });
16936
17004
  }
17005
+ let tag = options.attrs?.tag || "block_table_sdt";
17006
+ if (options.attrs?.group) {
17007
+ tag = createTagObject({ group: options.attrs.group });
17008
+ }
16937
17009
  const attrs = {
16938
- ...options.attrs,
16939
17010
  id: options.attrs?.id || generateRandomSigned32BitIntStrId(),
16940
- tag: "block_table_sdt",
16941
- alias: options.attrs?.alias || "Structured content"
17011
+ tag,
17012
+ alias: options.attrs?.alias || "Structured content",
17013
+ ...options.attrs
16942
17014
  };
17015
+ delete attrs.group;
16943
17016
  const node = schema.nodes.structuredContentBlock.create(attrs, content, null);
16944
17017
  const parent = findParentNode((node2) => node2.type.name === "structuredContentBlock")(state.selection);
16945
17018
  if (parent) {
@@ -17069,6 +17142,85 @@ const StructuredContentCommands = Extension.create({
17069
17142
  }
17070
17143
  return true;
17071
17144
  },
17145
+ /**
17146
+ * Updates all structured content fields that share the same group identifier.
17147
+ * Groups allow linking multiple fields together for batch operations.
17148
+ * @category Command
17149
+ * @param {string} group - Group identifier shared by multiple fields
17150
+ * @param {StructuredContentUpdate} options
17151
+ * @example
17152
+ * // Update all fields in the customer-info group
17153
+ * editor.commands.updateStructuredContentByGroup('customer-info', { text: 'Jane Doe' });
17154
+ *
17155
+ * // Update block content in a group
17156
+ * editor.commands.updateStructuredContentByGroup('terms-section', {
17157
+ * html: '<p>Updated terms...</p>'
17158
+ * });
17159
+ */
17160
+ updateStructuredContentByGroup: (group, options = {}) => ({ editor, dispatch, state, tr }) => {
17161
+ const structuredContentTags = getStructuredContentByGroup(group, state);
17162
+ if (!structuredContentTags.length) {
17163
+ return true;
17164
+ }
17165
+ const { schema } = editor;
17166
+ if (dispatch) {
17167
+ structuredContentTags.forEach((structuredContent) => {
17168
+ const { pos, node } = structuredContent;
17169
+ const posFrom = tr.mapping.map(pos);
17170
+ const posTo = tr.mapping.map(pos + node.nodeSize);
17171
+ let content = null;
17172
+ if (options.text) {
17173
+ content = schema.text(options.text);
17174
+ }
17175
+ if (options.html) {
17176
+ const html = htmlHandler(options.html, editor);
17177
+ const doc2 = DOMParser$1.fromSchema(schema).parse(html);
17178
+ content = doc2.content;
17179
+ }
17180
+ if (options.json) {
17181
+ content = schema.nodeFromJSON(options.json);
17182
+ }
17183
+ if (!content) {
17184
+ content = node.content;
17185
+ }
17186
+ const updatedNode = node.type.create({ ...node.attrs, ...options.attrs }, content, node.marks);
17187
+ const currentNode = tr.doc.nodeAt(posFrom);
17188
+ if (currentNode && node.eq(currentNode)) {
17189
+ tr.replaceWith(posFrom, posTo, updatedNode);
17190
+ }
17191
+ });
17192
+ }
17193
+ return true;
17194
+ },
17195
+ /**
17196
+ * Removes all structured content fields that share the same group identifier.
17197
+ * @category Command
17198
+ * @param {string | string[]} groupOrGroups - Single group or array of groups
17199
+ * @example
17200
+ * // Delete all fields in a group
17201
+ * editor.commands.deleteStructuredContentByGroup('customer-info');
17202
+ *
17203
+ * // Delete multiple groups
17204
+ * editor.commands.deleteStructuredContentByGroup(['header', 'footer']);
17205
+ */
17206
+ deleteStructuredContentByGroup: (groupOrGroups) => ({ dispatch, state, tr }) => {
17207
+ const structuredContentTags = getStructuredContentByGroup(groupOrGroups, state);
17208
+ if (!structuredContentTags.length) {
17209
+ return true;
17210
+ }
17211
+ if (dispatch) {
17212
+ structuredContentTags.forEach((structuredContent) => {
17213
+ const { pos, node } = structuredContent;
17214
+ const posFrom = tr.mapping.map(pos);
17215
+ const posTo = tr.mapping.map(pos + node.nodeSize);
17216
+ const currentNode = tr.doc.nodeAt(posFrom);
17217
+ if (currentNode && node.eq(currentNode)) {
17218
+ tr.delete(posFrom, posTo);
17219
+ }
17220
+ });
17221
+ }
17222
+ return true;
17223
+ },
17072
17224
  /**
17073
17225
  * Append multiple rows to the end of a table inside a structured content block.
17074
17226
  * Each inner array represents the cell values for one new row.
@@ -18217,7 +18369,7 @@ const applyLinkedStyleToTransaction = (tr, editor, style) => {
18217
18369
  let selection = tr.selection;
18218
18370
  const state = editor.state;
18219
18371
  const focusState = CustomSelectionPluginKey.getState(state);
18220
- if (selection.empty && focusState?.preservedSelection) {
18372
+ if (selection.empty && focusState?.preservedSelection && !focusState?.preservedSelection.empty) {
18221
18373
  selection = focusState.preservedSelection;
18222
18374
  tr.setSelection(selection);
18223
18375
  } else if (selection.empty && editor.options.lastSelection) {
@@ -18284,6 +18436,31 @@ const applyLinkedStyleToTransaction = (tr, editor, style) => {
18284
18436
  });
18285
18437
  return true;
18286
18438
  };
18439
+ const stepInsertsTextIntoStyledParagraph = (tr, oldEditorState, step, stepIndex) => {
18440
+ if (!step.slice || step.slice.size === 0 || typeof step.from !== "number") {
18441
+ return false;
18442
+ }
18443
+ let insertsText = false;
18444
+ step.slice.content.descendants((node) => {
18445
+ if (node.type?.name === "text" && node.text?.length) {
18446
+ insertsText = true;
18447
+ return false;
18448
+ }
18449
+ return true;
18450
+ });
18451
+ if (!insertsText) return false;
18452
+ const docBeforeStep = tr.docs?.[stepIndex] || oldEditorState.doc;
18453
+ if (!docBeforeStep) return false;
18454
+ const resolvedPos = Math.min(step.from, docBeforeStep.content.size);
18455
+ const $pos = docBeforeStep.resolve(resolvedPos);
18456
+ for (let depth = $pos.depth; depth >= 0; depth--) {
18457
+ const node = $pos.node(depth);
18458
+ if (node?.type?.name === "paragraph") {
18459
+ return Boolean(node.attrs?.styleId);
18460
+ }
18461
+ }
18462
+ return false;
18463
+ };
18287
18464
  const LinkedStylesPluginKey = new PluginKey("linkedStyles");
18288
18465
  const createLinkedStylesPlugin = (editor) => {
18289
18466
  return new Plugin({
@@ -18317,7 +18494,7 @@ const createLinkedStylesPlugin = (editor) => {
18317
18494
  if (tr.docChanged) {
18318
18495
  let mightAffectStyles = false;
18319
18496
  const styleRelatedMarks = /* @__PURE__ */ new Set(["textStyle", "bold", "italic", "underline", "strike"]);
18320
- tr.steps.forEach((step) => {
18497
+ tr.steps.forEach((step, index2) => {
18321
18498
  if (step.slice) {
18322
18499
  step.slice.content.descendants((node) => {
18323
18500
  if (node.attrs?.styleId) {
@@ -18338,6 +18515,9 @@ const createLinkedStylesPlugin = (editor) => {
18338
18515
  mightAffectStyles = true;
18339
18516
  }
18340
18517
  }
18518
+ if (!mightAffectStyles && stepInsertsTextIntoStyledParagraph(tr, oldEditorState, step, index2)) {
18519
+ mightAffectStyles = true;
18520
+ }
18341
18521
  });
18342
18522
  if (mightAffectStyles) {
18343
18523
  const styles = LinkedStylesPluginKey.getState(editor.state).styles;
@@ -19736,6 +19916,8 @@ const Paragraph = OxmlNode.create({
19736
19916
  }
19737
19917
  },
19738
19918
  styleId: {
19919
+ default: null,
19920
+ keepOnSplit: false,
19739
19921
  renderDOM: (attrs) => {
19740
19922
  if (!attrs.styleId) return {};
19741
19923
  return { styleid: attrs.styleId };
@@ -20481,15 +20663,6 @@ const HardBreak = Node$1.create({
20481
20663
  };
20482
20664
  }
20483
20665
  });
20484
- const getColStyleDeclaration = (minWidth, width) => {
20485
- if (width != null) {
20486
- const numericWidth = Number(width);
20487
- if (Number.isFinite(numericWidth) && numericWidth >= 0) {
20488
- return ["width", `${numericWidth}px`];
20489
- }
20490
- }
20491
- return ["min-width", `${minWidth}px`];
20492
- };
20493
20666
  const createTableView = ({ editor }) => {
20494
20667
  return class TableView {
20495
20668
  constructor(node, cellMinWidth) {
@@ -20508,7 +20681,7 @@ const createTableView = ({ editor }) => {
20508
20681
  this.table = this.dom.appendChild(document.createElement("table"));
20509
20682
  this.colgroup = this.table.appendChild(document.createElement("colgroup"));
20510
20683
  updateTable(this.editor, this.node, this.table);
20511
- updateColumns(node, this.colgroup, this.table, cellMinWidth, void 0, void 0, this.editor);
20684
+ updateColumns(node, this.colgroup, this.table);
20512
20685
  this.contentDOM = this.table.appendChild(document.createElement("tbody"));
20513
20686
  setTimeout(() => {
20514
20687
  updateTableWrapper(this.dom, this.table);
@@ -20520,7 +20693,7 @@ const createTableView = ({ editor }) => {
20520
20693
  }
20521
20694
  this.node = node;
20522
20695
  updateTable(this.editor, node, this.table);
20523
- updateColumns(node, this.colgroup, this.table, this.cellMinWidth, void 0, void 0, this.editor);
20696
+ updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
20524
20697
  updateTableWrapper(this.dom, this.table);
20525
20698
  return true;
20526
20699
  }
@@ -20533,43 +20706,20 @@ const createTableView = ({ editor }) => {
20533
20706
  }
20534
20707
  };
20535
20708
  };
20536
- function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue, editor) {
20709
+ function updateColumns(node, colgroup, table, cellMinWidth) {
20537
20710
  const gridColumns = Array.isArray(node.attrs?.grid) && node.attrs.grid.length ? node.attrs.grid.map((col) => twipsToPixels(col.col)) : null;
20538
20711
  const totalColumns = gridColumns?.length ?? null;
20539
- const pageBody = table.closest(".page__body");
20540
- const wrapper = table.parentElement;
20541
- let availableWidth = pageBody?.getBoundingClientRect?.().width;
20542
- if (!availableWidth && wrapper) {
20543
- availableWidth = wrapper.getBoundingClientRect().width;
20544
- }
20545
- if (typeof availableWidth === "number" && !Number.isNaN(availableWidth)) {
20546
- availableWidth = Math.max(availableWidth - 2, 0);
20547
- } else {
20548
- availableWidth = null;
20549
- }
20550
- const pageStyles = editor?.converter?.pageStyles;
20551
- if (pageStyles?.pageSize?.width) {
20552
- const toNumber = (v) => typeof v === "number" ? v : parseFloat(v) || 0;
20553
- const pageWidth = toNumber(pageStyles.pageSize.width);
20554
- const marginLeft = toNumber(pageStyles.pageMargins?.left);
20555
- const marginRight = toNumber(pageStyles.pageMargins?.right);
20556
- const pageAvailableWidthPx = Math.max((pageWidth - marginLeft - marginRight) * PIXELS_PER_INCH, 0);
20557
- if (pageAvailableWidthPx > 0) {
20558
- availableWidth = availableWidth ? Math.min(availableWidth, pageAvailableWidthPx) : pageAvailableWidthPx;
20559
- }
20560
- }
20561
20712
  const resolveColumnWidth = (colIndex2, colwidthValue) => {
20562
- if (overrideCol === colIndex2) return overrideValue;
20563
20713
  if (colwidthValue != null) return colwidthValue;
20564
20714
  if (gridColumns && gridColumns[colIndex2] != null) return gridColumns[colIndex2];
20565
20715
  return null;
20566
20716
  };
20567
20717
  const widths = [];
20568
- const row = node.firstChild;
20718
+ const firstRow = node.firstChild;
20569
20719
  let colIndex = 0;
20570
- if (row !== null) {
20571
- for (let i = 0; i < row.childCount; i++) {
20572
- const child = row.child(i);
20720
+ if (firstRow !== null) {
20721
+ for (let i = 0; i < firstRow.childCount; i++) {
20722
+ const child = firstRow.child(i);
20573
20723
  const { colspan, colwidth } = child.attrs;
20574
20724
  for (let span = 0; span < colspan; span += 1, colIndex += 1) {
20575
20725
  widths.push(resolveColumnWidth(colIndex, colwidth && colwidth[span]));
@@ -20589,49 +20739,41 @@ function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrid
20589
20739
  if (numericWidth < 1) return 0;
20590
20740
  return numericWidth;
20591
20741
  });
20592
- const rawTotalWidth = normalizedWidths.reduce((sum, width) => sum + (width != null ? width : cellMinWidth), 0);
20593
- let scale = 1;
20594
- if (availableWidth && rawTotalWidth > 0 && rawTotalWidth > availableWidth) {
20595
- scale = availableWidth / rawTotalWidth;
20596
- }
20597
- let totalWidth = 0;
20598
- let hasUndefinedWidth = false;
20599
- let dom = colgroup.firstChild;
20742
+ const tableWidthCSS = convertSizeToCSS(
20743
+ // TODO: why is tableWidth undefined in src/tests/import-export/font-default-styles.test.js?
20744
+ node.attrs.tableProperties.tableWidth?.value ?? null,
20745
+ node.attrs.tableProperties.tableWidth?.type ?? "auto"
20746
+ );
20747
+ let colElement = colgroup.firstChild;
20600
20748
  normalizedWidths.forEach((width) => {
20601
- let scaledWidth = width;
20602
- if (scaledWidth != null) {
20603
- scaledWidth = scaledWidth * scale;
20604
- }
20605
- const [propKey, propVal] = getColStyleDeclaration(cellMinWidth, scaledWidth);
20606
- if (scaledWidth == null) {
20607
- totalWidth += cellMinWidth;
20608
- hasUndefinedWidth = true;
20609
- } else {
20610
- totalWidth += scaledWidth;
20611
- }
20612
- if (!dom) {
20613
- const colElement = document.createElement("col");
20614
- colElement.style.setProperty(propKey, propVal);
20749
+ if (!colElement) {
20750
+ colElement = document.createElement("col");
20615
20751
  colgroup.appendChild(colElement);
20616
- } else {
20617
- dom.style.setProperty(propKey, propVal);
20618
- dom = dom.nextSibling;
20619
20752
  }
20753
+ colElement.style.width = width !== null && width !== void 0 ? `${width}px` : null;
20754
+ colElement = colElement.nextSibling;
20620
20755
  });
20621
- while (dom) {
20622
- const next = dom.nextSibling;
20623
- dom.parentNode?.removeChild(dom);
20624
- dom = next;
20625
- }
20626
- if (scale < 1 || !hasUndefinedWidth) {
20627
- const clampedWidth = Math.min(totalWidth, availableWidth || totalWidth);
20628
- table.style.width = `${clampedWidth}px`;
20629
- table.style.minWidth = "";
20756
+ while (colElement) {
20757
+ const next = colElement.nextSibling;
20758
+ colElement.parentNode?.removeChild(colElement);
20759
+ colElement = next;
20760
+ }
20761
+ const tableIndent = convertSizeToCSS(
20762
+ node.attrs.tableProperties.tableIndent?.value ?? 0,
20763
+ node.attrs.tableProperties.tableIndent?.type ?? "dxa"
20764
+ );
20765
+ const firstRowFirstCellPaddingLeftPx = firstRow?.firstChild?.attrs?.cellMargins?.left ?? 0;
20766
+ const firstRowLastCellPaddingRightPx = firstRow?.lastChild?.attrs?.cellMargins?.right ?? 0;
20767
+ table.style.marginLeft = `${-firstRowFirstCellPaddingLeftPx}px`;
20768
+ if (tableIndent !== null) {
20769
+ table.style.marginLeft = tableIndent;
20770
+ }
20771
+ if (node.attrs.tableProperties.tableWidth?.type === "pct") {
20772
+ const padding = firstRowFirstCellPaddingLeftPx + firstRowLastCellPaddingRightPx;
20773
+ table.style.maxWidth = table.style.width = `calc(${tableWidthCSS} + ${padding}px)`;
20630
20774
  } else {
20631
- table.style.width = "";
20632
- table.style.minWidth = `${totalWidth}px`;
20775
+ table.style.maxWidth = table.style.width = tableWidthCSS;
20633
20776
  }
20634
- table.style.maxWidth = "100%";
20635
20777
  }
20636
20778
  function updateTable(editor, node, table) {
20637
20779
  const allExtensionsAttrs = editor.extensionService.attributes;
@@ -20709,6 +20851,15 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
20709
20851
  const tableBorders = createTableBorders();
20710
20852
  return types.table.createChecked({ borders: tableBorders }, rows);
20711
20853
  };
20854
+ const getColStyleDeclaration = (minWidth, width) => {
20855
+ if (width != null) {
20856
+ const numericWidth = Number(width);
20857
+ if (Number.isFinite(numericWidth) && numericWidth >= 0) {
20858
+ return ["width", `${numericWidth}px`];
20859
+ }
20860
+ }
20861
+ return ["min-width", `${minWidth}px`];
20862
+ };
20712
20863
  const MIN_MEANINGFUL_WIDTH_PX = 1;
20713
20864
  const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
20714
20865
  let totalWidth = 0;
@@ -23075,15 +23226,6 @@ const Table = Node$1.create({
23075
23226
  },
23076
23227
  addAttributes() {
23077
23228
  return {
23078
- /* tableWidth: {
23079
- renderDOM: ({ tableWidth }) => {
23080
- if (!tableWidth) return {};
23081
- const { width, type = 'auto' } = tableWidth;
23082
- return {
23083
- style: `width: ${width}px`
23084
- };
23085
- },
23086
- }, */
23087
23229
  /**
23088
23230
  * @private
23089
23231
  * @category Attribute
@@ -23187,7 +23329,12 @@ const Table = Node$1.create({
23187
23329
  * @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
23188
23330
  */
23189
23331
  tableProperties: {
23190
- default: null,
23332
+ default: {
23333
+ tableWidth: {
23334
+ value: null,
23335
+ type: "auto"
23336
+ }
23337
+ },
23191
23338
  rendered: false
23192
23339
  },
23193
23340
  /**
@@ -23955,12 +24102,14 @@ const TableCell = Node$1.create({
23955
24102
  }
23956
24103
  },
23957
24104
  cellMargins: {
23958
- renderDOM({ cellMargins }) {
24105
+ renderDOM({ cellMargins, borders }) {
23959
24106
  if (!cellMargins) return {};
23960
24107
  const sides2 = ["top", "right", "bottom", "left"];
23961
24108
  const style = sides2.map((side) => {
23962
- const margin = cellMargins?.[side];
23963
- if (margin) return `padding-${side}: ${margin}px;`;
24109
+ const margin = cellMargins?.[side] ?? 0;
24110
+ const border = borders?.[side];
24111
+ const borderSize = border && border.val !== "none" ? Math.ceil(border.size) : 0;
24112
+ if (margin) return `padding-${side}: ${Math.max(0, margin - borderSize)}px;`;
23964
24113
  return "";
23965
24114
  }).join(" ");
23966
24115
  return { style };
@@ -1,4 +1,4 @@
1
- import { aF as getDefaultExportFromCjs } from "./converter-BIsS-JzD.js";
1
+ import { aF as getDefaultExportFromCjs } from "./converter-DVDL6NWz.js";
2
2
  import { V as VFile } from "./index-CvBqQJbG.js";
3
3
  function bail(error) {
4
4
  if (error) {
@@ -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-BIsS-JzD.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-ZbcM1RTL.js";
2
+ import { p as process$1 } from "./converter-DVDL6NWz.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-B8v33PJq.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 { a7 } from "./chunks/converter-BIsS-JzD.js";
1
+ import { a7 } from "./chunks/converter-DVDL6NWz.js";
2
2
  export {
3
3
  a7 as SuperConverter
4
4
  };
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-BIsS-JzD.js";
2
- import { D } from "./chunks/docx-zipper-DVDiaIyD.js";
1
+ import "./chunks/converter-DVDL6NWz.js";
2
+ import { D } from "./chunks/docx-zipper-4ipmBNSH.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-ZbcM1RTL.js";
2
- import "./chunks/converter-BIsS-JzD.js";
3
- import "./chunks/docx-zipper-DVDiaIyD.js";
1
+ import { E } from "./chunks/editor-B8v33PJq.js";
2
+ import "./chunks/converter-DVDL6NWz.js";
3
+ import "./chunks/docx-zipper-4ipmBNSH.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-DVDiaIyD.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-4ipmBNSH.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {