tiptap-extension-resize-image
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -91,3 +91,3 @@ 'use strict'; | ||
const { style } = node.attrs; | ||
const $positionContainer = document.createElement('div'); | ||
const $wrapper = document.createElement('div'); | ||
const $container = document.createElement('div'); | ||
@@ -107,22 +107,31 @@ const $img = document.createElement('img'); | ||
const $rightController = document.createElement('img'); | ||
const controllerMouseOver = e => { | ||
e.target.style.opacity = 0.3; | ||
}; | ||
const controllerMouseOut = e => { | ||
e.target.style.opacity = 1; | ||
}; | ||
$postionController.setAttribute('style', 'position: absolute; top: 0%; left: 50%; width: 100px; height: 25px; z-index: 999; background-color: rgba(255, 255, 255, 0.7); border-radius: 4px; border: 2px solid #6C6C6C; cursor: pointer; transform: translate(-50%, -50%); display: flex; justify-content: space-between; align-items: center; padding: 0 10px;'); | ||
$leftController.setAttribute('src', 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg'); | ||
$leftController.setAttribute('style', iconStyle); | ||
$leftController.addEventListener('mouseover', controllerMouseOver); | ||
$leftController.addEventListener('mouseout', controllerMouseOut); | ||
$centerController.setAttribute('src', 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg'); | ||
$centerController.setAttribute('style', iconStyle); | ||
$centerController.addEventListener('mouseover', controllerMouseOver); | ||
$centerController.addEventListener('mouseout', controllerMouseOut); | ||
$rightController.setAttribute('src', 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg'); | ||
$rightController.setAttribute('style', iconStyle); | ||
$rightController.addEventListener('mouseover', controllerMouseOver); | ||
$rightController.addEventListener('mouseout', controllerMouseOut); | ||
$leftController.addEventListener('click', () => { | ||
$positionContainer.setAttribute('style', 'display: flex; justify-content: flex-start;'); | ||
$img.setAttribute('style', `${$img.style.cssText} justify-content: flex-start;`); | ||
$img.setAttribute('style', `${$img.style.cssText} margin: 0 auto 0 0;`); | ||
dispatchNodeView(); | ||
}); | ||
$centerController.addEventListener('click', () => { | ||
$positionContainer.setAttribute('style', 'display: flex; justify-content: center;'); | ||
$img.setAttribute('style', `${$img.style.cssText} justify-content: center;`); | ||
$img.setAttribute('style', `${$img.style.cssText} margin: 0 auto;`); | ||
dispatchNodeView(); | ||
}); | ||
$rightController.addEventListener('click', () => { | ||
$positionContainer.setAttribute('style', 'display: flex; justify-content: flex-end;'); | ||
$img.setAttribute('style', `${$img.style.cssText} justify-content: flex-end;`); | ||
$img.setAttribute('style', `${$img.style.cssText} margin: 0 0 0 auto;`); | ||
dispatchNodeView(); | ||
@@ -135,9 +144,4 @@ }); | ||
}; | ||
// add position style and className | ||
$positionContainer.appendChild($container); | ||
const justifyContent = style.match(/justify-content: (.*?);/); | ||
$positionContainer.setAttribute('style', `display: flex; ${justifyContent ? justifyContent[0] : ''}`); | ||
if (justifyContent) { | ||
$img.className = `tiptap-image-${justifyContent[1]}`; | ||
} | ||
$wrapper.setAttribute('style', `display: flex;`); | ||
$wrapper.appendChild($container); | ||
$container.setAttribute('style', `${style}`); | ||
@@ -219,3 +223,3 @@ $container.appendChild($img); | ||
return { | ||
dom: $positionContainer, | ||
dom: $wrapper, | ||
}; | ||
@@ -222,0 +226,0 @@ }; |
@@ -87,3 +87,3 @@ import Image from '@tiptap/extension-image'; | ||
const { style } = node.attrs; | ||
const $positionContainer = document.createElement('div'); | ||
const $wrapper = document.createElement('div'); | ||
const $container = document.createElement('div'); | ||
@@ -103,22 +103,31 @@ const $img = document.createElement('img'); | ||
const $rightController = document.createElement('img'); | ||
const controllerMouseOver = e => { | ||
e.target.style.opacity = 0.3; | ||
}; | ||
const controllerMouseOut = e => { | ||
e.target.style.opacity = 1; | ||
}; | ||
$postionController.setAttribute('style', 'position: absolute; top: 0%; left: 50%; width: 100px; height: 25px; z-index: 999; background-color: rgba(255, 255, 255, 0.7); border-radius: 4px; border: 2px solid #6C6C6C; cursor: pointer; transform: translate(-50%, -50%); display: flex; justify-content: space-between; align-items: center; padding: 0 10px;'); | ||
$leftController.setAttribute('src', 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg'); | ||
$leftController.setAttribute('style', iconStyle); | ||
$leftController.addEventListener('mouseover', controllerMouseOver); | ||
$leftController.addEventListener('mouseout', controllerMouseOut); | ||
$centerController.setAttribute('src', 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg'); | ||
$centerController.setAttribute('style', iconStyle); | ||
$centerController.addEventListener('mouseover', controllerMouseOver); | ||
$centerController.addEventListener('mouseout', controllerMouseOut); | ||
$rightController.setAttribute('src', 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg'); | ||
$rightController.setAttribute('style', iconStyle); | ||
$rightController.addEventListener('mouseover', controllerMouseOver); | ||
$rightController.addEventListener('mouseout', controllerMouseOut); | ||
$leftController.addEventListener('click', () => { | ||
$positionContainer.setAttribute('style', 'display: flex; justify-content: flex-start;'); | ||
$img.setAttribute('style', `${$img.style.cssText} justify-content: flex-start;`); | ||
$img.setAttribute('style', `${$img.style.cssText} margin: 0 auto 0 0;`); | ||
dispatchNodeView(); | ||
}); | ||
$centerController.addEventListener('click', () => { | ||
$positionContainer.setAttribute('style', 'display: flex; justify-content: center;'); | ||
$img.setAttribute('style', `${$img.style.cssText} justify-content: center;`); | ||
$img.setAttribute('style', `${$img.style.cssText} margin: 0 auto;`); | ||
dispatchNodeView(); | ||
}); | ||
$rightController.addEventListener('click', () => { | ||
$positionContainer.setAttribute('style', 'display: flex; justify-content: flex-end;'); | ||
$img.setAttribute('style', `${$img.style.cssText} justify-content: flex-end;`); | ||
$img.setAttribute('style', `${$img.style.cssText} margin: 0 0 0 auto;`); | ||
dispatchNodeView(); | ||
@@ -131,9 +140,4 @@ }); | ||
}; | ||
// add position style and className | ||
$positionContainer.appendChild($container); | ||
const justifyContent = style.match(/justify-content: (.*?);/); | ||
$positionContainer.setAttribute('style', `display: flex; ${justifyContent ? justifyContent[0] : ''}`); | ||
if (justifyContent) { | ||
$img.className = `tiptap-image-${justifyContent[1]}`; | ||
} | ||
$wrapper.setAttribute('style', `display: flex;`); | ||
$wrapper.appendChild($container); | ||
$container.setAttribute('style', `${style}`); | ||
@@ -215,3 +219,3 @@ $container.appendChild($img); | ||
return { | ||
dom: $positionContainer, | ||
dom: $wrapper, | ||
}; | ||
@@ -218,0 +222,0 @@ }; |
{ | ||
"name": "tiptap-extension-resize-image", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59012
451