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