@harbour-enterprises/superdoc 0.18.0-next.2 → 0.18.0-next.3

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 (41) hide show
  1. package/dist/chunks/{PdfViewer-D9sb0T1f.cjs → PdfViewer-DDwiCSwf.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-C3MhLK2d.es.js → PdfViewer-Md3OYLQ6.es.js} +1 -1
  3. package/dist/chunks/{index-D4MPFidQ.cjs → index-B8Gqq2Ls.cjs} +2 -2
  4. package/dist/chunks/{index-OlqsNrl5.es.js → index-nnK3k8Eg.es.js} +2 -2
  5. package/dist/chunks/{super-editor.es-D57bZvWs.es.js → super-editor.es-C2jrGo_q.es.js} +366 -42
  6. package/dist/chunks/{super-editor.es-D0wPEvPh.cjs → super-editor.es-DPPXteBi.cjs} +366 -42
  7. package/dist/super-editor/ai-writer.es.js +2 -2
  8. package/dist/super-editor/chunks/{converter-DdzGurMJ.js → converter-YnaMMkRN.js} +15 -11
  9. package/dist/super-editor/chunks/{docx-zipper-Bjul2JVv.js → docx-zipper-Bq9-qqP_.js} +1 -1
  10. package/dist/super-editor/chunks/{editor-Dlzi1Ni6.js → editor-CAEseNKq.js} +353 -33
  11. package/dist/super-editor/chunks/{toolbar-DIRJurpK.js → toolbar-BxxxSTHJ.js} +2 -2
  12. package/dist/super-editor/converter.es.js +1 -1
  13. package/dist/super-editor/docx-zipper.es.js +2 -2
  14. package/dist/super-editor/editor.es.js +3 -3
  15. package/dist/super-editor/file-zipper.es.js +1 -1
  16. package/dist/super-editor/src/extensions/block-node/block-node.d.ts +27 -3
  17. package/dist/super-editor/src/extensions/color/color.d.ts +1 -1
  18. package/dist/super-editor/src/extensions/dropcursor/dropcursor.d.ts +5 -0
  19. package/dist/super-editor/src/extensions/gapcursor/gapcursor.d.ts +5 -0
  20. package/dist/super-editor/src/extensions/image/image.d.ts +5 -0
  21. package/dist/super-editor/src/extensions/image/imageHelpers/getFileOpener.d.ts +1 -1
  22. package/dist/super-editor/src/extensions/image/imageHelpers/handleImageUpload.d.ts +1 -1
  23. package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +2 -3
  24. package/dist/super-editor/src/extensions/image/imageHelpers/imagePositionPlugin.d.ts +1 -2
  25. package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -5
  26. package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +18 -3
  27. package/dist/super-editor/src/extensions/linked-styles/helpers.d.ts +4 -6
  28. package/dist/super-editor/src/extensions/linked-styles/linked-styles.d.ts +29 -0
  29. package/dist/super-editor/src/extensions/linked-styles/plugin.d.ts +4 -2
  30. package/dist/super-editor/src/extensions/text-align/text-align.d.ts +9 -0
  31. package/dist/super-editor/src/extensions/text-indent/text-indent.d.ts +19 -0
  32. package/dist/super-editor/src/extensions/text-transform/text-transform.d.ts +5 -0
  33. package/dist/super-editor/super-editor.es.js +6 -6
  34. package/dist/super-editor/toolbar.es.js +2 -2
  35. package/dist/super-editor.cjs +1 -1
  36. package/dist/super-editor.es.js +1 -1
  37. package/dist/superdoc.cjs +2 -2
  38. package/dist/superdoc.es.js +2 -2
  39. package/dist/superdoc.umd.js +366 -42
  40. package/dist/superdoc.umd.js.map +1 -1
  41. package/package.json +1 -1
@@ -27612,17 +27612,21 @@
27612
27612
  let listDefinitionForThisNumId = abstractDefinitions?.find(
27613
27613
  (style2) => style2.attributes["w:abstractNumId"] === abstractNumId
27614
27614
  );
