@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
@@ -19870,17 +19870,21 @@ const getAbstractDefinition = (numId, docx) => {
19870
19870
  let listDefinitionForThisNumId = abstractDefinitions?.find(
19871
19871
  (style2) => style2.attributes["w:abstractNumId"] === abstractNumId
19872
19872
  );
19873
- const templateIdTag = listDefinitionForThisNumId?.elements?.find((el) => el.name === "w:tmpl");
19874
- const templateId = templateIdTag?.attributes?.["w:val"];
19875
- if (templateId) {
19876
- listDefinitionForThisNumId = numberingElements?.find((el) => {
19877
- if (el.name !== "w:abstractNum") return false;
19878
- const tmpl = el.elements?.find((el2) => el2.name === "w:tmpl");
19879
- if (!tmpl) return false;
19880
- const hasLevels = el.elements?.some((el2) => el2.name === "w:lvl");
19881
- const tmplId = tmpl.attributes?.["w:val"];
19882
- return tmplId && hasLevels && tmplId === templateId;
19883
- });
19873
+ const hasLevels = listDefinitionForThisNumId?.elements?.some((el) => el.name === "w:lvl");
19874
+ if (!listDefinitionForThisNumId || !hasLevels) {
19875
+ const templateIdTag = listDefinitionForThisNumId?.elements?.find((el) => el.name === "w:tmpl");
19876
+ const templateId = templateIdTag?.attributes?.["w:val"];
19877
+ if (templateId) {
19878
+ const byTemplate = numberingElements?.find((el) => {
19879
+ if (el.name !== "w:abstractNum") return false;
19880
+ const tmpl = el.elements?.find((el2) => el2.name === "w:tmpl");
19881
+ if (!tmpl) return false;
19882
+ const tmplId = tmpl.attributes?.["w:val"];
19883
+ const hasLvl = el.elements?.some((e) => e.name === "w:lvl");
19884
+ return tmplId && hasLvl && tmplId === templateId;
19885
+ });
19886
+ if (byTemplate) listDefinitionForThisNumId = byTemplate;
19887
+ }
19884
19888
  }
19885
19889
  return listDefinitionForThisNumId;
19886
19890
  };
@@ -48499,6 +48503,10 @@ const TextAlign = Extension.create({
48499
48503
  {
48500
48504
  types: this.options.types,
48501
48505
  attributes: {
48506
+ /**
48507
+ * @category Attribute
48508
+ * @param {string} [textAlign='left'] - Text alignment value (left, center, right, justify)
48509
+ */
48502
48510
  textAlign: {
48503
48511
  default: this.options.defaultAlignment,
48504
48512
  parseDOM: (el) => {
@@ -48519,11 +48527,32 @@ const TextAlign = Extension.create({
48519
48527
  },
48520
48528
  addCommands() {
48521
48529
  return {
48530
+ /**
48531
+ * Set text alignment
48532
+ * @category Command
48533
+ * @param {string} alignment - Alignment value (left, center, right, justify)
48534
+ * @returns {Function} Command function
48535
+ * @example
48536
+ * // Set to center
48537
+ * setTextAlign('center')
48538
+ *
48539
+ * // Set to justify
48540
+ * setTextAlign('justify')
48541
+ * @note Applies to all configured node types (heading, paragraph by default)
48542
+ */
48522
48543
  setTextAlign: (alignment2) => ({ commands: commands2 }) => {
48523
48544
  const containsAlignment = this.options.alignments.includes(alignment2);
48524
48545
  if (!containsAlignment) return false;
48525
48546
  return this.options.types.map((type2) => commands2.updateAttributes(type2, { textAlign: alignment2 })).every((result) => result);
48526
48547
  },
48548
+ /**
48549
+ * Remove text alignment (reset to default)
48550
+ * @category Command
48551
+ * @returns {Function} Command function
48552
+ * @example
48553
+ * unsetTextAlign()
48554
+ * @note Resets alignment to the default value
48555
+ */
48527
48556
  unsetTextAlign: () => ({ commands: commands2 }) => {
48528
48557
  return this.options.types.map((type2) => commands2.resetAttributes(type2, "textAlign")).every((result) => result);
48529
48558
  }
@@ -48554,6 +48583,10 @@ const TextIndent = Extension.create({
48554
48583
  {
48555
48584
  types: this.options.types,
48556
48585
  attributes: {
48586
+ /**
48587
+ * @category Attribute
48588
+ * @param {string} [textIndent] - Text indentation value with unit (e.g., '0.5in')
48589
+ */
48557
48590
  textIndent: {
48558
48591
  default: null,
48559
48592
  parseDOM: (el) => el.style.textIndent,
@@ -48571,13 +48604,43 @@ const TextIndent = Extension.create({
48571
48604
  },
48572
48605
  addCommands() {
48573
48606
  return {
48607
+ /**
48608
+ * Set text indentation
48609
+ * @category Command
48610
+ * @param {string} indent - Indentation value with unit (e.g., '0.5in', '2cm')
48611
+ * @returns {Function} Command function
48612
+ * @example
48613
+ * // Set to 0.5 inches
48614
+ * setTextIndent('0.5in')
48615
+ *
48616
+ * // Set to 2 centimeters
48617
+ * setTextIndent('2cm')
48618
+ * @note Accepts any valid CSS unit (in, cm, px, em, etc.)
48619
+ */
48574
48620
  setTextIndent: (indent) => ({ commands: commands2 }) => {
48575
48621
  if (!indent) return false;
48576
48622
  return this.options.types.map((type2) => commands2.updateAttributes(type2, { textIndent: indent })).every((result) => result);
48577
48623
  },
48624
+ /**
48625
+ * Remove text indentation
48626
+ * @category Command
48627
+ * @returns {Function} Command function
48628
+ * @example
48629
+ * unsetTextIndent()
48630
+ * @note Removes all indentation from the selected nodes
48631
+ */
48578
48632
  unsetTextIndent: () => ({ commands: commands2 }) => {
48579
48633
  return this.options.types.map((type2) => commands2.resetAttributes(type2, "textIndent")).every((result) => result);
48580
48634
  },
48635
+ /**
48636
+ * Increase text indentation
48637
+ * @category Command
48638
+ * @returns {Function} Command function
48639
+ * @example
48640
+ * increaseTextIndent()
48641
+ * @note Increments by the default value (0.125in by default)
48642
+ * @note Creates initial indent if none exists
48643
+ */
48581
48644
  increaseTextIndent: () => ({ commands: commands2 }) => {
48582
48645
  return this.options.types.map((type2) => {
48583
48646
  let { textIndent } = this.editor.getAttributes(type2);
@@ -48588,7 +48651,7 @@ const TextIndent = Extension.create({
48588
48651
  });
48589
48652
  }
48590
48653
  let [value, unit] = parseSizeUnit(textIndent);
48591
- value = value + this.options.defaults.increment;
48654
+ value = Number(value) + this.options.defaults.increment;
48592
48655
  unit = unit ? unit : this.options.defaults.unit;
48593
48656
  if (Number.isNaN(value)) return false;
48594
48657
  return commands2.updateAttributes(type2, {
@@ -48596,12 +48659,21 @@ const TextIndent = Extension.create({
48596
48659
  });
48597
48660
  }).every((result) => result);
48598
48661
  },
48662
+ /**
48663
+ * Decrease text indentation
48664
+ * @category Command
48665
+ * @returns {Function} Command function
48666
+ * @example
48667
+ * decreaseTextIndent()
48668
+ * @note Decrements by the default value (0.125in by default)
48669
+ * @note Removes indentation completely if it reaches 0 or below
48670
+ */
48599
48671
  decreaseTextIndent: () => ({ commands: commands2 }) => {
48600
48672
  return this.options.types.map((type2) => {
48601
48673
  let { textIndent } = this.editor.getAttributes(type2);
48602
48674
  if (!textIndent) return false;
48603
48675
  let [value, unit] = parseSizeUnit(textIndent);
48604
- value = value - this.options.defaults.increment;
48676
+ value = Number(value) - this.options.defaults.increment;
48605
48677
  unit = unit ? unit : this.options.defaults.unit;
48606
48678
  if (Number.isNaN(value)) return false;
48607
48679
  if (value <= 0) {
@@ -49170,8 +49242,17 @@ const Gapcursor = Extension.create({
49170
49242
  addPmPlugins() {
49171
49243
  return [gapCursor()];
49172
49244
  },
49245
+ /**
49246
+ * Extend node schema to allow gap cursor positioning
49247
+ * @returns {Object} Schema extension with allowGapCursor property
49248
+ */
49173
49249
  extendNodeSchema(extension) {
49174
49250
  return {
49251
+ /**
49252
+ * Whether to allow gap cursor before/after this node
49253
+ * Set to false on nodes where gap cursor shouldn't appear
49254
+ * @type {boolean|null}
49255
+ */
49175
49256
  allowGapCursor: callOrGet(
49176
49257
  getExtensionConfigField(extension, "allowGapCursor", {
49177
49258
  name: extension.name,
@@ -50233,10 +50314,12 @@ const getLinkedStyle = (styleId, styles = []) => {
50233
50314
  };
50234
50315
  const getSpacingStyle = (spacing) => {
50235
50316
  const { lineSpaceBefore, lineSpaceAfter, line, lineRule } = spacing;
50317
+ const lineHeightResult = getLineHeightValueString(line, "", lineRule, true);
50318
+ const lineHeightStyles = typeof lineHeightResult === "object" && lineHeightResult !== null ? lineHeightResult : {};
50236
50319
  return {
50237
50320
  "margin-top": lineSpaceBefore + "px",
50238
50321
  "margin-bottom": lineSpaceAfter + "px",
50239
- ...getLineHeightValueString(line, "", lineRule, true)
50322
+ ...lineHeightStyles
50240
50323
  };
50241
50324
  };
50242
50325
  const getSpacingStyleString = (spacing) => {
@@ -50421,6 +50504,11 @@ const createLinkedStylesPlugin = (editor) => {
50421
50504
  return new Plugin({
50422
50505
  key: LinkedStylesPluginKey,
50423
50506
  state: {
50507
+ /**
50508
+ * Initialize plugin state with styles and decorations
50509
+ * @returns {Object} Initial state with styles and decorations
50510
+ * @private
50511
+ */
50424
50512
  init() {
50425
50513
  if (!editor.converter || editor.options.mode !== "docx") return {};
50426
50514
  const styles = editor.converter?.linkedStyles || [];
@@ -50429,6 +50517,15 @@ const createLinkedStylesPlugin = (editor) => {
50429
50517
  decorations: generateDecorations(editor.state, styles)
50430
50518
  };
50431
50519
  },
50520
+ /**
50521
+ * Update decorations when document changes
50522
+ * @param {Object} tr - The transaction
50523
+ * @param {Object} prev - Previous plugin state
50524
+ * @param {Object} oldEditorState - Old editor state
50525
+ * @param {Object} newEditorState - New editor state
50526
+ * @returns {Object} Updated state with styles and decorations
50527
+ * @private
50528
+ */
50432
50529
  apply(tr, prev, oldEditorState, newEditorState) {
50433
50530
  if (!editor.converter || editor.options.mode !== "docx") return { ...prev };
50434
50531
  let decorations = prev.decorations || DecorationSet.empty;
@@ -50440,6 +50537,12 @@ const createLinkedStylesPlugin = (editor) => {
50440
50537
  }
50441
50538
  },
50442
50539
  props: {
50540
+ /**
50541
+ * Provide decorations to the editor view
50542
+ * @param {Object} state - Current editor state
50543
+ * @returns {Object} The decoration set
50544
+ * @private
50545
+ */
50443
50546
  decorations(state2) {
50444
50547
  return LinkedStylesPluginKey.getState(state2)?.decorations;
50445
50548
  }
@@ -50481,24 +50584,35 @@ const LinkedStyles = Extension.create({
50481
50584
  addCommands() {
50482
50585
  return {
50483
50586
  /**
50484
- * Apply a linked style to the current selection.
50485
- *
50486
- * @param {object} style The linked style to apply
50487
- * @param {string} style.id The style ID (e.g., 'Heading1')
50488
- * @returns {boolean} Whether the style was correctly applied
50587
+ * Apply a linked style to the selected paragraphs
50588
+ * @category Command
50589
+ * @param {Object} style - The style object to apply
50590
+ * @returns {Function} Command function
50591
+ * @example
50592
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
50593
+ * setLinkedStyle(style);
50594
+ * @note Clears existing formatting when applying a style
50595
+ * @note Works with custom selection preservation
50489
50596
  */
50490
50597
  setLinkedStyle: (style2) => (params2) => {
50491
50598
  const { tr } = params2;
50492
50599
  return applyLinkedStyleToTransaction(tr, this.editor, style2);
50493
50600
  },
50494
50601
  /**
50495
- * Toggle a linked style on the current selection.
50602
+ * Toggle a linked style on the current selection
50603
+ * @category Command
50604
+ * @param {Object} style - The linked style to apply (with id property)
50605
+ * @param {string|null} [nodeType=null] - Node type to restrict toggle to (e.g., 'paragraph')
50606
+ * @returns {Function} Command function
50607
+ * @example
50608
+ * // Toggle a heading style
50609
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
50610
+ * toggleLinkedStyle(style)
50496
50611
  *
50497
- * @param {object} style The linked style to apply
50498
- * @param {string} style.id The style ID (e.g., 'Heading1')
50499
- * @param {string|null} nodeType The node type to restrict the toggle to (e.g., 'paragraph'). If null,
50500
- * the style can be toggled on any node type.
50501
- * @returns {boolean} Whether the style was correctly applied/removed
50612
+ * // Toggle only on paragraph nodes
50613
+ * toggleLinkedStyle(style, 'paragraph')
50614
+ * @note If selection is empty, returns false
50615
+ * @note Removes style if already applied, applies it if not
50502
50616
  */
50503
50617
  toggleLinkedStyle: (style2, nodeType = null) => (params2) => {
50504
50618
  const { tr } = params2;
@@ -50521,9 +50635,17 @@ const LinkedStyles = Extension.create({
50521
50635
  return applyLinkedStyleToTransaction(tr, this.editor, style2);
50522
50636
  },
50523
50637
  /**
50524
- * Apply a linked style by its ID.
50525
- * @param {string} styleId The style ID (e.g., 'Heading1')
50526
- * @returns {boolean} Whether the style was correctly applied
50638
+ * Apply a linked style by its ID
50639
+ * @category Command
50640
+ * @param {string} styleId - The style ID to apply (e.g., 'Heading1')
50641
+ * @returns {Function} Command function
50642
+ * @example
50643
+ * // Apply a heading style
50644
+ * setStyleById('Heading1')
50645
+ *
50646
+ * // Apply a normal style
50647
+ * setStyleById('Normal')
50648
+ * @note Looks up the style from loaded Word styles
50527
50649
  */
50528
50650
  setStyleById: (styleId) => (params2) => {
50529
50651
  const { state: state2, tr } = params2;
@@ -50538,22 +50660,39 @@ const LinkedStyles = Extension.create({
50538
50660
  addHelpers() {
50539
50661
  return {
50540
50662
  /**
50541
- * Get all linked styles available in the editor
50663
+ * Get all available linked styles
50664
+ * @category Helper
50542
50665
  * @returns {Array} Array of linked style objects
50666
+ * @example
50667
+ * const styles = editor.helpers.linkedStyles.getStyles();
50668
+ * // Returns all styles from the Word document
50543
50669
  */
50544
50670
  getStyles: () => {
50545
50671
  const styles = LinkedStylesPluginKey.getState(this.editor.state)?.styles || [];
50546
50672
  return styles;
50547
50673
  },
50548
50674
  /**
50549
- * Get a linked style by its ID
50550
- * @param {string} styleId The style ID (e.g., 'Heading1')
50551
- * @returns {object|null} The linked style object or null if not found
50675
+ * Get a specific style by ID
50676
+ * @category Helper
50677
+ * @param {string} styleId - The style ID to find
50678
+ * @returns {Object} The style object or undefined
50679
+ * @example
50680
+ * const headingStyle = editor.helpers.linkedStyles.getStyleById('Heading1');
50552
50681
  */
50553
50682
  getStyleById: (styleId) => {
50554
50683
  const styles = this.editor.helpers[this.name].getStyles();
50555
50684
  return styles.find((s) => s.id === styleId);
50556
50685
  },
50686
+ /**
50687
+ * Get the CSS string for a style
50688
+ * @category Helper
50689
+ * @param {string} styleId - The style ID
50690
+ * @returns {string} CSS style string
50691
+ * @example
50692
+ * const css = editor.helpers.linkedStyles.getLinkedStyleString('Heading1');
50693
+ * // Returns: "font-size: 16pt; font-weight: bold; color: #2E74B5"
50694
+ * @private
50695
+ */
50557
50696
  getLinkedStyleString: (styleId) => {
50558
50697
  const styles = this.editor.helpers.linkedStyles.getStyles();
50559
50698
  const style2 = styles.find((s) => s.id === styleId);
@@ -56932,6 +57071,10 @@ const Image = Node$1.create({
56932
57071
  },
56933
57072
  addAttributes() {
56934
57073
  return {
57074
+ /**
57075
+ * @category Attribute
57076
+ * @param {string} [src] - Image source URL or path
57077
+ */
56935
57078
  src: {
56936
57079
  default: null,
56937
57080
  renderDOM: ({ src }) => {
@@ -56940,31 +57083,90 @@ const Image = Node$1.create({
56940
57083
  };
56941
57084
  }
56942
57085
  },
57086
+ /**
57087
+ * @category Attribute
57088
+ * @param {string} [alt='Uploaded picture'] - Alternative text for accessibility
57089
+ */
56943
57090
  alt: {
56944
57091
  default: "Uploaded picture"
56945
57092
  },
57093
+ /**
57094
+ * @category Attribute
57095
+ * @param {string} [id] - Image element ID
57096
+ * @private
57097
+ */
56946
57098
  id: { rendered: false },
57099
+ /**
57100
+ * @category Attribute
57101
+ * @param {string} [title] - Image title/tooltip text
57102
+ */
56947
57103
  title: {
56948
57104
  default: null
56949
57105
  },
57106
+ /**
57107
+ * @category Attribute
57108
+ * @param {string} [rId] - Relationship ID for Word export
57109
+ * @private
57110
+ */
56950
57111
  rId: {
56951
57112
  default: null,
56952
57113
  rendered: false
56953
57114
  },
57115
+ /**
57116
+ * @category Attribute
57117
+ * @param {Object} [originalPadding] - Original padding values from Word import
57118
+ * @private
57119
+ */
56954
57120
  originalPadding: {
56955
57121
  default: null,
56956
57122
  rendered: false
56957
57123
  },
57124
+ /**
57125
+ * @category Attribute
57126
+ * @param {Object} [originalAttributes] - Original attributes from Word import
57127
+ * @private
57128
+ */
56958
57129
  originalAttributes: { rendered: false },
57130
+ /**
57131
+ * @category Attribute
57132
+ * @param {boolean} [wrapTopAndBottom] - Wrap text above and below image
57133
+ * @private
57134
+ */
56959
57135
  wrapTopAndBottom: { rendered: false },
57136
+ /**
57137
+ * @category Attribute
57138
+ * @param {Object} [anchorData] - Anchor positioning data for Word
57139
+ * @private
57140
+ */
56960
57141
  anchorData: {
56961
57142
  default: null,
56962
57143
  rendered: false
56963
57144
  },
57145
+ /**
57146
+ * @category Attribute
57147
+ * @param {boolean} [isAnchor] - Whether image is anchored
57148
+ * @private
57149
+ */
56964
57150
  isAnchor: { rendered: false },
57151
+ /**
57152
+ * @category Attribute
57153
+ * @param {boolean} [simplePos] - Simple positioning flag
57154
+ * @private
57155
+ */
56965
57156
  simplePos: { rendered: false },
57157
+ /**
57158
+ * @category Attribute
57159
+ * @param {string} [wrapText] - Text wrapping style
57160
+ * @private
57161
+ */
56966
57162
  wrapText: { rendered: false },
56967
57163
  extension: { rendered: false },
57164
+ /**
57165
+ * @category Attribute
57166
+ * @param {Object} [size] - Image dimensions
57167
+ * @param {number} [size.width] - Width in pixels
57168
+ * @param {number} [size.height] - Height in pixels
57169
+ */
56968
57170
  size: {
56969
57171
  default: {},
56970
57172
  renderDOM: ({ size: size2, extension }) => {
@@ -56977,6 +57179,14 @@ const Image = Node$1.create({
56977
57179
  return { style: style2 };
56978
57180
  }
56979
57181
  },
57182
+ /**
57183
+ * @category Attribute
57184
+ * @param {Object} [padding] - Image padding/margins
57185
+ * @param {number} [padding.left] - Left padding in pixels
57186
+ * @param {number} [padding.top] - Top padding in pixels
57187
+ * @param {number} [padding.bottom] - Bottom padding in pixels
57188
+ * @param {number} [padding.right] - Right padding in pixels
57189
+ */
56980
57190
  padding: {
56981
57191
  default: {},
56982
57192
  renderDOM: ({ padding, marginOffset }) => {
@@ -56989,6 +57199,12 @@ const Image = Node$1.create({
56989
57199
  return { style: style2 };
56990
57200
  }
56991
57201
  },
57202
+ /**
57203
+ * @category Attribute
57204
+ * @param {Object} [marginOffset] - Margin offset for anchored images
57205
+ * @param {number} [marginOffset.left] - Left margin offset
57206
+ * @param {number} [marginOffset.top] - Top margin offset
57207
+ */
56992
57208
  marginOffset: {
56993
57209
  default: {},
56994
57210
  renderDOM: ({ marginOffset, anchorData }) => {
@@ -57004,6 +57220,10 @@ const Image = Node$1.create({
57004
57220
  return { style: style2 };
57005
57221
  }
57006
57222
  },
57223
+ /**
57224
+ * @category Attribute
57225
+ * @param {string} [style] - Custom inline CSS styles
57226
+ */
57007
57227
  style: {
57008
57228
  default: null,
57009
57229
  rendered: true,
@@ -57026,6 +57246,27 @@ const Image = Node$1.create({
57026
57246
  },
57027
57247
  addCommands() {
57028
57248
  return {
57249
+ /**
57250
+ * Insert an image at the current position
57251
+ * @category Command
57252
+ * @param {Object} options - Image attributes
57253
+ * @param {string} options.src - Image source URL or data URI
57254
+ * @param {string} [options.alt] - Alternative text
57255
+ * @param {string} [options.title] - Image title
57256
+ * @param {Object} [options.size] - Image dimensions
57257
+ * @returns {Function} Command function
57258
+ * @example
57259
+ * // Insert an image from a URL
57260
+ * setImage({ src: 'https://example.com/image.jpg' })
57261
+ *
57262
+ * // Insert a base64 encoded image
57263
+ * setImage({
57264
+ * src: 'data:image/png;base64,...',
57265
+ * alt: 'Company logo',
57266
+ * size: { width: 200 }
57267
+ * })
57268
+ * @note Supports URLs, relative paths, and base64 data URIs
57269
+ */
57029
57270
  setImage: (options) => ({ commands: commands2 }) => {
57030
57271
  return commands2.insertContent({
57031
57272
  type: this.name,
@@ -57063,7 +57304,9 @@ const getFileOpener = () => {
57063
57304
  const handleImageUpload = (file) => {
57064
57305
  return new Promise((resolve, reject) => {
57065
57306
  let reader = new FileReader();
57066
- reader.onload = (event) => resolve(event.target.result);
57307
+ reader.onload = (event) => {
57308
+ resolve(event.target.result);
57309
+ };
57067
57310
  reader.onerror = reject;
57068
57311
  setTimeout(() => reader.readAsDataURL(file), 250);
57069
57312
  });
@@ -57267,8 +57510,8 @@ async function uploadImage({ editor, view, file, size: size2, uploadHandler }) {
57267
57510
  let rId = null;
57268
57511
  if (editor.options.mode === "docx") {
57269
57512
  const [, path] = mediaPath.split("word/");
57270
- const id2 = addImageRelationship({ editor, path });
57271
- if (id2) rId = id2;
57513
+ const imageid = addImageRelationship({ editor, path });
57514
+ if (imageid) rId = imageid;
57272
57515
  }
57273
57516
  let imageNode = schema.nodes.image.create({
57274
57517
  src: mediaPath,
@@ -57291,8 +57534,8 @@ function addImageRelationship({ editor, path }) {
57291
57534
  const target = path;
57292
57535
  const type2 = "image";
57293
57536
  try {
57294
- const id = insertNewRelationship(target, type2, editor);
57295
- return id;
57537
+ const relationshipId = insertNewRelationship(target, type2, editor);
57538
+ return relationshipId;
57296
57539
  } catch {
57297
57540
  return null;
57298
57541
  }
@@ -58405,6 +58648,17 @@ const BlockNode = Extension.create({
58405
58648
  name: "blockNode",
58406
58649
  addCommands() {
58407
58650
  return {
58651
+ /**
58652
+ * Replace a block node by its ID with new content
58653
+ * @category Command
58654
+ * @param {string} id - The sdBlockId of the node to replace
58655
+ * @param {Object} contentNode - The replacement ProseMirror node
58656
+ * @returns {Function} Command function
58657
+ * @example
58658
+ * const newParagraph = editor.schema.nodes.paragraph.create({}, editor.schema.text('New content'))
58659
+ * replaceBlockNodeById('block-123', newParagraph)
58660
+ * @note The replacement node should have the same type as the original
58661
+ */
58408
58662
  replaceBlockNodeById: (id, contentNode) => ({ dispatch, tr }) => {
58409
58663
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
58410
58664
  if (!blockNode || blockNode.length > 1) {
@@ -58421,6 +58675,15 @@ const BlockNode = Extension.create({
58421
58675
  }
58422
58676
  return true;
58423
58677
  },
58678
+ /**
58679
+ * Delete a block node by its ID
58680
+ * @category Command
58681
+ * @param {string} id - The sdBlockId of the node to delete
58682
+ * @returns {Function} Command function
58683
+ * @example
58684
+ * deleteBlockNodeById('block-123')
58685
+ * @note Completely removes the node from the document
58686
+ */
58424
58687
  deleteBlockNodeById: (id) => ({ dispatch, tr }) => {
58425
58688
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
58426
58689
  if (!blockNode || blockNode.length > 1) {
@@ -58437,6 +58700,18 @@ const BlockNode = Extension.create({
58437
58700
  }
58438
58701
  return true;
58439
58702
  },
58703
+ /**
58704
+ * Update attributes of a block node by its ID
58705
+ * @category Command
58706
+ * @param {string} id - The sdBlockId of the node to update
58707
+ * @param {Object} attrs - Attributes to update
58708
+ * @returns {Function} Command function
58709
+ * @example
58710
+ * updateBlockNodeAttributes('block-123', { textAlign: 'center' })
58711
+ * @example
58712
+ * updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
58713
+ * @note Merges new attributes with existing ones
58714
+ */
58440
58715
  updateBlockNodeAttributes: (id, attrs = {}) => ({ dispatch, tr }) => {
58441
58716
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
58442
58717
  if (!blockNode || blockNode.length > 1) {
@@ -58459,15 +58734,54 @@ const BlockNode = Extension.create({
58459
58734
  },
58460
58735
  addHelpers() {
58461
58736
  return {
58737
+ /**
58738
+ * Get all block nodes in the document
58739
+ * @category Helper
58740
+ * @returns {Array<BlockNodeInfo>} Array of block node info objects
58741
+ * @example
58742
+ * const blocks = editor.helpers.blockNode.getBlockNodes()
58743
+ * console.log(`Found ${blocks.length} block nodes`)
58744
+ */
58462
58745
  getBlockNodes: () => {
58463
58746
  return findChildren(this.editor.state.doc, (node2) => nodeAllowsSdBlockIdAttr(node2));
58464
58747
  },
58748
+ /**
58749
+ * Get a specific block node by its ID
58750
+ * @category Helper
58751
+ * @param {string} id - The sdBlockId to search for
58752
+ * @returns {Array<BlockNodeInfo>} Array containing the matching node (or empty)
58753
+ * @example
58754
+ * const block = editor.helpers.blockNode.getBlockNodeById('block-123')
58755
+ * if (block.length) console.log('Found:', block[0].node.type.name)
58756
+ */
58465
58757
  getBlockNodeById: (id) => {
58466
58758
  return findChildren(this.editor.state.doc, (node2) => node2.attrs.sdBlockId === id);
58467
58759
  },
58760
+ /**
58761
+ * Get all block nodes of a specific type
58762
+ * @category Helper
58763
+ * @param {string} type - The node type name (e.g., 'paragraph', 'heading')
58764
+ * @returns {Array<BlockNodeInfo>} Array of matching block nodes
58765
+ * @example
58766
+ * const paragraphs = editor.helpers.blockNode.getBlockNodesByType('paragraph')
58767
+ * const headings = editor.helpers.blockNode.getBlockNodesByType('heading')
58768
+ */
58468
58769
  getBlockNodesByType: (type2) => {
58469
58770
  return findChildren(this.editor.state.doc, (node2) => node2.type.name === type2);
58470
58771
  },
58772
+ /**
58773
+ * Get all block nodes within a position range
58774
+ * @category Helper
58775
+ * @param {number} from - Start position
58776
+ * @param {number} to - End position
58777
+ * @returns {Array<BlockNodeInfo>} Array of block nodes in the range
58778
+ * @example
58779
+ * const selection = editor.state.selection
58780
+ * const blocksInSelection = editor.helpers.blockNode.getBlockNodesInRange(
58781
+ * selection.from,
58782
+ * selection.to
58783
+ * )
58784
+ */
58471
58785
  getBlockNodesInRange: (from2, to) => {
58472
58786
  let blockNodes = [];
58473
58787
  this.editor.state.doc.nodesBetween(from2, to, (node2, pos) => {
@@ -58523,10 +58837,11 @@ const nodeNeedsSdBlockId = (node2) => {
58523
58837
  return !currentId;
58524
58838
  };
58525
58839
  const checkForNewBlockNodesInTrs = (transactions) => {
58526
- return transactions.some((tr) => {
58840
+ return Array.from(transactions).some((tr) => {
58527
58841
  return tr.steps.some((step) => {
58842
+ if (!(step instanceof ReplaceStep)) return false;
58528
58843
  const hasValidSdBlockNodes = step.slice?.content?.content?.some((node2) => nodeAllowsSdBlockIdAttr(node2));
58529
- return step instanceof ReplaceStep && hasValidSdBlockNodes;
58844
+ return hasValidSdBlockNodes;
58530
58845
  });
58531
58846
  });
58532
58847
  };
@@ -58555,6 +58870,10 @@ const TextStyle = Mark2.create({
58555
58870
  },
58556
58871
  addAttributes() {
58557
58872
  return {
58873
+ /**
58874
+ * @category Attribute
58875
+ * @param {string} [styleId] - Style identifier for referencing predefined styles
58876
+ */
58558
58877
  styleId: {}
58559
58878
  };
58560
58879
  },
@@ -58563,10 +58882,11 @@ const TextStyle = Mark2.create({
58563
58882
  /**
58564
58883
  * Remove empty text style marks
58565
58884
  * @category Command
58566
- * @returns {Function} Command - Removes mark if no attributes present
58885
+ * @returns {Function} Command function - Removes mark if no attributes present
58567
58886
  * @example
58568
58887
  * removeEmptyTextStyle()
58569
58888
  * @note Cleanup utility to prevent empty span elements
58889
+ * @note Automatically checks if any style attributes exist before removal
58570
58890
  */
58571
58891
  removeEmptyTextStyle: () => ({ state: state2, commands: commands2 }) => {
58572
58892
  const attributes = Attribute2.getMarkAttributes(state2, this.type);
@@ -59588,12 +59908,16 @@ const TextTransform = Extension.create({
59588
59908
  {
59589
59909
  types: this.options.types,
59590
59910
  attributes: {
59911
+ /**
59912
+ * @category Attribute
59913
+ * @param {string} [textTransform] - Text transform value (uppercase, lowercase, capitalize, none)
59914
+ */
59591
59915
  textTransform: {
59592
59916
  default: null,
59593
59917
  renderDOM: (attrs) => {
59594
- if (!attrs.textCase) return {};
59918
+ if (!attrs.textTransform) return {};
59595
59919
  return {
59596
- style: `text-transform: ${attrs.textCase}`
59920
+ style: `text-transform: ${attrs.textTransform}`
59597
59921
  };
59598
59922
  }
59599
59923
  }