@conloca/mdx 0.2.2 → 0.2.4
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 +45 -7
- package/dist/.build-inputs.json +34 -0
- package/dist/editor-core.d.ts +2 -0
- package/dist/editor-core.d.ts.map +1 -1
- package/dist/editor-core.js +2 -1
- package/dist/editor-core.js.map +1 -1
- package/dist/sandbox-frame.d.ts +12 -1
- package/dist/sandbox-frame.d.ts.map +1 -1
- package/dist/sandbox-frame.js +64 -9
- package/dist/sandbox-frame.js.map +1 -1
- package/package.json +2 -3
- package/src/editor-core.tsx +4 -0
- package/src/sandbox-frame.ts +63 -8
package/README.md
CHANGED
|
@@ -8,7 +8,9 @@ Universal MDX package for both browser and Node.js environments.
|
|
|
8
8
|
|
|
9
9
|
- **MDXEditor** - Embeddable MDX editor component (the page-route editor in the CMS SPA uses this directly)
|
|
10
10
|
- **BaseMDXEditor** - Lower-level editor primitive that accepts the image-dialog hook used by the CMS SPA's
|
|
11
|
-
media-library integration
|
|
11
|
+
media-library integration, and an optional `imagePreviewHandler(src) => Promise<string>` that maps an image's `src` to
|
|
12
|
+
the URL the editor canvas shows (for example an object URL of unpublished bytes); the saved markdown keeps the
|
|
13
|
+
original `src`
|
|
12
14
|
- **codeBlockWrapperInfo$** - Editor realm cell a host publishes so the editor's fenced code blocks inherit the host
|
|
13
15
|
site's own code-block classes
|
|
14
16
|
|
|
@@ -32,7 +34,9 @@ Compiled MDX is evaluated in an opaque-origin iframe, never in the page that hos
|
|
|
32
34
|
|
|
33
35
|
- **buildSandboxSrcdoc** - Build the preview frame's HTML document, with its runtime inlined
|
|
34
36
|
- **SANDBOX_FRAME_CSP** - The content-security policy that confines the MDX evaluation to that frame
|
|
35
|
-
- **
|
|
37
|
+
- **MDX_SANDBOX_FRAME_POLICY** - The policy a server sends with the frame document: `SANDBOX_FRAME_CSP` plus
|
|
38
|
+
`sandbox allow-scripts` and `frame-ancestors 'self'`, which a meta policy cannot carry
|
|
39
|
+
- **SANDBOX_FRAME_PATH** - The path a dev server serves the frame document from
|
|
36
40
|
- **SandboxRenderMessage** / **SandboxOutboundMessage** - The messages the host and the frame exchange
|
|
37
41
|
|
|
38
42
|
## Usage
|
|
@@ -50,16 +54,27 @@ MDXEditor's own stylesheet in first, so that is the only stylesheet import a hos
|
|
|
50
54
|
|
|
51
55
|
### Browser (Preview)
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
In development, serve the frame document at `SANDBOX_FRAME_PATH` only to iframe loads, point an iframe at it, and post
|
|
58
|
+
the compiled MDX to the frame. A built site can ship `buildSandboxSrcdoc()` as a static file instead; without the
|
|
59
|
+
response policy below the frame then relies on its own opaque-origin check, unless the site's headers send
|
|
60
|
+
`Content-Security-Policy: sandbox allow-scripts` for that file:
|
|
54
61
|
|
|
55
62
|
```typescript
|
|
56
|
-
import { buildSandboxSrcdoc,
|
|
63
|
+
import { buildSandboxSrcdoc, MDX_SANDBOX_FRAME_POLICY, SANDBOX_FRAME_PATH } from '@conloca/mdx/sandbox-frame';
|
|
57
64
|
|
|
58
65
|
// In the host's request handler for SANDBOX_FRAME_PATH
|
|
59
|
-
|
|
66
|
+
if (request.headers.get('sec-fetch-dest') !== 'iframe') {
|
|
67
|
+
return new Response('The MDX preview frame loads only inside an editor frame.', {
|
|
68
|
+
status: 403,
|
|
69
|
+
headers: { 'cache-control': 'no-store' },
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return new Response(buildSandboxSrcdoc(), {
|
|
60
73
|
headers: {
|
|
61
74
|
'content-type': 'text/html; charset=utf-8',
|
|
62
|
-
'content-security-policy':
|
|
75
|
+
'content-security-policy': MDX_SANDBOX_FRAME_POLICY,
|
|
76
|
+
'x-content-type-options': 'nosniff',
|
|
77
|
+
'cache-control': 'no-store',
|
|
63
78
|
},
|
|
64
79
|
});
|
|
65
80
|
|
|
@@ -68,7 +83,30 @@ new Response(buildSandboxSrcdoc(), {
|
|
|
68
83
|
frame.contentWindow?.postMessage({ __conlocaSandbox: true, kind: 'render', mode: 'mdx', payload: compiledMdx }, '*');
|
|
69
84
|
```
|
|
70
85
|
|
|
71
|
-
|
|
86
|
+
An image `src` the opaque-origin frame cannot load itself, such as an unpublished upload, can travel in the optional
|
|
87
|
+
`images` field of the render message: a map from that `src`, exactly as the compiled MDX names it, to a `data:` URL. The
|
|
88
|
+
frame shows the data URL in place of a matching `<img>` `src` and leaves every other `src` alone. Blob URLs do not work
|
|
89
|
+
here, because the frame's origin cannot read the host page's blobs.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
frame.contentWindow?.postMessage(
|
|
93
|
+
{
|
|
94
|
+
__conlocaSandbox: true,
|
|
95
|
+
kind: 'render',
|
|
96
|
+
mode: 'mdx',
|
|
97
|
+
payload: compiledMdx,
|
|
98
|
+
images: { '/assets/hero.png': 'data:image/png;base64,…' },
|
|
99
|
+
},
|
|
100
|
+
'*'
|
|
101
|
+
);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`@conloca/astro-cms` serves this route under `astro dev`; `@conloca/cloud-astro` writes the static copy to
|
|
105
|
+
`/_conloca/editor/sandbox-frame.html` in builds. A host that mounts the editor itself has to serve it.
|
|
106
|
+
|
|
107
|
+
Browsers send `Sec-Fetch-Dest` only to `https` and `localhost` addresses. Under `astro dev --host`, opened at a
|
|
108
|
+
plain-HTTP LAN or IP address such as `http://192.168.1.20:4321/__cms`, the frame route answers 403 to every preview;
|
|
109
|
+
open the editor at `localhost` instead.
|
|
72
110
|
|
|
73
111
|
### Node.js (Server-side)
|
|
74
112
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"files": {
|
|
4
|
+
"packages/mdx/src/code-block-frame.tsx": "555fde4e6e09d40a1533194e265b8c5fd2495793fa30565e07f8275d4e9152ac",
|
|
5
|
+
"packages/mdx/src/editor-core.tsx": "13fe0161b399f948945da5eafda4c0085540c8baf0675e026d0955a870eeb32d",
|
|
6
|
+
"packages/mdx/src/esm-passthrough.ts": "bec9999fc54348c78ee6a9903ac1e8b9230dc92da316d4beb22870ed9bcd9498",
|
|
7
|
+
"packages/mdx/src/fragments.ts": "52a1f0eb0249c4c994304686c1dcaa7223ba9c6bb8712766798975ccdc73161f",
|
|
8
|
+
"packages/mdx/src/index.ts": "bdd05a498c3cd2f69c4bc490c6f99fabd3286dc4389191c5894c2907745551c9",
|
|
9
|
+
"packages/mdx/src/markdown-options.ts": "8a207c1aa5489e703bc0a298e13acdb0bea897cd208a685ccb93b788be1de847",
|
|
10
|
+
"packages/mdx/src/mdx-editor.tsx": "230d30760c4f10da56722f1f83be7db0b10a5c003a511810ba15978cbc207787",
|
|
11
|
+
"packages/mdx/src/mdx/compile-request.ts": "f30f1868b62cd29e4a6b0f9546d9932f4a49f92904eff5d446c02d793a1273dd",
|
|
12
|
+
"packages/mdx/src/mdx/compile.ts": "6ad8f37764bbbeb28a2b1873026f990791a03d9431262e4c20fbfc545ada78dd",
|
|
13
|
+
"packages/mdx/src/mdx/evaluate.ts": "4b7874e8d574c10a4f243e02b75351d4c7ed0d91e11cabedb7b47dea23acfd64",
|
|
14
|
+
"packages/mdx/src/mdx/heading-outline.ts": "80680c3d67487161abc19adb2c473565c396d0d7ae32cf035f9733be62f99d78",
|
|
15
|
+
"packages/mdx/src/mdx/literal-attributes.ts": "8256d84fa7e135c4c8d802bc9259781ef4e1101d61a9605ed2773604114a5100",
|
|
16
|
+
"packages/mdx/src/mdx/restrict-expressions.ts": "6acc4426bd315e0a6bb6a5f94187b7c34710781f370e0ddbd9c8436e0c1d82cc",
|
|
17
|
+
"packages/mdx/src/node.ts": "7f087e8cd4965927a17c388088c3f17567e26af1eb8ef9616808d75ceabe8c99",
|
|
18
|
+
"packages/mdx/src/sandbox-frame.ts": "91338e3e94f78a00bcb0f3260deea22bbfb1c58c4f344eb074c9b7c4e65580b7",
|
|
19
|
+
"packages/mdx/src/types.ts": "99ff35d0a6f59308b7f7ae188aa20164ae04ce043c0e4917199ba09a87b062b8",
|
|
20
|
+
"packages/mdx/tsconfig.lib.json": "381a7f94b78a2598ce415629f8aef13a0664cf60299cffca6a783269c0b0ff88"
|
|
21
|
+
},
|
|
22
|
+
"complete": [
|
|
23
|
+
":(glob)packages/mdx/src/**/*.ts",
|
|
24
|
+
":(glob)packages/mdx/src/**/*.tsx",
|
|
25
|
+
":(exclude,glob)packages/mdx/src/**/*.test.ts",
|
|
26
|
+
":(exclude,glob)packages/mdx/src/**/*.test.tsx",
|
|
27
|
+
":(exclude,glob)packages/mdx/src/**/*.spec.ts",
|
|
28
|
+
":(exclude,glob)packages/mdx/src/**/*.spec.tsx"
|
|
29
|
+
],
|
|
30
|
+
"producer": {
|
|
31
|
+
"project": "mdx",
|
|
32
|
+
"target": "tsc-js"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/editor-core.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface BaseMDXEditorProps {
|
|
|
23
23
|
* library/picker `imageDialog` flow — both can be active simultaneously.
|
|
24
24
|
*/
|
|
25
25
|
imageUploadHandler?: (file: File) => Promise<string>;
|
|
26
|
+
/** Maps an image's `src` to the URL the editor canvas shows; the document keeps the original `src`. */
|
|
27
|
+
imagePreviewHandler?: (src: string) => Promise<string>;
|
|
26
28
|
jsxComponentDescriptors?: JsxComponentDescriptor[];
|
|
27
29
|
/**
|
|
28
30
|
* Additional @mdxeditor/editor RealmPlugins appended to the built-in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-core.d.ts","sourceRoot":"","sources":["../src/editor-core.tsx"],"names":[],"mappings":"AAAA,OAAO,EAmBL,KAAK,sBAAsB,EAO3B,KAAK,gBAAgB,EAGrB,KAAK,WAAW,EAOjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAoF,MAAM,OAAO,CAAC;AAwDzG,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IAC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|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
export const BaseMDXEditor = React.forwardRef(({ value, onChange, onSave, readOnly = false, imageDialog, disableImageSettingsButton = false, onImageShortcut, imageButtonRef, imageUploadHandler, jsxComponentDescriptors, extraPlugins, extraToolbarItems, className, placeholder, autoFocus, }, ref) => {
|
|
108
|
+
export const BaseMDXEditor = React.forwardRef(({ value, onChange, onSave, readOnly = false, imageDialog, disableImageSettingsButton = false, onImageShortcut, imageButtonRef, imageUploadHandler, imagePreviewHandler, jsxComponentDescriptors, extraPlugins, extraToolbarItems, className, placeholder, autoFocus, }, ref) => {
|
|
109
109
|
// The library reads `markdown` once, as `initialMarkdown`, and consumers
|
|
110
110
|
// swap documents by remounting (see the `key=` on MdxPageEditor's and
|
|
111
111
|
// FragmentEditor's editors). So the ESM lifted off the document belongs to
|
|
@@ -199,6 +199,7 @@ export const BaseMDXEditor = React.forwardRef(({ value, onChange, onSave, readOn
|
|
|
199
199
|
imagePlugin({
|
|
200
200
|
...(imageDialog ? { ImageDialog: imageDialog, disableImageSettingsButton } : {}),
|
|
201
201
|
...(imageUploadHandler ? { imageUploadHandler } : {}),
|
|
202
|
+
...(imagePreviewHandler ? { imagePreviewHandler } : {}),
|
|
202
203
|
}),
|
|
203
204
|
...(extraPlugins ?? []),
|
|
204
205
|
toolbarPlugin({
|
package/dist/editor-core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-core.js","sourceRoot":"","sources":["../src/editor-core.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,WAAW,EAEX,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB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EACb,KAAC,eAAe,KAAG,EACnB,KAAC,SAAS,KAAG,EACb,KAAC,UAAU,KAAG,EACb,uBAAuB,CAAC,cAAc,CAAC,EACxC,KAAC,WAAW,KAAG,EACf,KAAC,mBAAmB,KAAG,EACvB,KAAC,SAAS,KAAG,EACb,KAAC,eAAe,KAAG,EAClB,iBAAiB,EAClB,KAAC,SAAS,KAAG,EACb,KAAC,eAAe,KAAG,IAClB,CACJ;6BACF;yBACF,GACD,GACsB,CAC3B;aACF,CAAC;SACH,GACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
package/dist/sandbox-frame.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export interface SandboxRenderMessage {
|
|
|
20
20
|
payload: string;
|
|
21
21
|
/** Optional stylesheet text injected into the frame for preview fidelity. */
|
|
22
22
|
styles?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Data URLs to show instead of an image the frame cannot load itself, keyed by its stored value: an element's
|
|
25
|
+
* `src` in both modes, and an MDX component's string prop.
|
|
26
|
+
*/
|
|
27
|
+
images?: Record<string, string>;
|
|
23
28
|
}
|
|
24
29
|
export type SandboxOutboundMessage = {
|
|
25
30
|
__conlocaSandbox: true;
|
|
@@ -49,7 +54,7 @@ export type SandboxOutboundMessage = {
|
|
|
49
54
|
kind: 'error';
|
|
50
55
|
message: string;
|
|
51
56
|
};
|
|
52
|
-
export declare function createSandboxRuntime(): {
|
|
57
|
+
export declare function createSandboxRuntime(images?: Record<string, string>): {
|
|
53
58
|
Fragment: symbol;
|
|
54
59
|
jsx: (type: unknown, props: Record<string, unknown>) => Node;
|
|
55
60
|
jsxs: (type: unknown, props: Record<string, unknown>) => Node;
|
|
@@ -98,6 +103,12 @@ export declare function sandboxFrameMain(deps: {
|
|
|
98
103
|
* no CSP mitigation. Both leak only request metadata, never privileged content.
|
|
99
104
|
*/
|
|
100
105
|
export declare const SANDBOX_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: https: blob:; font-src data: https:";
|
|
106
|
+
/**
|
|
107
|
+
* The policy a server sends with the frame document. It adds what a meta
|
|
108
|
+
* policy cannot carry: `sandbox allow-scripts` (an opaque origin even when the
|
|
109
|
+
* document is not loaded by a sandboxed iframe) and `frame-ancestors`.
|
|
110
|
+
*/
|
|
111
|
+
export declare const MDX_SANDBOX_FRAME_POLICY = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: https: blob:; font-src data: https:; sandbox allow-scripts; frame-ancestors 'self'";
|
|
101
112
|
/**
|
|
102
113
|
* Assemble the sandbox frame document. The runtime functions are injected as
|
|
103
114
|
* argument expressions to `sandboxFrameMain` so no cross-function identifier
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-frame.d.ts","sourceRoot":"","sources":["../src/sandbox-frame.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,IAAI,CAAC;IACvB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"sandbox-frame.d.ts","sourceRoot":"","sources":["../src/sandbox-frame.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,IAAI,CAAC;IACvB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,MAAM,CAAC,EAAE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,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACjE,CAyFA;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CAAE,CAAC,CAKjE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,oBAAoB,EAAE,OAAO,oBAAoB,CAAC;IAClD,cAAc,EAAE,OAAO,cAAc,CAAC;CACvC,GAAG,IAAI,CAsHP;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,+IACgH,CAAC;AAE/I;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,8LAAwE,CAAC;AAU9G;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAc3C;AAED,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,8BAA8B,CAAC"}
|
package/dist/sandbox-frame.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Shared by the cms-spa ContentSandbox and the server route that serves this
|
|
5
5
|
* frame's HTML at `SANDBOX_FRAME_PATH`.
|
|
6
6
|
*/
|
|
7
|
-
export function createSandboxRuntime() {
|
|
7
|
+
export function createSandboxRuntime(images) {
|
|
8
8
|
// Everything below stays inside this function: the frame receives it as source text.
|
|
9
9
|
const Fragment = Symbol('sandbox.fragment');
|
|
10
10
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
@@ -13,6 +13,7 @@ export function createSandboxRuntime() {
|
|
|
13
13
|
// it again as SVG from what each HTML element was made of, kept here, which
|
|
14
14
|
// is the namespace React would have given it.
|
|
15
15
|
const madeOf = new WeakMap();
|
|
16
|
+
// oxlint-disable-next-line unicorn/consistent-function-scoping -- the frame receives this function as source text, so its helpers stay inside it.
|
|
16
17
|
const toNodes = (value) => {
|
|
17
18
|
if (value == null || value === true || value === false)
|
|
18
19
|
return [];
|
|
@@ -33,6 +34,8 @@ export function createSandboxRuntime() {
|
|
|
33
34
|
if (key === 'children' || key === 'key')
|
|
34
35
|
continue;
|
|
35
36
|
const value = p[key];
|
|
37
|
+
// Inherited keys are never strings, so only a src the host sent is swapped.
|
|
38
|
+
const sent = type === 'img' && key === 'src' && typeof value === 'string' ? images?.[value] : undefined;
|
|
36
39
|
if (/^on/i.test(key))
|
|
37
40
|
continue; // never wire an event handler
|
|
38
41
|
if (key === 'className') {
|
|
@@ -47,6 +50,9 @@ export function createSandboxRuntime() {
|
|
|
47
50
|
else if (value === true) {
|
|
48
51
|
el.setAttribute(key, '');
|
|
49
52
|
}
|
|
53
|
+
else if (typeof sent === 'string') {
|
|
54
|
+
el.setAttribute('src', sent);
|
|
55
|
+
}
|
|
50
56
|
else if (value != null && value !== false) {
|
|
51
57
|
el.setAttribute(key, String(value));
|
|
52
58
|
}
|
|
@@ -59,6 +65,29 @@ export function createSandboxRuntime() {
|
|
|
59
65
|
}
|
|
60
66
|
return el;
|
|
61
67
|
};
|
|
68
|
+
// A component takes images as props of any name, so every string prop at any depth the host sent bytes for is
|
|
69
|
+
// swapped; `children` is content, not a link, and stays as written.
|
|
70
|
+
// oxlint-disable-next-line unicorn/consistent-function-scoping, anti-slop/no-unknown-returns, anti-slop/no-known-value-widening -- the frame receives this function as source text, so its helpers stay inside it; props are whatever the component takes, so every value passes through as it came.
|
|
71
|
+
const withSentImages = (value, sent) => {
|
|
72
|
+
if (typeof value === 'string') {
|
|
73
|
+
// Inherited keys are never strings, so only a value the host sent is swapped.
|
|
74
|
+
const data = sent[value];
|
|
75
|
+
return typeof data === 'string' ? data : value;
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(value))
|
|
78
|
+
return value.map((item) => withSentImages(item, sent));
|
|
79
|
+
if (value === null || typeof value !== 'object')
|
|
80
|
+
return value;
|
|
81
|
+
const prototype = Object.getPrototypeOf(value);
|
|
82
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
83
|
+
return value;
|
|
84
|
+
// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- a copy of the component's own props, values as they came.
|
|
85
|
+
const out = {};
|
|
86
|
+
for (const [key, item] of Object.entries(value))
|
|
87
|
+
out[key] = key === 'children' ? item : withSentImages(item, sent);
|
|
88
|
+
// oxlint-disable-next-line anti-slop/no-known-value-widening -- the copy is as open as the props it came from.
|
|
89
|
+
return out;
|
|
90
|
+
};
|
|
62
91
|
const jsx = (type, props) => {
|
|
63
92
|
const p = props || {};
|
|
64
93
|
if (type === Fragment) {
|
|
@@ -67,8 +96,14 @@ export function createSandboxRuntime() {
|
|
|
67
96
|
frag.appendChild(child);
|
|
68
97
|
return frag;
|
|
69
98
|
}
|
|
70
|
-
if (typeof type === 'function')
|
|
71
|
-
|
|
99
|
+
if (typeof type === 'function') {
|
|
100
|
+
// SAFETY: `p` is a plain props object, and withSentImages copies a plain object into a plain object.
|
|
101
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion, anti-slop/no-unsafe-dictionary-type -- same reason as the SAFETY note.
|
|
102
|
+
const componentProps = images ? withSentImages(p, images) : p;
|
|
103
|
+
// SAFETY: compiled MDX passes only components, which take one props object and return this runtime's DOM nodes.
|
|
104
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion, anti-slop/no-unsafe-dictionary-type -- same reason as the SAFETY note.
|
|
105
|
+
return type(componentProps);
|
|
106
|
+
}
|
|
72
107
|
if (typeof type === 'string')
|
|
73
108
|
return element(type, p, false);
|
|
74
109
|
const missing = document.createElement('span');
|
|
@@ -94,6 +129,9 @@ export function runCompiledMdx(code, runtime) {
|
|
|
94
129
|
* minifier could rename.
|
|
95
130
|
*/
|
|
96
131
|
export function sandboxFrameMain(deps) {
|
|
132
|
+
// MDX runs only where it has no origin of its own: an opaque origin inside a parent frame.
|
|
133
|
+
if (self.origin !== 'null' || window.parent === window)
|
|
134
|
+
return;
|
|
97
135
|
const root = document.getElementById('__sandbox_root');
|
|
98
136
|
if (!root)
|
|
99
137
|
return;
|
|
@@ -139,8 +177,8 @@ export function sandboxFrameMain(deps) {
|
|
|
139
177
|
}
|
|
140
178
|
style.textContent = css;
|
|
141
179
|
};
|
|
142
|
-
const renderMdx = (code) => {
|
|
143
|
-
const runtime = deps.createSandboxRuntime();
|
|
180
|
+
const renderMdx = (code, images) => {
|
|
181
|
+
const runtime = deps.createSandboxRuntime(images);
|
|
144
182
|
deps
|
|
145
183
|
.runCompiledMdx(code, runtime)
|
|
146
184
|
.then((module) => {
|
|
@@ -162,10 +200,21 @@ export function sandboxFrameMain(deps) {
|
|
|
162
200
|
});
|
|
163
201
|
});
|
|
164
202
|
};
|
|
165
|
-
const renderHtml = (html) => {
|
|
203
|
+
const renderHtml = (html, images) => {
|
|
166
204
|
// Already allowlist-sanitized by the host; the sandbox contains anything
|
|
167
205
|
// that slips through (opaque origin, no privileged globals, strict CSP).
|
|
168
|
-
|
|
206
|
+
// Parsed inert first, so nothing loads before a sent src replaces the stored one.
|
|
207
|
+
const parsed = new DOMParser().parseFromString(html, 'text/html');
|
|
208
|
+
if (images) {
|
|
209
|
+
parsed.querySelectorAll('[src]').forEach((el) => {
|
|
210
|
+
// Inherited keys are never strings, so only a src the host sent is swapped.
|
|
211
|
+
const sent = images[el.getAttribute('src') ?? ''];
|
|
212
|
+
if (typeof sent === 'string')
|
|
213
|
+
el.setAttribute('src', sent);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
// A leading <style> or <link> lands in the parsed head; keep it with the body, as innerHTML did.
|
|
217
|
+
root.replaceChildren(...Array.from(parsed.head.childNodes), ...Array.from(parsed.body.childNodes));
|
|
169
218
|
post({ __conlocaSandbox: true, kind: 'rendered' });
|
|
170
219
|
postHeight();
|
|
171
220
|
};
|
|
@@ -179,9 +228,9 @@ export function sandboxFrameMain(deps) {
|
|
|
179
228
|
applyStyles(data.styles);
|
|
180
229
|
try {
|
|
181
230
|
if (data.mode === 'mdx')
|
|
182
|
-
renderMdx(data.payload);
|
|
231
|
+
renderMdx(data.payload, data.images);
|
|
183
232
|
else
|
|
184
|
-
renderHtml(data.payload);
|
|
233
|
+
renderHtml(data.payload, data.images);
|
|
185
234
|
}
|
|
186
235
|
catch (error) {
|
|
187
236
|
post({ __conlocaSandbox: true, kind: 'error', message: error instanceof Error ? error.message : String(error) });
|
|
@@ -216,6 +265,12 @@ export function sandboxFrameMain(deps) {
|
|
|
216
265
|
* no CSP mitigation. Both leak only request metadata, never privileged content.
|
|
217
266
|
*/
|
|
218
267
|
export const SANDBOX_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: https: blob:; font-src data: https:";
|
|
268
|
+
/**
|
|
269
|
+
* The policy a server sends with the frame document. It adds what a meta
|
|
270
|
+
* policy cannot carry: `sandbox allow-scripts` (an opaque origin even when the
|
|
271
|
+
* document is not loaded by a sandboxed iframe) and `frame-ancestors`.
|
|
272
|
+
*/
|
|
273
|
+
export const MDX_SANDBOX_FRAME_POLICY = `${SANDBOX_FRAME_CSP}; sandbox allow-scripts; frame-ancestors 'self'`;
|
|
219
274
|
/**
|
|
220
275
|
* esbuild-style bundlers inject `/* @__PURE__ *\/ __name(fn, "id")` around
|
|
221
276
|
* function expressions when keepNames is on. That helper exists in the bundle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-frame.js","sourceRoot":"","sources":["../src/sandbox-frame.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"sandbox-frame.js","sourceRoot":"","sources":["../src/sandbox-frame.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkCH,MAAM,UAAU,oBAAoB,CAAC,MAA+B;IAMlE,qFAAqF;IACrF,MAAM,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,sGAAsG;QACtG,mEAAmE;QACnE,qEAAqE;QACrE,sEAAsE;QACtE,wDAAwD;QACxD,oEAAoE;QACpE,WAAW,SAAS,WAAW;QAC/B,gBAAgB;KACjB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conloca/mdx",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"main": "./dist/index.js",
|
|
13
13
|
"module": "./dist/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@conloca/content-api": "0.2.
|
|
15
|
+
"@conloca/content-api": "0.2.4",
|
|
16
16
|
"@mdx-js/mdx": "^3.1.1",
|
|
17
17
|
"@mdx-js/react": "^3.1.1",
|
|
18
18
|
"@mdxeditor/editor": "^4.2.3",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
},
|
|
78
78
|
"nx": {
|
|
79
79
|
"targets": {
|
|
80
|
-
"clean": {},
|
|
81
80
|
"test": {
|
|
82
81
|
"dependsOn": [
|
|
83
82
|
"typecheck-tests",
|
package/src/editor-core.tsx
CHANGED
|
@@ -115,6 +115,8 @@ export interface BaseMDXEditorProps {
|
|
|
115
115
|
* library/picker `imageDialog` flow — both can be active simultaneously.
|
|
116
116
|
*/
|
|
117
117
|
imageUploadHandler?: (file: File) => Promise<string>;
|
|
118
|
+
/** Maps an image's `src` to the URL the editor canvas shows; the document keeps the original `src`. */
|
|
119
|
+
imagePreviewHandler?: (src: string) => Promise<string>;
|
|
118
120
|
jsxComponentDescriptors?: JsxComponentDescriptor[];
|
|
119
121
|
/**
|
|
120
122
|
* Additional @mdxeditor/editor RealmPlugins appended to the built-in
|
|
@@ -214,6 +216,7 @@ export const BaseMDXEditor = React.forwardRef<MDXEditorMethods, BaseMDXEditorPro
|
|
|
214
216
|
onImageShortcut,
|
|
215
217
|
imageButtonRef,
|
|
216
218
|
imageUploadHandler,
|
|
219
|
+
imagePreviewHandler,
|
|
217
220
|
jsxComponentDescriptors,
|
|
218
221
|
extraPlugins,
|
|
219
222
|
extraToolbarItems,
|
|
@@ -346,6 +349,7 @@ export const BaseMDXEditor = React.forwardRef<MDXEditorMethods, BaseMDXEditorPro
|
|
|
346
349
|
imagePlugin({
|
|
347
350
|
...(imageDialog ? { ImageDialog: imageDialog, disableImageSettingsButton } : {}),
|
|
348
351
|
...(imageUploadHandler ? { imageUploadHandler } : {}),
|
|
352
|
+
...(imagePreviewHandler ? { imagePreviewHandler } : {}),
|
|
349
353
|
}),
|
|
350
354
|
...(extraPlugins ?? []),
|
|
351
355
|
toolbarPlugin({
|
package/src/sandbox-frame.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface SandboxRenderMessage {
|
|
|
22
22
|
payload: string;
|
|
23
23
|
/** Optional stylesheet text injected into the frame for preview fidelity. */
|
|
24
24
|
styles?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Data URLs to show instead of an image the frame cannot load itself, keyed by its stored value: an element's
|
|
27
|
+
* `src` in both modes, and an MDX component's string prop.
|
|
28
|
+
*/
|
|
29
|
+
images?: Record<string, string>;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export type SandboxOutboundMessage =
|
|
@@ -32,7 +37,7 @@ export type SandboxOutboundMessage =
|
|
|
32
37
|
| { __conlocaSandbox: true; k: string; kind: 'rendered' }
|
|
33
38
|
| { __conlocaSandbox: true; k: string; kind: 'error'; message: string };
|
|
34
39
|
|
|
35
|
-
export function createSandboxRuntime(): {
|
|
40
|
+
export function createSandboxRuntime(images?: Record<string, string>): {
|
|
36
41
|
Fragment: symbol;
|
|
37
42
|
jsx: (type: unknown, props: Record<string, unknown>) => Node;
|
|
38
43
|
jsxs: (type: unknown, props: Record<string, unknown>) => Node;
|
|
@@ -46,6 +51,7 @@ export function createSandboxRuntime(): {
|
|
|
46
51
|
// it again as SVG from what each HTML element was made of, kept here, which
|
|
47
52
|
// is the namespace React would have given it.
|
|
48
53
|
const madeOf = new WeakMap<Node, { type: string; props: Record<string, unknown> }>();
|
|
54
|
+
// oxlint-disable-next-line unicorn/consistent-function-scoping -- the frame receives this function as source text, so its helpers stay inside it.
|
|
49
55
|
const toNodes = (value: unknown): Node[] => {
|
|
50
56
|
if (value == null || value === true || value === false) return [];
|
|
51
57
|
if (Array.isArray(value)) return value.flatMap(toNodes);
|
|
@@ -60,6 +66,8 @@ export function createSandboxRuntime(): {
|
|
|
60
66
|
for (const key in p) {
|
|
61
67
|
if (key === 'children' || key === 'key') continue;
|
|
62
68
|
const value = p[key];
|
|
69
|
+
// Inherited keys are never strings, so only a src the host sent is swapped.
|
|
70
|
+
const sent = type === 'img' && key === 'src' && typeof value === 'string' ? images?.[value] : undefined;
|
|
63
71
|
if (/^on/i.test(key)) continue; // never wire an event handler
|
|
64
72
|
if (key === 'className') {
|
|
65
73
|
el.setAttribute('class', String(value));
|
|
@@ -69,6 +77,8 @@ export function createSandboxRuntime(): {
|
|
|
69
77
|
Object.assign((el as HTMLElement).style, value as Record<string, string>);
|
|
70
78
|
} else if (value === true) {
|
|
71
79
|
el.setAttribute(key, '');
|
|
80
|
+
} else if (typeof sent === 'string') {
|
|
81
|
+
el.setAttribute('src', sent);
|
|
72
82
|
} else if (value != null && value !== false) {
|
|
73
83
|
el.setAttribute(key, String(value));
|
|
74
84
|
}
|
|
@@ -81,6 +91,25 @@ export function createSandboxRuntime(): {
|
|
|
81
91
|
}
|
|
82
92
|
return el;
|
|
83
93
|
};
|
|
94
|
+
// A component takes images as props of any name, so every string prop at any depth the host sent bytes for is
|
|
95
|
+
// swapped; `children` is content, not a link, and stays as written.
|
|
96
|
+
// oxlint-disable-next-line unicorn/consistent-function-scoping, anti-slop/no-unknown-returns, anti-slop/no-known-value-widening -- the frame receives this function as source text, so its helpers stay inside it; props are whatever the component takes, so every value passes through as it came.
|
|
97
|
+
const withSentImages = (value: unknown, sent: Record<string, string>): unknown => {
|
|
98
|
+
if (typeof value === 'string') {
|
|
99
|
+
// Inherited keys are never strings, so only a value the host sent is swapped.
|
|
100
|
+
const data = sent[value];
|
|
101
|
+
return typeof data === 'string' ? data : value;
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(value)) return value.map((item) => withSentImages(item, sent));
|
|
104
|
+
if (value === null || typeof value !== 'object') return value;
|
|
105
|
+
const prototype: unknown = Object.getPrototypeOf(value);
|
|
106
|
+
if (prototype !== Object.prototype && prototype !== null) return value;
|
|
107
|
+
// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- a copy of the component's own props, values as they came.
|
|
108
|
+
const out: Record<string, unknown> = {};
|
|
109
|
+
for (const [key, item] of Object.entries(value)) out[key] = key === 'children' ? item : withSentImages(item, sent);
|
|
110
|
+
// oxlint-disable-next-line anti-slop/no-known-value-widening -- the copy is as open as the props it came from.
|
|
111
|
+
return out;
|
|
112
|
+
};
|
|
84
113
|
const jsx = (type: unknown, props: Record<string, unknown>): Node => {
|
|
85
114
|
const p = props || {};
|
|
86
115
|
if (type === Fragment) {
|
|
@@ -88,7 +117,14 @@ export function createSandboxRuntime(): {
|
|
|
88
117
|
for (const child of toNodes(p.children)) frag.appendChild(child);
|
|
89
118
|
return frag;
|
|
90
119
|
}
|
|
91
|
-
if (typeof type === 'function')
|
|
120
|
+
if (typeof type === 'function') {
|
|
121
|
+
// SAFETY: `p` is a plain props object, and withSentImages copies a plain object into a plain object.
|
|
122
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion, anti-slop/no-unsafe-dictionary-type -- same reason as the SAFETY note.
|
|
123
|
+
const componentProps = images ? (withSentImages(p, images) as Record<string, unknown>) : p;
|
|
124
|
+
// SAFETY: compiled MDX passes only components, which take one props object and return this runtime's DOM nodes.
|
|
125
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion, anti-slop/no-unsafe-dictionary-type -- same reason as the SAFETY note.
|
|
126
|
+
return (type as (props: Record<string, unknown>) => Node)(componentProps);
|
|
127
|
+
}
|
|
92
128
|
if (typeof type === 'string') return element(type, p, false);
|
|
93
129
|
const missing = document.createElement('span');
|
|
94
130
|
missing.setAttribute('data-sandbox-unknown', '');
|
|
@@ -123,6 +159,8 @@ export function sandboxFrameMain(deps: {
|
|
|
123
159
|
createSandboxRuntime: typeof createSandboxRuntime;
|
|
124
160
|
runCompiledMdx: typeof runCompiledMdx;
|
|
125
161
|
}): void {
|
|
162
|
+
// MDX runs only where it has no origin of its own: an opaque origin inside a parent frame.
|
|
163
|
+
if (self.origin !== 'null' || window.parent === window) return;
|
|
126
164
|
const root = document.getElementById('__sandbox_root');
|
|
127
165
|
if (!root) return;
|
|
128
166
|
// Per-instance key from ?k= so the host can accept messages without relying
|
|
@@ -179,8 +217,8 @@ export function sandboxFrameMain(deps: {
|
|
|
179
217
|
}
|
|
180
218
|
style.textContent = css;
|
|
181
219
|
};
|
|
182
|
-
const renderMdx = (code: string): void => {
|
|
183
|
-
const runtime = deps.createSandboxRuntime();
|
|
220
|
+
const renderMdx = (code: string, images: Record<string, string> | undefined): void => {
|
|
221
|
+
const runtime = deps.createSandboxRuntime(images);
|
|
184
222
|
deps
|
|
185
223
|
.runCompiledMdx(code, runtime as unknown as Record<string, unknown>)
|
|
186
224
|
.then((module) => {
|
|
@@ -201,10 +239,20 @@ export function sandboxFrameMain(deps: {
|
|
|
201
239
|
});
|
|
202
240
|
});
|
|
203
241
|
};
|
|
204
|
-
const renderHtml = (html: string): void => {
|
|
242
|
+
const renderHtml = (html: string, images: Record<string, string> | undefined): void => {
|
|
205
243
|
// Already allowlist-sanitized by the host; the sandbox contains anything
|
|
206
244
|
// that slips through (opaque origin, no privileged globals, strict CSP).
|
|
207
|
-
|
|
245
|
+
// Parsed inert first, so nothing loads before a sent src replaces the stored one.
|
|
246
|
+
const parsed = new DOMParser().parseFromString(html, 'text/html');
|
|
247
|
+
if (images) {
|
|
248
|
+
parsed.querySelectorAll('[src]').forEach((el) => {
|
|
249
|
+
// Inherited keys are never strings, so only a src the host sent is swapped.
|
|
250
|
+
const sent = images[el.getAttribute('src') ?? ''];
|
|
251
|
+
if (typeof sent === 'string') el.setAttribute('src', sent);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
// A leading <style> or <link> lands in the parsed head; keep it with the body, as innerHTML did.
|
|
255
|
+
root.replaceChildren(...Array.from(parsed.head.childNodes), ...Array.from(parsed.body.childNodes));
|
|
208
256
|
post({ __conlocaSandbox: true, kind: 'rendered' });
|
|
209
257
|
postHeight();
|
|
210
258
|
};
|
|
@@ -216,8 +264,8 @@ export function sandboxFrameMain(deps: {
|
|
|
216
264
|
if (data?.__conlocaSandbox !== true || data.kind !== 'render') return;
|
|
217
265
|
if (typeof data.styles === 'string') applyStyles(data.styles);
|
|
218
266
|
try {
|
|
219
|
-
if (data.mode === 'mdx') renderMdx(data.payload);
|
|
220
|
-
else renderHtml(data.payload);
|
|
267
|
+
if (data.mode === 'mdx') renderMdx(data.payload, data.images);
|
|
268
|
+
else renderHtml(data.payload, data.images);
|
|
221
269
|
} catch (error: unknown) {
|
|
222
270
|
post({ __conlocaSandbox: true, kind: 'error', message: error instanceof Error ? error.message : String(error) });
|
|
223
271
|
}
|
|
@@ -256,6 +304,13 @@ export function sandboxFrameMain(deps: {
|
|
|
256
304
|
export const SANDBOX_FRAME_CSP =
|
|
257
305
|
"default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: https: blob:; font-src data: https:";
|
|
258
306
|
|
|
307
|
+
/**
|
|
308
|
+
* The policy a server sends with the frame document. It adds what a meta
|
|
309
|
+
* policy cannot carry: `sandbox allow-scripts` (an opaque origin even when the
|
|
310
|
+
* document is not loaded by a sandboxed iframe) and `frame-ancestors`.
|
|
311
|
+
*/
|
|
312
|
+
export const MDX_SANDBOX_FRAME_POLICY = `${SANDBOX_FRAME_CSP}; sandbox allow-scripts; frame-ancestors 'self'`;
|
|
313
|
+
|
|
259
314
|
/**
|
|
260
315
|
* esbuild-style bundlers inject `/* @__PURE__ *\/ __name(fn, "id")` around
|
|
261
316
|
* function expressions when keepNames is on. That helper exists in the bundle
|