@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.
Files changed (86) hide show
  1. package/README.md +50 -16
  2. package/dist/code-block-frame.js +1 -0
  3. package/dist/code-block-frame.js.map +1 -0
  4. package/dist/editor-core.d.ts +0 -2
  5. package/dist/editor-core.d.ts.map +1 -1
  6. package/dist/editor-core.js +50 -6
  7. package/dist/editor-core.js.map +1 -0
  8. package/dist/esm-passthrough.d.ts +36 -0
  9. package/dist/esm-passthrough.d.ts.map +1 -0
  10. package/dist/esm-passthrough.js +237 -0
  11. package/dist/esm-passthrough.js.map +1 -0
  12. package/dist/fragments.d.ts +37 -0
  13. package/dist/fragments.d.ts.map +1 -0
  14. package/dist/fragments.js +53 -0
  15. package/dist/fragments.js.map +1 -0
  16. package/dist/index.d.ts +0 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -0
  20. package/dist/markdown-options.js +1 -0
  21. package/dist/markdown-options.js.map +1 -0
  22. package/dist/mdx/compile-request.d.ts +5 -0
  23. package/dist/mdx/compile-request.d.ts.map +1 -0
  24. package/dist/mdx/compile-request.js +40 -0
  25. package/dist/mdx/compile-request.js.map +1 -0
  26. package/dist/mdx/compile.d.ts.map +1 -1
  27. package/dist/mdx/compile.js +21 -1
  28. package/dist/mdx/compile.js.map +1 -0
  29. package/dist/mdx/evaluate.d.ts +18 -23
  30. package/dist/mdx/evaluate.d.ts.map +1 -1
  31. package/dist/mdx/evaluate.js +103 -29
  32. package/dist/mdx/evaluate.js.map +1 -0
  33. package/dist/mdx/heading-outline.d.ts +46 -0
  34. package/dist/mdx/heading-outline.d.ts.map +1 -0
  35. package/dist/mdx/heading-outline.js +114 -0
  36. package/dist/mdx/heading-outline.js.map +1 -0
  37. package/dist/mdx/restrict-expressions.d.ts +43 -0
  38. package/dist/mdx/restrict-expressions.d.ts.map +1 -0
  39. package/dist/mdx/restrict-expressions.js +160 -0
  40. package/dist/mdx/restrict-expressions.js.map +1 -0
  41. package/dist/mdx-editor.js +1 -0
  42. package/dist/mdx-editor.js.map +1 -0
  43. package/dist/node.d.ts +3 -2
  44. package/dist/node.d.ts.map +1 -1
  45. package/dist/node.js +3 -1
  46. package/dist/node.js.map +1 -0
  47. package/dist/sandbox-frame.d.ts +114 -0
  48. package/dist/sandbox-frame.d.ts.map +1 -0
  49. package/dist/sandbox-frame.js +234 -0
  50. package/dist/sandbox-frame.js.map +1 -0
  51. package/dist/types.d.ts +7 -4
  52. package/dist/types.d.ts.map +1 -1
  53. package/dist/types.js +1 -0
  54. package/dist/types.js.map +1 -0
  55. package/package.json +58 -41
  56. package/src/code-block-frame.tsx +262 -0
  57. package/src/editor-core.tsx +403 -0
  58. package/src/editor-styles.css +282 -0
  59. package/src/esm-passthrough.ts +269 -0
  60. package/src/fragments.ts +91 -0
  61. package/src/index.ts +5 -0
  62. package/src/markdown-options.ts +21 -0
  63. package/src/mdx/compile-request.ts +53 -0
  64. package/src/mdx/compile.ts +51 -0
  65. package/src/mdx/evaluate.ts +144 -0
  66. package/src/mdx/heading-outline.ts +153 -0
  67. package/src/mdx/restrict-expressions.ts +173 -0
  68. package/src/mdx-editor.tsx +15 -0
  69. package/src/node.ts +25 -0
  70. package/src/sandbox-frame.ts +277 -0
  71. package/src/types.ts +23 -0
  72. package/dist/blocks.d.ts +0 -37
  73. package/dist/blocks.d.ts.map +0 -1
  74. package/dist/blocks.js +0 -51
  75. package/dist/hooks/useMDXEvaluation.d.ts +0 -28
  76. package/dist/hooks/useMDXEvaluation.d.ts.map +0 -1
  77. package/dist/hooks/useMDXEvaluation.js +0 -117
  78. package/dist/index.d.mts +0 -127
  79. package/dist/index.d.mts.map +0 -1
  80. package/dist/index.mjs +0 -516
  81. package/dist/index.mjs.map +0 -1
  82. package/dist/node.d.mts +0 -102
  83. package/dist/node.d.mts.map +0 -1
  84. package/dist/node.mjs +0 -140
  85. package/dist/node.mjs.map +0 -1
  86. package/dist/style.css +0 -88
