@edifice.io/tiptap-extensions 1.5.16-develop-rc.2 → 1.7.4-develop-pedago.20241211160712
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 +66 -0
- package/dist/abbr/abbr.cjs +1 -32
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.d.ts +12 -12
- 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 +6 -6
- 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 +13 -17
- 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 +13 -13
- 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 +12 -10
- 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 +24 -27
- 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 +14 -12
- 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 +17 -17
- 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 +12 -12
- 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 +9 -9
- 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.d.ts +1 -4
- package/dist/transform/html-to-json/html-to-json.js +4 -2
- package/dist/transform/json-to-html/json-to-html.cjs +1 -4
- package/dist/transform/json-to-html/json-to-html.js +4 -2
- package/dist/video/video.cjs +2 -111
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +19 -28
- package/dist/video/video.js +90 -114
- package/dist/video/video.js.map +1 -1
- package/package.json +27 -16
- package/.turbo/turbo-build.log +0 -58
- package/.turbo/turbo-format.log +0 -142
- package/.turbo/turbo-lint.log +0 -5
- 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/src/abbr/abbr.ts +0 -57
- package/src/abbr/index.ts +0 -5
- package/src/alert/alert.ts +0 -46
- package/src/alert/index.ts +0 -5
- package/src/attachment/attachment.ts +0 -113
- package/src/attachment/index.ts +0 -5
- package/src/audio/audio.ts +0 -81
- package/src/audio/index.ts +0 -5
- package/src/font-size/font-size.ts +0 -74
- package/src/font-size/index.ts +0 -5
- package/src/heading/heading.ts +0 -90
- package/src/heading/index.ts +0 -5
- package/src/highlight/highlight.ts +0 -27
- package/src/highlight/index.ts +0 -5
- package/src/hyperlink/hyperlink.ts +0 -92
- package/src/hyperlink/index.ts +0 -5
- package/src/iframe/iframe.ts +0 -112
- package/src/iframe/index.ts +0 -5
- package/src/image/custom-image.ts +0 -226
- package/src/image/index.ts +0 -5
- package/src/index.ts +0 -19
- package/src/line-height/index.ts +0 -5
- package/src/line-height/line-height.ts +0 -37
- package/src/linker/index.ts +0 -5
- package/src/linker/linker.ts +0 -153
- package/src/mathjax/index.ts +0 -5
- package/src/mathjax/mathjax.ts +0 -55
- package/src/paragraph/index.ts +0 -5
- package/src/paragraph/paragraph.ts +0 -25
- package/src/speech-recognition/index.ts +0 -5
- package/src/speech-recognition/speech-recognition.ts +0 -123
- package/src/speech-synthesis/index.ts +0 -5
- package/src/speech-synthesis/speech-synthesis.ts +0 -52
- package/src/table-cell/index.ts +0 -5
- package/src/table-cell/table-cell.ts +0 -28
- package/src/transform/html-to-json/html-to-json.ts +0 -5
- package/src/transform/index.ts +0 -4
- package/src/transform/json-to-html/json-to-html.ts +0 -5
- package/src/video/index.ts +0 -5
- package/src/video/video.ts +0 -173
- package/tsconfig.json +0 -20
- package/vite.config.ts +0 -46
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
export interface AttachmentOptions {
|
|
4
|
-
HTMLAttributes: Record<string, string>;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare module '@tiptap/core' {
|
|
8
|
-
interface Commands<ReturnType> {
|
|
9
|
-
attachment: {
|
|
10
|
-
setAttachment: (attachment) => ReturnType;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const Attachment = Node.create<AttachmentOptions>({
|
|
16
|
-
name: 'attachments',
|
|
17
|
-
content: '',
|
|
18
|
-
marks: '',
|
|
19
|
-
group: 'block',
|
|
20
|
-
selectable: true,
|
|
21
|
-
atom: true,
|
|
22
|
-
draggable: true,
|
|
23
|
-
|
|
24
|
-
addOptions() {
|
|
25
|
-
return {
|
|
26
|
-
HTMLAttributes: {
|
|
27
|
-
class: 'attachments',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
parseHTML() {
|
|
33
|
-
return [{ tag: 'div[class=attachments]' }];
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
renderHTML({ HTMLAttributes }) {
|
|
37
|
-
const links = HTMLAttributes.links;
|
|
38
|
-
|
|
39
|
-
const renderedLinks = links.map((el) => {
|
|
40
|
-
return [
|
|
41
|
-
'a',
|
|
42
|
-
{
|
|
43
|
-
name: el.name,
|
|
44
|
-
href: el.href,
|
|
45
|
-
documentId: el.documentId,
|
|
46
|
-
dataContentType: el.dataContentType,
|
|
47
|
-
},
|
|
48
|
-
el.name,
|
|
49
|
-
];
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return ['div', this.options.HTMLAttributes, ...renderedLinks];
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
addAttributes() {
|
|
56
|
-
return {
|
|
57
|
-
links: {
|
|
58
|
-
default: [],
|
|
59
|
-
parseHTML: (element) => {
|
|
60
|
-
const links = element.getElementsByTagName('a');
|
|
61
|
-
const parsedLinks = [];
|
|
62
|
-
|
|
63
|
-
for (let i = 0; i < links.length; i++) {
|
|
64
|
-
const link = links[i];
|
|
65
|
-
const href = link.getAttribute('href');
|
|
66
|
-
const name = link.textContent;
|
|
67
|
-
const regexResult = href.match(/([^/]+$)/);
|
|
68
|
-
const documentId =
|
|
69
|
-
link.getAttribute('data-document-id') ||
|
|
70
|
-
(regexResult && regexResult[0]);
|
|
71
|
-
const dataContentType = link.getAttribute('data-content-type');
|
|
72
|
-
|
|
73
|
-
parsedLinks.push({
|
|
74
|
-
href,
|
|
75
|
-
name,
|
|
76
|
-
documentId,
|
|
77
|
-
dataContentType,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return parsedLinks;
|
|
82
|
-
},
|
|
83
|
-
renderHTML: (attributes) => {
|
|
84
|
-
return {
|
|
85
|
-
links: attributes.links.map((link) => ({
|
|
86
|
-
href: link.href,
|
|
87
|
-
name: link.name,
|
|
88
|
-
documentId: link.documentId,
|
|
89
|
-
dataContentType: link.dataContentType,
|
|
90
|
-
})),
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
addCommands() {
|
|
98
|
-
return {
|
|
99
|
-
setAttachment:
|
|
100
|
-
(
|
|
101
|
-
attrs = {
|
|
102
|
-
dataContentType: '',
|
|
103
|
-
name: '',
|
|
104
|
-
documentId: '',
|
|
105
|
-
href: '',
|
|
106
|
-
},
|
|
107
|
-
) =>
|
|
108
|
-
({ chain }) => {
|
|
109
|
-
return chain().insertContent({ type: this.name, attrs }).run();
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
});
|
package/src/attachment/index.ts
DELETED
package/src/audio/audio.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { mergeAttributes, Node } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
export interface AudioOptions {
|
|
4
|
-
url: string;
|
|
5
|
-
HTMLAttributes: Record<string, any>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
declare module '@tiptap/core' {
|
|
9
|
-
interface Commands<ReturnType> {
|
|
10
|
-
audio: {
|
|
11
|
-
/**
|
|
12
|
-
* Set a audio node
|
|
13
|
-
* @param options.updateSelection set to true will select the newly inserted content
|
|
14
|
-
*/
|
|
15
|
-
setAudio: (
|
|
16
|
-
id: string,
|
|
17
|
-
src: string,
|
|
18
|
-
options?: { updateSelection: boolean },
|
|
19
|
-
) => ReturnType;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const Audio = Node.create({
|
|
25
|
-
name: 'audio',
|
|
26
|
-
|
|
27
|
-
group: 'block',
|
|
28
|
-
|
|
29
|
-
addAttributes() {
|
|
30
|
-
return {
|
|
31
|
-
src: {
|
|
32
|
-
default: null,
|
|
33
|
-
parseHTML: (el: any) => (el as HTMLSpanElement).getAttribute('src'),
|
|
34
|
-
renderHTML: (attrs: any) => ({ src: attrs.src }),
|
|
35
|
-
},
|
|
36
|
-
documentId: {
|
|
37
|
-
default: '',
|
|
38
|
-
renderHTML: (attributes: any) => {
|
|
39
|
-
return { 'data-document-id': attributes.documentId };
|
|
40
|
-
},
|
|
41
|
-
parseHTML: (element: any) => element.getAttribute('data-document-id'),
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
parseHTML() {
|
|
47
|
-
return [
|
|
48
|
-
{
|
|
49
|
-
tag: 'div.audio-wrapper>audio,audio',
|
|
50
|
-
getAttrs: (el: any) => ({
|
|
51
|
-
src: (el as HTMLAudioElement).getAttribute('src'),
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
renderHTML({ HTMLAttributes }) {
|
|
58
|
-
return [
|
|
59
|
-
'div',
|
|
60
|
-
{ class: 'audio-wrapper' },
|
|
61
|
-
['audio', mergeAttributes(HTMLAttributes)],
|
|
62
|
-
];
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
addCommands() {
|
|
66
|
-
return {
|
|
67
|
-
setAudio:
|
|
68
|
-
(id, src, options) =>
|
|
69
|
-
({ commands, state }) => {
|
|
70
|
-
return commands.insertContentAt(
|
|
71
|
-
state.selection,
|
|
72
|
-
`<audio
|
|
73
|
-
src="${src}"
|
|
74
|
-
controls preload="none"
|
|
75
|
-
data-document-id="${id}"></audio>`,
|
|
76
|
-
options,
|
|
77
|
-
);
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
});
|
package/src/audio/index.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import '@tiptap/extension-text-style';
|
|
2
|
-
|
|
3
|
-
import { Extension } from '@tiptap/core';
|
|
4
|
-
|
|
5
|
-
export type FontSizeOptions = {
|
|
6
|
-
types: string[];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
declare module '@tiptap/core' {
|
|
10
|
-
interface Commands<ReturnType> {
|
|
11
|
-
fontSize: {
|
|
12
|
-
/**
|
|
13
|
-
* Set the font size
|
|
14
|
-
*/
|
|
15
|
-
setFontSize: (fontSize: string) => ReturnType;
|
|
16
|
-
/**
|
|
17
|
-
* Unset the font size
|
|
18
|
-
*/
|
|
19
|
-
unsetFontSize: () => ReturnType;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const FontSize = Extension.create<FontSizeOptions>({
|
|
25
|
-
name: 'fontSize',
|
|
26
|
-
|
|
27
|
-
addOptions() {
|
|
28
|
-
return {
|
|
29
|
-
types: ['textStyle'],
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
addGlobalAttributes() {
|
|
34
|
-
return [
|
|
35
|
-
{
|
|
36
|
-
types: this.options.types,
|
|
37
|
-
attributes: {
|
|
38
|
-
fontSize: {
|
|
39
|
-
default: null,
|
|
40
|
-
parseHTML: (element) =>
|
|
41
|
-
element.style.fontSize?.replace(/['"]+/g, ''),
|
|
42
|
-
renderHTML: (attributes) => {
|
|
43
|
-
if (!attributes.fontSize) {
|
|
44
|
-
return {};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
style: `font-size: ${attributes.fontSize}`,
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
addCommands() {
|
|
58
|
-
return {
|
|
59
|
-
setFontSize:
|
|
60
|
-
(fontSize) =>
|
|
61
|
-
({ chain }) => {
|
|
62
|
-
return chain().setMark('textStyle', { fontSize }).run();
|
|
63
|
-
},
|
|
64
|
-
unsetFontSize:
|
|
65
|
-
() =>
|
|
66
|
-
({ chain }) => {
|
|
67
|
-
return chain()
|
|
68
|
-
.setMark('textStyle', { fontSize: null })
|
|
69
|
-
.removeEmptyTextStyle()
|
|
70
|
-
.run();
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
});
|
package/src/font-size/index.ts
DELETED
package/src/heading/heading.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { mergeAttributes } from '@tiptap/core';
|
|
2
|
-
import { Heading } from '@tiptap/extension-heading';
|
|
3
|
-
import '@tiptap/extension-text-style';
|
|
4
|
-
|
|
5
|
-
export declare type Level = 1 | 2;
|
|
6
|
-
|
|
7
|
-
interface Options {
|
|
8
|
-
levels: Level[];
|
|
9
|
-
HTMLAttributes: Record<string, any>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare module '@tiptap/core' {
|
|
13
|
-
interface Commands<ReturnType> {
|
|
14
|
-
customHeading: {
|
|
15
|
-
/**
|
|
16
|
-
* Apply Heading Level
|
|
17
|
-
*/
|
|
18
|
-
setCustomHeading: (attributes: { level: Level }) => ReturnType;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const CustomHeading = Heading.extend<Options>({
|
|
24
|
-
name: 'customHeading',
|
|
25
|
-
|
|
26
|
-
addOptions() {
|
|
27
|
-
return {
|
|
28
|
-
...this.parent?.(),
|
|
29
|
-
HTMLAttributes: {},
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
parseHTML() {
|
|
34
|
-
return this.options.levels.map((level: Level) => ({
|
|
35
|
-
tag: `h${level}`,
|
|
36
|
-
attrs: { level },
|
|
37
|
-
}));
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
41
|
-
const hasLevel = this.options.levels.includes(node.attrs.level);
|
|
42
|
-
const level = hasLevel ? node.attrs.level : this.options.levels[0];
|
|
43
|
-
|
|
44
|
-
return [
|
|
45
|
-
`h${level}`,
|
|
46
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
47
|
-
0,
|
|
48
|
-
];
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
addCommands() {
|
|
52
|
-
return {
|
|
53
|
-
setCustomHeading:
|
|
54
|
-
(attributes) =>
|
|
55
|
-
({ tr, dispatch, commands }) => {
|
|
56
|
-
if (!this.options.levels.includes(attributes.level)) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const { selection } = tr;
|
|
61
|
-
const { from, to } = selection;
|
|
62
|
-
|
|
63
|
-
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
64
|
-
if (node.isBlock && from >= pos && to <= pos + node.nodeSize) {
|
|
65
|
-
/* get node content and iterate through */
|
|
66
|
-
node.content.forEach((content) => {
|
|
67
|
-
/* get content marks and iterate through */
|
|
68
|
-
content.marks.forEach((mark) => {
|
|
69
|
-
/* find textStyle mark and if has fontSize attrs */
|
|
70
|
-
if (
|
|
71
|
-
mark.type.name === 'textStyle' &&
|
|
72
|
-
mark.attrs['fontSize'] &&
|
|
73
|
-
mark.attrs['fontSize'] !== null
|
|
74
|
-
) {
|
|
75
|
-
/* remove any fontSize attr to reset heading style */
|
|
76
|
-
tr = tr.removeMark(pos, pos + node.nodeSize, mark.type);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (dispatch) {
|
|
84
|
-
dispatch(tr);
|
|
85
|
-
}
|
|
86
|
-
return commands.setHeading({ level: attributes.level });
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
});
|
package/src/heading/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Highlight from '@tiptap/extension-highlight';
|
|
2
|
-
|
|
3
|
-
export const CustomHighlight = Highlight.extend({
|
|
4
|
-
name: 'customHighlight',
|
|
5
|
-
|
|
6
|
-
addOptions() {
|
|
7
|
-
return {
|
|
8
|
-
...this.parent?.(),
|
|
9
|
-
multicolor: true,
|
|
10
|
-
HTMLAttributes: {},
|
|
11
|
-
};
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
parseHTML() {
|
|
15
|
-
return [
|
|
16
|
-
{
|
|
17
|
-
...this.parent?.(),
|
|
18
|
-
style: 'background-color',
|
|
19
|
-
getAttrs: (style) => {
|
|
20
|
-
return {
|
|
21
|
-
color: style,
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
},
|
|
27
|
-
});
|
package/src/highlight/index.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Link } from '@tiptap/extension-link';
|
|
2
|
-
|
|
3
|
-
/** Our own model of an hyperlink in a rich document. */
|
|
4
|
-
export type HyperlinkAttributes = {
|
|
5
|
-
href: string | null;
|
|
6
|
-
target: '_blank' | null;
|
|
7
|
-
title: string | null;
|
|
8
|
-
text: string | null;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
declare module '@tiptap/core' {
|
|
12
|
-
interface Commands<ReturnType> {
|
|
13
|
-
hyperlink: {
|
|
14
|
-
/**
|
|
15
|
-
* Set an hyperlink mark
|
|
16
|
-
*/
|
|
17
|
-
setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;
|
|
18
|
-
/**
|
|
19
|
-
* Toggle an hyperlink mark
|
|
20
|
-
*/
|
|
21
|
-
toggleLink: (attributes: {
|
|
22
|
-
href: string;
|
|
23
|
-
target?: string | null;
|
|
24
|
-
}) => ReturnType;
|
|
25
|
-
/**
|
|
26
|
-
* Unset an hyperlink mark
|
|
27
|
-
*/
|
|
28
|
-
unsetLink: () => ReturnType;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Hyperlink (external links), extends `Link` extension from TipTap.
|
|
35
|
-
*
|
|
36
|
-
* Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.
|
|
37
|
-
* The `target` attribute has to be sanitized, so it is overriden.
|
|
38
|
-
*/
|
|
39
|
-
export const Hyperlink = Link.extend({
|
|
40
|
-
name: 'hyperlink',
|
|
41
|
-
|
|
42
|
-
parseHTML() {
|
|
43
|
-
return [
|
|
44
|
-
{
|
|
45
|
-
tag: 'a[href]:not([href *= "javascript:" i])',
|
|
46
|
-
// Be sure no data-id and data-app-prefix attribute exists :
|
|
47
|
-
// it would then be an Linker, not an Hyperlink !
|
|
48
|
-
getAttrs: (node: HTMLAnchorElement) => {
|
|
49
|
-
// See https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs
|
|
50
|
-
if (
|
|
51
|
-
node.getAttribute('data-id') &&
|
|
52
|
-
node.getAttribute('data-app-prefix')
|
|
53
|
-
)
|
|
54
|
-
return false;
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
addOptions() {
|
|
61
|
-
return {
|
|
62
|
-
...this.parent?.(),
|
|
63
|
-
openOnClick: false,
|
|
64
|
-
HTMLAttributes: {
|
|
65
|
-
...this.parent?.().HTMLAttributes,
|
|
66
|
-
target: null,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
/* Manage `title` and `target` attributes. */
|
|
72
|
-
addAttributes() {
|
|
73
|
-
return {
|
|
74
|
-
// Preserve attributes of parent extension...
|
|
75
|
-
...this.parent?.(),
|
|
76
|
-
// ...then add or override the following :
|
|
77
|
-
//------------------
|
|
78
|
-
target: {
|
|
79
|
-
default: this.options.HTMLAttributes.target,
|
|
80
|
-
// Sanitize target value
|
|
81
|
-
parseHTML: (element) =>
|
|
82
|
-
element.getAttribute('target') !== '_blank' ? null : '_blank',
|
|
83
|
-
renderHTML: (attributes) => ({
|
|
84
|
-
target: attributes['target'],
|
|
85
|
-
}),
|
|
86
|
-
},
|
|
87
|
-
title: {
|
|
88
|
-
default: this.options.HTMLAttributes.title,
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
});
|
package/src/hyperlink/index.ts
DELETED
package/src/iframe/iframe.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
export interface IframeOptions {
|
|
4
|
-
allowFullscreen: boolean;
|
|
5
|
-
HTMLAttributes: {
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare module '@tiptap/core' {
|
|
11
|
-
interface Commands<ReturnType> {
|
|
12
|
-
iframe: {
|
|
13
|
-
/**
|
|
14
|
-
* Add an iframe
|
|
15
|
-
*/
|
|
16
|
-
setIframe: (options: { src: string }) => ReturnType;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const Iframe = Node.create<IframeOptions>({
|
|
22
|
-
name: 'iframe',
|
|
23
|
-
group: 'block',
|
|
24
|
-
atom: true,
|
|
25
|
-
draggable: true,
|
|
26
|
-
|
|
27
|
-
addOptions() {
|
|
28
|
-
return {
|
|
29
|
-
allowFullscreen: true,
|
|
30
|
-
HTMLAttributes: {
|
|
31
|
-
class: 'iframe-wrapper',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
addAttributes() {
|
|
37
|
-
return {
|
|
38
|
-
src: {
|
|
39
|
-
default: null,
|
|
40
|
-
},
|
|
41
|
-
frameborder: {
|
|
42
|
-
default: 0,
|
|
43
|
-
},
|
|
44
|
-
allowfullscreen: {
|
|
45
|
-
default: this.options.allowFullscreen,
|
|
46
|
-
parseHTML: () => this.options.allowFullscreen,
|
|
47
|
-
},
|
|
48
|
-
width: {
|
|
49
|
-
renderHTML: (attributes) => {
|
|
50
|
-
return attributes.width
|
|
51
|
-
? {
|
|
52
|
-
width:
|
|
53
|
-
attributes.width === '100%'
|
|
54
|
-
? '100%'
|
|
55
|
-
: parseInt(attributes.width),
|
|
56
|
-
}
|
|
57
|
-
: {};
|
|
58
|
-
},
|
|
59
|
-
parseHTML: (element) => element.getAttribute('width'),
|
|
60
|
-
},
|
|
61
|
-
height: {
|
|
62
|
-
renderHTML: (attributes) => {
|
|
63
|
-
return attributes.height
|
|
64
|
-
? {
|
|
65
|
-
height: parseInt(attributes.height),
|
|
66
|
-
}
|
|
67
|
-
: {};
|
|
68
|
-
},
|
|
69
|
-
parseHTML: (element) => element.getAttribute('height'),
|
|
70
|
-
},
|
|
71
|
-
style: {
|
|
72
|
-
renderHTML: (attributes) => {
|
|
73
|
-
return attributes.style
|
|
74
|
-
? {
|
|
75
|
-
style: attributes.style,
|
|
76
|
-
}
|
|
77
|
-
: {};
|
|
78
|
-
},
|
|
79
|
-
parseHTML: (element) => element.getAttribute('style'),
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
parseHTML() {
|
|
85
|
-
return [
|
|
86
|
-
{
|
|
87
|
-
tag: 'iframe',
|
|
88
|
-
},
|
|
89
|
-
];
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
renderHTML({ HTMLAttributes }) {
|
|
93
|
-
return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
addCommands() {
|
|
97
|
-
return {
|
|
98
|
-
setIframe:
|
|
99
|
-
(options: { src: string }) =>
|
|
100
|
-
({ tr, dispatch }) => {
|
|
101
|
-
const { selection } = tr;
|
|
102
|
-
const node = this.type.create(options);
|
|
103
|
-
|
|
104
|
-
if (dispatch) {
|
|
105
|
-
tr.replaceRangeWith(selection.from, selection.to, node);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return true;
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
});
|