|
@@ -3,18 +3,14 @@ import { useCallback } from 'react';
|
|
|
import { useSWRStatic } from '@growi/core/dist/swr';
|
|
import { useSWRStatic } from '@growi/core/dist/swr';
|
|
|
import type { SWRResponse } from 'swr';
|
|
import type { SWRResponse } from 'swr';
|
|
|
|
|
|
|
|
-type DrawioModalSaveHandler = () => void;
|
|
|
|
|
-
|
|
|
|
|
type DrawioModalStatus = {
|
|
type DrawioModalStatus = {
|
|
|
isOpened: boolean,
|
|
isOpened: boolean,
|
|
|
editorKey: string | undefined,
|
|
editorKey: string | undefined,
|
|
|
- onSave?: DrawioModalSaveHandler,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type DrawioModalStatusUtils = {
|
|
type DrawioModalStatusUtils = {
|
|
|
open(
|
|
open(
|
|
|
editorKey: string,
|
|
editorKey: string,
|
|
|
- onSave?: DrawioModalSaveHandler,
|
|
|
|
|
): void,
|
|
): void,
|
|
|
close(): void,
|
|
close(): void,
|
|
|
}
|
|
}
|
|
@@ -28,12 +24,12 @@ export const useDrawioModalForEditor = (status?: DrawioModalStatus): SWRResponse
|
|
|
|
|
|
|
|
const { mutate } = swrResponse;
|
|
const { mutate } = swrResponse;
|
|
|
|
|
|
|
|
- const open = useCallback((editorKey: string | undefined, onSave?: DrawioModalSaveHandler): void => {
|
|
|
|
|
- mutate({ isOpened: true, editorKey, onSave });
|
|
|
|
|
|
|
+ const open = useCallback((editorKey: string | undefined): void => {
|
|
|
|
|
+ mutate({ isOpened: true, editorKey });
|
|
|
}, [mutate]);
|
|
}, [mutate]);
|
|
|
|
|
|
|
|
const close = useCallback((): void => {
|
|
const close = useCallback((): void => {
|
|
|
- mutate({ isOpened: false, editorKey: undefined, onSave: undefined });
|
|
|
|
|
|
|
+ mutate({ isOpened: false, editorKey: undefined });
|
|
|
}, [mutate]);
|
|
}, [mutate]);
|
|
|
|
|
|
|
|
return {
|
|
return {
|