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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.ts"],"sourcesContent":["declare module
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Instagram/instagram.ts"],"sourcesContent":["declare module '@tiptap/core' {\n interface Commands<ReturnType> {\n instagram: {\n /**\n * Add an image\n */\n\n insertInstagram: (url?: string, className?: string) => ReturnType\n }\n }\n}\n\nimport { Node, mergeAttributes } from '@tiptap/core'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\nimport InstagramEmbed from './InstagramEmbed.js'\n\nexport const Instagram = Node.create({\n name: 'instagram',\n\n group: 'block',\n content: 'inline*',\n draggable: true,\n // content: 'inline*',\n\n addAttributes() {\n return {\n url: { default: null },\n class: { default: null },\n src: {\n default: null,\n },\n width: {\n default: '400',\n },\n height: {\n default: '480',\n },\n frameborder: {\n default: '0',\n },\n scrolling: {\n default: 'no',\n },\n allowtransparency: {\n default: 'true',\n },\n }\n },\n\n\n parseHTML() {\n return [\n {\n tag: 'div[data-type=\"instagram\"]',\n },\n ]\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes({\n 'data-type': 'instagram',\n class: 'socialMediaContainer',\n }),\n ['iframe', mergeAttributes({ src: HTMLAttributes.src }, HTMLAttributes)],\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 addNodeView() {\n return ReactNodeViewRenderer(InstagramEmbed)\n },\n\n addCommands() {\n return {\n insertInstagram:\n (url, className) =>\n ({ commands, state }) => {\n let embedUrl = \"\"\n if (url) {\n\n // Convert URL to embed format\n const urlObj = new URL(url)\n const path = urlObj.pathname\n const postId = path.split('/').filter(Boolean)[1] // Get the post ID after /p/\n if (postId) {\n embedUrl = `https://www.instagram.com/p/${postId}/embed/`\n }\n }\n return commands.insertContent({\n type: 'instagram',\n attrs: {\n url: url,\n class: className,\n src: embedUrl,\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","InstagramEmbed","Instagram","create","name","group","content","draggable","addAttributes","url","default","class","src","width","height","frameborder","scrolling","allowtransparency","parseHTML","tag","renderHTML","HTMLAttributes","addKeyboardShortcuts","editor","chain","insertContentAt","state","selection","head","type","focus","run","addNodeView","addCommands","insertInstagram","className","commands","embedUrl","urlObj","URL","path","pathname","postId","split","filter","Boolean","insertContent","attrs","isValidHttpUrl","string","_","protocol"],"mappings":"AAYA,SAASA,IAAI,EAAEC,eAAe,QAAQ,eAAc;AACpD,S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KAAKC,MAAM,CAACC,QAAQ,CAAC,EAAE,CAAC,4BAA4B;;wBAC9E,IAAIH,QAAQ;4BACVL,WAAW,CAAC,4BAA4B,EAAEK,OAAO,OAAO,CAAC;wBAC3D;oBACF;oBACA,OAAON,SAASU,aAAa,CAAC;wBAC5BjB,MAAM;wBACNkB,OAAO;4BACLtC,KAAKA;4BACLE,OAAOwB;4BACPvB,KAAKyB;wBACP;oBACF;gBACF;QACN;IACF;AACF,GAAE;AAEF,SAASW,eAAeC,MAAc;IACpC,IAAIxC;IAEJ,IAAI;QACFA,MAAM,IAAI8B,IAAIU;IAChB,EAAE,OAAOC,GAAG;QACV,OAAO;IACT;IAEA,OAAOzC,IAAI0C,QAAQ,KAAK,WAAW1C,IAAI0C,QAAQ,KAAK;AACtD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module '@tiptap/core' {
|
|
2
2
|
interface Commands<ReturnType> {
|
|
3
3
|
tiktok: {
|
|
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 Tiktok: Node<any, any>;
|
|
13
13
|
//# sourceMappingURL=tiktok.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiktok.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,MAAM,EAAE;YACN;;eAEG;YAEH,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"tiktok.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,MAAM,EAAE;YACN;;eAEG;YAEH,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,CAAA;SAC/D,CAAA;KACF;CACF;AAED,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAA;AAIpD,eAAO,MAAM,MAAM,gBAiGjB,CAAA"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
2
|
-
import { ReactNodeViewRenderer } from
|
|
3
|
-
import TiktokEmbed from
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
+
import TiktokEmbed from './TiktokEmbed.js';
|
|
4
4
|
export const Tiktok = Node.create({
|
|
5
|
-
name:
|
|
6
|
-
group:
|
|
7
|
-
content:
|
|
5
|
+
name: 'tiktok',
|
|
6
|
+
group: 'block',
|
|
7
|
+
content: 'inline*',
|
|
8
8
|
draggable: true,
|
|
9
9
|
// content: 'inline*',
|
|
10
|
-
parseHTML () {
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
tag: "tiktok-component"
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
},
|
|
17
10
|
addAttributes () {
|
|
18
11
|
return {
|
|
19
12
|
url: {
|
|
@@ -21,36 +14,80 @@ export const Tiktok = 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: '100%'
|
|
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="tiktok"]'
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
},
|
|
45
|
+
renderHTML ({ HTMLAttributes }) {
|
|
46
|
+
return [
|
|
47
|
+
'div',
|
|
48
|
+
mergeAttributes({
|
|
49
|
+
'data-type': 'tiktok',
|
|
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
|
-
"tiktok-component",
|
|
39
|
-
mergeAttributes(HTMLAttributes),
|
|
40
|
-
0
|
|
41
|
-
];
|
|
42
|
-
},
|
|
43
69
|
addNodeView () {
|
|
44
70
|
return ReactNodeViewRenderer(TiktokEmbed);
|
|
45
71
|
},
|
|
46
72
|
addCommands () {
|
|
47
73
|
return {
|
|
48
74
|
insertTiktok: (url, className)=>({ commands, state })=>{
|
|
75
|
+
let embedUrl;
|
|
76
|
+
if (url) {
|
|
77
|
+
const urlObj = new URL(url);
|
|
78
|
+
const path = urlObj.pathname;
|
|
79
|
+
const videoId = path.split('/').filter(Boolean)[2] // Get video ID from path
|
|
80
|
+
;
|
|
81
|
+
if (videoId) {
|
|
82
|
+
embedUrl = `https://www.tiktok.com/embed/v3/${videoId}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
49
85
|
return commands.insertContent({
|
|
50
|
-
type:
|
|
86
|
+
type: 'tiktok',
|
|
51
87
|
attrs: {
|
|
52
88
|
url,
|
|
53
|
-
class: className
|
|
89
|
+
class: className,
|
|
90
|
+
src: embedUrl
|
|
54
91
|
}
|
|
55
92
|
});
|
|
56
93
|
}
|
|
@@ -64,7 +101,7 @@ function isValidHttpUrl(string) {
|
|
|
64
101
|
} catch (_) {
|
|
65
102
|
return false;
|
|
66
103
|
}
|
|
67
|
-
return url.protocol ===
|
|
104
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
68
105
|
}
|
|
69
106
|
|
|
70
107
|
//# sourceMappingURL=tiktok.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.ts"],"sourcesContent":["declare module
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/tiktok.ts"],"sourcesContent":["declare module '@tiptap/core' {\n interface Commands<ReturnType> {\n tiktok: {\n /**\n * Add an image\n */\n\n insertTiktok: (url?: string, className?: string) => ReturnType\n }\n }\n}\n\nimport { Node, mergeAttributes } from '@tiptap/core'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\nimport TiktokEmbed from './TiktokEmbed.js'\n\nexport const Tiktok = Node.create({\n name: 'tiktok',\n\n group: 'block',\n content: 'inline*',\n draggable: true,\n\n // content: 'inline*',\n\n addAttributes() {\n return {\n url: { default: null },\n class: { default: null },\n src: {\n default: null,\n },\n width: {\n default: '400',\n },\n height: {\n default: '100%',\n },\n frameborder: {\n default: '0',\n },\n scrolling: {\n default: 'no',\n },\n allowtransparency: {\n default: 'true',\n },\n }\n },\n parseHTML() {\n return [\n {\n tag: 'div[data-type=\"tiktok\"]',\n },\n ]\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes({\n 'data-type': 'tiktok',\n class: 'socialMediaContainer',\n }),\n ['iframe', mergeAttributes({ src: HTMLAttributes.src }, HTMLAttributes)],\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 addNodeView() {\n return ReactNodeViewRenderer(TiktokEmbed)\n },\n\n addCommands() {\n return {\n insertTiktok:\n (url, className) =>\n ({ commands, state }) => {\n\n\n let embedUrl\n if (url) { // Convert URL to embed format\n const urlObj = new URL(url)\n const path = urlObj.pathname\n const videoId = path.split('/').filter(Boolean)[2] // Get video ID from path\n\n\n if (videoId) {\n embedUrl = `https://www.tiktok.com/embed/v3/${videoId}`\n }\n }\n return commands.insertContent({\n type: 'tiktok',\n attrs: {\n url,\n class: className,\n src: embedUrl,\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","TiktokEmbed","Tiktok","create","name","group","content","draggable","addAttributes","url","default","class","src","width","height","frameborder","scrolling","allowtransparency","parseHTML","tag","renderHTML","HTMLAttributes","addKeyboardShortcuts","editor","chain","insertContentAt","state","selection","head","type","focus","run","addNodeView","addCommands","insertTiktok","className","commands","embedUrl","urlObj","URL","path","pathname","videoId","split","filter","Boolean","insertContent","attrs","isValidHttpUrl","string","_","protocol"],"mappings":"AAYA,SAASA,IAAI,EAAEC,eAAe,QAAQ,eAAc;AACpD,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,OAAOC,iBAAiB,m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S;4BACXL,WAAW,CAAC,gCAAgC,EAAEK,QAAQ,CAAC;wBACzD;oBACF;oBACA,OAAON,SAASU,aAAa,CAAC;wBAC5BjB,MAAM;wBACNkB,OAAO;4BACLtC;4BACAE,OAAOwB;4BACPvB,KAAKyB;wBACP;oBACF;gBACF;QACN;IACF;AACF,GAAE;AAEF,SAASW,eAAeC,MAAc;IACpC,IAAIxC;IAEJ,IAAI;QACFA,MAAM,IAAI8B,IAAIU;IAChB,EAAE,OAAOC,GAAG;QACV,OAAO;IACT;IAEA,OAAOzC,IAAI0C,QAAQ,KAAK,WAAW1C,IAAI0C,QAAQ,KAAK;AACtD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module '@tiptap/core' {
|
|
2
2
|
interface Commands<ReturnType> {
|
|
3
3
|
twitter: {
|
|
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 Twitter: Node<any, any>;
|
|
13
13
|
//# sourceMappingURL=twitter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twitter.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,OAAO,EAAE;YACP;;eAEG;YAEH,aAAa,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"twitter.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,OAAO,EAAE;YACP;;eAEG;YAEH,aAAa,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,CAAA;SAChE,CAAA;KACF;CACF;AAED,OAAO,EAAE,IAAI,EAA6C,MAAM,cAAc,CAAA;AAI9E,eAAO,MAAM,OAAO,gBAiGlB,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
2
|
-
import { ReactNodeViewRenderer } from
|
|
3
|
-
import TwitterEmbed from
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
+
import TwitterEmbed from './TwitterEmbed.js';
|
|
4
4
|
export const Twitter = Node.create({
|
|
5
|
-
name:
|
|
6
|
-
group:
|
|
7
|
-
content:
|
|
5
|
+
name: 'twitter',
|
|
6
|
+
group: 'block',
|
|
7
|
+
content: 'inline*',
|
|
8
8
|
draggable: true,
|
|
9
9
|
// content: 'inline*',
|
|
10
10
|
parseHTML () {
|
|
@@ -19,6 +19,9 @@ export const Twitter = Node.create({
|
|
|
19
19
|
url: {
|
|
20
20
|
default: null
|
|
21
21
|
},
|
|
22
|
+
src: {
|
|
23
|
+
default: null
|
|
24
|
+
},
|
|
22
25
|
class: {
|
|
23
26
|
default: null
|
|
24
27
|
}
|
|
@@ -26,20 +29,49 @@ export const Twitter = Node.create({
|
|
|
26
29
|
},
|
|
27
30
|
addKeyboardShortcuts () {
|
|
28
31
|
return {
|
|
29
|
-
|
|
32
|
+
'Mod-Enter': ()=>{
|
|
30
33
|
return this.editor.chain().insertContentAt(this.editor.state.selection.head, {
|
|
31
34
|
type: this.type.name
|
|
32
35
|
}).focus().run();
|
|
33
36
|
}
|
|
34
37
|
};
|
|
35
38
|
},
|
|
39
|
+
// renderHTML({ HTMLAttributes }) {
|
|
40
|
+
// return [
|
|
41
|
+
// "div",
|
|
42
|
+
// mergeAttributes(HTMLAttributes, { "data-type": "twitter" }),
|
|
43
|
+
// 0,
|
|
44
|
+
// ];
|
|
45
|
+
// },
|
|
36
46
|
renderHTML ({ HTMLAttributes }) {
|
|
47
|
+
console.log('HTMLAttributes', HTMLAttributes);
|
|
37
48
|
return [
|
|
38
|
-
|
|
39
|
-
mergeAttributes(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
'div',
|
|
50
|
+
mergeAttributes({
|
|
51
|
+
'data-type': 'twitter',
|
|
52
|
+
class: 'socialMediaContainer'
|
|
53
|
+
}, HTMLAttributes),
|
|
54
|
+
[
|
|
55
|
+
'blockquote',
|
|
56
|
+
{
|
|
57
|
+
class: 'twitter-tweet'
|
|
58
|
+
},
|
|
59
|
+
[
|
|
60
|
+
'a',
|
|
61
|
+
{
|
|
62
|
+
href: HTMLAttributes.src ?? HTMLAttributes.url
|
|
63
|
+
},
|
|
64
|
+
''
|
|
65
|
+
]
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
'script',
|
|
69
|
+
{
|
|
70
|
+
async: true,
|
|
71
|
+
src: 'https://platform.twitter.com/widgets.js',
|
|
72
|
+
charset: 'utf-8'
|
|
73
|
+
}
|
|
74
|
+
]
|
|
43
75
|
];
|
|
44
76
|
},
|
|
45
77
|
addNodeView () {
|
|
@@ -48,11 +80,21 @@ export const Twitter = Node.create({
|
|
|
48
80
|
addCommands () {
|
|
49
81
|
return {
|
|
50
82
|
insertTwitter: (url, className)=>({ commands, state })=>{
|
|
83
|
+
let formattedUrl = url;
|
|
84
|
+
if (url) {
|
|
85
|
+
const tweetMatch = url.match(/(?:twitter\.com|x\.com)\/([^\/]+)\/status\/(\d+)/);
|
|
86
|
+
if (tweetMatch) {
|
|
87
|
+
const [_, username, tweetId] = tweetMatch;
|
|
88
|
+
formattedUrl = `https://twitter.com/${username}/status/${tweetId}`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
console.log('URL', url);
|
|
51
92
|
return commands.insertContent({
|
|
52
|
-
type:
|
|
93
|
+
type: 'twitter',
|
|
53
94
|
attrs: {
|
|
54
|
-
url,
|
|
55
|
-
class: className
|
|
95
|
+
url: url,
|
|
96
|
+
class: className,
|
|
97
|
+
src: formattedUrl
|
|
56
98
|
}
|
|
57
99
|
});
|
|
58
100
|
}
|
|
@@ -66,7 +108,7 @@ function isValidHttpUrl(string) {
|
|
|
66
108
|
} catch (_) {
|
|
67
109
|
return false;
|
|
68
110
|
}
|
|
69
|
-
return url.protocol ===
|
|
111
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
70
112
|
}
|
|
71
113
|
|
|
72
114
|
//# sourceMappingURL=twitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.ts"],"sourcesContent":["declare module
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Twitter/twitter.ts"],"sourcesContent":["declare module '@tiptap/core' {\n interface Commands<ReturnType> {\n twitter: {\n /**\n * Add an image\n */\n\n insertTwitter: (url?: string, className?: string) => ReturnType\n }\n }\n}\n\nimport { Node, PasteRule, markPasteRule, mergeAttributes } from '@tiptap/core'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\nimport TwitterEmbed from './TwitterEmbed.js'\n\nexport const Twitter = Node.create({\n name: 'twitter',\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=\"twitter\"]',\n },\n ]\n },\n\n addAttributes() {\n return {\n url: { default: null },\n src: { default: null },\n class: { 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\": \"twitter\" }),\n // 0,\n // ];\n // },\n renderHTML({ HTMLAttributes }) {\n console.log('HTMLAttributes', HTMLAttributes)\n return [\n 'div',\n mergeAttributes({ 'data-type': 'twitter', class: 'socialMediaContainer' }, HTMLAttributes),\n [\n 'blockquote',\n { class: 'twitter-tweet' },\n ['a', { href:HTMLAttributes.src ?? HTMLAttributes.url }, ''],\n ],\n [\n 'script',\n {\n async: true,\n src: 'https://platform.twitter.com/widgets.js',\n charset: 'utf-8',\n },\n ],\n ]\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(TwitterEmbed)\n },\n\n addCommands() {\n return {\n insertTwitter:\n (url, className) =>\n ({ commands, state }) => {\n let formattedUrl = url\n if(url){\n\n const tweetMatch = url.match(/(?:twitter\\.com|x\\.com)\\/([^\\/]+)\\/status\\/(\\d+)/)\n if (tweetMatch) {\n const [_, username, tweetId] = tweetMatch\n formattedUrl = `https://twitter.com/${username}/status/${tweetId}`\n }\n }\n console.log('URL', url)\n return commands.insertContent({\n type: 'twitter',\n attrs: {\n url: url,\n class: className,\n src: formattedUrl,\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","TwitterEmbed","Twitter","create","name","group","content","draggable","parseHTML","tag","addAttributes","url","default","src","class","addKeyboardShortcuts","editor","chain","insertContentAt","state","selection","head","type","focus","run","renderHTML","HTMLAttributes","console","log","href","async","charset","addNodeView","addCommands","insertTwitter","className","commands","formattedUrl","tweetMatch","match","_","username","tweetId","insertContent","attrs","isValidHttpUrl","string","URL","protocol"],"mappings":"AAYA,SAASA,IAAI,EAA4BC,eAAe,QAAQ,eAAc;AAC9E,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,OAAOC,kBAAkB,oBAAmB;AAE5C,OA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AAGC,UAAUC,QAAQ,GAAGJ;4BAC/BD,eAAe,CAAC,oBAAoB,EAAEI,SAAS,QAAQ,EAAEC,QAAQ,CAAC;wBACpE;oBACF;oBACAf,QAAQC,GAAG,CAAC,OAAOjB;oBACnB,OAAOyB,SAASO,aAAa,CAAC;wBAC5BrB,MAAM;wBACNsB,OAAO;4BACLjC,KAAKA;4BACLG,OAAOqB;4BACPtB,KAAKwB;wBACP;oBACF;gBACF;QACJ;IACF;AACF,GAAE;AAEF,SAASQ,eAAeC,MAAc;IACpC,IAAInC;IAEJ,IAAI;QACFA,MAAM,IAAIoC,IAAID;IAChB,EAAE,OAAON,GAAG;QACV,OAAO;IACT;IAEA,OAAO7B,IAAIqC,QAAQ,KAAK,WAAWrC,IAAIqC,QAAQ,KAAK;AACtD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module '@tiptap/core' {
|
|
2
2
|
interface Commands<ReturnType> {
|
|
3
3
|
youtube: {
|
|
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 Youtube: Node<any, any>;
|
|
13
13
|
//# sourceMappingURL=youtube.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"youtube.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,OAAO,EAAE;YACP;;eAEG;YAEH,aAAa,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"youtube.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,OAAO,EAAE;YACP;;eAEG;YAEH,aAAa,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,UAAU,CAAA;SAChE,CAAA;KACF;CACF;AAED,OAAO,EAAE,IAAI,EAA6C,MAAM,cAAc,CAAA;AAI9E,eAAO,MAAM,OAAO,gBAiHlB,CAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
2
|
-
import { ReactNodeViewRenderer } from
|
|
3
|
-
import TwitterEmbed from
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
+
import TwitterEmbed from './YoutubeEmbed.js';
|
|
4
4
|
export const Youtube = Node.create({
|
|
5
|
-
name:
|
|
6
|
-
group:
|
|
7
|
-
content:
|
|
5
|
+
name: 'youtube',
|
|
6
|
+
group: 'block',
|
|
7
|
+
content: 'inline*',
|
|
8
8
|
draggable: true,
|
|
9
9
|
// content: 'inline*',
|
|
10
10
|
parseHTML () {
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
13
|
-
tag: "youtube
|
|
13
|
+
tag: 'div[data-type="youtube"]'
|
|
14
14
|
}
|
|
15
15
|
];
|
|
16
16
|
},
|
|
@@ -21,12 +21,27 @@ export const Youtube = Node.create({
|
|
|
21
21
|
},
|
|
22
22
|
class: {
|
|
23
23
|
default: null
|
|
24
|
+
},
|
|
25
|
+
src: {
|
|
26
|
+
default: null
|
|
27
|
+
},
|
|
28
|
+
width: {
|
|
29
|
+
default: '560'
|
|
30
|
+
},
|
|
31
|
+
height: {
|
|
32
|
+
default: '315'
|
|
33
|
+
},
|
|
34
|
+
frameborder: {
|
|
35
|
+
default: '0'
|
|
36
|
+
},
|
|
37
|
+
allowfullscreen: {
|
|
38
|
+
default: true
|
|
24
39
|
}
|
|
25
40
|
};
|
|
26
41
|
},
|
|
27
42
|
addKeyboardShortcuts () {
|
|
28
43
|
return {
|
|
29
|
-
|
|
44
|
+
'Mod-Enter': ()=>{
|
|
30
45
|
return this.editor.chain().insertContentAt(this.editor.state.selection.head, {
|
|
31
46
|
type: this.type.name
|
|
32
47
|
}).focus().run();
|
|
@@ -35,9 +50,17 @@ export const Youtube = Node.create({
|
|
|
35
50
|
},
|
|
36
51
|
renderHTML ({ HTMLAttributes }) {
|
|
37
52
|
return [
|
|
38
|
-
|
|
39
|
-
mergeAttributes(
|
|
40
|
-
|
|
53
|
+
'div',
|
|
54
|
+
mergeAttributes({
|
|
55
|
+
'data-type': 'youtube',
|
|
56
|
+
class: 'socialMediaContainer'
|
|
57
|
+
}),
|
|
58
|
+
[
|
|
59
|
+
'iframe',
|
|
60
|
+
mergeAttributes({
|
|
61
|
+
src: HTMLAttributes.src
|
|
62
|
+
}, HTMLAttributes)
|
|
63
|
+
]
|
|
41
64
|
];
|
|
42
65
|
},
|
|
43
66
|
addNodeView () {
|
|
@@ -46,11 +69,37 @@ export const Youtube = Node.create({
|
|
|
46
69
|
addCommands () {
|
|
47
70
|
return {
|
|
48
71
|
insertYoutube: (url, className)=>({ commands, state })=>{
|
|
72
|
+
let embedUrl = '';
|
|
73
|
+
if (url) {
|
|
74
|
+
// Extract video ID from various YouTube URL formats
|
|
75
|
+
const urlObj = new URL(url);
|
|
76
|
+
let videoId = '';
|
|
77
|
+
if (urlObj.hostname === 'youtu.be') {
|
|
78
|
+
// Handle youtu.be format
|
|
79
|
+
videoId = urlObj.pathname.slice(1);
|
|
80
|
+
} else {
|
|
81
|
+
// Handle youtube.com formats
|
|
82
|
+
const searchParams = new URLSearchParams(urlObj.search);
|
|
83
|
+
videoId = searchParams.get('v') || '';
|
|
84
|
+
if (!videoId) {
|
|
85
|
+
// Try extracting from pathname for embed URLs
|
|
86
|
+
const matches = urlObj.pathname.match(/\/embed\/([^/?]+)/);
|
|
87
|
+
if (matches) {
|
|
88
|
+
videoId = matches[1];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (videoId) {
|
|
93
|
+
// Convert to embed URL
|
|
94
|
+
embedUrl = `https://www.youtube.com/embed/${videoId}`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
49
97
|
return commands.insertContent({
|
|
50
|
-
type:
|
|
98
|
+
type: 'youtube',
|
|
51
99
|
attrs: {
|
|
52
100
|
url,
|
|
53
|
-
class: className
|
|
101
|
+
class: className,
|
|
102
|
+
src: embedUrl
|
|
54
103
|
}
|
|
55
104
|
});
|
|
56
105
|
}
|
|
@@ -64,7 +113,7 @@ function isValidHttpUrl(string) {
|
|
|
64
113
|
} catch (_) {
|
|
65
114
|
return false;
|
|
66
115
|
}
|
|
67
|
-
return url.protocol ===
|
|
116
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
68
117
|
}
|
|
69
118
|
|
|
70
119
|
//# sourceMappingURL=youtube.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.ts"],"sourcesContent":["declare module
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Youtube/youtube.ts"],"sourcesContent":["declare module '@tiptap/core' {\n interface Commands<ReturnType> {\n youtube: {\n /**\n * Add an image\n */\n\n insertYoutube: (url?: string, className?: string) => ReturnType\n }\n }\n}\n\nimport { Node, PasteRule, markPasteRule, mergeAttributes } from '@tiptap/core'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\nimport TwitterEmbed from './YoutubeEmbed.js'\n\nexport const Youtube = Node.create({\n name: 'youtube',\n\n group: 'block',\n content: 'inline*',\n draggable: true,\n\n // content: 'inline*',\n parseHTML() {\n return [\n {\n tag: 'div[data-type=\"youtube\"]',\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: '560',\n },\n height: {\n default: '315',\n },\n frameborder: {\n default: '0',\n },\n allowfullscreen: {\n default: true,\n },\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': 'youtube',\n class: 'socialMediaContainer',\n }),\n ['iframe', mergeAttributes({ src: HTMLAttributes.src }, HTMLAttributes)],\n ]\n },\n addNodeView() {\n return ReactNodeViewRenderer(TwitterEmbed)\n },\n\n addCommands() {\n return {\n insertYoutube:\n (url, className) =>\n ({ commands, state }) => {\n let embedUrl = ''\n \n if(url){\n\n\n // Extract video ID from various YouTube URL formats\n const urlObj = new URL(url)\n let videoId = ''\n\n if (urlObj.hostname === 'youtu.be') {\n // Handle youtu.be format\n videoId = urlObj.pathname.slice(1)\n } else {\n // Handle youtube.com formats\n const searchParams = new URLSearchParams(urlObj.search)\n videoId = searchParams.get('v') || ''\n\n if (!videoId) {\n // Try extracting from pathname for embed URLs\n const matches = urlObj.pathname.match(/\\/embed\\/([^/?]+)/)\n if (matches) {\n videoId = matches[1]\n }\n }\n }\n\n if (videoId) {\n // Convert to embed URL\n embedUrl = `https://www.youtube.com/embed/${videoId}`\n }\n }\n\n return commands.insertContent({\n type: 'youtube',\n attrs: {\n url,\n class: className,\n src: embedUrl,\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","TwitterEmbed","Youtube","create","name","group","content","draggable","parseHTML","tag","addAttributes","url","default","class","src","width","height","frameborder","allowfullscreen","addKeyboardShortcuts","editor","chain","insertContentAt","state","selection","head","type","focus","run","renderHTML","HTMLAttributes","addNodeView","addCommands","insertYoutube","className","commands","embedUrl","urlObj","URL","videoId","hostname","pathname","slice","searchParams","URLSearchParams","search","get","matches","match","insertContent","attrs","isValidHttpUrl","string","_","protocol"],"mappings":"AAYA,SAASA,IAAI,EAA4BC,eAAe,QAAQ,eAAc;AAC9E,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,OAAOC,kBAAkB,oBAAmB;AAE5C,OAAO,MAAMC,UAAUJ,KAAKK,MAAM,CAAC;IACjCC,MAAM;IAENC,OAAO;IACPC,SAAS;IACTC,WAAW;IAEX,sBAAsB;IACtBC;QACE,OAAO;YACL;gBACEC,KAAK;YACP;SACD;IACH;IACAC;QACE,OAAO;YACLC,KAAK;gBAAEC,SAAS;YAAK;YACrBC,OAAO;gBAAED,SAAS;YAAK;YACvBE,KAAK;gBACHF,SAAS;YACX;YACAG,OAAO;gBACLH,SAAS;YACX;YACAI,QAAQ;gBACNJ,SAAS;YACX;YACAK,aAAa;gBACXL,SAAS;YACX;YACAM,iBAAiB;gBACfN,SAAS;YACX;QACF;IACF;IAEAO;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,CAACtB,IAAI;gBACtB,GACCuB,KAAK,GACLC,GAAG;YACR;QACF;IACF;IAEAC,YAAW,EAAEC,cAAc,EAAE;QAC3B,OAAO;YACL;YACA/B,gBAAgB;gBACd,aAAa;gBACbc,OAAO;YACT;YACA;gBAAC;gBAAUd,gBAAgB;oBAAEe,KAAKgB,eAAehB,GAAG;gBAAC,GAAGgB;aAAgB;SACzE;IACH;IACAC;QACE,OAAO/B,sBAAsBC;IAC/B;IAEA+B;QACE,OAAO;YACLC,eACE,CAACtB,KAAKuB,YACN,CAAC,EAAEC,QAAQ,EAAEZ,KAAK,EAAE;oBAClB,IAAIa,WAAW;oBAEf,IAAGzB,KAAI;wBAGP,oDAAoD;wBACpD,MAAM0B,SAAS,IAAIC,IAAI3B;wBACvB,IAAI4B,UAAU;wBAEd,IAAIF,OAAOG,QAAQ,KAAK,YAAY;4BAClC,yBAAyB;4BACzBD,UAAUF,OAAOI,QAAQ,CAACC,KAAK,CAAC;wBAClC,OAAO;4BACL,6BAA6B;4BAC7B,MAAMC,eAAe,IAAIC,gBAAgBP,OAAOQ,MAAM;4BACtDN,UAAUI,aAAaG,GAAG,CAAC,QAAQ;4BAEnC,IAAI,CAACP,SAAS;gCACZ,8CAA8C;gCAC9C,MAAMQ,UAAUV,OAAOI,QAAQ,CAACO,KAAK,CAAC;gCACtC,IAAID,SAAS;oCACXR,UAAUQ,OAAO,CAAC,EAAE;gCACtB;4BACF;wBACF;wBAEA,IAAIR,SAAS;4BACX,uBAAuB;4BACvBH,WAAW,CAAC,8BAA8B,EAAEG,QAAQ,CAAC;wBACvD;oBACF;oBAEE,OAAOJ,SAASc,aAAa,CAAC;wBAC5BvB,MAAM;wBACNwB,OAAO;4BACLvC;4BACAE,OAAOqB;4BACPpB,KAAKsB;wBACP;oBACF;gBACF;QACJ;IACF;AACF,GAAE;AAEF,SAASe,eAAeC,MAAc;IACpC,IAAIzC;IAEJ,IAAI;QACFA,MAAM,IAAI2B,IAAIc;IAChB,EAAE,OAAOC,GAAG;QACV,OAAO;IACT;IAEA,OAAO1C,IAAI2C,QAAQ,KAAK,WAAW3C,IAAI2C,QAAQ,KAAK;AACtD"}
|
|
@@ -3,6 +3,6 @@ interface ExtensionKitProps {
|
|
|
3
3
|
openAssetHQHandler: openAssetHQType;
|
|
4
4
|
dir?: "ltr" | "rtl";
|
|
5
5
|
}
|
|
6
|
-
export declare const ExtensionKit: ({ dir, openAssetHQHandler, }: ExtensionKitProps) => (import("@tiptap/core").
|
|
6
|
+
export declare const ExtensionKit: ({ dir, openAssetHQHandler, }: ExtensionKitProps) => (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-subscript").SubscriptExtensionOptions, any>)[];
|
|
7
7
|
export default ExtensionKit;
|
|
8
8
|
//# sourceMappingURL=extension-kit.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONContent } from
|
|
1
|
+
import { JSONContent } from '@tiptap/core';
|
|
2
2
|
export declare const extractTiptapJson: (markdownValue: string) => JSONContent;
|
|
3
3
|
export declare const extractTiptapJsonFromHTML: (htmlinput: string) => Record<string, any>;
|
|
4
4
|
export declare const extractMarkdown: (json: any) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/lib/extract.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../../src/fields/TiptapEditor/lib/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,WAAW,EAAE,MAAM,cAAc,CAAA;AAG9E,eAAO,MAAM,iBAAiB,kBAAmB,MAAM,gBAWtD,CAAA;AAED,eAAO,MAAM,yBAAyB,cAAe,MAAM,wBAO1D,CAAA;AAED,eAAO,MAAM,eAAe,SAAU,GAAG,QAYxC,CAAA;AAED,eAAO,MAAM,OAAO,SAAU,WAAW,WAcxC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Editor, generateJSON } from
|
|
2
|
-
import ExtensionKit from
|
|
1
|
+
import { Editor, generateHTML, generateJSON } from '@tiptap/core';
|
|
2
|
+
import ExtensionKit from '../extensions/extension-kit.js';
|
|
3
3
|
export const extractTiptapJson = (markdownValue)=>{
|
|
4
4
|
const editor = new Editor({
|
|
5
5
|
content: markdownValue,
|
|
@@ -32,16 +32,18 @@ export const extractMarkdown = (json)=>{
|
|
|
32
32
|
return markdown;
|
|
33
33
|
};
|
|
34
34
|
export const getHtml = (json)=>{
|
|
35
|
-
const editor = new Editor({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
// const editor = new Editor({
|
|
36
|
+
// content: json,
|
|
37
|
+
// extensions: [
|
|
38
|
+
// ,
|
|
39
|
+
// ],
|
|
40
|
+
// });
|
|
41
|
+
return generateHTML(json, [
|
|
42
|
+
...ExtensionKit({
|
|
43
|
+
// provider,
|
|
44
|
+
openAssetHQHandler: ()=>{}
|
|
45
|
+
})
|
|
46
|
+
]);
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
//# sourceMappingURL=extract.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/lib/extract.ts"],"sourcesContent":["import { Editor, generateJSON, JSONContent } from
|
|
1
|
+
{"version":3,"sources":["../../../../../src/fields/TiptapEditor/lib/extract.ts"],"sourcesContent":["import { Editor, generateHTML, generateJSON, JSONContent } from '@tiptap/core'\nimport ExtensionKit from '../extensions/extension-kit.js'\n\nexport const extractTiptapJson = (markdownValue: string) => {\n const editor = new Editor({\n content: markdownValue,\n extensions: [\n ...ExtensionKit({\n openAssetHQHandler: () => {},\n // provider,\n }),\n ],\n })\n return editor.getJSON()\n}\n\nexport const extractTiptapJsonFromHTML = (htmlinput: string) => {\n return generateJSON(htmlinput, [\n ...ExtensionKit({\n openAssetHQHandler: () => {},\n // provider,\n }),\n ])\n}\n\nexport const extractMarkdown = (json: any) => {\n const editor = new Editor({\n content: json,\n extensions: [\n ...ExtensionKit({\n // provider,\n openAssetHQHandler: () => {},\n }),\n ],\n })\n const markdown = editor.storage.markdown.getMarkdown()\n return markdown\n}\n\nexport const getHtml = (json: JSONContent) => {\n // const editor = new Editor({\n // content: json,\n // extensions: [\n // ,\n // ],\n // });\n\n return generateHTML(json, [\n ...ExtensionKit({\n // provider,\n openAssetHQHandler: () => {},\n }),\n ])\n}\n"],"names":["Editor","generateHTML","generateJSON","ExtensionKit","extractTiptapJson","markdownValue","editor","content","extensions","openAssetHQHandler","getJSON","extractTiptapJsonFromHTML","htmlinput","extractMarkdown","json","markdown","storage","getMarkdown","getHtml"],"mappings":"AAAA,SAASA,MAAM,EAAEC,YAAY,EAAEC,YAAY,QAAqB,eAAc;AAC9E,OAAOC,kBAAkB,iCAAgC;AAEzD,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAMC,SAAS,IAAIN,OAAO;QACxBO,SAASF;QACTG,YAAY;eACPL,aAAa;gBACdM,oBAAoB,KAAO;YAE7B;SACD;IACH;IACA,OAAOH,OAAOI,OAAO;AACvB,EAAC;AAED,OAAO,MAAMC,4BAA4B,CAACC;IACxC,OAAOV,aAAaU,WAAW;WAC1BT,aAAa;YACdM,oBAAoB,KAAO;QAE7B;KACD;AACH,EAAC;AAED,OAAO,MAAMI,kBAAkB,CAACC;IAC9B,MAAMR,SAAS,IAAIN,OAAO;QACxBO,SAASO;QACTN,YAAY;eACPL,aAAa;gBACd,YAAY;gBACZM,oBAAoB,KAAO;YAC7B;SACD;IACH;IACA,MAAMM,WAAWT,OAAOU,OAAO,CAACD,QAAQ,CAACE,WAAW;IACpD,OAAOF;AACT,EAAC;AAED,OAAO,MAAMG,UAAU,CAACJ;IACtB,8BAA8B;IAC9B,mBAAmB;IACnB,kBAAkB;IAClB,MAAM;IACN,OAAO;IACP,MAAM;IAEN,OAAOb,aAAaa,MAAM;WACrBX,aAAa;YACd,YAAY;YACZM,oBAAoB,KAAO;QAC7B;KACD;AACH,EAAC"}
|