editor: use dataurl attr for inserting an image

This commit is contained in:
Abdullah Atta
2023-03-22 09:49:06 +05:00
committed by Abdullah Atta
parent bc433c56ae
commit 4318a65a99
2 changed files with 7 additions and 4 deletions

View File

@@ -390,15 +390,18 @@ function toIEditor(editor: Editor): IEditor {
},
attachFile: (file: Attachment) => {
if (file.dataurl) {
editor.current?.commands.insertImage({ ...file, src: file.dataurl });
editor.current?.commands.insertImage({
...file,
dataurl: file.dataurl
});
} else editor.current?.commands.insertAttachment(file);
},
loadWebClip: (hash, src) =>
editor.current?.commands.updateWebClip({ hash }, { src }),
loadImage: (hash, src) =>
loadImage: (hash, dataurl) =>
editor.current?.commands.updateImage(
{ hash },
{ hash, dataurl: src, preventUpdate: true }
{ hash, dataurl, preventUpdate: true }
),
sendAttachmentProgress: (hash, type, progress) =>
editor.current?.commands.setAttachmentProgress({

View File

@@ -79,7 +79,7 @@ declare module "@tiptap/core" {
/**
* Add an image
*/
insertImage: (options: ImageAttributes) => ReturnType;
insertImage: (options: Partial<ImageAttributes>) => ReturnType;
updateImage: (
query: { src?: string; hash?: string },
options: Partial<ImageAttributes> & { preventUpdate?: boolean }