-
The docs say:
But I'm not seeing this behaviour at all. I've hit a number of issues integrating the editor with a large corpus of legacy mdx content, and have seen a lot of processing errors (JSX component used but not imported, badly named directives, arbitrary html in the markdown), and unless I wrap the editor in an ErrorBoundary (which I would anyway), the errors bubble all the way to the top of my Next.js app. I can't see how to set the editor to fallback into Even trying to trap these errors in the Boundary and falling back to an instance of the editor with viewMode=source and suppressHtmlProcessing=true doesn't work - the errors still occur, and the browser locks in a constant error/fallback/error cycle. At no point does it seem to ever trigger the What am I doing wrong? <MDXEditor
className={`${styles.editor} ${editorTheme}-theme`}
contentEditableClassName={classes}
markdown={value}
onChange={onChange}
onError={onError}
toMarkdownOptions={{
bullet: '-',
listItemIndent: 'one',
emphasis: '_',
rule: '-',
incrementListMarker: false,
}}
plugins={[
frontmatterPlugin(),
diffSourcePlugin({
diffMarkdown: oldMdxContent,
viewMode: 'rich-text',
}),
jsxPlugin({ jsxComponentDescriptors }),
codeBlockPlugin({
codeBlockEditorDescriptors: [FallbackCodeEditorDescriptor],
defaultCodeBlockLanguage: 'tsx',
}),
codeMirrorPlugin({
codeBlockLanguages,
}),
directivesPlugin({
directiveDescriptors: [AdmonitionDirectiveDescriptor],
}),
headingsPlugin(),
listsPlugin(),
linkPlugin(),
linkDialogPlugin({
linkAutocompleteSuggestions: pageList.map((p) => p.pathname),
}),
imagePlugin({
imageUploadHandler: async (image: File) => {
const { filePath } = await onUpload([image]);
return filePath;
},
imageAutocompleteSuggestions: uploads,
}),
tablePlugin(),
quotePlugin(),
thematicBreakPlugin(),
toolbarPlugin({
toolbarContents: () => (
<DiffSourceToggleWrapper>
<BlockTypeSelect />
<BoldItalicUnderlineToggles />
{/* <ChangeAdmonitionType /> */}
{/* <ChangeCodeMirrorLanguage /> */}
<CodeToggle />
<CreateLink />
<InsertAdmonition />
<InsertCodeBlock />
{/* <InsertFrontmatter /> */}
<InsertImage />
<InsertTable />
<InsertThematicBreak />
<ListsToggle />
<UndoRedo />
</DiffSourceToggleWrapper>
),
}),
markdownShortcutPlugin(),
]}
/>
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Can you paste/link some content you have trouble with? I think I know what goes on, but I need to ensure that this is properly handled. Great if you can include something that would cause as many of errors you've encountered as possible. |
Beta Was this translation helpful? Give feedback.
-
@dave-db just published v2.3.3 that bundles any errors due to missing directives, JSX descriptors and code blocks into the markdown import process. As a result, you should be able to see the source editor fallback mechanism working - at least it did with the configuration and the sample source you sent. Keep me posted if you discover more of those. My goal is to make the editor as resilient as possible in cases of unknown content. |
Beta Was this translation helpful? Give feedback.
@dave-db just published v2.3.3 that bundles any errors due to missing directives, JSX descriptors and code blocks into the markdown import process. As a result, you should be able to see the source editor fallback mechanism working - at least it did with the configuration and the sample source you sent.
Keep me posted if you discover more of those. My goal is to make the editor as resilient as possible in cases of unknown content.