tiptap-extension-resize-image
Advanced tools
+4
-0
@@ -67,5 +67,9 @@ 'use strict'; | ||
| }; | ||
| // 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]}`; | ||
| } | ||
| $container.setAttribute('style', `${style}`); | ||
@@ -72,0 +76,0 @@ $container.appendChild($img); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../lib/imageResize.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\n\nexport const ImageResize = Image.extend({\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n style: {\n default: 'width: 100%; height: auto; cursor: pointer;',\n },\n };\n },\n addNodeView() {\n return ({ node, editor, getPos }) => {\n const {\n view,\n options: { editable },\n } = editor;\n const { src, alt, style } = node.attrs;\n const $positionContainer = document.createElement('div');\n const $container = document.createElement('div');\n const $img = document.createElement('img');\n const iconStyle = 'width: 24px; height: 24px; cursor: pointer;';\n\n const dispatchNodeView = () => {\n if (typeof getPos === 'function') {\n const newAttrs = {\n ...node.attrs,\n style: `${$img.style.cssText}`,\n };\n view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, newAttrs));\n }\n };\n const paintPositionContoller = () => {\n const $postionController = document.createElement('div');\n\n const $leftController = document.createElement('img');\n const $centerController = document.createElement('img');\n const $rightController = document.createElement('img');\n\n $postionController.setAttribute(\n 'style',\n '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;',\n );\n $leftController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg',\n );\n $leftController.setAttribute('style', iconStyle);\n $centerController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg',\n );\n $centerController.setAttribute('style', iconStyle);\n $rightController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg',\n );\n $rightController.setAttribute('style', iconStyle);\n\n $leftController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-start;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-start;`);\n dispatchNodeView();\n });\n $centerController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: center;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: center;`);\n dispatchNodeView();\n });\n $rightController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-end;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-end;`);\n dispatchNodeView();\n });\n\n $postionController.appendChild($leftController);\n $postionController.appendChild($centerController);\n $postionController.appendChild($rightController);\n\n $container.appendChild($postionController);\n };\n\n $positionContainer.appendChild($container);\n const justifyContent = style.match(/justify-content: (.*?);/);\n $positionContainer.setAttribute(\n 'style',\n `display: flex; ${justifyContent ? justifyContent[0] : ''}`,\n );\n\n $container.setAttribute('style', `${style}`);\n $container.appendChild($img);\n\n $img.setAttribute('src', src);\n $img.setAttribute('alt', alt);\n $img.setAttribute('style', style);\n $img.setAttribute('draggable', 'true');\n\n if (!editable) return { dom: $img };\n\n const dotsPosition = [\n 'top: -4px; left: -4px; cursor: nwse-resize;',\n 'top: -4px; right: -4px; cursor: nesw-resize;',\n 'bottom: -4px; left: -4px; cursor: nesw-resize;',\n 'bottom: -4px; right: -4px; cursor: nwse-resize;',\n ];\n\n let isResizing = false;\n let startX: number, startWidth: number, startHeight: number;\n\n $container.addEventListener('click', () => {\n //remove remaining dots and position controller\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n\n paintPositionContoller();\n\n $container.setAttribute(\n 'style',\n `position: relative; border: 1px dashed #6C6C6C; ${style} cursor: pointer;`,\n );\n\n Array.from({ length: 4 }, (_, index) => {\n const $dot = document.createElement('div');\n $dot.setAttribute(\n 'style',\n `position: absolute; width: 9px; height: 9px; border: 1.5px solid #6C6C6C; border-radius: 50%; ${dotsPosition[index]}`,\n );\n\n $dot.addEventListener('mousedown', e => {\n e.preventDefault();\n isResizing = true;\n startX = e.clientX;\n startWidth = $container.offsetWidth;\n startHeight = $container.offsetHeight;\n\n const onMouseMove = (e: MouseEvent) => {\n if (!isResizing) return;\n const deltaX = index % 2 === 0 ? -(e.clientX - startX) : e.clientX - startX;\n\n const aspectRatio = startWidth / startHeight;\n const newWidth = startWidth + deltaX;\n const newHeight = newWidth / aspectRatio;\n\n $container.style.width = newWidth + 'px';\n $container.style.height = newHeight + 'px';\n\n $img.style.width = newWidth + 'px';\n $img.style.height = newHeight + 'px';\n };\n\n const onMouseUp = () => {\n if (isResizing) {\n isResizing = false;\n }\n dispatchNodeView();\n\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', onMouseUp);\n };\n\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', onMouseUp);\n });\n $container.appendChild($dot);\n });\n });\n\n document.addEventListener('click', (e: MouseEvent) => {\n const $target = e.target as HTMLElement;\n const isClickInside = $container.contains($target) || $target.style.cssText === iconStyle;\n\n if (!isClickInside) {\n const containerStyle = $container.getAttribute('style');\n const newStyle = containerStyle?.replace('border: 1px dashed #6C6C6C;', '');\n $container.setAttribute('style', newStyle as string);\n\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n }\n });\n\n return {\n dom: $positionContainer,\n };\n };\n },\n});\n"],"names":[],"mappings":";;;;;;AAEa,MAAA,WAAW,GAAG,KAAK,CAAC,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
| {"version":3,"file":"index.js","sources":["../lib/imageResize.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\n\nexport const ImageResize = Image.extend({\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n style: {\n default: 'width: 100%; height: auto; cursor: pointer;',\n },\n };\n },\n addNodeView() {\n return ({ node, editor, getPos }) => {\n const {\n view,\n options: { editable },\n } = editor;\n const { src, alt, style } = node.attrs;\n const $positionContainer = document.createElement('div');\n const $container = document.createElement('div');\n const $img = document.createElement('img');\n const iconStyle = 'width: 24px; height: 24px; cursor: pointer;';\n\n const dispatchNodeView = () => {\n if (typeof getPos === 'function') {\n const newAttrs = {\n ...node.attrs,\n style: `${$img.style.cssText}`,\n };\n view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, newAttrs));\n }\n };\n const paintPositionContoller = () => {\n const $postionController = document.createElement('div');\n\n const $leftController = document.createElement('img');\n const $centerController = document.createElement('img');\n const $rightController = document.createElement('img');\n\n $postionController.setAttribute(\n 'style',\n '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;',\n );\n $leftController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg',\n );\n $leftController.setAttribute('style', iconStyle);\n $centerController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg',\n );\n $centerController.setAttribute('style', iconStyle);\n $rightController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg',\n );\n $rightController.setAttribute('style', iconStyle);\n\n $leftController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-start;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-start;`);\n dispatchNodeView();\n });\n $centerController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: center;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: center;`);\n dispatchNodeView();\n });\n $rightController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-end;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-end;`);\n dispatchNodeView();\n });\n\n $postionController.appendChild($leftController);\n $postionController.appendChild($centerController);\n $postionController.appendChild($rightController);\n\n $container.appendChild($postionController);\n };\n\n // add position style and className\n $positionContainer.appendChild($container);\n const justifyContent = style.match(/justify-content: (.*?);/);\n $positionContainer.setAttribute(\n 'style',\n `display: flex; ${justifyContent ? justifyContent[0] : ''}`,\n );\n\n if (justifyContent) {\n $img.className = `tiptap-image-${justifyContent[1]}`;\n }\n\n $container.setAttribute('style', `${style}`);\n $container.appendChild($img);\n\n $img.setAttribute('src', src);\n $img.setAttribute('alt', alt);\n $img.setAttribute('style', style);\n $img.setAttribute('draggable', 'true');\n\n if (!editable) return { dom: $img };\n\n const dotsPosition = [\n 'top: -4px; left: -4px; cursor: nwse-resize;',\n 'top: -4px; right: -4px; cursor: nesw-resize;',\n 'bottom: -4px; left: -4px; cursor: nesw-resize;',\n 'bottom: -4px; right: -4px; cursor: nwse-resize;',\n ];\n\n let isResizing = false;\n let startX: number, startWidth: number, startHeight: number;\n\n $container.addEventListener('click', () => {\n //remove remaining dots and position controller\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n\n paintPositionContoller();\n\n $container.setAttribute(\n 'style',\n `position: relative; border: 1px dashed #6C6C6C; ${style} cursor: pointer;`,\n );\n\n Array.from({ length: 4 }, (_, index) => {\n const $dot = document.createElement('div');\n $dot.setAttribute(\n 'style',\n `position: absolute; width: 9px; height: 9px; border: 1.5px solid #6C6C6C; border-radius: 50%; ${dotsPosition[index]}`,\n );\n\n $dot.addEventListener('mousedown', e => {\n e.preventDefault();\n isResizing = true;\n startX = e.clientX;\n startWidth = $container.offsetWidth;\n startHeight = $container.offsetHeight;\n\n const onMouseMove = (e: MouseEvent) => {\n if (!isResizing) return;\n const deltaX = index % 2 === 0 ? -(e.clientX - startX) : e.clientX - startX;\n\n const aspectRatio = startWidth / startHeight;\n const newWidth = startWidth + deltaX;\n const newHeight = newWidth / aspectRatio;\n\n $container.style.width = newWidth + 'px';\n $container.style.height = newHeight + 'px';\n\n $img.style.width = newWidth + 'px';\n $img.style.height = newHeight + 'px';\n };\n\n const onMouseUp = () => {\n if (isResizing) {\n isResizing = false;\n }\n dispatchNodeView();\n\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', onMouseUp);\n };\n\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', onMouseUp);\n });\n $container.appendChild($dot);\n });\n });\n\n document.addEventListener('click', (e: MouseEvent) => {\n const $target = e.target as HTMLElement;\n const isClickInside = $container.contains($target) || $target.style.cssText === iconStyle;\n\n if (!isClickInside) {\n const containerStyle = $container.getAttribute('style');\n const newStyle = containerStyle?.replace('border: 1px dashed #6C6C6C;', '');\n $container.setAttribute('style', newStyle as string);\n\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n }\n });\n\n return {\n dom: $positionContainer,\n };\n };\n },\n});\n"],"names":[],"mappings":";;;;;;AAEa,MAAA,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IACtC,aAAa,GAAA;QACX,OAAO;AACL,YAAA,GAAG,EAAE;AACH,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,GAAG,EAAE;AACH,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,KAAK,EAAE;AACL,gBAAA,OAAO,EAAE,6CAA6C;AACvD,aAAA;SACF,CAAC;KACH;IACD,WAAW,GAAA;QACT,OAAO,CAAC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CAAC;AAClD,qBAAC,CAAC,CAAC;AACH,oBAAA,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC/B,iBAAC,CAAC,CAAC;AACL,aAAC,CAAC,CAAC;YAEH,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAa,KAAI;AACnD,gBAAA,MAAM,OAAO,GAAG,CAAC,CAAC,MAAqB,CAAC;AACxC,gBAAA,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC;gBAE1F,IAAI,CAAC,aAAa,EAAE;oBAClB,MAAM,cAAc,GAAG,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACxD,oBAAA,MAAM,QAAQ,GAAG,cAAc,KAAA,IAAA,IAAd,cAAc,KAAd,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,cAAc,CAAE,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;AAC5E,oBAAA,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,QAAkB,CAAC,CAAC;AAErD,oBAAA,IAAI,UAAU,CAAC,iBAAiB,GAAG,CAAC,EAAE;wBACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,4BAAA,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,SAAiB,CAAC,CAAC;AACtD,yBAAA;AACF,qBAAA;AACF,iBAAA;AACH,aAAC,CAAC,CAAC;YAEH,OAAO;AACL,gBAAA,GAAG,EAAE,kBAAkB;aACxB,CAAC;AACJ,SAAC,CAAC;KACH;AACF,CAAA;;;;;"} |
+4
-0
@@ -63,5 +63,9 @@ import Image from '@tiptap/extension-image'; | ||
| }; | ||
| // 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]}`; | ||
| } | ||
| $container.setAttribute('style', `${style}`); | ||
@@ -68,0 +72,0 @@ $container.appendChild($img); |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../lib/imageResize.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\n\nexport const ImageResize = Image.extend({\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n style: {\n default: 'width: 100%; height: auto; cursor: pointer;',\n },\n };\n },\n addNodeView() {\n return ({ node, editor, getPos }) => {\n const {\n view,\n options: { editable },\n } = editor;\n const { src, alt, style } = node.attrs;\n const $positionContainer = document.createElement('div');\n const $container = document.createElement('div');\n const $img = document.createElement('img');\n const iconStyle = 'width: 24px; height: 24px; cursor: pointer;';\n\n const dispatchNodeView = () => {\n if (typeof getPos === 'function') {\n const newAttrs = {\n ...node.attrs,\n style: `${$img.style.cssText}`,\n };\n view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, newAttrs));\n }\n };\n const paintPositionContoller = () => {\n const $postionController = document.createElement('div');\n\n const $leftController = document.createElement('img');\n const $centerController = document.createElement('img');\n const $rightController = document.createElement('img');\n\n $postionController.setAttribute(\n 'style',\n '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;',\n );\n $leftController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg',\n );\n $leftController.setAttribute('style', iconStyle);\n $centerController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg',\n );\n $centerController.setAttribute('style', iconStyle);\n $rightController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg',\n );\n $rightController.setAttribute('style', iconStyle);\n\n $leftController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-start;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-start;`);\n dispatchNodeView();\n });\n $centerController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: center;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: center;`);\n dispatchNodeView();\n });\n $rightController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-end;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-end;`);\n dispatchNodeView();\n });\n\n $postionController.appendChild($leftController);\n $postionController.appendChild($centerController);\n $postionController.appendChild($rightController);\n\n $container.appendChild($postionController);\n };\n\n $positionContainer.appendChild($container);\n const justifyContent = style.match(/justify-content: (.*?);/);\n $positionContainer.setAttribute(\n 'style',\n `display: flex; ${justifyContent ? justifyContent[0] : ''}`,\n );\n\n $container.setAttribute('style', `${style}`);\n $container.appendChild($img);\n\n $img.setAttribute('src', src);\n $img.setAttribute('alt', alt);\n $img.setAttribute('style', style);\n $img.setAttribute('draggable', 'true');\n\n if (!editable) return { dom: $img };\n\n const dotsPosition = [\n 'top: -4px; left: -4px; cursor: nwse-resize;',\n 'top: -4px; right: -4px; cursor: nesw-resize;',\n 'bottom: -4px; left: -4px; cursor: nesw-resize;',\n 'bottom: -4px; right: -4px; cursor: nwse-resize;',\n ];\n\n let isResizing = false;\n let startX: number, startWidth: number, startHeight: number;\n\n $container.addEventListener('click', () => {\n //remove remaining dots and position controller\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n\n paintPositionContoller();\n\n $container.setAttribute(\n 'style',\n `position: relative; border: 1px dashed #6C6C6C; ${style} cursor: pointer;`,\n );\n\n Array.from({ length: 4 }, (_, index) => {\n const $dot = document.createElement('div');\n $dot.setAttribute(\n 'style',\n `position: absolute; width: 9px; height: 9px; border: 1.5px solid #6C6C6C; border-radius: 50%; ${dotsPosition[index]}`,\n );\n\n $dot.addEventListener('mousedown', e => {\n e.preventDefault();\n isResizing = true;\n startX = e.clientX;\n startWidth = $container.offsetWidth;\n startHeight = $container.offsetHeight;\n\n const onMouseMove = (e: MouseEvent) => {\n if (!isResizing) return;\n const deltaX = index % 2 === 0 ? -(e.clientX - startX) : e.clientX - startX;\n\n const aspectRatio = startWidth / startHeight;\n const newWidth = startWidth + deltaX;\n const newHeight = newWidth / aspectRatio;\n\n $container.style.width = newWidth + 'px';\n $container.style.height = newHeight + 'px';\n\n $img.style.width = newWidth + 'px';\n $img.style.height = newHeight + 'px';\n };\n\n const onMouseUp = () => {\n if (isResizing) {\n isResizing = false;\n }\n dispatchNodeView();\n\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', onMouseUp);\n };\n\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', onMouseUp);\n });\n $container.appendChild($dot);\n });\n });\n\n document.addEventListener('click', (e: MouseEvent) => {\n const $target = e.target as HTMLElement;\n const isClickInside = $container.contains($target) || $target.style.cssText === iconStyle;\n\n if (!isClickInside) {\n const containerStyle = $container.getAttribute('style');\n const newStyle = containerStyle?.replace('border: 1px dashed #6C6C6C;', '');\n $container.setAttribute('style', newStyle as string);\n\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n }\n });\n\n return {\n dom: $positionContainer,\n };\n };\n },\n});\n"],"names":[],"mappings":";;AAEa,MAAA,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IACtC,aAAa,GAAA;QACX,OAAO;AACL,YAAA,GAAG,EAAE;AACH,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,GAAG,EAAE;AACH,gBAAA,OAAO,EAAE,IAAI;AAC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,qBAAC,CAAC,CAAC;AACH,oBAAA,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC/B,iBAAC,CAAC,CAAC;AACL,aAAC,CAAC,CAAC;YAEH,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAa,KAAI;AACnD,gBAAA,MAAM,OAAO,GAAG,CAAC,CAAC,MAAqB,CAAC;AACxC,gBAAA,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC;gBAE1F,IAAI,CAAC,aAAa,EAAE;oBAClB,MAAM,cAAc,GAAG,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACxD,oBAAA,MAAM,QAAQ,GAAG,cAAc,KAAA,IAAA,IAAd,cAAc,KAAd,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,cAAc,CAAE,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;AAC5E,oBAAA,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,QAAkB,CAAC,CAAC;AAErD,oBAAA,IAAI,UAAU,CAAC,iBAAiB,GAAG,CAAC,EAAE;wBACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,4BAAA,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,SAAiB,CAAC,CAAC;AACtD,yBAAA;AACF,qBAAA;AACF,iBAAA;AACH,aAAC,CAAC,CAAC;YAEH,OAAO;AACL,gBAAA,GAAG,EAAE,kBAAkB;aACxB,CAAC;AACJ,SAAC,CAAC;KACH;AACF,CAAA;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../lib/imageResize.ts"],"sourcesContent":["import Image from '@tiptap/extension-image';\n\nexport const ImageResize = Image.extend({\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n style: {\n default: 'width: 100%; height: auto; cursor: pointer;',\n },\n };\n },\n addNodeView() {\n return ({ node, editor, getPos }) => {\n const {\n view,\n options: { editable },\n } = editor;\n const { src, alt, style } = node.attrs;\n const $positionContainer = document.createElement('div');\n const $container = document.createElement('div');\n const $img = document.createElement('img');\n const iconStyle = 'width: 24px; height: 24px; cursor: pointer;';\n\n const dispatchNodeView = () => {\n if (typeof getPos === 'function') {\n const newAttrs = {\n ...node.attrs,\n style: `${$img.style.cssText}`,\n };\n view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, newAttrs));\n }\n };\n const paintPositionContoller = () => {\n const $postionController = document.createElement('div');\n\n const $leftController = document.createElement('img');\n const $centerController = document.createElement('img');\n const $rightController = document.createElement('img');\n\n $postionController.setAttribute(\n 'style',\n '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;',\n );\n $leftController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg',\n );\n $leftController.setAttribute('style', iconStyle);\n $centerController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg',\n );\n $centerController.setAttribute('style', iconStyle);\n $rightController.setAttribute(\n 'src',\n 'https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg',\n );\n $rightController.setAttribute('style', iconStyle);\n\n $leftController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-start;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-start;`);\n dispatchNodeView();\n });\n $centerController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: center;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: center;`);\n dispatchNodeView();\n });\n $rightController.addEventListener('click', () => {\n $positionContainer.setAttribute('style', 'display: flex; justify-content: flex-end;');\n $img.setAttribute('style', `${$img.style.cssText} justify-content: flex-end;`);\n dispatchNodeView();\n });\n\n $postionController.appendChild($leftController);\n $postionController.appendChild($centerController);\n $postionController.appendChild($rightController);\n\n $container.appendChild($postionController);\n };\n\n // add position style and className\n $positionContainer.appendChild($container);\n const justifyContent = style.match(/justify-content: (.*?);/);\n $positionContainer.setAttribute(\n 'style',\n `display: flex; ${justifyContent ? justifyContent[0] : ''}`,\n );\n\n if (justifyContent) {\n $img.className = `tiptap-image-${justifyContent[1]}`;\n }\n\n $container.setAttribute('style', `${style}`);\n $container.appendChild($img);\n\n $img.setAttribute('src', src);\n $img.setAttribute('alt', alt);\n $img.setAttribute('style', style);\n $img.setAttribute('draggable', 'true');\n\n if (!editable) return { dom: $img };\n\n const dotsPosition = [\n 'top: -4px; left: -4px; cursor: nwse-resize;',\n 'top: -4px; right: -4px; cursor: nesw-resize;',\n 'bottom: -4px; left: -4px; cursor: nesw-resize;',\n 'bottom: -4px; right: -4px; cursor: nwse-resize;',\n ];\n\n let isResizing = false;\n let startX: number, startWidth: number, startHeight: number;\n\n $container.addEventListener('click', () => {\n //remove remaining dots and position controller\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n\n paintPositionContoller();\n\n $container.setAttribute(\n 'style',\n `position: relative; border: 1px dashed #6C6C6C; ${style} cursor: pointer;`,\n );\n\n Array.from({ length: 4 }, (_, index) => {\n const $dot = document.createElement('div');\n $dot.setAttribute(\n 'style',\n `position: absolute; width: 9px; height: 9px; border: 1.5px solid #6C6C6C; border-radius: 50%; ${dotsPosition[index]}`,\n );\n\n $dot.addEventListener('mousedown', e => {\n e.preventDefault();\n isResizing = true;\n startX = e.clientX;\n startWidth = $container.offsetWidth;\n startHeight = $container.offsetHeight;\n\n const onMouseMove = (e: MouseEvent) => {\n if (!isResizing) return;\n const deltaX = index % 2 === 0 ? -(e.clientX - startX) : e.clientX - startX;\n\n const aspectRatio = startWidth / startHeight;\n const newWidth = startWidth + deltaX;\n const newHeight = newWidth / aspectRatio;\n\n $container.style.width = newWidth + 'px';\n $container.style.height = newHeight + 'px';\n\n $img.style.width = newWidth + 'px';\n $img.style.height = newHeight + 'px';\n };\n\n const onMouseUp = () => {\n if (isResizing) {\n isResizing = false;\n }\n dispatchNodeView();\n\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', onMouseUp);\n };\n\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', onMouseUp);\n });\n $container.appendChild($dot);\n });\n });\n\n document.addEventListener('click', (e: MouseEvent) => {\n const $target = e.target as HTMLElement;\n const isClickInside = $container.contains($target) || $target.style.cssText === iconStyle;\n\n if (!isClickInside) {\n const containerStyle = $container.getAttribute('style');\n const newStyle = containerStyle?.replace('border: 1px dashed #6C6C6C;', '');\n $container.setAttribute('style', newStyle as string);\n\n if ($container.childElementCount > 3) {\n for (let i = 0; i < 5; i++) {\n $container.removeChild($container.lastChild as Node);\n }\n }\n }\n });\n\n return {\n dom: $positionContainer,\n };\n };\n },\n});\n"],"names":[],"mappings":";;AAEa,MAAA,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IACtC,aAAa,GAAA;QACX,OAAO;AACL,YAAA,GAAG,EAAE;AACH,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,GAAG,EAAE;AACH,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA;AACD,YAAA,KAAK,EAAE;AACL,gBAAA,OAAO,EAAE,6CAA6C;AACvD,aAAA;SACF,CAAC;KACH;IACD,WAAW,GAAA;QACT,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAI;YAClC,MAAM,EACJ,IAAI,EACJ,OAAO,EAAE,EAAE,QAAQ,EAAE,GACtB,GAAG,MAAM,CAAC;YACX,MAAM,EAAE,GAAG,EAAE,GA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C,OAAO,EAAE,CAAC,CAAa,KAAI;AACnD,gBAAA,MAAM,OAAO,GAAG,CAAC,CAAC,MAAqB,CAAC;AACxC,gBAAA,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC;gBAE1F,IAAI,CAAC,aAAa,EAAE;oBAClB,MAAM,cAAc,GAAG,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACxD,oBAAA,MAAM,QAAQ,GAAG,cAAc,KAAA,IAAA,IAAd,cAAc,KAAd,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,cAAc,CAAE,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;AAC5E,oBAAA,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,QAAkB,CAAC,CAAC;AAErD,oBAAA,IAAI,UAAU,CAAC,iBAAiB,GAAG,CAAC,EAAE;wBACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,4BAAA,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,SAAiB,CAAC,CAAC;AACtD,yBAAA;AACF,qBAAA;AACF,iBAAA;AACH,aAAC,CAAC,CAAC;YAEH,OAAO;AACL,gBAAA,GAAG,EAAE,kBAAkB;aACxB,CAAC;AACJ,SAAC,CAAC;KACH;AACF,CAAA;;;;"} |
+1
-1
| { | ||
| "name": "tiptap-extension-resize-image", | ||
| "version": "1.1.3", | ||
| "version": "1.1.4", | ||
| "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.", |
49790
1.75%309
2.66%