mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
loader
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
} from "@/features/editor/components/table/types/types.ts";
|
||||
import {
|
||||
ActionIcon,
|
||||
LoadingOverlay,
|
||||
Modal,
|
||||
Text,
|
||||
Tooltip,
|
||||
@@ -46,6 +47,8 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
const computedColorScheme = useComputedColorScheme();
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const editorState = useEditorState({
|
||||
editor,
|
||||
@@ -140,6 +143,7 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
if (isSavingRef.current) return;
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const svgString = decodeBase64ToSvgString(svgXml);
|
||||
@@ -167,6 +171,7 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
}, [editor, editorState?.attachmentId]);
|
||||
|
||||
@@ -196,6 +201,7 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
const handleOpen = useCallback(async () => {
|
||||
if (!editorState?.src) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const url = getFileUrl(editorState.src);
|
||||
const request = await fetch(url, {
|
||||
@@ -213,6 +219,7 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
isDirtyRef.current = false;
|
||||
open();
|
||||
}
|
||||
@@ -307,6 +314,7 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
size="lg"
|
||||
aria-label={t("Edit")}
|
||||
variant="subtle"
|
||||
loading={isLoading}
|
||||
>
|
||||
<IconEdit size={18} />
|
||||
</ActionIcon>
|
||||
@@ -339,7 +347,8 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
<Modal.Root opened={opened} onClose={handleClose} fullScreen closeOnEscape={false}>
|
||||
<Modal.Overlay />
|
||||
<Modal.Content style={{ overflow: "hidden" }}>
|
||||
<Modal.Body>
|
||||
<Modal.Body pos="relative">
|
||||
<LoadingOverlay visible={isSaving} />
|
||||
<div style={{ height: "100vh" }}>
|
||||
<DrawIoEmbed
|
||||
ref={drawioRef}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
|
||||
import {
|
||||
ActionIcon,
|
||||
Card,
|
||||
LoadingOverlay,
|
||||
Modal,
|
||||
Text,
|
||||
useComputedColorScheme,
|
||||
@@ -34,6 +35,7 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
const computedColorScheme = useComputedColorScheme();
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
const handleOpen = async () => {
|
||||
if (!editor.isEditable) {
|
||||
@@ -47,6 +49,7 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
if (isSavingRef.current) return;
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const svgString = decodeBase64ToSvgString(svgXml);
|
||||
@@ -79,6 +82,7 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -136,7 +140,8 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
<Modal.Root opened={opened} onClose={handleClose} fullScreen closeOnEscape={false}>
|
||||
<Modal.Overlay />
|
||||
<Modal.Content style={{ overflow: "hidden" }}>
|
||||
<Modal.Body>
|
||||
<Modal.Body pos="relative">
|
||||
<LoadingOverlay visible={isSaving} />
|
||||
<div style={{ height: "100vh" }}>
|
||||
<DrawIoEmbed
|
||||
ref={drawioRef}
|
||||
|
||||
@@ -56,6 +56,8 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
const computedColorScheme = useComputedColorScheme();
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const isInitialLoadRef = useRef(true);
|
||||
const lastFingerprintRef = useRef("");
|
||||
|
||||
@@ -153,6 +155,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
const handleOpen = useCallback(async () => {
|
||||
if (!editorState?.src) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const url = getFileUrl(editorState.src);
|
||||
const request = await fetch(url, {
|
||||
@@ -166,6 +169,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
isDirtyRef.current = false;
|
||||
isInitialLoadRef.current = true;
|
||||
open();
|
||||
@@ -178,6 +182,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
}
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
||||
@@ -223,6 +228,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
}, [editor, excalidrawAPI, editorState?.attachmentId]);
|
||||
|
||||
@@ -339,6 +345,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
size="lg"
|
||||
aria-label={t("Edit")}
|
||||
variant="subtle"
|
||||
loading={isLoading}
|
||||
>
|
||||
<IconEdit size={18} />
|
||||
</ActionIcon>
|
||||
@@ -390,7 +397,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
bg="var(--mantine-color-body)"
|
||||
p="xs"
|
||||
>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"}>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"} loading={isSaving}>
|
||||
{t("Save & Exit")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
||||
|
||||
@@ -52,6 +52,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const isInitialLoadRef = useRef(true);
|
||||
const lastFingerprintRef = useRef("");
|
||||
|
||||
@@ -70,6 +71,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
}
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
||||
@@ -120,6 +122,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
}, [excalidrawAPI, editor, attachmentId, updateAttributes]);
|
||||
|
||||
@@ -191,7 +194,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
bg="var(--mantine-color-body)"
|
||||
p="xs"
|
||||
>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"}>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"} loading={isSaving}>
|
||||
{t("Save & Exit")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
||||
|
||||
Reference in New Issue
Block a user