@tiptap/extension-image 2.0.0-beta.23 → 2.0.0-beta.27
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/packages/extension-image/src/image.d.ts +22 -0
- package/dist/packages/extension-image/src/index.d.ts +3 -0
- package/dist/tiptap-extension-image.cjs.js +76 -0
- package/dist/tiptap-extension-image.cjs.js.map +1 -0
- package/dist/tiptap-extension-image.esm.js +70 -0
- package/dist/tiptap-extension-image.esm.js.map +1 -0
- package/dist/tiptap-extension-image.umd.js +80 -0
- package/dist/tiptap-extension-image.umd.js.map +1 -0
- package/package.json +2 -2
- package/src/image.ts +6 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface ImageOptions {
|
|
3
|
+
inline: boolean;
|
|
4
|
+
allowBase64: boolean;
|
|
5
|
+
HTMLAttributes: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
image: {
|
|
10
|
+
/**
|
|
11
|
+
* Add an image
|
|
12
|
+
*/
|
|
13
|
+
setImage: (options: {
|
|
14
|
+
src: string;
|
|
15
|
+
alt?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
}) => ReturnType;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export declare const inputRegex: RegExp;
|
|
22
|
+
export declare const Image: Node<ImageOptions, any>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@tiptap/core');
|
|
6
|
+
|
|
7
|
+
const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
8
|
+
const Image = core.Node.create({
|
|
9
|
+
name: 'image',
|
|
10
|
+
addOptions() {
|
|
11
|
+
return {
|
|
12
|
+
inline: false,
|
|
13
|
+
allowBase64: false,
|
|
14
|
+
HTMLAttributes: {},
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
inline() {
|
|
18
|
+
return this.options.inline;
|
|
19
|
+
},
|
|
20
|
+
group() {
|
|
21
|
+
return this.options.inline ? 'inline' : 'block';
|
|
22
|
+
},
|
|
23
|
+
draggable: true,
|
|
24
|
+
addAttributes() {
|
|
25
|
+
return {
|
|
26
|
+
src: {
|
|
27
|
+
default: null,
|
|
28
|
+
},
|
|
29
|
+
alt: {
|
|
30
|
+
default: null,
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
parseHTML() {
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
tag: this.options.allowBase64
|
|
41
|
+
? 'img[src]'
|
|
42
|
+
: 'img[src]:not([src^="data:"])',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
},
|
|
46
|
+
renderHTML({ HTMLAttributes }) {
|
|
47
|
+
return ['img', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
48
|
+
},
|
|
49
|
+
addCommands() {
|
|
50
|
+
return {
|
|
51
|
+
setImage: options => ({ commands }) => {
|
|
52
|
+
return commands.insertContent({
|
|
53
|
+
type: this.name,
|
|
54
|
+
attrs: options,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
addInputRules() {
|
|
60
|
+
return [
|
|
61
|
+
core.nodeInputRule({
|
|
62
|
+
find: inputRegex,
|
|
63
|
+
type: this.type,
|
|
64
|
+
getAttributes: match => {
|
|
65
|
+
const [, , alt, src, title] = match;
|
|
66
|
+
return { src, alt, title };
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
exports.Image = Image;
|
|
74
|
+
exports["default"] = Image;
|
|
75
|
+
exports.inputRegex = inputRegex;
|
|
76
|
+
//# sourceMappingURL=tiptap-extension-image.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiptap-extension-image.cjs.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Node,\n nodeInputRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface ImageOptions {\n inline: boolean,\n allowBase64: boolean,\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType,\n }\n }\n}\n\nexport const inputRegex = /(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n addOptions() {\n return {\n inline: false,\n allowBase64: false,\n HTMLAttributes: {},\n }\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: this.options.allowBase64\n ? 'img[src]'\n : 'img[src]:not([src^=\"data:\"])',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]\n },\n\n addCommands() {\n return {\n setImage: options => ({ commands }) => {\n return commands.insertContent({\n type: this.name,\n attrs: options,\n })\n },\n }\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => {\n const [,, alt, src, title] = match\n\n return { src, alt, title }\n },\n }),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","nodeInputRule"],"mappings":";;;;;;MAuBa,UAAU,GAAG,mDAAkD;MAE/D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,UAAU;QACR,OAAO;YACL,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;KAC3B;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;KAChD;IAED,SAAS,EAAE,IAAI;IAEf,aAAa;QACX,OAAO;YACL,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI;aACd;SACF,CAAA;KACF;IAED,SAAS;QACP,OAAO;YACL;gBACE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;sBACzB,UAAU;sBACV,8BAA8B;aACnC;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,KAAK,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;KAC7E;IAED,WAAW;QACT,OAAO;YACL,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,QAAQ,EAAE;gBAChC,OAAO,QAAQ,CAAC,aAAa,CAAC;oBAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAE,OAAO;iBACf,CAAC,CAAA;aACH;SACF,CAAA;KACF;IAED,aAAa;QACX,OAAO;YACLC,kBAAa,CAAC;gBACZ,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,aAAa,EAAE,KAAK;oBAClB,MAAM,KAAI,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;oBAElC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;iBAC3B;aACF,CAAC;SACH,CAAA;KACF;CACF;;;;;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
4
|
+
const Image = Node.create({
|
|
5
|
+
name: 'image',
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
inline: false,
|
|
9
|
+
allowBase64: false,
|
|
10
|
+
HTMLAttributes: {},
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
inline() {
|
|
14
|
+
return this.options.inline;
|
|
15
|
+
},
|
|
16
|
+
group() {
|
|
17
|
+
return this.options.inline ? 'inline' : 'block';
|
|
18
|
+
},
|
|
19
|
+
draggable: true,
|
|
20
|
+
addAttributes() {
|
|
21
|
+
return {
|
|
22
|
+
src: {
|
|
23
|
+
default: null,
|
|
24
|
+
},
|
|
25
|
+
alt: {
|
|
26
|
+
default: null,
|
|
27
|
+
},
|
|
28
|
+
title: {
|
|
29
|
+
default: null,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
parseHTML() {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
tag: this.options.allowBase64
|
|
37
|
+
? 'img[src]'
|
|
38
|
+
: 'img[src]:not([src^="data:"])',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
},
|
|
42
|
+
renderHTML({ HTMLAttributes }) {
|
|
43
|
+
return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
44
|
+
},
|
|
45
|
+
addCommands() {
|
|
46
|
+
return {
|
|
47
|
+
setImage: options => ({ commands }) => {
|
|
48
|
+
return commands.insertContent({
|
|
49
|
+
type: this.name,
|
|
50
|
+
attrs: options,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
addInputRules() {
|
|
56
|
+
return [
|
|
57
|
+
nodeInputRule({
|
|
58
|
+
find: inputRegex,
|
|
59
|
+
type: this.type,
|
|
60
|
+
getAttributes: match => {
|
|
61
|
+
const [, , alt, src, title] = match;
|
|
62
|
+
return { src, alt, title };
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
];
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export { Image, Image as default, inputRegex };
|
|
70
|
+
//# sourceMappingURL=tiptap-extension-image.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiptap-extension-image.esm.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Node,\n nodeInputRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface ImageOptions {\n inline: boolean,\n allowBase64: boolean,\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType,\n }\n }\n}\n\nexport const inputRegex = /(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n addOptions() {\n return {\n inline: false,\n allowBase64: false,\n HTMLAttributes: {},\n }\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: this.options.allowBase64\n ? 'img[src]'\n : 'img[src]:not([src^=\"data:\"])',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]\n },\n\n addCommands() {\n return {\n setImage: options => ({ commands }) => {\n return commands.insertContent({\n type: this.name,\n attrs: options,\n })\n },\n }\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => {\n const [,, alt, src, title] = match\n\n return { src, alt, title }\n },\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;MAuBa,UAAU,GAAG,mDAAkD;MAE/D,KAAK,GAAG,IAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,UAAU;QACR,OAAO;YACL,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;KAC3B;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;KAChD;IAED,SAAS,EAAE,IAAI;IAEf,aAAa;QACX,OAAO;YACL,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI;aACd;SACF,CAAA;KACF;IAED,SAAS;QACP,OAAO;YACL;gBACE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;sBACzB,UAAU;sBACV,8BAA8B;aACnC;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;KAC7E;IAED,WAAW;QACT,OAAO;YACL,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,QAAQ,EAAE;gBAChC,OAAO,QAAQ,CAAC,aAAa,CAAC;oBAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAE,OAAO;iBACf,CAAC,CAAA;aACH;SACF,CAAA;KACF;IAED,aAAa;QACX,OAAO;YACL,aAAa,CAAC;gBACZ,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,aAAa,EAAE,KAAK;oBAClB,MAAM,KAAI,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;oBAElC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;iBAC3B;aACF,CAAC;SACH,CAAA;KACF;CACF;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-image"] = {}, global.core));
|
|
5
|
+
})(this, (function (exports, core) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
8
|
+
const Image = core.Node.create({
|
|
9
|
+
name: 'image',
|
|
10
|
+
addOptions() {
|
|
11
|
+
return {
|
|
12
|
+
inline: false,
|
|
13
|
+
allowBase64: false,
|
|
14
|
+
HTMLAttributes: {},
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
inline() {
|
|
18
|
+
return this.options.inline;
|
|
19
|
+
},
|
|
20
|
+
group() {
|
|
21
|
+
return this.options.inline ? 'inline' : 'block';
|
|
22
|
+
},
|
|
23
|
+
draggable: true,
|
|
24
|
+
addAttributes() {
|
|
25
|
+
return {
|
|
26
|
+
src: {
|
|
27
|
+
default: null,
|
|
28
|
+
},
|
|
29
|
+
alt: {
|
|
30
|
+
default: null,
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
parseHTML() {
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
tag: this.options.allowBase64
|
|
41
|
+
? 'img[src]'
|
|
42
|
+
: 'img[src]:not([src^="data:"])',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
},
|
|
46
|
+
renderHTML({ HTMLAttributes }) {
|
|
47
|
+
return ['img', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
48
|
+
},
|
|
49
|
+
addCommands() {
|
|
50
|
+
return {
|
|
51
|
+
setImage: options => ({ commands }) => {
|
|
52
|
+
return commands.insertContent({
|
|
53
|
+
type: this.name,
|
|
54
|
+
attrs: options,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
addInputRules() {
|
|
60
|
+
return [
|
|
61
|
+
core.nodeInputRule({
|
|
62
|
+
find: inputRegex,
|
|
63
|
+
type: this.type,
|
|
64
|
+
getAttributes: match => {
|
|
65
|
+
const [, , alt, src, title] = match;
|
|
66
|
+
return { src, alt, title };
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
exports.Image = Image;
|
|
74
|
+
exports["default"] = Image;
|
|
75
|
+
exports.inputRegex = inputRegex;
|
|
76
|
+
|
|
77
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
78
|
+
|
|
79
|
+
}));
|
|
80
|
+
//# sourceMappingURL=tiptap-extension-image.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiptap-extension-image.umd.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Node,\n nodeInputRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface ImageOptions {\n inline: boolean,\n allowBase64: boolean,\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType,\n }\n }\n}\n\nexport const inputRegex = /(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n addOptions() {\n return {\n inline: false,\n allowBase64: false,\n HTMLAttributes: {},\n }\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: this.options.allowBase64\n ? 'img[src]'\n : 'img[src]:not([src^=\"data:\"])',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]\n },\n\n addCommands() {\n return {\n setImage: options => ({ commands }) => {\n return commands.insertContent({\n type: this.name,\n attrs: options,\n })\n },\n }\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: inputRegex,\n type: this.type,\n getAttributes: match => {\n const [,, alt, src, title] = match\n\n return { src, alt, title }\n },\n }),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","nodeInputRule"],"mappings":";;;;;;QAuBa,UAAU,GAAG,mDAAkD;QAE/D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;MAC7C,IAAI,EAAE,OAAO;MAEb,UAAU;UACR,OAAO;cACL,MAAM,EAAE,KAAK;cACb,WAAW,EAAE,KAAK;cAClB,cAAc,EAAE,EAAE;WACnB,CAAA;OACF;MAED,MAAM;UACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;OAC3B;MAED,KAAK;UACH,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;OAChD;MAED,SAAS,EAAE,IAAI;MAEf,aAAa;UACX,OAAO;cACL,GAAG,EAAE;kBACH,OAAO,EAAE,IAAI;eACd;cACD,GAAG,EAAE;kBACH,OAAO,EAAE,IAAI;eACd;cACD,KAAK,EAAE;kBACL,OAAO,EAAE,IAAI;eACd;WACF,CAAA;OACF;MAED,SAAS;UACP,OAAO;cACL;kBACE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;wBACzB,UAAU;wBACV,8BAA8B;eACnC;WACF,CAAA;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE;UAC3B,OAAO,CAAC,KAAK,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;OAC7E;MAED,WAAW;UACT,OAAO;cACL,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,QAAQ,EAAE;kBAChC,OAAO,QAAQ,CAAC,aAAa,CAAC;sBAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;sBACf,KAAK,EAAE,OAAO;mBACf,CAAC,CAAA;eACH;WACF,CAAA;OACF;MAED,aAAa;UACX,OAAO;cACLC,kBAAa,CAAC;kBACZ,IAAI,EAAE,UAAU;kBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;kBACf,aAAa,EAAE,KAAK;sBAClB,MAAM,KAAI,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;sBAElC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;mBAC3B;eACF,CAAC;WACH,CAAA;OACF;GACF;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-image",
|
|
3
3
|
"description": "image extension for tiptap",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.27",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
29
29
|
"directory": "packages/extension-image"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "3462e5625235f7e598dcb4bf4fdd4dcb3e99eb06"
|
|
32
32
|
}
|
package/src/image.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
|
|
7
7
|
export interface ImageOptions {
|
|
8
8
|
inline: boolean,
|
|
9
|
+
allowBase64: boolean,
|
|
9
10
|
HTMLAttributes: Record<string, any>,
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -20,7 +21,7 @@ declare module '@tiptap/core' {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))
|
|
24
|
+
export const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/
|
|
24
25
|
|
|
25
26
|
export const Image = Node.create<ImageOptions>({
|
|
26
27
|
name: 'image',
|
|
@@ -28,6 +29,7 @@ export const Image = Node.create<ImageOptions>({
|
|
|
28
29
|
addOptions() {
|
|
29
30
|
return {
|
|
30
31
|
inline: false,
|
|
32
|
+
allowBase64: false,
|
|
31
33
|
HTMLAttributes: {},
|
|
32
34
|
}
|
|
33
35
|
},
|
|
@@ -59,7 +61,9 @@ export const Image = Node.create<ImageOptions>({
|
|
|
59
61
|
parseHTML() {
|
|
60
62
|
return [
|
|
61
63
|
{
|
|
62
|
-
tag:
|
|
64
|
+
tag: this.options.allowBase64
|
|
65
|
+
? 'img[src]'
|
|
66
|
+
: 'img[src]:not([src^="data:"])',
|
|
63
67
|
},
|
|
64
68
|
]
|
|
65
69
|
},
|