@ampless/plugin-youtube 1.0.0-alpha.4 → 1.0.0-alpha.6
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/editor.d.ts +14 -1
- package/dist/editor.js +17 -1
- package/package.json +2 -2
package/dist/editor.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
|
+
import { TiptapNodeMarkdownAdapters } from 'ampless';
|
|
2
3
|
|
|
3
4
|
declare module '@tiptap/core' {
|
|
4
5
|
interface Commands<ReturnType> {
|
|
@@ -35,4 +36,16 @@ declare const youtubeEditor: {
|
|
|
35
36
|
*/
|
|
36
37
|
declare const editorExtension: Node<any, any>;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
/**
|
|
40
|
+
* tiptap → markdown adapter map. Serialises `amplessYoutube` nodes back
|
|
41
|
+
* to a bare `https://youtu.be/<videoId>` URL line so the admin's
|
|
42
|
+
* "format: tiptap → markdown" body switch is lossless. The reverse
|
|
43
|
+
* direction (URL → embed node on paste) is handled by the existing paste
|
|
44
|
+
* rule + `extractSingleUrl` path in the runtime.
|
|
45
|
+
*
|
|
46
|
+
* `update-ampless` reads this export (via namespace import `* as`) and
|
|
47
|
+
* wires it into `installAdminTiptapNodeMarkdown`.
|
|
48
|
+
*/
|
|
49
|
+
declare const tiptapNodeToMarkdown: TiptapNodeMarkdownAdapters;
|
|
50
|
+
|
|
51
|
+
export { AmplessYoutubeNode, editorExtension, tiptapNodeToMarkdown, youtubeEditor };
|
package/dist/editor.js
CHANGED
|
@@ -70,7 +70,15 @@ var AmplessYoutubeNode = Node.create({
|
|
|
70
70
|
return [
|
|
71
71
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
72
|
{
|
|
73
|
-
|
|
73
|
+
// tiptap's paste rule internally calls `String.prototype.matchAll`
|
|
74
|
+
// which throws when the regex doesn't carry the `g` flag. Clone
|
|
75
|
+
// the source regex (which is anchored `^...$` for use in the
|
|
76
|
+
// renderer / markdown extractor) into a global form here. Anchored
|
|
77
|
+
// global is fine — without the `m` flag, `^...$` only anchor at the
|
|
78
|
+
// start / end of the **entire input**, so this matches at most
|
|
79
|
+
// once for the pasted input as a whole (= exactly the single-URL
|
|
80
|
+
// paste case we care about).
|
|
81
|
+
find: new RegExp(YOUTUBE_URL.source, "g"),
|
|
74
82
|
handler: ({ range, match, commands }) => {
|
|
75
83
|
const videoId = match[1] ?? match[2];
|
|
76
84
|
if (!videoId) return;
|
|
@@ -88,8 +96,16 @@ var youtubeEditor = {
|
|
|
88
96
|
extension: AmplessYoutubeNode
|
|
89
97
|
};
|
|
90
98
|
var editorExtension = AmplessYoutubeNode;
|
|
99
|
+
var tiptapNodeToMarkdown = {
|
|
100
|
+
amplessYoutube: (node) => {
|
|
101
|
+
const videoId = String(node.attrs?.videoId ?? "").trim();
|
|
102
|
+
if (!videoId) return null;
|
|
103
|
+
return `https://youtu.be/${videoId}`;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
91
106
|
export {
|
|
92
107
|
AmplessYoutubeNode,
|
|
93
108
|
editorExtension,
|
|
109
|
+
tiptapNodeToMarkdown,
|
|
94
110
|
youtubeEditor
|
|
95
111
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/plugin-youtube",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"description": "YouTube embed plugin for ampless — renders youtube.com / youtu.be URLs inline as iframes in tiptap + markdown posts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@tiptap/core": "^3",
|
|
34
34
|
"react": "^18 || ^19",
|
|
35
|
-
"ampless": "1.0.0-alpha.
|
|
35
|
+
"ampless": "1.0.0-alpha.45"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@tiptap/core": "^3.23.6",
|