|
@@ -7,13 +7,13 @@ type DrawioModalSaveHandler = () => void;
|
|
|
|
|
|
|
|
type DrawioModalStatus = {
|
|
type DrawioModalStatus = {
|
|
|
isOpened: boolean,
|
|
isOpened: boolean,
|
|
|
- editorKey?: string,
|
|
|
|
|
|
|
+ editorKey: string,
|
|
|
onSave?: DrawioModalSaveHandler,
|
|
onSave?: DrawioModalSaveHandler,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type DrawioModalStatusUtils = {
|
|
type DrawioModalStatusUtils = {
|
|
|
open(
|
|
open(
|
|
|
- editorKey?: string,
|
|
|
|
|
|
|
+ editorKey: string,
|
|
|
onSave?: DrawioModalSaveHandler,
|
|
onSave?: DrawioModalSaveHandler,
|
|
|
): void,
|
|
): void,
|
|
|
close(): void,
|
|
close(): void,
|
|
@@ -22,17 +22,18 @@ type DrawioModalStatusUtils = {
|
|
|
export const useDrawioModalForEditor = (status?: DrawioModalStatus): SWRResponse<DrawioModalStatus, Error> & DrawioModalStatusUtils => {
|
|
export const useDrawioModalForEditor = (status?: DrawioModalStatus): SWRResponse<DrawioModalStatus, Error> & DrawioModalStatusUtils => {
|
|
|
const initialData: DrawioModalStatus = {
|
|
const initialData: DrawioModalStatus = {
|
|
|
isOpened: false,
|
|
isOpened: false,
|
|
|
|
|
+ editorKey: '',
|
|
|
};
|
|
};
|
|
|
const swrResponse = useSWRStatic<DrawioModalStatus, Error>('drawioModalStatus', status, { fallbackData: initialData });
|
|
const swrResponse = useSWRStatic<DrawioModalStatus, Error>('drawioModalStatus', status, { fallbackData: initialData });
|
|
|
|
|
|
|
|
const { mutate } = swrResponse;
|
|
const { mutate } = swrResponse;
|
|
|
|
|
|
|
|
- const open = useCallback((editorKey?: string, onSave?: DrawioModalSaveHandler): void => {
|
|
|
|
|
|
|
+ const open = useCallback((editorKey: string, onSave?: DrawioModalSaveHandler): void => {
|
|
|
mutate({ isOpened: true, editorKey, onSave });
|
|
mutate({ isOpened: true, editorKey, onSave });
|
|
|
}, [mutate]);
|
|
}, [mutate]);
|
|
|
|
|
|
|
|
const close = useCallback((): void => {
|
|
const close = useCallback((): void => {
|
|
|
- mutate({ isOpened: false, editorKey: undefined, onSave: undefined });
|
|
|
|
|
|
|
+ mutate({ isOpened: false, editorKey: '', onSave: undefined });
|
|
|
}, [mutate]);
|
|
}, [mutate]);
|
|
|
|
|
|
|
|
return {
|
|
return {
|