sanity-io / sanity-plugin-markdown

Markdown support in the Sanity Studio
MIT License
50 stars 8 forks source link

Loading editor takes a long time #101

Closed javayhu closed 1 week ago

javayhu commented 1 week ago

If you find a security vulnerability, do NOT open an issue. Email security@sanity.io instead.

Describe the bug

Loading editor takes a long time, even if the content is very small

To Reproduce

open a document using this Markdown Editor

Expected behavior

load Markdown Editor faster

Screenshots

SCR-20240910-bssy SCR-20240910-bsty

Which versions of Sanity are you using?

Run sanity versions in the terminal and copy-paste the result here.

What operating system are you using?

macOS 14.4.1 (23E224)

Which versions of Node.js / npm are you running?

npm -v && node -v
10.7.0
v22.2.0

Additional context

the source code of CustomMarkdownInput

import { useMemo } from 'react';
import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown';

import '@/styles/mde.css';
import 'easymde/dist/easymde.min.css';

const mdeOptions = {
    toolbar: ["heading", "bold", "italic", "strikethrough",
        "code", "quote", "unordered-list", "ordered-list",
        "link", "upload-image", "horizontal-rule",
        "preview", "side-by-side"],
    previewClass: ['prose', 'prose-slate', 'dark:prose-invert',
        'bg-background', 'text-foreground'],
};

export function CustomMarkdownInput(props: MarkdownInputProps) {
    const reactMdeProps: MarkdownInputProps['reactMdeProps'] =
        useMemo(() => {
            return {
                options: mdeOptions,
            }
        }, []);

    return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />
}
javayhu commented 1 week ago

The editor seems to be OK if I turned off disable cache on Chrome Inspector, so I close this issue.

javayhu commented 1 week ago

When I use sanity studio in my home network, and turn off disable caceh on Chrome Inspector, the problem is still there.

Maybe it's related to the network, but I think there maybe other reasons, since images and other content have already loaded, but the editor still takes a long time to show.

Anyone can help me?