@mdzip/editor 1.3.1 → 1.3.11

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 (52) hide show
  1. package/README.md +200 -4
  2. package/dist/archive-utils.d.ts.map +1 -1
  3. package/dist/archive-utils.js +1 -34
  4. package/dist/archive-utils.js.map +1 -1
  5. package/dist/asset-cache.d.ts +92 -0
  6. package/dist/asset-cache.d.ts.map +1 -0
  7. package/dist/asset-cache.js +392 -0
  8. package/dist/asset-cache.js.map +1 -0
  9. package/dist/diff-view-css.d.ts +2 -0
  10. package/dist/diff-view-css.d.ts.map +1 -0
  11. package/dist/diff-view-css.js +49 -0
  12. package/dist/diff-view-css.js.map +1 -0
  13. package/dist/diff-view.d.ts +112 -0
  14. package/dist/diff-view.d.ts.map +1 -0
  15. package/dist/diff-view.js +573 -0
  16. package/dist/diff-view.js.map +1 -0
  17. package/dist/diff.d.ts +2 -1
  18. package/dist/diff.d.ts.map +1 -1
  19. package/dist/diff.js +3 -1
  20. package/dist/diff.js.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/library-info.d.ts +37 -0
  26. package/dist/library-info.d.ts.map +1 -0
  27. package/dist/library-info.js +46 -0
  28. package/dist/library-info.js.map +1 -0
  29. package/dist/mermaid.d.ts +46 -0
  30. package/dist/mermaid.d.ts.map +1 -0
  31. package/dist/mermaid.js +107 -0
  32. package/dist/mermaid.js.map +1 -0
  33. package/dist/preview.d.ts +10 -0
  34. package/dist/preview.d.ts.map +1 -0
  35. package/dist/preview.js +9 -0
  36. package/dist/preview.js.map +1 -0
  37. package/dist/rendering.d.ts +175 -2
  38. package/dist/rendering.d.ts.map +1 -1
  39. package/dist/rendering.js +132 -14
  40. package/dist/rendering.js.map +1 -1
  41. package/dist/view-css.d.ts.map +1 -1
  42. package/dist/view-css.js +133 -1
  43. package/dist/view-css.js.map +1 -1
  44. package/dist/view.d.ts +148 -1
  45. package/dist/view.d.ts.map +1 -1
  46. package/dist/view.js +805 -22
  47. package/dist/view.js.map +1 -1
  48. package/dist/workspace.d.ts +15 -0
  49. package/dist/workspace.d.ts.map +1 -1
  50. package/dist/workspace.js +42 -4
  51. package/dist/workspace.js.map +1 -1
  52. package/package.json +26 -4
package/dist/diff.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAoB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ1D,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAiB;IAEjB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC5C,CAAC;AAiBD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAiB;IAEjB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC;IAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAE7C,MAAM,OAAO,GAA4B,EAAE,CAAC;IAE5C,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;Q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,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,MAAM,EAAE,SAAS;gBACjB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,MAAM,EAAE,WAAW;gBACnB,KAAK,EAAE,UAAU;aAClB,CAAC,CAAC;YACH,YAAY,EAAE,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,YAAY;YACZ,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,MAAM,EAAE,WAAW;gBACnB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,MAAM,EAAE,WAAW;gBACnB,KAAK,EAAE,UAAU;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,kCAAkC;IAClC,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,MAAM,EAAE,SAAS;gBACjB,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,MAAM,EAAE,WAAW;aACpB,CAAC,CAAC;YACH,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,eAAe;IACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAErD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AAC7D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export type { MdzWorkspace, MdzWorkspaceAsset } from '@mdzip/core-js';
2
2
  export * from './archive-utils.js';
3
+ export * from './asset-cache.js';
3
4
  export * from './browser.js';
4
5
  export * from './diff.js';
5
6
  export * from './metadata.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './archive-utils.js';
2
+ export * from './asset-cache.js';
2
3
  export * from './browser.js';
3
4
  export * from './diff.js';
4
5
  export * from './metadata.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,37 @@
