diff --git a/shared/editor/commands/insertFiles.ts b/shared/editor/commands/insertFiles.ts index 3982fe73d..78d512445 100644 --- a/shared/editor/commands/insertFiles.ts +++ b/shared/editor/commands/insertFiles.ts @@ -13,12 +13,16 @@ export type Options = { isAttachment?: boolean; /** Set to true to replace any existing image at the users selection */ replaceExisting?: boolean; - /** Width to use when inserting image */ - width?: number; uploadFile?: (file: File) => Promise; onFileUploadStart?: () => void; onFileUploadStop?: () => void; onShowToast: (message: string) => void; + attrs?: { + /** Width to use when inserting image */ + width?: number; + /** Height to use when inserting image */ + height?: number; + }; }; const insertFiles = function ( @@ -124,7 +128,7 @@ const insertFiles = function ( .replaceWith( from, to || from, - schema.nodes.image.create({ src, width: options.width }) + schema.nodes.image.create({ src, ...options.attrs }) ) .setMeta(uploadPlaceholderPlugin, { remove: { id: upload.id } }) ); diff --git a/shared/editor/components/Image.tsx b/shared/editor/components/Image.tsx index d4017db88..441144895 100644 --- a/shared/editor/components/Image.tsx +++ b/shared/editor/components/Image.tsx @@ -199,15 +199,17 @@ const Image = ( } }} /> - + {!loaded && ( + + )} {isEditable && !isFullWidth && isResizable && ( <> diff --git a/shared/editor/nodes/Image.tsx b/shared/editor/nodes/Image.tsx index 5f14e975a..5c6a0b399 100644 --- a/shared/editor/nodes/Image.tsx +++ b/shared/editor/nodes/Image.tsx @@ -200,11 +200,13 @@ export default class Image extends SimpleImage { const { tr } = view.state; const pos = getPos(); - const transaction = tr.setNodeMarkup(pos, undefined, { - ...node.attrs, - width, - height, - }); + const transaction = tr + .setNodeMarkup(pos, undefined, { + ...node.attrs, + width, + height, + }) + .setMeta("addToHistory", true); const $pos = transaction.doc.resolve(getPos()); view.dispatch(transaction.setSelection(new NodeSelection($pos))); }; diff --git a/shared/editor/nodes/SimpleImage.tsx b/shared/editor/nodes/SimpleImage.tsx index a3153c0fa..e8168f9c9 100644 --- a/shared/editor/nodes/SimpleImage.tsx +++ b/shared/editor/nodes/SimpleImage.tsx @@ -225,7 +225,9 @@ export default class SimpleImage extends Node { onShowToast, dictionary: this.options.dictionary, replaceExisting: true, - width: node.attrs.width, + attrs: { + width: node.attrs.width, + }, }); }; inputElement.click();