tiptap-extension-izzy-resizable-image 0.1.4 → 0.1.5
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/npm/index.js +27 -0
- package/package.json +1 -1
package/npm/index.js
CHANGED
|
@@ -467,6 +467,33 @@ export const TiptapIzzyExtensionResizableImage = Node.create({
|
|
|
467
467
|
},
|
|
468
468
|
},
|
|
469
469
|
},
|
|
470
|
+
appendTransaction: (transactions, oldState, newState) => {
|
|
471
|
+
const imgType = newState.schema.nodes.image
|
|
472
|
+
const resizeType = newState.schema.nodes[this.name]
|
|
473
|
+
if (!imgType || !resizeType) return null
|
|
474
|
+
let tr = newState.tr
|
|
475
|
+
let changed = false
|
|
476
|
+
newState.doc.descendants((node, pos) => {
|
|
477
|
+
if (node.type === imgType) {
|
|
478
|
+
tr = tr.setNodeMarkup(pos, resizeType, {
|
|
479
|
+
src: node.attrs.src,
|
|
480
|
+
alt: node.attrs.alt,
|
|
481
|
+
title: node.attrs.title,
|
|
482
|
+
width: node.attrs.width,
|
|
483
|
+
height: node.attrs.height ?? this.options.height,
|
|
484
|
+
showAlignMenu: this.options.showAlignMenu,
|
|
485
|
+
alignMenuPosition: this.options.alignMenuPosition,
|
|
486
|
+
iconLeft: this.options.alignMenuIcons?.left,
|
|
487
|
+
iconCenter: this.options.alignMenuIcons?.center,
|
|
488
|
+
iconRight: this.options.alignMenuIcons?.right,
|
|
489
|
+
iconClear: this.options.alignMenuIcons?.clear,
|
|
490
|
+
iconView: this.options.alignMenuIcons?.preview,
|
|
491
|
+
})
|
|
492
|
+
changed = true
|
|
493
|
+
}
|
|
494
|
+
})
|
|
495
|
+
return changed ? tr : null
|
|
496
|
+
},
|
|
470
497
|
}),
|
|
471
498
|
]
|
|
472
499
|
},
|