mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-03 08:35:29 +02:00
Desktop: Fixes #3324: Attaching an image, then cancelling the resize dialog, would crash the app
This commit is contained in:
parent
d9c266e3f1
commit
39a506ad52
@ -101,6 +101,10 @@ function AceEditor(props: NoteBodyEditorProps, ref: any) {
|
||||
useListIdent({ editor });
|
||||
|
||||
const aceEditor_change = useCallback((newBody: string) => {
|
||||
// Throw an error early to know what part of the code set the body to the
|
||||
// wrong value. Otherwise it will trigger an error somewhere deep in React-Ace
|
||||
// which will be hard to debug.
|
||||
if (typeof newBody !== 'string') throw new Error('Body is not a string');
|
||||
props_onChangeRef.current({ changeId: null, content: newBody });
|
||||
}, []);
|
||||
|
||||
@ -258,7 +262,7 @@ function AceEditor(props: NoteBodyEditorProps, ref: any) {
|
||||
wrapSelectionWithStrings('', '', '', cmd.value.markdownTags.join('\n'));
|
||||
} else if (cmd.value.type === 'files') {
|
||||
const newBody = await commandAttachFileToBody(props.content, cmd.value.paths, { createFileURL: !!cmd.value.createFileURL });
|
||||
aceEditor_change(newBody);
|
||||
if (newBody) aceEditor_change(newBody);
|
||||
} else {
|
||||
reg.logger().warn('AceEditor: unsupported drop item: ', cmd);
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
|
||||
|
||||
const insertResourcesIntoContent = useCallback(async (filePaths:string[] = null, options:any = null) => {
|
||||
const resourceMd = await commandAttachFileToBody('', filePaths, options);
|
||||
if (!resourceMd) return;
|
||||
const result = await props.markupToHtml(MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN, resourceMd, markupRenderOptions({ bodyOnly: true }));
|
||||
editor.insertContent(result.html);
|
||||
// editor.fire('joplinChange');
|
||||
|
@ -120,7 +120,7 @@ export async function handlePasteEvent(event:any) {
|
||||
const md = await commandAttachFileToBody('', [filePath]);
|
||||
await shim.fsDriver().remove(filePath);
|
||||
|
||||
output.push(md);
|
||||
if (md) output.push(md);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
|
Loading…
Reference in New Issue
Block a user