package/dist/index.mjs DELETED
@@ -1,516 +0,0 @@
1
- import './style.css';
2
- import { BlockTypeSelect, BoldItalicUnderlineToggles, ButtonWithTooltip, Cell, ChangeCodeMirrorLanguage, CodeMirrorEditor, ConditionalContents, CreateLink, DiffSourceToggleWrapper, GenericJsxEditor, HighlightToggle, InsertCodeBlock, InsertImage, InsertTable, InsertThematicBreak, ListsToggle, MDXEditor as MDXEditor$1, Separator, StrikeThroughSupSubToggles, UndoRedo, codeBlockPlugin, codeMirrorPlugin, diffSourcePlugin, headingsPlugin, imagePlugin, jsxPlugin, linkDialogPlugin, linkPlugin, listsPlugin, markdownShortcutPlugin, quotePlugin, tablePlugin, thematicBreakPlugin, toolbarPlugin, useCellValue, useCodeBlockEditorContext } from "@mdxeditor/editor";
3
- import { Check, Copy, Maximize2, Minimize2 } from "lucide-react";
4
- import React, { createElement, useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
5
- import * as runtime from "react/jsx-runtime";
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import "@mdxeditor/editor/style.css";
8
- import * as devRuntime from "react/jsx-dev-runtime";
9
- //#region src/code-block-frame.tsx
10
- /**
11
- * Frame chrome around the editor's fenced code blocks — header bar with
12
- * filename, language tag, and a copy button. The outer wrapper picks up
13
- * the host's code-block classes (published via `codeBlockWrapperInfo$`
14
- * by the host-wrapper plugin in cms-spa), so the host's actual code-
15
- * block CSS (Starlight's expressive-code, Tailwind's pre styling, etc.)
16
- * reaches the editor's frame through the cascade — no shipped mirror.
17
- *
18
- * Host-agnostic: no Shiki / Starlight / ExpressiveCode imports. Class
19
- * names are discovered at runtime from the host's live HTML.
20
- */
21
- /**
22
- * Realm-published cell carrying the host's code-block wrapper chain,
23
- * outermost first. For Starlight's expressive-code:
24
- *
25
- * [
26
- * { tagName: 'div', className: 'expressive-code' },
27
- * { tagName: 'figure', className: 'frame has-title not-content' },
28
- * ]
29
- *
30
- * The cms-spa `hostWrapperPlugin` writes to this whenever the fetched
31
- * wrapper info changes; the code-block frame reads from it to render
32
- * each chain link as a nested element with the host's expected tag
33
- * name. Same publish-pattern as the content-wrapper plugin in cms-spa.
34
- *
35
- * Null when the host has no code-block chrome (or the fetch is in
36
- * flight). The frame then falls back to its base `.conloca-code-block`
37
- * wrapper with no host inheritance — "looks plain but not broken."
38
- */
39
- const codeBlockWrapperInfo$ = Cell(null);
40
- const TITLE_META_RE = /\btitle=(?:"([^"]*)"|'([^']*)'|(\S+))/;
41
- const FILENAME_COMMENT_RE = /^\s*(?:\/\/|#|;|--|<!--|\/\*)\s*([\w.\-/@]+\.[\w.-]+)\s*(?:-->|\*\/)?\s*$/;
42
- function parseMeta(meta) {
43
- const match = meta.match(TITLE_META_RE);
44
- if (!match) return {
45
- title: "",
46
- rest: meta.trim()
47
- };
48
- return {
49
- title: match[1] ?? match[2] ?? match[3] ?? "",
50
- rest: (meta.slice(0, match.index) + meta.slice(match.index + match[0].length)).replace(/\s+/g, " ").trim()
51
- };
52
- }
53
- /** Reassemble a meta string with `title` set (or stripped when empty). */
54
- function buildMeta(title, rest) {
55
- const trimmedTitle = title.trim();
56
- const titleFragment = trimmedTitle ? `title="${trimmedTitle.replace(/"/g, "\\\"")}"` : "";
57
- if (titleFragment && rest) return `${titleFragment} ${rest}`;
58
- return titleFragment || rest;
59
- }
60
- /**
61
- * Detect a leading filename comment, the convention EC's frames plugin
62
- * uses on the published page when no explicit `title=` is set. Returns
63
- * the filename when line 1 of the code is a single-line comment ending
64
- * in a dot-extension; empty string otherwise.
65
- *
66
- * Used to pre-fill the editor's filename input on legacy fences so
67
- * authors see the same value the reader sees in the rendered tab. Pure
68
- * read — the underlying code/comment is never touched.
69
- */
70
- function detectFilenameComment(code) {
71
- const match = (code.split("\n", 1)[0] ?? "").match(FILENAME_COMMENT_RE);
72
- return match ? match[1] ?? "" : "";
73
- }
74
- function CopyButton({ code }) {
75
- const [copied, setCopied] = useState(false);
76
- return /* @__PURE__ */ jsx("button", {
77
- type: "button",
78
- onClick: useCallback(() => {
79
- navigator.clipboard.writeText(code).then(() => {
80
- setCopied(true);
81
- window.setTimeout(() => setCopied(false), 1200);
82
- });
83
- }, [code]),
84
- className: "conloca-code-copy",
85
- "aria-label": copied ? "Copied" : "Copy code",
86
- title: copied ? "Copied" : "Copy code",
87
- children: copied ? /* @__PURE__ */ jsx(Check, {
88
- size: 14,
89
- "aria-hidden": "true"
90
- }) : /* @__PURE__ */ jsx(Copy, {
91
- size: 14,
92
- "aria-hidden": "true"
93
- })
94
- });
95
- }
96
- /**
97
- * Editable filename slot. Rewrites the code block's meta string via
98
- * `setMeta` from `useCodeBlockEditorContext` so authors can author the
99
- * frame title (`\`\`\`ts title="src/foo.ts"`) directly from the editor —
100
- * the meta string round-trips through MDXEditor's markdown serializer
101
- * and ExpressiveCode picks it up as the frame header on the published
102
- * page. Other meta fragments (ins/del/mark/wrap) are preserved.
103
- *
104
- * Legacy fences with a filename comment on line 1 (`// foo.ts`) — EC's
105
- * pre-meta convention for tab titles — are detected and pre-filled in
106
- * the input as a read-only display. Opening such a fence does NOT
107
- * mutate the source. Editing the field is an explicit author intent:
108
- * the new value is written as `title=` meta AND the original comment
109
- * line is stripped, so the editor's input becomes the single source of
110
- * truth without breaking the published render.
111
- */
112
- function FilenameInput({ meta, code }) {
113
- const { setMeta, setCode } = useCodeBlockEditorContext();
114
- const parsed = useMemo(() => parseMeta(meta), [meta]);
115
- const detectedFromComment = useMemo(() => parsed.title ? "" : detectFilenameComment(code), [parsed.title, code]);
116
- const displayed = parsed.title || detectedFromComment;
117
- const [title, setTitle] = useState(displayed);
118
- const [interacted, setInteracted] = useState(false);
119
- useEffect(() => {
120
- setTitle(displayed);
121
- setInteracted(false);
122
- }, [displayed]);
123
- const commit = useCallback((next) => {
124
- if (!interacted) return;
125
- if (next === parsed.title) return;
126
- setMeta(buildMeta(next, parsed.rest));
127
- if (detectedFromComment) {
128
- const lines = code.split("\n");
129
- if (lines[0] && FILENAME_COMMENT_RE.test(lines[0])) setCode(lines.slice(1).join("\n").replace(/^\n+/, ""));
130
- }
131
- }, [
132
- interacted,
133
- parsed.title,
134
- parsed.rest,
135
- detectedFromComment,
136
- code,
137
- setMeta,
138
- setCode
139
- ]);
140
- const onChange = (e) => {
141
- setInteracted(true);
142
- setTitle(e.target.value);
143
- };
144
- const onBlur = () => commit(title);
145
- return /* @__PURE__ */ jsx("input", {
146
- type: "text",
147
- className: "conloca-code-block__filename",
148
- value: title,
149
- placeholder: "filename",
150
- spellCheck: false,
151
- onChange,
152
- onBlur,
153
- "aria-label": "Code block filename"
154
- });
155
- }
156
- function ConlocaCodeBlockEditor(props) {
157
- const chain = useCellValue(codeBlockWrapperInfo$) ?? [];
158
- const frameLink = chain.length > 0 ? chain[chain.length - 1] : null;
159
- const outerLinks = frameLink ? chain.slice(0, -1) : [];
160
- const frameInner = /* @__PURE__ */ jsxs(Fragment, { children: [
161
- /* @__PURE__ */ jsx("figcaption", {
162
- className: "conloca-code-block__header header",
163
- children: /* @__PURE__ */ jsx("span", {
164
- className: "title",
165
- children: /* @__PURE__ */ jsx(FilenameInput, {
166
- meta: props.meta,
167
- code: props.code
168
- })
169
- })
170
- }),
171
- /* @__PURE__ */ jsx("pre", {
172
- className: "conloca-code-block__pre",
173
- children: /* @__PURE__ */ jsx(CodeMirrorEditor, { ...props })
174
- }),
175
- /* @__PURE__ */ jsx("div", {
176
- className: "conloca-code-block__copy copy",
177
- children: /* @__PURE__ */ jsx(CopyButton, { code: props.code })
178
- })
179
- ] });
180
- const frame = frameLink ? createElement(frameLink.tagName, { className: `conloca-code-block ${frameLink.className}` }, frameInner) : /* @__PURE__ */ jsx("div", {
181
- className: "conloca-code-block",
182
- children: frameInner
183
- });
184
- return outerLinks.reduceRight((kids, link) => createElement(link.tagName, { className: link.className }, kids), frame);
185
- }
186
- /**
187
- * Catch-all descriptor — `priority: 100`, `match: () => true` — registered
188
- * via `codeBlockPlugin({ codeBlockEditorDescriptors: [conlocaCodeBlockDescriptor] })`.
189
- * Wraps the upstream `CodeMirrorEditor` with the host-themed frame.
190
- */
191
- const conlocaCodeBlockDescriptor = {
192
- priority: 100,
193
- match: () => true,
194
- Editor: ConlocaCodeBlockEditor
195
- };
196
- //#endregion
197
- //#region src/markdown-options.ts
198
- const TO_MARKDOWN_OPTIONS = {
199
- bullet: "-",
200
- rule: "-",
201
- emphasis: "_",
202
- strong: "*",
203
- fence: "`",
204
- listItemIndent: "one",
205
- tightDefinitions: true
206
- };
207
- //#endregion
208
- //#region src/editor-core.tsx
209
- const FOCUS_MODE_STORAGE_KEY = "conloca.mdxeditor.focusMode";
210
- const FOCUS_MODE_BODY_CLASS = "mdxeditor-focus-mode";
211
- /**
212
- * Toggle focus-mode by writing the class on `document.body`. Direct DOM
213
- * mutation (vs. piping a boolean through React state into the editor's
214
- * `className` prop) avoids re-rendering Lexical on every toggle — the
215
- * editor's prop is the only entry point and changing it forces a parse
216
- * round-trip. Persisted in localStorage so the preference survives reloads.
217
- */
218
- function readFocusMode() {
219
- if (typeof document === "undefined") return false;
220
- return document.body.classList.contains(FOCUS_MODE_BODY_CLASS);
221
- }
222
- function subscribeFocusMode(callback) {
223
- if (typeof window === "undefined") return () => {};
224
- const handler = () => callback();
225
- window.addEventListener("conloca:focusModeChange", handler);
226
- return () => window.removeEventListener("conloca:focusModeChange", handler);
227
- }
228
- function setFocusMode(next) {
229
- if (typeof document === "undefined") return;
230
- document.body.classList.toggle(FOCUS_MODE_BODY_CLASS, next);
231
- try {
232
- if (next) window.localStorage.setItem(FOCUS_MODE_STORAGE_KEY, "1");
233
- else window.localStorage.removeItem(FOCUS_MODE_STORAGE_KEY);
234
- } catch {}
235
- window.dispatchEvent(new Event("conloca:focusModeChange"));
236
- }
237
- function FocusModeToggle() {
238
- const focusMode = useSyncExternalStore(subscribeFocusMode, readFocusMode, () => false);
239
- const onClick = useCallback(() => setFocusMode(!focusMode), [focusMode]);
240
- return /* @__PURE__ */ jsx(ButtonWithTooltip, {
241
- title: focusMode ? "Exit focus mode (wider column)" : "Enter focus mode (narrow column)",
242
- onClick,
243
- children: /* @__PURE__ */ jsx(focusMode ? Minimize2 : Maximize2, {
244
- size: 16,
245
- "aria-hidden": true
246
- })
247
- });
248
- }
249
- const codeBlockLanguages = {
250
- "": "Plain text",
251
- text: "Plain Text",
252
- js: "JavaScript",
253
- jsx: "JavaScript (React)",
254
- ts: "TypeScript",
255
- tsx: "TypeScript (React)",
256
- css: "CSS",
257
- html: "HTML",
258
- json: "JSON",
259
- md: "Markdown",
260
- mdx: "MDX",
261
- bash: "Bash",
262
- python: "Python"
263
- };
264
- /**
265
- * Wildcard fallback so any unknown JSX tag round-trips through GenericJsxEditor
266
- * instead of crashing the importer with "Parsing of the following markdown
267
- * structure failed". Two entries because the upstream visitor dispatches by
268
- * `kind` (block vs inline JSX) — without the inline one, an inline `<Badge>`
269
- * mid-paragraph would be matched by the flow wildcard and lifted out of its
270
- * paragraph in Lexical. Consumers passing typed descriptors win via the
271
- * exact-name match in the visitor; the wildcard only handles the leftovers.
272
- */
273
- const wildcardJsxDescriptors = [{
274
- name: "*",
275
- kind: "flow",
276
- props: [],
277
- hasChildren: true,
278
- Editor: GenericJsxEditor
279
- }, {
280
- name: "*",
281
- kind: "text",
282
- props: [],
283
- hasChildren: true,
284
- Editor: GenericJsxEditor
285
- }];
286
- function renderInsertImageButton(imageButtonRef) {
287
- if (!imageButtonRef) return /* @__PURE__ */ jsx(InsertImage, {});
288
- return React.createElement(InsertImage, { ref: imageButtonRef });
289
- }
290
- /**
291
- * Restore the persisted focus-mode preference on first import. Runs once at
292
- * module load so the class is in place before any editor mounts — avoids a
293
- * flash of wide column when the user previously selected focus mode.
294
- */
295
- if (typeof window !== "undefined") try {
296
- if (window.localStorage.getItem(FOCUS_MODE_STORAGE_KEY) === "1") document.body.classList.add(FOCUS_MODE_BODY_CLASS);
297
- } catch {}
298
- const BaseMDXEditor = React.forwardRef(({ value, onChange, onSave, readOnly = false, imageDialog, disableImageSettingsButton = false, onImageShortcut, imageButtonRef, imageUploadHandler, jsxComponentDescriptors, extraPlugins, extraToolbarItems, className, placeholder, autoFocus }, ref) => {
299
- useEffect(() => {
300
- const handleKeyDown = (event) => {
301
- if ((event.ctrlKey || event.metaKey) && event.key === "s") {
302
- event.preventDefault();
303
- onSave?.(value);
304
- }
305
- if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.key.toLowerCase() === "i") {
306
- if (!onImageShortcut) return;
307
- event.preventDefault();
308
- onImageShortcut();
309
- }
310
- };
311
- document.addEventListener("keydown", handleKeyDown);
312
- return () => document.removeEventListener("keydown", handleKeyDown);
313
- }, [
314
- onImageShortcut,
315
- onSave,
316
- value
317
- ]);
318
- return /* @__PURE__ */ jsx(MDXEditor$1, {
319
- ref,
320
- markdown: value,
321
- toMarkdownOptions: TO_MARKDOWN_OPTIONS,
322
- onChange,
323
- onError: ({ error, source }) => {
324
- console.error("[MDXEditor] parse error:", error, "\nsource:", source);
325
- },
326
- readOnly,
327
- className,
328
- placeholder,
329
- autoFocus,
330
- contentEditableClassName: "conloca-prose conloca-prose--editor",
331
- plugins: [
332
- headingsPlugin(),
333
- listsPlugin(),
334
- quotePlugin(),
335
- linkPlugin(),
336
- linkDialogPlugin(),
337
- tablePlugin(),
338
- thematicBreakPlugin(),
339
- codeBlockPlugin({
340
- defaultCodeBlockLanguage: "ts",
341
- codeBlockEditorDescriptors: [conlocaCodeBlockDescriptor]
342
- }),
343
- codeMirrorPlugin({ codeBlockLanguages }),
344
- diffSourcePlugin({ viewMode: "rich-text" }),
345
- markdownShortcutPlugin(),
346
- jsxPlugin({ jsxComponentDescriptors: [...jsxComponentDescriptors ?? [], ...wildcardJsxDescriptors] }),
347
- imagePlugin({
348
- ...imageDialog ? {
349
- ImageDialog: imageDialog,
350
- disableImageSettingsButton
351
- } : {},
352
- ...imageUploadHandler ? { imageUploadHandler } : {}
353
- }),
354
- ...extraPlugins ?? [],
355
- toolbarPlugin({
356
- toolbarClassName: "mdxeditor-toolbar-wrap",
357
- toolbarContents: () => /* @__PURE__ */ jsx(DiffSourceToggleWrapper, { children: /* @__PURE__ */ jsx(ConditionalContents, { options: [{
358
- when: (editor) => editor?.editorType === "codeblock",
359
- contents: () => /* @__PURE__ */ jsx(ChangeCodeMirrorLanguage, {})
360
- }, { fallback: () => /* @__PURE__ */ jsxs(Fragment, { children: [
361
- /* @__PURE__ */ jsx(UndoRedo, {}),
362
- /* @__PURE__ */ jsx(Separator, {}),
363
- /* @__PURE__ */ jsx(BoldItalicUnderlineToggles, {}),
364
- /* @__PURE__ */ jsx(StrikeThroughSupSubToggles, {}),
365
- /* @__PURE__ */ jsx(HighlightToggle, {}),
366
- /* @__PURE__ */ jsx(Separator, {}),
367
- /* @__PURE__ */ jsx(ListsToggle, {}),
368
- /* @__PURE__ */ jsx(Separator, {}),
369
- /* @__PURE__ */ jsx(BlockTypeSelect, {}),
370
- /* @__PURE__ */ jsx(Separator, {}),
371
- /* @__PURE__ */ jsx(CreateLink, {}),
372
- renderInsertImageButton(imageButtonRef),
373
- /* @__PURE__ */ jsx(InsertTable, {}),
374
- /* @__PURE__ */ jsx(InsertThematicBreak, {}),
375
- /* @__PURE__ */ jsx(Separator, {}),
376
- /* @__PURE__ */ jsx(InsertCodeBlock, {}),
377
- extraToolbarItems,
378
- /* @__PURE__ */ jsx(Separator, {}),
379
- /* @__PURE__ */ jsx(FocusModeToggle, {})
380
- ] }) }] }) })
381
- })
382
- ]
383
- });
384
- });
385
- BaseMDXEditor.displayName = "BaseMDXEditor";
386
- //#endregion
387
- //#region src/hooks/useMDXEvaluation.ts
388
- const compiledCache = /* @__PURE__ */ new Map();
389
- /**
390
- * Execute pre-compiled MDX code (compiled with outputFormat: 'function-body').
391
- * This is the same as @mdx-js/mdx's run() — inlined here to avoid importing
392
- * the full @mdx-js/mdx package (which pulls acorn + remark + unified into the browser).
393
- *
394
- * Note: Uses AsyncFunction constructor which requires CSP `unsafe-eval`.
395
- * This is acceptable since the CMS admin UI runs in a trusted environment.
396
- */
397
- const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
398
- async function runMDX(code, options) {
399
- return new AsyncFunction(String(code))(options);
400
- }
401
- /**
402
- * Create the JSX runtime options for runMDX().
403
- * Checked once at module load to avoid repeated environment checks.
404
- */
405
- function createRunOptions() {
406
- return process.env.NODE_ENV === "development" ? {
407
- ...devRuntime,
408
- development: true
409
- } : { ...runtime };
410
- }
411
- const runOptions = createRunOptions();
412
- /**
413
- * Simple hash function for generating cache keys from MDX content.
414
- */
415
- function hashString(str) {
416
- let hash = 0;
417
- for (let i = 0; i < str.length; i++) {
418
- const char = str.charCodeAt(i);
419
- hash = (hash << 5) - hash + char;
420
- hash = hash & hash;
421
- }
422
- return hash.toString(36);
423
- }
424
- /**
425
- * Hook for evaluating pre-compiled MDX code into React components.
426
- *
427
- * Uses the browser-side half of a server-compile + browser-run pattern:
428
- * 1. The server compiles MDX → JavaScript function body
429
- * 2. The browser executes the pre-compiled code with run() (zero compiler dependencies)
430
- *
431
- * This keeps the full MDX compilation pipeline on the server and only ships
432
- * a tiny runtime helper to the browser.
433
- *
434
- * @param options.compiledCode - The pre-compiled MDX function body. If null, returns null component
435
- * @param options.cacheKey - Optional cache key. If not provided, uses hash of code
436
- *
437
- * @returns Object containing Component, error, isLoading, retry
438
- */
439
- function useMDXEvaluation({ compiledCode, cacheKey }) {
440
- const [Component, setComponent] = useState(null);
441
- const [error, setError] = useState(null);
442
- const [isLoading, setIsLoading] = useState(() => {
443
- if (!compiledCode) return false;
444
- const key = cacheKey || `mdx-${hashString(compiledCode)}`;
445
- return !compiledCache.has(key);
446
- });
447
- const [retryCount, setRetryCount] = useState(0);
448
- const retry = () => {
449
- if (compiledCode) {
450
- const key = cacheKey || `mdx-${hashString(compiledCode)}`;
451
- compiledCache.delete(key);
452
- }
453
- setRetryCount((prev) => prev + 1);
454
- };
455
- useEffect(() => {
456
- if (!compiledCode) {
457
- setComponent(null);
458
- setError(null);
459
- setIsLoading(false);
460
- return;
461
- }
462
- const key = cacheKey || `mdx-${hashString(compiledCode)}`;
463
- const cached = compiledCache.get(key);
464
- if (cached) {
465
- setComponent(() => cached);
466
- setError(null);
467
- setIsLoading(false);
468
- return;
469
- }
470
- let cancelled = false;
471
- const compileAndRun = async () => {
472
- try {
473
- setError(null);
474
- setIsLoading(true);
475
- const { default: MDXComponent } = await runMDX(compiledCode, runOptions);
476
- if (cancelled) return;
477
- compiledCache.set(key, MDXComponent);
478
- setComponent(() => MDXComponent);
479
- } catch (err) {
480
- if (cancelled) return;
481
- const evaluationError = err instanceof Error ? err : /* @__PURE__ */ new Error("MDX evaluation failed");
482
- setError(evaluationError);
483
- setComponent(null);
484
- } finally {
485
- if (!cancelled) setIsLoading(false);
486
- }
487
- };
488
- compileAndRun();
489
- return () => {
490
- cancelled = true;
491
- };
492
- }, [
493
- compiledCode,
494
- cacheKey,
495
- retryCount
496
- ]);
497
- return {
498
- Component,
499
- error,
500
- isLoading,
501
- retry
502
- };
503
- }
504
- //#endregion
505
- //#region src/mdx-editor.tsx
506
- const MDXEditor = React.forwardRef((props, ref) => {
507
- return /* @__PURE__ */ jsx(BaseMDXEditor, {
508
- ref,
509
- ...props
510
- });
511
- });
512
- MDXEditor.displayName = "MDXEditor";
513
- //#endregion
514
- export { BaseMDXEditor, MDXEditor, codeBlockWrapperInfo$, useMDXEvaluation };
515
-
516
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["MDXEditorLib"],"sources":["../src/code-block-frame.tsx","../src/markdown-options.ts","../src/editor-core.tsx","../src/hooks/useMDXEvaluation.ts","../src/mdx-editor.tsx"],"sourcesContent":["import {\n Cell,\n type CodeBlockEditorDescriptor,\n type CodeBlockEditorProps,\n CodeMirrorEditor,\n useCellValue,\n useCodeBlockEditorContext,\n} from '@mdxeditor/editor';\nimport { Check, Copy } from 'lucide-react';\nimport { type ChangeEvent, createElement, type ReactElement, useCallback, useEffect, useMemo, useState } from 'react';\n\n/**\n * Frame chrome around the editor's fenced code blocks — header bar with\n * filename, language tag, and a copy button. The outer wrapper picks up\n * the host's code-block classes (published via `codeBlockWrapperInfo$`\n * by the host-wrapper plugin in cms-spa), so the host's actual code-\n * block CSS (Starlight's expressive-code, Tailwind's pre styling, etc.)\n * reaches the editor's frame through the cascade — no shipped mirror.\n *\n * Host-agnostic: no Shiki / Starlight / ExpressiveCode imports. Class\n * names are discovered at runtime from the host's live HTML.\n */\n\n/**\n * Realm-published cell carrying the host's code-block wrapper chain,\n * outermost first. For Starlight's expressive-code:\n *\n * [\n * { tagName: 'div', className: 'expressive-code' },\n * { tagName: 'figure', className: 'frame has-title not-content' },\n * ]\n *\n * The cms-spa `hostWrapperPlugin` writes to this whenever the fetched\n * wrapper info changes; the code-block frame reads from it to render\n * each chain link as a nested element with the host's expected tag\n * name. Same publish-pattern as the content-wrapper plugin in cms-spa.\n *\n * Null when the host has no code-block chrome (or the fetch is in\n * flight). The frame then falls back to its base `.conloca-code-block`\n * wrapper with no host inheritance — \"looks plain but not broken.\"\n */\nexport const codeBlockWrapperInfo$ = Cell<{ tagName: string; className: string }[] | null>(null);\n\nconst TITLE_META_RE = /\\btitle=(?:\"([^\"]*)\"|'([^']*)'|(\\S+))/;\n// First-line filename comment, the convention ExpressiveCode's frames\n// plugin recognizes when no explicit `title=` is set on the fence —\n// `// foo.ts`, `# foo.py`, `<!-- foo.html -->`, `/* foo.css */`,\n// `; foo.ini`, `-- foo.sql`. Requires a dot-extension so plain prose\n// comments don't get mistaken for filenames.\nconst FILENAME_COMMENT_RE = /^\\s*(?:\\/\\/|#|;|--|<!--|\\/\\*)\\s*([\\w.\\-/@]+\\.[\\w.-]+)\\s*(?:-->|\\*\\/)?\\s*$/;\n\ninterface MetaParts {\n /** The current title value (empty string when no title meta is set). */\n title: string;\n /** Everything else in the meta string, with the title slice removed. */\n rest: string;\n}\n\nfunction parseMeta(meta: string): MetaParts {\n const match = meta.match(TITLE_META_RE);\n if (!match) return { title: '', rest: meta.trim() };\n const value = match[1] ?? match[2] ?? match[3] ?? '';\n const rest = (meta.slice(0, match.index) + meta.slice(match.index! + match[0].length)).replace(/\\s+/g, ' ').trim();\n return { title: value, rest };\n}\n\n/** Reassemble a meta string with `title` set (or stripped when empty). */\nfunction buildMeta(title: string, rest: string): string {\n const trimmedTitle = title.trim();\n const titleFragment = trimmedTitle ? `title=\"${trimmedTitle.replace(/\"/g, '\\\\\"')}\"` : '';\n if (titleFragment && rest) return `${titleFragment} ${rest}`;\n return titleFragment || rest;\n}\n\n/**\n * Detect a leading filename comment, the convention EC's frames plugin\n * uses on the published page when no explicit `title=` is set. Returns\n * the filename when line 1 of the code is a single-line comment ending\n * in a dot-extension; empty string otherwise.\n *\n * Used to pre-fill the editor's filename input on legacy fences so\n * authors see the same value the reader sees in the rendered tab. Pure\n * read — the underlying code/comment is never touched.\n */\nfunction detectFilenameComment(code: string): string {\n const firstLine = code.split('\\n', 1)[0] ?? '';\n const match = firstLine.match(FILENAME_COMMENT_RE);\n return match ? (match[1] ?? '') : '';\n}\n\nfunction CopyButton({ code }: { code: string }) {\n const [copied, setCopied] = useState(false);\n const onClick = useCallback(() => {\n void navigator.clipboard.writeText(code).then(() => {\n setCopied(true);\n window.setTimeout(() => setCopied(false), 1200);\n });\n }, [code]);\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className=\"conloca-code-copy\"\n aria-label={copied ? 'Copied' : 'Copy code'}\n title={copied ? 'Copied' : 'Copy code'}\n >\n {copied ? <Check size={14} aria-hidden=\"true\" /> : <Copy size={14} aria-hidden=\"true\" />}\n </button>\n );\n}\n\n/**\n * Editable filename slot. Rewrites the code block's meta string via\n * `setMeta` from `useCodeBlockEditorContext` so authors can author the\n * frame title (`\\`\\`\\`ts title=\"src/foo.ts\"`) directly from the editor —\n * the meta string round-trips through MDXEditor's markdown serializer\n * and ExpressiveCode picks it up as the frame header on the published\n * page. Other meta fragments (ins/del/mark/wrap) are preserved.\n *\n * Legacy fences with a filename comment on line 1 (`// foo.ts`) — EC's\n * pre-meta convention for tab titles — are detected and pre-filled in\n * the input as a read-only display. Opening such a fence does NOT\n * mutate the source. Editing the field is an explicit author intent:\n * the new value is written as `title=` meta AND the original comment\n * line is stripped, so the editor's input becomes the single source of\n * truth without breaking the published render.\n */\nfunction FilenameInput({ meta, code }: { meta: string; code: string }) {\n const { setMeta, setCode } = useCodeBlockEditorContext();\n const parsed = useMemo(() => parseMeta(meta), [meta]);\n const detectedFromComment = useMemo(() => (parsed.title ? '' : detectFilenameComment(code)), [parsed.title, code]);\n const displayed = parsed.title || detectedFromComment;\n const [title, setTitle] = useState(displayed);\n const [interacted, setInteracted] = useState(false);\n\n // External updates (HMR, language change, sibling code edits) reset\n // the local view to the canonical value and clear the \"user edited\"\n // flag — so the next blur after an external update doesn't write\n // anything until the author actively types again.\n useEffect(() => {\n setTitle(displayed);\n setInteracted(false);\n }, [displayed]);\n\n const commit = useCallback(\n (next: string) => {\n if (!interacted) return;\n if (next === parsed.title) return;\n setMeta(buildMeta(next, parsed.rest));\n // If the pre-fill came from a leading filename comment and the\n // author has now committed an explicit title, strip the comment\n // so EC doesn't render the title twice (once as the tab, once as\n // a stray code comment) on the published page.\n if (detectedFromComment) {\n const lines = code.split('\\n');\n if (lines[0] && FILENAME_COMMENT_RE.test(lines[0])) {\n setCode(lines.slice(1).join('\\n').replace(/^\\n+/, ''));\n }\n }\n },\n [interacted, parsed.title, parsed.rest, detectedFromComment, code, setMeta, setCode],\n );\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n setInteracted(true);\n setTitle(e.target.value);\n };\n const onBlur = () => commit(title);\n\n return (\n <input\n type=\"text\"\n className=\"conloca-code-block__filename\"\n value={title}\n placeholder=\"filename\"\n spellCheck={false}\n onChange={onChange}\n onBlur={onBlur}\n aria-label=\"Code block filename\"\n />\n );\n}\n\nfunction ConlocaCodeBlockEditor(props: CodeBlockEditorProps) {\n // Materialise the host's discovered code-block chain as nested\n // elements. The INNERMOST link in the chain becomes the \"frame\"\n // element that directly holds the filename header, the code body,\n // and the copy slot — matching ExpressiveCode's authoring shape:\n //\n // <div class=\"expressive-code\"> ← outer link\n // <figure class=\"frame has-title …\"> ← inner link (frame)\n // <figcaption class=\"header\">\n // <span class=\"title\"><FilenameInput /></span>\n // </figcaption>\n // <pre><CodeMirror /></pre>\n // <div class=\"copy\"><CopyButton /></div>\n // </figure>\n // </div>\n //\n // Rendering with the host's expected tags (figure / figcaption / pre)\n // and nesting depth lets descendant CSS selectors land — both single-\n // class (`.frame { ... }`) and descendant (`.expressive-code .frame\n // .header > .title { ... }`) rules paint without us shipping a\n // parallel copy.\n //\n // When chain is null/empty (host has no code-block chrome, or the\n // wrapper fetch hasn't resolved yet) we fall back to a bare\n // `<div class=\"conloca-code-block\">` containing the same inner\n // shape — \"looks plain but not broken.\"\n const chain = useCellValue(codeBlockWrapperInfo$) ?? [];\n const frameLink = chain.length > 0 ? chain[chain.length - 1] : null;\n const outerLinks = frameLink ? chain.slice(0, -1) : [];\n\n const frameInner = (\n <>\n <figcaption className=\"conloca-code-block__header header\">\n <span className=\"title\">\n <FilenameInput meta={props.meta} code={props.code} />\n </span>\n </figcaption>\n <pre className=\"conloca-code-block__pre\">\n <CodeMirrorEditor {...props} />\n </pre>\n {/* `.copy` matches expressive-code's expected slot name so any\n `.frame .copy` styling from the host paints. We host only the\n copy button here — language selection lives in MDXEditor's\n own `_codeMirrorToolbar_*` (combobox), positioned via\n editor-styles.css so it doesn't overlap the code. */}\n <div className=\"conloca-code-block__copy copy\">\n <CopyButton code={props.code} />\n </div>\n </>\n );\n\n // The frame element carries `conloca-code-block` (our own targeting\n // hook) alongside the host's discovered classes. When the host has\n // no chain, we still wrap in a plain `<div>` so the inner shape is\n // consistent for our utility selectors.\n const frame = frameLink ? (\n createElement(frameLink.tagName, { className: `conloca-code-block ${frameLink.className}` }, frameInner)\n ) : (\n <div className=\"conloca-code-block\">{frameInner}</div>\n );\n\n // Wrap outer links from inside out. `reduceRight` so the first\n // chain link ends up as the outermost rendered element.\n return outerLinks.reduceRight<ReactElement>(\n (kids, link) => createElement(link.tagName, { className: link.className }, kids),\n frame,\n );\n}\n\n/**\n * Catch-all descriptor — `priority: 100`, `match: () => true` — registered\n * via `codeBlockPlugin({ codeBlockEditorDescriptors: [conlocaCodeBlockDescriptor] })`.\n * Wraps the upstream `CodeMirrorEditor` with the host-themed frame.\n */\nexport const conlocaCodeBlockDescriptor: CodeBlockEditorDescriptor = {\n priority: 100,\n match: () => true,\n Editor: ConlocaCodeBlockEditor,\n};\n","import type { Options as ToMarkdownOptions } from 'mdast-util-to-markdown';\n\n// MDXEditor rebuilds the markdown body from its Lexical AST on every change\n// via `mdast-util-to-markdown`. Without explicit options, the library defaults\n// flip canonical project style: thematic breaks render as `***` instead of\n// `---`, bullets pick `*` over `-`, and emphasis ambiguity inside GFM table\n// cells inserts backslash escapes on every save. Pinning these to match the\n// committed fixtures keeps no-op round-trips diff-clean.\n//\n// Exported as a plain TS module (no React deps) so it can be exercised\n// directly from tests against `mdast-util-to-markdown` without mounting the\n// editor.\nexport const TO_MARKDOWN_OPTIONS: ToMarkdownOptions = {\n bullet: '-',\n rule: '-',\n emphasis: '_',\n strong: '*',\n fence: '`',\n listItemIndent: 'one',\n tightDefinitions: true,\n};\n","import {\n BlockTypeSelect,\n BoldItalicUnderlineToggles,\n ButtonWithTooltip,\n ChangeCodeMirrorLanguage,\n ConditionalContents,\n CreateLink,\n codeBlockPlugin,\n codeMirrorPlugin,\n DiffSourceToggleWrapper,\n diffSourcePlugin,\n GenericJsxEditor,\n HighlightToggle,\n headingsPlugin,\n InsertCodeBlock,\n InsertImage,\n InsertTable,\n InsertThematicBreak,\n imagePlugin,\n type JsxComponentDescriptor,\n jsxPlugin,\n ListsToggle,\n linkDialogPlugin,\n linkPlugin,\n listsPlugin,\n MDXEditor as MDXEditorLib,\n type MDXEditorMethods,\n markdownShortcutPlugin,\n quotePlugin,\n type RealmPlugin,\n Separator,\n StrikeThroughSupSubToggles,\n tablePlugin,\n thematicBreakPlugin,\n toolbarPlugin,\n UndoRedo,\n} from '@mdxeditor/editor';\nimport { Maximize2, Minimize2 } from 'lucide-react';\nimport React, { useCallback, useEffect, useSyncExternalStore } from 'react';\nimport '@mdxeditor/editor/style.css';\nimport './editor-styles.css';\nimport { conlocaCodeBlockDescriptor } from './code-block-frame';\nimport { TO_MARKDOWN_OPTIONS } from './markdown-options';\n\nconst FOCUS_MODE_STORAGE_KEY = 'conloca.mdxeditor.focusMode';\nconst FOCUS_MODE_BODY_CLASS = 'mdxeditor-focus-mode';\n\n/**\n * Toggle focus-mode by writing the class on `document.body`. Direct DOM\n * mutation (vs. piping a boolean through React state into the editor's\n * `className` prop) avoids re-rendering Lexical on every toggle — the\n * editor's prop is the only entry point and changing it forces a parse\n * round-trip. Persisted in localStorage so the preference survives reloads.\n */\nfunction readFocusMode(): boolean {\n if (typeof document === 'undefined') return false;\n return document.body.classList.contains(FOCUS_MODE_BODY_CLASS);\n}\n\nfunction subscribeFocusMode(callback: () => void): () => void {\n if (typeof window === 'undefined') return () => {};\n const handler = () => callback();\n window.addEventListener('conloca:focusModeChange', handler);\n return () => window.removeEventListener('conloca:focusModeChange', handler);\n}\n\nfunction setFocusMode(next: boolean): void {\n if (typeof document === 'undefined') return;\n document.body.classList.toggle(FOCUS_MODE_BODY_CLASS, next);\n try {\n if (next) {\n window.localStorage.setItem(FOCUS_MODE_STORAGE_KEY, '1');\n } else {\n window.localStorage.removeItem(FOCUS_MODE_STORAGE_KEY);\n }\n } catch {\n // localStorage may be unavailable (private mode, SSR) — ignore.\n }\n window.dispatchEvent(new Event('conloca:focusModeChange'));\n}\n\nfunction FocusModeToggle() {\n const focusMode = useSyncExternalStore(subscribeFocusMode, readFocusMode, () => false);\n const onClick = useCallback(() => setFocusMode(!focusMode), [focusMode]);\n const Icon = focusMode ? Minimize2 : Maximize2;\n return (\n <ButtonWithTooltip\n title={focusMode ? 'Exit focus mode (wider column)' : 'Enter focus mode (narrow column)'}\n onClick={onClick}\n >\n <Icon size={16} aria-hidden />\n </ButtonWithTooltip>\n );\n}\n\nexport interface BaseMDXEditorProps {\n value: string;\n /**\n * Called whenever the editor content changes. The second argument is `true`\n * the first time the library normalizes the parsed markdown back to its\n * canonical form (bullet style, trailing newline, etc.) — consumers tracking\n * dirty state should treat that call as a re-baseline rather than a user\n * edit, otherwise the editor looks dirty the moment the page loads.\n */\n onChange: (value: string, initialMarkdownNormalize?: boolean) => void;\n onSave?: (value: string) => void;\n readOnly?: boolean;\n imageDialog?: React.FC | null;\n disableImageSettingsButton?: boolean;\n onImageShortcut?: () => void;\n imageButtonRef?: React.Ref<HTMLButtonElement>;\n /**\n * Upload handler for images pasted or dropped directly into the editor. When\n * provided, the underlying imagePlugin will route those events through this\n * function and insert the returned URL as the image src. Independent of the\n * library/picker `imageDialog` flow — both can be active simultaneously.\n */\n imageUploadHandler?: (file: File) => Promise<string>;\n jsxComponentDescriptors?: JsxComponentDescriptor[];\n /**\n * Additional @mdxeditor/editor RealmPlugins appended to the built-in\n * plugin list. Used by the SPA shell to register the MDX components\n * registry-driven slash menu without coupling @conloca/mdx to\n * @conloca/cms-spa.\n */\n extraPlugins?: RealmPlugin[];\n /**\n * Extra toolbar buttons inserted between `<InsertAdmonition />` and the\n * separator preceding focus mode. Pass `null` (default) to keep the\n * stock toolbar.\n */\n extraToolbarItems?: React.ReactNode;\n /**\n * Class applied to the MDXEditor root element (library forwards it to the\n * toolbar and portaled popups too). Pass `\"dark-theme\"` to activate the\n * library's built-in Radix dark palette.\n * See https://mdxeditor.dev/editor/docs/theming\n */\n className?: string;\n /** Placeholder shown when the editor is empty. Forwarded to MDXEditorLib. */\n placeholder?: React.ReactNode;\n /** Auto-focus the editor on mount. Forwarded to MDXEditorLib. */\n autoFocus?: boolean | { defaultSelection?: 'rootStart' | 'rootEnd'; preventScroll?: boolean };\n}\n\n// The empty-string entry is the documented escape hatch for code blocks\n// authored without a language hint. Without it, fences like ```\\nfoo\\n``` (which\n// the parser tags as language `null` / meta `'N/A'`) trip a hard error in\n// older versions and emit a noisy warning even on v3.55+. See mdx-editor/editor\n// issues #370, #423, #463, #885, #886, #901.\nconst codeBlockLanguages: Record<string, string> = {\n '': 'Plain text',\n text: 'Plain Text',\n js: 'JavaScript',\n jsx: 'JavaScript (React)',\n ts: 'TypeScript',\n tsx: 'TypeScript (React)',\n css: 'CSS',\n html: 'HTML',\n json: 'JSON',\n md: 'Markdown',\n mdx: 'MDX',\n bash: 'Bash',\n python: 'Python',\n};\n\n/**\n * Wildcard fallback so any unknown JSX tag round-trips through GenericJsxEditor\n * instead of crashing the importer with \"Parsing of the following markdown\n * structure failed\". Two entries because the upstream visitor dispatches by\n * `kind` (block vs inline JSX) — without the inline one, an inline `<Badge>`\n * mid-paragraph would be matched by the flow wildcard and lifted out of its\n * paragraph in Lexical. Consumers passing typed descriptors win via the\n * exact-name match in the visitor; the wildcard only handles the leftovers.\n */\nconst wildcardJsxDescriptors: JsxComponentDescriptor[] = [\n { name: '*', kind: 'flow', props: [], hasChildren: true, Editor: GenericJsxEditor },\n { name: '*', kind: 'text', props: [], hasChildren: true, Editor: GenericJsxEditor },\n];\n\nfunction renderInsertImageButton(imageButtonRef?: React.Ref<HTMLButtonElement>) {\n if (!imageButtonRef) {\n return <InsertImage />;\n }\n\n return React.createElement(InsertImage as unknown as React.FC<{ ref: React.Ref<HTMLButtonElement> }>, {\n ref: imageButtonRef,\n });\n}\n\n/**\n * Restore the persisted focus-mode preference on first import. Runs once at\n * module load so the class is in place before any editor mounts — avoids a\n * flash of wide column when the user previously selected focus mode.\n */\nif (typeof window !== 'undefined') {\n try {\n if (window.localStorage.getItem(FOCUS_MODE_STORAGE_KEY) === '1') {\n document.body.classList.add(FOCUS_MODE_BODY_CLASS);\n }\n } catch {\n // ignore\n }\n}\n\nexport const BaseMDXEditor = React.forwardRef<MDXEditorMethods, BaseMDXEditorProps>(\n (\n {\n value,\n onChange,\n onSave,\n readOnly = false,\n imageDialog,\n disableImageSettingsButton = false,\n onImageShortcut,\n imageButtonRef,\n imageUploadHandler,\n jsxComponentDescriptors,\n extraPlugins,\n extraToolbarItems,\n className,\n placeholder,\n autoFocus,\n },\n ref,\n ) => {\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if ((event.ctrlKey || event.metaKey) && event.key === 's') {\n event.preventDefault();\n onSave?.(value);\n }\n\n if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.key.toLowerCase() === 'i') {\n if (!onImageShortcut) {\n return;\n }\n\n event.preventDefault();\n onImageShortcut();\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [onImageShortcut, onSave, value]);\n\n return (\n <MDXEditorLib\n ref={ref}\n markdown={value}\n toMarkdownOptions={TO_MARKDOWN_OPTIONS}\n onChange={onChange}\n onError={({ error, source }) => {\n // Library invokes this synchronously inside a gurx signal, so don't\n // setState here — that triggers a render-phase warning (#872).\n // Logging only is enough; the React error boundary still catches\n // anything that escapes from rendering.\n console.error('[MDXEditor] parse error:', error, '\\nsource:', source);\n }}\n readOnly={readOnly}\n className={className}\n placeholder={placeholder}\n autoFocus={autoFocus}\n contentEditableClassName=\"conloca-prose conloca-prose--editor\"\n plugins={[\n headingsPlugin(),\n listsPlugin(),\n quotePlugin(),\n linkPlugin(),\n linkDialogPlugin(),\n tablePlugin(),\n thematicBreakPlugin(),\n // frontmatterPlugin intentionally omitted: metadata (title,\n // description, id, created, modified) is server-owned and stripped\n // from `content.mdx` on load. Re-introducing the plugin would let\n // the editor round-trip a YAML block as body text, corrupting the\n // file when content is inserted above it.\n codeBlockPlugin({\n defaultCodeBlockLanguage: 'ts',\n codeBlockEditorDescriptors: [conlocaCodeBlockDescriptor],\n }),\n codeMirrorPlugin({ codeBlockLanguages }),\n diffSourcePlugin({ viewMode: 'rich-text' }),\n markdownShortcutPlugin(),\n jsxPlugin({\n jsxComponentDescriptors: [...(jsxComponentDescriptors ?? []), ...wildcardJsxDescriptors],\n }),\n imagePlugin({\n ...(imageDialog ? { ImageDialog: imageDialog, disableImageSettingsButton } : {}),\n ...(imageUploadHandler ? { imageUploadHandler } : {}),\n }),\n ...(extraPlugins ?? []),\n toolbarPlugin({\n // flex-wrap so the toolbar reflows on narrow viewports instead of\n // overflowing horizontally — workaround documented in\n // mdx-editor/editor#908.\n toolbarClassName: 'mdxeditor-toolbar-wrap',\n toolbarContents: () => (\n <DiffSourceToggleWrapper>\n <ConditionalContents\n options={[\n {\n // When the user clicks into a code block, swap most of\n // the rich-text toolbar for the language picker — those\n // controls are no-ops inside CodeMirror anyway.\n when: (editor) => editor?.editorType === 'codeblock',\n contents: () => <ChangeCodeMirrorLanguage />,\n },\n {\n fallback: () => (\n <>\n <UndoRedo />\n <Separator />\n <BoldItalicUnderlineToggles />\n <StrikeThroughSupSubToggles />\n <HighlightToggle />\n <Separator />\n <ListsToggle />\n <Separator />\n <BlockTypeSelect />\n <Separator />\n <CreateLink />\n {renderInsertImageButton(imageButtonRef)}\n <InsertTable />\n <InsertThematicBreak />\n <Separator />\n <InsertCodeBlock />\n {extraToolbarItems}\n <Separator />\n <FocusModeToggle />\n </>\n ),\n },\n ]}\n />\n </DiffSourceToggleWrapper>\n ),\n }),\n ]}\n />\n );\n },\n);\n\nBaseMDXEditor.displayName = 'BaseMDXEditor';\n","import type React from 'react';\nimport { useEffect, useState } from 'react';\nimport * as devRuntime from 'react/jsx-dev-runtime';\nimport * as runtime from 'react/jsx-runtime';\n\n// Cache for compiled MDX components\nconst compiledCache = new Map<string, React.ComponentType>();\n\n/**\n * Execute pre-compiled MDX code (compiled with outputFormat: 'function-body').\n * This is the same as @mdx-js/mdx's run() — inlined here to avoid importing\n * the full @mdx-js/mdx package (which pulls acorn + remark + unified into the browser).\n *\n * Note: Uses AsyncFunction constructor which requires CSP `unsafe-eval`.\n * This is acceptable since the CMS admin UI runs in a trusted environment.\n */\nconst AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;\nasync function runMDX(code: string, options: Record<string, unknown>): Promise<{ default: React.ComponentType }> {\n return new AsyncFunction(String(code))(options);\n}\n\n/**\n * Create the JSX runtime options for runMDX().\n * Checked once at module load to avoid repeated environment checks.\n */\nfunction createRunOptions() {\n const isDevelopment = process.env.NODE_ENV === 'development';\n return isDevelopment ? { ...devRuntime, development: true } : { ...runtime };\n}\n\nconst runOptions = createRunOptions();\n\n/**\n * Simple hash function for generating cache keys from MDX content.\n */\nfunction hashString(str: string): string {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash.toString(36);\n}\n\nexport interface UseMDXEvaluationOptions {\n compiledCode: string | null;\n cacheKey?: string;\n}\n\nexport interface UseMDXEvaluationResult {\n Component: React.ComponentType | null;\n error: Error | null;\n isLoading: boolean;\n retry: () => void;\n}\n\n/**\n * Hook for evaluating pre-compiled MDX code into React components.\n *\n * Uses the browser-side half of a server-compile + browser-run pattern:\n * 1. The server compiles MDX → JavaScript function body\n * 2. The browser executes the pre-compiled code with run() (zero compiler dependencies)\n *\n * This keeps the full MDX compilation pipeline on the server and only ships\n * a tiny runtime helper to the browser.\n *\n * @param options.compiledCode - The pre-compiled MDX function body. If null, returns null component\n * @param options.cacheKey - Optional cache key. If not provided, uses hash of code\n *\n * @returns Object containing Component, error, isLoading, retry\n */\nexport function useMDXEvaluation({ compiledCode, cacheKey }: UseMDXEvaluationOptions): UseMDXEvaluationResult {\n const [Component, setComponent] = useState<React.ComponentType | null>(null);\n const [error, setError] = useState<Error | null>(null);\n const [isLoading, setIsLoading] = useState(() => {\n if (!compiledCode) return false;\n const key = cacheKey || `mdx-${hashString(compiledCode)}`;\n return !compiledCache.has(key);\n });\n const [retryCount, setRetryCount] = useState(0);\n\n const retry = () => {\n if (compiledCode) {\n const key = cacheKey || `mdx-${hashString(compiledCode)}`;\n compiledCache.delete(key);\n }\n setRetryCount((prev) => prev + 1);\n };\n\n useEffect(() => {\n void retryCount;\n\n if (!compiledCode) {\n setComponent(null);\n setError(null);\n setIsLoading(false);\n return;\n }\n\n const key = cacheKey || `mdx-${hashString(compiledCode)}`;\n const cached = compiledCache.get(key);\n if (cached) {\n setComponent(() => cached);\n setError(null);\n setIsLoading(false);\n return;\n }\n\n let cancelled = false;\n\n const compileAndRun = async () => {\n try {\n setError(null);\n setIsLoading(true);\n\n const { default: MDXComponent } = await runMDX(compiledCode, runOptions);\n\n if (cancelled) return;\n\n compiledCache.set(key, MDXComponent);\n setComponent(() => MDXComponent);\n } catch (err) {\n if (cancelled) return;\n const evaluationError = err instanceof Error ? err : new Error('MDX evaluation failed');\n setError(evaluationError);\n setComponent(null);\n } finally {\n if (!cancelled) {\n setIsLoading(false);\n }\n }\n };\n\n compileAndRun();\n\n return () => {\n cancelled = true;\n };\n }, [compiledCode, cacheKey, retryCount]);\n\n return { Component, error, isLoading, retry };\n}\n","import type { MDXEditorMethods } from '@mdxeditor/editor';\nimport React from 'react';\nimport { BaseMDXEditor, type BaseMDXEditorProps } from './editor-core.js';\n\nexport interface MDXEditorProps\n extends Omit<\n BaseMDXEditorProps,\n 'disableImageSettingsButton' | 'imageButtonRef' | 'imageDialog' | 'onImageShortcut'\n > {}\n\nexport const MDXEditor = React.forwardRef<MDXEditorMethods, MDXEditorProps>((props, ref) => {\n return <BaseMDXEditor ref={ref} {...props} />;\n});\n\nMDXEditor.displayName = 'MDXEditor';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,wBAAwB,KAAsD,IAAI;AAE/F,MAAM,gBAAgB;AAMtB,MAAM,sBAAsB;AAS5B,SAAS,UAAU,MAAyB;CAC1C,MAAM,QAAQ,KAAK,MAAM,aAAa;CACtC,IAAI,CAAC,OAAO,OAAO;EAAE,OAAO;EAAI,MAAM,KAAK,KAAK;CAAE;CAGlD,OAAO;EAAE,OAFK,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM;EAE3B,OADT,KAA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