@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
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, g as getExtensionConfigField, b as getMarkType, d as getMarksFromSelection, e as getNodeType, f as getSchemaTypeNameByName, S as Schema$1, h as cleanSchemaItem, T as TextSelection, N as NodeSelection, i as canSplit, j as defaultBlockAt$1, l as liftTarget, A as AllSelection, k as canJoin, m as joinPoint, n as Selection, r as replaceStep$1, o as Slice, F as Fragment, R as ReplaceAroundStep$1, p as isTextSelection, q as getMarkRange, s as isMarkActive, t as isNodeActive, u as deleteProps, D as DOMParser$1, v as ReplaceStep, w as NodeRange, x as findWrapping, L as ListHelpers, y as findParentNode, z as isMacOS, B as isIOS, C as DOMSerializer, E as Mark$1, G as dropPoint, H as process$1, I as Buffer2, J as getSchemaTypeByName, K as inputRulesPlugin, O as TrackDeleteMarkName, Q as TrackInsertMarkName, U as v4, V as TrackFormatMarkName, W as comments_module_events, X as findMark, Y as objectIncludes, Z as AddMarkStep, _ as RemoveMarkStep, $ as twipsToLines, a0 as pixelsToTwips, a1 as helpers, a2 as posToDOMRect, a3 as CommandService, a4 as SuperConverter, a5 as createDocument, a6 as createDocFromMarkdown, a7 as createDocFromHTML, a8 as EditorState, a9 as hasSomeParentWithClass, aa as isActive, ab as unflattenListsInHtml, ac as parseSizeUnit, ad as minMax, ae as getLineHeightValueString, af as InputRule, ag as kebabCase, ah as findParentNodeClosestToPos, ai as getListItemStyleDefinitions, aj as docxNumberigHelpers, ak as parseIndentElement, al as combineIndents, am as StepMap, an as getColStyleDeclaration, ao as SelectionRange, ap as Transform, aq as isInTable$1, ar as createColGroup, as as generateDocxRandomId, at as insertNewRelationship, au as htmlHandler } from "./converter-DdzGurMJ.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, g as getExtensionConfigField, b as getMarkType, d as getMarksFromSelection, e as getNodeType, f as getSchemaTypeNameByName, S as Schema$1, h as cleanSchemaItem, T as TextSelection, N as NodeSelection, i as canSplit, j as defaultBlockAt$1, l as liftTarget, A as AllSelection, k as canJoin, m as joinPoint, n as Selection, r as replaceStep$1, o as Slice, F as Fragment, R as ReplaceAroundStep$1, p as isTextSelection, q as getMarkRange, s as isMarkActive, t as isNodeActive, u as deleteProps, D as DOMParser$1, v as ReplaceStep, w as NodeRange, x as findWrapping, L as ListHelpers, y as findParentNode, z as isMacOS, B as isIOS, C as DOMSerializer, E as Mark$1, G as dropPoint, H as process$1, I as Buffer2, J as getSchemaTypeByName, K as inputRulesPlugin, O as TrackDeleteMarkName, Q as TrackInsertMarkName, U as v4, V as TrackFormatMarkName, W as comments_module_events, X as findMark, Y as objectIncludes, Z as AddMarkStep, _ as RemoveMarkStep, $ as twipsToLines, a0 as pixelsToTwips, a1 as helpers, a2 as posToDOMRect, a3 as CommandService, a4 as SuperConverter, a5 as createDocument, a6 as createDocFromMarkdown, a7 as createDocFromHTML, a8 as EditorState, a9 as hasSomeParentWithClass, aa as isActive, ab as unflattenListsInHtml, ac as parseSizeUnit, ad as minMax, ae as getLineHeightValueString, af as InputRule, ag as kebabCase, ah as findParentNodeClosestToPos, ai as getListItemStyleDefinitions, aj as docxNumberigHelpers, ak as parseIndentElement, al as combineIndents, am as StepMap, an as getColStyleDeclaration, ao as SelectionRange, ap as Transform, aq as isInTable$1, ar as createColGroup, as as generateDocxRandomId, at as insertNewRelationship, au as htmlHandler } from "./converter-YnaMMkRN.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-Bjul2JVv.js";
17
+ import { D as DocxZipper } from "./docx-zipper-Bq9-qqP_.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -15279,6 +15279,10 @@ const TextAlign = Extension.create({
15279
15279
  {
15280
15280
  types: this.options.types,
15281
15281
  attributes: {
15282
+ /**
15283
+ * @category Attribute
15284
+ * @param {string} [textAlign='left'] - Text alignment value (left, center, right, justify)
15285
+ */
15282
15286
  textAlign: {
15283
15287
  default: this.options.defaultAlignment,
15284
15288
  parseDOM: (el) => {
@@ -15299,11 +15303,32 @@ const TextAlign = Extension.create({
15299
15303
  },
15300
15304
  addCommands() {
15301
15305
  return {
15306
+ /**
15307
+ * Set text alignment
15308
+ * @category Command
15309
+ * @param {string} alignment - Alignment value (left, center, right, justify)
15310
+ * @returns {Function} Command function
15311
+ * @example
15312
+ * // Set to center
15313
+ * setTextAlign('center')
15314
+ *
15315
+ * // Set to justify
15316
+ * setTextAlign('justify')
15317
+ * @note Applies to all configured node types (heading, paragraph by default)
15318
+ */
15302
15319
  setTextAlign: (alignment) => ({ commands: commands2 }) => {
15303
15320
  const containsAlignment = this.options.alignments.includes(alignment);
15304
15321
  if (!containsAlignment) return false;
15305
15322
  return this.options.types.map((type) => commands2.updateAttributes(type, { textAlign: alignment })).every((result) => result);
15306
15323
  },
15324
+ /**
15325
+ * Remove text alignment (reset to default)
15326
+ * @category Command
15327
+ * @returns {Function} Command function
15328
+ * @example
15329
+ * unsetTextAlign()
15330
+ * @note Resets alignment to the default value
15331
+ */
15307
15332
  unsetTextAlign: () => ({ commands: commands2 }) => {
15308
15333
  return this.options.types.map((type) => commands2.resetAttributes(type, "textAlign")).every((result) => result);
15309
15334
  }
@@ -15334,6 +15359,10 @@ const TextIndent = Extension.create({
15334
15359
  {
15335
15360
  types: this.options.types,
15336
15361
  attributes: {
15362
+ /**
15363
+ * @category Attribute
15364
+ * @param {string} [textIndent] - Text indentation value with unit (e.g., '0.5in')
15365
+ */
15337
15366
  textIndent: {
15338
15367
  default: null,
15339
15368
  parseDOM: (el) => el.style.textIndent,
@@ -15351,13 +15380,43 @@ const TextIndent = Extension.create({
15351
15380
  },
15352
15381
  addCommands() {
15353
15382
  return {
15383
+ /**
15384
+ * Set text indentation
15385
+ * @category Command
15386
+ * @param {string} indent - Indentation value with unit (e.g., '0.5in', '2cm')
15387
+ * @returns {Function} Command function
15388
+ * @example
15389
+ * // Set to 0.5 inches
15390
+ * setTextIndent('0.5in')
15391
+ *
15392
+ * // Set to 2 centimeters
15393
+ * setTextIndent('2cm')
15394
+ * @note Accepts any valid CSS unit (in, cm, px, em, etc.)
15395
+ */
15354
15396
  setTextIndent: (indent) => ({ commands: commands2 }) => {
15355
15397
  if (!indent) return false;
15356
15398
  return this.options.types.map((type) => commands2.updateAttributes(type, { textIndent: indent })).every((result) => result);
15357
15399
  },
15400
+ /**
15401
+ * Remove text indentation
15402
+ * @category Command
15403
+ * @returns {Function} Command function
15404
+ * @example
15405
+ * unsetTextIndent()
15406
+ * @note Removes all indentation from the selected nodes
15407
+ */
15358
15408
  unsetTextIndent: () => ({ commands: commands2 }) => {
15359
15409
  return this.options.types.map((type) => commands2.resetAttributes(type, "textIndent")).every((result) => result);
15360
15410
  },
15411
+ /**
15412
+ * Increase text indentation
15413
+ * @category Command
15414
+ * @returns {Function} Command function
15415
+ * @example
15416
+ * increaseTextIndent()
15417
+ * @note Increments by the default value (0.125in by default)
15418
+ * @note Creates initial indent if none exists
15419
+ */
15361
15420
  increaseTextIndent: () => ({ commands: commands2 }) => {
15362
15421
  return this.options.types.map((type) => {
15363
15422
  let { textIndent } = this.editor.getAttributes(type);
@@ -15368,7 +15427,7 @@ const TextIndent = Extension.create({
15368
15427
  });
15369
15428
  }
15370
15429
  let [value, unit] = parseSizeUnit(textIndent);
15371
- value = value + this.options.defaults.increment;
15430
+ value = Number(value) + this.options.defaults.increment;
15372
15431
  unit = unit ? unit : this.options.defaults.unit;
15373
15432
  if (Number.isNaN(value)) return false;
15374
15433
  return commands2.updateAttributes(type, {
@@ -15376,12 +15435,21 @@ const TextIndent = Extension.create({
15376
15435
  });
15377
15436
  }).every((result) => result);
15378
15437
  },
15438
+ /**
15439
+ * Decrease text indentation
15440
+ * @category Command
15441
+ * @returns {Function} Command function
15442
+ * @example
15443
+ * decreaseTextIndent()
15444
+ * @note Decrements by the default value (0.125in by default)
15445
+ * @note Removes indentation completely if it reaches 0 or below
15446
+ */
15379
15447
  decreaseTextIndent: () => ({ commands: commands2 }) => {
15380
15448
  return this.options.types.map((type) => {
15381
15449
  let { textIndent } = this.editor.getAttributes(type);
15382
15450
  if (!textIndent) return false;
15383
15451
  let [value, unit] = parseSizeUnit(textIndent);
15384
- value = value - this.options.defaults.increment;
15452
+ value = Number(value) - this.options.defaults.increment;
15385
15453
  unit = unit ? unit : this.options.defaults.unit;
15386
15454
  if (Number.isNaN(value)) return false;
15387
15455
  if (value <= 0) {
@@ -15950,8 +16018,17 @@ const Gapcursor = Extension.create({
15950
16018
  addPmPlugins() {
15951
16019
  return [gapCursor()];
15952
16020
  },
16021
+ /**
16022
+ * Extend node schema to allow gap cursor positioning
16023
+ * @returns {Object} Schema extension with allowGapCursor property
16024
+ */
15953
16025
  extendNodeSchema(extension) {
15954
16026
  return {
16027
+ /**
16028
+ * Whether to allow gap cursor before/after this node
16029
+ * Set to false on nodes where gap cursor shouldn't appear
16030
+ * @type {boolean|null}
16031
+ */
15955
16032
  allowGapCursor: callOrGet(
15956
16033
  getExtensionConfigField(extension, "allowGapCursor", {
15957
16034
  name: extension.name,
@@ -17013,10 +17090,12 @@ const getLinkedStyle = (styleId, styles = []) => {
17013
17090
  };
17014
17091
  const getSpacingStyle = (spacing) => {
17015
17092
  const { lineSpaceBefore, lineSpaceAfter, line, lineRule } = spacing;
17093
+ const lineHeightResult = getLineHeightValueString(line, "", lineRule, true);
17094
+ const lineHeightStyles = typeof lineHeightResult === "object" && lineHeightResult !== null ? lineHeightResult : {};
17016
17095
  return {
17017
17096
  "margin-top": lineSpaceBefore + "px",
17018
17097
  "margin-bottom": lineSpaceAfter + "px",
17019
- ...getLineHeightValueString(line, "", lineRule, true)
17098
+ ...lineHeightStyles
17020
17099
  };
17021
17100
  };
17022
17101
  const getSpacingStyleString = (spacing) => {
@@ -17201,6 +17280,11 @@ const createLinkedStylesPlugin = (editor) => {
17201
17280
  return new Plugin({
17202
17281
  key: LinkedStylesPluginKey,
17203
17282
  state: {
17283
+ /**
17284
+ * Initialize plugin state with styles and decorations
17285
+ * @returns {Object} Initial state with styles and decorations
17286
+ * @private
17287
+ */
17204
17288
  init() {
17205
17289
  if (!editor.converter || editor.options.mode !== "docx") return {};
17206
17290
  const styles = editor.converter?.linkedStyles || [];
@@ -17209,6 +17293,15 @@ const createLinkedStylesPlugin = (editor) => {
17209
17293
  decorations: generateDecorations(editor.state, styles)
17210
17294
  };
17211
17295
  },
17296
+ /**
17297
+ * Update decorations when document changes
17298
+ * @param {Object} tr - The transaction
17299
+ * @param {Object} prev - Previous plugin state
17300
+ * @param {Object} oldEditorState - Old editor state
17301
+ * @param {Object} newEditorState - New editor state
17302
+ * @returns {Object} Updated state with styles and decorations
17303
+ * @private
17304
+ */
17212
17305
  apply(tr, prev, oldEditorState, newEditorState) {
17213
17306
  if (!editor.converter || editor.options.mode !== "docx") return { ...prev };
17214
17307
  let decorations = prev.decorations || DecorationSet.empty;
@@ -17220,6 +17313,12 @@ const createLinkedStylesPlugin = (editor) => {
17220
17313
  }
17221
17314
  },
17222
17315
  props: {
17316
+ /**
17317
+ * Provide decorations to the editor view
17318
+ * @param {Object} state - Current editor state
17319
+ * @returns {Object} The decoration set
17320
+ * @private
17321
+ */
17223
17322
  decorations(state) {
17224
17323
  return LinkedStylesPluginKey.getState(state)?.decorations;
17225
17324
  }
@@ -17261,24 +17360,35 @@ const LinkedStyles = Extension.create({
17261
17360
  addCommands() {
17262
17361
  return {
17263
17362
  /**
17264
- * Apply a linked style to the current selection.
17265
- *
17266
- * @param {object} style The linked style to apply
17267
- * @param {string} style.id The style ID (e.g., 'Heading1')
17268
- * @returns {boolean} Whether the style was correctly applied
17363
+ * Apply a linked style to the selected paragraphs
17364
+ * @category Command
17365
+ * @param {Object} style - The style object to apply
17366
+ * @returns {Function} Command function
17367
+ * @example
17368
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
17369
+ * setLinkedStyle(style);
17370
+ * @note Clears existing formatting when applying a style
17371
+ * @note Works with custom selection preservation
17269
17372
  */
17270
17373
  setLinkedStyle: (style) => (params2) => {
17271
17374
  const { tr } = params2;
17272
17375
  return applyLinkedStyleToTransaction(tr, this.editor, style);
17273
17376
  },
17274
17377
  /**
17275
- * Toggle a linked style on the current selection.
17378
+ * Toggle a linked style on the current selection
17379
+ * @category Command
17380
+ * @param {Object} style - The linked style to apply (with id property)
17381
+ * @param {string|null} [nodeType=null] - Node type to restrict toggle to (e.g., 'paragraph')
17382
+ * @returns {Function} Command function
17383
+ * @example
17384
+ * // Toggle a heading style
17385
+ * const style = editor.helpers.linkedStyles.getStyleById('Heading1');
17386
+ * toggleLinkedStyle(style)
17276
17387
  *
17277
- * @param {object} style The linked style to apply
17278
- * @param {string} style.id The style ID (e.g., 'Heading1')
17279
- * @param {string|null} nodeType The node type to restrict the toggle to (e.g., 'paragraph'). If null,
17280
- * the style can be toggled on any node type.
17281
- * @returns {boolean} Whether the style was correctly applied/removed
17388
+ * // Toggle only on paragraph nodes
17389
+ * toggleLinkedStyle(style, 'paragraph')
17390
+ * @note If selection is empty, returns false
17391
+ * @note Removes style if already applied, applies it if not
17282
17392
  */
17283
17393
  toggleLinkedStyle: (style, nodeType = null) => (params2) => {
17284
17394
  const { tr } = params2;
@@ -17301,9 +17411,17 @@ const LinkedStyles = Extension.create({
17301
17411
  return applyLinkedStyleToTransaction(tr, this.editor, style);
17302
17412
  },
17303
17413
  /**
17304
- * Apply a linked style by its ID.
17305
- * @param {string} styleId The style ID (e.g., 'Heading1')
17306
- * @returns {boolean} Whether the style was correctly applied
17414
+ * Apply a linked style by its ID
17415
+ * @category Command
17416
+ * @param {string} styleId - The style ID to apply (e.g., 'Heading1')
17417
+ * @returns {Function} Command function
17418
+ * @example
17419
+ * // Apply a heading style
17420
+ * setStyleById('Heading1')
17421
+ *
17422
+ * // Apply a normal style
17423
+ * setStyleById('Normal')
17424
+ * @note Looks up the style from loaded Word styles
17307
17425
  */
17308
17426
  setStyleById: (styleId) => (params2) => {
17309
17427
  const { state, tr } = params2;
@@ -17318,22 +17436,39 @@ const LinkedStyles = Extension.create({
17318
17436
  addHelpers() {
17319
17437
  return {
17320
17438
  /**
17321
- * Get all linked styles available in the editor
17439
+ * Get all available linked styles
17440
+ * @category Helper
17322
17441
  * @returns {Array} Array of linked style objects
17442
+ * @example
17443
+ * const styles = editor.helpers.linkedStyles.getStyles();
17444
+ * // Returns all styles from the Word document
17323
17445
  */
17324
17446
  getStyles: () => {
17325
17447
  const styles = LinkedStylesPluginKey.getState(this.editor.state)?.styles || [];
17326
17448
  return styles;
17327
17449
  },
17328
17450
  /**
17329
- * Get a linked style by its ID
17330
- * @param {string} styleId The style ID (e.g., 'Heading1')
17331
- * @returns {object|null} The linked style object or null if not found
17451
+ * Get a specific style by ID
17452
+ * @category Helper
17453
+ * @param {string} styleId - The style ID to find
17454
+ * @returns {Object} The style object or undefined
17455
+ * @example
17456
+ * const headingStyle = editor.helpers.linkedStyles.getStyleById('Heading1');
17332
17457
  */
17333
17458
  getStyleById: (styleId) => {
17334
17459
  const styles = this.editor.helpers[this.name].getStyles();
17335
17460
  return styles.find((s) => s.id === styleId);
17336
17461
  },
17462
+ /**
17463
+ * Get the CSS string for a style
17464
+ * @category Helper
17465
+ * @param {string} styleId - The style ID
17466
+ * @returns {string} CSS style string
17467
+ * @example
17468
+ * const css = editor.helpers.linkedStyles.getLinkedStyleString('Heading1');
17469
+ * // Returns: "font-size: 16pt; font-weight: bold; color: #2E74B5"
17470
+ * @private
17471
+ */
17337
17472
  getLinkedStyleString: (styleId) => {
17338
17473
  const styles = this.editor.helpers.linkedStyles.getStyles();
17339
17474
  const style = styles.find((s) => s.id === styleId);
@@ -23712,6 +23847,10 @@ const Image = Node$1.create({
23712
23847
  },
23713
23848
  addAttributes() {
23714
23849
  return {
23850
+ /**
23851
+ * @category Attribute
23852
+ * @param {string} [src] - Image source URL or path
23853
+ */
23715
23854
  src: {
23716
23855
  default: null,
23717
23856
  renderDOM: ({ src }) => {
@@ -23720,31 +23859,90 @@ const Image = Node$1.create({
23720
23859
  };
23721
23860
  }
23722
23861
  },
23862
+ /**
23863
+ * @category Attribute
23864
+ * @param {string} [alt='Uploaded picture'] - Alternative text for accessibility
23865
+ */
23723
23866
  alt: {
23724
23867
  default: "Uploaded picture"
23725
23868
  },
23869
+ /**
23870
+ * @category Attribute
23871
+ * @param {string} [id] - Image element ID
23872
+ * @private
23873
+ */
23726
23874
  id: { rendered: false },
23875
+ /**
23876
+ * @category Attribute
23877
+ * @param {string} [title] - Image title/tooltip text
23878
+ */
23727
23879
  title: {
23728
23880
  default: null
23729
23881
  },
23882
+ /**
23883
+ * @category Attribute
23884
+ * @param {string} [rId] - Relationship ID for Word export
23885
+ * @private
23886
+ */
23730
23887
  rId: {
23731
23888
  default: null,
23732
23889
  rendered: false
23733
23890
  },
23891
+ /**
23892
+ * @category Attribute
23893
+ * @param {Object} [originalPadding] - Original padding values from Word import
23894
+ * @private
23895
+ */
23734
23896
  originalPadding: {
23735
23897
  default: null,
23736
23898
  rendered: false
23737
23899
  },
23900
+ /**
23901
+ * @category Attribute
23902
+ * @param {Object} [originalAttributes] - Original attributes from Word import
23903
+ * @private
23904
+ */
23738
23905
  originalAttributes: { rendered: false },
23906
+ /**
23907
+ * @category Attribute
23908
+ * @param {boolean} [wrapTopAndBottom] - Wrap text above and below image
23909
+ * @private
23910
+ */
23739
23911
  wrapTopAndBottom: { rendered: false },
23912
+ /**
23913
+ * @category Attribute
23914
+ * @param {Object} [anchorData] - Anchor positioning data for Word
23915
+ * @private
23916
+ */
23740
23917
  anchorData: {
23741
23918
  default: null,
23742
23919
  rendered: false
23743
23920
  },
23921
+ /**
23922
+ * @category Attribute
23923
+ * @param {boolean} [isAnchor] - Whether image is anchored
23924
+ * @private
23925
+ */
23744
23926
  isAnchor: { rendered: false },
23927
+ /**
23928
+ * @category Attribute
23929
+ * @param {boolean} [simplePos] - Simple positioning flag
23930
+ * @private
23931
+ */
23745
23932
  simplePos: { rendered: false },
23933
+ /**
23934
+ * @category Attribute
23935
+ * @param {string} [wrapText] - Text wrapping style
23936
+ * @private
23937
+ */
23746
23938
  wrapText: { rendered: false },
23747
23939
  extension: { rendered: false },
23940
+ /**
23941
+ * @category Attribute
23942
+ * @param {Object} [size] - Image dimensions
23943
+ * @param {number} [size.width] - Width in pixels
23944
+ * @param {number} [size.height] - Height in pixels
23945
+ */
23748
23946
  size: {
23749
23947
  default: {},
23750
23948
  renderDOM: ({ size, extension }) => {
@@ -23757,6 +23955,14 @@ const Image = Node$1.create({
23757
23955
  return { style };
23758
23956
  }
23759
23957
  },
23958
+ /**
23959
+ * @category Attribute
23960
+ * @param {Object} [padding] - Image padding/margins
23961
+ * @param {number} [padding.left] - Left padding in pixels
23962
+ * @param {number} [padding.top] - Top padding in pixels
23963
+ * @param {number} [padding.bottom] - Bottom padding in pixels
23964
+ * @param {number} [padding.right] - Right padding in pixels
23965
+ */
23760
23966
  padding: {
23761
23967
  default: {},
23762
23968
  renderDOM: ({ padding, marginOffset }) => {
@@ -23769,6 +23975,12 @@ const Image = Node$1.create({
23769
23975
  return { style };
23770
23976
  }
23771
23977
  },
23978
+ /**
23979
+ * @category Attribute
23980
+ * @param {Object} [marginOffset] - Margin offset for anchored images
23981
+ * @param {number} [marginOffset.left] - Left margin offset
23982
+ * @param {number} [marginOffset.top] - Top margin offset
23983
+ */
23772
23984
  marginOffset: {
23773
23985
  default: {},
23774
23986
  renderDOM: ({ marginOffset, anchorData }) => {
@@ -23784,6 +23996,10 @@ const Image = Node$1.create({
23784
23996
  return { style };
23785
23997
  }
23786
23998
  },
23999
+ /**
24000
+ * @category Attribute
24001
+ * @param {string} [style] - Custom inline CSS styles
24002
+ */
23787
24003
  style: {
23788
24004
  default: null,
23789
24005
  rendered: true,
@@ -23806,6 +24022,27 @@ const Image = Node$1.create({
23806
24022
  },
23807
24023
  addCommands() {
23808
24024
  return {
24025
+ /**
24026
+ * Insert an image at the current position
24027
+ * @category Command
24028
+ * @param {Object} options - Image attributes
24029
+ * @param {string} options.src - Image source URL or data URI
24030
+ * @param {string} [options.alt] - Alternative text
24031
+ * @param {string} [options.title] - Image title
24032
+ * @param {Object} [options.size] - Image dimensions
24033
+ * @returns {Function} Command function
24034
+ * @example
24035
+ * // Insert an image from a URL
24036
+ * setImage({ src: 'https://example.com/image.jpg' })
24037
+ *
24038
+ * // Insert a base64 encoded image
24039
+ * setImage({
24040
+ * src: 'data:image/png;base64,...',
24041
+ * alt: 'Company logo',
24042
+ * size: { width: 200 }
24043
+ * })
24044
+ * @note Supports URLs, relative paths, and base64 data URIs
24045
+ */
23809
24046
  setImage: (options) => ({ commands: commands2 }) => {
23810
24047
  return commands2.insertContent({
23811
24048
  type: this.name,
@@ -23843,7 +24080,9 @@ const getFileOpener = () => {
23843
24080
  const handleImageUpload = (file) => {
23844
24081
  return new Promise((resolve, reject) => {
23845
24082
  let reader = new FileReader();
23846
- reader.onload = (event) => resolve(event.target.result);
24083
+ reader.onload = (event) => {
24084
+ resolve(event.target.result);
24085
+ };
23847
24086
  reader.onerror = reject;
23848
24087
  setTimeout(() => reader.readAsDataURL(file), 250);
23849
24088
  });
@@ -24047,8 +24286,8 @@ async function uploadImage({ editor, view, file, size, uploadHandler }) {
24047
24286
  let rId = null;
24048
24287
  if (editor.options.mode === "docx") {
24049
24288
  const [, path] = mediaPath.split("word/");
24050
- const id2 = addImageRelationship({ editor, path });
24051
- if (id2) rId = id2;
24289
+ const imageid = addImageRelationship({ editor, path });
24290
+ if (imageid) rId = imageid;
24052
24291
  }
24053
24292
  let imageNode = schema.nodes.image.create({
24054
24293
  src: mediaPath,
@@ -24071,8 +24310,8 @@ function addImageRelationship({ editor, path }) {
24071
24310
  const target = path;
24072
24311
  const type = "image";
24073
24312
  try {
24074
- const id = insertNewRelationship(target, type, editor);
24075
- return id;
24313
+ const relationshipId = insertNewRelationship(target, type, editor);
24314
+ return relationshipId;
24076
24315
  } catch {
24077
24316
  return null;
24078
24317
  }
@@ -25185,6 +25424,17 @@ const BlockNode = Extension.create({
25185
25424
  name: "blockNode",
25186
25425
  addCommands() {
25187
25426
  return {
25427
+ /**
25428
+ * Replace a block node by its ID with new content
25429
+ * @category Command
25430
+ * @param {string} id - The sdBlockId of the node to replace
25431
+ * @param {Object} contentNode - The replacement ProseMirror node
25432
+ * @returns {Function} Command function
25433
+ * @example
25434
+ * const newParagraph = editor.schema.nodes.paragraph.create({}, editor.schema.text('New content'))
25435
+ * replaceBlockNodeById('block-123', newParagraph)
25436
+ * @note The replacement node should have the same type as the original
25437
+ */
25188
25438
  replaceBlockNodeById: (id, contentNode) => ({ dispatch, tr }) => {
25189
25439
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
25190
25440
  if (!blockNode || blockNode.length > 1) {
@@ -25201,6 +25451,15 @@ const BlockNode = Extension.create({
25201
25451
  }
25202
25452
  return true;
25203
25453
  },
25454
+ /**
25455
+ * Delete a block node by its ID
25456
+ * @category Command
25457
+ * @param {string} id - The sdBlockId of the node to delete
25458
+ * @returns {Function} Command function
25459
+ * @example
25460
+ * deleteBlockNodeById('block-123')
25461
+ * @note Completely removes the node from the document
25462
+ */
25204
25463
  deleteBlockNodeById: (id) => ({ dispatch, tr }) => {
25205
25464
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
25206
25465
  if (!blockNode || blockNode.length > 1) {
@@ -25217,6 +25476,18 @@ const BlockNode = Extension.create({
25217
25476
  }
25218
25477
  return true;
25219
25478
  },
25479
+ /**
25480
+ * Update attributes of a block node by its ID
25481
+ * @category Command
25482
+ * @param {string} id - The sdBlockId of the node to update
25483
+ * @param {Object} attrs - Attributes to update
25484
+ * @returns {Function} Command function
25485
+ * @example
25486
+ * updateBlockNodeAttributes('block-123', { textAlign: 'center' })
25487
+ * @example
25488
+ * updateBlockNodeAttributes('block-123', { indent: { left: 20 } })
25489
+ * @note Merges new attributes with existing ones
25490
+ */
25220
25491
  updateBlockNodeAttributes: (id, attrs = {}) => ({ dispatch, tr }) => {
25221
25492
  const blockNode = this.editor.helpers.blockNode.getBlockNodeById(id);
25222
25493
  if (!blockNode || blockNode.length > 1) {
@@ -25239,15 +25510,54 @@ const BlockNode = Extension.create({
25239
25510
  },
25240
25511
  addHelpers() {
25241
25512
  return {
25513
+ /**
25514
+ * Get all block nodes in the document
25515
+ * @category Helper
25516
+ * @returns {Array<BlockNodeInfo>} Array of block node info objects
25517
+ * @example
25518
+ * const blocks = editor.helpers.blockNode.getBlockNodes()
25519
+ * console.log(`Found ${blocks.length} block nodes`)
25520
+ */
25242
25521
  getBlockNodes: () => {
25243
25522
  return findChildren(this.editor.state.doc, (node) => nodeAllowsSdBlockIdAttr(node));
25244
25523
  },
25524
+ /**
25525
+ * Get a specific block node by its ID
25526
+ * @category Helper
25527
+ * @param {string} id - The sdBlockId to search for
25528
+ * @returns {Array<BlockNodeInfo>} Array containing the matching node (or empty)
25529
+ * @example
25530
+ * const block = editor.helpers.blockNode.getBlockNodeById('block-123')
25531
+ * if (block.length) console.log('Found:', block[0].node.type.name)
25532
+ */
25245
25533
  getBlockNodeById: (id) => {
25246
25534
  return findChildren(this.editor.state.doc, (node) => node.attrs.sdBlockId === id);
25247
25535
  },
25536
+ /**
25537
+ * Get all block nodes of a specific type
25538
+ * @category Helper
25539
+ * @param {string} type - The node type name (e.g., 'paragraph', 'heading')
25540
+ * @returns {Array<BlockNodeInfo>} Array of matching block nodes
25541
+ * @example
25542
+ * const paragraphs = editor.helpers.blockNode.getBlockNodesByType('paragraph')
25543
+ * const headings = editor.helpers.blockNode.getBlockNodesByType('heading')
25544
+ */
25248
25545
  getBlockNodesByType: (type) => {
25249
25546
  return findChildren(this.editor.state.doc, (node) => node.type.name === type);
25250
25547
  },
25548
+ /**
25549
+ * Get all block nodes within a position range
25550
+ * @category Helper
25551
+ * @param {number} from - Start position
25552
+ * @param {number} to - End position
25553
+ * @returns {Array<BlockNodeInfo>} Array of block nodes in the range
25554
+ * @example
25555
+ * const selection = editor.state.selection
25556
+ * const blocksInSelection = editor.helpers.blockNode.getBlockNodesInRange(
25557
+ * selection.from,
25558
+ * selection.to
25559
+ * )
25560
+ */
25251
25561
  getBlockNodesInRange: (from2, to) => {
25252
25562
  let blockNodes = [];
25253
25563
  this.editor.state.doc.nodesBetween(from2, to, (node, pos) => {
@@ -25303,10 +25613,11 @@ const nodeNeedsSdBlockId = (node) => {
25303
25613
  return !currentId;
25304
25614
  };
25305
25615
  const checkForNewBlockNodesInTrs = (transactions) => {
25306
- return transactions.some((tr) => {
25616
+ return Array.from(transactions).some((tr) => {
25307
25617
  return tr.steps.some((step) => {
25618
+ if (!(step instanceof ReplaceStep)) return false;
25308
25619
  const hasValidSdBlockNodes = step.slice?.content?.content?.some((node) => nodeAllowsSdBlockIdAttr(node));
25309
- return step instanceof ReplaceStep && hasValidSdBlockNodes;
25620
+ return hasValidSdBlockNodes;
25310
25621
  });
25311
25622
  });
25312
25623
  };
@@ -25335,6 +25646,10 @@ const TextStyle = Mark.create({
25335
25646
  },
25336
25647
  addAttributes() {
25337
25648
  return {
25649
+ /**
25650
+ * @category Attribute
25651
+ * @param {string} [styleId] - Style identifier for referencing predefined styles
25652
+ */
25338
25653
  styleId: {}
25339
25654
  };
25340
25655
  },
@@ -25343,10 +25658,11 @@ const TextStyle = Mark.create({
25343
25658
  /**
25344
25659
  * Remove empty text style marks
25345
25660
  * @category Command
25346
- * @returns {Function} Command - Removes mark if no attributes present
25661
+ * @returns {Function} Command function - Removes mark if no attributes present
25347
25662
  * @example
25348
25663
  * removeEmptyTextStyle()
25349
25664
  * @note Cleanup utility to prevent empty span elements
25665
+ * @note Automatically checks if any style attributes exist before removal
25350
25666
  */
25351
25667
  removeEmptyTextStyle: () => ({ state, commands: commands2 }) => {
25352
25668
  const attributes = Attribute.getMarkAttributes(state, this.type);
@@ -26368,12 +26684,16 @@ const TextTransform = Extension.create({
26368
26684
  {
26369
26685
  types: this.options.types,
26370
26686
  attributes: {
26687
+ /**
26688
+ * @category Attribute
26689
+ * @param {string} [textTransform] - Text transform value (uppercase, lowercase, capitalize, none)
26690
+ */
26371
26691
  textTransform: {
26372
26692
  default: null,
26373
26693
  renderDOM: (attrs) => {
26374
- if (!attrs.textCase) return {};
26694
+ if (!attrs.textTransform) return {};
26375
26695
  return {
26376
- style: `text-transform: ${attrs.textCase}`
26696
+ style: `text-transform: ${attrs.textTransform}`
26377
26697
  };
26378
26698
  }
26379
26699
  }