@yiitap/extension-video 0.5.0 → 0.7.0
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/index.cjs +3 -1
- package/dist/index.js +4 -2
- package/dist/index.mjs +27 -8
- package/dist/types/video.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/video.ts +27 -0
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";/**
|
|
2
2
|
* Copyright 2025 Yiitap
|
|
3
3
|
* @license MIT
|
|
4
|
-
**/Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
4
|
+
**/Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("@tiptap/core"),c=/(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,a=n.Node.create({name:"video",draggable:!0,addOptions(){return{inline:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},addAttributes(){return{caption:{default:"",rendered:!1},src:{default:null,parseHTML:t=>t.firstElementChild?.src??""}}},parseHTML(){return[{tag:"video"}]},renderHTML({node:t,HTMLAttributes:e}){return["video",{caption:t.attrs.caption},["source",n.mergeAttributes(this.options.HTMLAttributes,e)]]},parseMarkdown:(t,e)=>{if(t.type==="html_block"||t.type==="html_inline"){const r=t.content,i=r.match(/<video\b([^>]*)>/i);if(!i)return{};const u=i[1],s=r.match(/<source\s+src="([^"]+)"/i),o=u.match(/caption="([^"]*)"/i);if(s)return e.createNode("video",{src:s[1],caption:o?o[1]:""})}return{}},renderMarkdown:t=>{const e=t.attrs?.src??"";return`<video caption="${t.attrs?.caption??""}" controls>
|
|
5
|
+
<source src="${e}">
|
|
6
|
+
</video>`},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[n.nodeInputRule({find:c,type:this.type,getAttributes:t=>{const[e]=t;return{src:e}}})]}});exports.Video=a;exports.default=a;exports.inputRegex=c;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
var Video=function(
|
|
1
|
+
var Video=function(r,i){"use strict";/**
|
|
2
2
|
* Copyright 2025 Yiitap
|
|
3
3
|
* @license MIT
|
|
4
|
-
**/const
|
|
4
|
+
**/const s=/(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,o=i.Node.create({name:"video",draggable:!0,addOptions(){return{inline:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},addAttributes(){return{caption:{default:"",rendered:!1},src:{default:null,parseHTML:t=>t.firstElementChild?.src??""}}},parseHTML(){return[{tag:"video"}]},renderHTML({node:t,HTMLAttributes:e}){return["video",{caption:t.attrs.caption},["source",i.mergeAttributes(this.options.HTMLAttributes,e)]]},parseMarkdown:(t,e)=>{if(t.type==="html_block"||t.type==="html_inline"){const n=t.content,c=n.match(/<video\b([^>]*)>/i);if(!c)return{};const d=c[1],a=n.match(/<source\s+src="([^"]+)"/i),u=d.match(/caption="([^"]*)"/i);if(a)return e.createNode("video",{src:a[1],caption:u?u[1]:""})}return{}},renderMarkdown:t=>{const e=t.attrs?.src??"";return`<video caption="${t.attrs?.caption??""}" controls>
|
|
5
|
+
<source src="${e}">
|
|
6
|
+
</video>`},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[i.nodeInputRule({find:s,type:this.type,getAttributes:t=>{const[e]=t;return{src:e}}})]}});return r.Video=o,r.default=o,r.inputRegex=s,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),r}({},TiptapCore);
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Node as
|
|
1
|
+
import { Node as c, nodeInputRule as a, mergeAttributes as d } from "@tiptap/core";
|
|
2
2
|
/**
|
|
3
3
|
* Copyright 2025 Yiitap
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
const
|
|
6
|
+
const u = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, l = c.create({
|
|
7
7
|
name: "video",
|
|
8
8
|
draggable: !0,
|
|
9
9
|
addOptions() {
|
|
@@ -44,9 +44,28 @@ const s = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, d = r.create({
|
|
|
44
44
|
{
|
|
45
45
|
caption: t.attrs.caption
|
|
46
46
|
},
|
|
47
|
-
["source",
|
|
47
|
+
["source", d(this.options.HTMLAttributes, e)]
|
|
48
48
|
];
|
|
49
49
|
},
|
|
50
|
+
parseMarkdown: (t, e) => {
|
|
51
|
+
if (t.type === "html_block" || t.type === "html_inline") {
|
|
52
|
+
const r = t.content, n = r.match(/<video\b([^>]*)>/i);
|
|
53
|
+
if (!n) return {};
|
|
54
|
+
const o = n[1], i = r.match(/<source\s+src="([^"]+)"/i), s = o.match(/caption="([^"]*)"/i);
|
|
55
|
+
if (i)
|
|
56
|
+
return e.createNode("video", {
|
|
57
|
+
src: i[1],
|
|
58
|
+
caption: s ? s[1] : ""
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return {};
|
|
62
|
+
},
|
|
63
|
+
renderMarkdown: (t) => {
|
|
64
|
+
const e = t.attrs?.src ?? "";
|
|
65
|
+
return `<video caption="${t.attrs?.caption ?? ""}" controls>
|
|
66
|
+
<source src="${e}">
|
|
67
|
+
</video>`;
|
|
68
|
+
},
|
|
50
69
|
addCommands() {
|
|
51
70
|
return {
|
|
52
71
|
setVideo: (t) => ({ commands: e }) => e.insertContent({
|
|
@@ -57,8 +76,8 @@ const s = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, d = r.create({
|
|
|
57
76
|
},
|
|
58
77
|
addInputRules() {
|
|
59
78
|
return [
|
|
60
|
-
|
|
61
|
-
find:
|
|
79
|
+
a({
|
|
80
|
+
find: u,
|
|
62
81
|
type: this.type,
|
|
63
82
|
getAttributes: (t) => {
|
|
64
83
|
const [e] = t;
|
|
@@ -69,7 +88,7 @@ const s = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, d = r.create({
|
|
|
69
88
|
}
|
|
70
89
|
});
|
|
71
90
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
91
|
+
l as Video,
|
|
92
|
+
l as default,
|
|
93
|
+
u as inputRegex
|
|
75
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,cAAc,CAAA;AAEnE,eAAO,MAAM,UAAU,QAAqD,CAAA;AAE5E,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,KAAK,EAAE;YACL,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,UAAU,CAAA;SACvC,CAAA;KACF;CACF;AAED,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,cAAc,CAAA;AAEnE,eAAO,MAAM,UAAU,QAAqD,CAAA;AAE5E,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,KAAK,EAAE;YACL,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,UAAU,CAAA;SACvC,CAAA;KACF;CACF;AAED,eAAO,MAAM,KAAK,gBA4GhB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yiitap/extension-video",
|
|
3
3
|
"description": "Video extension",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Yiitap",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@tiptap/core": "^3.7.
|
|
30
|
-
"@tiptap/pm": "^3.7.
|
|
29
|
+
"@tiptap/core": "^3.7.2",
|
|
30
|
+
"@tiptap/pm": "^3.7.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {},
|
|
33
33
|
"scripts": {
|
package/src/video.ts
CHANGED
|
@@ -65,6 +65,33 @@ export const Video = Node.create({
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
+
parseMarkdown: (token, helpers) => {
|
|
69
|
+
if (token.type === 'html_block' || token.type === 'html_inline') {
|
|
70
|
+
const html = token.content
|
|
71
|
+
const videoMatch = html.match(/<video\b([^>]*)>/i)
|
|
72
|
+
if (!videoMatch) return {}
|
|
73
|
+
|
|
74
|
+
const attrsStr = videoMatch[1]
|
|
75
|
+
const srcMatch = html.match(/<source\s+src="([^"]+)"/i)
|
|
76
|
+
const captionMatch = attrsStr.match(/caption="([^"]*)"/i)
|
|
77
|
+
if (srcMatch) {
|
|
78
|
+
return helpers.createNode('video', {
|
|
79
|
+
src: srcMatch[1],
|
|
80
|
+
caption: captionMatch ? captionMatch[1] : '',
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return {}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
renderMarkdown: (node) => {
|
|
88
|
+
const src = node.attrs?.src ?? ''
|
|
89
|
+
const caption = node.attrs?.caption ?? ''
|
|
90
|
+
return `<video caption="${caption}" controls>
|
|
91
|
+
<source src="${src}">
|
|
92
|
+
</video>`
|
|
93
|
+
},
|
|
94
|
+
|
|
68
95
|
addCommands() {
|
|
69
96
|
return {
|
|
70
97
|
setVideo:
|