@tiptap/extension-image 2.0.0-beta.21 → 2.0.0-beta.211
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 +77 -0
- package/dist/{packages/extension-image/src/image.d.ts → index.d.ts} +25 -21
- package/dist/index.js +77 -0
- package/package.json +30 -7
- package/src/image.ts +7 -3
- package/LICENSE.md +0 -21
- package/dist/packages/extension-image/src/index.d.ts +0 -3
- package/dist/tiptap-extension-image.cjs.js +0 -73
- package/dist/tiptap-extension-image.cjs.js.map +0 -1
- package/dist/tiptap-extension-image.esm.js +0 -67
- package/dist/tiptap-extension-image.esm.js.map +0 -1
- package/dist/tiptap-extension-image.umd.js +0 -77
- package/dist/tiptap-extension-image.umd.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/image.ts
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _core = require('@tiptap/core');
|
|
7
|
+
var inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
8
|
+
var 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 ? "img[src]" : 'img[src]:not([src^="data:"])'
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
},
|
|
44
|
+
renderHTML({ HTMLAttributes }) {
|
|
45
|
+
return ["img", _core.mergeAttributes.call(void 0, this.options.HTMLAttributes, HTMLAttributes)];
|
|
46
|
+
},
|
|
47
|
+
addCommands() {
|
|
48
|
+
return {
|
|
49
|
+
setImage: (options) => ({ commands }) => {
|
|
50
|
+
return commands.insertContent({
|
|
51
|
+
type: this.name,
|
|
52
|
+
attrs: options
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
addInputRules() {
|
|
58
|
+
return [
|
|
59
|
+
_core.nodeInputRule.call(void 0, {
|
|
60
|
+
find: inputRegex,
|
|
61
|
+
type: this.type,
|
|
62
|
+
getAttributes: (match) => {
|
|
63
|
+
const [, , alt, src, title] = match;
|
|
64
|
+
return { src, alt, title };
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// src/index.ts
|
|
72
|
+
var src_default = Image;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
exports.Image = Image; exports.default = src_default; exports.inputRegex = inputRegex;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface ImageOptions {
|
|
4
|
+
inline: boolean;
|
|
5
|
+
allowBase64: boolean;
|
|
6
|
+
HTMLAttributes: Record<string, any>;
|
|
7
|
+
}
|
|
8
|
+
declare module '@tiptap/core' {
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
image: {
|
|
11
|
+
/**
|
|
12
|
+
* Add an image
|
|
13
|
+
*/
|
|
14
|
+
setImage: (options: {
|
|
15
|
+
src: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
}) => ReturnType;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
declare const inputRegex: RegExp;
|
|
23
|
+
declare const Image: Node<ImageOptions, any>;
|
|
24
|
+
|
|
25
|
+
export { Image, ImageOptions, Image as default, inputRegex };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/image.ts
|
|
2
|
+
import {
|
|
3
|
+
mergeAttributes,
|
|
4
|
+
Node,
|
|
5
|
+
nodeInputRule
|
|
6
|
+
} from "@tiptap/core";
|
|
7
|
+
var inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
8
|
+
var Image = 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 ? "img[src]" : 'img[src]:not([src^="data:"])'
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
},
|
|
44
|
+
renderHTML({ HTMLAttributes }) {
|
|
45
|
+
return ["img", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
46
|
+
},
|
|
47
|
+
addCommands() {
|
|
48
|
+
return {
|
|
49
|
+
setImage: (options) => ({ commands }) => {
|
|
50
|
+
return commands.insertContent({
|
|
51
|
+
type: this.name,
|
|
52
|
+
attrs: options
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
addInputRules() {
|
|
58
|
+
return [
|
|
59
|
+
nodeInputRule({
|
|
60
|
+
find: inputRegex,
|
|
61
|
+
type: this.type,
|
|
62
|
+
getAttributes: (match) => {
|
|
63
|
+
const [, , alt, src, title] = match;
|
|
64
|
+
return { src, alt, title };
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// src/index.ts
|
|
72
|
+
var src_default = Image;
|
|
73
|
+
export {
|
|
74
|
+
Image,
|
|
75
|
+
src_default as default,
|
|
76
|
+
inputRegex
|
|
77
|
+
};
|
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.211",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -12,21 +12,44 @@
|
|
|
12
12
|
"type": "github",
|
|
13
13
|
"url": "https://github.com/sponsors/ueberdosis"
|
|
14
14
|
},
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
19
26
|
"files": [
|
|
20
27
|
"src",
|
|
21
28
|
"dist"
|
|
22
29
|
],
|
|
23
30
|
"peerDependencies": {
|
|
24
|
-
"@tiptap/core": "^2.0.0-beta.
|
|
31
|
+
"@tiptap/core": "^2.0.0-beta.209"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@tiptap/core": "^2.0.0-beta.211"
|
|
25
35
|
},
|
|
26
36
|
"repository": {
|
|
27
37
|
"type": "git",
|
|
28
38
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
29
39
|
"directory": "packages/extension-image"
|
|
30
40
|
},
|
|
31
|
-
"
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup"
|
|
43
|
+
},
|
|
44
|
+
"tsup": {
|
|
45
|
+
"entry": [
|
|
46
|
+
"src/index.ts"
|
|
47
|
+
],
|
|
48
|
+
"dts": true,
|
|
49
|
+
"splitting": true,
|
|
50
|
+
"format": [
|
|
51
|
+
"esm",
|
|
52
|
+
"cjs"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
32
55
|
}
|
package/src/image.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
mergeAttributes,
|
|
2
3
|
Node,
|
|
3
4
|
nodeInputRule,
|
|
4
|
-
mergeAttributes,
|
|
5
5
|
} from '@tiptap/core'
|
|
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+)["'](\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
|
},
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021, überdosis GbR
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
HTMLAttributes: {},
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
inline() {
|
|
17
|
-
return this.options.inline;
|
|
18
|
-
},
|
|
19
|
-
group() {
|
|
20
|
-
return this.options.inline ? 'inline' : 'block';
|
|
21
|
-
},
|
|
22
|
-
draggable: true,
|
|
23
|
-
addAttributes() {
|
|
24
|
-
return {
|
|
25
|
-
src: {
|
|
26
|
-
default: null,
|
|
27
|
-
},
|
|
28
|
-
alt: {
|
|
29
|
-
default: null,
|
|
30
|
-
},
|
|
31
|
-
title: {
|
|
32
|
-
default: null,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
parseHTML() {
|
|
37
|
-
return [
|
|
38
|
-
{
|
|
39
|
-
tag: 'img[src]',
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
},
|
|
43
|
-
renderHTML({ HTMLAttributes }) {
|
|
44
|
-
return ['img', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
45
|
-
},
|
|
46
|
-
addCommands() {
|
|
47
|
-
return {
|
|
48
|
-
setImage: options => ({ commands }) => {
|
|
49
|
-
return commands.insertContent({
|
|
50
|
-
type: this.name,
|
|
51
|
-
attrs: options,
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
addInputRules() {
|
|
57
|
-
return [
|
|
58
|
-
core.nodeInputRule({
|
|
59
|
-
find: inputRegex,
|
|
60
|
-
type: this.type,
|
|
61
|
-
getAttributes: match => {
|
|
62
|
-
const [, , alt, src, title] = match;
|
|
63
|
-
return { src, alt, title };
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
];
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
exports.Image = Image;
|
|
71
|
-
exports["default"] = Image;
|
|
72
|
-
exports.inputRegex = inputRegex;
|
|
73
|
-
//# sourceMappingURL=tiptap-extension-image.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 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 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: 'img[src]',\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":";;;;;;MAsBa,UAAU,GAAG,kDAAiD;MAE9D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,UAAU;QACR,OAAO;YACL,MAAM,EAAE,KAAK;YACb,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,UAAU;aAChB;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;;;;;;"}
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
HTMLAttributes: {},
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
inline() {
|
|
13
|
-
return this.options.inline;
|
|
14
|
-
},
|
|
15
|
-
group() {
|
|
16
|
-
return this.options.inline ? 'inline' : 'block';
|
|
17
|
-
},
|
|
18
|
-
draggable: true,
|
|
19
|
-
addAttributes() {
|
|
20
|
-
return {
|
|
21
|
-
src: {
|
|
22
|
-
default: null,
|
|
23
|
-
},
|
|
24
|
-
alt: {
|
|
25
|
-
default: null,
|
|
26
|
-
},
|
|
27
|
-
title: {
|
|
28
|
-
default: null,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
parseHTML() {
|
|
33
|
-
return [
|
|
34
|
-
{
|
|
35
|
-
tag: 'img[src]',
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
|
-
},
|
|
39
|
-
renderHTML({ HTMLAttributes }) {
|
|
40
|
-
return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
41
|
-
},
|
|
42
|
-
addCommands() {
|
|
43
|
-
return {
|
|
44
|
-
setImage: options => ({ commands }) => {
|
|
45
|
-
return commands.insertContent({
|
|
46
|
-
type: this.name,
|
|
47
|
-
attrs: options,
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
addInputRules() {
|
|
53
|
-
return [
|
|
54
|
-
nodeInputRule({
|
|
55
|
-
find: inputRegex,
|
|
56
|
-
type: this.type,
|
|
57
|
-
getAttributes: match => {
|
|
58
|
-
const [, , alt, src, title] = match;
|
|
59
|
-
return { src, alt, title };
|
|
60
|
-
},
|
|
61
|
-
}),
|
|
62
|
-
];
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export { Image, Image as default, inputRegex };
|
|
67
|
-
//# sourceMappingURL=tiptap-extension-image.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 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 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: 'img[src]',\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":";;MAsBa,UAAU,GAAG,kDAAiD;MAE9D,KAAK,GAAG,IAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,UAAU;QACR,OAAO;YACL,MAAM,EAAE,KAAK;YACb,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,UAAU;aAChB;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;;;;"}
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
HTMLAttributes: {},
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
inline() {
|
|
17
|
-
return this.options.inline;
|
|
18
|
-
},
|
|
19
|
-
group() {
|
|
20
|
-
return this.options.inline ? 'inline' : 'block';
|
|
21
|
-
},
|
|
22
|
-
draggable: true,
|
|
23
|
-
addAttributes() {
|
|
24
|
-
return {
|
|
25
|
-
src: {
|
|
26
|
-
default: null,
|
|
27
|
-
},
|
|
28
|
-
alt: {
|
|
29
|
-
default: null,
|
|
30
|
-
},
|
|
31
|
-
title: {
|
|
32
|
-
default: null,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
parseHTML() {
|
|
37
|
-
return [
|
|
38
|
-
{
|
|
39
|
-
tag: 'img[src]',
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
},
|
|
43
|
-
renderHTML({ HTMLAttributes }) {
|
|
44
|
-
return ['img', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
45
|
-
},
|
|
46
|
-
addCommands() {
|
|
47
|
-
return {
|
|
48
|
-
setImage: options => ({ commands }) => {
|
|
49
|
-
return commands.insertContent({
|
|
50
|
-
type: this.name,
|
|
51
|
-
attrs: options,
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
addInputRules() {
|
|
57
|
-
return [
|
|
58
|
-
core.nodeInputRule({
|
|
59
|
-
find: inputRegex,
|
|
60
|
-
type: this.type,
|
|
61
|
-
getAttributes: match => {
|
|
62
|
-
const [, , alt, src, title] = match;
|
|
63
|
-
return { src, alt, title };
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
];
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
exports.Image = Image;
|
|
71
|
-
exports["default"] = Image;
|
|
72
|
-
exports.inputRegex = inputRegex;
|
|
73
|
-
|
|
74
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
75
|
-
|
|
76
|
-
}));
|
|
77
|
-
//# sourceMappingURL=tiptap-extension-image.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 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 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: 'img[src]',\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":";;;;;;QAsBa,UAAU,GAAG,kDAAiD;QAE9D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;MAC7C,IAAI,EAAE,OAAO;MAEb,UAAU;UACR,OAAO;cACL,MAAM,EAAE,KAAK;cACb,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,UAAU;eAChB;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;;;;;;;;;;;;"}
|