payload-richtext-tiptap 0.0.126 → 0.0.128
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/src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.d.ts +2 -2
- package/dist/src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.js +121 -21
- package/dist/src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/Link/Link.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/Link/Link.js +25 -1
- package/dist/src/fields/TiptapEditor/extensions/Link/Link.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.d.ts +2 -2
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.js +44 -14
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.d.ts +2 -2
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.js +63 -25
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.d.ts +2 -2
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.js +61 -24
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.d.ts +2 -2
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.js +58 -16
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.d.ts +2 -2
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.js +63 -14
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/lib/extract.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/lib/extract.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/lib/extract.js +14 -12
- package/dist/src/fields/TiptapEditor/lib/extract.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module '@tiptap/core' {
|
|
2
2
|
interface Commands<ReturnType> {
|
|
3
3
|
insideLinks: {
|
|
4
4
|
/**
|
|
@@ -14,6 +14,6 @@ declare module "@tiptap/core" {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
import { Node } from
|
|
17
|
+
import { Node } from '@tiptap/core';
|
|
18
18
|
export declare const InsideLinks: Node<any, any>;
|
|
19
19
|
//# sourceMappingURL=insideLinks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insideLinks.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,WAAW,EAAE;YACX;;eAEG;YAEH,iBAAiB,EAAE,CAAC,EAClB,SAAS,EACT,KAAK,EACL,EAAE,EACF,IAAI,EACJ,GAAG,GACJ,EAAE;gBACD,SAAS,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"insideLinks.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,WAAW,EAAE;YACX;;eAEG;YAEH,iBAAiB,EAAE,CAAC,EAClB,SAAS,EACT,KAAK,EACL,EAAE,EACF,IAAI,EACJ,GAAG,GACJ,EAAE;gBACD,SAAS,CAAC,EAAE,MAAM,CAAA;gBAClB,KAAK,CAAC,EAAE,MAAM,CAAA;gBACd,EAAE,CAAC,EAAE,MAAM,CAAA;gBACX,IAAI,CAAC,EAAE,MAAM,CAAA;gBACb,GAAG,CAAC,EAAE,MAAM,CAAA;aACb,KAAK,UAAU,CAAA;SACjB,CAAA;KACF;CACF;AAED,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAA;AAIpD,eAAO,MAAM,WAAW,gBAsMtB,CAAA"}
|
|
@@ -1,54 +1,154 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
2
|
-
import { ReactNodeViewRenderer } from
|
|
3
|
-
import InsideLinksComponent from
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
+
import InsideLinksComponent from './InsideLinksComponent.js';
|
|
4
4
|
export const InsideLinks = Node.create({
|
|
5
|
-
name:
|
|
6
|
-
group:
|
|
7
|
-
content:
|
|
5
|
+
name: 'insideLinks',
|
|
6
|
+
group: 'block',
|
|
7
|
+
content: 'inline*',
|
|
8
8
|
draggable: true,
|
|
9
9
|
// content: 'inline*',
|
|
10
10
|
parseHTML () {
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
13
|
-
tag: 'div[data-type="
|
|
13
|
+
tag: 'div[data-type="social-media-embed"]'
|
|
14
14
|
}
|
|
15
15
|
];
|
|
16
16
|
},
|
|
17
17
|
addAttributes () {
|
|
18
18
|
return {
|
|
19
|
-
|
|
19
|
+
id: {
|
|
20
20
|
default: null
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
url: {
|
|
23
23
|
default: null
|
|
24
24
|
},
|
|
25
|
-
|
|
26
|
-
default:
|
|
25
|
+
title: {
|
|
26
|
+
default: ''
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
default:
|
|
28
|
+
thumbnail: {
|
|
29
|
+
default: ''
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
draggable: {
|
|
32
|
+
default: true
|
|
33
|
+
},
|
|
34
|
+
type: {
|
|
32
35
|
default: null
|
|
33
36
|
}
|
|
34
37
|
};
|
|
35
38
|
},
|
|
36
39
|
addKeyboardShortcuts () {
|
|
37
40
|
return {
|
|
38
|
-
|
|
41
|
+
'Mod-Enter': ()=>{
|
|
39
42
|
return this.editor.chain().insertContentAt(this.editor.state.selection.head, {
|
|
40
43
|
type: this.type.name
|
|
41
44
|
}).focus().run();
|
|
42
45
|
}
|
|
43
46
|
};
|
|
44
47
|
},
|
|
45
|
-
renderHTML
|
|
48
|
+
// renderHTML({ HTMLAttributes }) {
|
|
49
|
+
// return [
|
|
50
|
+
// "div",
|
|
51
|
+
// mergeAttributes(HTMLAttributes, { "data-type": "insideLinks" }),
|
|
52
|
+
// 0,
|
|
53
|
+
// ];
|
|
54
|
+
// },
|
|
55
|
+
// parseHTML() {
|
|
56
|
+
// return [
|
|
57
|
+
// {
|
|
58
|
+
// tag: 'div[data-type="social-media-embed"]',
|
|
59
|
+
// },
|
|
60
|
+
// ];
|
|
61
|
+
// },
|
|
62
|
+
renderHTML ({ node, HTMLAttributes }) {
|
|
63
|
+
const { id, url, title, thumbnail, draggable } = node.attrs;
|
|
64
|
+
if (!id) {
|
|
65
|
+
return [
|
|
66
|
+
'div',
|
|
67
|
+
mergeAttributes(HTMLAttributes, {
|
|
68
|
+
'data-type': 'social-media-embed',
|
|
69
|
+
class: 'socialMediaContainer'
|
|
70
|
+
}),
|
|
71
|
+
[
|
|
72
|
+
'div',
|
|
73
|
+
{
|
|
74
|
+
class: 'w-full bg-zinc-100 py-8 px-6 flex items-center justify-center gap-2 socialMediaCard',
|
|
75
|
+
draggable: draggable ? 'true' : 'false',
|
|
76
|
+
'data-drag-handle': ''
|
|
77
|
+
},
|
|
78
|
+
[
|
|
79
|
+
'svg',
|
|
80
|
+
{
|
|
81
|
+
class: 'h-6 w-6'
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
'p',
|
|
86
|
+
{
|
|
87
|
+
class: 'w-full flex items-center justify-start mt-0',
|
|
88
|
+
style: 'margin-top: 0;'
|
|
89
|
+
},
|
|
90
|
+
'Add Internal Content Links'
|
|
91
|
+
]
|
|
92
|
+
]
|
|
93
|
+
];
|
|
94
|
+
}
|
|
46
95
|
return [
|
|
47
|
-
|
|
96
|
+
'div',
|
|
48
97
|
mergeAttributes(HTMLAttributes, {
|
|
49
|
-
|
|
98
|
+
'data-type': 'social-media-embed',
|
|
99
|
+
class: 'socialMediaContainer'
|
|
50
100
|
}),
|
|
51
|
-
|
|
101
|
+
[
|
|
102
|
+
'div',
|
|
103
|
+
{
|
|
104
|
+
class: 'flex justify-center items-center w-full gap-x-6'
|
|
105
|
+
},
|
|
106
|
+
[
|
|
107
|
+
'div',
|
|
108
|
+
{
|
|
109
|
+
class: 'flex justify-center items-center'
|
|
110
|
+
},
|
|
111
|
+
[
|
|
112
|
+
'div',
|
|
113
|
+
{
|
|
114
|
+
class: 'w-[32px] h-[64px] bg-blue-400'
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
'img',
|
|
119
|
+
{
|
|
120
|
+
src: thumbnail,
|
|
121
|
+
width: '212',
|
|
122
|
+
height: '120',
|
|
123
|
+
alt: '',
|
|
124
|
+
class: '-ml-6 !w-[212px] !h-[120px] object-cover'
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
'div',
|
|
130
|
+
{
|
|
131
|
+
class: 'flex flex-col justify-start items-start font-trt gap-y-2'
|
|
132
|
+
},
|
|
133
|
+
[
|
|
134
|
+
'a',
|
|
135
|
+
{
|
|
136
|
+
class: 'text-black dark:text-white text-lg capitalize w-full',
|
|
137
|
+
href: url,
|
|
138
|
+
dir: 'ltr'
|
|
139
|
+
},
|
|
140
|
+
'Read More'
|
|
141
|
+
],
|
|
142
|
+
[
|
|
143
|
+
'h3',
|
|
144
|
+
{
|
|
145
|
+
class: 'text-2xl font-bold !mt-0 w-full',
|
|
146
|
+
dir: 'ltr'
|
|
147
|
+
},
|
|
148
|
+
title
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
]
|
|
52
152
|
];
|
|
53
153
|
},
|
|
54
154
|
addNodeView () {
|
|
@@ -58,7 +158,7 @@ export const InsideLinks = Node.create({
|
|
|
58
158
|
return {
|
|
59
159
|
insertInsideLinks: ({ thumbnail, title, id, type, url })=>({ commands, state })=>{
|
|
60
160
|
return commands.insertContent({
|
|
61
|
-
type:
|
|
161
|
+
type: 'insideLinks',
|
|
62
162
|
attrs: {
|
|
63
163
|
thumbnail,
|
|
64
164
|
title,
|
|
@@ -78,7 +178,7 @@ function isValidHttpUrl(string) {
|
|
|
78
178
|
} catch (_) {
|
|
79
179
|
return false;
|
|
80
180
|
}
|
|
81
|
-
return url.protocol ===
|
|
181
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
82
182
|
}
|
|
83
183
|
|
|
84
184
|
//# sourceMappingURL=insideLinks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.ts"],"sourcesContent":["declare module
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/InsideLinks/insideLinks.ts"],"sourcesContent":["declare module '@tiptap/core' {\n interface Commands<ReturnType> {\n insideLinks: {\n /**\n * Add an image\n */\n\n insertInsideLinks: ({\n thumbnail,\n title,\n id,\n type,\n url,\n }: {\n thumbnail?: string\n title?: string\n id?: string\n type?: string\n url?: string\n }) => ReturnType\n }\n }\n}\n\nimport { Node, mergeAttributes } from '@tiptap/core'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\nimport InsideLinksComponent from './InsideLinksComponent.js'\n\nexport const InsideLinks = Node.create({\n name: 'insideLinks',\n\n group: 'block',\n content: 'inline*',\n draggable: true,\n\n // content: 'inline*',\n\n parseHTML() {\n return [\n {\n tag: 'div[data-type=\"social-media-embed\"]',\n },\n ]\n },\n\n addAttributes() {\n return {\n id: {\n default: null,\n },\n url: {\n default: null,\n },\n title: {\n default: '',\n },\n thumbnail: {\n default: '',\n },\n draggable: {\n default: true,\n },\n type: { default: null },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Enter': () => {\n return this.editor\n .chain()\n .insertContentAt(this.editor.state.selection.head, {\n type: this.type.name,\n })\n .focus()\n .run()\n },\n }\n },\n\n // renderHTML({ HTMLAttributes }) {\n // return [\n // \"div\",\n // mergeAttributes(HTMLAttributes, { \"data-type\": \"insideLinks\" }),\n // 0,\n // ];\n // },\n // parseHTML() {\n // return [\n // {\n // tag: 'div[data-type=\"social-media-embed\"]',\n // },\n // ];\n // },\n\n renderHTML({ node, HTMLAttributes }) {\n const { id, url, title, thumbnail, draggable } = node.attrs\n\n if (!id) {\n return [\n 'div',\n mergeAttributes(HTMLAttributes, {\n 'data-type': 'social-media-embed',\n class: 'socialMediaContainer',\n }),\n [\n 'div',\n {\n class:\n 'w-full bg-zinc-100 py-8 px-6 flex items-center justify-center gap-2 socialMediaCard',\n draggable: draggable ? 'true' : 'false',\n 'data-drag-handle': '',\n },\n [\n 'svg',\n {\n class: 'h-6 w-6',\n // SVG content for ExternalLinkIcon\n },\n ],\n [\n 'p',\n {\n class: 'w-full flex items-center justify-start mt-0',\n style: 'margin-top: 0;',\n },\n 'Add Internal Content Links',\n ],\n ],\n ]\n }\n\n return [\n 'div',\n mergeAttributes(HTMLAttributes, {\n 'data-type': 'social-media-embed',\n class: 'socialMediaContainer',\n }),\n [\n 'div',\n {\n class: 'flex justify-center items-center w-full gap-x-6',\n },\n [\n 'div',\n {\n class: 'flex justify-center items-center',\n },\n [\n 'div',\n {\n class: 'w-[32px] h-[64px] bg-blue-400',\n },\n ],\n [\n 'img',\n {\n src: thumbnail,\n width: '212',\n height: '120',\n alt: '',\n class: '-ml-6 !w-[212px] !h-[120px] object-cover',\n },\n ],\n ],\n [\n 'div',\n {\n class: 'flex flex-col justify-start items-start font-trt gap-y-2',\n },\n [\n 'a',\n {\n class: 'text-black dark:text-white text-lg capitalize w-full',\n href: url,\n dir: 'ltr', // Adjust based on your i18n setup\n },\n 'Read More', // Adjust based on your i18n setup\n ],\n [\n 'h3',\n {\n class: 'text-2xl font-bold !mt-0 w-full',\n dir: 'ltr', // Adjust based on your i18n setup\n },\n title,\n ],\n ],\n ],\n ]\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(InsideLinksComponent)\n },\n\n addCommands() {\n return {\n insertInsideLinks:\n ({\n thumbnail,\n title,\n id,\n type,\n url,\n }: {\n thumbnail?: string\n title?: string\n id?: string\n type?: string\n url?: string\n }) =>\n ({ commands, state }) => {\n return commands.insertContent({\n type: 'insideLinks',\n attrs: {\n thumbnail,\n title,\n id,\n type,\n url,\n },\n })\n },\n }\n },\n})\n\nfunction isValidHttpUrl(string: string) {\n let url\n\n try {\n url = new URL(string)\n } catch (_) {\n return false\n }\n\n return url.protocol === 'http:' || url.protocol === 'https:'\n}\n"],"names":["Node","mergeAttributes","ReactNodeViewRenderer","InsideLinksComponent","InsideLinks","create","name","group","content","draggable","parseHTML","tag","addAttributes","id","default","url","title","thumbnail","type","addKeyboardShortcuts","editor","chain","insertContentAt","state","selection","head","focus","run","renderHTML","node","HTMLAttributes","attrs","class","style","src","width","height","alt","href","dir","addNodeView","addCommands","insertInsideLinks","commands","insertContent","isValidHttpUrl","string","URL","_","protocol"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/Link/Link.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/Link/Link.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,gFAsFf,CAAA;AAEF,eAAe,IAAI,CAAA"}
|
|
@@ -20,9 +20,12 @@ export const Link = TiptapLink.extend({
|
|
|
20
20
|
];
|
|
21
21
|
},
|
|
22
22
|
addPasteRules () {
|
|
23
|
-
const twitterRegex = /^https:\/\/twitter\.com\/([a-zA-Z0-9_-]+)\/status\/(\d+)/g;
|
|
23
|
+
const twitterRegex = /^https:\/\/(twitter|x)\.com\/([a-zA-Z0-9_-]+)\/status\/(\d+)/g;
|
|
24
24
|
const instagramRegex = /^https:\/\/www\.instagram\.com\/p\/([A-Za-z0-9_-]+)/g;
|
|
25
|
+
const instagramReelRegex = /^https:\/\/www\.instagram\.com\/reel\/([A-Za-z0-9_-]+)/g;
|
|
25
26
|
const youtubeRegex = /^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|live\/|v\/)?)([\w\-]+)(\S+)?/g;
|
|
27
|
+
const facebookRegex = /^https:\/\/(?:www\.)?facebook\.com\/[a-zA-Z0-9.]+\/(?:posts|photos|videos)\/(?:[a-zA-Z0-9.]+\/)?(\d+)/g;
|
|
28
|
+
const tiktokRegex = /^https:\/\/(?:www\.)?tiktok\.com\/@[\w.-]+\/video\/(\d+)/g;
|
|
26
29
|
return [
|
|
27
30
|
new PasteRule({
|
|
28
31
|
find: twitterRegex,
|
|
@@ -38,12 +41,33 @@ export const Link = TiptapLink.extend({
|
|
|
38
41
|
chain().selectParentNode().deleteSelection().insertInstagram(matchUrl).run();
|
|
39
42
|
}
|
|
40
43
|
}),
|
|
44
|
+
new PasteRule({
|
|
45
|
+
find: instagramReelRegex,
|
|
46
|
+
handler: ({ commands, match, state, pasteEvent, chain })=>{
|
|
47
|
+
const matchUrl = match?.[0];
|
|
48
|
+
chain().selectParentNode().deleteSelection().insertInstagram(matchUrl).run();
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
41
51
|
new PasteRule({
|
|
42
52
|
find: youtubeRegex,
|
|
43
53
|
handler: ({ commands, match, state, pasteEvent, chain })=>{
|
|
44
54
|
const matchUrl = match?.[0];
|
|
45
55
|
chain().selectParentNode().deleteSelection().insertYoutube(matchUrl).run();
|
|
46
56
|
}
|
|
57
|
+
}),
|
|
58
|
+
new PasteRule({
|
|
59
|
+
find: facebookRegex,
|
|
60
|
+
handler: ({ commands, match, state, pasteEvent, chain })=>{
|
|
61
|
+
const matchUrl = match?.[0];
|
|
62
|
+
chain().selectParentNode().deleteSelection().insertFacebook(matchUrl).run();
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
new PasteRule({
|
|
66
|
+
find: tiktokRegex,
|
|
67
|
+
handler: ({ commands, match, state, pasteEvent, chain })=>{
|
|
68
|
+
const matchUrl = match?.[0];
|
|
69
|
+
chain().selectParentNode().deleteSelection().insertTiktok(matchUrl).run();
|
|
70
|
+
}
|
|
47
71
|
})
|
|
48
72
|
];
|
|
49
73
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/Link/Link.ts"],"sourcesContent":["import { PasteRule, mergeAttributes } from '@tiptap/core'\nimport TiptapLink from '@tiptap/extension-link'\nimport { Plugin } from '@tiptap/pm/state'\nimport { EditorView } from '@tiptap/pm/view'\n\nexport const Link = TiptapLink.extend({\n inclusive: false,\n\n parseHTML() {\n return [{ tag: 'a[href]:not([data-type=\"button\"]):not([href *= \"javascript:\" i])' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['a', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { class: 'link' }), 0]\n },\n\n addPasteRules() {\n const twitterRegex = /^https:\\/\\/twitter\\.com\\/([a-zA-Z0-9_-]+)\\/status\\/(\\d+)/g\n const instagramRegex = /^https:\\/\\/www\\.instagram\\.com\\/p\\/([A-Za-z0-9_-]+)/g\n const youtubeRegex =\n /^((?:https?:)?\\/\\/)?((?:www|m)\\.)?((?:youtube(-nocookie)?\\.com|youtu.be))(\\/(?:[\\w\\-]+\\?v=|embed\\/|live\\/|v\\/)?)([\\w\\-]+)(\\S+)?/g\n\n return [\n new PasteRule({\n find: twitterRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertTwitter(matchUrl).run()\n },\n }),\n new PasteRule({\n find: instagramRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertInstagram(matchUrl).run()\n },\n }),\n new PasteRule({\n find: youtubeRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertYoutube(matchUrl).run()\n },\n }),\n ]\n },\n addProseMirrorPlugins() {\n const { editor } = this\n\n return [\n ...(this.parent?.() || []),\n new Plugin({\n props: {\n handleKeyDown: (view: EditorView, event: KeyboardEvent) => {\n const { selection } = editor.state\n\n if (event.key === 'Escape' && selection.empty !== true) {\n editor.commands.focus(selection.to, { scrollIntoView: false })\n }\n\n return false\n },\n },\n }),\n ]\n },\n})\n\nexport default Link\n"],"names":["PasteRule","mergeAttributes","TiptapLink","Plugin","Link","extend","inclusive","parseHTML","tag","renderHTML","HTMLAttributes","options","class","addPasteRules","twitterRegex","instagramRegex","youtubeRegex","find","handler","commands","match","state","pasteEvent","chain","matchUrl","selectParentNode","deleteSelection","insertTwitter","run","insertInstagram","insertYoutube","addProseMirrorPlugins","editor","parent","props","handleKeyDown","view","event","selection","key","empty","focus","to","scrollIntoView"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,eAAc;AACzD,OAAOC,gBAAgB,yBAAwB;AAC/C,SAASC,MAAM,QAAQ,mBAAkB;AAGzC,OAAO,MAAMC,OAAOF,WAAWG,MAAM,CAAC;IACpCC,WAAW;IAEXC;QACE,OAAO;YAAC;gBAAEC,KAAK;YAAmE;SAAE;IACtF;IAEAC,YAAW,EAAEC,cAAc,EAAE;QAC3B,OAAO;YAAC;YAAKT,gBAAgB,IAAI,CAACU,OAAO,CAACD,cAAc,EAAEA,gBAAgB;gBAAEE,OAAO;YAAO;YAAI;SAAE;IAClG;IAEAC;QACE,MAAMC,eAAe;QACrB,MAAMC,iBAAiB;QACvB,MAAMC,eACJ;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/Link/Link.ts"],"sourcesContent":["import { PasteRule, mergeAttributes } from '@tiptap/core'\nimport TiptapLink from '@tiptap/extension-link'\nimport { Plugin } from '@tiptap/pm/state'\nimport { EditorView } from '@tiptap/pm/view'\n\nexport const Link = TiptapLink.extend({\n inclusive: false,\n\n parseHTML() {\n return [{ tag: 'a[href]:not([data-type=\"button\"]):not([href *= \"javascript:\" i])' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['a', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { class: 'link' }), 0]\n },\n\n addPasteRules() {\n const twitterRegex = /^https:\\/\\/(twitter|x)\\.com\\/([a-zA-Z0-9_-]+)\\/status\\/(\\d+)/g\n const instagramRegex = /^https:\\/\\/www\\.instagram\\.com\\/p\\/([A-Za-z0-9_-]+)/g\n const instagramReelRegex = /^https:\\/\\/www\\.instagram\\.com\\/reel\\/([A-Za-z0-9_-]+)/g\n const youtubeRegex =\n /^((?:https?:)?\\/\\/)?((?:www|m)\\.)?((?:youtube(-nocookie)?\\.com|youtu.be))(\\/(?:[\\w\\-]+\\?v=|embed\\/|live\\/|v\\/)?)([\\w\\-]+)(\\S+)?/g\n const facebookRegex =\n /^https:\\/\\/(?:www\\.)?facebook\\.com\\/[a-zA-Z0-9.]+\\/(?:posts|photos|videos)\\/(?:[a-zA-Z0-9.]+\\/)?(\\d+)/g\n const tiktokRegex = /^https:\\/\\/(?:www\\.)?tiktok\\.com\\/@[\\w.-]+\\/video\\/(\\d+)/g\n\n return [\n new PasteRule({\n find: twitterRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertTwitter(matchUrl).run()\n },\n }),\n new PasteRule({\n find: instagramRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertInstagram(matchUrl).run()\n },\n }),\n new PasteRule({\n find: instagramReelRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertInstagram(matchUrl).run()\n },\n }),\n new PasteRule({\n find: youtubeRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertYoutube(matchUrl).run()\n },\n }),\n new PasteRule({\n find: facebookRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertFacebook(matchUrl).run()\n },\n }),\n new PasteRule({\n find: tiktokRegex,\n handler: ({ commands, match, state, pasteEvent, chain }) => {\n const matchUrl = match?.[0]\n chain().selectParentNode().deleteSelection().insertTiktok(matchUrl).run()\n },\n }),\n ]\n },\n addProseMirrorPlugins() {\n const { editor } = this\n\n return [\n ...(this.parent?.() || []),\n new Plugin({\n props: {\n handleKeyDown: (view: EditorView, event: KeyboardEvent) => {\n const { selection } = editor.state\n\n if (event.key === 'Escape' && selection.empty !== true) {\n editor.commands.focus(selection.to, { scrollIntoView: false })\n }\n\n return false\n },\n },\n }),\n ]\n },\n})\n\nexport default Link\n"],"names":["PasteRule","mergeAttributes","TiptapLink","Plugin","Link","extend","inclusive","parseHTML","tag","renderHTML","HTMLAttributes","options","class","addPasteRules","twitterRegex","instagramRegex","instagramReelRegex","youtubeRegex","facebookRegex","tiktokRegex","find","handler","commands","match","state","pasteEvent","chain","matchUrl","selectParentNode","deleteSelection","insertTwitter","run","insertInstagram","insertYoutube","insertFacebook","insertTiktok","addProseMirrorPlugins","editor","parent","props","handleKeyDown","view","event","selection","key","empty","focus","to","scrollIntoView"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module '@tiptap/core' {
|
|
2
2
|
interface Commands<ReturnType> {
|
|
3
3
|
facebook: {
|
|
4
4
|
/**
|
|
@@ -8,6 +8,6 @@ declare module "@tiptap/core" {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
import { Node } from
|
|
11
|
+
import { Node } from '@tiptap/core';
|
|
12
12
|
export declare const Facebook: Node<any, any>;
|
|
13
13
|
//# sourceMappingURL=facebook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facebook.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,QAAQ,EAAE;YACR;;eAEG;YAEH,cAAc,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"facebook.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,QAAQ,EAAE;YACR;;eAEG;YAEH,cAAc,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,CAAA;SACjE,CAAA;KACF;CACF;AAED,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAA;AAIpD,eAAO,MAAM,QAAQ,gBA4FnB,CAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
2
|
-
import { ReactNodeViewRenderer } from
|
|
3
|
-
import FacebookEmbed from
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
+
import FacebookEmbed from './FacebookEmbed.js';
|
|
4
4
|
export const Facebook = Node.create({
|
|
5
|
-
name:
|
|
6
|
-
group:
|
|
7
|
-
content:
|
|
5
|
+
name: 'facebook',
|
|
6
|
+
group: 'block',
|
|
7
|
+
content: 'inline*',
|
|
8
8
|
draggable: true,
|
|
9
9
|
// content: 'inline*',
|
|
10
10
|
parseHTML () {
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
13
|
-
tag: "facebook-
|
|
13
|
+
tag: 'div[data-type="facebook-post"]'
|
|
14
14
|
}
|
|
15
15
|
];
|
|
16
16
|
},
|
|
@@ -21,12 +21,21 @@ export const Facebook = Node.create({
|
|
|
21
21
|
},
|
|
22
22
|
class: {
|
|
23
23
|
default: null
|
|
24
|
+
},
|
|
25
|
+
src: {
|
|
26
|
+
default: null
|
|
27
|
+
},
|
|
28
|
+
width: {
|
|
29
|
+
default: '500'
|
|
30
|
+
},
|
|
31
|
+
showText: {
|
|
32
|
+
default: true
|
|
24
33
|
}
|
|
25
34
|
};
|
|
26
35
|
},
|
|
27
36
|
addKeyboardShortcuts () {
|
|
28
37
|
return {
|
|
29
|
-
|
|
38
|
+
'Mod-Enter': ()=>{
|
|
30
39
|
return this.editor.chain().insertContentAt(this.editor.state.selection.head, {
|
|
31
40
|
type: this.type.name
|
|
32
41
|
}).focus().run();
|
|
@@ -35,9 +44,29 @@ export const Facebook = Node.create({
|
|
|
35
44
|
},
|
|
36
45
|
renderHTML ({ HTMLAttributes }) {
|
|
37
46
|
return [
|
|
38
|
-
|
|
39
|
-
mergeAttributes(
|
|
40
|
-
|
|
47
|
+
'div',
|
|
48
|
+
mergeAttributes({
|
|
49
|
+
'data-type': 'facebook-post',
|
|
50
|
+
class: 'socialMediaContainer'
|
|
51
|
+
}, HTMLAttributes),
|
|
52
|
+
[
|
|
53
|
+
'div',
|
|
54
|
+
{
|
|
55
|
+
class: 'fb-post',
|
|
56
|
+
'data-href': HTMLAttributes.url,
|
|
57
|
+
'data-width': HTMLAttributes.width,
|
|
58
|
+
'data-show-text': HTMLAttributes.showText
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
'script',
|
|
63
|
+
{
|
|
64
|
+
async: true,
|
|
65
|
+
defer: true,
|
|
66
|
+
crossorigin: 'anonymous',
|
|
67
|
+
src: 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v22.0&appId=990160422555057'
|
|
68
|
+
}
|
|
69
|
+
]
|
|
41
70
|
];
|
|
42
71
|
},
|
|
43
72
|
addNodeView () {
|
|
@@ -47,10 +76,11 @@ export const Facebook = Node.create({
|
|
|
47
76
|
return {
|
|
48
77
|
insertFacebook: (url, className)=>({ commands, state })=>{
|
|
49
78
|
return commands.insertContent({
|
|
50
|
-
type:
|
|
79
|
+
type: 'facebook',
|
|
51
80
|
attrs: {
|
|
52
81
|
url,
|
|
53
|
-
class: className
|
|
82
|
+
class: className,
|
|
83
|
+
src: url
|
|
54
84
|
}
|
|
55
85
|
});
|
|
56
86
|
}
|
|
@@ -64,7 +94,7 @@ function isValidHttpUrl(string) {
|
|
|
64
94
|
} catch (_) {
|
|
65
95
|
return false;
|
|
66
96
|
}
|
|
67
|
-
return url.protocol ===
|
|
97
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
68
98
|
}
|
|
69
99
|
|
|
70
100
|
//# sourceMappingURL=facebook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.ts"],"sourcesContent":["declare module
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Facebook/facebook.ts"],"sourcesContent":["declare module '@tiptap/core' {\n interface Commands<ReturnType> {\n facebook: {\n /**\n * Add an image\n */\n\n insertFacebook: (url?: string, className?: string) => ReturnType\n }\n }\n}\n\nimport { Node, mergeAttributes } from '@tiptap/core'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\nimport FacebookEmbed from './FacebookEmbed.js'\n\nexport const Facebook = Node.create({\n name: 'facebook',\n group: 'block',\n content: 'inline*',\n draggable: true,\n\n // content: 'inline*',\n parseHTML() {\n return [\n {\n tag: 'div[data-type=\"facebook-post\"]',\n },\n ]\n },\n\n addAttributes() {\n return {\n url: { default: null },\n class: { default: null },\n src: {\n default: null,\n },\n width: {\n default: '500',\n },\n showText: {\n default: true,\n },\n }\n },\n addKeyboardShortcuts() {\n return {\n 'Mod-Enter': () => {\n return this.editor\n .chain()\n .insertContentAt(this.editor.state.selection.head, {\n type: this.type.name,\n })\n .focus()\n .run()\n },\n }\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes(\n { 'data-type': 'facebook-post', class: 'socialMediaContainer' },\n HTMLAttributes,\n ),\n [\n 'div',\n {\n class: 'fb-post',\n 'data-href': HTMLAttributes.url,\n 'data-width': HTMLAttributes.width,\n 'data-show-text': HTMLAttributes.showText,\n },\n ],\n [\n 'script',\n {\n async: true,\n defer: true,\n crossorigin: 'anonymous',\n src: 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v22.0&appId=990160422555057',\n },\n ],\n ]\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(FacebookEmbed)\n },\n\n addCommands() {\n return {\n insertFacebook:\n (url, className) =>\n ({ commands, state }) => {\n return commands.insertContent({\n type: 'facebook',\n attrs: {\n url,\n class: className,\n src: url,\n },\n })\n },\n }\n },\n})\n\nfunction isValidHttpUrl(string: string) {\n let url\n\n try {\n url = new URL(string)\n } catch (_) {\n return false\n }\n\n return url.protocol === 'http:' || url.protocol === 'https:'\n}\n"],"names":["Node","mergeAttributes","ReactNodeViewRenderer","FacebookEmbed","Facebook","create","name","group","content","draggable","parseHTML","tag","addAttributes","url","default","class","src","width","showText","addKeyboardShortcuts","editor","chain","insertContentAt","state","selection","head","type","focus","run","renderHTML","HTMLAttributes","async","defer","crossorigin","addNodeView","addCommands","insertFacebook","className","commands","insertContent","attrs","isValidHttpUrl","string","URL","_","protocol"],"mappings":"AAYA,SAASA,IAAI,EAAEC,eAAe,QAAQ,eAAc;AACpD,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,OAAOC,mBAAmB,qBAAoB;AAE9C,OAAO,MAAMC,WAAWJ,KAAKK,MAAM,CAAC;IAClCC,MAAM;IACNC,OAAO;IACPC,SAAS;IACTC,WAAW;IAEX,sBAAsB;IACtBC;QACE,OAAO;YACL;gBACEC,KAAK;YACP;SACD;IACH;IAEAC;QACE,OAAO;YACLC,KAAK;gBAAEC,SAAS;YAAK;YACrBC,OAAO;gBAAED,SAAS;YAAK;YACvBE,KAAK;gBACHF,SAAS;YACX;YACAG,OAAO;gBACLH,SAAS;YACX;YACAI,UAAU;gBACRJ,SAAS;YACX;QACF;IACF;IACAK;QACE,OAAO;YACL,aAAa;gBACX,OAAO,IAAI,CAACC,MAAM,CACfC,KAAK,GACLC,eAAe,CAAC,IAAI,CAACF,MAAM,CAACG,KAAK,CAACC,SAAS,CAACC,IAAI,EAAE;oBACjDC,MAAM,IAAI,CAACA,IAAI,CAACpB,IAAI;gBACtB,GACCqB,KAAK,GACLC,GAAG;YACR;QACF;IACF;IAEAC,YAAW,EAAEC,cAAc,EAAE;QAC3B,OAAO;YACL;YACA7B,gBACE;gBAAE,aAAa;gBAAiBc,OAAO;YAAuB,GAC9De;YAEF;gBACE;gBACA;oBACEf,OAAO;oBACP,aAAae,eAAejB,GAAG;oBAC/B,cAAciB,eAAeb,KAAK;oBAClC,kBAAkBa,eAAeZ,QAAQ;gBAC3C;aACD;YACD;gBACE;gBACA;oBACEa,OAAO;oBACPC,OAAO;oBACPC,aAAa;oBACbjB,KAAK;gBACP;aACD;SACF;IACH;IAEAkB;QACE,OAAOhC,sBAAsBC;IAC/B;IAEAgC;QACE,OAAO;YACLC,gBACE,CAACvB,KAAKwB,YACN,CAAC,EAAEC,QAAQ,EAAEf,KAAK,EAAE;oBAClB,OAAOe,SAASC,aAAa,CAAC;wBAC5Bb,MAAM;wBACNc,OAAO;4BACL3B;4BACAE,OAAOsB;4BACPrB,KAAKH;wBACP;oBACF;gBACF;QACJ;IACF;AACF,GAAE;AAEF,SAAS4B,eAAeC,MAAc;IACpC,IAAI7B;IAEJ,IAAI;QACFA,MAAM,IAAI8B,IAAID;IAChB,EAAE,OAAOE,GAAG;QACV,OAAO;IACT;IAEA,OAAO/B,IAAIgC,QAAQ,KAAK,WAAWhC,IAAIgC,QAAQ,KAAK;AACtD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module '@tiptap/core' {
|
|
2
2
|
interface Commands<ReturnType> {
|
|
3
3
|
instagram: {
|
|
4
4
|
/**
|
|
@@ -8,6 +8,6 @@ declare module "@tiptap/core" {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
import { Node } from
|
|
11
|
+
import { Node } from '@tiptap/core';
|
|
12
12
|
export declare const Instagram: Node<any, any>;
|
|
13
13
|
//# sourceMappingURL=instagram.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instagram.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,SAAS,EAAE;YACT;;eAEG;YAEH,eAAe,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"instagram.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,SAAS,EAAE;YACT;;eAEG;YAEH,eAAe,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,CAAA;SAClE,CAAA;KACF;CACF;AAED,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAA;AAIpD,eAAO,MAAM,SAAS,gBAgGpB,CAAA"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
2
|
-
import { ReactNodeViewRenderer } from
|
|
3
|
-
import InstagramEmbed from
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
+
import InstagramEmbed from './InstagramEmbed.js';
|
|
4
4
|
export const Instagram = Node.create({
|
|
5
|
-
name:
|
|
6
|
-
group:
|
|
7
|
-
content:
|
|
5
|
+
name: 'instagram',
|
|
6
|
+
group: 'block',
|
|
7
|
+
content: 'inline*',
|
|
8
8
|
draggable: true,
|
|
9
9
|
// content: 'inline*',
|
|
10
|
-
parseHTML () {
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
tag: "instagram-component"
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
},
|
|
17
10
|
addAttributes () {
|
|
18
11
|
return {
|
|
19
12
|
url: {
|
|
@@ -21,36 +14,81 @@ export const Instagram = Node.create({
|
|
|
21
14
|
},
|
|
22
15
|
class: {
|
|
23
16
|
default: null
|
|
17
|
+
},
|
|
18
|
+
src: {
|
|
19
|
+
default: null
|
|
20
|
+
},
|
|
21
|
+
width: {
|
|
22
|
+
default: '400'
|
|
23
|
+
},
|
|
24
|
+
height: {
|
|
25
|
+
default: '480'
|
|
26
|
+
},
|
|
27
|
+
frameborder: {
|
|
28
|
+
default: '0'
|
|
29
|
+
},
|
|
30
|
+
scrolling: {
|
|
31
|
+
default: 'no'
|
|
32
|
+
},
|
|
33
|
+
allowtransparency: {
|
|
34
|
+
default: 'true'
|
|
24
35
|
}
|
|
25
36
|
};
|
|
26
37
|
},
|
|
38
|
+
parseHTML () {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
tag: 'div[data-type="instagram"]'
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
},
|
|
45
|
+
renderHTML ({ HTMLAttributes }) {
|
|
46
|
+
return [
|
|
47
|
+
'div',
|
|
48
|
+
mergeAttributes({
|
|
49
|
+
'data-type': 'instagram',
|
|
50
|
+
class: 'socialMediaContainer'
|
|
51
|
+
}),
|
|
52
|
+
[
|
|
53
|
+
'iframe',
|
|
54
|
+
mergeAttributes({
|
|
55
|
+
src: HTMLAttributes.src
|
|
56
|
+
}, HTMLAttributes)
|
|
57
|
+
]
|
|
58
|
+
];
|
|
59
|
+
},
|
|
27
60
|
addKeyboardShortcuts () {
|
|
28
61
|
return {
|
|
29
|
-
|
|
62
|
+
'Mod-Enter': ()=>{
|
|
30
63
|
return this.editor.chain().insertContentAt(this.editor.state.selection.head, {
|
|
31
64
|
type: this.type.name
|
|
32
65
|
}).focus().run();
|
|
33
66
|
}
|
|
34
67
|
};
|
|
35
68
|
},
|
|
36
|
-
renderHTML ({ HTMLAttributes }) {
|
|
37
|
-
return [
|
|
38
|
-
"instagram-component",
|
|
39
|
-
mergeAttributes(HTMLAttributes),
|
|
40
|
-
0
|
|
41
|
-
];
|
|
42
|
-
},
|
|
43
69
|
addNodeView () {
|
|
44
70
|
return ReactNodeViewRenderer(InstagramEmbed);
|
|
45
71
|
},
|
|
46
72
|
addCommands () {
|
|
47
73
|
return {
|
|
48
74
|
insertInstagram: (url, className)=>({ commands, state })=>{
|
|
75
|
+
let embedUrl = "";
|
|
76
|
+
if (url) {
|
|
77
|
+
// Convert URL to embed format
|
|
78
|
+
const urlObj = new URL(url);
|
|
79
|
+
const path = urlObj.pathname;
|
|
80
|
+
const postId = path.split('/').filter(Boolean)[1] // Get the post ID after /p/
|
|
81
|
+
;
|
|
82
|
+
if (postId) {
|
|
83
|
+
embedUrl = `https://www.instagram.com/p/${postId}/embed/`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
49
86
|
return commands.insertContent({
|
|
50
|
-
type:
|
|
87
|
+
type: 'instagram',
|
|
51
88
|
attrs: {
|
|
52
|
-
url,
|
|
53
|
-
class: className
|
|
89
|
+
url: url,
|
|
90
|
+
class: className,
|
|
91
|
+
src: embedUrl
|
|
54
92
|
}
|
|
55
93
|
});
|
|
56
94
|
}
|
|
@@ -64,7 +102,7 @@ function isValidHttpUrl(string) {
|
|
|
64
102
|
} catch (_) {
|
|
65
103
|
return false;
|
|
66
104
|
}
|
|
67
|
-
return url.protocol ===
|
|
105
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
68
106
|
}
|
|
69
107
|
|
|
70
108
|
//# sourceMappingURL=instagram.js.map
|