27615
- const templateIdTag = listDefinitionForThisNumId?.elements?.find((el) => el.name === "w:tmpl");
27616
- const templateId = templateIdTag?.attributes?.["w:val"];
27617
- if (templateId) {
27618
- listDefinitionForThisNumId = numberingElements?.find((el) => {
27619
- if (el.name !== "w:abstractNum") return false;
27620
- const tmpl = el.elements?.find((el2) => el2.name === "w:tmpl");
27621
- if (!tmpl) return false;
27622
- const hasLevels = el.elements?.some((el2) => el2.name === "w:lvl");
27623
- const tmplId = tmpl.attributes?.["w:val"];
27624
- return tmplId && hasLevels && tmplId === templateId;
27625
- });
27615
+ const hasLevels = listDefinitionForThisNumId?.elements?.some((el) => el.name === "w:lvl");
27616
+ if (!listDefinitionForThisNumId || !hasLevels) {
27617
+ const templateIdTag = listDefinitionForThisNumId?.elements?.find((el) => el.name === "w:tmpl");
27618
+ const templateId = templateIdTag?.attributes?.["w:val"];
27619
+ if (templateId) {
27620
+ const byTemplate = numberingElements?.find((el) => {
27621
+ if (el.name !== "w:abstractNum") return false;
27622
+ const tmpl = el.elements?.find((el2) => el2.name === "w:tmpl");
27623
+ if (!tmpl) return false;
27624
+ const tmplId = tmpl.attributes?.["w:val"];
27625
+ const hasLvl = el.elements?.some((e) => e.name === "w:lvl");
27626
+ return tmplId && hasLvl && tmplId === templateId;
27627
+ });
27628
+ if (byTemplate) listDefinitionForThisNumId = byTemplate;
27629
+ }
27626
27630
  }
27627
27631
  return listDefinitionForThisNumId;
27628
27632
  };
