@tiptap/extension-image 2.0.0-beta.9 → 2.0.0-rc.1
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/README.md +4 -4
- package/dist/{tiptap-extension-image.cjs.js → index.cjs} +19 -10
- package/dist/index.cjs.map +1 -0
- package/dist/{tiptap-extension-image.esm.js → index.js} +19 -11
- package/dist/index.js.map +1 -0
- package/dist/{tiptap-extension-image.umd.js → index.umd.js} +22 -13
- package/dist/index.umd.js.map +1 -0
- package/dist/packages/extension-image/src/image.d.ts +5 -4
- package/package.json +22 -11
- package/src/image.ts +21 -12
- package/CHANGELOG.md +0 -182
- package/LICENSE.md +0 -21
- package/dist/tiptap-extension-image.cjs.js.map +0 -1
- package/dist/tiptap-extension-image.esm.js.map +0 -1
- package/dist/tiptap-extension-image.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
[](https://github.com/sponsors/ueberdosis)
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
|
-
|
|
8
|
+
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
|
|
9
9
|
|
|
10
|
-
##
|
|
11
|
-
Documentation can be found on the [
|
|
10
|
+
## Official Documentation
|
|
11
|
+
Documentation can be found on the [Tiptap website](https://tiptap.dev).
|
|
12
12
|
|
|
13
13
|
## License
|
|
14
|
-
|
|
14
|
+
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
|
@@ -4,12 +4,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@tiptap/core');
|
|
6
6
|
|
|
7
|
-
const inputRegex =
|
|
7
|
+
const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
8
8
|
const Image = core.Node.create({
|
|
9
9
|
name: 'image',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
addOptions() {
|
|
11
|
+
return {
|
|
12
|
+
inline: false,
|
|
13
|
+
allowBase64: false,
|
|
14
|
+
HTMLAttributes: {},
|
|
15
|
+
};
|
|
13
16
|
},
|
|
14
17
|
inline() {
|
|
15
18
|
return this.options.inline;
|
|
@@ -34,7 +37,9 @@ const Image = core.Node.create({
|
|
|
34
37
|
parseHTML() {
|
|
35
38
|
return [
|
|
36
39
|
{
|
|
37
|
-
tag:
|
|
40
|
+
tag: this.options.allowBase64
|
|
41
|
+
? 'img[src]'
|
|
42
|
+
: 'img[src]:not([src^="data:"])',
|
|
38
43
|
},
|
|
39
44
|
];
|
|
40
45
|
},
|
|
@@ -53,15 +58,19 @@ const Image = core.Node.create({
|
|
|
53
58
|
},
|
|
54
59
|
addInputRules() {
|
|
55
60
|
return [
|
|
56
|
-
core.nodeInputRule(
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
},
|
|
59
68
|
}),
|
|
60
69
|
];
|
|
61
70
|
},
|
|
62
71
|
});
|
|
63
72
|
|
|
64
73
|
exports.Image = Image;
|
|
65
|
-
exports
|
|
74
|
+
exports["default"] = Image;
|
|
66
75
|
exports.inputRegex = inputRegex;
|
|
67
|
-
//# sourceMappingURL=
|
|
76
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/image.ts"],"sourcesContent":["import {\n mergeAttributes,\n Node,\n nodeInputRule,\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+)[\"'](\\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":";;;;;;AAuBO,MAAM,UAAU,GAAG,2DAA0D;AAEvE,MAAA,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;AAC7C,IAAA,IAAI,EAAE,OAAO;IAEb,UAAU,GAAA;QACR,OAAO;AACL,YAAA,MAAM,EAAE,KAAK;AACb,YAAA,WAAW,EAAE,KAAK;AAClB,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,MAAM,GAAA;AACJ,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;KAC3B;IAED,KAAK,GAAA;AACH,QAAA,OAAO,IAAI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;;"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
|
|
2
2
|
|
|
3
|
-
const inputRegex =
|
|
3
|
+
const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
4
4
|
const Image = Node.create({
|
|
5
5
|
name: 'image',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
inline: false,
|
|
9
|
+
allowBase64: false,
|
|
10
|
+
HTMLAttributes: {},
|
|
11
|
+
};
|
|
9
12
|
},
|
|
10
13
|
inline() {
|
|
11
14
|
return this.options.inline;
|
|
@@ -30,7 +33,9 @@ const Image = Node.create({
|
|
|
30
33
|
parseHTML() {
|
|
31
34
|
return [
|
|
32
35
|
{
|
|
33
|
-
tag:
|
|
36
|
+
tag: this.options.allowBase64
|
|
37
|
+
? 'img[src]'
|
|
38
|
+
: 'img[src]:not([src^="data:"])',
|
|
34
39
|
},
|
|
35
40
|
];
|
|
36
41
|
},
|
|
@@ -49,14 +54,17 @@ const Image = Node.create({
|
|
|
49
54
|
},
|
|
50
55
|
addInputRules() {
|
|
51
56
|
return [
|
|
52
|
-
nodeInputRule(
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
nodeInputRule({
|
|
58
|
+
find: inputRegex,
|
|
59
|
+
type: this.type,
|
|
60
|
+
getAttributes: match => {
|
|
61
|
+
const [, , alt, src, title] = match;
|
|
62
|
+
return { src, alt, title };
|
|
63
|
+
},
|
|
55
64
|
}),
|
|
56
65
|
];
|
|
57
66
|
},
|
|
58
67
|
});
|
|
59
68
|
|
|
60
|
-
export default
|
|
61
|
-
|
|
62
|
-
//# sourceMappingURL=tiptap-extension-image.esm.js.map
|
|
69
|
+
export { Image, Image as default, inputRegex };
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/image.ts"],"sourcesContent":["import {\n mergeAttributes,\n Node,\n nodeInputRule,\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+)[\"'](\\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":";;AAuBO,MAAM,UAAU,GAAG,2DAA0D;AAEvE,MAAA,KAAK,GAAG,IAAI,CAAC,MAAM,CAAe;AAC7C,IAAA,IAAI,EAAE,OAAO;IAEb,UAAU,GAAA;QACR,OAAO;AACL,YAAA,MAAM,EAAE,KAAK;AACb,YAAA,WAAW,EAAE,KAAK;AAClB,YAAA,cAAc,EAAE,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GAAG,KAAK,CAAA;AAElC,oBAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;iBAC3B;aACF,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global[
|
|
5
|
-
}(this, (function (exports, core) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-image"] = {}, global.core));
|
|
5
|
+
})(this, (function (exports, core) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const inputRegex =
|
|
7
|
+
const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
|
|
8
8
|
const Image = core.Node.create({
|
|
9
9
|
name: 'image',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
addOptions() {
|
|
11
|
+
return {
|
|
12
|
+
inline: false,
|
|
13
|
+
allowBase64: false,
|
|
14
|
+
HTMLAttributes: {},
|
|
15
|
+
};
|
|
13
16
|
},
|
|
14
17
|
inline() {
|
|
15
18
|
return this.options.inline;
|
|
@@ -34,7 +37,9 @@
|
|
|
34
37
|
parseHTML() {
|
|
35
38
|
return [
|
|
36
39
|
{
|
|
37
|
-
tag:
|
|
40
|
+
tag: this.options.allowBase64
|
|
41
|
+
? 'img[src]'
|
|
42
|
+
: 'img[src]:not([src^="data:"])',
|
|
38
43
|
},
|
|
39
44
|
];
|
|
40
45
|
},
|
|
@@ -53,19 +58,23 @@
|
|
|
53
58
|
},
|
|
54
59
|
addInputRules() {
|
|
55
60
|
return [
|
|
56
|
-
core.nodeInputRule(
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
},
|
|
59
68
|
}),
|
|
60
69
|
];
|
|
61
70
|
},
|
|
62
71
|
});
|
|
63
72
|
|
|
64
73
|
exports.Image = Image;
|
|
65
|
-
exports
|
|
74
|
+
exports["default"] = Image;
|
|
66
75
|
exports.inputRegex = inputRegex;
|
|
67
76
|
|
|
68
77
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
69
78
|
|
|
70
|
-
}))
|
|
71
|
-
//# sourceMappingURL=
|
|
79
|
+
}));
|
|
80
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/image.ts"],"sourcesContent":["import {\n mergeAttributes,\n Node,\n nodeInputRule,\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+)[\"'](\\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":";;;;;;AAuBO,QAAM,UAAU,GAAG,2DAA0D;AAEvE,QAAA,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;EAC7C,IAAA,IAAI,EAAE,OAAO;MAEb,UAAU,GAAA;UACR,OAAO;EACL,YAAA,MAAM,EAAE,KAAK;EACb,YAAA,WAAW,EAAE,KAAK;EAClB,YAAA,cAAc,EAAE,EAAE;WACnB,CAAA;OACF;MAED,MAAM,GAAA;EACJ,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;OAC3B;MAED,KAAK,GAAA;EACH,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;OAChD;EAED,IAAA,SAAS,EAAE,IAAI;MAEf,aAAa,GAAA;UACX,OAAO;EACL,YAAA,GAAG,EAAE;EACH,gBAAA,OAAO,EAAE,IAAI;EACd,aAAA;EACD,YAAA,GAAG,EAAE;EACH,gBAAA,OAAO,EAAE,IAAI;EACd,aAAA;EACD,YAAA,KAAK,EAAE;EACL,gBAAA,OAAO,EAAE,IAAI;EACd,aAAA;WACF,CAAA;OACF;MAED,SAAS,GAAA;UACP,OAAO;EACL,YAAA;EACE,gBAAA,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;EAC3B,sBAAE,UAAU;EACZ,sBAAE,8BAA8B;EACnC,aAAA;WACF,CAAA;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;EAC3B,QAAA,OAAO,CAAC,KAAK,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;OAC7E;MAED,WAAW,GAAA;UACT,OAAO;cACL,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;kBACpC,OAAO,QAAQ,CAAC,aAAa,CAAC;sBAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;EACf,oBAAA,KAAK,EAAE,OAAO;EACf,iBAAA,CAAC,CAAA;eACH;WACF,CAAA;OACF;MAED,aAAa,GAAA;UACX,OAAO;EACL,YAAAC,kBAAa,CAAC;EACZ,gBAAA,IAAI,EAAE,UAAU;kBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;kBACf,aAAa,EAAE,KAAK,IAAG;sBACrB,MAAM,KAAI,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;EAElC,oBAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;mBAC3B;eACF,CAAC;WACH,CAAA;OACF;EACF,CAAA;;;;;;;;;;;;"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
2
|
export interface ImageOptions {
|
|
3
3
|
inline: boolean;
|
|
4
|
+
allowBase64: boolean;
|
|
4
5
|
HTMLAttributes: Record<string, any>;
|
|
5
6
|
}
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
|
-
interface Commands {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
8
9
|
image: {
|
|
9
10
|
/**
|
|
10
11
|
* Add an image
|
|
@@ -13,9 +14,9 @@ declare module '@tiptap/core' {
|
|
|
13
14
|
src: string;
|
|
14
15
|
alt?: string;
|
|
15
16
|
title?: string;
|
|
16
|
-
}) =>
|
|
17
|
+
}) => ReturnType;
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
export declare const inputRegex: RegExp;
|
|
21
|
-
export declare const Image: Node<ImageOptions>;
|
|
22
|
+
export declare const Image: Node<ImageOptions, any>;
|
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-
|
|
4
|
+
"version": "2.0.0-rc.1",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -12,24 +12,35 @@
|
|
|
12
12
|
"type": "github",
|
|
13
13
|
"url": "https://github.com/sponsors/ueberdosis"
|
|
14
14
|
},
|
|
15
|
-
"main": "dist/tiptap-extension-image.cjs.js",
|
|
16
|
-
"umd": "dist/tiptap-extension-image.umd.js",
|
|
17
|
-
"module": "dist/tiptap-extension-image.esm.js",
|
|
18
|
-
"types": "dist/packages/extension-image/src/index.d.ts",
|
|
19
15
|
"type": "module",
|
|
20
16
|
"exports": {
|
|
21
17
|
".": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
18
|
+
"types": "./dist/packages/extension-image/src/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
25
21
|
}
|
|
26
22
|
},
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"umd": "dist/index.umd.js",
|
|
26
|
+
"types": "dist/packages/extension-image/src/index.d.ts",
|
|
27
27
|
"files": [
|
|
28
28
|
"src",
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@tiptap/core": "
|
|
32
|
+
"@tiptap/core": "2.0.0-rc.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tiptap/core": "2.0.0-rc.1"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
40
|
+
"directory": "packages/extension-image"
|
|
33
41
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "rm -rf dist",
|
|
44
|
+
"build": "npm run clean && rollup -c"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/image.ts
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
mergeAttributes,
|
|
3
3
|
Node,
|
|
4
4
|
nodeInputRule,
|
|
5
|
-
mergeAttributes,
|
|
6
5
|
} from '@tiptap/core'
|
|
7
6
|
|
|
8
7
|
export interface ImageOptions {
|
|
9
8
|
inline: boolean,
|
|
9
|
+
allowBase64: boolean,
|
|
10
10
|
HTMLAttributes: Record<string, any>,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
declare module '@tiptap/core' {
|
|
14
|
-
interface Commands {
|
|
14
|
+
interface Commands<ReturnType> {
|
|
15
15
|
image: {
|
|
16
16
|
/**
|
|
17
17
|
* Add an image
|
|
18
18
|
*/
|
|
19
|
-
setImage: (options: { src: string, alt?: string, title?: string }) =>
|
|
19
|
+
setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType,
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const inputRegex =
|
|
24
|
+
export const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/
|
|
25
25
|
|
|
26
26
|
export const Image = Node.create<ImageOptions>({
|
|
27
27
|
name: 'image',
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
addOptions() {
|
|
30
|
+
return {
|
|
31
|
+
inline: false,
|
|
32
|
+
allowBase64: false,
|
|
33
|
+
HTMLAttributes: {},
|
|
34
|
+
}
|
|
32
35
|
},
|
|
33
36
|
|
|
34
37
|
inline() {
|
|
@@ -58,7 +61,9 @@ export const Image = Node.create<ImageOptions>({
|
|
|
58
61
|
parseHTML() {
|
|
59
62
|
return [
|
|
60
63
|
{
|
|
61
|
-
tag:
|
|
64
|
+
tag: this.options.allowBase64
|
|
65
|
+
? 'img[src]'
|
|
66
|
+
: 'img[src]:not([src^="data:"])',
|
|
62
67
|
},
|
|
63
68
|
]
|
|
64
69
|
},
|
|
@@ -80,10 +85,14 @@ export const Image = Node.create<ImageOptions>({
|
|
|
80
85
|
|
|
81
86
|
addInputRules() {
|
|
82
87
|
return [
|
|
83
|
-
nodeInputRule(
|
|
84
|
-
|
|
88
|
+
nodeInputRule({
|
|
89
|
+
find: inputRegex,
|
|
90
|
+
type: this.type,
|
|
91
|
+
getAttributes: match => {
|
|
92
|
+
const [,, alt, src, title] = match
|
|
85
93
|
|
|
86
|
-
|
|
94
|
+
return { src, alt, title }
|
|
95
|
+
},
|
|
87
96
|
}),
|
|
88
97
|
]
|
|
89
98
|
},
|
package/CHANGELOG.md
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [2.0.0-beta.9](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.8...@tiptap/extension-image@2.0.0-beta.9) (2021-05-06)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* add exports to package.json ([1277fa4](https://github.com/ueberdosis/tiptap/commit/1277fa47151e9c039508cdb219bdd0ffe647f4ee))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# [2.0.0-beta.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.7...@tiptap/extension-image@2.0.0-beta.8) (2021-05-06)
|
|
18
|
-
|
|
19
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# [2.0.0-beta.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.6...@tiptap/extension-image@2.0.0-beta.7) (2021-05-05)
|
|
26
|
-
|
|
27
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# [2.0.0-beta.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.5...@tiptap/extension-image@2.0.0-beta.6) (2021-04-23)
|
|
34
|
-
|
|
35
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# [2.0.0-beta.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.4...@tiptap/extension-image@2.0.0-beta.5) (2021-04-22)
|
|
42
|
-
|
|
43
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.3...@tiptap/extension-image@2.0.0-beta.4) (2021-04-21)
|
|
50
|
-
|
|
51
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.2...@tiptap/extension-image@2.0.0-beta.3) (2021-04-16)
|
|
58
|
-
|
|
59
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# [2.0.0-beta.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-beta.1...@tiptap/extension-image@2.0.0-beta.2) (2021-04-15)
|
|
66
|
-
|
|
67
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
# [2.0.0-beta.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.11...@tiptap/extension-image@2.0.0-beta.1) (2021-03-05)
|
|
74
|
-
|
|
75
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
# [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.10...@tiptap/extension-image@2.0.0-alpha.11) (2021-02-16)
|
|
82
|
-
|
|
83
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
# [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.9...@tiptap/extension-image@2.0.0-alpha.10) (2021-02-07)
|
|
90
|
-
|
|
91
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
# [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.8...@tiptap/extension-image@2.0.0-alpha.9) (2021-02-05)
|
|
98
|
-
|
|
99
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
# [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.7...@tiptap/extension-image@2.0.0-alpha.8) (2021-01-29)
|
|
106
|
-
|
|
107
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
# [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.6...@tiptap/extension-image@2.0.0-alpha.7) (2021-01-29)
|
|
114
|
-
|
|
115
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
# [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.5...@tiptap/extension-image@2.0.0-alpha.6) (2021-01-28)
|
|
122
|
-
|
|
123
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.4...@tiptap/extension-image@2.0.0-alpha.5) (2020-12-18)
|
|
130
|
-
|
|
131
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.3...@tiptap/extension-image@2.0.0-alpha.4) (2020-12-02)
|
|
138
|
-
|
|
139
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
# [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.2...@tiptap/extension-image@2.0.0-alpha.3) (2020-11-19)
|
|
146
|
-
|
|
147
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
# [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@2.0.0-alpha.1...@tiptap/extension-image@2.0.0-alpha.2) (2020-11-19)
|
|
154
|
-
|
|
155
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
# [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@1.0.0-alpha.2...@tiptap/extension-image@2.0.0-alpha.1) (2020-11-18)
|
|
162
|
-
|
|
163
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
# [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-image@1.0.0-alpha.1...@tiptap/extension-image@1.0.0-alpha.2) (2020-11-16)
|
|
170
|
-
|
|
171
|
-
**Note:** Version bump only for package @tiptap/extension-image
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
# 1.0.0-alpha.1 (2020-11-16)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
### Reverts
|
|
181
|
-
|
|
182
|
-
* Revert "use global namespace" ([0c9ce26](https://github.com/ueberdosis/tiptap/commit/0c9ce26c02c07d88a757c01b0a9d7f9e2b0b7502))
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-image.cjs.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Command,\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 {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => Command,\n }\n }\n}\n\nexport const inputRegex = /!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\)/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n defaultOptions: {\n inline: false,\n HTMLAttributes: {},\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(inputRegex, this.type, match => {\n const [, alt, src, title] = match\n\n return { src, alt, title }\n }),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","nodeInputRule"],"mappings":";;;;;;MAuBa,UAAU,GAAG,gDAA+C;MAE5D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,EAAE;KACnB;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,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;gBACxC,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;gBAEjC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-image.esm.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Command,\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 {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => Command,\n }\n }\n}\n\nexport const inputRegex = /!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\)/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n defaultOptions: {\n inline: false,\n HTMLAttributes: {},\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(inputRegex, this.type, match => {\n const [, alt, src, title] = match\n\n return { src, alt, title }\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;MAuBa,UAAU,GAAG,gDAA+C;MAE5D,KAAK,GAAG,IAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,EAAE;KACnB;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,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;gBACxC,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;gBAEjC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extension-image.umd.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Command,\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 {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => Command,\n }\n }\n}\n\nexport const inputRegex = /!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\)/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n defaultOptions: {\n inline: false,\n HTMLAttributes: {},\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(inputRegex, this.type, match => {\n const [, alt, src, title] = match\n\n return { src, alt, title }\n }),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","nodeInputRule"],"mappings":";;;;;;QAuBa,UAAU,GAAG,gDAA+C;QAE5D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;MAC7C,IAAI,EAAE,OAAO;MAEb,cAAc,EAAE;UACd,MAAM,EAAE,KAAK;UACb,cAAc,EAAE,EAAE;OACnB;MAED,MAAM;U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