cleanup (broken files)

This commit is contained in:
2026-03-12 17:23:28 -05:00
parent f53030294b
commit df94685c96
6 changed files with 65 additions and 47 deletions
+25 -13
View File
@@ -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;
};
}
}