@edifice.io/tiptap-extensions 2.0.0-develop-rc.12 → 2.0.0-develop-rc.13
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 +1 -1
- package/dist/abbr/abbr.cjs +32 -1
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.d.ts +12 -12
- package/dist/abbr/abbr.js +20 -16
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/alert/alert.cjs +32 -1
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +22 -24
- package/dist/alert/alert.js.map +1 -1
- package/dist/attachment/attachment.cjs +73 -1
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.d.ts +6 -6
- package/dist/attachment/attachment.js +58 -47
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/audio/audio.cjs +53 -3
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.d.ts +17 -13
- package/dist/audio/audio.js +33 -30
- package/dist/audio/audio.js.map +1 -1
- package/dist/font-size/font-size.cjs +48 -1
- package/dist/font-size/font-size.cjs.map +1 -1
- package/dist/font-size/font-size.d.ts +13 -13
- package/dist/font-size/font-size.js +32 -20
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/heading/heading.cjs +61 -1
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.d.ts +10 -12
- package/dist/heading/heading.js +45 -31
- package/dist/heading/heading.js.map +1 -1
- package/dist/highlight/highlight.cjs +25 -1
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.d.ts +4 -1
- package/dist/highlight/highlight.js +15 -17
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/hyperlink/hyperlink.cjs +47 -1
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.d.ts +27 -24
- package/dist/hyperlink/hyperlink.js +26 -24
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/iframe/iframe.cjs +69 -1
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.d.ts +12 -14
- package/dist/iframe/iframe.js +50 -34
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/image/custom-image.cjs +162 -1
- package/dist/image/custom-image.cjs.map +1 -1
- package/dist/image/custom-image.d.ts +19 -16
- package/dist/image/custom-image.js +179 -130
- package/dist/image/custom-image.js.map +1 -1
- package/dist/index.cjs +43 -1
- package/dist/index.js +41 -41
- package/dist/line-height/line-height.cjs +33 -1
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +21 -18
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/linker/linker.cjs +95 -1
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.d.ts +17 -17
- package/dist/linker/linker.js +60 -52
- package/dist/linker/linker.js.map +1 -1
- package/dist/mathjax/mathjax.cjs +47 -1
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +33 -23
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/paragraph/paragraph.cjs +13 -1
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.d.ts +4 -1
- package/dist/paragraph/paragraph.js +8 -10
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/speech-recognition/speech-recognition.cjs +76 -1
- package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
- package/dist/speech-recognition/speech-recognition.d.ts +12 -12
- package/dist/speech-recognition/speech-recognition.js +61 -45
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +32 -1
- package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.d.ts +9 -9
- package/dist/speech-synthesis/speech-synthesis.js +23 -14
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +27 -1
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.d.ts +4 -1
- package/dist/table-cell/table-cell.js +21 -16
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs +4 -1
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.d.ts +4 -1
- package/dist/transform/html-to-json/html-to-json.js +3 -5
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +4 -1
- package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
- package/dist/transform/json-to-html/json-to-html.js +3 -5
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +118 -9
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +28 -19
- package/dist/video/video.js +121 -97
- package/dist/video/video.js.map +1 -1
- package/package.json +36 -47
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 '@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":["
|
|
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,aAE1C,UAAY,SAAiB,QAAQ,aAAa,kBAAkB,CACtE,CAAA,CAEJ,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,gCACL,SAAW,KAAa,CACtB,IAAM,GAAwB,aAAa,KAAK,CAAA,EAEpD,CAAA,CAEJ,EAEA,WAAW,CAAE,gBAAkB,CACtB,MAAA,CACL,MACA,CAAE,MAAO,eAAgB,EACzB,CAAC,QAASC,qBAAgB,cAAc,CAAC,CAAA,CAE7C,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,OAAA,CAEJ,CAEN,CACF,CAAC"}
|
package/dist/audio/audio.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
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
6
|
declare module '@tiptap/core' {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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: (
|
|
14
|
+
id: string,
|
|
15
|
+
src: string,
|
|
16
|
+
options?: {
|
|
17
|
+
updateSelection: boolean;
|
|
18
|
+
},
|
|
19
|
+
) => ReturnType;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
export declare const Audio: Node<any, any>;
|
package/dist/audio/audio.js
CHANGED
|
@@ -1,52 +1,55 @@
|
|
|
1
|
-
import { Node
|
|
2
|
-
const
|
|
3
|
-
name:
|
|
4
|
-
group:
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
const Audio = Node.create({
|
|
3
|
+
name: 'audio',
|
|
4
|
+
group: 'block',
|
|
5
5
|
addAttributes() {
|
|
6
6
|
return {
|
|
7
7
|
src: {
|
|
8
8
|
default: null,
|
|
9
|
-
parseHTML: (
|
|
10
|
-
renderHTML: (
|
|
9
|
+
parseHTML: (el) => el.getAttribute('src'),
|
|
10
|
+
renderHTML: (attrs) => ({ src: attrs.src }),
|
|
11
11
|
},
|
|
12
12
|
documentId: {
|
|
13
|
-
default:
|
|
14
|
-
renderHTML: (
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
default: '',
|
|
14
|
+
renderHTML: (attributes) => ({
|
|
15
|
+
'data-document-id': attributes.documentId,
|
|
16
|
+
}),
|
|
17
|
+
parseHTML: (element) => element.getAttribute('data-document-id'),
|
|
18
|
+
},
|
|
17
19
|
};
|
|
18
20
|
},
|
|
19
21
|
parseHTML() {
|
|
20
22
|
return [
|
|
21
23
|
{
|
|
22
|
-
tag:
|
|
23
|
-
getAttrs: (
|
|
24
|
-
src:
|
|
25
|
-
})
|
|
26
|
-
}
|
|
24
|
+
tag: 'div.audio-wrapper>audio,audio',
|
|
25
|
+
getAttrs: (el) => ({
|
|
26
|
+
src: el.getAttribute('src'),
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
27
29
|
];
|
|
28
30
|
},
|
|
29
|
-
renderHTML({ HTMLAttributes
|
|
31
|
+
renderHTML({ HTMLAttributes }) {
|
|
30
32
|
return [
|
|
31
|
-
|
|
32
|
-
{ class:
|
|
33
|
-
[
|
|
33
|
+
'div',
|
|
34
|
+
{ class: 'audio-wrapper' },
|
|
35
|
+
['audio', mergeAttributes(HTMLAttributes)],
|
|
34
36
|
];
|
|
35
37
|
},
|
|
36
38
|
addCommands() {
|
|
37
39
|
return {
|
|
38
|
-
setAudio:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
setAudio:
|
|
41
|
+
(id, src, options) =>
|
|
42
|
+
({ commands, state }) =>
|
|
43
|
+
commands.insertContentAt(
|
|
44
|
+
state.selection,
|
|
45
|
+
`<audio
|
|
46
|
+
src="${src}"
|
|
42
47
|
controls preload="none"
|
|
43
|
-
data-document-id="${
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
data-document-id="${id}"></audio>`,
|
|
49
|
+
options,
|
|
50
|
+
),
|
|
46
51
|
};
|
|
47
|
-
}
|
|
52
|
+
},
|
|
48
53
|
});
|
|
49
|
-
export {
|
|
50
|
-
i as Audio
|
|
51
|
-
};
|
|
54
|
+
export { Audio };
|
|
52
55
|
//# 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 '@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":[
|
|
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;QAE1C,WAAW,CAAC,YAAiB,QAAQ,aAAa,kBAAkB;AAAA,MACtE;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,QACL,UAAU,CAAC,QAAa;AAAA,UACtB,KAAM,GAAwB,aAAa,KAAK;AAAA,QAAA;AAAA,MAEpD;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,WAAW,EAAE,kBAAkB;AACtB,WAAA;AAAA,MACL;AAAA,MACA,EAAE,OAAO,gBAAgB;AAAA,MACzB,CAAC,SAAS,gBAAgB,cAAc,CAAC;AAAA,IAAA;AAAA,EAE7C;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,MAAA;AAAA,IAEJ;AAAA,EAEN;AACF,CAAC;"}
|
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
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;
|
|
2
49
|
//# sourceMappingURL=font-size.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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,CAAA,CAEvB,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,EAAA,EAJjC,EAOb,CACF,CACF,CAAA,CAEJ,EAEA,aAAc,CACL,MAAA,CACL,YACG,UACD,CAAC,CAAE,SACM,QAAQ,QAAQ,YAAa,CAAE,QAAU,CAAA,EAAE,MAEtD,cACE,IACA,CAAC,CAAE,SACM,MACJ,EAAA,QAAQ,YAAa,CAAE,SAAU,IAAA,CAAM,EACvC,uBACA,KACL,CAEN,CACF,CAAC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/core';
|
|
2
2
|
export type FontSizeOptions = {
|
|
3
|
-
|
|
3
|
+
types: string[];
|
|
4
4
|
};
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
3
|
-
const
|
|
4
|
-
name:
|
|
1
|
+
import '@tiptap/extension-text-style';
|
|
2
|
+
import { Extension } from '@tiptap/core';
|
|
3
|
+
const FontSize = Extension.create({
|
|
4
|
+
name: 'fontSize',
|
|
5
5
|
addOptions() {
|
|
6
6
|
return {
|
|
7
|
-
types: [
|
|
7
|
+
types: ['textStyle'],
|
|
8
8
|
};
|
|
9
9
|
},
|
|
10
10
|
addGlobalAttributes() {
|
|
@@ -14,26 +14,38 @@ const i = n.create({
|
|
|
14
14
|
attributes: {
|
|
15
15
|
fontSize: {
|
|
16
16
|
default: null,
|
|
17
|
-
parseHTML: (
|
|
18
|
-
var
|
|
19
|
-
return (
|
|
17
|
+
parseHTML: (element) => {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = element.style.fontSize) == null
|
|
20
|
+
? void 0
|
|
21
|
+
: _a.replace(/['"]+/g, '');
|
|
20
22
|
},
|
|
21
|
-
renderHTML: (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
renderHTML: (attributes) =>
|
|
24
|
+
attributes.fontSize
|
|
25
|
+
? {
|
|
26
|
+
style: `font-size: ${attributes.fontSize}`,
|
|
27
|
+
}
|
|
28
|
+
: {},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
27
32
|
];
|
|
28
33
|
},
|
|
29
34
|
addCommands() {
|
|
30
35
|
return {
|
|
31
|
-
setFontSize:
|
|
32
|
-
|
|
36
|
+
setFontSize:
|
|
37
|
+
(fontSize) =>
|
|
38
|
+
({ chain }) =>
|
|
39
|
+
chain().setMark('textStyle', { fontSize }).run(),
|
|
40
|
+
unsetFontSize:
|
|
41
|
+
() =>
|
|
42
|
+
({ chain }) =>
|
|
43
|
+
chain()
|
|
44
|
+
.setMark('textStyle', { fontSize: null })
|
|
45
|
+
.removeEmptyTextStyle()
|
|
46
|
+
.run(),
|
|
33
47
|
};
|
|
34
|
-
}
|
|
48
|
+
},
|
|
35
49
|
});
|
|
36
|
-
export {
|
|
37
|
-
i as FontSize
|
|
38
|
-
};
|
|
50
|
+
export { FontSize };
|
|
39
51
|
//# sourceMappingURL=font-size.js.map
|
|
@@ -1 +1 @@
|
|
|
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":[
|
|
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,IAAA;AAAA,EAEvB;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,YAAA,IAJjC;UAOb;AAAA,QACF;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,aACE,CAAC,aACD,CAAC,EAAE,YACM,QAAQ,QAAQ,aAAa,EAAE,SAAU,CAAA,EAAE;MAEtD,eACE,MACA,CAAC,EAAE,YACM,MACJ,EAAA,QAAQ,aAAa,EAAE,UAAU,KAAA,CAAM,EACvC,uBACA;IACL;AAAA,EAEN;AACF,CAAC;"}
|
package/dist/heading/heading.cjs
CHANGED
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
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;
|
|
2
62
|
//# sourceMappingURL=heading.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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,CAAC,CAAA,CAErB,EAEA,WAAY,CACV,OAAO,KAAK,QAAQ,OAAO,IAAK,QAAkB,CAChD,IAAK,IAAI,KAAK,GACd,MAAO,CAAE,KAAM,CACf,EAAA,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,CAAA,CAEJ,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,SAAc,EAAA,GAChB,CAAE,KAAM,EAAO,EAAA,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,CACxD,CAAA,CAEN,CACF,CAAC"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
export declare type Level = 1 | 2;
|
|
2
2
|
interface Options {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
levels: Level[];
|
|
4
|
+
HTMLAttributes: Record<string, any>;
|
|
5
5
|
}
|
|
6
6
|
declare module '@tiptap/core' {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
}
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
customHeading: {
|
|
9
|
+
/**
|
|
10
|
+
* Apply Heading Level
|
|
11
|
+
*/
|
|
12
|
+
setCustomHeading: (attributes: { level: Level }) => ReturnType;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
17
15
|
}
|
|
18
16
|
export declare const CustomHeading: import('@tiptap/core').Node<Options, any>;
|
|
19
17
|
export {};
|
package/dist/heading/heading.js
CHANGED
|
@@ -1,46 +1,60 @@
|
|
|
1
|
-
import { mergeAttributes
|
|
2
|
-
import { Heading
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
name:
|
|
1
|
+
import { mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { Heading } from '@tiptap/extension-heading';
|
|
3
|
+
import '@tiptap/extension-text-style';
|
|
4
|
+
const CustomHeading = Heading.extend({
|
|
5
|
+
name: 'customHeading',
|
|
6
6
|
addOptions() {
|
|
7
|
-
var
|
|
7
|
+
var _a;
|
|
8
8
|
return {
|
|
9
|
-
...(
|
|
10
|
-
HTMLAttributes: {}
|
|
9
|
+
...((_a = this.parent) == null ? void 0 : _a.call(this)),
|
|
10
|
+
HTMLAttributes: {},
|
|
11
11
|
};
|
|
12
12
|
},
|
|
13
13
|
parseHTML() {
|
|
14
|
-
return this.options.levels.map((
|
|
15
|
-
tag: `h${
|
|
16
|
-
attrs: { level
|
|
14
|
+
return this.options.levels.map((level) => ({
|
|
15
|
+
tag: `h${level}`,
|
|
16
|
+
attrs: { level },
|
|
17
17
|
}));
|
|
18
18
|
},
|
|
19
|
-
renderHTML({ node
|
|
19
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
20
20
|
return [
|
|
21
|
-
`h${
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
`h${
|
|
22
|
+
this.options.levels.includes(node.attrs.level)
|
|
23
|
+
? node.attrs.level
|
|
24
|
+
: this.options.levels[0]
|
|
25
|
+
}`,
|
|
26
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
27
|
+
0,
|
|
24
28
|
];
|
|
25
29
|
},
|
|
26
30
|
addCommands() {
|
|
27
31
|
return {
|
|
28
|
-
setCustomHeading:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
setCustomHeading:
|
|
33
|
+
(attributes) =>
|
|
34
|
+
({ tr, dispatch, commands }) => {
|
|
35
|
+
if (!this.options.levels.includes(attributes.level)) return !1;
|
|
36
|
+
const { selection } = tr,
|
|
37
|
+
{ from, to } = selection;
|
|
38
|
+
return (
|
|
39
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
40
|
+
node.isBlock &&
|
|
41
|
+
from >= pos &&
|
|
42
|
+
to <= pos + node.nodeSize &&
|
|
43
|
+
node.content.forEach((content) => {
|
|
44
|
+
content.marks.forEach((mark) => {
|
|
45
|
+
mark.type.name === 'textStyle' &&
|
|
46
|
+
mark.attrs.fontSize &&
|
|
47
|
+
mark.attrs.fontSize !== null &&
|
|
48
|
+
(tr = tr.removeMark(pos, pos + node.nodeSize, mark.type));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}),
|
|
52
|
+
dispatch && dispatch(tr),
|
|
53
|
+
commands.setHeading({ level: attributes.level })
|
|
54
|
+
);
|
|
55
|
+
},
|
|
40
56
|
};
|
|
41
|
-
}
|
|
57
|
+
},
|
|
42
58
|
});
|
|
43
|
-
export {
|
|
44
|
-
p as CustomHeading
|
|
45
|
-
};
|
|
59
|
+
export { CustomHeading };
|
|
46
60
|
//# sourceMappingURL=heading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","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":[
|
|
1
|
+
{"version":3,"file":"heading.js","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":[],"mappings":";;;AAsBa,MAAA,gBAAgB,QAAQ,OAAgB;AAAA,EACnD,MAAM;AAAA,EAEN,aAAa;;AACJ,WAAA;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,gBAAgB,CAAC;AAAA,IAAA;AAAA,EAErB;AAAA,EAEA,YAAY;AACV,WAAO,KAAK,QAAQ,OAAO,IAAI,CAAC,WAAkB;AAAA,MAChD,KAAK,IAAI,KAAK;AAAA,MACd,OAAO,EAAE,MAAM;AAAA,IACf,EAAA;AAAA,EACJ;AAAA,EAEA,WAAW,EAAE,MAAM,kBAAkB;AAI5B,WAAA;AAAA,MACL,IAJe,KAAK,QAAQ,OAAO,SAAS,KAAK,MAAM,KAAK,IACrC,KAAK,MAAM,QAAQ,KAAK,QAAQ,OAAO,CAAC,CAGtD;AAAA,MACT,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc;AAAA,MAC3D;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,kBACE,CAAC,eACD,CAAC,EAAE,IAAI,UAAU,eAAe;AAC9B,YAAI,CAAC,KAAK,QAAQ,OAAO,SAAS,WAAW,KAAK;AACzC,iBAAA;AAGH,cAAA,EAAE,UAAc,IAAA,IAChB,EAAE,MAAM,GAAO,IAAA;AAErB,kBAAG,IAAI,aAAa,MAAM,IAAI,CAAC,MAAM,QAAQ;AAC3C,UAAI,KAAK,WAAW,QAAQ,OAAO,MAAM,MAAM,KAAK,YAE7C,KAAA,QAAQ,QAAQ,CAAC,YAAY;AAExB,oBAAA,MAAM,QAAQ,CAAC,SAAS;AAE9B,cACE,KAAK,KAAK,SAAS,eACnB,KAAK,MAAM,YACX,KAAK,MAAM,aAAgB,SAG3B,KAAK,GAAG,WAAW,KAAK,MAAM,KAAK,UAAU,KAAK,IAAI;AAAA,YACxD,CACD;AAAA,UAAA,CACF;AAAA,QACH,CACD,GAEG,YACF,SAAS,EAAE,GAEN,SAAS,WAAW,EAAE,OAAO,WAAW,OAAO;AAAA,MACxD;AAAA,IAAA;AAAA,EAEN;AACF,CAAC;"}
|
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const Highlight = require('@tiptap/extension-highlight'),
|
|
4
|
+
CustomHighlight = Highlight.extend({
|
|
5
|
+
name: 'customHighlight',
|
|
6
|
+
addOptions() {
|
|
7
|
+
var _a;
|
|
8
|
+
return {
|
|
9
|
+
...((_a = this.parent) == null ? void 0 : _a.call(this)),
|
|
10
|
+
multicolor: !0,
|
|
11
|
+
HTMLAttributes: {},
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
parseHTML() {
|
|
15
|
+
var _a;
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
...((_a = this.parent) == null ? void 0 : _a.call(this)),
|
|
19
|
+
style: 'background-color',
|
|
20
|
+
getAttrs: (style) => ({ color: style }),
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
exports.CustomHighlight = CustomHighlight;
|
|
2
26
|
//# sourceMappingURL=highlight.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.cjs","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":[
|
|
1
|
+
{"version":3,"file":"highlight.cjs","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":[],"mappings":"uIAEa,gBAAkB,UAAU,OAAO,CAC9C,KAAM,kBAEN,YAAa,QACJ,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,WAAY,GACZ,eAAgB,CAAC,CAAA,CAErB,EAEA,WAAY,QACH,MAAA,CACL,CACE,IAAG,QAAK,SAAL,0BACH,MAAO,mBACP,SAAW,QACF,CACL,MAAO,KAAA,EAGb,CAAA,CAEJ,CACF,CAAC"}
|