@@ -409,24 +409,25 @@ const pasteImageFileToMarkdown = (markdown: string, insertPosition: SupportedIns
409409 form .markdown = insertIntoTextarea (markdown , markdownArea .value as unknown as HTMLTextAreaElement , insertPosition );
410410};
411411
412- const removeImageFileFromMarkdown = (file : File ) => {
413- const strToRemove = ` .find ((key ) => files [key ] === file )}) ` .trim ();
414- setTimeout (() => {
415- // give the preview time to update
416- form .markdown = form .markdown .split (strToRemove ).join (" " );
417- }, 0 );
418- };
419-
420412const pasteFileToMarkdown = (markdown : string , insertPosition : SupportedInsertPositionType = " afterCursor" ) => {
421413 form .markdown = insertIntoTextarea (markdown , markdownArea .value as unknown as HTMLTextAreaElement , insertPosition );
422414};
423415
424416const removeFileFromMarkdown = (file : File ) => {
425- const strToRemove = ` .find ((key ) => files [key ] === file )}) ` .trim ();
426- setTimeout (() => {
427- // give the preview time to update
428- form .markdown = form .markdown .split (strToRemove ).join (" " );
429- }, 0 );
417+ const fileHash = Object .keys (files ).find ((key ) => files [key ] === file );
418+ if (isImageFile (file )) {
419+ const strToRemove = `  ` .trim ();
420+ setTimeout (() => {
421+ // give the preview time to update
422+ form .markdown = form .markdown .split (strToRemove ).join (" " );
423+ }, 0 );
424+ } else if (isAudioFile (file )) {
425+ const strToRemove = `  ` .trim ();
426+ setTimeout (() => {
427+ // give the preview time to update
428+ form .markdown = form .markdown .split (strToRemove ).join (" " );
429+ }, 0 );
430+ }
430431};
431432
432433const isImageFile = (file : File ): boolean => {
0 commit comments