Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError on render MdPreview (SSR) #201

Open
varelaleonardo opened this issue Jan 30, 2025 · 1 comment
Open

TypeError on render MdPreview (SSR) #201

varelaleonardo opened this issue Jan 30, 2025 · 1 comment

Comments

@varelaleonardo
Copy link

描述这个Bug

Image

import { MdPreview, MdCatalog, config } from 'md-editor-rt';
import 'md-editor-rt/lib/style.css';
import './viwerServerComponent.css';
import ancher from 'markdown-it-anchor';




export default function ViwerServerComponent({ post }: { post: any }) {
    const id_preview: string = 'preview';
    config({
        markdownItConfig(mdit) {
            mdit.use(ancher, {
                permalink: ancher.permalink.headerLink(),
                permalinkClass: 'header-anchor', // Classe CSS para o link de permalink
                permalinkBefore: false, // Coloca o link de permalink após o título
                slugify: (s: any) => s
                    .toLowerCase() // Converte para minúsculas
                    .replace(/[^\w\u4e00-\u9fa5]+/g, '-') // Substitui caracteres especiais por hífens
                    .replace(/^-+|-+$/g, ''), // Remove hífens no início e no fim

            });
        },
    });
    // const scrollElement = document.documentElement;

    const mdHeadingId = (_text: string, _level: number, index: number) => `${_text
        .toLowerCase()
        .replace(/[^\w\u4e00-\u9fa5]+/g, '-')
        .replace(/^-+|-+$/g, '')}`;
    return (
        <div className='container_2'>
            <div className='doc_2'>
                <div className='content_2'>
                    <MdPreview
                        id='preview'
                        value={post.data}
                        language="pt-BR"
                        previewTheme="github"
                        showCodeRowNumber={true}
                        mdHeadingId={mdHeadingId}
                    >

                    </MdPreview>
                </div>
                {/* <div className='catalog_2'>
                    <div className='affix'><MdCatalog editorId='preview' scrollElement={scrollElement} /></div>
                </div> */}
            </div>
        </div>
    );
}

版本号

nodejs: v22.12.0 "dependencies": { "@vavt/cm-extension": "^1.6.0", "@vavt/v3-extension": "^3.0.0", "cookies-next": "^5.1.0", "markdown-it-anchor": "^9.2.0", "md-editor-rt": "^5.2.1", "next": "15.1.6", "react": "^19.0.0", "react-dom": "^19.0.0", "sanitize-html": "^2.14.0" },

问题重现链接

No response

@imzbf
Copy link
Owner

imzbf commented Feb 3, 2025

Can you provide a full demo that can be run right away?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants