@@ -3,12 +3,17 @@ import AutoLink from "@/components/Linkable/AutoLink";
33import {
44 copyTextToClipboard ,
55 readBlobsFromClipboard ,
6- } from "@/scripts/Utils/Clipboard/clipboard" ;
7- import { NotificationType , notify } from "@/components/Notifications" ;
6+ } from "@/scripts/Utils/Clipboard" ;
7+ import {
8+ loadingNotify ,
9+ NotificationType ,
10+ notify ,
11+ } from "@/components/Notifications" ;
812import getElement from "@/scripts/Utils/Element" ;
913import ImagePreview from "@/components/BuiltInTools/ImagePreview" ;
1014import PaletteEditor from "@/components/BuiltInTools/PaletteEditor" ;
1115import { makeNaNUndefined } from "@/scripts/Utils/TypeHelp/NullUndefined" ;
16+ import { LoadingNotifyReturn } from "@/components/Notifications/notifications" ;
1217
1318export type ImageImporterToolInput = {
1419 width ?: number | undefined ;
@@ -33,6 +38,7 @@ export default function ImageImporterTool(): React.ReactNode {
3338 const [ outputBuf , setOutputBuf ] = React . useState < ArrayBuffer | null > ( null ) ;
3439
3540 const [ iframeReady , setIframeReady ] = React . useState ( false ) ;
41+ const notifyCbs = React . useRef < LoadingNotifyReturn | null > ( ) ;
3642
3743 const handleMessage = React . useCallback ( ( e : MessageEvent ) => {
3844 let data = e . data ;
@@ -50,6 +56,7 @@ export default function ImageImporterTool(): React.ReactNode {
5056 setOutputCode ( data . output_image_code ) ;
5157 setOutputBuf ( Buffer . from ( data . output_preview_img , "base64" ) ) ;
5258 setIframeReady ( true ) ;
59+ notifyCbs . current ?. successCallback ( ) ;
5360 } catch ( e ) {
5461 console . warn ( e ) ;
5562 }
@@ -78,6 +85,12 @@ export default function ImageImporterTool(): React.ReactNode {
7885 setIframeReady ( false ) ;
7986 setOutputCode ( null ) ;
8087 setOutputBuf ( null ) ;
88+ notifyCbs . current = loadingNotify (
89+ "Converting image..." ,
90+ "Conversion complete!" ,
91+ "Failed to convert!" ,
92+ "Canceled conversion." ,
93+ ) ;
8194 setTimeout ( ( ) => {
8295 iframe . contentWindow ! . postMessage (
8396 JSON . stringify ( {
@@ -247,7 +260,6 @@ export default function ImageImporterTool(): React.ReactNode {
247260 aria-describedby = "width-label"
248261 placeholder = "Leave blank to auto-calculate from height and keep aspect ratio"
249262 onChange = { ( e ) => {
250- const v = e . target . value . trim ( ) ;
251263 setOptions ( {
252264 ...options ,
253265 width : makeNaNUndefined ( parseInt ( e . target . value . trim ( ) ) ) ,
@@ -272,7 +284,6 @@ export default function ImageImporterTool(): React.ReactNode {
272284 aria-describedby = "height-label"
273285 placeholder = "Leave blank to auto-calculate from width and keep aspect ratio"
274286 onChange = { ( e ) => {
275- const v = e . target . value . trim ( ) ;
276287 setOptions ( {
277288 ...options ,
278289 height : makeNaNUndefined ( parseInt ( e . target . value . trim ( ) ) ) ,
0 commit comments