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