Unable to implement parsing plugin for video tags
Closed this issue · 3 comments
chen-lee-li commented
const videoRemarkPlugin = () => (tree) => {
return (tree, file) => {
visit(tree, (node) => {
if (
node.type === 'textDirective' ||
node.type === 'leafDirective' ||
node.type === 'containerDirective'
) {
// console.log(node)
if (node.name !== 'video') return
// console.log(node)
const data = node.data || (node.data = {})
const attributes = node.attributes || {}
const src = attributes.src
if (node.type === 'textDirective') file.fail('Text directives for `video` not supported', node)
if (!src) file.fail('Missing video src', node)
console.log(node)
data.hName = 'video'
data.hProperties = {
src: src,
width: 200,
height: 200,
frameBorder: 0,
allow: 'picture-in-picture',
allowFullScreen: true
}
}
})
}
}
function videoUpload({
locale: _locale = {},
uploadFile,
accept = "*"
} = {}) {
const locale = { ...en, ..._locale };
return {
remark: (processor) =>
processor.use(remarkDirective).use(videoRemarkPlugin()),
actions: [
{
title: "Video",
icon: icons.VideoFile({}),
// cheatsheet: `::video[name="video"]{video}`,
handler: uploadFile ? {
type: "action",
async click(ctx) {
const files = await selectFiles({
accept,
multiple: false
});
if (files == null ? void 0 : files.length) {
await handleVideoUpload(ctx, uploadFile, files[0]);
}
}
} : void 0
},
],
};
}
wangxiang365 commented
你要在sanitize中把video放开
function sanitize (ast) { ast.attributes = { ...ast.attributes, ...{ video: ['src', 'width', 'height'] } } ast .tagNames = [...ast.tagNames, 'video'] retrun ast }
github-actions commented
This issue is stale because it has been open for 60 days with no activity.
github-actions commented
This issue was closed because it has been inactive for 7 days since being marked as stale.