tiptap-extension-izzy-resizable-image 0.1.6 → 0.1.8

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 (2) hide show
  1. package/npm/index.js +11 -10
  2. package/package.json +1 -1
package/npm/index.js CHANGED
@@ -39,11 +39,11 @@ class ResizableImageView {
39
39
  this.img.src = node.attrs.src
40
40
  this.img.alt = node.attrs.alt || ''
41
41
  this.img.style.display = 'block'
42
- this.img.style.userSelect = 'none'
43
- this.img.style.pointerEvents = 'none'
44
- if (node.attrs.id) this.img.id = node.attrs.id
45
- if (node.attrs.class) this.img.className = node.attrs.class
46
- if (node.attrs.width) this.img.style.width = node.attrs.width + 'px'
42
+ this.img.style.userSelect = 'none'
43
+ this.img.style.pointerEvents = 'none'
44
+ if (node.attrs.id) this.img.id = node.attrs.id
45
+ if (node.attrs.class) this.img.className = node.attrs.class
46
+ if (node.attrs.width) this.img.style.width = node.attrs.width + 'px'
47
47
  if (node.attrs.height) {
48
48
  this.img.style.height = node.attrs.height + 'px'
49
49
  } else if (this.options && this.options.height) {
@@ -94,7 +94,7 @@ class ResizableImageView {
94
94
  this.btnCenter.innerHTML = (node.attrs.iconCenter != null ? node.attrs.iconCenter : (this.options.alignMenuIcons?.center ?? '⇔'))
95
95
  this.btnRight.innerHTML = (node.attrs.iconRight != null ? node.attrs.iconRight : (this.options.alignMenuIcons?.right ?? '⟹'))
96
96
  this.btnClear.innerHTML = (node.attrs.iconClear != null ? node.attrs.iconClear : (this.options.alignMenuIcons?.clear ?? 'x'))
97
- this.btnView.innerHTML = (this.options.alignMenuIcons?.preview ?? '🔍')
97
+ this.btnView.innerHTML = (node.attrs.iconView != null ? node.attrs.iconView : (this.options.alignMenuIcons?.preview ?? '🔍'))
98
98
  this.btnSize50.textContent = '50%'
99
99
  this.btnSize100.textContent = '100%'
100
100
 
@@ -280,8 +280,7 @@ class ResizableImageView {
280
280
  this.btnCenter.innerHTML = (node.attrs.iconCenter != null ? node.attrs.iconCenter : (this.options && this.options.alignMenuIcons ? this.options.alignMenuIcons.center : '⇔'))
281
281
  this.btnRight.innerHTML = (node.attrs.iconRight != null ? node.attrs.iconRight : (this.options && this.options.alignMenuIcons ? this.options.alignMenuIcons.right : '⟹'))
282
282
  this.btnClear.innerHTML = (node.attrs.iconClear != null ? node.attrs.iconClear : (this.options && this.options.alignMenuIcons ? this.options.alignMenuIcons.clear : 'x'))
283
- if (this.btnView) this.btnView.innerHTML = (this.options && this.options.alignMenuIcons ? this.options.alignMenuIcons.preview : '🔍')
284
- this.btnView.innerHTML = this.options.iconView ?? '🔍'
283
+ if (this.btnView) this.btnView.innerHTML = (node.attrs.iconView != null ? node.attrs.iconView : (this.options && this.options.alignMenuIcons ? this.options.alignMenuIcons.preview : '🔍'))
285
284
  this.aspect = (node.attrs.height && node.attrs.width) ? node.attrs.width / node.attrs.height : this.aspect
286
285
  return true
287
286
  }
@@ -394,7 +393,7 @@ export const TiptapIzzyExtensionResizableImage = Node.create({
394
393
  addCommands() {
395
394
  return {
396
395
  insertResizableImage:
397
- ({ src, alt, title, width, height }) => ({ commands }) => {
396
+ ({ src, alt, title, width, height, id, class: className, iconView }) => ({ commands }) => {
398
397
  return commands.insertContent({
399
398
  type: this.name,
400
399
  attrs: {
@@ -403,13 +402,15 @@ export const TiptapIzzyExtensionResizableImage = Node.create({
403
402
  title,
404
403
  width,
405
404
  height: height != null ? height : this.options.height,
405
+ id,
406
+ class: className,
406
407
  showAlignMenu: this.options.showAlignMenu,
407
408
  alignMenuPosition: this.options.alignMenuPosition,
408
409
  iconLeft: this.options.alignMenuIcons?.left,
409
410
  iconCenter: this.options.alignMenuIcons?.center,
410
411
  iconRight: this.options.alignMenuIcons?.right,
411
412
  iconClear: this.options.alignMenuIcons?.clear,
412
- iconView: this.options.alignMenuIcons?.preview,
413
+ iconView: iconView != null ? iconView : this.options.alignMenuIcons?.preview,
413
414
  },
414
415
  })
415
416
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiptap-extension-izzy-resizable-image",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Resizable image NodeView for TipTap v2 with alignment menu and defaults",
5
5
  "license": "MIT",
6
6
  "type": "module",