diff --git a/src/exportMarkdownFromLexical.ts b/src/exportMarkdownFromLexical.ts
index fec82646..3a16c88f 100644
--- a/src/exportMarkdownFromLexical.ts
+++ b/src/exportMarkdownFromLexical.ts
@@ -194,6 +194,9 @@ export function exportLexicalTreeToMdast({
if (!descriptor) {
throw new Error(`Component ${componentName} is used but not imported`)
}
+ if (!descriptor.source) {
+ continue
+ }
if (descriptor.defaultExport) {
defaultImportsMap.set(componentName, descriptor.source)
} else {
diff --git a/src/plugins/jsx/index.ts b/src/plugins/jsx/index.ts
index 0d9c31f4..c54ae51e 100644
--- a/src/plugins/jsx/index.ts
+++ b/src/plugins/jsx/index.ts
@@ -46,8 +46,9 @@ export interface JsxComponentDescriptor {
kind: 'flow' | 'text'
/**
* The module path from which the component can be imported
+ * Omit to skip injecting an import statement
*/
- source: string
+ source?: string
/**
* Wether the component is the default export of the module
*/
diff --git a/src/test/jsx.test.tsx b/src/test/jsx.test.tsx
new file mode 100644
index 00000000..d732de0d
--- /dev/null
+++ b/src/test/jsx.test.tsx
@@ -0,0 +1,31 @@
+import React from 'react'
+import { describe, expect, it } from 'vitest'
+import { GenericJsxEditor, JsxComponentDescriptor, MDXEditor, MDXEditorMethods, jsxPlugin } from '../'
+import { render } from '@testing-library/react'
+
+// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
+;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
+
+const jsxComponentDescriptors: JsxComponentDescriptor[] = [
+ {
+ name: 'Callout',
+ kind: 'text',
+ props: [
+ { name: 'foo', type: 'string' },
+ { name: 'bar', type: 'string' }
+ ],
+ hasChildren: false,
+ Editor: GenericJsxEditor
+ }
+]
+describe('jsx markdown import export', () => {
+ it('skips jsx import if not specified', () => {
+ const markdown = `
+
+ `
+ const ref = React.createRef()
+ render()
+ const processedMarkdown = ref.current?.getMarkdown().trim()
+ expect(processedMarkdown).toEqual(markdown.trim())
+ })
+})