@edifice.io/tiptap-extensions 2.0.0-develop-rc.13 → 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 +24 -16
- 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
|
@@ -1,56 +1,48 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
2
|
const Attachment = Node.create({
|
|
3
|
-
name:
|
|
4
|
-
content:
|
|
5
|
-
marks:
|
|
6
|
-
group:
|
|
3
|
+
name: "attachments",
|
|
4
|
+
content: "",
|
|
5
|
+
marks: "",
|
|
6
|
+
group: "block",
|
|
7
7
|
selectable: !0,
|
|
8
8
|
atom: !0,
|
|
9
9
|
draggable: !0,
|
|
10
10
|
addOptions() {
|
|
11
11
|
return {
|
|
12
12
|
HTMLAttributes: {
|
|
13
|
-
class:
|
|
14
|
-
}
|
|
13
|
+
class: "attachments"
|
|
14
|
+
}
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
17
|
parseHTML() {
|
|
18
|
-
return [{ tag:
|
|
18
|
+
return [{ tag: "div[class=attachments]" }];
|
|
19
19
|
},
|
|
20
20
|
renderHTML({ HTMLAttributes }) {
|
|
21
21
|
const renderedLinks = HTMLAttributes.links.map((el) => [
|
|
22
|
-
|
|
22
|
+
"a",
|
|
23
23
|
{
|
|
24
24
|
name: el.name,
|
|
25
25
|
href: el.href,
|
|
26
26
|
documentId: el.documentId,
|
|
27
|
-
dataContentType: el.dataContentType
|
|
27
|
+
dataContentType: el.dataContentType
|
|
28
28
|
},
|
|
29
|
-
el.name
|
|
29
|
+
el.name
|
|
30
30
|
]);
|
|
31
|
-
return [
|
|
31
|
+
return ["div", this.options.HTMLAttributes, ...renderedLinks];
|
|
32
32
|
},
|
|
33
33
|
addAttributes() {
|
|
34
34
|
return {
|
|
35
35
|
links: {
|
|
36
36
|
default: [],
|
|
37
37
|
parseHTML: (element) => {
|
|
38
|
-
const links = element.getElementsByTagName(
|
|
39
|
-
parsedLinks = [];
|
|
38
|
+
const links = element.getElementsByTagName("a"), parsedLinks = [];
|
|
40
39
|
for (let i = 0; i < links.length; i++) {
|
|
41
|
-
const link = links[i],
|
|
42
|
-
href = link.getAttribute('href'),
|
|
43
|
-
name = link.textContent,
|
|
44
|
-
regexResult = href.match(/([^/]+$)/),
|
|
45
|
-
documentId =
|
|
46
|
-
link.getAttribute('data-document-id') ||
|
|
47
|
-
(regexResult && regexResult[0]),
|
|
48
|
-
dataContentType = link.getAttribute('data-content-type');
|
|
40
|
+
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");
|
|
49
41
|
parsedLinks.push({
|
|
50
42
|
href,
|
|
51
43
|
name,
|
|
52
44
|
documentId,
|
|
53
|
-
dataContentType
|
|
45
|
+
dataContentType
|
|
54
46
|
});
|
|
55
47
|
}
|
|
56
48
|
return parsedLinks;
|
|
@@ -60,27 +52,24 @@ const Attachment = Node.create({
|
|
|
60
52
|
href: link.href,
|
|
61
53
|
name: link.name,
|
|
62
54
|
documentId: link.documentId,
|
|
63
|
-
dataContentType: link.dataContentType
|
|
64
|
-
}))
|
|
65
|
-
})
|
|
66
|
-
}
|
|
55
|
+
dataContentType: link.dataContentType
|
|
56
|
+
}))
|
|
57
|
+
})
|
|
58
|
+
}
|
|
67
59
|
};
|
|
68
60
|
},
|
|
69
61
|
addCommands() {
|
|
70
62
|
return {
|
|
71
|
-
setAttachment:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
href: '',
|
|
78
|
-
},
|
|
79
|
-
) =>
|
|
80
|
-
({ chain }) =>
|
|
81
|
-
chain().insertContent({ type: this.name, attrs }).run(),
|
|
63
|
+
setAttachment: (attrs = {
|
|
64
|
+
dataContentType: "",
|
|
65
|
+
name: "",
|
|
66
|
+
documentId: "",
|
|
67
|
+
href: ""
|
|
68
|
+
}) => ({ chain }) => chain().insertContent({ type: this.name, attrs }).run()
|
|
82
69
|
};
|
|
83
|
-
}
|
|
70
|
+
}
|
|
84
71
|
});
|
|
85
|
-
export {
|
|
72
|
+
export {
|
|
73
|
+
Attachment
|
|
74
|
+
};
|
|
86
75
|
//# sourceMappingURL=attachment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.js","sources":["../../src/attachment/attachment.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"attachment.js","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":[],"mappings":";AAca,MAAA,aAAa,KAAK,OAA0B;AAAA,EACvD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP,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;"}
|
package/dist/audio/audio.cjs
CHANGED
|
@@ -1,55 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core'),
|
|
4
|
-
Audio = core.Node.create({
|
|
5
|
-
name: 'audio',
|
|
6
|
-
group: 'block',
|
|
7
|
-
addAttributes() {
|
|
8
|
-
return {
|
|
9
|
-
src: {
|
|
10
|
-
default: null,
|
|
11
|
-
parseHTML: (el) => el.getAttribute('src'),
|
|
12
|
-
renderHTML: (attrs) => ({ src: attrs.src }),
|
|
13
|
-
},
|
|
14
|
-
documentId: {
|
|
15
|
-
default: '',
|
|
16
|
-
renderHTML: (attributes) => ({
|
|
17
|
-
'data-document-id': attributes.documentId,
|
|
18
|
-
}),
|
|
19
|
-
parseHTML: (element) => element.getAttribute('data-document-id'),
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
parseHTML() {
|
|
24
|
-
return [
|
|
25
|
-
{
|
|
26
|
-
tag: 'div.audio-wrapper>audio,audio',
|
|
27
|
-
getAttrs: (el) => ({ src: el.getAttribute('src') }),
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
},
|
|
31
|
-
renderHTML({ HTMLAttributes }) {
|
|
32
|
-
return [
|
|
33
|
-
'div',
|
|
34
|
-
{ class: 'audio-wrapper' },
|
|
35
|
-
['audio', core.mergeAttributes(HTMLAttributes)],
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
addCommands() {
|
|
39
|
-
return {
|
|
40
|
-
setAudio:
|
|
41
|
-
(id, src, options) =>
|
|
42
|
-
({ commands, state }) =>
|
|
43
|
-
commands.insertContentAt(
|
|
44
|
-
state.selection,
|
|
45
|
-
`<audio
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),Audio=core.Node.create({name:"audio",group:"block",addAttributes(){return{src:{default:null,parseHTML:el=>el.getAttribute("src"),renderHTML:attrs=>({src:attrs.src})},documentId:{default:"",renderHTML:attributes=>({"data-document-id":attributes.documentId}),parseHTML:element=>element.getAttribute("data-document-id")}}},parseHTML(){return[{tag:"div.audio-wrapper>audio,audio",getAttrs:el=>({src:el.getAttribute("src")})}]},renderHTML({HTMLAttributes}){return["div",{class:"audio-wrapper"},["audio",core.mergeAttributes(HTMLAttributes)]]},addCommands(){return{setAudio:(id,src,options)=>({commands,state})=>commands.insertContentAt(state.selection,`<audio
|
|
46
2
|
src="${src}"
|
|
47
3
|
controls preload="none"
|
|
48
|
-
data-document-id="${id}"></audio>`,
|
|
49
|
-
options,
|
|
50
|
-
),
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
exports.Audio = Audio;
|
|
4
|
+
data-document-id="${id}"></audio>`,options)}}});exports.Audio=Audio;
|
|
55
5
|
//# sourceMappingURL=audio.cjs.map
|
package/dist/audio/audio.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio.cjs","sources":["../../src/audio/audio.ts"],"sourcesContent":["import { mergeAttributes, Node } from
|
|
1
|
+
{"version":3,"file":"audio.cjs","sources":["../../src/audio/audio.ts"],"sourcesContent":["import { mergeAttributes, Node } from \"@tiptap/core\";\n\nexport interface AudioOptions {\n url: string;\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n audio: {\n /**\n * Set a audio node\n * @param options.updateSelection set to true will select the newly inserted content\n */\n setAudio: (\n id: string,\n src: string,\n options?: { updateSelection: boolean },\n ) => ReturnType;\n };\n }\n}\n\nexport const Audio = Node.create({\n name: \"audio\",\n\n group: \"block\",\n\n addAttributes() {\n return {\n src: {\n default: null,\n parseHTML: (el: any) => (el as HTMLSpanElement).getAttribute(\"src\"),\n renderHTML: (attrs: any) => ({ src: attrs.src }),\n },\n documentId: {\n default: \"\",\n renderHTML: (attributes: any) => {\n return { \"data-document-id\": attributes.documentId };\n },\n parseHTML: (element: any) => element.getAttribute(\"data-document-id\"),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"div.audio-wrapper>audio,audio\",\n getAttrs: (el: any) => ({\n src: (el as HTMLAudioElement).getAttribute(\"src\"),\n }),\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"div\",\n { class: \"audio-wrapper\" },\n [\"audio\", mergeAttributes(HTMLAttributes)],\n ];\n },\n\n addCommands() {\n return {\n setAudio:\n (id, src, options) =>\n ({ commands, state }) => {\n return commands.insertContentAt(\n state.selection,\n `<audio \n src=\"${src}\" \n controls preload=\"none\"\n data-document-id=\"${id}\"></audio>`,\n options,\n );\n },\n };\n },\n});\n"],"names":["Node","mergeAttributes"],"mappings":"mHAuBa,MAAQA,UAAK,OAAO,CAC/B,KAAM,QAEN,MAAO,QAEP,eAAgB,CACP,MAAA,CACL,IAAK,CACH,QAAS,KACT,UAAY,IAAa,GAAuB,aAAa,KAAK,EAClE,WAAa,QAAgB,CAAE,IAAK,MAAM,GAAI,EAChD,EACA,WAAY,CACV,QAAS,GACT,WAAa,aACJ,CAAE,mBAAoB,WAAW,UAAW,GAErD,UAAY,SAAiB,QAAQ,aAAa,kBAAkB,CAAA,CAExE,CACF,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,gCACL,SAAW,KAAa,CACtB,IAAM,GAAwB,aAAa,KAAK,CAClD,EAAA,CAEJ,CACF,EAEA,WAAW,CAAE,gBAAkB,CACtB,MAAA,CACL,MACA,CAAE,MAAO,eAAgB,EACzB,CAAC,QAASC,KAAgB,gBAAA,cAAc,CAAC,CAC3C,CACF,EAEA,aAAc,CACL,MAAA,CACL,SACE,CAAC,GAAI,IAAK,UACV,CAAC,CAAE,SAAU,SACJ,SAAS,gBACd,MAAM,UACN;AAAA,qBACS,GAAG;AAAA;AAAA,kCAEU,EAAE,aACxB,OACF,CAEN,CAAA,CAEJ,CAAC"}
|
package/dist/audio/audio.d.ts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
2
|
export interface AudioOptions {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
url: string;
|
|
4
|
+
HTMLAttributes: Record<string, any>;
|
|
5
5
|
}
|
|
6
|
-
declare module
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
) => ReturnType;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
6
|
+
declare module "@tiptap/core" {
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
audio: {
|
|
9
|
+
/**
|
|
10
|
+
* Set a audio node
|
|
11
|
+
* @param options.updateSelection set to true will select the newly inserted content
|
|
12
|
+
*/
|
|
13
|
+
setAudio: (id: string, src: string, options?: {
|
|
14
|
+
updateSelection: boolean;
|
|
15
|
+
}) => ReturnType;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
22
18
|
}
|
|
23
19
|
export declare const Audio: Node<any, any>;
|
package/dist/audio/audio.js
CHANGED
|
@@ -1,55 +1,52 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
1
|
+
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
2
|
const Audio = Node.create({
|
|
3
|
-
name:
|
|
4
|
-
group:
|
|
3
|
+
name: "audio",
|
|
4
|
+
group: "block",
|
|
5
5
|
addAttributes() {
|
|
6
6
|
return {
|
|
7
7
|
src: {
|
|
8
8
|
default: null,
|
|
9
|
-
parseHTML: (el) => el.getAttribute(
|
|
10
|
-
renderHTML: (attrs) => ({ src: attrs.src })
|
|
9
|
+
parseHTML: (el) => el.getAttribute("src"),
|
|
10
|
+
renderHTML: (attrs) => ({ src: attrs.src })
|
|
11
11
|
},
|
|
12
12
|
documentId: {
|
|
13
|
-
default:
|
|
14
|
-
renderHTML: (attributes) => ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
parseHTML: (element) => element.getAttribute('data-document-id'),
|
|
18
|
-
},
|
|
13
|
+
default: "",
|
|
14
|
+
renderHTML: (attributes) => ({ "data-document-id": attributes.documentId }),
|
|
15
|
+
parseHTML: (element) => element.getAttribute("data-document-id")
|
|
16
|
+
}
|
|
19
17
|
};
|
|
20
18
|
},
|
|
21
19
|
parseHTML() {
|
|
22
20
|
return [
|
|
23
21
|
{
|
|
24
|
-
tag:
|
|
22
|
+
tag: "div.audio-wrapper>audio,audio",
|
|
25
23
|
getAttrs: (el) => ({
|
|
26
|
-
src: el.getAttribute(
|
|
27
|
-
})
|
|
28
|
-
}
|
|
24
|
+
src: el.getAttribute("src")
|
|
25
|
+
})
|
|
26
|
+
}
|
|
29
27
|
];
|
|
30
28
|
},
|
|
31
29
|
renderHTML({ HTMLAttributes }) {
|
|
32
30
|
return [
|
|
33
|
-
|
|
34
|
-
{ class:
|
|
35
|
-
[
|
|
31
|
+
"div",
|
|
32
|
+
{ class: "audio-wrapper" },
|
|
33
|
+
["audio", mergeAttributes(HTMLAttributes)]
|
|
36
34
|
];
|
|
37
35
|
},
|
|
38
36
|
addCommands() {
|
|
39
37
|
return {
|
|
40
|
-
setAudio:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
commands.insertContentAt(
|
|
44
|
-
state.selection,
|
|
45
|
-
`<audio
|
|
38
|
+
setAudio: (id, src, options) => ({ commands, state }) => commands.insertContentAt(
|
|
39
|
+
state.selection,
|
|
40
|
+
`<audio
|
|
46
41
|
src="${src}"
|
|
47
42
|
controls preload="none"
|
|
48
43
|
data-document-id="${id}"></audio>`,
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
options
|
|
45
|
+
)
|
|
51
46
|
};
|
|
52
|
-
}
|
|
47
|
+
}
|
|
53
48
|
});
|
|
54
|
-
export {
|
|
49
|
+
export {
|
|
50
|
+
Audio
|
|
51
|
+
};
|
|
55
52
|
//# sourceMappingURL=audio.js.map
|
package/dist/audio/audio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio.js","sources":["../../src/audio/audio.ts"],"sourcesContent":["import { mergeAttributes, Node } from
|
|
1
|
+
{"version":3,"file":"audio.js","sources":["../../src/audio/audio.ts"],"sourcesContent":["import { mergeAttributes, Node } from \"@tiptap/core\";\n\nexport interface AudioOptions {\n url: string;\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n audio: {\n /**\n * Set a audio node\n * @param options.updateSelection set to true will select the newly inserted content\n */\n setAudio: (\n id: string,\n src: string,\n options?: { updateSelection: boolean },\n ) => ReturnType;\n };\n }\n}\n\nexport const Audio = Node.create({\n name: \"audio\",\n\n group: \"block\",\n\n addAttributes() {\n return {\n src: {\n default: null,\n parseHTML: (el: any) => (el as HTMLSpanElement).getAttribute(\"src\"),\n renderHTML: (attrs: any) => ({ src: attrs.src }),\n },\n documentId: {\n default: \"\",\n renderHTML: (attributes: any) => {\n return { \"data-document-id\": attributes.documentId };\n },\n parseHTML: (element: any) => element.getAttribute(\"data-document-id\"),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"div.audio-wrapper>audio,audio\",\n getAttrs: (el: any) => ({\n src: (el as HTMLAudioElement).getAttribute(\"src\"),\n }),\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"div\",\n { class: \"audio-wrapper\" },\n [\"audio\", mergeAttributes(HTMLAttributes)],\n ];\n },\n\n addCommands() {\n return {\n setAudio:\n (id, src, options) =>\n ({ commands, state }) => {\n return commands.insertContentAt(\n state.selection,\n `<audio \n src=\"${src}\" \n controls preload=\"none\"\n data-document-id=\"${id}\"></audio>`,\n options,\n );\n },\n };\n },\n});\n"],"names":[],"mappings":";AAuBa,MAAA,QAAQ,KAAK,OAAO;AAAA,EAC/B,MAAM;AAAA,EAEN,OAAO;AAAA,EAEP,gBAAgB;AACP,WAAA;AAAA,MACL,KAAK;AAAA,QACH,SAAS;AAAA,QACT,WAAW,CAAC,OAAa,GAAuB,aAAa,KAAK;AAAA,QAClE,YAAY,CAAC,WAAgB,EAAE,KAAK,MAAM,IAAI;AAAA,MAChD;AAAA,MACA,YAAY;AAAA,QACV,SAAS;AAAA,QACT,YAAY,CAAC,gBACJ,EAAE,oBAAoB,WAAW,WAAW;AAAA,QAErD,WAAW,CAAC,YAAiB,QAAQ,aAAa,kBAAkB;AAAA,MAAA;AAAA,IAExE;AAAA,EACF;AAAA,EAEA,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,QACL,UAAU,CAAC,QAAa;AAAA,UACtB,KAAM,GAAwB,aAAa,KAAK;AAAA,QAClD;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,kBAAkB;AACtB,WAAA;AAAA,MACL;AAAA,MACA,EAAE,OAAO,gBAAgB;AAAA,MACzB,CAAC,SAAS,gBAAgB,cAAc,CAAC;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,UACE,CAAC,IAAI,KAAK,YACV,CAAC,EAAE,UAAU,YACJ,SAAS;AAAA,QACd,MAAM;AAAA,QACN;AAAA,qBACS,GAAG;AAAA;AAAA,kCAEU,EAAE;AAAA,QACxB;AAAA,MACF;AAAA,IAEN;AAAA,EAAA;AAEJ,CAAC;"}
|
|
@@ -1,49 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
require('@tiptap/extension-text-style');
|
|
4
|
-
const core = require('@tiptap/core'),
|
|
5
|
-
FontSize = core.Extension.create({
|
|
6
|
-
name: 'fontSize',
|
|
7
|
-
addOptions() {
|
|
8
|
-
return { types: ['textStyle'] };
|
|
9
|
-
},
|
|
10
|
-
addGlobalAttributes() {
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
types: this.options.types,
|
|
14
|
-
attributes: {
|
|
15
|
-
fontSize: {
|
|
16
|
-
default: null,
|
|
17
|
-
parseHTML: (element) => {
|
|
18
|
-
var _a;
|
|
19
|
-
return (_a = element.style.fontSize) == null
|
|
20
|
-
? void 0
|
|
21
|
-
: _a.replace(/['"]+/g, '');
|
|
22
|
-
},
|
|
23
|
-
renderHTML: (attributes) =>
|
|
24
|
-
attributes.fontSize
|
|
25
|
-
? { style: `font-size: ${attributes.fontSize}` }
|
|
26
|
-
: {},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
addCommands() {
|
|
33
|
-
return {
|
|
34
|
-
setFontSize:
|
|
35
|
-
(fontSize) =>
|
|
36
|
-
({ chain }) =>
|
|
37
|
-
chain().setMark('textStyle', { fontSize }).run(),
|
|
38
|
-
unsetFontSize:
|
|
39
|
-
() =>
|
|
40
|
-
({ chain }) =>
|
|
41
|
-
chain()
|
|
42
|
-
.setMark('textStyle', { fontSize: null })
|
|
43
|
-
.removeEmptyTextStyle()
|
|
44
|
-
.run(),
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
exports.FontSize = FontSize;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@tiptap/extension-text-style");const core=require("@tiptap/core"),FontSize=core.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:element=>{var _a;return(_a=element.style.fontSize)==null?void 0:_a.replace(/['"]+/g,"")},renderHTML:attributes=>attributes.fontSize?{style:`font-size: ${attributes.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:fontSize=>({chain})=>chain().setMark("textStyle",{fontSize}).run(),unsetFontSize:()=>({chain})=>chain().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}});exports.FontSize=FontSize;
|
|
49
2
|
//# sourceMappingURL=font-size.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-size.cjs","sources":["../../src/font-size/font-size.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"font-size.cjs","sources":["../../src/font-size/font-size.ts"],"sourcesContent":["import \"@tiptap/extension-text-style\";\n\nimport { Extension } from \"@tiptap/core\";\n\nexport type FontSizeOptions = {\n types: string[];\n};\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n fontSize: {\n /**\n * Set the font size\n */\n setFontSize: (fontSize: string) => ReturnType;\n /**\n * Unset the font size\n */\n unsetFontSize: () => ReturnType;\n };\n }\n}\n\nexport const FontSize = Extension.create<FontSizeOptions>({\n name: \"fontSize\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontSize: {\n default: null,\n parseHTML: (element) =>\n element.style.fontSize?.replace(/['\"]+/g, \"\"),\n renderHTML: (attributes) => {\n if (!attributes.fontSize) {\n return {};\n }\n\n return {\n style: `font-size: ${attributes.fontSize}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setFontSize:\n (fontSize) =>\n ({ chain }) => {\n return chain().setMark(\"textStyle\", { fontSize }).run();\n },\n unsetFontSize:\n () =>\n ({ chain }) => {\n return chain()\n .setMark(\"textStyle\", { fontSize: null })\n .removeEmptyTextStyle()\n .run();\n },\n };\n },\n});\n"],"names":["Extension"],"mappings":"2JAuBa,SAAWA,eAAU,OAAwB,CACxD,KAAM,WAEN,YAAa,CACJ,MAAA,CACL,MAAO,CAAC,WAAW,CACrB,CACF,EAEA,qBAAsB,CACb,MAAA,CACL,CACE,MAAO,KAAK,QAAQ,MACpB,WAAY,CACV,SAAU,CACR,QAAS,KACT,UAAY,SACV,QAAA,kBAAQ,MAAM,WAAd,eAAwB,QAAQ,SAAU,KAC5C,WAAa,YACN,WAAW,SAIT,CACL,MAAO,cAAc,WAAW,QAAQ,EAC1C,EALS,CAAC,CAMZ,CACF,CACF,CAEJ,CACF,EAEA,aAAc,CACL,MAAA,CACL,YACG,UACD,CAAC,CAAE,SACM,QAAQ,QAAQ,YAAa,CAAE,QAAS,CAAC,EAAE,IAAI,EAE1D,cACE,IACA,CAAC,CAAE,SACM,MAAA,EACJ,QAAQ,YAAa,CAAE,SAAU,KAAM,EACvC,qBAAqB,EACrB,IAAI,CAEb,CAAA,CAEJ,CAAC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/core';
|
|
2
2
|
export type FontSizeOptions = {
|
|
3
|
-
|
|
3
|
+
types: string[];
|
|
4
4
|
};
|
|
5
|
-
declare module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
declare module "@tiptap/core" {
|
|
6
|
+
interface Commands<ReturnType> {
|
|
7
|
+
fontSize: {
|
|
8
|
+
/**
|
|
9
|
+
* Set the font size
|
|
10
|
+
*/
|
|
11
|
+
setFontSize: (fontSize: string) => ReturnType;
|
|
12
|
+
/**
|
|
13
|
+
* Unset the font size
|
|
14
|
+
*/
|
|
15
|
+
unsetFontSize: () => ReturnType;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
18
|
}
|
|
19
19
|
export declare const FontSize: Extension<FontSizeOptions, any>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Extension } from
|
|
1
|
+
import "@tiptap/extension-text-style";
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
3
|
const FontSize = Extension.create({
|
|
4
|
-
name:
|
|
4
|
+
name: "fontSize",
|
|
5
5
|
addOptions() {
|
|
6
6
|
return {
|
|
7
|
-
types: [
|
|
7
|
+
types: ["textStyle"]
|
|
8
8
|
};
|
|
9
9
|
},
|
|
10
10
|
addGlobalAttributes() {
|
|
@@ -16,36 +16,24 @@ const FontSize = Extension.create({
|
|
|
16
16
|
default: null,
|
|
17
17
|
parseHTML: (element) => {
|
|
18
18
|
var _a;
|
|
19
|
-
return (_a = element.style.fontSize) == null
|
|
20
|
-
? void 0
|
|
21
|
-
: _a.replace(/['"]+/g, '');
|
|
19
|
+
return (_a = element.style.fontSize) == null ? void 0 : _a.replace(/['"]+/g, "");
|
|
22
20
|
},
|
|
23
|
-
renderHTML: (attributes) =>
|
|
24
|
-
attributes.fontSize
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
21
|
+
renderHTML: (attributes) => attributes.fontSize ? {
|
|
22
|
+
style: `font-size: ${attributes.fontSize}`
|
|
23
|
+
} : {}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
32
27
|
];
|
|
33
28
|
},
|
|
34
29
|
addCommands() {
|
|
35
30
|
return {
|
|
36
|
-
setFontSize:
|
|
37
|
-
|
|
38
|
-
({ chain }) =>
|
|
39
|
-
chain().setMark('textStyle', { fontSize }).run(),
|
|
40
|
-
unsetFontSize:
|
|
41
|
-
() =>
|
|
42
|
-
({ chain }) =>
|
|
43
|
-
chain()
|
|
44
|
-
.setMark('textStyle', { fontSize: null })
|
|
45
|
-
.removeEmptyTextStyle()
|
|
46
|
-
.run(),
|
|
31
|
+
setFontSize: (fontSize) => ({ chain }) => chain().setMark("textStyle", { fontSize }).run(),
|
|
32
|
+
unsetFontSize: () => ({ chain }) => chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
|
|
47
33
|
};
|
|
48
|
-
}
|
|
34
|
+
}
|
|
49
35
|
});
|
|
50
|
-
export {
|
|
36
|
+
export {
|
|
37
|
+
FontSize
|
|
38
|
+
};
|
|
51
39
|
//# sourceMappingURL=font-size.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-size.js","sources":["../../src/font-size/font-size.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"font-size.js","sources":["../../src/font-size/font-size.ts"],"sourcesContent":["import \"@tiptap/extension-text-style\";\n\nimport { Extension } from \"@tiptap/core\";\n\nexport type FontSizeOptions = {\n types: string[];\n};\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n fontSize: {\n /**\n * Set the font size\n */\n setFontSize: (fontSize: string) => ReturnType;\n /**\n * Unset the font size\n */\n unsetFontSize: () => ReturnType;\n };\n }\n}\n\nexport const FontSize = Extension.create<FontSizeOptions>({\n name: \"fontSize\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontSize: {\n default: null,\n parseHTML: (element) =>\n element.style.fontSize?.replace(/['\"]+/g, \"\"),\n renderHTML: (attributes) => {\n if (!attributes.fontSize) {\n return {};\n }\n\n return {\n style: `font-size: ${attributes.fontSize}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setFontSize:\n (fontSize) =>\n ({ chain }) => {\n return chain().setMark(\"textStyle\", { fontSize }).run();\n },\n unsetFontSize:\n () =>\n ({ chain }) => {\n return chain()\n .setMark(\"textStyle\", { fontSize: null })\n .removeEmptyTextStyle()\n .run();\n },\n };\n },\n});\n"],"names":[],"mappings":";;AAuBa,MAAA,WAAW,UAAU,OAAwB;AAAA,EACxD,MAAM;AAAA,EAEN,aAAa;AACJ,WAAA;AAAA,MACL,OAAO,CAAC,WAAW;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,sBAAsB;AACb,WAAA;AAAA,MACL;AAAA,QACE,OAAO,KAAK,QAAQ;AAAA,QACpB,YAAY;AAAA,UACV,UAAU;AAAA,YACR,SAAS;AAAA,YACT,WAAW,CAAC,YACV;;AAAA,mCAAQ,MAAM,aAAd,mBAAwB,QAAQ,UAAU;AAAA;AAAA,YAC5C,YAAY,CAAC,eACN,WAAW,WAIT;AAAA,cACL,OAAO,cAAc,WAAW,QAAQ;AAAA,YAC1C,IALS,CAAC;AAAA,UAMZ;AAAA,QACF;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,aACE,CAAC,aACD,CAAC,EAAE,YACM,QAAQ,QAAQ,aAAa,EAAE,SAAS,CAAC,EAAE,IAAI;AAAA,MAE1D,eACE,MACA,CAAC,EAAE,YACM,MAAA,EACJ,QAAQ,aAAa,EAAE,UAAU,MAAM,EACvC,qBAAqB,EACrB,IAAI;AAAA,IAEb;AAAA,EAAA;AAEJ,CAAC;"}
|
package/dist/heading/heading.cjs
CHANGED
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core'),
|
|
4
|
-
extensionHeading = require('@tiptap/extension-heading');
|
|
5
|
-
require('@tiptap/extension-text-style');
|
|
6
|
-
const CustomHeading = extensionHeading.Heading.extend({
|
|
7
|
-
name: 'customHeading',
|
|
8
|
-
addOptions() {
|
|
9
|
-
var _a;
|
|
10
|
-
return {
|
|
11
|
-
...((_a = this.parent) == null ? void 0 : _a.call(this)),
|
|
12
|
-
HTMLAttributes: {},
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
parseHTML() {
|
|
16
|
-
return this.options.levels.map((level) => ({
|
|
17
|
-
tag: `h${level}`,
|
|
18
|
-
attrs: { level },
|
|
19
|
-
}));
|
|
20
|
-
},
|
|
21
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
22
|
-
return [
|
|
23
|
-
`h${
|
|
24
|
-
this.options.levels.includes(node.attrs.level)
|
|
25
|
-
? node.attrs.level
|
|
26
|
-
: this.options.levels[0]
|
|
27
|
-
}`,
|
|
28
|
-
core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
29
|
-
0,
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
addCommands() {
|
|
33
|
-
return {
|
|
34
|
-
setCustomHeading:
|
|
35
|
-
(attributes) =>
|
|
36
|
-
({ tr, dispatch, commands }) => {
|
|
37
|
-
if (!this.options.levels.includes(attributes.level)) return !1;
|
|
38
|
-
const { selection } = tr,
|
|
39
|
-
{ from, to } = selection;
|
|
40
|
-
return (
|
|
41
|
-
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
42
|
-
node.isBlock &&
|
|
43
|
-
from >= pos &&
|
|
44
|
-
to <= pos + node.nodeSize &&
|
|
45
|
-
node.content.forEach((content) => {
|
|
46
|
-
content.marks.forEach((mark) => {
|
|
47
|
-
mark.type.name === 'textStyle' &&
|
|
48
|
-
mark.attrs.fontSize &&
|
|
49
|
-
mark.attrs.fontSize !== null &&
|
|
50
|
-
(tr = tr.removeMark(pos, pos + node.nodeSize, mark.type));
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}),
|
|
54
|
-
dispatch && dispatch(tr),
|
|
55
|
-
commands.setHeading({ level: attributes.level })
|
|
56
|
-
);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
exports.CustomHeading = CustomHeading;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),extensionHeading=require("@tiptap/extension-heading");require("@tiptap/extension-text-style");const CustomHeading=extensionHeading.Heading.extend({name:"customHeading",addOptions(){var _a;return{...(_a=this.parent)==null?void 0:_a.call(this),HTMLAttributes:{}}},parseHTML(){return this.options.levels.map(level=>({tag:`h${level}`,attrs:{level}}))},renderHTML({node,HTMLAttributes}){return[`h${this.options.levels.includes(node.attrs.level)?node.attrs.level:this.options.levels[0]}`,core.mergeAttributes(this.options.HTMLAttributes,HTMLAttributes),0]},addCommands(){return{setCustomHeading:attributes=>({tr,dispatch,commands})=>{if(!this.options.levels.includes(attributes.level))return!1;const{selection}=tr,{from,to}=selection;return tr.doc.nodesBetween(from,to,(node,pos)=>{node.isBlock&&from>=pos&&to<=pos+node.nodeSize&&node.content.forEach(content=>{content.marks.forEach(mark=>{mark.type.name==="textStyle"&&mark.attrs.fontSize&&mark.attrs.fontSize!==null&&(tr=tr.removeMark(pos,pos+node.nodeSize,mark.type))})})}),dispatch&&dispatch(tr),commands.setHeading({level:attributes.level})}}}});exports.CustomHeading=CustomHeading;
|
|
62
2
|
//# sourceMappingURL=heading.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.cjs","sources":["../../src/heading/heading.ts"],"sourcesContent":["import { mergeAttributes } from
|
|
1
|
+
{"version":3,"file":"heading.cjs","sources":["../../src/heading/heading.ts"],"sourcesContent":["import { mergeAttributes } from \"@tiptap/core\";\nimport { Heading } from \"@tiptap/extension-heading\";\nimport \"@tiptap/extension-text-style\";\n\nexport declare type Level = 1 | 2;\n\ninterface Options {\n levels: Level[];\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n customHeading: {\n /**\n * Apply Heading Level\n */\n setCustomHeading: (attributes: { level: Level }) => ReturnType;\n };\n }\n}\n\nexport const CustomHeading = Heading.extend<Options>({\n name: \"customHeading\",\n\n addOptions() {\n return {\n ...this.parent?.(),\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return this.options.levels.map((level: Level) => ({\n tag: `h${level}`,\n attrs: { level },\n }));\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const hasLevel = this.options.levels.includes(node.attrs.level);\n const level = hasLevel ? node.attrs.level : this.options.levels[0];\n\n return [\n `h${level}`,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setCustomHeading:\n (attributes) =>\n ({ tr, dispatch, commands }) => {\n if (!this.options.levels.includes(attributes.level)) {\n return false;\n }\n\n const { selection } = tr;\n const { from, to } = selection;\n\n tr.doc.nodesBetween(from, to, (node, pos) => {\n if (node.isBlock && from >= pos && to <= pos + node.nodeSize) {\n /* get node content and iterate through */\n node.content.forEach((content) => {\n /* get content marks and iterate through */\n content.marks.forEach((mark) => {\n /* find textStyle mark and if has fontSize attrs */\n if (\n mark.type.name === \"textStyle\" &&\n mark.attrs[\"fontSize\"] &&\n mark.attrs[\"fontSize\"] !== null\n ) {\n /* remove any fontSize attr to reset heading style */\n tr = tr.removeMark(pos, pos + node.nodeSize, mark.type);\n }\n });\n });\n }\n });\n\n if (dispatch) {\n dispatch(tr);\n }\n return commands.setHeading({ level: attributes.level });\n },\n };\n },\n});\n"],"names":["Heading","mergeAttributes"],"mappings":"iNAsBa,MAAA,cAAgBA,yBAAQ,OAAgB,CACnD,KAAM,gBAEN,YAAa,QACJ,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,eAAgB,CAAA,CAClB,CACF,EAEA,WAAY,CACV,OAAO,KAAK,QAAQ,OAAO,IAAK,QAAkB,CAChD,IAAK,IAAI,KAAK,GACd,MAAO,CAAE,KAAM,CAAA,EACf,CACJ,EAEA,WAAW,CAAE,KAAM,gBAAkB,CAI5B,MAAA,CACL,IAJe,KAAK,QAAQ,OAAO,SAAS,KAAK,MAAM,KAAK,EACrC,KAAK,MAAM,MAAQ,KAAK,QAAQ,OAAO,CAAC,CAGtD,GACTC,KAAAA,gBAAgB,KAAK,QAAQ,eAAgB,cAAc,EAC3D,CACF,CACF,EAEA,aAAc,CACL,MAAA,CACL,iBACG,YACD,CAAC,CAAE,GAAI,SAAU,YAAe,CAC9B,GAAI,CAAC,KAAK,QAAQ,OAAO,SAAS,WAAW,KAAK,EACzC,MAAA,GAGH,KAAA,CAAE,WAAc,GAChB,CAAE,KAAM,EAAA,EAAO,UAErB,UAAG,IAAI,aAAa,KAAM,GAAI,CAAC,KAAM,MAAQ,CACvC,KAAK,SAAW,MAAQ,KAAO,IAAM,IAAM,KAAK,UAE7C,KAAA,QAAQ,QAAS,SAAY,CAExB,QAAA,MAAM,QAAS,MAAS,CAG5B,KAAK,KAAK,OAAS,aACnB,KAAK,MAAM,UACX,KAAK,MAAM,WAAgB,OAG3B,GAAK,GAAG,WAAW,IAAK,IAAM,KAAK,SAAU,KAAK,IAAI,EACxD,CACD,CAAA,CACF,CACH,CACD,EAEG,UACF,SAAS,EAAE,EAEN,SAAS,WAAW,CAAE,MAAO,WAAW,MAAO,CAAA,CAE5D,CAAA,CAEJ,CAAC"}
|