fix: move options back to UmbImage element to ensure everything is available when the editor loads

This commit is contained in:
Jacob Overgaard
2024-09-19 16:08:39 +02:00
parent 1b2b35a94d
commit fc5c3e8dcf
2 changed files with 3 additions and 32 deletions

View File

@@ -20,6 +20,8 @@ export const UmbImage = Image.extend({
sizes: {
default: null,
},
'data-tmpimg': { default: null },
'data-udi': { default: null },
};
},
});
@@ -44,6 +46,7 @@ declare module '@tiptap/core' {
loading?: string;
srcset?: string;
sizes?: string;
'data-tmpimg'?: string;
}) => ReturnType;
};
}

View File

@@ -50,12 +50,6 @@ export default class UmbTiptapMediaUploadExtension extends UmbTiptapExtensionApi
return [
UmbImage.extend({
name: 'umbMediaUpload',
addAttributes() {
return {
...this.parent?.(),
'data-tmpimg': { default: null },
};
},
onCreate() {
this.parent?.();
const host = this.editor.view.dom;
@@ -167,29 +161,3 @@ export default class UmbTiptapMediaUploadExtension extends UmbTiptapExtensionApi
return promise;
}
}
declare module '@tiptap/core' {
interface Commands<ReturnType> {
umbMediaUpload: {
/**
* Add an image
* @param options The image attributes
* @example
* editor
* .commands
* .setImage({ src: 'https://tiptap.dev/logo.png', alt: 'tiptap', title: 'tiptap logo' })
*/
setImage: (options: {
src: string;
alt?: string;
title?: string;
width?: string;
height?: string;
loading?: string;
srcset?: string;
sizes?: string;
'data-tmpimg'?: string;
}) => ReturnType;
};
}
}