@@ -56214,6 +56218,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56214
56218
  {
56215
56219
  types: this.options.types,
56216
56220
  attributes: {
56221
+ /**
56222
+ * @category Attribute
56223
+ * @param {string} [textAlign='left'] - Text alignment value (left, center, right, justify)
56224
+ */
56217
56225
  textAlign: {
56218
56226
  default: this.options.defaultAlignment,
56219
56227
  parseDOM: (el) => {
@@ -56234,11 +56242,32 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56234
56242
  },
56235
56243
  addCommands() {
56236
56244
  return {
56245
+ /**
56246
+ * Set text alignment
56247
+ * @category Command
56248
+ * @param {string} alignment - Alignment value (left, center, right, justify)
56249
+ * @returns {Function} Command function
56250
+ * @example
56251
+ * // Set to center
56252
+ * setTextAlign('center')
56253
+ *
56254
+ * // Set to justify
56255
+ * setTextAlign('justify')
56256
+ * @note Applies to all configured node types (heading, paragraph by default)
56257
+ */
56237
56258
  setTextAlign: (alignment2) => ({ commands: commands2 }) => {
56238
56259
  const containsAlignment = this.options.alignments.includes(alignment2);
56239
56260
  if (!containsAlignment) return false;
56240
56261
  return this.options.types.map((type2) => commands2.updateAttributes(type2, { textAlign: alignment2 })).every((result) => result);
56241
56262
  },
56263
+ /**
56264
+ * Remove text alignment (reset to default)
56265
+ * @category Command
56266
+ * @returns {Function} Command function
56267
+ * @example
56268
+ * unsetTextAlign()
56269
+ * @note Resets alignment to the default value
56270
+ */
56242
56271
  unsetTextAlign: () => ({ commands: commands2 }) => {
56243
56272
  return this.options.types.map((type2) => commands2.resetAttributes(type2, "textAlign")).every((result) => result);
56244
56273
  }
@@ -56269,6 +56298,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56269
56298
  {
56270
56299
  types: this.options.types,
56271
56300
  attributes: {
56301
+ /**
56302
+ * @category Attribute
56303
+ * @param {string} [textIndent] - Text indentation value with unit (e.g., '0.5in')
56304
+ */
56272
56305
  textIndent: {
56273
56306
  default: null,
56274
56307
  parseDOM: (el) => el.style.textIndent,
@@ -56286,13 +56319,43 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56286
56319
  },
56287
56320
  addCommands() {
56288
56321
  return {
56322
+ /**
56323
+ * Set text indentation
56324
+ * @category Command
56325
+ * @param {string} indent - Indentation value with unit (e.g., '0.5in', '2cm')
56326
+ * @returns {Function} Command function
56327
+ * @example
56328
+ * // Set to 0.5 inches
56329
+ * setTextIndent('0.5in')
56330
+ *
56331
+ * // Set to 2 centimeters
56332
+ * setTextIndent('2cm')
56333
+ * @note Accepts any valid CSS unit (in, cm, px, em, etc.)
56334
+ */
56289
56335
  setTextIndent: (indent) => ({ commands: commands2 }) => {
56290
56336
  if (!indent) return false;
56291
56337
  return this.options.types.map((type2) => commands2.updateAttributes(type2, { textIndent: indent })).every((result) => result);
56292
56338
  },
56339
+ /**
56340
+ * Remove text indentation
56341
+ * @category Command
56342
+ * @returns {Function} Command function
56343
+ * @example
56344
+ * unsetTextIndent()
56345
+ * @note Removes all indentation from the selected nodes
56346
+ */
56293
56347
  unsetTextIndent: () => ({ commands: commands2 }) => {
56294
56348
  return this.options.types.map((type2) => commands2.resetAttributes(type2, "textIndent")).every((result) => result);
56295
56349
  },
56350
+ /**
56351
+ * Increase text indentation
56352
+ * @category Command
56353
+ * @returns {Function} Command function
56354
+ * @example
56355
+ * increaseTextIndent()
56356
+ * @note Increments by the default value (0.125in by default)
56357
+ * @note Creates initial indent if none exists
56358
+ */
56296
56359
  increaseTextIndent: () => ({ commands: commands2 }) => {
56297
56360
  return this.options.types.map((type2) => {
56298
56361
  let { textIndent } = this.editor.getAttributes(type2);
@@ -56303,7 +56366,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56303
56366
  });
56304
56367
  }
56305
56368
  let [value, unit] = parseSizeUnit(textIndent);
56306
- value = value + this.options.defaults.increment;
56369
+ value = Number(value) + this.options.defaults.increment;
56307
56370
  unit = unit ? unit : this.options.defaults.unit;
56308
56371
  if (Number.isNaN(value)) return false;
56309
56372
  return commands2.updateAttributes(type2, {
@@ -56311,12 +56374,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56311
56374
  });
56312
56375
  }).every((result) => result);
56313
56376
  },
56377
+ /**
56378
+ * Decrease text indentation
56379
+ * @category Command
56380
+ * @returns {Function} Command function
56381
+ * @example
56382
+ * decreaseTextIndent()
56383
+ * @note Decrements by the default value (0.125in by default)
56384
+ * @note Removes indentation completely if it reaches 0 or below
56385
+ */
56314
56386
  decreaseTextIndent: () => ({ commands: commands2 }) => {
56315
56387
  return this.options.types.map((type2) => {
56316
56388
  let { textIndent } = this.editor.getAttributes(type2);
56317
56389
  if (!textIndent) return false;
56318
56390
  let [value, unit] = parseSizeUnit(textIndent);
56319
- value = value - this.options.defaults.increment;
56391
+ value = Number(value) - this.options.defaults.increment;
56320
56392
  unit = unit ? unit : this.options.defaults.unit;
56321
56393
  if (Number.isNaN(value)) return false;
56322
56394
  if (value <= 0) {
@@ -56885,8 +56957,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56885
56957
  addPmPlugins() {
56886
56958
  return [gapCursor()];
56887
56959
  },
56960
+ /**
56961
+ * Extend node schema to allow gap cursor positioning
56962
+ * @returns {Object} Schema extension with allowGapCursor property
56963
+ */
56888
56964
  extendNodeSchema(extension) {
56889
56965
  return {
56966
+ /**
56967
+ * Whether to allow gap cursor before/after this node
56968
+ * Set to false on nodes where gap cursor shouldn't appear
56969
+ * @type {boolean|null}
56970
+ */
56890
56971
  allowGapCursor: callOrGet(
56891
56972
  getExtensionConfigField(extension, "allowGapCursor", {
56892
56973
  name: extension.name,
@@ -57948,10 +58029,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57948
58029
  };
57949
58030
  const getSpacingStyle = (spacing) => {
57950
58031
  const { lineSpaceBefore, lineSpaceAfter, line, lineRule } = spacing;
58032
+ const lineHeightResult = getLineHeightValueString(line, "", lineRule, true);
58033
+ const lineHeightStyles = typeof lineHeightResult === "object" && lineHeightResult !== null ? lineHeightResult : {};
57951
58034
  return {
57952
58035
  "margin-top": lineSpaceBefore + "px",
57953
58036
  "margin-bottom": lineSpaceAfter + "px",
57954
- ...getLineHeightValueString(line, "", lineRule, true)
58037
+ ...lineHeightStyles
57955
58038
  };
57956
58039
  };
57957
58040
  const getSpacingStyleString = (spacing) => {
@@ -58136,6 +58219,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58136
58219
  return new Plugin({
58137
58220
  key: LinkedStylesPluginKey,
58138
58221
  state: {
58222
+ /**
58223
+ * Initialize plugin state with styles and decorations
58224
+ * @returns {Object} Initial state with styles and decorations
58225
+ * @private
58226
+ */
58139
58227
  init() {
58140
58228
  if (!editor.converter || editor.options.mode !== "docx") return {};
58141
58229
  const styles = editor.converter?.linkedStyles || [];
@@ -58144,6 +58232,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58144
58232
  decorations: generateDecorations(editor.state, styles)
58145
58233
  };
58146
58234
  },
58235
+ /**
58236
+ * Update decorations when document changes
58237
+ * @param {Object} tr - The transaction
58238
+ * @param {Object} prev - Previous plugin state
58239
+ * @param {Object} oldEditorState - Old editor state
58240
+ * @param {Object} newEditorState - New editor state
58241
+ * @returns {Object} Updated state with styles and decorations
58242
+ * @private
58243
+ */
58147
58244
  apply(tr, prev, oldEditorState, newEditorState) {
58148
58245
  if (!editor.converter || editor.options.mode !== "docx") return { ...prev };
58149
58246
  let decorations = prev.decorations || DecorationSet.empty;
@@ -58155,6 +58252,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58155
58252
  }
58156
58253
  },
58157
58254
  props: {
58255
+ /**
58256
+ * Provide decorations to the editor view
58257
+ * @param {Object} state - Current editor state
58258
+ * @returns {Object} The decoration set
58259
+ * @private
58260
+ */
58158
58261
  decorations(state2) {
58159
58262
  return LinkedStylesPluginKey.getState(state2)?.decorations;
58160
58263
  }
@@ -58196,24 +58299,35 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58196
58299
  addCommands() {
58197
58300
  return {
58198
58301
  /**
58199
- * Apply a linked style to the current selection.
58200
- *
58201
- * @param {object} style The linked style to apply
58202
- * @param {string} style.id The style ID (e.g., 'Heading1')
58203
- * @returns {boolean} Whether the style was correctly applied
58302
+ * Apply a linked style to the selected paragraphs
58303
+ * @category Command
58304
+ * @param {Object} style - The style object to apply
58305
+ * @returns {Function} Command function
58306
+ * @example
58307
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
58308
+ * setLinkedStyle(style);
58309
+ * @note Clears existing formatting when applying a style
58310
+ * @note Works with custom selection preservation
58204
58311
  */
58205
58312
  setLinkedStyle: (style2) => (params2) => {
58206
58313
  const { tr } = params2;
58207
58314
  return applyLinkedStyleToTransaction(tr, this.editor, style2);
58208
58315
  },
58209
58316
  /**
58210
- * Toggle a linked style on the current selection.
58317
+ * Toggle a linked style on the current selection
58318
+ * @category Command
58319
+ * @param {Object} style - The linked style to apply (with id property)
58320
+ * @param {string|null} [nodeType=null] - Node type to restrict toggle to (e.g., 'paragraph')
58321
+ * @returns {Function} Command function
58322
+ * @example
58323
+ * // Toggle a heading style
58324
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
58325
+ * toggleLinkedStyle(style)
58211
58326
  *
58212
- * @param {object} style The linked style to apply
58213
- * @param {string} style.id The style ID (e.g., 'Heading1')
58214
- * @param {string|null} nodeType The node type to restrict the toggle to (e.g., 'paragraph'). If null,
58215
- * the style can be toggled on any node type.
58216
- * @returns {boolean} Whether the style was correctly applied/removed
58327
+ * // Toggle only on paragraph nodes
58328
+ * toggleLinkedStyle(style, 'paragraph')
58329
+ * @note If selection is empty, returns false
58330
+ * @note Removes style if already applied, applies it if not
58217
58331
  */
58218
58332
  toggleLinkedStyle: (style2, nodeType = null) => (params2) => {
58219
58333
  const { tr } = params2;
@@ -58236,9 +58350,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58236
58350
  return applyLinkedStyleToTransaction(tr, this.editor, style2);
58237
58351
  },
58238
58352
  /**
58239
- * Apply a linked style by its ID.
58240
- * @param {string} styleId The style ID (e.g., 'Heading1')
58241
- * @returns {boolean} Whether the style was correctly applied
58353
+ * Apply a linked style by its ID
58354
+ * @category Command
58355
+ * @param {string} styleId - The style ID to apply (e.g., 'Heading1')
58356
+ * @returns {Function} Command function
58357
+ * @example
58358
+ * // Apply a heading style
58359
+ * setStyleById('Heading1')
58360
+ *
58361
+ * // Apply a normal style
58362
+ * setStyleById('Normal')
58363
+ * @note Looks up the style from loaded Word styles
58242
58364
  */
58243
58365
  setStyleById: (styleId) => (params2) => {
58244
58366
  const { state: state2, tr } = params2;
@@ -58253,22 +58375,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58253
58375
  addHelpers() {
58254
58376
  return {
58255
58377
  /**
58256
- * Get all linked styles available in the editor
58378
+ * Get all available linked styles
58379
+ * @category Helper
58257
58380
  * @returns {Array} Array of linked style objects
58381
+ * @example
58382
+ * const styles = editor.helpers.linkedStyles.getStyles();
58383
+ * // Returns all styles from the Word document
58258
58384
  */
58259
58385
  getStyles: () => {
58260
58386
  const styles = LinkedStylesPluginKey.getState(this.editor.state)?.styles || [];
58261
58387
  return styles;
58262
58388
  },
58263
58389
  /**
58264
- * Get a linked style by its ID
58265
- * @param {string} styleId The style ID (e.g., 'Heading1')
58266
- * @returns {object|null} The linked style object or null if not found
58390
+ * Get a specific style by ID
58391
+ * @category Helper
58392
+ * @param {string} styleId - The style ID to find
58393
+ * @returns {Object} The style object or undefined
58394
+ * @example
58395
+ * const headingStyle = editor.helpers.linkedStyles.getStyleById('Heading1');
58267
58396
  */
58268
58397
  getStyleById: (styleId) => {
58269
58398
  const styles = this.editor.helpers[this.name].getStyles();
58270
58399
  return styles.find((s) => s.id === styleId);
58271
58400
  },
58401
+ /**
58402
+ * Get the CSS string for a style
58403
+ * @category Helper
58404
+ * @param {string} styleId - The style ID
58405
+ * @returns {string} CSS style string
58406
+ * @example
58407
+ * const css = editor.helpers.linkedStyles.getLinkedStyleString('Heading1');
58408
+ * // Returns: "font-size: 16pt; font-weight: bold; color: #2E74B5"
58409
+ * @private
58410
+ */
58272
58411
  getLinkedStyleString: (styleId) => {
58273
58412
  const styles = this.editor.helpers.linkedStyles.getStyles();
58274
58413
  const style2 = styles.find((s) => s.id === styleId);
@@ -64647,6 +64786,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64647
64786
  },
64648
64787
  addAttributes() {
64649
64788
  return {
64789
+ /**
64790
+ * @category Attribute
64791
+ * @param {string} [src] - Image source URL or path
64792
+ */
64650
64793
  src: {
64651
64794
  default: null,
64652
64795
  renderDOM: ({ src }) => {
@@ -64655,31 +64798,90 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64655
64798
  };
64656
64799
  }
64657
64800
  },
64801
+ /**
64802
+ * @category Attribute
64803
+ * @param {string} [alt='Uploaded picture'] - Alternative text for accessibility
64804
+ */
64658
64805
  alt: {
64659
64806
  default: "Uploaded picture"
64660
64807
  },
64808
+ /**
64809
+ * @category Attribute
64810
+ * @param {string} [id] - Image element ID
64811
+ * @private
64812
+ */
64661
64813
  id: { rendered: false },
64814
+ /**
64815
+ * @category Attribute
64816
+ * @param {string} [title] - Image title/tooltip text
64817
+ */
64662
64818
  title: {
64663
64819
  default: null
64664
64820
  },
64821
+ /**
64822
+ * @category Attribute
64823
+ * @param {string} [rId] - Relationship ID for Word export
64824
+ * @private
64825
+ */
64665
64826
  rId: {
64666
64827
  default: null,
64667
64828
  rendered: false
64668
64829
  },
64830
+ /**
64831
+ * @category Attribute
64832
+ * @param {Object} [originalPadding] - Original padding values from Word import
64833
+ * @private
64834
+ */
64669
64835
  originalPadding: {
64670
64836
  default: null,
64671
64837
  rendered: false
64672
64838
  },
64839
+ /**
64840
+ * @category Attribute
64841
+ * @param {Object} [originalAttributes] - Original attributes from Word import
64842
+ * @private
64843
+ */
64673
64844
  originalAttributes: { rendered: false },
64845
+ /**
64846
+ * @category Attribute
64847
+ * @param {boolean} [wrapTopAndBottom] - Wrap text above and below image
64848
+ * @private
64849
+ */
64674
64850
  wrapTopAndBottom: { rendered: false },
64851
+ /**
64852
+ * @category Attribute
64853
+ * @param {Object} [anchorData] - Anchor positioning data for Word
64854
+ * @private
64855
+ */
64675
64856
  anchorData: {
64676
64857
  default: null,
64677
64858
  rendered: false
64678
64859
  },
64860
+ /**
64861
+ * @category Attribute
64862
+ * @param {boolean} [isAnchor] - Whether image is anchored
64863
+ * @private
64864
+ */
64679
64865
  isAnchor: { rendered: false },
64866
+ /**
64867
+ * @category Attribute
64868
+ * @param {boolean} [simplePos] - Simple positioning flag
64869
+ * @private
64870
+ */
64680
64871
  simplePos: { rendered: false },
64872
+ /**
64873
+ * @category Attribute
64874
+ * @param {string} [wrapText] - Text wrapping style
64875
+ * @private
64876
+ */
64681
64877
  wrapText: { rendered: false },
64682
64878
  extension: { rendered: false },
64879
+ /**
64880
+ * @category Attribute
64881
+ * @param {Object} [size] - Image dimensions
64882
+ * @param {number} [size.width] - Width in pixels
64883
+ * @param {number} [size.height] - Height in pixels
64884
+ */
64683
64885
  size: {
64684
64886
  default: {},
64685
64887
  renderDOM: ({ size: size2, extension }) => {
@@ -64692,6 +64894,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64692
64894
  return { style: style2 };
64693
64895
  }
64694
64896
  },
64897
+ /**
64898
+ * @category Attribute
64899
+ * @param {Object} [padding] - Image padding/margins
64900
+ * @param {number} [padding.left] - Left padding in pixels
64901
+ * @param {number} [padding.top] - Top padding in pixels
64902
+ * @param {number} [padding.bottom] - Bottom padding in pixels
64903
+ * @param {number} [padding.right] - Right padding in pixels
64904
+ */
64695
64905
  padding: {
64696
64906
  default: {},
64697
64907
  renderDOM: ({ padding, marginOffset }) => {
@@ -64704,6 +64914,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64704
64914
  return { style: style2 };
64705
64915
  }
64706
64916
  },
64917
+ /**
64918
+ * @category Attribute
64919
+ * @param {Object} [marginOffset] - Margin offset for anchored images
64920
+ * @param {number} [marginOffset.left] - Left margin offset
64921
+ * @param {number} [marginOffset.top] - Top margin offset
64922
+ */
64707
64923
  marginOffset: {
64708
64924
  default: {},
64709
64925
  renderDOM: ({ marginOffset, anchorData }) => {
@@ -64719,6 +64935,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64719
64935
  return { style: style2 };
64720
64936
  }
64721
64937
  },
64938
+ /**
64939
+ * @category Attribute
64940
+ * @param {string} [style] - Custom inline CSS styles
64941
+ */
64722
64942
  style: {
64723
64943
  default: null,
64724
64944
  rendered: true,
@@ -64741,6 +64961,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64741
64961
  },
64742
64962
  addCommands() {
64743
64963
  return {
64964
+ /**
64965
+ * Insert an image at the current position
64966
+ * @category Command
64967
+ * @param {Object} options - Image attributes
64968
+ * @param {string} options.src - Image source URL or data URI
64969
+ * @param {string} [options.alt] - Alternative text
64970
+ * @param {string} [options.title] - Image title
64971
+ * @param {Object} [options.size] - Image dimensions
64972
+ * @returns {Function} Command function
64973
+ * @example
64974
+ * // Insert an image from a URL
64975
+ * setImage({ src: 'https://example.com/image.jpg' })
64976
+ *
64977
+ * // Insert a base64 encoded image
64978
+ * setImage({
64979
+ * src: 'data:image/png;base64,...',
64980
+ * alt: 'Company logo',
64981
+ * size: { width: 200 }
64982
+ * })
64983
+ * @note Supports URLs, relative paths, and base64 data URIs
64984
+ */
64744
64985
  setImage: (options) => ({ commands: commands2 }) => {
64745
64986
  return commands2.insertContent({
64746
64987
  type: this.name,
@@ -64778,7 +65019,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64778
65019
  const handleImageUpload = (file) => {
64779
65020
  return new Promise((resolve2, reject) => {
64780
65021
  let reader = new FileReader();
64781
- reader.onload = (event) => resolve2(event.target.result);
65022
+ reader.onload = (event) => {
65023
+ resolve2(event.target.result);
65024
+ };
64782
65025
  reader.onerror = reject;
64783
65026
  setTimeout(() => reader.readAsDataURL(file), 250);
64784
65027
  });
@@ -64982,8 +65225,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64982
65225
  let rId = null;
64983
65226
  if (editor.options.mode === "docx") {
64984
65227
  const [, path] = mediaPath.split("word/");
64985
- const id2 = addImageRelationship({ editor, path });
64986
- if (id2) rId = id2;
65228
+ const imageid = addImageRelationship({ editor, path });
65229
+ if (imageid) rId = imageid;
64987
65230
  }
64988
65231
  let imageNode = schema.nodes.image.create({
64989
65232
  src: mediaPath,
@@ -65006,8 +65249,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65006
65249
  const target = path;
65007
65250
  const type2 = "image";
65008
65251
  try {
65009
- const id = insertNewRelationship(target, type2, editor);
65010
- return id;
65252
+ const relationshipId = insertNewRelationship(target, type2, editor);
65253
+ return relationshipId;
65011
65254
  } catch {
65012
65255
  return null;
65013
65256
  }
@@ -66120,6 +66363,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66120
66363
  name: "blockNode",
66121
66364
  addCommands() {
66122
66365
  return {
66366
+ /**
66367
+ * Replace a block node by its ID with new content
66368
+ * @category Command
66369
+ * @param {string} id - The sdBlockId of the node to replace
66370
+ * @param {Object} contentNode - The replacement ProseMirror node
66371
+ * @returns {Function} Command function
66372
+ * @example
66373
+ * const newParagraph = editor.schema.nodes.paragraph.create({}, editor.schema.text('New content'))
66374
+ * replaceBlockNodeById('block-123', newParagraph)
66375
+ * @note The replacement node should have the same type as the original
66376
+ */
66123
66377
  replaceBlockNodeById: (id, contentNode) => ({ dispatch, tr }) => {
66124
66378
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
66125
66379
  if (!blockNode || blockNode.length > 1) {
@@ -66136,6 +66390,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66136
66390
  }
66137
66391
  return true;
66138
66392
  },
66393
+ /**
66394
+ * Delete a block node by its ID
66395
+ * @category Command
66396
+ * @param {string} id - The sdBlockId of the node to delete
66397
+ * @returns {Function} Command function
66398
+ * @example
66399
+ * deleteBlockNodeById('block-123')
66400
+ * @note Completely removes the node from the document
66401
+ */
66139
66402
  deleteBlockNodeById: (id) => ({ dispatch, tr }) => {
66140
66403
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
66141
66404
  if (!blockNode || blockNode.length > 1) {
@@ -66152,6 +66415,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66152
66415
  }
66153
66416
  return true;
66154
66417
  },
66418
+ /**
66419
+ * Update attributes of a block node by its ID
66420
+ * @category Command
66421
+ * @param {string} id - The sdBlockId of the node to update
66422
+ * @param {Object} attrs - Attributes to update
66423
+ * @returns {Function} Command function
66424
+ * @example
66425
+ * updateBlockNodeAttributes('block-123', { textAlign: 'center' })
66426
+ * @example
66427
+ * updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
66428
+ * @note Merges new attributes with existing ones
66429
+ */
66155
66430
  updateBlockNodeAttributes: (id, attrs = {}) => ({ dispatch, tr }) => {
66156
66431
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
66157
66432
  if (!blockNode || blockNode.length > 1) {
@@ -66174,15 +66449,54 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66174
66449
  },
66175
66450
  addHelpers() {
66176
66451
  return {
66452
+ /**
66453
+ * Get all block nodes in the document
66454
+ * @category Helper
66455
+ * @returns {Array<BlockNodeInfo>} Array of block node info objects
66456
+ * @example
66457
+ * const blocks = editor.helpers.blockNode.getBlockNodes()
66458
+ * console.log(`Found ${blocks.length} block nodes`)
66459
+ */
66177
66460
  getBlockNodes: () => {
66178
66461
  return findChildren(this.editor.state.doc, (node2) => nodeAllowsSdBlockIdAttr(node2));
66179
66462
  },
66463
+ /**
66464
+ * Get a specific block node by its ID
66465
+ * @category Helper
66466
+ * @param {string} id - The sdBlockId to search for
66467
+ * @returns {Array<BlockNodeInfo>} Array containing the matching node (or empty)
66468
+ * @example
66469
+ * const block = editor.helpers.blockNode.getBlockNodeById('block-123')
66470
+ * if (block.length) console.log('Found:', block[0].node.type.name)
66471
+ */
66180
66472
  getBlockNodeById: (id) => {
66181
66473
  return findChildren(this.editor.state.doc, (node2) => node2.attrs.sdBlockId === id);
66182
66474
  },
66475
+ /**
66476
+ * Get all block nodes of a specific type
66477
+ * @category Helper
66478
+ * @param {string} type - The node type name (e.g., 'paragraph', 'heading')
66479
+ * @returns {Array<BlockNodeInfo>} Array of matching block nodes
66480
+ * @example
66481
+ * const paragraphs = editor.helpers.blockNode.getBlockNodesByType('paragraph')
66482
+ * const headings = editor.helpers.blockNode.getBlockNodesByType('heading')
66483
+ */
66183
66484
  getBlockNodesByType: (type2) => {
66184
66485
  return findChildren(this.editor.state.doc, (node2) => node2.type.name === type2);
66185
66486
  },
66487
+ /**
66488
+ * Get all block nodes within a position range
66489
+ * @category Helper
66490
+ * @param {number} from - Start position
66491
+ * @param {number} to - End position
66492
+ * @returns {Array<BlockNodeInfo>} Array of block nodes in the range
66493
+ * @example
66494
+ * const selection = editor.state.selection
66495
+ * const blocksInSelection = editor.helpers.blockNode.getBlockNodesInRange(
66496
+ * selection.from,
66497
+ * selection.to
66498
+ * )
66499
+ */
66186
66500
  getBlockNodesInRange: (from2, to) => {
66187
66501
  let blockNodes = [];
66188
66502
  this.editor.state.doc.nodesBetween(from2, to, (node2, pos) => {
@@ -66238,10 +66552,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66238
66552
  return !currentId;
66239
66553
  };
66240
66554
  const checkForNewBlockNodesInTrs = (transactions) => {
66241
- return transactions.some((tr) => {
66555
+ return Array.from(transactions).some((tr) => {
66242
66556
  return tr.steps.some((step) => {
66557
+ if (!(step instanceof ReplaceStep)) return false;
66243
66558
  const hasValidSdBlockNodes = step.slice?.content?.content?.some((node2) => nodeAllowsSdBlockIdAttr(node2));
66244
- return step instanceof ReplaceStep && hasValidSdBlockNodes;
66559
+ return hasValidSdBlockNodes;
66245
66560
  });
66246
66561
  });
66247
66562
  };
@@ -66270,6 +66585,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66270
66585
  },
66271
66586
  addAttributes() {
66272
66587
  return {
66588
+ /**
66589
+ * @category Attribute
66590
+ * @param {string} [styleId] - Style identifier for referencing predefined styles
66591
+ */
66273
66592
  styleId: {}
66274
66593
  };
66275
66594
  },
@@ -66278,10 +66597,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66278
66597
  /**
66279
66598
  * Remove empty text style marks
66280
66599
  * @category Command
66281
- * @returns {Function} Command - Removes mark if no attributes present
66600
+ * @returns {Function} Command function - Removes mark if no attributes present
66282
66601
  * @example
66283
66602
  * removeEmptyTextStyle()
66284
66603
  * @note Cleanup utility to prevent empty span elements
66604
+ * @note Automatically checks if any style attributes exist before removal
66285
66605
  */
66286
66606
  removeEmptyTextStyle: () => ({ state: state2, commands: commands2 }) => {
66287
66607
  const attributes = Attribute.getMarkAttributes(state2, this.type);
@@ -67303,12 +67623,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67303
67623
  {
67304
67624
  types: this.options.types,
67305
67625
  attributes: {
67626
+ /**
67627
+ * @category Attribute
67628
+ * @param {string} [textTransform] - Text transform value (uppercase, lowercase, capitalize, none)
67629
+ */
67306
67630
  textTransform: {
67307
67631
  default: null,
67308
67632
  renderDOM: (attrs) => {
67309
- if (!attrs.textCase) return {};
67633
+ if (!attrs.textTransform) return {};
67310
67634
  return {
67311
- style: `text-transform: ${attrs.textCase}`
67635
+ style: `text-transform: ${attrs.textTransform}`
67312
67636
  };
67313
67637
  }
67314
67638
  }