cleanup (broken files)
This commit is contained in:
+25
-13
@@ -27,6 +27,25 @@ export const Video = Node.create<VideoOptions>({
|
||||
src: {
|
||||
default: null,
|
||||
},
|
||||
filename: {
|
||||
default: null,
|
||||
parseHTML: element => element.getAttribute('data-filename'),
|
||||
renderHTML: attributes => {
|
||||
if (!attributes.filename) return {};
|
||||
return { 'data-filename': attributes.filename };
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
setVideo: (options: { src: string, filename?: string }) => ({ commands }) => {
|
||||
return commands.insertContent({
|
||||
type: this.name,
|
||||
attrs: options,
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -76,7 +95,11 @@ export const Video = Node.create<VideoOptions>({
|
||||
const video = document.createElement('video');
|
||||
Object.entries(node.attrs).forEach(([key, value]) => {
|
||||
if (value !== null && value !== undefined) {
|
||||
video.setAttribute(key, value);
|
||||
if (key === 'filename') {
|
||||
video.setAttribute('data-filename', value);
|
||||
} else {
|
||||
video.setAttribute(key, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
// Apply default attributes if not present
|
||||
@@ -115,23 +138,12 @@ export const Video = Node.create<VideoOptions>({
|
||||
};
|
||||
};
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
setVideo: (options: { src: string }) => ({ commands }) => {
|
||||
return commands.insertContent({
|
||||
type: this.name,
|
||||
attrs: options,
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands<ReturnType> {
|
||||
video: {
|
||||
setVideo: (options: { src: string }) => ReturnType;
|
||||
setVideo: (options: { src: string, filename?: string }) => ReturnType;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user