@pentestpad/tiptap-extension-figure 1.0.2 → 1.0.3
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/dist/index.cjs.js
CHANGED
|
@@ -328,16 +328,15 @@ const TiptapImageFigureExtension = ImageExtension.extend({
|
|
|
328
328
|
renderHTML({ HTMLAttributes, node }) {
|
|
329
329
|
const hasCaption = node.content.size > 0;
|
|
330
330
|
if (hasCaption) {
|
|
331
|
+
// We should ignore src, alt and title from html attributes if the wrapper element is a figure
|
|
332
|
+
const { src, alt, title, ...figureHtmlAttributes } = HTMLAttributes;
|
|
331
333
|
return [
|
|
332
334
|
"figure",
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
contenteditable: false,
|
|
339
|
-
}),
|
|
340
|
-
],
|
|
335
|
+
core.mergeAttributes(figureHtmlAttributes, {
|
|
336
|
+
draggable: false,
|
|
337
|
+
contenteditable: false,
|
|
338
|
+
}),
|
|
339
|
+
["img", core.mergeAttributes(HTMLAttributes)],
|
|
341
340
|
["figcaption", 0],
|
|
342
341
|
];
|
|
343
342
|
}
|
|
@@ -387,6 +386,7 @@ const TiptapImageFigureExtension = ImageExtension.extend({
|
|
|
387
386
|
wrapperElement.addEventListener("click", (event) => {
|
|
388
387
|
event.stopPropagation();
|
|
389
388
|
event.preventDefault();
|
|
389
|
+
editor.commands.setNodeSelection(getPos());
|
|
390
390
|
// If controls are already visible, check if another image or figure is being clicked on
|
|
391
391
|
if (this.storage.elementsVisible) {
|
|
392
392
|
const clickedElement = event.target;
|
package/dist/index.js
CHANGED
|
@@ -324,16 +324,15 @@ const TiptapImageFigureExtension = ImageExtension.extend({
|
|
|
324
324
|
renderHTML({ HTMLAttributes, node }) {
|
|
325
325
|
const hasCaption = node.content.size > 0;
|
|
326
326
|
if (hasCaption) {
|
|
327
|
+
// We should ignore src, alt and title from html attributes if the wrapper element is a figure
|
|
328
|
+
const { src, alt, title, ...figureHtmlAttributes } = HTMLAttributes;
|
|
327
329
|
return [
|
|
328
330
|
"figure",
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
contenteditable: false,
|
|
335
|
-
}),
|
|
336
|
-
],
|
|
331
|
+
mergeAttributes(figureHtmlAttributes, {
|
|
332
|
+
draggable: false,
|
|
333
|
+
contenteditable: false,
|
|
334
|
+
}),
|
|
335
|
+
["img", mergeAttributes(HTMLAttributes)],
|
|
337
336
|
["figcaption", 0],
|
|
338
337
|
];
|
|
339
338
|
}
|
|
@@ -383,6 +382,7 @@ const TiptapImageFigureExtension = ImageExtension.extend({
|
|
|
383
382
|
wrapperElement.addEventListener("click", (event) => {
|
|
384
383
|
event.stopPropagation();
|
|
385
384
|
event.preventDefault();
|
|
385
|
+
editor.commands.setNodeSelection(getPos());
|
|
386
386
|
// If controls are already visible, check if another image or figure is being clicked on
|
|
387
387
|
if (this.storage.elementsVisible) {
|
|
388
388
|
const clickedElement = event.target;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pentestpad/tiptap-extension-figure",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "An extension for Tiptap that allows you to add and edit captions for images as well as align and resize them.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@tiptap/core": "^2.11.5",
|
|
19
19
|
"@tiptap/extension-image": "^2.11.5",
|
|
20
20
|
"@tiptap/pm": "^2.11.5",
|
|
21
|
-
"rollup": "^4.34.
|
|
21
|
+
"rollup": "^4.34.8",
|
|
22
22
|
"rollup-plugin-auto-external": "^2.0.0",
|
|
23
23
|
"rollup-plugin-postcss": "^4.0.2",
|
|
24
24
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
@@ -99,16 +99,16 @@ const TiptapImageFigureExtension = ImageExtension.extend<ImageOptions>({
|
|
|
99
99
|
const hasCaption = node.content.size > 0;
|
|
100
100
|
|
|
101
101
|
if (hasCaption) {
|
|
102
|
+
// We should ignore src, alt and title from html attributes if the wrapper element is a figure
|
|
103
|
+
const { src, alt, title, ...figureHtmlAttributes } = HTMLAttributes;
|
|
104
|
+
|
|
102
105
|
return [
|
|
103
106
|
"figure",
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
contenteditable: false,
|
|
110
|
-
}),
|
|
111
|
-
],
|
|
107
|
+
mergeAttributes(figureHtmlAttributes, {
|
|
108
|
+
draggable: false,
|
|
109
|
+
contenteditable: false,
|
|
110
|
+
}),
|
|
111
|
+
["img", mergeAttributes(HTMLAttributes)],
|
|
112
112
|
["figcaption", 0],
|
|
113
113
|
];
|
|
114
114
|
}
|
|
@@ -175,6 +175,8 @@ const TiptapImageFigureExtension = ImageExtension.extend<ImageOptions>({
|
|
|
175
175
|
event.stopPropagation();
|
|
176
176
|
event.preventDefault();
|
|
177
177
|
|
|
178
|
+
editor.commands.setNodeSelection(getPos());
|
|
179
|
+
|
|
178
180
|
// If controls are already visible, check if another image or figure is being clicked on
|
|
179
181
|
if (this.storage.elementsVisible) {
|
|
180
182
|
const clickedElement = event.target as HTMLElement;
|