tiptap-extension-resize-image
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -18,3 +18,70 @@ 'use strict'; | ||
default: 'width: 100%; height: auto; cursor: pointer;', | ||
parseHTML: element => { | ||
const width = element.getAttribute('width'); | ||
if (!width || isNaN(Number(width))) { | ||
return; | ||
} | ||
return `width: ${width}px; height: auto; cursor: pointer;`; | ||
}, | ||
}, | ||
title: { | ||
default: null, | ||
}, | ||
loading: { | ||
default: null, | ||
}, | ||
srcset: { | ||
default: null, | ||
}, | ||
sizes: { | ||
default: null, | ||
}, | ||
crossorigin: { | ||
default: null, | ||
}, | ||
usemap: { | ||
default: null, | ||
}, | ||
ismap: { | ||
default: null, | ||
}, | ||
width: { | ||
default: null, | ||
}, | ||
height: { | ||
default: null, | ||
}, | ||
referrerpolicy: { | ||
default: null, | ||
}, | ||
longdesc: { | ||
default: null, | ||
}, | ||
decoding: { | ||
default: null, | ||
}, | ||
class: { | ||
default: null, | ||
}, | ||
id: { | ||
default: null, | ||
}, | ||
name: { | ||
default: null, | ||
}, | ||
draggable: { | ||
default: true, | ||
}, | ||
tabindex: { | ||
default: null, | ||
}, | ||
'aria-label': { | ||
default: null, | ||
}, | ||
'aria-labelledby': { | ||
default: null, | ||
}, | ||
'aria-describedby': { | ||
default: null, | ||
}, | ||
}; | ||
@@ -25,3 +92,3 @@ }, | ||
const { view, options: { editable }, } = editor; | ||
const { src, alt, style } = node.attrs; | ||
const { style } = node.attrs; | ||
const $positionContainer = document.createElement('div'); | ||
@@ -78,6 +145,7 @@ const $container = document.createElement('div'); | ||
$container.appendChild($img); | ||
$img.setAttribute('src', src); | ||
$img.setAttribute('alt', alt); | ||
$img.setAttribute('style', style); | ||
$img.setAttribute('draggable', 'true'); | ||
Object.entries(node.attrs).forEach(([key, value]) => { | ||
if (value === undefined || value === null) | ||
return; | ||
$img.setAttribute(key, value); | ||
}); | ||
if (!editable) | ||
@@ -84,0 +152,0 @@ return { dom: $img }; |
@@ -14,3 +14,70 @@ import Image from '@tiptap/extension-image'; | ||
default: 'width: 100%; height: auto; cursor: pointer;', | ||
parseHTML: element => { | ||
const width = element.getAttribute('width'); | ||
if (!width || isNaN(Number(width))) { | ||
return; | ||
} | ||
return `width: ${width}px; height: auto; cursor: pointer;`; | ||
}, | ||
}, | ||
title: { | ||
default: null, | ||
}, | ||
loading: { | ||
default: null, | ||
}, | ||
srcset: { | ||
default: null, | ||
}, | ||
sizes: { | ||
default: null, | ||
}, | ||
crossorigin: { | ||
default: null, | ||
}, | ||
usemap: { | ||
default: null, | ||
}, | ||
ismap: { | ||
default: null, | ||
}, | ||
width: { | ||
default: null, | ||
}, | ||
height: { | ||
default: null, | ||
}, | ||
referrerpolicy: { | ||
default: null, | ||
}, | ||
longdesc: { | ||
default: null, | ||
}, | ||
decoding: { | ||
default: null, | ||
}, | ||
class: { | ||
default: null, | ||
}, | ||
id: { | ||
default: null, | ||
}, | ||
name: { | ||
default: null, | ||
}, | ||
draggable: { | ||
default: true, | ||
}, | ||
tabindex: { | ||
default: null, | ||
}, | ||
'aria-label': { | ||
default: null, | ||
}, | ||
'aria-labelledby': { | ||
default: null, | ||
}, | ||
'aria-describedby': { | ||
default: null, | ||
}, | ||
}; | ||
@@ -21,3 +88,3 @@ }, | ||
const { view, options: { editable }, } = editor; | ||
const { src, alt, style } = node.attrs; | ||
const { style } = node.attrs; | ||
const $positionContainer = document.createElement('div'); | ||
@@ -74,6 +141,7 @@ const $container = document.createElement('div'); | ||
$container.appendChild($img); | ||
$img.setAttribute('src', src); | ||
$img.setAttribute('alt', alt); | ||
$img.setAttribute('style', style); | ||
$img.setAttribute('draggable', 'true'); | ||
Object.entries(node.attrs).forEach(([key, value]) => { | ||
if (value === undefined || value === null) | ||
return; | ||
$img.setAttribute(key, value); | ||
}); | ||
if (!editable) | ||
@@ -80,0 +148,0 @@ return { dom: $img }; |
{ | ||
"name": "tiptap-extension-resize-image", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A tiptap image resizing extension for React, Vue, Next, and VanillaJS. Additionally, it can align the image position.", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58618
445