-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ui): update image dimensions and mime type handling #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
1ca420e
ef5e949
27e0357
c3b2f40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,10 +41,17 @@ const actions = { | |
|
|
||
| commit(BLANCHETTE_EDITOR_IS_LOADING) | ||
|
|
||
| // TODO: update document width and height | ||
| return DocumentApi.setDocument(formData) | ||
| .then(async (response) => { | ||
| const data = await response.json() | ||
| const data = await response.json().catch(() => null) | ||
|
|
||
| if (!response.ok) { | ||
| throw ( | ||
| data ?? | ||
| new Error(response.statusText || 'Request failed') | ||
| ) | ||
| } | ||
|
|
||
| commit(BLANCHETTE_EDITOR_LOADED) | ||
| if (data && data.path) { | ||
| window.dispatchEvent( | ||
|
|
@@ -56,13 +63,36 @@ const actions = { | |
| }), | ||
| ) | ||
| commit(BLANCHETTE_EDITOR_SAVE_SUCCESS, { path: data.path }) | ||
| return data | ||
| } else { | ||
| throw new Error('No path found') | ||
| } | ||
|
Comment on lines
+66
to
69
|
||
| }) | ||
| .catch(async (error) => { | ||
| let parsedError = null | ||
|
|
||
| if ( | ||
| error?.response && | ||
| typeof error.response.json === 'function' | ||
| ) { | ||
| parsedError = await error.response.json().catch(() => null) | ||
| } else if ( | ||
| error && | ||
| typeof error === 'object' && | ||
| !(error instanceof Error) | ||
| ) { | ||
| parsedError = error | ||
| } | ||
|
|
||
| const errorMessage = | ||
| parsedError?.humanMessage || | ||
| parsedError?.message || | ||
| (error instanceof Error ? error.message : 'Request failed') | ||
|
|
||
| commit(BLANCHETTE_EDITOR_ERROR, { | ||
| error: await error.response.json(), | ||
| error: { | ||
| message: errorMessage, | ||
| }, | ||
| }) | ||
| commit(BLANCHETTE_EDITOR_LOADED) | ||
| }) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolveOutputMimeTypenow allowsimage/webp, but the crop implementation later treats any non-PNG output as needing a whitefillColorbackground. Since WebP supports alpha like PNG, this will flatten transparency when outputting WebP. Adjust the crop canvas options logic to avoid forcing a fill color for WebP outputs.