@seorii/tiptap 0.2.4 → 0.2.5
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/dist/plugin/embed.d.ts +21 -0
- package/dist/plugin/embed.js +46 -0
- package/dist/tiptap/TipTap.svelte +2 -1
- package/dist/tiptap/tiptap.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export interface EmbedOptions {
|
|
3
|
+
allowFullscreen: boolean;
|
|
4
|
+
type: string;
|
|
5
|
+
HTMLAttributes: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
declare module '@tiptap/core' {
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
embed: {
|
|
12
|
+
setEmbed: (options: {
|
|
13
|
+
src: string;
|
|
14
|
+
type: string;
|
|
15
|
+
width: string;
|
|
16
|
+
}) => ReturnType;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
declare const _default: Node<EmbedOptions, any>;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { mergeAttributes, Node } from '@tiptap/core';
|
|
2
|
+
export default Node.create({
|
|
3
|
+
name: 'embed',
|
|
4
|
+
group: 'block',
|
|
5
|
+
atom: true,
|
|
6
|
+
addOptions() {
|
|
7
|
+
return {
|
|
8
|
+
allowFullscreen: true,
|
|
9
|
+
HTMLAttributes: {
|
|
10
|
+
class: 'embed-wrapper',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
addAttributes() {
|
|
15
|
+
return {
|
|
16
|
+
src: { default: null },
|
|
17
|
+
frameborder: { default: 0 },
|
|
18
|
+
allowfullscreen: {
|
|
19
|
+
default: this.options.allowFullscreen,
|
|
20
|
+
parseHTML: () => this.options.allowFullscreen,
|
|
21
|
+
},
|
|
22
|
+
width: { default: '100%' },
|
|
23
|
+
height: { default: '800px' },
|
|
24
|
+
type: { default: '' }
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
parseHTML() {
|
|
28
|
+
return [{
|
|
29
|
+
tag: 'embed',
|
|
30
|
+
}];
|
|
31
|
+
},
|
|
32
|
+
renderHTML({ HTMLAttributes }) {
|
|
33
|
+
return ['div', this.options.HTMLAttributes, ['embed', mergeAttributes(HTMLAttributes, { credentialless: true })]];
|
|
34
|
+
},
|
|
35
|
+
addCommands() {
|
|
36
|
+
return {
|
|
37
|
+
setEmbed: (options) => ({ tr, dispatch }) => {
|
|
38
|
+
const { selection } = tr;
|
|
39
|
+
const node = this.type.create(options);
|
|
40
|
+
if (dispatch)
|
|
41
|
+
tr.replaceRangeWith(selection.from, selection.to, node);
|
|
42
|
+
return true;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -10,7 +10,7 @@ import { slashItems, slashProps, slashVisible } from "../plugin/command/stores";
|
|
|
10
10
|
import i18n from "../i18n";
|
|
11
11
|
import { fallbackUpload } from "../plugin/image/dragdrop";
|
|
12
12
|
const san = (body) => sanitizeHtml(body, {
|
|
13
|
-
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'math-inline', 'math-node', 'iframe', 'tiptap-file', 'lite-youtube', 'blockquote']),
|
|
13
|
+
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'math-inline', 'math-node', 'iframe', 'tiptap-file', 'lite-youtube', 'blockquote', 'embed']),
|
|
14
14
|
allowedStyles: '*', allowedAttributes: {
|
|
15
15
|
'*': ['style', 'class'],
|
|
16
16
|
a: ['href', 'name', 'target'],
|
|
@@ -20,6 +20,7 @@ const san = (body) => sanitizeHtml(body, {
|
|
|
20
20
|
td: ['colwidth', 'colspan', 'rowspan'],
|
|
21
21
|
'tiptap-file': ['id'],
|
|
22
22
|
'lite-youtube': ['videoid', 'params', 'nocookie', 'title', 'provider'],
|
|
23
|
+
embed: ['src', 'type', 'frameborder', 'allowfullscreen']
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
export let body = '', editable = false, ref = null, options = {};
|
package/dist/tiptap/tiptap.js
CHANGED
|
@@ -20,6 +20,7 @@ import { Indent } from "../plugin/indent";
|
|
|
20
20
|
import { Color } from '@tiptap/extension-color';
|
|
21
21
|
import TextStyle from '@tiptap/extension-text-style';
|
|
22
22
|
import Iframe from "../plugin/iframe";
|
|
23
|
+
import Embed from "../plugin/embed";
|
|
23
24
|
// @ts-ignore
|
|
24
25
|
import { MathInline, MathBlock } from "@seorii/prosemirror-math/tiptap";
|
|
25
26
|
import Youtube from "../plugin/youtube";
|
|
@@ -70,6 +71,7 @@ export default (element, content, { placeholder = i18n('placeholder'), plugins =
|
|
|
70
71
|
Color,
|
|
71
72
|
TextStyle,
|
|
72
73
|
Iframe,
|
|
74
|
+
Embed,
|
|
73
75
|
Code.extend({
|
|
74
76
|
renderHTML({ HTMLAttributes }) {
|
|
75
77
|
return ['code', mergeAttributes(HTMLAttributes, { class: 'inline' })];
|