1
+ export declare const MDZIP_RUNTIME_LIBRARIES: readonly [{
2
+ readonly name: "@mdzip/editor";
3
+ readonly version: "1.3.11";
4
+ readonly repositoryUrl: "https://github.com/mdzip-project/mdzip-editor";
5
+ readonly description: "MDZip workspace engine and browser UI.";
6
+ }, {
7
+ readonly name: "@mdzip/core-js";
8
+ readonly version: "1.3.1";
9
+ readonly repositoryUrl: "https://github.com/mdzip-project/mdzip-core-js";
10
+ readonly description: "MDZip archive reading, writing, and validation.";
11
+ }, {
12
+ readonly name: "CodeMirror";
13
+ readonly version: "6.43.0";
14
+ readonly repositoryUrl: "https://github.com/codemirror/dev";
15
+ readonly description: "Extensible code editor and diff UI.";
16
+ }, {
17
+ readonly name: "Marked";
18
+ readonly version: "15.0.12";
19
+ readonly repositoryUrl: "https://github.com/markedjs/marked";
20
+ readonly description: "Markdown parser and renderer.";
21
+ }, {
22
+ readonly name: "DOMPurify";
23
+ readonly version: "3.4.8";
24
+ readonly repositoryUrl: "https://github.com/cure53/DOMPurify";
25
+ readonly description: "HTML sanitization.";
26
+ }, {
27
+ readonly name: "highlight.js";
28
+ readonly version: "11.11.1";
29
+ readonly repositoryUrl: "https://github.com/highlightjs/highlight.js";
30
+ readonly description: "Code-block syntax highlighting.";
31
+ }, {
32
+ readonly name: "Lucide";
33
+ readonly version: "1.17.0";
34
+ readonly repositoryUrl: "https://github.com/lucide-icons/lucide";
35
+ readonly description: "Interface icons.";
36
+ }];
37
+ //# sourceMappingURL=library-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library-info.d.ts","sourceRoot":"","sources":["../src/library-info.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2C1B,CAAC"}
@@ -0,0 +1,46 @@
1
+ // Generated from package metadata. Do not edit by hand.
2
+ export const MDZIP_RUNTIME_LIBRARIES = [
3
+ {
4
+ "name": "@mdzip/editor",
5
+ "version": "1.3.11",
6
+ "repositoryUrl": "https://github.com/mdzip-project/mdzip-editor",
7
+ "description": "MDZip workspace engine and browser UI."
8
+ },
9
+ {
10
+ "name": "@mdzip/core-js",
11
+ "version": "1.3.1",
12
+ "repositoryUrl": "https://github.com/mdzip-project/mdzip-core-js",
13
+ "description": "MDZip archive reading, writing, and validation."
14
+ },
15
+ {
16
+ "name": "CodeMirror",
17
+ "version": "6.43.0",
18
+ "repositoryUrl": "https://github.com/codemirror/dev",
19
+ "description": "Extensible code editor and diff UI."
20
+ },
21
+ {
22
+ "name": "Marked",
23
+ "version": "15.0.12",
24
+ "repositoryUrl": "https://github.com/markedjs/marked",
25
+ "description": "Markdown parser and renderer."
26
+ },
27
+ {
28
+ "name": "DOMPurify",
29
+ "version": "3.4.8",
30
+ "repositoryUrl": "https://github.com/cure53/DOMPurify",
31
+ "description": "HTML sanitization."
32
+ },
33
+ {
34
+ "name": "highlight.js",
35
+ "version": "11.11.1",
36
+ "repositoryUrl": "https://github.com/highlightjs/highlight.js",
37
+ "description": "Code-block syntax highlighting."
38
+ },
39
+ {
40
+ "name": "Lucide",
41
+ "version": "1.17.0",
42
+ "repositoryUrl": "https://github.com/lucide-icons/lucide",
43
+ "description": "Interface icons."
44
+ }
45
+ ];
46
+ //# sourceMappingURL=library-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library-info.js","sourceRoot":"","sources":["../src/library-info.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC;QACE,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,QAAQ;QACnB,eAAe,EAAE,+CAA+C;QAChE,aAAa,EAAE,wCAAwC;KACxD;IACD;QACE,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,OAAO;QAClB,eAAe,EAAE,gDAAgD;QACjE,aAAa,EAAE,iDAAiD;KACjE;IACD;QACE,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,QAAQ;QACnB,eAAe,EAAE,mCAAmC;QACpD,aAAa,EAAE,qCAAqC;KACrD;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,SAAS;QACpB,eAAe,EAAE,oCAAoC;QACrD,aAAa,EAAE,+BAA+B;KAC/C;IACD;QACE,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,OAAO;QAClB,eAAe,EAAE,qCAAqC;QACtD,aAAa,EAAE,oBAAoB;KACpC;IACD;QACE,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,SAAS;QACpB,eAAe,EAAE,6CAA6C;QAC9D,aAAa,EAAE,iCAAiC;KACjD;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,QAAQ;QACnB,eAAe,EAAE,wCAAwC;QACzD,aAAa,EAAE,kBAAkB;KAClC;CACO,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { MdzipMarkdownRenderExtension } from './rendering.js';
2
+ export type MdzipMermaidTheme = 'auto' | 'default' | 'dark' | 'neutral' | 'forest' | 'base';
3
+ /**
4
+ * Minimal surface of the `mermaid` module the extension relies on. Exposed so
5
+ * the loader can be supplied directly (tests, or hosts that already own a
6
+ * mermaid instance) instead of going through the lazy dynamic import.
7
+ */
8
+ export interface MdzipMermaidApi {
9
+ initialize(config: Record<string, unknown>): void;
10
+ render(id: string, text: string): Promise<{
11
+ svg: string;
12
+ }>;
13
+ }
14
+ export interface MdzipMermaidOptions {
15
+ /**
16
+ * Mermaid theme. `'auto'` (the default) follows the preview color scheme —
17
+ * the `dark` theme under a dark scheme, `default` under light.
18
+ */
19
+ theme?: MdzipMermaidTheme;
20
+ /**
21
+ * Supplies the mermaid API instead of the built-in lazy `import('mermaid')`.
22
+ * Use for tests or to share a preconfigured instance. When omitted, mermaid
23
+ * is dynamically imported the first time a `mermaid` block is rendered.
24
+ */
25
+ loadMermaid?: () => Promise<MdzipMermaidApi>;
26
+ }
27
+ /**
28
+ * A markdown render extension that renders fenced ` ```mermaid ` code blocks to
29
+ * inline SVG in the preview.
30
+ *
31
+ * Ships as a separate entrypoint (`@mdzip/editor/mermaid`) so the ~1MB mermaid
32
+ * library stays out of the core bundle: it is dynamically imported the first
33
+ * time a document actually contains a mermaid block. Pass the returned
34
+ * extension via the view's `markdownExtensions` option.
35
+ *
36
+ * Diagrams render with mermaid's `strict` security level, each SVG is
37
+ * re-sanitized before injection, and invalid diagrams render as an inline
38
+ * error block instead of breaking the whole preview. The theme follows the
39
+ * preview color scheme by default ({@link MdzipMermaidOptions.theme}).
40
+ *
41
+ * Note: enabling this widens the preview's sanitize policy to allow SVG and
42
+ * inline styles for the whole render (not just the diagram), since the markdown
43
+ * HTML and diagram SVG are sanitized together.
44
+ */
45
+ export declare function mdzipMermaidExtension(options?: MdzipMermaidOptions): MdzipMarkdownRenderExtension;
46
+ //# sourceMappingURL=mermaid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../src/mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAGnE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE5F;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9C;AA2CD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,mBAAwB,GAAG,4BAA4B,CA0DrG"}
@@ -0,0 +1,107 @@
1
+ import { sanitizeMdzipHtml } from './rendering.js';
2
+ let defaultMermaidPromise = null;
3
+ function loadDefaultMermaid() {
4
+ // Literal specifier so bundlers can split mermaid into its own lazily-loaded
5
+ // chunk. Memoized so the module is fetched and parsed at most once.
6
+ defaultMermaidPromise ??= import('mermaid').then((module) => (module.default ?? module));
7
+ return defaultMermaidPromise;
8
+ }
9
+ function resolveTheme(theme, colorScheme) {
10
+ if (theme === 'auto') {
11
+ return colorScheme === 'dark' ? 'dark' : 'default';
12
+ }
13
+ return theme;
14
+ }
15
+ function requireDocument() {
16
+ const doc = globalThis.document;
17
+ if (!doc) {
18
+ throw new Error('The mermaid extension requires a DOM document to render diagrams.');
19
+ }
20
+ return doc;
21
+ }
22
+ // Mermaid SVG carries a nested <style> element and inline style attributes for
23
+ // theming, so the diagram needs SVG plus those two relaxations to survive the
24
+ // sanitizer. Reused both for the extension's contribution to the pipeline pass
25
+ // and for defensively re-sanitizing each SVG before it is injected.
26
+ const MERMAID_SANITIZE = {
27
+ allowSvg: true,
28
+ unforbidTags: ['style'],
29
+ unforbidAttr: ['style']
30
+ };
31
+ function mermaidErrorMessage(error) {
32
+ const detail = error instanceof Error ? error.message : String(error);
33
+ return `Mermaid diagram error: ${detail}`;
34
+ }
35
+ /**
36
+ * A markdown render extension that renders fenced ` ```mermaid ` code blocks to
37
+ * inline SVG in the preview.
38
+ *
39
+ * Ships as a separate entrypoint (`@mdzip/editor/mermaid`) so the ~1MB mermaid
40
+ * library stays out of the core bundle: it is dynamically imported the first
41
+ * time a document actually contains a mermaid block. Pass the returned
42
+ * extension via the view's `markdownExtensions` option.
43
+ *
44
+ * Diagrams render with mermaid's `strict` security level, each SVG is
45
+ * re-sanitized before injection, and invalid diagrams render as an inline
46
+ * error block instead of breaking the whole preview. The theme follows the
47
+ * preview color scheme by default ({@link MdzipMermaidOptions.theme}).
48
+ *
49
+ * Note: enabling this widens the preview's sanitize policy to allow SVG and
50
+ * inline styles for the whole render (not just the diagram), since the markdown
51
+ * HTML and diagram SVG are sanitized together.
52
+ */
53
+ export function mdzipMermaidExtension(options = {}) {
54
+ const load = options.loadMermaid ?? loadDefaultMermaid;
55
+ let counter = 0;
56
+ return {
57
+ name: 'mermaid',
58
+ sanitize: MERMAID_SANITIZE,
59
+ async transformHtml(html, context) {
60
+ const doc = requireDocument();
61
+ const template = doc.createElement('template');
62
+ template.innerHTML = html;
63
+ const blocks = Array.from(template.content.querySelectorAll('pre > code.language-mermaid'));
64
+ if (blocks.length === 0) {
65
+ return html;
66
+ }
67
+ const mermaid = await load();
68
+ if (context.signal.aborted) {
69
+ return html;
70
+ }
71
+ mermaid.initialize({
72
+ startOnLoad: false,
73
+ securityLevel: 'strict',
74
+ // Render labels as SVG <text> rather than HTML inside <foreignObject>.
75
+ // The bundled sanitizer keeps the SVG but strips foreignObject HTML, so
76
+ // html labels would otherwise vanish — this keeps the emitted SVG
77
+ // self-consistent with the policy without re-allowing HTML in labels.
78
+ htmlLabels: false,
79
+ flowchart: { htmlLabels: false },
80
+ theme: resolveTheme(options.theme ?? 'auto', context.colorScheme)
81
+ });
82
+ for (const code of blocks) {
83
+ const pre = code.parentElement;
84
+ if (!pre) {
85
+ continue;
86
+ }
87
+ const source = code.textContent ?? '';
88
+ const container = doc.createElement('div');
89
+ try {
90
+ const { svg } = await mermaid.render(`mdzip-mermaid-${(counter += 1)}`, source);
91
+ container.className = 'mdzip-mermaid';
92
+ container.innerHTML = sanitizeMdzipHtml(svg, [MERMAID_SANITIZE]);
93
+ }
94
+ catch (error) {
95
+ container.className = 'mdzip-mermaid-error';
96
+ container.textContent = mermaidErrorMessage(error);
97
+ }
98
+ pre.replaceWith(container);
99
+ if (context.signal.aborted) {
100
+ return html;
101
+ }
102
+ }
103
+ return template.innerHTML;
104
+ }
105
+ };
106
+ }
107
+ //# sourceMappingURL=mermaid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../src/mermaid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA4BnD,IAAI,qBAAqB,GAAoC,IAAI,CAAC;AAElE,SAAS,kBAAkB;IACzB,6EAA6E;IAC7E,oEAAoE;IACpE,qBAAqB,KAAK,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAC9C,CAAC,MAAM,EAAE,EAAE,CAAC,CAAE,MAAwC,CAAC,OAAO,IAAI,MAAM,CAAoB,CAC7F,CAAC;IACF,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,SAAS,YAAY,CAAC,KAAwB,EAAE,WAA6B;IAC3E,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACrB,OAAO,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe;IACtB,MAAM,GAAG,GAAI,UAAsC,CAAC,QAAQ,CAAC;IAC7D,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,oEAAoE;A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orkspace, MdzWorkspaceAsset } from '@mdzip/core-js';
2
+ export * from './archive-utils.js';
3
+ export * from './browser.js';
4
+ export * from './diff.js';
5
+ export * from './metadata.js';
6
+ export * from './rendering.js';
7
+ export * from './theme.js';
8
+ export * from './workspace.js';
9
+ export * from './workspace-view.js';
10
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './archive-utils.js';
2
+ export * from './browser.js';
3
+ export * from './diff.js';
4
+ export * from './metadata.js';
5
+ export * from './rendering.js';
6
+ export * from './theme.js';
7
+ export * from './workspace.js';
8
+ export * from './workspace-view.js';
9
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -1,6 +1,160 @@
1
+ import type { MdzManifest } from '@mdzip/core-js';
2
+ import type { MdzipPathType, MdzipSourceFormat, MdzipWorkspaceMode, MdzipWorkspaceSnapshot } from './workspace.js';
3
+ /**
4
+ * Narrow, opt-in relaxations a render extension contributes to the single
5
+ * DOMPurify pass so its `transformHtml` output survives sanitization.
6
+ *
7
+ * The default policy is HTML-only and strips SVG, inline styles, `<style>`,
8
+ * and data attributes. An extension that injects richer markup — inline SVG
9
+ * for a diagram, say — declares exactly what it needs here. Keep contributions
10
+ * as narrow as possible: they widen the policy for the **whole** render pass
11
+ * (the extension output and the surrounding markdown HTML are sanitized
12
+ * together), so anything allowed here is allowed everywhere in that preview.
13
+ */
14
+ export interface MdzipSanitizeContribution {
15
+ /**
16
+ * Enable DOMPurify's `svg` + `svgFilters` profiles so inline SVG survives.
17
+ * Even with this on, DOMPurify still strips scripts and event handlers from
18
+ * the SVG — extensions should additionally sanitize and lock down their own
19
+ * SVG before injecting it.
20
+ */
21
+ allowSvg?: boolean;
22
+ /** Extra element names to allow beyond the default policy. */
23
+ addTags?: readonly string[];
24
+ /** Extra attribute names to allow beyond the default policy. */
25
+ addAttr?: readonly string[];
26
+ /** Tags to drop from the default forbid-list (e.g. re-allow `style`). */
27
+ unforbidTags?: readonly string[];
28
+ /** Attributes to drop from the default forbid-list (e.g. re-allow inline `style`). */
29
+ unforbidAttr?: readonly string[];
30
+ }
31
+ /**
32
+ * Sanitizes rendered HTML with the editor's default DOMPurify policy.
33
+ *
34
+ * Note the policy strips data attributes and inline styles. Markdown render
35
+ * extensions that need to find placeholders again in `mount()` should use
36
+ * class or id markers and carry payloads out-of-band (e.g. a side map keyed
37
+ * by marker id), not element attributes.
38
+ *
39
+ * Pass `contributions` (an extension's {@link MdzipSanitizeContribution}s) to
40
+ * widen the policy just enough for richer output such as inline SVG.
41
+ */
42
+ export declare function sanitizeMdzipHtml(html: string, contributions?: readonly MdzipSanitizeContribution[]): string;
43
+ /**
44
+ * Context handed to markdown renderers and render extensions for one render
45
+ * generation. `signal` aborts when the selection or content moves on before
46
+ * an asynchronous stage finishes; stages should stop work when it fires.
47
+ */
48
+ export interface MdzipMarkdownRenderContext {
49
+ currentPath: string;
50
+ sourceFormat: MdzipSourceFormat;
51
+ colorScheme: 'light' | 'dark';
52
+ mode: MdzipWorkspaceMode;
53
+ manifest: MdzManifest | null;
54
+ /**
55
+ * Resolves archive asset paths (e.g. to data URIs) for stages that need to
56
+ * reference assets directly. Markdown image sources are already rewritten
57
+ * before the pipeline runs, so most extensions never need this.
58
+ */
59
+ assetResolver?: MdzipAssetUrlResolver;
60
+ signal: AbortSignal;
61
+ }
1
62
  export interface MdzipMarkdownRenderer {
2
- render(markdown: string, options?: Record<string, unknown>): string;
63
+ /**
64
+ * Renders markdown to HTML. May return a promise; the pipeline keeps a
65
+ * fully synchronous fast path when it does not.
66
+ *
67
+ * String output is sanitized by the pipeline before insertion unless
68
+ * `sanitizesOutput` is `true` and no `transformHtml` extension is
69
+ * registered.
70
+ */
71
+ render(markdown: string, context?: MdzipMarkdownRenderContext): string | Promise<string>;
72
+ /**
73
+ * Explicit sanitization bypass: declares that `render()` output is already
74
+ * safe to insert. Only set this when the renderer sanitizes internally —
75
+ * the default renderer does. When any `transformHtml` extension is
76
+ * registered the pipeline still sanitizes the final HTML, because the
77
+ * transformed output is no longer what this renderer produced.
78
+ */
79
+ readonly sanitizesOutput?: boolean;
80
+ }
81
+ /**
82
+ * Handle returned by a `mount()` hook so the view can update or dispose
83
+ * mounted content. `destroy()` is called before the container's HTML is
84
+ * replaced and when the view is destroyed.
85
+ */
86
+ export interface MdzipRenderHandle {
87
+ update?(context: MdzipMarkdownRenderContext): void | Promise<void>;
88
+ destroy(): void;
89
+ }
90
+ /**
91
+ * Composable extension over the default markdown pipeline:
92
+ *
93
+ * markdown -> transformMarkdown* -> renderer -> transformHtml*
94
+ * -> sanitize -> DOM insertion -> mount*
95
+ *
96
+ * `transformMarkdown`/`transformHtml` outputs pass through sanitization, so
97
+ * they cannot inject unsafe markup. `mount()` runs against the live preview
98
+ * DOM and is privileged host code.
99
+ */
100
+ export interface MdzipMarkdownRenderExtension {
101
+ name: string;
102
+ /**
103
+ * Narrow sanitizer relaxations this extension needs for its `transformHtml`
104
+ * output to survive the pipeline's DOMPurify pass (e.g. inline SVG). Merged
105
+ * across all registered extensions. See {@link MdzipSanitizeContribution}.
106
+ */
107
+ sanitize?: MdzipSanitizeContribution;
108
+ transformMarkdown?(markdown: string, context: MdzipMarkdownRenderContext): string | Promise<string>;
109
+ transformHtml?(html: string, context: MdzipMarkdownRenderContext): string | Promise<string>;
110
+ mount?(container: HTMLElement, context: MdzipMarkdownRenderContext): void | MdzipRenderHandle | Promise<void | MdzipRenderHandle>;
111
+ }
112
+ /**
113
+ * Context handed to entry renderers for the currently selected archive entry.
114
+ * Exposes supported operations instead of view internals.
115
+ */
116
+ export interface MdzipEntryRenderContext {
117
+ path: string;
118
+ pathType: MdzipPathType;
119
+ mode: MdzipWorkspaceMode;
120
+ sourceFormat: MdzipSourceFormat;
121
+ colorScheme: 'light' | 'dark';
122
+ manifest: MdzManifest | null;
123
+ snapshot: MdzipWorkspaceSnapshot;
124
+ signal: AbortSignal;
125
+ /** Reads the raw bytes of the selected entry. */
126
+ readBytes(): Promise<Uint8Array>;
127
+ /**
128
+ * Replaces the manifest wholesale (canonicalized). Routes through the
129
+ * workspace `'manifest'` edit event, so `onManifestChanged` host-delegated
130
+ * persistence keeps working.
131
+ */
132
+ updateManifest(manifest: MdzManifest): Promise<void>;
133
+ }
134
+ export interface MdzipEntryRenderHandle {
135
+ update?(context: MdzipEntryRenderContext): void | Promise<void>;
136
+ destroy(): void;
137
+ }
138
+ /**
139
+ * Claims the full pane stack (edit and preview panes included) for selected
140
+ * archive entries it matches. The first matching renderer by descending
141
+ * `priority` wins; when none match, built-in rendering is used.
142
+ */
143
+ export interface MdzipEntryRenderer {
144
+ id: string;
145
+ priority?: number;
146
+ /** Must be cheap and synchronous; called when the selection key changes. */
147
+ matches(context: MdzipEntryRenderContext): boolean;
148
+ mount(container: HTMLElement, context: MdzipEntryRenderContext): void | MdzipEntryRenderHandle | Promise<void | MdzipEntryRenderHandle>;
3
149
  }
