@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
@@ -19887,17 +19887,21 @@ const getAbstractDefinition = (numId, docx) => {
19887
19887
  let listDefinitionForThisNumId = abstractDefinitions?.find(
19888
19888
  (style2) => style2.attributes["w:abstractNumId"] === abstractNumId
19889
19889
  );
19890
- const templateIdTag = listDefinitionForThisNumId?.elements?.find((el) => el.name === "w:tmpl");
19891
- const templateId = templateIdTag?.attributes?.["w:val"];
19892
- if (templateId) {
19893
- listDefinitionForThisNumId = numberingElements?.find((el) => {
19894
- if (el.name !== "w:abstractNum") return false;
19895
- const tmpl = el.elements?.find((el2) => el2.name === "w:tmpl");
19896
- if (!tmpl) return false;
19897
- const hasLevels = el.elements?.some((el2) => el2.name === "w:lvl");
19898
- const tmplId = tmpl.attributes?.["w:val"];
19899
- return tmplId && hasLevels && tmplId === templateId;
19900
- });
19890
+ const hasLevels = listDefinitionForThisNumId?.elements?.some((el) => el.name === "w:lvl");
19891
+ if (!listDefinitionForThisNumId || !hasLevels) {
19892
+ const templateIdTag = listDefinitionForThisNumId?.elements?.find((el) => el.name === "w:tmpl");
19893
+ const templateId = templateIdTag?.attributes?.["w:val"];
19894
+ if (templateId) {
19895
+ const byTemplate = numberingElements?.find((el) => {
19896
+ if (el.name !== "w:abstractNum") return false;
19897
+ const tmpl = el.elements?.find((el2) => el2.name === "w:tmpl");
19898
+ if (!tmpl) return false;
19899
+ const tmplId = tmpl.attributes?.["w:val"];
19900
+ const hasLvl = el.elements?.some((e) => e.name === "w:lvl");
19901
+ return tmplId && hasLvl && tmplId === templateId;
19902
+ });
19903
+ if (byTemplate) listDefinitionForThisNumId = byTemplate;
19904
+ }
19901
19905
  }
19902
19906
  return listDefinitionForThisNumId;
19903
19907
  };
@@ -48516,6 +48520,10 @@ const TextAlign = Extension.create({
48516
48520
  {
48517
48521
  types: this.options.types,
48518
48522
  attributes: {
48523
+ /**
48524
+ * @category Attribute
48525
+ * @param {string} [textAlign='left'] - Text alignment value (left, center, right, justify)
48526
+ */
48519
48527
  textAlign: {
48520
48528
  default: this.options.defaultAlignment,
48521
48529
  parseDOM: (el) => {
@@ -48536,11 +48544,32 @@ const TextAlign = Extension.create({
48536
48544
  },
48537
48545
  addCommands() {
48538
48546
  return {
48547
+ /**
48548
+ * Set text alignment
48549
+ * @category Command
48550
+ * @param {string} alignment - Alignment value (left, center, right, justify)
48551
+ * @returns {Function} Command function
48552
+ * @example
48553
+ * // Set to center
48554
+ * setTextAlign('center')
48555
+ *
48556
+ * // Set to justify
48557
+ * setTextAlign('justify')
48558
+ * @note Applies to all configured node types (heading, paragraph by default)
48559
+ */
48539
48560
  setTextAlign: (alignment2) => ({ commands: commands2 }) => {
48540
48561
  const containsAlignment = this.options.alignments.includes(alignment2);
48541
48562
  if (!containsAlignment) return false;
48542
48563
  return this.options.types.map((type2) => commands2.updateAttributes(type2, { textAlign: alignment2 })).every((result) => result);
48543
48564
  },
48565
+ /**
48566
+ * Remove text alignment (reset to default)
48567
+ * @category Command
48568
+ * @returns {Function} Command function
48569
+ * @example
48570
+ * unsetTextAlign()
48571
+ * @note Resets alignment to the default value
48572
+ */
48544
48573
  unsetTextAlign: () => ({ commands: commands2 }) => {
48545
48574
  return this.options.types.map((type2) => commands2.resetAttributes(type2, "textAlign")).every((result) => result);
48546
48575
  }
@@ -48571,6 +48600,10 @@ const TextIndent = Extension.create({
48571
48600
  {
48572
48601
  types: this.options.types,
48573
48602
  attributes: {
48603
+ /**
48604
+ * @category Attribute
48605
+ * @param {string} [textIndent] - Text indentation value with unit (e.g., '0.5in')
48606
+ */
48574
48607
  textIndent: {
48575
48608
  default: null,
48576
48609
  parseDOM: (el) => el.style.textIndent,
@@ -48588,13 +48621,43 @@ const TextIndent = Extension.create({
48588
48621
  },
48589
48622
  addCommands() {
48590
48623
  return {
48624
+ /**
48625
+ * Set text indentation
48626
+ * @category Command
48627
+ * @param {string} indent - Indentation value with unit (e.g., '0.5in', '2cm')
48628
+ * @returns {Function} Command function
48629
+ * @example
48630
+ * // Set to 0.5 inches
48631
+ * setTextIndent('0.5in')
48632
+ *
48633
+ * // Set to 2 centimeters
48634
+ * setTextIndent('2cm')
48635
+ * @note Accepts any valid CSS unit (in, cm, px, em, etc.)
48636
+ */
48591
48637
  setTextIndent: (indent) => ({ commands: commands2 }) => {
48592
48638
  if (!indent) return false;
48593
48639
  return this.options.types.map((type2) => commands2.updateAttributes(type2, { textIndent: indent })).every((result) => result);
48594
48640
  },
48641
+ /**
48642
+ * Remove text indentation
48643
+ * @category Command
48644
+ * @returns {Function} Command function
48645
+ * @example
48646
+ * unsetTextIndent()
48647
+ * @note Removes all indentation from the selected nodes
48648
+ */
48595
48649
  unsetTextIndent: () => ({ commands: commands2 }) => {
48596
48650
  return this.options.types.map((type2) => commands2.resetAttributes(type2, "textIndent")).every((result) => result);
48597
48651
  },
48652
+ /**
48653
+ * Increase text indentation
48654
+ * @category Command
48655
+ * @returns {Function} Command function
48656
+ * @example
48657
+ * increaseTextIndent()
48658
+ * @note Increments by the default value (0.125in by default)
48659
+ * @note Creates initial indent if none exists
48660
+ */
48598
48661
  increaseTextIndent: () => ({ commands: commands2 }) => {
48599
48662
  return this.options.types.map((type2) => {
48600
48663
  let { textIndent } = this.editor.getAttributes(type2);
@@ -48605,7 +48668,7 @@ const TextIndent = Extension.create({
48605
48668
  });
48606
48669
  }
48607
48670
  let [value, unit] = parseSizeUnit(textIndent);
48608
- value = value + this.options.defaults.increment;
48671
+ value = Number(value) + this.options.defaults.increment;
48609
48672
  unit = unit ? unit : this.options.defaults.unit;
48610
48673
  if (Number.isNaN(value)) return false;
48611
48674
  return commands2.updateAttributes(type2, {
@@ -48613,12 +48676,21 @@ const TextIndent = Extension.create({
48613
48676
  });
48614
48677
  }).every((result) => result);
48615
48678
  },
48679
+ /**
48680
+ * Decrease text indentation
48681
+ * @category Command
48682
+ * @returns {Function} Command function
48683
+ * @example
48684
+ * decreaseTextIndent()
48685
+ * @note Decrements by the default value (0.125in by default)
48686
+ * @note Removes indentation completely if it reaches 0 or below
48687
+ */
48616
48688
  decreaseTextIndent: () => ({ commands: commands2 }) => {
48617
48689
  return this.options.types.map((type2) => {
48618
48690
  let { textIndent } = this.editor.getAttributes(type2);
48619
48691
  if (!textIndent) return false;
48620
48692
  let [value, unit] = parseSizeUnit(textIndent);
48621
- value = value - this.options.defaults.increment;
48693
+ value = Number(value) - this.options.defaults.increment;
48622
48694
  unit = unit ? unit : this.options.defaults.unit;
48623
48695
  if (Number.isNaN(value)) return false;
48624
48696
  if (value <= 0) {
@@ -49187,8 +49259,17 @@ const Gapcursor = Extension.create({
49187
49259
  addPmPlugins() {
49188
49260
  return [gapCursor()];
49189
49261
  },
49262
+ /**
49263
+ * Extend node schema to allow gap cursor positioning
49264
+ * @returns {Object} Schema extension with allowGapCursor property
49265
+ */
49190
49266
  extendNodeSchema(extension) {
49191
49267
  return {
49268
+ /**
49269
+ * Whether to allow gap cursor before/after this node
49270
+ * Set to false on nodes where gap cursor shouldn't appear
49271
+ * @type {boolean|null}
49272
+ */
49192
49273
  allowGapCursor: callOrGet(
49193
49274
  getExtensionConfigField(extension, "allowGapCursor", {
49194
49275
  name: extension.name,
@@ -50250,10 +50331,12 @@ const getLinkedStyle = (styleId, styles = []) => {
50250
50331
  };
50251
50332
  const getSpacingStyle = (spacing) => {
50252
50333
  const { lineSpaceBefore, lineSpaceAfter, line, lineRule } = spacing;
50334
+ const lineHeightResult = getLineHeightValueString(line, "", lineRule, true);
50335
+ const lineHeightStyles = typeof lineHeightResult === "object" && lineHeightResult !== null ? lineHeightResult : {};
50253
50336
  return {
50254
50337
  "margin-top": lineSpaceBefore + "px",
50255
50338
  "margin-bottom": lineSpaceAfter + "px",
50256
- ...getLineHeightValueString(line, "", lineRule, true)
50339
+ ...lineHeightStyles
50257
50340
  };
50258
50341
  };
50259
50342
  const getSpacingStyleString = (spacing) => {
@@ -50438,6 +50521,11 @@ const createLinkedStylesPlugin = (editor) => {
50438
50521
  return new Plugin({
50439
50522
  key: LinkedStylesPluginKey,
50440
50523
  state: {
50524
+ /**
50525
+ * Initialize plugin state with styles and decorations
50526
+ * @returns {Object} Initial state with styles and decorations
50527
+ * @private
50528
+ */
50441
50529
  init() {
50442
50530
  if (!editor.converter || editor.options.mode !== "docx") return {};
50443
50531
  const styles = editor.converter?.linkedStyles || [];
@@ -50446,6 +50534,15 @@ const createLinkedStylesPlugin = (editor) => {
50446
50534
  decorations: generateDecorations(editor.state, styles)
50447
50535
  };
50448
50536
  },
50537
+ /**
50538
+ * Update decorations when document changes
50539
+ * @param {Object} tr - The transaction
50540
+ * @param {Object} prev - Previous plugin state
50541
+ * @param {Object} oldEditorState - Old editor state
50542
+ * @param {Object} newEditorState - New editor state
50543
+ * @returns {Object} Updated state with styles and decorations
50544
+ * @private
50545
+ */
50449
50546
  apply(tr, prev, oldEditorState, newEditorState) {
50450
50547
  if (!editor.converter || editor.options.mode !== "docx") return { ...prev };
50451
50548
  let decorations = prev.decorations || DecorationSet.empty;
@@ -50457,6 +50554,12 @@ const createLinkedStylesPlugin = (editor) => {
50457
50554
  }
50458
50555
  },
50459
50556
  props: {
50557
+ /**
50558
+ * Provide decorations to the editor view
50559
+ * @param {Object} state - Current editor state
50560
+ * @returns {Object} The decoration set
50561
+ * @private
50562
+ */
50460
50563
  decorations(state2) {
50461
50564
  return LinkedStylesPluginKey.getState(state2)?.decorations;
50462
50565
  }
@@ -50498,24 +50601,35 @@ const LinkedStyles = Extension.create({
50498
50601
  addCommands() {
50499
50602
  return {
50500
50603
  /**
50501
- * Apply a linked style to the current selection.
50502
- *
50503
- * @param {object} style The linked style to apply
50504
- * @param {string} style.id The style ID (e.g., 'Heading1')
50505
- * @returns {boolean} Whether the style was correctly applied
50604
+ * Apply a linked style to the selected paragraphs
50605
+ * @category Command
50606
+ * @param {Object} style - The style object to apply
50607
+ * @returns {Function} Command function
50608
+ * @example
50609
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
50610
+ * setLinkedStyle(style);
50611
+ * @note Clears existing formatting when applying a style
50612
+ * @note Works with custom selection preservation
50506
50613
  */
50507
50614
  setLinkedStyle: (style2) => (params2) => {
50508
50615
  const { tr } = params2;
50509
50616
  return applyLinkedStyleToTransaction(tr, this.editor, style2);
50510
50617
  },
50511
50618
  /**
50512
- * Toggle a linked style on the current selection.
50619
+ * Toggle a linked style on the current selection
50620
+ * @category Command
50621
+ * @param {Object} style - The linked style to apply (with id property)
50622
+ * @param {string|null} [nodeType=null] - Node type to restrict toggle to (e.g., 'paragraph')
50623
+ * @returns {Function} Command function
50624
+ * @example
50625
+ * // Toggle a heading style
50626
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
50627
+ * toggleLinkedStyle(style)
50513
50628
  *
50514
- * @param {object} style The linked style to apply
50515
- * @param {string} style.id The style ID (e.g., 'Heading1')
50516
- * @param {string|null} nodeType The node type to restrict the toggle to (e.g., 'paragraph'). If null,
50517
- * the style can be toggled on any node type.
50518
- * @returns {boolean} Whether the style was correctly applied/removed
50629
+ * // Toggle only on paragraph nodes
50630
+ * toggleLinkedStyle(style, 'paragraph')
50631
+ * @note If selection is empty, returns false
50632
+ * @note Removes style if already applied, applies it if not
50519
50633
  */
50520
50634
  toggleLinkedStyle: (style2, nodeType = null) => (params2) => {
50521
50635
  const { tr } = params2;
@@ -50538,9 +50652,17 @@ const LinkedStyles = Extension.create({
50538
50652
  return applyLinkedStyleToTransaction(tr, this.editor, style2);
50539
50653
  },
50540
50654
  /**
50541
- * Apply a linked style by its ID.
50542
- * @param {string} styleId The style ID (e.g., 'Heading1')
50543
- * @returns {boolean} Whether the style was correctly applied
50655
+ * Apply a linked style by its ID
50656
+ * @category Command
50657
+ * @param {string} styleId - The style ID to apply (e.g., 'Heading1')
50658
+ * @returns {Function} Command function
50659
+ * @example
50660
+ * // Apply a heading style
50661
+ * setStyleById('Heading1')
50662
+ *
50663
+ * // Apply a normal style
50664
+ * setStyleById('Normal')
50665
+ * @note Looks up the style from loaded Word styles
50544
50666
  */
50545
50667
  setStyleById: (styleId) => (params2) => {
50546
50668
  const { state: state2, tr } = params2;
@@ -50555,22 +50677,39 @@ const LinkedStyles = Extension.create({
50555
50677
  addHelpers() {
50556
50678
  return {
50557
50679
  /**
50558
- * Get all linked styles available in the editor
50680
+ * Get all available linked styles
50681
+ * @category Helper
50559
50682
  * @returns {Array} Array of linked style objects
50683
+ * @example
50684
+ * const styles = editor.helpers.linkedStyles.getStyles();
50685
+ * // Returns all styles from the Word document
50560
50686
  */
50561
50687
  getStyles: () => {
50562
50688
  const styles = LinkedStylesPluginKey.getState(this.editor.state)?.styles || [];
50563
50689
  return styles;
50564
50690
  },
50565
50691
  /**
50566
- * Get a linked style by its ID
50567
- * @param {string} styleId The style ID (e.g., 'Heading1')
50568
- * @returns {object|null} The linked style object or null if not found
50692
+ * Get a specific style by ID
50693
+ * @category Helper
50694
+ * @param {string} styleId - The style ID to find
50695
+ * @returns {Object} The style object or undefined
50696
+ * @example
50697
+ * const headingStyle = editor.helpers.linkedStyles.getStyleById('Heading1');
50569
50698
  */
50570
50699
  getStyleById: (styleId) => {
50571
50700
  const styles = this.editor.helpers[this.name].getStyles();
50572
50701
  return styles.find((s) => s.id === styleId);
50573
50702
  },
50703
+ /**
50704
+ * Get the CSS string for a style
50705
+ * @category Helper
50706
+ * @param {string} styleId - The style ID
50707
+ * @returns {string} CSS style string
50708
+ * @example
50709
+ * const css = editor.helpers.linkedStyles.getLinkedStyleString('Heading1');
50710
+ * // Returns: "font-size: 16pt; font-weight: bold; color: #2E74B5"
50711
+ * @private
50712
+ */
50574
50713
  getLinkedStyleString: (styleId) => {
50575
50714
  const styles = this.editor.helpers.linkedStyles.getStyles();
50576
50715
  const style2 = styles.find((s) => s.id === styleId);
@@ -56949,6 +57088,10 @@ const Image = Node$1.create({
56949
57088
  },
56950
57089
  addAttributes() {
56951
57090
  return {
57091
+ /**
57092
+ * @category Attribute
57093
+ * @param {string} [src] - Image source URL or path
57094
+ */
56952
57095
  src: {
56953
57096
  default: null,
56954
57097
  renderDOM: ({ src }) => {
@@ -56957,31 +57100,90 @@ const Image = Node$1.create({
56957
57100
  };
56958
57101
  }
56959
57102
  },
57103
+ /**
57104
+ * @category Attribute
57105
+ * @param {string} [alt='Uploaded picture'] - Alternative text for accessibility
57106
+ */
56960
57107
  alt: {
56961
57108
  default: "Uploaded picture"
56962
57109
  },
57110
+ /**
57111
+ * @category Attribute
57112
+ * @param {string} [id] - Image element ID
57113
+ * @private
57114
+ */
56963
57115
  id: { rendered: false },
57116
+ /**
57117
+ * @category Attribute
57118
+ * @param {string} [title] - Image title/tooltip text
57119
+ */
56964
57120
  title: {
56965
57121
  default: null
56966
57122
  },
57123
+ /**
57124
+ * @category Attribute
57125
+ * @param {string} [rId] - Relationship ID for Word export
57126
+ * @private
57127
+ */
56967
57128
  rId: {
56968
57129
  default: null,
56969
57130
  rendered: false
56970
57131
  },
57132
+ /**
57133
+ * @category Attribute
57134
+ * @param {Object} [originalPadding] - Original padding values from Word import
57135
+ * @private
57136
+ */
56971
57137
  originalPadding: {
56972
57138
  default: null,
56973
57139
  rendered: false
56974
57140
  },
57141
+ /**
57142
+ * @category Attribute
57143
+ * @param {Object} [originalAttributes] - Original attributes from Word import
57144
+ * @private
57145
+ */
56975
57146
  originalAttributes: { rendered: false },
57147
+ /**
57148
+ * @category Attribute
57149
+ * @param {boolean} [wrapTopAndBottom] - Wrap text above and below image
57150
+ * @private
57151
+ */
56976
57152
  wrapTopAndBottom: { rendered: false },
57153
+ /**
57154
+ * @category Attribute
57155
+ * @param {Object} [anchorData] - Anchor positioning data for Word
57156
+ * @private
57157
+ */
56977
57158
  anchorData: {
56978
57159
  default: null,
56979
57160
  rendered: false
56980
57161
  },
57162
+ /**
57163
+ * @category Attribute
57164
+ * @param {boolean} [isAnchor] - Whether image is anchored
57165
+ * @private
57166
+ */
56981
57167
  isAnchor: { rendered: false },
57168
+ /**
57169
+ * @category Attribute
57170
+ * @param {boolean} [simplePos] - Simple positioning flag
57171
+ * @private
57172
+ */
56982
57173
  simplePos: { rendered: false },
57174
+ /**
57175
+ * @category Attribute
57176
+ * @param {string} [wrapText] - Text wrapping style
57177
+ * @private
57178
+ */
56983
57179
  wrapText: { rendered: false },
56984
57180
  extension: { rendered: false },
57181
+ /**
57182
+ * @category Attribute
57183
+ * @param {Object} [size] - Image dimensions
57184
+ * @param {number} [size.width] - Width in pixels
57185
+ * @param {number} [size.height] - Height in pixels
57186
+ */
56985
57187
  size: {
56986
57188
  default: {},
56987
57189
  renderDOM: ({ size: size2, extension }) => {
@@ -56994,6 +57196,14 @@ const Image = Node$1.create({
56994
57196
  return { style: style2 };
56995
57197
  }
56996
57198
  },
57199
+ /**
57200
+ * @category Attribute
57201
+ * @param {Object} [padding] - Image padding/margins
57202
+ * @param {number} [padding.left] - Left padding in pixels
57203
+ * @param {number} [padding.top] - Top padding in pixels
57204
+ * @param {number} [padding.bottom] - Bottom padding in pixels
57205
+ * @param {number} [padding.right] - Right padding in pixels
57206
+ */
56997
57207
  padding: {
56998
57208
  default: {},
56999
57209
  renderDOM: ({ padding, marginOffset }) => {
@@ -57006,6 +57216,12 @@ const Image = Node$1.create({
57006
57216
  return { style: style2 };
57007
57217
  }
57008
57218
  },
57219
+ /**
57220
+ * @category Attribute
57221
+ * @param {Object} [marginOffset] - Margin offset for anchored images
57222
+ * @param {number} [marginOffset.left] - Left margin offset
57223
+ * @param {number} [marginOffset.top] - Top margin offset
57224
+ */
57009
57225
  marginOffset: {
57010
57226
  default: {},
57011
57227
  renderDOM: ({ marginOffset, anchorData }) => {
@@ -57021,6 +57237,10 @@ const Image = Node$1.create({
57021
57237
  return { style: style2 };
57022
57238
  }
57023
57239
  },
57240
+ /**
57241
+ * @category Attribute
57242
+ * @param {string} [style] - Custom inline CSS styles
57243
+ */
57024
57244
  style: {
57025
57245
  default: null,
57026
57246
  rendered: true,
@@ -57043,6 +57263,27 @@ const Image = Node$1.create({
57043
57263
  },
57044
57264
  addCommands() {
57045
57265
  return {
57266
+ /**
57267
+ * Insert an image at the current position
57268
+ * @category Command
57269
+ * @param {Object} options - Image attributes
57270
+ * @param {string} options.src - Image source URL or data URI
57271
+ * @param {string} [options.alt] - Alternative text
57272
+ * @param {string} [options.title] - Image title
57273
+ * @param {Object} [options.size] - Image dimensions
57274
+ * @returns {Function} Command function
57275
+ * @example
57276
+ * // Insert an image from a URL
57277
+ * setImage({ src: 'https://example.com/image.jpg' })
57278
+ *
57279
+ * // Insert a base64 encoded image
57280
+ * setImage({
57281
+ * src: 'data:image/png;base64,...',
57282
+ * alt: 'Company logo',
57283
+ * size: { width: 200 }
57284
+ * })
57285
+ * @note Supports URLs, relative paths, and base64 data URIs
57286
+ */
57046
57287
  setImage: (options) => ({ commands: commands2 }) => {
57047
57288
  return commands2.insertContent({
57048
57289
  type: this.name,
@@ -57080,7 +57321,9 @@ const getFileOpener = () => {
57080
57321
  const handleImageUpload = (file) => {
57081
57322
  return new Promise((resolve, reject) => {
57082
57323
  let reader = new FileReader();
57083
- reader.onload = (event) => resolve(event.target.result);
57324
+ reader.onload = (event) => {
57325
+ resolve(event.target.result);
57326
+ };
57084
57327
  reader.onerror = reject;
57085
57328
  setTimeout(() => reader.readAsDataURL(file), 250);
57086
57329
  });
@@ -57284,8 +57527,8 @@ async function uploadImage({ editor, view, file, size: size2, uploadHandler }) {
57284
57527
  let rId = null;
57285
57528
  if (editor.options.mode === "docx") {
57286
57529
  const [, path] = mediaPath.split("word/");
57287
- const id2 = addImageRelationship({ editor, path });
57288
- if (id2) rId = id2;
57530
+ const imageid = addImageRelationship({ editor, path });
57531
+ if (imageid) rId = imageid;
57289
57532
  }
57290
57533
  let imageNode = schema.nodes.image.create({
57291
57534
  src: mediaPath,
@@ -57308,8 +57551,8 @@ function addImageRelationship({ editor, path }) {
57308
57551
  const target = path;
57309
57552
  const type2 = "image";
57310
57553
  try {
57311
- const id = insertNewRelationship(target, type2, editor);
57312
- return id;
57554
+ const relationshipId = insertNewRelationship(target, type2, editor);
57555
+ return relationshipId;
57313
57556
  } catch {
57314
57557
  return null;
57315
57558
  }
@@ -58422,6 +58665,17 @@ const BlockNode = Extension.create({
58422
58665
  name: "blockNode",
58423
58666
  addCommands() {
58424
58667
  return {
58668
+ /**
58669
+ * Replace a block node by its ID with new content
58670
+ * @category Command
58671
+ * @param {string} id - The sdBlockId of the node to replace
58672
+ * @param {Object} contentNode - The replacement ProseMirror node
58673
+ * @returns {Function} Command function
58674
+ * @example
58675
+ * const newParagraph = editor.schema.nodes.paragraph.create({}, editor.schema.text('New content'))
58676
+ * replaceBlockNodeById('block-123', newParagraph)
58677
+ * @note The replacement node should have the same type as the original
58678
+ */
58425
58679
  replaceBlockNodeById: (id, contentNode) => ({ dispatch, tr }) => {
58426
58680
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
58427
58681
  if (!blockNode || blockNode.length > 1) {
@@ -58438,6 +58692,15 @@ const BlockNode = Extension.create({
58438
58692
  }
58439
58693
  return true;
58440
58694
  },
58695
+ /**
58696
+ * Delete a block node by its ID
58697
+ * @category Command
58698
+ * @param {string} id - The sdBlockId of the node to delete
58699
+ * @returns {Function} Command function
58700
+ * @example
58701
+ * deleteBlockNodeById('block-123')
58702
+ * @note Completely removes the node from the document
58703
+ */
58441
58704
  deleteBlockNodeById: (id) => ({ dispatch, tr }) => {
58442
58705
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
58443
58706
  if (!blockNode || blockNode.length > 1) {
@@ -58454,6 +58717,18 @@ const BlockNode = Extension.create({
58454
58717
  }
58455
58718
  return true;
58456
58719
  },
58720
+ /**
58721
+ * Update attributes of a block node by its ID
58722
+ * @category Command
58723
+ * @param {string} id - The sdBlockId of the node to update
58724
+ * @param {Object} attrs - Attributes to update
58725
+ * @returns {Function} Command function
58726
+ * @example
58727
+ * updateBlockNodeAttributes('block-123', { textAlign: 'center' })
58728
+ * @example
58729
+ * updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
58730
+ * @note Merges new attributes with existing ones
58731
+ */
58457
58732
  updateBlockNodeAttributes: (id, attrs = {}) => ({ dispatch, tr }) => {
58458
58733
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
58459
58734
  if (!blockNode || blockNode.length > 1) {
@@ -58476,15 +58751,54 @@ const BlockNode = Extension.create({
58476
58751
  },
58477
58752
  addHelpers() {
58478
58753
  return {
58754
+ /**
58755
+ * Get all block nodes in the document
58756
+ * @category Helper
58757
+ * @returns {Array<BlockNodeInfo>} Array of block node info objects
58758
+ * @example
58759
+ * const blocks = editor.helpers.blockNode.getBlockNodes()
58760
+ * console.log(`Found ${blocks.length} block nodes`)
58761
+ */
58479
58762
  getBlockNodes: () => {
58480
58763
  return findChildren(this.editor.state.doc, (node2) => nodeAllowsSdBlockIdAttr(node2));
58481
58764
  },
58765
+ /**
58766
+ * Get a specific block node by its ID
58767
+ * @category Helper
58768
+ * @param {string} id - The sdBlockId to search for
58769
+ * @returns {Array<BlockNodeInfo>} Array containing the matching node (or empty)
58770
+ * @example
58771
+ * const block = editor.helpers.blockNode.getBlockNodeById('block-123')
58772
+ * if (block.length) console.log('Found:', block[0].node.type.name)
58773
+ */
58482
58774
  getBlockNodeById: (id) => {
58483
58775
  return findChildren(this.editor.state.doc, (node2) => node2.attrs.sdBlockId === id);
58484
58776
  },
58777
+ /**
58778
+ * Get all block nodes of a specific type
58779
+ * @category Helper
58780
+ * @param {string} type - The node type name (e.g., 'paragraph', 'heading')
58781
+ * @returns {Array<BlockNodeInfo>} Array of matching block nodes
58782
+ * @example
58783
+ * const paragraphs = editor.helpers.blockNode.getBlockNodesByType('paragraph')
58784
+ * const headings = editor.helpers.blockNode.getBlockNodesByType('heading')
58785
+ */
58485
58786
  getBlockNodesByType: (type2) => {
58486
58787
  return findChildren(this.editor.state.doc, (node2) => node2.type.name === type2);
58487
58788
  },
58789
+ /**
58790
+ * Get all block nodes within a position range
58791
+ * @category Helper
58792
+ * @param {number} from - Start position
58793
+ * @param {number} to - End position
58794
+ * @returns {Array<BlockNodeInfo>} Array of block nodes in the range
58795
+ * @example
58796
+ * const selection = editor.state.selection
58797
+ * const blocksInSelection = editor.helpers.blockNode.getBlockNodesInRange(
58798
+ * selection.from,
58799
+ * selection.to
58800
+ * )
58801
+ */
58488
58802
  getBlockNodesInRange: (from2, to) => {
58489
58803
  let blockNodes = [];
58490
58804
  this.editor.state.doc.nodesBetween(from2, to, (node2, pos) => {
@@ -58540,10 +58854,11 @@ const nodeNeedsSdBlockId = (node2) => {
58540
58854
  return !currentId;
58541
58855
  };
58542
58856
  const checkForNewBlockNodesInTrs = (transactions) => {
58543
- return transactions.some((tr) => {
58857
+ return Array.from(transactions).some((tr) => {
58544
58858
  return tr.steps.some((step) => {
58859
+ if (!(step instanceof ReplaceStep)) return false;
58545
58860
  const hasValidSdBlockNodes = step.slice?.content?.content?.some((node2) => nodeAllowsSdBlockIdAttr(node2));
58546
- return step instanceof ReplaceStep && hasValidSdBlockNodes;
58861
+ return hasValidSdBlockNodes;
58547
58862
  });
58548
58863
  });
58549
58864
  };
@@ -58572,6 +58887,10 @@ const TextStyle = Mark2.create({
58572
58887
  },
58573
58888
  addAttributes() {
58574
58889
  return {
58890
+ /**
58891
+ * @category Attribute
58892
+ * @param {string} [styleId] - Style identifier for referencing predefined styles
58893
+ */
58575
58894
  styleId: {}
58576
58895
  };
58577
58896
  },
@@ -58580,10 +58899,11 @@ const TextStyle = Mark2.create({
58580
58899
  /**
58581
58900
  * Remove empty text style marks
58582
58901
  * @category Command
58583
- * @returns {Function} Command - Removes mark if no attributes present
58902
+ * @returns {Function} Command function - Removes mark if no attributes present
58584
58903
  * @example
58585
58904
  * removeEmptyTextStyle()
58586
58905
  * @note Cleanup utility to prevent empty span elements
58906
+ * @note Automatically checks if any style attributes exist before removal
58587
58907
  */
58588
58908
  removeEmptyTextStyle: () => ({ state: state2, commands: commands2 }) => {
58589
58909
  const attributes = Attribute2.getMarkAttributes(state2, this.type);
@@ -59605,12 +59925,16 @@ const TextTransform = Extension.create({
59605
59925
  {
59606
59926
  types: this.options.types,
59607
59927
  attributes: {
59928
+ /**
59929
+ * @category Attribute
59930
+ * @param {string} [textTransform] - Text transform value (uppercase, lowercase, capitalize, none)
59931
+ */
59608
59932
  textTransform: {
59609
59933
  default: null,
59610
59934
  renderDOM: (attrs) => {
59611
- if (!attrs.textCase) return {};
59935
+ if (!attrs.textTransform) return {};
59612
59936
  return {
59613
- style: `text-transform: ${attrs.textCase}`
59937
+ style: `text-transform: ${attrs.textTransform}`
59614
59938
  };
59615
59939
  }
59616
59940
  }