@echozedlabs/react 0.1.0 → 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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.tsx"],"names":[],"mappings":";AAEA,4EAA4E;AAC5E,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAuC;IAC7E,OAAO,CACL,cAAK,SAAS,EAAC,gBAAgB,eAAY,QAAQ,EAAE,OAAO,EAAC,aAAa,EAAC,SAAS,EAAC,OAAO,iBAAa,MAAM,YAC7G,eAAM,IAAI,EAAC,cAAc,EAAC,CAAC,EAAE,IAAI,GAAI,GACjC,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,skBAAskB,CAAC;AACrmB,MAAM,CAAC,MAAM,iBAAiB,GAAG,ouBAAouB,CAAC"}
@@ -1,7 +1,23 @@
1
1
  /**
2
- * Sanitize preview HTML (concatenated registry-renderer output, which may
3
- * include host/diagram HTML) before it is injected via
4
- * dangerouslySetInnerHTML. Fails closed in a non-DOM environment.
2
+ * Sanitize renderer output HTML before it is injected (preview surface and the
3
+ * hybrid rendered-block widget). Fails closed in a non-DOM environment.
4
+ *
5
+ * Trust policy: this is a **trusted renderer-output** sanitizer, not a general
6
+ * untrusted-HTML policy. It runs DOMPurify's default config (which allows HTML +
7
+ * SVG + MathML and strips `<script>`, `on*` event handlers, and `javascript:`
8
+ * URLs) and additionally allows two tags that diagram renderers (Mermaid) require:
9
+ *
10
+ * - `<foreignObject>` — Mermaid renders flowchart node labels as HTML inside it;
11
+ * `USE_PROFILES` would drop that HTML and the diagram text would vanish.
12
+ * - `<style>` — Mermaid emits a `<style>` block scoped inside the diagram `<svg>`.
13
+ * DOMPurify's body-context parsing drops a *stray top-level* `<style>` blob, so
14
+ * only renderer SVG-scoped CSS survives — the CSS-injection surface is limited to
15
+ * trusted diagram output, not arbitrary document content.
16
+ *
17
+ * Renderers are nonetheless trusted to carry SVG-scoped CSS. Hosts that render
18
+ * genuinely untrusted Markdown source should keep renderer output trusted (or add
19
+ * a stricter profile). The regression test in `react/test/sanitize.test.ts` pins
20
+ * both behaviors (top-level dropped, SVG-scoped kept).
5
21
  */
6
22
  export declare function sanitizePreviewHtml(html: string): string;
7
23
  //# sourceMappingURL=sanitizeHtml.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeHtml.d.ts","sourceRoot":"","sources":["../src/sanitizeHtml.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAaxD"}
1
+ {"version":3,"file":"sanitizeHtml.d.ts","sourceRoot":"","sources":["../src/sanitizeHtml.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxD"}
@@ -1,19 +1,29 @@
1
1
  import DOMPurify from 'dompurify';
2
2
  /**
3
- * Sanitize preview HTML (concatenated registry-renderer output, which may
4
- * include host/diagram HTML) before it is injected via
5
- * dangerouslySetInnerHTML. Fails closed in a non-DOM environment.
3
+ * Sanitize renderer output HTML before it is injected (preview surface and the
4
+ * hybrid rendered-block widget). Fails closed in a non-DOM environment.
5
+ *
6
+ * Trust policy: this is a **trusted renderer-output** sanitizer, not a general
7
+ * untrusted-HTML policy. It runs DOMPurify's default config (which allows HTML +
8
+ * SVG + MathML and strips `<script>`, `on*` event handlers, and `javascript:`
9
+ * URLs) and additionally allows two tags that diagram renderers (Mermaid) require:
10
+ *
11
+ * - `<foreignObject>` — Mermaid renders flowchart node labels as HTML inside it;
12
+ * `USE_PROFILES` would drop that HTML and the diagram text would vanish.
13
+ * - `<style>` — Mermaid emits a `<style>` block scoped inside the diagram `<svg>`.
14
+ * DOMPurify's body-context parsing drops a *stray top-level* `<style>` blob, so
15
+ * only renderer SVG-scoped CSS survives — the CSS-injection surface is limited to
16
+ * trusted diagram output, not arbitrary document content.
17
+ *
18
+ * Renderers are nonetheless trusted to carry SVG-scoped CSS. Hosts that render
19
+ * genuinely untrusted Markdown source should keep renderer output trusted (or add
20
+ * a stricter profile). The regression test in `react/test/sanitize.test.ts` pins
21
+ * both behaviors (top-level dropped, SVG-scoped kept).
6
22
  */
7
23
  export function sanitizePreviewHtml(html) {
8
24
  if (typeof DOMPurify.sanitize !== 'function') {
9
25
  return '';
10
26
  }
11
- // Use DOMPurify's default config (which already allows HTML + SVG + MathML and
12
- // strips scripts/event handlers) rather than USE_PROFILES. USE_PROFILES
13
- // restricts namespaces and DROPS the HTML inside SVG <foreignObject>, which is
14
- // how Mermaid renders flowchart node labels — that made diagram text vanish in
15
- // the preview. The default config keeps foreignObject's HTML labels while still
16
- // removing <script>/on*-handlers/javascript: URLs.
17
27
  return DOMPurify.sanitize(html, {
18
28
  ADD_TAGS: ['foreignObject', 'style'],
19
29
  });
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeHtml.js","sourceRoot":"","sources":["../src/sanitizeHtml.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,OAAQ,SAAoC,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QACzE,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,+EAA+E;IAC/E,wEAAwE;IACxE,+EAA+E;IAC/E,+EAA+E;IAC/E,gFAAgF;IAChF,mDAAmD;IACnD,OAAO,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE;QAC9B,QAAQ,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC;KACrC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"sanitizeHtml.js","sourceRoot":"","sources":["../src/sanitizeHtml.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,OAAQ,SAAoC,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QACzE,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE;QAC9B,QAAQ,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC;KACrC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echozedlabs/react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "React markdown editor with Markdown, Hybrid, Preview, and Rich Text (WYSIWYG) modes — the echozed markdown editor.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,10 +45,10 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "dompurify": "^3.4.3",
48
- "@echozedlabs/core": "0.1.0",
49
- "@echozedlabs/codemirror": "0.1.0",
50
- "@echozedlabs/renderers": "0.1.0",
51
- "@echozedlabs/wysiwyg-lexical": "0.1.0"
48
+ "@echozedlabs/codemirror": "0.2.0",
49
+ "@echozedlabs/core": "0.2.0",
50
+ "@echozedlabs/renderers": "0.2.0",
51
+ "@echozedlabs/wysiwyg-lexical": "0.2.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": ">=18.2.0",