payload-richtext-tiptap 0.0.126 → 0.0.127
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 +64 -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 +63 -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 +56 -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 +64 -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 parseHTML() {\n return [\n {\n tag: 'iframe[src*=\"instagram.com\"]',\n },\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.url }, 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 if (!isValidHttpUrl(url)) {\n return false\n }\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 return false\n }\n\n const embedUrl = `https://www.instagram.com/p/${postId}/embed/`\n return commands.insertContent({\n type: 'instagram',\n attrs: {\n url: embedUrl,\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","isValidHttpUrl","urlObj","URL","path","pathname","postId","split","filter","Boolean","embedUrl","insertContent","attrs","string","_","protocol"],"mappings":"AAYA,SAASA,IAAI,EAAEC,eAAe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B,MAAMC,SAASF,KAAKG,KAAK,CAAC,KAAKC,MAAM,CAACC,QAAQ,CAAC,EAAE,CAAC,4BAA4B;;oBAC9E,IAAI,CAACH,QAAQ;wBACX,OAAO;oBACT;oBAEA,MAAMI,WAAW,CAAC,4BAA4B,EAAEJ,OAAO,OAAO,CAAC;oBAC/D,OAAON,SAASW,aAAa,CAAC;wBAC5BlB,MAAM;wBACNmB,OAAO;4BACLvC,KAAKqC;4BACLnC,OAAOwB;4BACPvB,KAAKkC;wBACP;oBACF;gBACF;QACJ;IACF;AACF,GAAE;AAEF,SAAST,eAAeY,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,gBAmGjB,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,82 @@ 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: 'iframe[src*="tiktok.com"]'
|
|
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.url
|
|
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
|
+
if (!isValidHttpUrl(url)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
// Convert URL to embed format
|
|
79
|
+
const urlObj = new URL(url);
|
|
80
|
+
const path = urlObj.pathname;
|
|
81
|
+
const videoId = path.split('/').filter(Boolean)[2] // Get video ID from path
|
|
82
|
+
;
|
|
83
|
+
if (!videoId) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
url = `https://www.tiktok.com/embed/v3/${videoId}`;
|
|
49
87
|
return commands.insertContent({
|
|
50
|
-
type:
|
|
88
|
+
type: 'tiktok',
|
|
51
89
|
attrs: {
|
|
52
90
|
url,
|
|
53
|
-
class: className
|
|
91
|
+
class: className,
|
|
92
|
+
src: url
|
|
54
93
|
}
|
|
55
94
|
});
|
|
56
95
|
}
|
|
@@ -64,7 +103,7 @@ function isValidHttpUrl(string) {
|
|
|
64
103
|
} catch (_) {
|
|
65
104
|
return false;
|
|
66
105
|
}
|
|
67
|
-
return url.protocol ===
|
|
106
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
68
107
|
}
|
|
69
108
|
|
|
70
109
|
//# 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\n parseHTML() {\n return [\n {\n tag: 'iframe[src*=\"tiktok.com\"]',\n },\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.url }, 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 if (!isValidHttpUrl(url)) {\n return false\n }\n\n // 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 if (!videoId) {\n return false\n }\n\n url = `https://www.tiktok.com/embed/v3/${videoId}`\n return commands.insertContent({\n type: 'tiktok',\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","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","isValidHttpUrl","urlObj","URL","path","pathname","videoId","split","filter","Boolean","insertContent","attrs","string","_","protocol"],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MAAM+B,OAAOF,OAAOG,QAAQ;oBAC5B,MAAMC,UAAUF,KAAKG,KAAK,CAAC,KAAKC,MAAM,CAACC,QAAQ,CAAC,EAAE,CAAC,yBAAyB;;oBAC5E,IAAI,CAACH,SAAS;wBACZ,OAAO;oBACT;oBAEAjC,MAAM,CAAC,gCAAgC,EAAEiC,QAAQ,CAAC;oBAClD,OAAON,SAASU,aAAa,CAAC;wBAC5BjB,MAAM;wBACNkB,OAAO;4BACLtC;4BACAE,OAAOwB;4BACPvB,KAAKH;wBACP;oBACF;gBACF;QACJ;IACF;AACF,GAAE;AAEF,SAAS4B,eAAeW,MAAc;IACpC,IAAIvC;IAEJ,IAAI;QACFA,MAAM,IAAI8B,IAAIS;IAChB,EAAE,OAAOC,GAAG;QACV,OAAO;IACT;IAEA,OAAOxC,IAAIyC,QAAQ,KAAK,WAAWzC,IAAIyC,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,gBA8FlB,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.url ?? HTMLAttributes.src
|
|
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,19 @@ export const Twitter = Node.create({
|
|
|
48
80
|
addCommands () {
|
|
49
81
|
return {
|
|
50
82
|
insertTwitter: (url, className)=>({ commands, state })=>{
|
|
83
|
+
const tweetMatch = url.match(/(?:twitter\.com|x\.com)\/([^\/]+)\/status\/(\d+)/);
|
|
84
|
+
let formattedUrl = url;
|
|
85
|
+
if (tweetMatch) {
|
|
86
|
+
const [_, username, tweetId] = tweetMatch;
|
|
87
|
+
formattedUrl = `https://twitter.com/${username}/status/${tweetId}`;
|
|
88
|
+
}
|
|
89
|
+
console.log('URL', url);
|
|
51
90
|
return commands.insertContent({
|
|
52
|
-
type:
|
|
91
|
+
type: 'twitter',
|
|
53
92
|
attrs: {
|
|
54
|
-
url,
|
|
55
|
-
class: className
|
|
93
|
+
url: formattedUrl,
|
|
94
|
+
class: className,
|
|
95
|
+
src: formattedUrl
|
|
56
96
|
}
|
|
57
97
|
});
|
|
58
98
|
}
|
|
@@ -66,7 +106,7 @@ function isValidHttpUrl(string) {
|
|
|
66
106
|
} catch (_) {
|
|
67
107
|
return false;
|
|
68
108
|
}
|
|
69
|
-
return url.protocol ===
|
|
109
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
70
110
|
}
|
|
71
111
|
|
|
72
112
|
//# 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.url ?? HTMLAttributes.src }, ''],\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 const tweetMatch = url.match(/(?:twitter\\.com|x\\.com)\\/([^\\/]+)\\/status\\/(\\d+)/)\n let formattedUrl = url\n if (tweetMatch) {\n const [_, username, tweetId] = tweetMatch\n formattedUrl = `https://twitter.com/${username}/status/${tweetId}`\n }\n console.log('URL', url)\n return commands.insertContent({\n type: 'twitter',\n attrs: {\n url: formattedUrl,\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","tweetMatch","match","formattedUrl","_","username","tweetId","insertContent","attrs","isValidHttpUrl","string","URL","protocol"],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oBAClB,MAAMkB,aAAa1B,IAAI2B,KAAK,CAAC;oBAC7B,IAAIC,eAAe5B;oBACnB,IAAI0B,YAAY;wBACd,MAAM,CAACG,GAAGC,UAAUC,QAAQ,GAAGL;wBAC/BE,eAAe,CAAC,oBAAoB,EAAEE,SAAS,QAAQ,EAAEC,QAAQ,CAAC;oBACpE;oBACAf,QAAQC,GAAG,CAAC,OAAOjB;oBACnB,OAAOyB,SAASO,aAAa,CAAC;wBAC5BrB,MAAM;wBACNsB,OAAO;4BACLjC,KAAK4B;4BACLzB,OAAOqB;4BACPtB,KAAK0B;wBACP;oBACF;gBACF;QACJ;IACF;AACF,GAAE;AAEF,SAASM,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:
|
|
13
|
+
tag: 'iframe[src]'
|
|
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.url
|
|
62
|
+
}, HTMLAttributes)
|
|
63
|
+
]
|
|
41
64
|
];
|
|
42
65
|
},
|
|
43
66
|
addNodeView () {
|
|
@@ -46,11 +69,38 @@ export const Youtube = Node.create({
|
|
|
46
69
|
addCommands () {
|
|
47
70
|
return {
|
|
48
71
|
insertYoutube: (url, className)=>({ commands, state })=>{
|
|
72
|
+
if (!isValidHttpUrl(url)) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
// Extract video ID from various YouTube URL formats
|
|
76
|
+
const urlObj = new URL(url);
|
|
77
|
+
let videoId = '';
|
|
78
|
+
if (urlObj.hostname === 'youtu.be') {
|
|
79
|
+
// Handle youtu.be format
|
|
80
|
+
videoId = urlObj.pathname.slice(1);
|
|
81
|
+
} else {
|
|
82
|
+
// Handle youtube.com formats
|
|
83
|
+
const searchParams = new URLSearchParams(urlObj.search);
|
|
84
|
+
videoId = searchParams.get('v') || '';
|
|
85
|
+
if (!videoId) {
|
|
86
|
+
// Try extracting from pathname for embed URLs
|
|
87
|
+
const matches = urlObj.pathname.match(/\/embed\/([^/?]+)/);
|
|
88
|
+
if (matches) {
|
|
89
|
+
videoId = matches[1];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!videoId) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
// Convert to embed URL
|
|
97
|
+
url = `https://www.youtube.com/embed/${videoId}`;
|
|
49
98
|
return commands.insertContent({
|
|
50
|
-
type:
|
|
99
|
+
type: 'youtube',
|
|
51
100
|
attrs: {
|
|
52
101
|
url,
|
|
53
|
-
class: className
|
|
102
|
+
class: className,
|
|
103
|
+
src: url
|
|
54
104
|
}
|
|
55
105
|
});
|
|
56
106
|
}
|
|
@@ -64,7 +114,7 @@ function isValidHttpUrl(string) {
|
|
|
64
114
|
} catch (_) {
|
|
65
115
|
return false;
|
|
66
116
|
}
|
|
67
|
-
return url.protocol ===
|
|
117
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
68
118
|
}
|
|
69
119
|
|
|
70
120
|
//# 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: 'iframe[src]',\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: '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.url }, HTMLAttributes)],\n ]\n },\n addNodeView() {\n return ReactNodeViewRenderer(TwitterEmbed)\n },\n\n addCommands() {\n return {\n insertYoutube:\n (url, className) =>\n ({ commands, state }) => {\n if (!isValidHttpUrl(url)) {\n return false\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 return false\n }\n\n // Convert to embed URL\n url = `https://www.youtube.com/embed/${videoId}`\n return commands.insertContent({\n type: 'youtube',\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","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","isValidHttpUrl","urlObj","URL","videoId","hostname","pathname","slice","searchParams","URLSearchParams","search","get","matches","match","insertContent","attrs","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;IAEAC;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,eAAenB,GAAG;gBAAC,GAAGmB;aAAgB;SACzE;IACH;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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"}
|