150
+ /** Predicate matching one or more exact archive paths (case-insensitive). */
151
+ export declare function mdzipPathMatcher(...paths: string[]): (context: {
152
+ path: string;
153
+ }) => boolean;
154
+ /** Predicate matching file extensions (case-insensitive, dot optional). */
155
+ export declare function mdzipExtensionMatcher(...extensions: string[]): (context: {
156
+ path: string;
157
+ }) => boolean;
4
158
  export interface MdzipAssetUrlResolver {
5
159
  resolveAssetUrl(path: string, fallbackDataUri?: string): string | undefined;
6
160
  }
@@ -14,7 +168,26 @@ export interface MdzipRenderResult {
14
168
  export declare const defaultSafeMarkdownRenderer: MdzipMarkdownRenderer;
15
169
  export declare class MdzipRenderingService {
16
170
  private readonly renderer;
17
- constructor(renderer?: MdzipMarkdownRenderer);
171
+ private readonly extensions;
172
+ constructor(renderer?: MdzipMarkdownRenderer, extensions?: readonly MdzipMarkdownRenderExtension[]);
173
+ /**
174
+ * Legacy synchronous render. Behavior is unchanged: the configured
175
+ * renderer's output is returned as-is (the default renderer sanitizes
176
+ * internally). Extensions do not run here — use {@link renderMarkdown}.
177
+ */
18
178
  render(request: MdzipRenderRequest): MdzipRenderResult;
179
+ /**
180
+ * Full extension pipeline:
181
+ *
182
+ * transformMarkdown* -> renderer -> transformHtml* -> sanitize
183
+ *
184
+ * Returns a plain string when every stage is synchronous, so the common
185
+ * no-extensions path costs no microtask hop. Exactly one DOMPurify pass
186
+ * runs per render: the default renderer skips its internal pass when
187
+ * `transformHtml` extensions are registered, and renderers declaring
188
+ * `sanitizesOutput` skip the pipeline pass when no `transformHtml`
189
+ * extension is registered.
190
+ */
191
+ renderMarkdown(markdown: string, context: MdzipMarkdownRenderContext): string | Promise<string>;
19
192
  }
20
193
  //# sourceMappingURL=rendering.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../src/rendering.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAA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