@conloca/mdx 0.1.16 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -16
- package/dist/code-block-frame.js +1 -0
- package/dist/code-block-frame.js.map +1 -0
- package/dist/editor-core.d.ts +0 -2
- package/dist/editor-core.d.ts.map +1 -1
- package/dist/editor-core.js +50 -6
- package/dist/editor-core.js.map +1 -0
- package/dist/esm-passthrough.d.ts +36 -0
- package/dist/esm-passthrough.d.ts.map +1 -0
- package/dist/esm-passthrough.js +237 -0
- package/dist/esm-passthrough.js.map +1 -0
- package/dist/fragments.d.ts +37 -0
- package/dist/fragments.d.ts.map +1 -0
- package/dist/fragments.js +53 -0
- package/dist/fragments.js.map +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -0
- package/dist/markdown-options.js +1 -0
- package/dist/markdown-options.js.map +1 -0
- package/dist/mdx/compile-request.d.ts +5 -0
- package/dist/mdx/compile-request.d.ts.map +1 -0
- package/dist/mdx/compile-request.js +40 -0
- package/dist/mdx/compile-request.js.map +1 -0
- package/dist/mdx/compile.d.ts.map +1 -1
- package/dist/mdx/compile.js +21 -1
- package/dist/mdx/compile.js.map +1 -0
- package/dist/mdx/evaluate.d.ts +18 -23
- package/dist/mdx/evaluate.d.ts.map +1 -1
- package/dist/mdx/evaluate.js +103 -29
- package/dist/mdx/evaluate.js.map +1 -0
- package/dist/mdx/heading-outline.d.ts +46 -0
- package/dist/mdx/heading-outline.d.ts.map +1 -0
- package/dist/mdx/heading-outline.js +114 -0
- package/dist/mdx/heading-outline.js.map +1 -0
- package/dist/mdx/restrict-expressions.d.ts +43 -0
- package/dist/mdx/restrict-expressions.d.ts.map +1 -0
- package/dist/mdx/restrict-expressions.js +160 -0
- package/dist/mdx/restrict-expressions.js.map +1 -0
- package/dist/mdx-editor.js +1 -0
- package/dist/mdx-editor.js.map +1 -0
- package/dist/node.d.ts +3 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +3 -1
- package/dist/node.js.map +1 -0
- package/dist/sandbox-frame.d.ts +114 -0
- package/dist/sandbox-frame.d.ts.map +1 -0
- package/dist/sandbox-frame.js +234 -0
- package/dist/sandbox-frame.js.map +1 -0
- package/dist/types.d.ts +7 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -41
- package/src/code-block-frame.tsx +262 -0
- package/src/editor-core.tsx +403 -0
- package/src/editor-styles.css +282 -0
- package/src/esm-passthrough.ts +269 -0
- package/src/fragments.ts +91 -0
- package/src/index.ts +5 -0
- package/src/markdown-options.ts +21 -0
- package/src/mdx/compile-request.ts +53 -0
- package/src/mdx/compile.ts +51 -0
- package/src/mdx/evaluate.ts +144 -0
- package/src/mdx/heading-outline.ts +153 -0
- package/src/mdx/restrict-expressions.ts +173 -0
- package/src/mdx-editor.tsx +15 -0
- package/src/node.ts +25 -0
- package/src/sandbox-frame.ts +277 -0
- package/src/types.ts +23 -0
- package/dist/blocks.d.ts +0 -37
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -51
- package/dist/hooks/useMDXEvaluation.d.ts +0 -28
- package/dist/hooks/useMDXEvaluation.d.ts.map +0 -1
- package/dist/hooks/useMDXEvaluation.js +0 -117
- package/dist/index.d.mts +0 -127
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -516
- package/dist/index.mjs.map +0 -1
- package/dist/node.d.mts +0 -102
- package/dist/node.d.mts.map +0 -1
- package/dist/node.mjs +0 -140
- package/dist/node.mjs.map +0 -1
- package/dist/style.css +0 -88
package/dist/blocks.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { MDXBlockEvaluationResult } from './types.js';
|
|
2
|
-
interface BlockLocaleSummary {
|
|
3
|
-
meta?: {
|
|
4
|
-
title?: string;
|
|
5
|
-
};
|
|
6
|
-
name?: string;
|
|
7
|
-
}
|
|
8
|
-
interface BlockManifest {
|
|
9
|
-
id: string;
|
|
10
|
-
locales: Record<string, BlockLocaleSummary | undefined>;
|
|
11
|
-
}
|
|
12
|
-
interface BlockLocalizedEntry {
|
|
13
|
-
localized?: {
|
|
14
|
-
meta?: {
|
|
15
|
-
title?: string;
|
|
16
|
-
};
|
|
17
|
-
name?: string;
|
|
18
|
-
content?: {
|
|
19
|
-
mdx?: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
interface BlockAPI {
|
|
24
|
-
listAllContent(filters: {
|
|
25
|
-
kind: 'block';
|
|
26
|
-
}): Iterable<BlockManifest>;
|
|
27
|
-
getLocalized(id: string, locale: string): Promise<BlockLocalizedEntry | null>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Evaluate all MDX blocks from a compatible content API.
|
|
31
|
-
*
|
|
32
|
-
* Returns structured success/error results so callers can decide how to
|
|
33
|
-
* surface broken blocks instead of hardcoding fallback UI in this package.
|
|
34
|
-
*/
|
|
35
|
-
export declare function evaluateMDXBlocks(api: BlockAPI, locale: string): Promise<MDXBlockEvaluationResult[]>;
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=blocks.d.ts.map
|
package/dist/blocks.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC,CAAC;CACzD;AAED,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE;YACL,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE;YACR,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CACH;AAED,UAAU,QAAQ;IAChB,cAAc,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;IACpE,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CAC/E;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAkD1G"}
|
package/dist/blocks.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { evaluateMDXToComponent } from './mdx/evaluate.js';
|
|
2
|
-
/**
|
|
3
|
-
* Evaluate all MDX blocks from a compatible content API.
|
|
4
|
-
*
|
|
5
|
-
* Returns structured success/error results so callers can decide how to
|
|
6
|
-
* surface broken blocks instead of hardcoding fallback UI in this package.
|
|
7
|
-
*/
|
|
8
|
-
export async function evaluateMDXBlocks(api, locale) {
|
|
9
|
-
const blocks = Array.from(api.listAllContent({ kind: 'block' }));
|
|
10
|
-
return Promise.all(blocks.map(async (block) => {
|
|
11
|
-
const locales = Object.keys(block.locales);
|
|
12
|
-
const firstLocale = locales.length > 0 ? block.locales[locales[0]] : null;
|
|
13
|
-
const manifestTitle = firstLocale?.meta?.title || firstLocale?.name || block.id;
|
|
14
|
-
try {
|
|
15
|
-
const blockLocalized = await api.getLocalized(block.id, locale);
|
|
16
|
-
const blockTitle = blockLocalized?.localized?.meta?.title || blockLocalized?.localized?.name || manifestTitle;
|
|
17
|
-
const mdxContent = blockLocalized?.localized?.content?.mdx;
|
|
18
|
-
if (!mdxContent) {
|
|
19
|
-
return {
|
|
20
|
-
ok: false,
|
|
21
|
-
id: block.id,
|
|
22
|
-
title: blockTitle,
|
|
23
|
-
error: new Error(`No MDX content found for block: ${block.id}`),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const { Component: EvaluatedComponent, error } = await evaluateMDXToComponent(mdxContent);
|
|
27
|
-
if (error || !EvaluatedComponent) {
|
|
28
|
-
return {
|
|
29
|
-
ok: false,
|
|
30
|
-
id: block.id,
|
|
31
|
-
title: blockTitle,
|
|
32
|
-
error: error || new Error(`MDX evaluation failed for block: ${block.id}`),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
ok: true,
|
|
37
|
-
id: block.id,
|
|
38
|
-
title: blockTitle,
|
|
39
|
-
Component: EvaluatedComponent,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
return {
|
|
44
|
-
ok: false,
|
|
45
|
-
id: block.id,
|
|
46
|
-
title: manifestTitle,
|
|
47
|
-
error: error instanceof Error ? error : new Error(`Failed to evaluate block: ${block.id}`),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
export interface UseMDXEvaluationOptions {
|
|
3
|
-
compiledCode: string | null;
|
|
4
|
-
cacheKey?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface UseMDXEvaluationResult {
|
|
7
|
-
Component: React.ComponentType | null;
|
|
8
|
-
error: Error | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
retry: () => void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Hook for evaluating pre-compiled MDX code into React components.
|
|
14
|
-
*
|
|
15
|
-
* Uses the browser-side half of a server-compile + browser-run pattern:
|
|
16
|
-
* 1. The server compiles MDX → JavaScript function body
|
|
17
|
-
* 2. The browser executes the pre-compiled code with run() (zero compiler dependencies)
|
|
18
|
-
*
|
|
19
|
-
* This keeps the full MDX compilation pipeline on the server and only ships
|
|
20
|
-
* a tiny runtime helper to the browser.
|
|
21
|
-
*
|
|
22
|
-
* @param options.compiledCode - The pre-compiled MDX function body. If null, returns null component
|
|
23
|
-
* @param options.cacheKey - Optional cache key. If not provided, uses hash of code
|
|
24
|
-
*
|
|
25
|
-
* @returns Object containing Component, error, isLoading, retry
|
|
26
|
-
*/
|
|
27
|
-
export declare function useMDXEvaluation({ compiledCode, cacheKey }: UseMDXEvaluationOptions): UseMDXEvaluationResult;
|
|
28
|
-
//# sourceMappingURL=useMDXEvaluation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMDXEvaluation.d.ts","sourceRoot":"","sources":["../../src/hooks/useMDXEvaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA6C/B,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;IACtC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,uBAAuB,GAAG,sBAAsB,CAsE5G"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import * as devRuntime from 'react/jsx-dev-runtime';
|
|
3
|
-
import * as runtime from 'react/jsx-runtime';
|
|
4
|
-
// Cache for compiled MDX components
|
|
5
|
-
const compiledCache = new Map();
|
|
6
|
-
/**
|
|
7
|
-
* Execute pre-compiled MDX code (compiled with outputFormat: 'function-body').
|
|
8
|
-
* This is the same as @mdx-js/mdx's run() — inlined here to avoid importing
|
|
9
|
-
* the full @mdx-js/mdx package (which pulls acorn + remark + unified into the browser).
|
|
10
|
-
*
|
|
11
|
-
* Note: Uses AsyncFunction constructor which requires CSP `unsafe-eval`.
|
|
12
|
-
* This is acceptable since the CMS admin UI runs in a trusted environment.
|
|
13
|
-
*/
|
|
14
|
-
const AsyncFunction = Object.getPrototypeOf(async () => { }).constructor;
|
|
15
|
-
async function runMDX(code, options) {
|
|
16
|
-
return new AsyncFunction(String(code))(options);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Create the JSX runtime options for runMDX().
|
|
20
|
-
* Checked once at module load to avoid repeated environment checks.
|
|
21
|
-
*/
|
|
22
|
-
function createRunOptions() {
|
|
23
|
-
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
24
|
-
return isDevelopment ? { ...devRuntime, development: true } : { ...runtime };
|
|
25
|
-
}
|
|
26
|
-
const runOptions = createRunOptions();
|
|
27
|
-
/**
|
|
28
|
-
* Simple hash function for generating cache keys from MDX content.
|
|
29
|
-
*/
|
|
30
|
-
function hashString(str) {
|
|
31
|
-
let hash = 0;
|
|
32
|
-
for (let i = 0; i < str.length; i++) {
|
|
33
|
-
const char = str.charCodeAt(i);
|
|
34
|
-
hash = (hash << 5) - hash + char;
|
|
35
|
-
hash = hash & hash;
|
|
36
|
-
}
|
|
37
|
-
return hash.toString(36);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Hook for evaluating pre-compiled MDX code into React components.
|
|
41
|
-
*
|
|
42
|
-
* Uses the browser-side half of a server-compile + browser-run pattern:
|
|
43
|
-
* 1. The server compiles MDX → JavaScript function body
|
|
44
|
-
* 2. The browser executes the pre-compiled code with run() (zero compiler dependencies)
|
|
45
|
-
*
|
|
46
|
-
* This keeps the full MDX compilation pipeline on the server and only ships
|
|
47
|
-
* a tiny runtime helper to the browser.
|
|
48
|
-
*
|
|
49
|
-
* @param options.compiledCode - The pre-compiled MDX function body. If null, returns null component
|
|
50
|
-
* @param options.cacheKey - Optional cache key. If not provided, uses hash of code
|
|
51
|
-
*
|
|
52
|
-
* @returns Object containing Component, error, isLoading, retry
|
|
53
|
-
*/
|
|
54
|
-
export function useMDXEvaluation({ compiledCode, cacheKey }) {
|
|
55
|
-
const [Component, setComponent] = useState(null);
|
|
56
|
-
const [error, setError] = useState(null);
|
|
57
|
-
const [isLoading, setIsLoading] = useState(() => {
|
|
58
|
-
if (!compiledCode)
|
|
59
|
-
return false;
|
|
60
|
-
const key = cacheKey || `mdx-${hashString(compiledCode)}`;
|
|
61
|
-
return !compiledCache.has(key);
|
|
62
|
-
});
|
|
63
|
-
const [retryCount, setRetryCount] = useState(0);
|
|
64
|
-
const retry = () => {
|
|
65
|
-
if (compiledCode) {
|
|
66
|
-
const key = cacheKey || `mdx-${hashString(compiledCode)}`;
|
|
67
|
-
compiledCache.delete(key);
|
|
68
|
-
}
|
|
69
|
-
setRetryCount((prev) => prev + 1);
|
|
70
|
-
};
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
void retryCount;
|
|
73
|
-
if (!compiledCode) {
|
|
74
|
-
setComponent(null);
|
|
75
|
-
setError(null);
|
|
76
|
-
setIsLoading(false);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const key = cacheKey || `mdx-${hashString(compiledCode)}`;
|
|
80
|
-
const cached = compiledCache.get(key);
|
|
81
|
-
if (cached) {
|
|
82
|
-
setComponent(() => cached);
|
|
83
|
-
setError(null);
|
|
84
|
-
setIsLoading(false);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
let cancelled = false;
|
|
88
|
-
const compileAndRun = async () => {
|
|
89
|
-
try {
|
|
90
|
-
setError(null);
|
|
91
|
-
setIsLoading(true);
|
|
92
|
-
const { default: MDXComponent } = await runMDX(compiledCode, runOptions);
|
|
93
|
-
if (cancelled)
|
|
94
|
-
return;
|
|
95
|
-
compiledCache.set(key, MDXComponent);
|
|
96
|
-
setComponent(() => MDXComponent);
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
if (cancelled)
|
|
100
|
-
return;
|
|
101
|
-
const evaluationError = err instanceof Error ? err : new Error('MDX evaluation failed');
|
|
102
|
-
setError(evaluationError);
|
|
103
|
-
setComponent(null);
|
|
104
|
-
}
|
|
105
|
-
finally {
|
|
106
|
-
if (!cancelled) {
|
|
107
|
-
setIsLoading(false);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
compileAndRun();
|
|
112
|
-
return () => {
|
|
113
|
-
cancelled = true;
|
|
114
|
-
};
|
|
115
|
-
}, [compiledCode, cacheKey, retryCount]);
|
|
116
|
-
return { Component, error, isLoading, retry };
|
|
117
|
-
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { JsxComponentDescriptor, MDXEditorMethods, MDXEditorMethods as MDXEditorMethods$1, RealmPlugin } from "@mdxeditor/editor";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import "@mdxeditor/editor/style.css";
|
|
4
|
-
//#region src/code-block-frame.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Frame chrome around the editor's fenced code blocks — header bar with
|
|
7
|
-
* filename, language tag, and a copy button. The outer wrapper picks up
|
|
8
|
-
* the host's code-block classes (published via `codeBlockWrapperInfo$`
|
|
9
|
-
* by the host-wrapper plugin in cms-spa), so the host's actual code-
|
|
10
|
-
* block CSS (Starlight's expressive-code, Tailwind's pre styling, etc.)
|
|
11
|
-
* reaches the editor's frame through the cascade — no shipped mirror.
|
|
12
|
-
*
|
|
13
|
-
* Host-agnostic: no Shiki / Starlight / ExpressiveCode imports. Class
|
|
14
|
-
* names are discovered at runtime from the host's live HTML.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Realm-published cell carrying the host's code-block wrapper chain,
|
|
18
|
-
* outermost first. For Starlight's expressive-code:
|
|
19
|
-
*
|
|
20
|
-
* [
|
|
21
|
-
* { tagName: 'div', className: 'expressive-code' },
|
|
22
|
-
* { tagName: 'figure', className: 'frame has-title not-content' },
|
|
23
|
-
* ]
|
|
24
|
-
*
|
|
25
|
-
* The cms-spa `hostWrapperPlugin` writes to this whenever the fetched
|
|
26
|
-
* wrapper info changes; the code-block frame reads from it to render
|
|
27
|
-
* each chain link as a nested element with the host's expected tag
|
|
28
|
-
* name. Same publish-pattern as the content-wrapper plugin in cms-spa.
|
|
29
|
-
*
|
|
30
|
-
* Null when the host has no code-block chrome (or the fetch is in
|
|
31
|
-
* flight). The frame then falls back to its base `.conloca-code-block`
|
|
32
|
-
* wrapper with no host inheritance — "looks plain but not broken."
|
|
33
|
-
*/
|
|
34
|
-
declare const codeBlockWrapperInfo$: import("@mdxeditor/editor").NodeRef<{
|
|
35
|
-
tagName: string;
|
|
36
|
-
className: string;
|
|
37
|
-
}[] | null>;
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/editor-core.d.ts
|
|
40
|
-
interface BaseMDXEditorProps {
|
|
41
|
-
value: string;
|
|
42
|
-
/**
|
|
43
|
-
* Called whenever the editor content changes. The second argument is `true`
|
|
44
|
-
* the first time the library normalizes the parsed markdown back to its
|
|
45
|
-
* canonical form (bullet style, trailing newline, etc.) — consumers tracking
|
|
46
|
-
* dirty state should treat that call as a re-baseline rather than a user
|
|
47
|
-
* edit, otherwise the editor looks dirty the moment the page loads.
|
|
48
|
-
*/
|
|
49
|
-
onChange: (value: string, initialMarkdownNormalize?: boolean) => void;
|
|
50
|
-
onSave?: (value: string) => void;
|
|
51
|
-
readOnly?: boolean;
|
|
52
|
-
imageDialog?: React.FC | null;
|
|
53
|
-
disableImageSettingsButton?: boolean;
|
|
54
|
-
onImageShortcut?: () => void;
|
|
55
|
-
imageButtonRef?: React.Ref<HTMLButtonElement>;
|
|
56
|
-
/**
|
|
57
|
-
* Upload handler for images pasted or dropped directly into the editor. When
|
|
58
|
-
* provided, the underlying imagePlugin will route those events through this
|
|
59
|
-
* function and insert the returned URL as the image src. Independent of the
|
|
60
|
-
* library/picker `imageDialog` flow — both can be active simultaneously.
|
|
61
|
-
*/
|
|
62
|
-
imageUploadHandler?: (file: File) => Promise<string>;
|
|
63
|
-
jsxComponentDescriptors?: JsxComponentDescriptor[];
|
|
64
|
-
/**
|
|
65
|
-
* Additional @mdxeditor/editor RealmPlugins appended to the built-in
|
|
66
|
-
* plugin list. Used by the SPA shell to register the MDX components
|
|
67
|
-
* registry-driven slash menu without coupling @conloca/mdx to
|
|
68
|
-
* @conloca/cms-spa.
|
|
69
|
-
*/
|
|
70
|
-
extraPlugins?: RealmPlugin[];
|
|
71
|
-
/**
|
|
72
|
-
* Extra toolbar buttons inserted between `<InsertAdmonition />` and the
|
|
73
|
-
* separator preceding focus mode. Pass `null` (default) to keep the
|
|
74
|
-
* stock toolbar.
|
|
75
|
-
*/
|
|
76
|
-
extraToolbarItems?: React.ReactNode;
|
|
77
|
-
/**
|
|
78
|
-
* Class applied to the MDXEditor root element (library forwards it to the
|
|
79
|
-
* toolbar and portaled popups too). Pass `"dark-theme"` to activate the
|
|
80
|
-
* library's built-in Radix dark palette.
|
|
81
|
-
* See https://mdxeditor.dev/editor/docs/theming
|
|
82
|
-
*/
|
|
83
|
-
className?: string;
|
|
84
|
-
/** Placeholder shown when the editor is empty. Forwarded to MDXEditorLib. */
|
|
85
|
-
placeholder?: React.ReactNode;
|
|
86
|
-
/** Auto-focus the editor on mount. Forwarded to MDXEditorLib. */
|
|
87
|
-
autoFocus?: boolean | {
|
|
88
|
-
defaultSelection?: 'rootStart' | 'rootEnd';
|
|
89
|
-
preventScroll?: boolean;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
declare const BaseMDXEditor: React.ForwardRefExoticComponent<BaseMDXEditorProps & React.RefAttributes<MDXEditorMethods$1>>;
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/hooks/useMDXEvaluation.d.ts
|
|
95
|
-
interface UseMDXEvaluationOptions {
|
|
96
|
-
compiledCode: string | null;
|
|
97
|
-
cacheKey?: string;
|
|
98
|
-
}
|
|
99
|
-
interface UseMDXEvaluationResult {
|
|
100
|
-
Component: React.ComponentType | null;
|
|
101
|
-
error: Error | null;
|
|
102
|
-
isLoading: boolean;
|
|
103
|
-
retry: () => void;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Hook for evaluating pre-compiled MDX code into React components.
|
|
107
|
-
*
|
|
108
|
-
* Uses the browser-side half of a server-compile + browser-run pattern:
|
|
109
|
-
* 1. The server compiles MDX → JavaScript function body
|
|
110
|
-
* 2. The browser executes the pre-compiled code with run() (zero compiler dependencies)
|
|
111
|
-
*
|
|
112
|
-
* This keeps the full MDX compilation pipeline on the server and only ships
|
|
113
|
-
* a tiny runtime helper to the browser.
|
|
114
|
-
*
|
|
115
|
-
* @param options.compiledCode - The pre-compiled MDX function body. If null, returns null component
|
|
116
|
-
* @param options.cacheKey - Optional cache key. If not provided, uses hash of code
|
|
117
|
-
*
|
|
118
|
-
* @returns Object containing Component, error, isLoading, retry
|
|
119
|
-
*/
|
|
120
|
-
declare function useMDXEvaluation({ compiledCode, cacheKey }: UseMDXEvaluationOptions): UseMDXEvaluationResult;
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/mdx-editor.d.ts
|
|
123
|
-
interface MDXEditorProps extends Omit<BaseMDXEditorProps, 'disableImageSettingsButton' | 'imageButtonRef' | 'imageDialog' | 'onImageShortcut'> {}
|
|
124
|
-
declare const MDXEditor: React.ForwardRefExoticComponent<MDXEditorProps & React.RefAttributes<MDXEditorMethods$1>>;
|
|
125
|
-
//#endregion
|
|
126
|
-
export { BaseMDXEditor, type BaseMDXEditorProps, MDXEditor, type MDXEditorMethods, MDXEditorProps, type UseMDXEvaluationOptions, type UseMDXEvaluationResult, codeBlockWrapperInfo$, useMDXEvaluation };
|
|
127
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/code-block-frame.tsx","../src/editor-core.tsx","../src/hooks/useMDXEvaluation.ts","../src/mdx-editor.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyCa,mDAAqB;EAAmB;EAAmB;;;;UCsDvD;EACf;;;;;;;;EAQA,WAAW,eAAe;EAC1B,UAAU;EACV;EACA,cAAc,MAAM;EACpB;EACA;EACA,iBAAiB,MAAM,IAAI;;;;;;;EAO3B,sBAAsB,MAAM,SAAS;EACrC,0BAA0B;;;;;;;EAO1B,eAAe;;;;;;EAMf,oBAAoB,MAAM;;;;;;;EAO1B;;EAEA,cAAc,MAAM;;EAEpB;IAAwB;IAA4C;;;cA+DzD,eAAa,MAAA,0BAAA,qBAAA,MAAA,cAAA;;;UChKT;EACf;EACA;;UAGe;EACf,WAAW,MAAM;EACjB,OAAO;EACP;EACA;;;;;;;;;;;;;;;;;iBAkBc,mBAAmB,cAAc,YAAY,0BAA0B;;;UCpEtE,uBACP,KACN;cAIS,WAAS,MAAA,0BAAA,iBAAA,MAAA,cAAA"}
|