@edifice.io/tiptap-extensions 2.0.0-develop-rc.14 → 2.0.0-develop-rc.15
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 +8 -5
- package/dist/abbr/abbr.cjs +1 -32
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.d.ts +13 -13
- package/dist/abbr/abbr.js +13 -17
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/alert/alert.cjs +1 -32
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +22 -20
- package/dist/alert/alert.js.map +1 -1
- package/dist/attachment/attachment-transformer.cjs +2 -0
- package/dist/attachment/attachment-transformer.cjs.map +1 -0
- package/dist/attachment/attachment-transformer.d.ts +12 -0
- package/dist/attachment/attachment-transformer.js +76 -0
- package/dist/attachment/attachment-transformer.js.map +1 -0
- package/dist/attachment/attachment.cjs +1 -73
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.d.ts +7 -7
- package/dist/attachment/attachment.js +29 -40
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/attachment/index.d.ts +1 -0
- package/dist/audio/audio.cjs +2 -52
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.d.ts +14 -18
- package/dist/audio/audio.js +25 -28
- package/dist/audio/audio.js.map +1 -1
- package/dist/font-size/font-size.cjs +1 -48
- package/dist/font-size/font-size.cjs.map +1 -1
- package/dist/font-size/font-size.d.ts +14 -14
- package/dist/font-size/font-size.js +17 -29
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/heading/heading.cjs +1 -61
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.d.ts +13 -11
- package/dist/heading/heading.js +25 -39
- package/dist/heading/heading.js.map +1 -1
- package/dist/highlight/highlight.cjs +1 -25
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.d.ts +1 -4
- package/dist/highlight/highlight.js +13 -11
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/hyperlink/hyperlink.cjs +1 -47
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.d.ts +25 -28
- package/dist/hyperlink/hyperlink.js +19 -21
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/iframe/iframe.cjs +1 -69
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.d.ts +15 -13
- package/dist/iframe/iframe.js +32 -48
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/image/image.cjs +2 -0
- package/dist/image/image.cjs.map +1 -0
- package/dist/image/image.d.ts +26 -0
- package/dist/image/image.js +178 -0
- package/dist/image/image.js.map +1 -0
- package/dist/image/index.d.ts +3 -3
- package/dist/index.cjs +1 -43
- package/dist/index.js +24 -22
- package/dist/index.js.map +1 -1
- package/dist/line-height/line-height.cjs +1 -33
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +15 -18
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/linker/linker.cjs +1 -95
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.d.ts +18 -18
- package/dist/linker/linker.js +49 -57
- package/dist/linker/linker.js.map +1 -1
- package/dist/mathjax/mathjax.cjs +1 -47
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +20 -30
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/paragraph/paragraph.cjs +1 -13
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.d.ts +1 -4
- package/dist/paragraph/paragraph.js +8 -6
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/speech-recognition/speech-recognition.cjs +1 -76
- package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
- package/dist/speech-recognition/speech-recognition.d.ts +13 -13
- package/dist/speech-recognition/speech-recognition.js +36 -57
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +1 -32
- package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.d.ts +10 -10
- package/dist/speech-synthesis/speech-synthesis.js +10 -19
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +1 -27
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.d.ts +1 -4
- package/dist/table-cell/table-cell.js +12 -17
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs +1 -4
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.d.ts +1 -4
- package/dist/transform/html-to-json/html-to-json.js +4 -2
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +1 -4
- package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
- package/dist/transform/json-to-html/json-to-html.js +4 -2
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +2 -111
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +20 -29
- package/dist/video/video.js +90 -114
- package/dist/video/video.js.map +1 -1
- package/package.json +23 -15
- package/dist/image/custom-image.cjs +0 -163
- package/dist/image/custom-image.cjs.map +0 -1
- package/dist/image/custom-image.d.ts +0 -27
- package/dist/image/custom-image.js +0 -181
- package/dist/image/custom-image.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
Extensions based on Tiptap Editor
|
|
6
|
+
Extensions based on [Tiptap Editor](https://tiptap.dev/). Extends functionalities of the editor.
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
- `pnpm: >= 9`
|
|
11
|
+
- `node: >= 20`
|
|
7
12
|
|
|
8
13
|
## Getting Started
|
|
9
14
|
|
|
@@ -47,9 +52,8 @@ my-extension
|
|
|
47
52
|
└── index.ts
|
|
48
53
|
```
|
|
49
54
|
|
|
50
|
-
- Check one existing extension or refer to
|
|
51
|
-
|
|
52
|
-
- Then, add your extension in the `package.json` sub-exports in alphabetical order
|
|
55
|
+
- Check one existing extension or refer to the official [documentation](https://tiptap.dev/docs/editor/extensions/custom-extensions) to develop an extension.
|
|
56
|
+
- Then, add your extension in the `package.json` sub-exports in alphabetical order.
|
|
53
57
|
|
|
54
58
|
```
|
|
55
59
|
"./my-extension": {
|
|
@@ -59,5 +63,4 @@ my-extension
|
|
|
59
63
|
```
|
|
60
64
|
|
|
61
65
|
- Run `pnpm run build` to generate a bundle
|
|
62
|
-
|
|
63
66
|
- Test your extension before committing and pushing to remote
|
package/dist/abbr/abbr.cjs
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core'),
|
|
4
|
-
Abbr = core.Mark.create({
|
|
5
|
-
name: 'abbr',
|
|
6
|
-
addOptions() {
|
|
7
|
-
return { HTMLAttributes: {} };
|
|
8
|
-
},
|
|
9
|
-
parseHTML() {
|
|
10
|
-
return [{ tag: 'abbr' }];
|
|
11
|
-
},
|
|
12
|
-
renderHTML({ HTMLAttributes }) {
|
|
13
|
-
return [
|
|
14
|
-
'abbr',
|
|
15
|
-
core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
16
|
-
0,
|
|
17
|
-
];
|
|
18
|
-
},
|
|
19
|
-
addCommands() {
|
|
20
|
-
return {
|
|
21
|
-
setAbbr:
|
|
22
|
-
() =>
|
|
23
|
-
({ commands }) =>
|
|
24
|
-
commands.setMark(this.name),
|
|
25
|
-
toggleAbbr:
|
|
26
|
-
() =>
|
|
27
|
-
({ commands }) =>
|
|
28
|
-
commands.toggleMark(this.name),
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
exports.Abbr = Abbr;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),Abbr=core.Mark.create({name:"abbr",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"abbr"}]},renderHTML({HTMLAttributes}){return["abbr",core.mergeAttributes(this.options.HTMLAttributes,HTMLAttributes),0]},addCommands(){return{setAbbr:()=>({commands})=>commands.setMark(this.name),toggleAbbr:()=>({commands})=>commands.toggleMark(this.name)}}});exports.Abbr=Abbr;
|
|
33
2
|
//# sourceMappingURL=abbr.cjs.map
|
package/dist/abbr/abbr.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abbr.cjs","sources":["../../src/abbr/abbr.ts"],"sourcesContent":["import { Mark, mergeAttributes } from
|
|
1
|
+
{"version":3,"file":"abbr.cjs","sources":["../../src/abbr/abbr.ts"],"sourcesContent":["import { Mark, mergeAttributes } from \"@tiptap/core\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n abbr: {\n /**\n * Set an abbr mark\n */\n setAbbr: (src: string) => ReturnType;\n /**\n * Toggle an abbr mark\n */\n toggleAbbr: (src: string) => ReturnType;\n };\n }\n}\n\nexport const Abbr = Mark.create({\n name: \"abbr\",\n\n addOptions() {\n return {\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"abbr\",\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"abbr\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setAbbr:\n () =>\n ({ commands }) => {\n return commands.setMark(this.name);\n },\n toggleAbbr:\n () =>\n ({ commands }) => {\n return commands.toggleMark(this.name);\n },\n };\n },\n});\n"],"names":["Mark","mergeAttributes"],"mappings":"mHAiBa,KAAOA,UAAK,OAAO,CAC9B,KAAM,OAEN,YAAa,CACJ,MAAA,CACL,eAAgB,CAAA,CAClB,CACF,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,MAAA,CAET,CACF,EAEA,WAAW,CAAE,gBAAkB,CACtB,MAAA,CACL,OACAC,KAAAA,gBAAgB,KAAK,QAAQ,eAAgB,cAAc,EAC3D,CACF,CACF,EAEA,aAAc,CACL,MAAA,CACL,QACE,IACA,CAAC,CAAE,YACM,SAAS,QAAQ,KAAK,IAAI,EAErC,WACE,IACA,CAAC,CAAE,YACM,SAAS,WAAW,KAAK,IAAI,CAE1C,CAAA,CAEJ,CAAC"}
|
package/dist/abbr/abbr.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/core';
|
|
2
|
-
declare module
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
declare module "@tiptap/core" {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
abbr: {
|
|
5
|
+
/**
|
|
6
|
+
* Set an abbr mark
|
|
7
|
+
*/
|
|
8
|
+
setAbbr: (src: string) => ReturnType;
|
|
9
|
+
/**
|
|
10
|
+
* Toggle an abbr mark
|
|
11
|
+
*/
|
|
12
|
+
toggleAbbr: (src: string) => ReturnType;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
15
|
}
|
|
16
16
|
export declare const Abbr: Mark<any, any>;
|
package/dist/abbr/abbr.js
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import { Mark, mergeAttributes } from
|
|
1
|
+
import { Mark, mergeAttributes } from "@tiptap/core";
|
|
2
2
|
const Abbr = Mark.create({
|
|
3
|
-
name:
|
|
3
|
+
name: "abbr",
|
|
4
4
|
addOptions() {
|
|
5
5
|
return {
|
|
6
|
-
HTMLAttributes: {}
|
|
6
|
+
HTMLAttributes: {}
|
|
7
7
|
};
|
|
8
8
|
},
|
|
9
9
|
parseHTML() {
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
12
|
-
tag:
|
|
13
|
-
}
|
|
12
|
+
tag: "abbr"
|
|
13
|
+
}
|
|
14
14
|
];
|
|
15
15
|
},
|
|
16
16
|
renderHTML({ HTMLAttributes }) {
|
|
17
17
|
return [
|
|
18
|
-
|
|
18
|
+
"abbr",
|
|
19
19
|
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
20
|
-
0
|
|
20
|
+
0
|
|
21
21
|
];
|
|
22
22
|
},
|
|
23
23
|
addCommands() {
|
|
24
24
|
return {
|
|
25
|
-
setAbbr:
|
|
26
|
-
|
|
27
|
-
({ commands }) =>
|
|
28
|
-
commands.setMark(this.name),
|
|
29
|
-
toggleAbbr:
|
|
30
|
-
() =>
|
|
31
|
-
({ commands }) =>
|
|
32
|
-
commands.toggleMark(this.name),
|
|
25
|
+
setAbbr: () => ({ commands }) => commands.setMark(this.name),
|
|
26
|
+
toggleAbbr: () => ({ commands }) => commands.toggleMark(this.name)
|
|
33
27
|
};
|
|
34
|
-
}
|
|
28
|
+
}
|
|
35
29
|
});
|
|
36
|
-
export {
|
|
30
|
+
export {
|
|
31
|
+
Abbr
|
|
32
|
+
};
|
|
37
33
|
//# sourceMappingURL=abbr.js.map
|
package/dist/abbr/abbr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abbr.js","sources":["../../src/abbr/abbr.ts"],"sourcesContent":["import { Mark, mergeAttributes } from
|
|
1
|
+
{"version":3,"file":"abbr.js","sources":["../../src/abbr/abbr.ts"],"sourcesContent":["import { Mark, mergeAttributes } from \"@tiptap/core\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n abbr: {\n /**\n * Set an abbr mark\n */\n setAbbr: (src: string) => ReturnType;\n /**\n * Toggle an abbr mark\n */\n toggleAbbr: (src: string) => ReturnType;\n };\n }\n}\n\nexport const Abbr = Mark.create({\n name: \"abbr\",\n\n addOptions() {\n return {\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"abbr\",\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"abbr\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setAbbr:\n () =>\n ({ commands }) => {\n return commands.setMark(this.name);\n },\n toggleAbbr:\n () =>\n ({ commands }) => {\n return commands.toggleMark(this.name);\n },\n };\n },\n});\n"],"names":[],"mappings":";AAiBa,MAAA,OAAO,KAAK,OAAO;AAAA,EAC9B,MAAM;AAAA,EAEN,aAAa;AACJ,WAAA;AAAA,MACL,gBAAgB,CAAA;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MAAA;AAAA,IAET;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,kBAAkB;AACtB,WAAA;AAAA,MACL;AAAA,MACA,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc;AAAA,MAC3D;AAAA,IACF;AAAA,EACF;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,SACE,MACA,CAAC,EAAE,eACM,SAAS,QAAQ,KAAK,IAAI;AAAA,MAErC,YACE,MACA,CAAC,EAAE,eACM,SAAS,WAAW,KAAK,IAAI;AAAA,IAE1C;AAAA,EAAA;AAEJ,CAAC;"}
|
package/dist/alert/alert.cjs
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core'),
|
|
4
|
-
Alert = core.Node.create({
|
|
5
|
-
name: 'alert',
|
|
6
|
-
content: 'inline+',
|
|
7
|
-
marks: '',
|
|
8
|
-
group: 'block',
|
|
9
|
-
inline: !1,
|
|
10
|
-
selectable: !0,
|
|
11
|
-
draggable: !0,
|
|
12
|
-
parseHTML() {
|
|
13
|
-
return [
|
|
14
|
-
{ tag: 'p.info', priority: 60 },
|
|
15
|
-
{ tag: 'p.warning', priority: 60 },
|
|
16
|
-
{ tag: 'div.info', priority: 60 },
|
|
17
|
-
{ tag: 'div.warning', priority: 60 },
|
|
18
|
-
];
|
|
19
|
-
},
|
|
20
|
-
addAttributes() {
|
|
21
|
-
return {
|
|
22
|
-
class: {
|
|
23
|
-
default: 'info',
|
|
24
|
-
parseHTML: (element) => element.getAttribute('class'),
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
renderHTML({ HTMLAttributes }) {
|
|
29
|
-
return ['div', HTMLAttributes, 0];
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
exports.Alert = Alert;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),Alert=core.Node.create({name:"alert",content:"inline+",marks:"",group:"block",inline:!1,selectable:!0,draggable:!0,parseHTML(){return[{tag:"p.info",priority:60},{tag:"p.warning",priority:60},{tag:"div.info",priority:60},{tag:"div.warning",priority:60}]},addAttributes(){return{class:{default:"info",parseHTML:element=>element.getAttribute("class")}}},renderHTML({HTMLAttributes}){return["div",HTMLAttributes,0]}});exports.Alert=Alert;
|
|
33
2
|
//# sourceMappingURL=alert.cjs.map
|
package/dist/alert/alert.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.cjs","sources":["../../src/alert/alert.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"alert.cjs","sources":["../../src/alert/alert.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport const Alert = Node.create({\n name: \"alert\",\n content: \"inline+\",\n marks: \"\",\n group: \"block\",\n\n inline: false,\n selectable: true,\n draggable: true,\n\n parseHTML() {\n return [\n {\n tag: \"p.info\",\n priority: 60,\n },\n {\n tag: \"p.warning\",\n priority: 60,\n },\n {\n tag: \"div.info\",\n priority: 60,\n },\n {\n tag: \"div.warning\",\n priority: 60,\n },\n ];\n },\n addAttributes() {\n return {\n class: {\n default: \"info\",\n parseHTML: (element) => {\n return element.getAttribute(\"class\");\n },\n },\n };\n },\n renderHTML({ HTMLAttributes }) {\n return [\"div\", HTMLAttributes, 0];\n },\n});\n"],"names":["Node"],"mappings":"mHAEa,MAAQA,UAAK,OAAO,CAC/B,KAAM,QACN,QAAS,UACT,MAAO,GACP,MAAO,QAEP,OAAQ,GACR,WAAY,GACZ,UAAW,GAEX,WAAY,CACH,MAAA,CACL,CACE,IAAK,SACL,SAAU,EACZ,EACA,CACE,IAAK,YACL,SAAU,EACZ,EACA,CACE,IAAK,WACL,SAAU,EACZ,EACA,CACE,IAAK,cACL,SAAU,EAAA,CAEd,CACF,EACA,eAAgB,CACP,MAAA,CACL,MAAO,CACL,QAAS,OACT,UAAY,SACH,QAAQ,aAAa,OAAO,CACrC,CAEJ,CACF,EACA,WAAW,CAAE,gBAAkB,CACtB,MAAA,CAAC,MAAO,eAAgB,CAAC,CAAA,CAEpC,CAAC"}
|
package/dist/alert/alert.js
CHANGED
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
2
|
const Alert = Node.create({
|
|
3
|
-
name:
|
|
4
|
-
content:
|
|
5
|
-
marks:
|
|
6
|
-
group:
|
|
3
|
+
name: "alert",
|
|
4
|
+
content: "inline+",
|
|
5
|
+
marks: "",
|
|
6
|
+
group: "block",
|
|
7
7
|
inline: !1,
|
|
8
8
|
selectable: !0,
|
|
9
9
|
draggable: !0,
|
|
10
10
|
parseHTML() {
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
13
|
-
tag:
|
|
14
|
-
priority: 60
|
|
13
|
+
tag: "p.info",
|
|
14
|
+
priority: 60
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
tag:
|
|
18
|
-
priority: 60
|
|
17
|
+
tag: "p.warning",
|
|
18
|
+
priority: 60
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
tag:
|
|
22
|
-
priority: 60
|
|
21
|
+
tag: "div.info",
|
|
22
|
+
priority: 60
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
tag:
|
|
26
|
-
priority: 60
|
|
27
|
-
}
|
|
25
|
+
tag: "div.warning",
|
|
26
|
+
priority: 60
|
|
27
|
+
}
|
|
28
28
|
];
|
|
29
29
|
},
|
|
30
30
|
addAttributes() {
|
|
31
31
|
return {
|
|
32
32
|
class: {
|
|
33
|
-
default:
|
|
34
|
-
parseHTML: (element) => element.getAttribute(
|
|
35
|
-
}
|
|
33
|
+
default: "info",
|
|
34
|
+
parseHTML: (element) => element.getAttribute("class")
|
|
35
|
+
}
|
|
36
36
|
};
|
|
37
37
|
},
|
|
38
38
|
renderHTML({ HTMLAttributes }) {
|
|
39
|
-
return [
|
|
40
|
-
}
|
|
39
|
+
return ["div", HTMLAttributes, 0];
|
|
40
|
+
}
|
|
41
41
|
});
|
|
42
|
-
export {
|
|
42
|
+
export {
|
|
43
|
+
Alert
|
|
44
|
+
};
|
|
43
45
|
//# sourceMappingURL=alert.js.map
|
package/dist/alert/alert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.js","sources":["../../src/alert/alert.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"alert.js","sources":["../../src/alert/alert.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport const Alert = Node.create({\n name: \"alert\",\n content: \"inline+\",\n marks: \"\",\n group: \"block\",\n\n inline: false,\n selectable: true,\n draggable: true,\n\n parseHTML() {\n return [\n {\n tag: \"p.info\",\n priority: 60,\n },\n {\n tag: \"p.warning\",\n priority: 60,\n },\n {\n tag: \"div.info\",\n priority: 60,\n },\n {\n tag: \"div.warning\",\n priority: 60,\n },\n ];\n },\n addAttributes() {\n return {\n class: {\n default: \"info\",\n parseHTML: (element) => {\n return element.getAttribute(\"class\");\n },\n },\n };\n },\n renderHTML({ HTMLAttributes }) {\n return [\"div\", HTMLAttributes, 0];\n },\n});\n"],"names":[],"mappings":";AAEa,MAAA,QAAQ,KAAK,OAAO;AAAA,EAC/B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EAEP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EAEX,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,QACL,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,UAAU;AAAA,MAAA;AAAA,IAEd;AAAA,EACF;AAAA,EACA,gBAAgB;AACP,WAAA;AAAA,MACL,OAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW,CAAC,YACH,QAAQ,aAAa,OAAO;AAAA,MACrC;AAAA,IAEJ;AAAA,EACF;AAAA,EACA,WAAW,EAAE,kBAAkB;AACtB,WAAA,CAAC,OAAO,gBAAgB,CAAC;AAAA,EAAA;AAEpC,CAAC;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),AttachmentTransformer=core.Node.create({name:"attachments",content:"",marks:"",group:"inline",inline:!0,selectable:!0,atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"attachments"}}},parseHTML(){return[{tag:"div[class=attachments]"}]},renderHTML({HTMLAttributes}){const renderedLinks=HTMLAttributes.links.map(el=>["a",{name:el.name,href:el.href,documentId:el.documentId,dataContentType:el.dataContentType},el.name]);return["div",this.options.HTMLAttributes,...renderedLinks]},addAttributes(){return{links:{default:[],parseHTML:element=>{const links=element.getElementsByTagName("a"),parsedLinks=[];for(let i=0;i<links.length;i++){const link=links[i],href=link.getAttribute("href"),name=link.textContent,regexResult=href.match(/([^/]+$)/),documentId=link.getAttribute("data-document-id")||regexResult&®exResult[0],dataContentType=link.getAttribute("data-content-type");parsedLinks.push({href,name,documentId,dataContentType})}return parsedLinks},renderHTML:attributes=>({links:attributes.links.map(link=>({href:link.href,name:link.name,documentId:link.documentId,dataContentType:link.dataContentType}))})}}},addCommands(){return{setAttachment:(attrs={dataContentType:"",name:"",documentId:"",href:""})=>({chain})=>chain().insertContent({type:this.name,attrs}).run()}}});exports.AttachmentTransformer=AttachmentTransformer;
|
|
2
|
+
//# sourceMappingURL=attachment-transformer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-transformer.cjs","sources":["../../src/attachment/attachment-transformer.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport interface AttachmentOptions {\n HTMLAttributes: Record<string, string>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n attachment: {\n setAttachment: (attachment) => ReturnType;\n };\n }\n}\n\nexport const AttachmentTransformer = Node.create<AttachmentOptions>({\n name: \"attachments\",\n content: \"\",\n marks: \"\",\n group: \"inline\",\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n HTMLAttributes: {\n class: \"attachments\",\n },\n };\n },\n\n parseHTML() {\n return [{ tag: \"div[class=attachments]\" }];\n },\n\n renderHTML({ HTMLAttributes }) {\n const links = HTMLAttributes.links;\n\n const renderedLinks = links.map((el) => {\n return [\n \"a\",\n {\n name: el.name,\n href: el.href,\n documentId: el.documentId,\n dataContentType: el.dataContentType,\n },\n el.name,\n ];\n });\n\n return [\"div\", this.options.HTMLAttributes, ...renderedLinks];\n },\n\n addAttributes() {\n return {\n links: {\n default: [],\n parseHTML: (element) => {\n const links = element.getElementsByTagName(\"a\");\n const parsedLinks = [];\n\n for (let i = 0; i < links.length; i++) {\n const link = links[i];\n const href = link.getAttribute(\"href\");\n const name = link.textContent;\n const regexResult = href.match(/([^/]+$)/);\n const documentId =\n link.getAttribute(\"data-document-id\") ||\n (regexResult && regexResult[0]);\n const dataContentType = link.getAttribute(\"data-content-type\");\n\n parsedLinks.push({\n href,\n name,\n documentId,\n dataContentType,\n });\n }\n\n return parsedLinks;\n },\n renderHTML: (attributes) => {\n return {\n links: attributes.links.map((link) => ({\n href: link.href,\n name: link.name,\n documentId: link.documentId,\n dataContentType: link.dataContentType,\n })),\n };\n },\n },\n };\n },\n\n addCommands() {\n return {\n setAttachment:\n (\n attrs = {\n dataContentType: \"\",\n name: \"\",\n documentId: \"\",\n href: \"\",\n },\n ) =>\n ({ chain }) => {\n return chain().insertContent({ type: this.name, attrs }).run();\n },\n };\n },\n});\n"],"names":["Node"],"mappings":"mHAca,sBAAwBA,UAAK,OAA0B,CAClE,KAAM,cACN,QAAS,GACT,MAAO,GACP,MAAO,SACP,OAAQ,GACR,WAAY,GACZ,KAAM,GACN,UAAW,GAEX,YAAa,CACJ,MAAA,CACL,eAAgB,CACd,MAAO,aAAA,CAEX,CACF,EAEA,WAAY,CACV,MAAO,CAAC,CAAE,IAAK,yBAA0B,CAC3C,EAEA,WAAW,CAAE,gBAAkB,CAG7B,MAAM,cAFQ,eAAe,MAED,IAAK,IACxB,CACL,IACA,CACE,KAAM,GAAG,KACT,KAAM,GAAG,KACT,WAAY,GAAG,WACf,gBAAiB,GAAG,eACtB,EACA,GAAG,IACL,CACD,EAED,MAAO,CAAC,MAAO,KAAK,QAAQ,eAAgB,GAAG,aAAa,CAC9D,EAEA,eAAgB,CACP,MAAA,CACL,MAAO,CACL,QAAS,CAAC,EACV,UAAY,SAAY,CAChB,MAAA,MAAQ,QAAQ,qBAAqB,GAAG,EACxC,YAAc,CAAC,EAErB,QAAS,EAAI,EAAG,EAAI,MAAM,OAAQ,IAAK,CAC/B,MAAA,KAAO,MAAM,CAAC,EACd,KAAO,KAAK,aAAa,MAAM,EAC/B,KAAO,KAAK,YACZ,YAAc,KAAK,MAAM,UAAU,EACnC,WACJ,KAAK,aAAa,kBAAkB,GACnC,aAAe,YAAY,CAAC,EACzB,gBAAkB,KAAK,aAAa,mBAAmB,EAE7D,YAAY,KAAK,CACf,KACA,KACA,WACA,eAAA,CACD,CAAA,CAGI,OAAA,WACT,EACA,WAAa,aACJ,CACL,MAAO,WAAW,MAAM,IAAK,OAAU,CACrC,KAAM,KAAK,KACX,KAAM,KAAK,KACX,WAAY,KAAK,WACjB,gBAAiB,KAAK,eAAA,EACtB,CACJ,EACF,CAEJ,CACF,EAEA,aAAc,CACL,MAAA,CACL,cACE,CACE,MAAQ,CACN,gBAAiB,GACjB,KAAM,GACN,WAAY,GACZ,KAAM,EAAA,IAGV,CAAC,CAAE,SACM,MAAA,EAAQ,cAAc,CAAE,KAAM,KAAK,KAAM,MAAO,EAAE,IAAI,CAEnE,CAAA,CAEJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface AttachmentOptions {
|
|
3
|
+
HTMLAttributes: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
declare module "@tiptap/core" {
|
|
6
|
+
interface Commands<ReturnType> {
|
|
7
|
+
attachment: {
|
|
8
|
+
setAttachment: (attachment: any) => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const AttachmentTransformer: Node<AttachmentOptions, any>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
const AttachmentTransformer = Node.create({
|
|
3
|
+
name: "attachments",
|
|
4
|
+
content: "",
|
|
5
|
+
marks: "",
|
|
6
|
+
group: "inline",
|
|
7
|
+
inline: !0,
|
|
8
|
+
selectable: !0,
|
|
9
|
+
atom: !0,
|
|
10
|
+
draggable: !0,
|
|
11
|
+
addOptions() {
|
|
12
|
+
return {
|
|
13
|
+
HTMLAttributes: {
|
|
14
|
+
class: "attachments"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
parseHTML() {
|
|
19
|
+
return [{ tag: "div[class=attachments]" }];
|
|
20
|
+
},
|
|
21
|
+
renderHTML({ HTMLAttributes }) {
|
|
22
|
+
const renderedLinks = HTMLAttributes.links.map((el) => [
|
|
23
|
+
"a",
|
|
24
|
+
{
|
|
25
|
+
name: el.name,
|
|
26
|
+
href: el.href,
|
|
27
|
+
documentId: el.documentId,
|
|
28
|
+
dataContentType: el.dataContentType
|
|
29
|
+
},
|
|
30
|
+
el.name
|
|
31
|
+
]);
|
|
32
|
+
return ["div", this.options.HTMLAttributes, ...renderedLinks];
|
|
33
|
+
},
|
|
34
|
+
addAttributes() {
|
|
35
|
+
return {
|
|
36
|
+
links: {
|
|
37
|
+
default: [],
|
|
38
|
+
parseHTML: (element) => {
|
|
39
|
+
const links = element.getElementsByTagName("a"), parsedLinks = [];
|
|
40
|
+
for (let i = 0; i < links.length; i++) {
|
|
41
|
+
const link = links[i], href = link.getAttribute("href"), name = link.textContent, regexResult = href.match(/([^/]+$)/), documentId = link.getAttribute("data-document-id") || regexResult && regexResult[0], dataContentType = link.getAttribute("data-content-type");
|
|
42
|
+
parsedLinks.push({
|
|
43
|
+
href,
|
|
44
|
+
name,
|
|
45
|
+
documentId,
|
|
46
|
+
dataContentType
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return parsedLinks;
|
|
50
|
+
},
|
|
51
|
+
renderHTML: (attributes) => ({
|
|
52
|
+
links: attributes.links.map((link) => ({
|
|
53
|
+
href: link.href,
|
|
54
|
+
name: link.name,
|
|
55
|
+
documentId: link.documentId,
|
|
56
|
+
dataContentType: link.dataContentType
|
|
57
|
+
}))
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
addCommands() {
|
|
63
|
+
return {
|
|
64
|
+
setAttachment: (attrs = {
|
|
65
|
+
dataContentType: "",
|
|
66
|
+
name: "",
|
|
67
|
+
documentId: "",
|
|
68
|
+
href: ""
|
|
69
|
+
}) => ({ chain }) => chain().insertContent({ type: this.name, attrs }).run()
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export {
|
|
74
|
+
AttachmentTransformer
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=attachment-transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-transformer.js","sources":["../../src/attachment/attachment-transformer.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport interface AttachmentOptions {\n HTMLAttributes: Record<string, string>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n attachment: {\n setAttachment: (attachment) => ReturnType;\n };\n }\n}\n\nexport const AttachmentTransformer = Node.create<AttachmentOptions>({\n name: \"attachments\",\n content: \"\",\n marks: \"\",\n group: \"inline\",\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n HTMLAttributes: {\n class: \"attachments\",\n },\n };\n },\n\n parseHTML() {\n return [{ tag: \"div[class=attachments]\" }];\n },\n\n renderHTML({ HTMLAttributes }) {\n const links = HTMLAttributes.links;\n\n const renderedLinks = links.map((el) => {\n return [\n \"a\",\n {\n name: el.name,\n href: el.href,\n documentId: el.documentId,\n dataContentType: el.dataContentType,\n },\n el.name,\n ];\n });\n\n return [\"div\", this.options.HTMLAttributes, ...renderedLinks];\n },\n\n addAttributes() {\n return {\n links: {\n default: [],\n parseHTML: (element) => {\n const links = element.getElementsByTagName(\"a\");\n const parsedLinks = [];\n\n for (let i = 0; i < links.length; i++) {\n const link = links[i];\n const href = link.getAttribute(\"href\");\n const name = link.textContent;\n const regexResult = href.match(/([^/]+$)/);\n const documentId =\n link.getAttribute(\"data-document-id\") ||\n (regexResult && regexResult[0]);\n const dataContentType = link.getAttribute(\"data-content-type\");\n\n parsedLinks.push({\n href,\n name,\n documentId,\n dataContentType,\n });\n }\n\n return parsedLinks;\n },\n renderHTML: (attributes) => {\n return {\n links: attributes.links.map((link) => ({\n href: link.href,\n name: link.name,\n documentId: link.documentId,\n dataContentType: link.dataContentType,\n })),\n };\n },\n },\n };\n },\n\n addCommands() {\n return {\n setAttachment:\n (\n attrs = {\n dataContentType: \"\",\n name: \"\",\n documentId: \"\",\n href: \"\",\n },\n ) =>\n ({ chain }) => {\n return chain().insertContent({ type: this.name, attrs }).run();\n },\n };\n },\n});\n"],"names":[],"mappings":";AAca,MAAA,wBAAwB,KAAK,OAA0B;AAAA,EAClE,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,WAAW;AAAA,EAEX,aAAa;AACJ,WAAA;AAAA,MACL,gBAAgB;AAAA,QACd,OAAO;AAAA,MAAA;AAAA,IAEX;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,0BAA0B;AAAA,EAC3C;AAAA,EAEA,WAAW,EAAE,kBAAkB;AAG7B,UAAM,gBAFQ,eAAe,MAED,IAAI,CAAC,OACxB;AAAA,MACL;AAAA,MACA;AAAA,QACE,MAAM,GAAG;AAAA,QACT,MAAM,GAAG;AAAA,QACT,YAAY,GAAG;AAAA,QACf,iBAAiB,GAAG;AAAA,MACtB;AAAA,MACA,GAAG;AAAA,IACL,CACD;AAED,WAAO,CAAC,OAAO,KAAK,QAAQ,gBAAgB,GAAG,aAAa;AAAA,EAC9D;AAAA,EAEA,gBAAgB;AACP,WAAA;AAAA,MACL,OAAO;AAAA,QACL,SAAS,CAAC;AAAA,QACV,WAAW,CAAC,YAAY;AAChB,gBAAA,QAAQ,QAAQ,qBAAqB,GAAG,GACxC,cAAc,CAAC;AAErB,mBAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAC/B,kBAAA,OAAO,MAAM,CAAC,GACd,OAAO,KAAK,aAAa,MAAM,GAC/B,OAAO,KAAK,aACZ,cAAc,KAAK,MAAM,UAAU,GACnC,aACJ,KAAK,aAAa,kBAAkB,KACnC,eAAe,YAAY,CAAC,GACzB,kBAAkB,KAAK,aAAa,mBAAmB;AAE7D,wBAAY,KAAK;AAAA,cACf;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YAAA,CACD;AAAA,UAAA;AAGI,iBAAA;AAAA,QACT;AAAA,QACA,YAAY,CAAC,gBACJ;AAAA,UACL,OAAO,WAAW,MAAM,IAAI,CAAC,UAAU;AAAA,YACrC,MAAM,KAAK;AAAA,YACX,MAAM,KAAK;AAAA,YACX,YAAY,KAAK;AAAA,YACjB,iBAAiB,KAAK;AAAA,UAAA,EACtB;AAAA,QACJ;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,eACE,CACE,QAAQ;AAAA,QACN,iBAAiB;AAAA,QACjB,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,MAAM;AAAA,MAAA,MAGV,CAAC,EAAE,YACM,MAAA,EAAQ,cAAc,EAAE,MAAM,KAAK,MAAM,OAAO,EAAE,IAAI;AAAA,IAEnE;AAAA,EAAA;AAEJ,CAAC;"}
|
|
@@ -1,74 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core'),
|
|
4
|
-
Attachment = core.Node.create({
|
|
5
|
-
name: 'attachments',
|
|
6
|
-
content: '',
|
|
7
|
-
marks: '',
|
|
8
|
-
group: 'block',
|
|
9
|
-
selectable: !0,
|
|
10
|
-
atom: !0,
|
|
11
|
-
draggable: !0,
|
|
12
|
-
addOptions() {
|
|
13
|
-
return { HTMLAttributes: { class: 'attachments' } };
|
|
14
|
-
},
|
|
15
|
-
parseHTML() {
|
|
16
|
-
return [{ tag: 'div[class=attachments]' }];
|
|
17
|
-
},
|
|
18
|
-
renderHTML({ HTMLAttributes }) {
|
|
19
|
-
const renderedLinks = HTMLAttributes.links.map((el) => [
|
|
20
|
-
'a',
|
|
21
|
-
{
|
|
22
|
-
name: el.name,
|
|
23
|
-
href: el.href,
|
|
24
|
-
documentId: el.documentId,
|
|
25
|
-
dataContentType: el.dataContentType,
|
|
26
|
-
},
|
|
27
|
-
el.name,
|
|
28
|
-
]);
|
|
29
|
-
return ['div', this.options.HTMLAttributes, ...renderedLinks];
|
|
30
|
-
},
|
|
31
|
-
addAttributes() {
|
|
32
|
-
return {
|
|
33
|
-
links: {
|
|
34
|
-
default: [],
|
|
35
|
-
parseHTML: (element) => {
|
|
36
|
-
const links = element.getElementsByTagName('a'),
|
|
37
|
-
parsedLinks = [];
|
|
38
|
-
for (let i = 0; i < links.length; i++) {
|
|
39
|
-
const link = links[i],
|
|
40
|
-
href = link.getAttribute('href'),
|
|
41
|
-
name = link.textContent,
|
|
42
|
-
regexResult = href.match(/([^/]+$)/),
|
|
43
|
-
documentId =
|
|
44
|
-
link.getAttribute('data-document-id') ||
|
|
45
|
-
(regexResult && regexResult[0]),
|
|
46
|
-
dataContentType = link.getAttribute('data-content-type');
|
|
47
|
-
parsedLinks.push({ href, name, documentId, dataContentType });
|
|
48
|
-
}
|
|
49
|
-
return parsedLinks;
|
|
50
|
-
},
|
|
51
|
-
renderHTML: (attributes) => ({
|
|
52
|
-
links: attributes.links.map((link) => ({
|
|
53
|
-
href: link.href,
|
|
54
|
-
name: link.name,
|
|
55
|
-
documentId: link.documentId,
|
|
56
|
-
dataContentType: link.dataContentType,
|
|
57
|
-
})),
|
|
58
|
-
}),
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
addCommands() {
|
|
63
|
-
return {
|
|
64
|
-
setAttachment:
|
|
65
|
-
(
|
|
66
|
-
attrs = { dataContentType: '', name: '', documentId: '', href: '' },
|
|
67
|
-
) =>
|
|
68
|
-
({ chain }) =>
|
|
69
|
-
chain().insertContent({ type: this.name, attrs }).run(),
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
exports.Attachment = Attachment;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),Attachment=core.Node.create({name:"attachments",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"attachments"}}},parseHTML(){return[{tag:"div[class=attachments]"}]},renderHTML({HTMLAttributes}){const renderedLinks=HTMLAttributes.links.map(el=>["a",{name:el.name,href:el.href,documentId:el.documentId,dataContentType:el.dataContentType},el.name]);return["div",this.options.HTMLAttributes,...renderedLinks]},addAttributes(){return{links:{default:[],parseHTML:element=>{const links=element.getElementsByTagName("a"),parsedLinks=[];for(let i=0;i<links.length;i++){const link=links[i],href=link.getAttribute("href"),name=link.textContent,regexResult=href.match(/([^/]+$)/),documentId=link.getAttribute("data-document-id")||regexResult&®exResult[0],dataContentType=link.getAttribute("data-content-type");parsedLinks.push({href,name,documentId,dataContentType})}return parsedLinks},renderHTML:attributes=>({links:attributes.links.map(link=>({href:link.href,name:link.name,documentId:link.documentId,dataContentType:link.dataContentType}))})}}},addCommands(){return{setAttachment:(attrs={dataContentType:"",name:"",documentId:"",href:""})=>({chain})=>chain().insertContent({type:this.name,attrs}).run()}}});exports.Attachment=Attachment;
|
|
74
2
|
//# sourceMappingURL=attachment.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.cjs","sources":["../../src/attachment/attachment.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"attachment.cjs","sources":["../../src/attachment/attachment.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport interface AttachmentOptions {\n HTMLAttributes: Record<string, string>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n attachment: {\n setAttachment: (attachment) => ReturnType;\n };\n }\n}\n\nexport const Attachment = Node.create<AttachmentOptions>({\n name: \"attachments\",\n content: \"\",\n marks: \"\",\n group: \"block\",\n selectable: true,\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n HTMLAttributes: {\n class: \"attachments\",\n },\n };\n },\n\n parseHTML() {\n return [{ tag: \"div[class=attachments]\" }];\n },\n\n renderHTML({ HTMLAttributes }) {\n const links = HTMLAttributes.links;\n\n const renderedLinks = links.map((el) => {\n return [\n \"a\",\n {\n name: el.name,\n href: el.href,\n documentId: el.documentId,\n dataContentType: el.dataContentType,\n },\n el.name,\n ];\n });\n\n return [\"div\", this.options.HTMLAttributes, ...renderedLinks];\n },\n\n addAttributes() {\n return {\n links: {\n default: [],\n parseHTML: (element) => {\n const links = element.getElementsByTagName(\"a\");\n const parsedLinks = [];\n\n for (let i = 0; i < links.length; i++) {\n const link = links[i];\n const href = link.getAttribute(\"href\");\n const name = link.textContent;\n const regexResult = href.match(/([^/]+$)/);\n const documentId =\n link.getAttribute(\"data-document-id\") ||\n (regexResult && regexResult[0]);\n const dataContentType = link.getAttribute(\"data-content-type\");\n\n parsedLinks.push({\n href,\n name,\n documentId,\n dataContentType,\n });\n }\n\n return parsedLinks;\n },\n renderHTML: (attributes) => {\n return {\n links: attributes.links.map((link) => ({\n href: link.href,\n name: link.name,\n documentId: link.documentId,\n dataContentType: link.dataContentType,\n })),\n };\n },\n },\n };\n },\n\n addCommands() {\n return {\n setAttachment:\n (\n attrs = {\n dataContentType: \"\",\n name: \"\",\n documentId: \"\",\n href: \"\",\n },\n ) =>\n ({ chain }) => {\n return chain().insertContent({ type: this.name, attrs }).run();\n },\n };\n },\n});\n"],"names":["Node"],"mappings":"mHAca,WAAaA,UAAK,OAA0B,CACvD,KAAM,cACN,QAAS,GACT,MAAO,GACP,MAAO,QACP,WAAY,GACZ,KAAM,GACN,UAAW,GAEX,YAAa,CACJ,MAAA,CACL,eAAgB,CACd,MAAO,aAAA,CAEX,CACF,EAEA,WAAY,CACV,MAAO,CAAC,CAAE,IAAK,yBAA0B,CAC3C,EAEA,WAAW,CAAE,gBAAkB,CAG7B,MAAM,cAFQ,eAAe,MAED,IAAK,IACxB,CACL,IACA,CACE,KAAM,GAAG,KACT,KAAM,GAAG,KACT,WAAY,GAAG,WACf,gBAAiB,GAAG,eACtB,EACA,GAAG,IACL,CACD,EAED,MAAO,CAAC,MAAO,KAAK,QAAQ,eAAgB,GAAG,aAAa,CAC9D,EAEA,eAAgB,CACP,MAAA,CACL,MAAO,CACL,QAAS,CAAC,EACV,UAAY,SAAY,CAChB,MAAA,MAAQ,QAAQ,qBAAqB,GAAG,EACxC,YAAc,CAAC,EAErB,QAAS,EAAI,EAAG,EAAI,MAAM,OAAQ,IAAK,CAC/B,MAAA,KAAO,MAAM,CAAC,EACd,KAAO,KAAK,aAAa,MAAM,EAC/B,KAAO,KAAK,YACZ,YAAc,KAAK,MAAM,UAAU,EACnC,WACJ,KAAK,aAAa,kBAAkB,GACnC,aAAe,YAAY,CAAC,EACzB,gBAAkB,KAAK,aAAa,mBAAmB,EAE7D,YAAY,KAAK,CACf,KACA,KACA,WACA,eAAA,CACD,CAAA,CAGI,OAAA,WACT,EACA,WAAa,aACJ,CACL,MAAO,WAAW,MAAM,IAAK,OAAU,CACrC,KAAM,KAAK,KACX,KAAM,KAAK,KACX,WAAY,KAAK,WACjB,gBAAiB,KAAK,eAAA,EACtB,CACJ,EACF,CAEJ,CACF,EAEA,aAAc,CACL,MAAA,CACL,cACE,CACE,MAAQ,CACN,gBAAiB,GACjB,KAAM,GACN,WAAY,GACZ,KAAM,EAAA,IAGV,CAAC,CAAE,SACM,MAAA,EAAQ,cAAc,CAAE,KAAM,KAAK,KAAM,MAAO,EAAE,IAAI,CAEnE,CAAA,CAEJ,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
2
|
export interface AttachmentOptions {
|
|
3
|
-
|
|
3
|
+
HTMLAttributes: Record<string, string>;
|
|
4
4
|
}
|
|
5
|
-
declare module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
declare module "@tiptap/core" {
|
|
6
|
+
interface Commands<ReturnType> {
|
|
7
|
+
attachment: {
|
|
8
|
+
setAttachment: (attachment: any) => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
12
|
export declare const Attachment: Node<AttachmentOptions, any>;
|