@orangelogic/design-system 2.221.0 → 2.222.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.
@@ -45,7 +45,7 @@ import { default as Qe } from "./include.js";
45
45
  import { C as qe } from "../chunks/input.B1JamaTE.js";
46
46
  import { default as Ke } from "./input-group.js";
47
47
  import { default as We } from "./line-clamp.js";
48
- import { C as Ye } from "../chunks/markdown.Cc9XwWxA.js";
48
+ import { C as Ye } from "../chunks/markdown.DP1DqzwO.js";
49
49
  import { default as _e } from "./menu.js";
50
50
  import { default as oo } from "./menu-item.js";
51
51
  import { default as ao } from "./menu-label.js";
@@ -1,5 +1,5 @@
1
1
  import "../chunks/icon-button.BBLy-yj3.js";
2
- import { C as s } from "../chunks/markdown.Cc9XwWxA.js";
2
+ import { C as s } from "../chunks/markdown.DP1DqzwO.js";
3
3
  import "../chunks/custom-element.L4WJXn1j.js";
4
4
  import "../chunks/i18n.CXIpdSSZ.js";
5
5
  import "../chunks/watch.DJF5K-8U.js";
@@ -46,7 +46,7 @@ import { default as fZt } from "./include.js";
46
46
  import { C as eo, I as ZS } from "../chunks/input.B1JamaTE.js";
47
47
  import { default as yZt } from "./input-group.js";
48
48
  import Bp from "./line-clamp.js";
49
- import { C as l3, e as pee, x as hee, s as gee, p as pM, a as mee } from "../chunks/markdown.Cc9XwWxA.js";
49
+ import { C as l3, e as pee, x as hee, s as gee, p as pM, a as mee } from "../chunks/markdown.DP1DqzwO.js";
50
50
  import hl from "./menu.js";
51
51
  import gl from "./menu-item.js";
52
52
  import d6 from "./menu-label.js";
@@ -50883,7 +50883,7 @@ let jr = class extends hn {
50883
50883
  }
50884
50884
  }
50885
50885
  };
50886
- return D`<cx-markdown markdown=${n.trim() ? n : "<p></p>"} .extensions=${[i]} .renderer=${{
50886
+ return D`<cx-markdown show-math-notation markdown=${n.trim() ? n : "<p></p>"} .extensions=${[i]} .renderer=${{
50887
50887
  // Method, not an arrow: marked binds renderer methods to expose `this.parser`.
50888
50888
  paragraph({ tokens: r }) {
50889
50889
  return this.parser.parseInline(r);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orangelogic/design-system",
3
3
  "type": "module",
4
- "version": "2.221.0",
4
+ "version": "2.222.0",
5
5
  "license": "UNLICENSED",
6
6
  "types": "library/types.d.ts",
7
7
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  import { default as CxIconButton } from '../icon-button/icon-button.ts';
2
2
  import { default as CortexLightElement } from '../../../../base/src/cortex-light-element.ts';
3
- import { TemplateResult } from 'lit';
3
+ import { PropertyValues, TemplateResult } from 'lit';
4
4
  import { RendererObject, TokenizerAndRendererExtension } from 'marked';
5
5
 
6
6
  /**
@@ -10,7 +10,8 @@ import { RendererObject, TokenizerAndRendererExtension } from 'marked';
10
10
  * cx-markdown is powered by [MarkedJs](https://marked.js.org/).
11
11
  *
12
12
  * Fenced `mermaid` code blocks render as diagrams; Mermaid is imported lazily only when one is
13
- * present. Output is sanitized with DOMPurify unless `live-script` is set.
13
+ * present; with `show-math-notation` set, `$…$` and `$$…$$` render through KaTeX the same way.
14
+ * Output is sanitized with DOMPurify unless `live-script` is set.
14
15
  *
15
16
  * Leading YAML frontmatter renders as a collapsed disclosure instead of an `<hr>` plus heading, and
16
17
  * is parsed onto the `frontmatter` property.
@@ -24,7 +25,7 @@ import { RendererObject, TokenizerAndRendererExtension } from 'marked';
24
25
  * buttons, Mermaid nodes — do not bubble past the component. Clicks on inert content still do.
25
26
  *
26
27
  * @event cx-ready - Emitted when the markdown has been rendered, deferred until any Mermaid
27
- * diagrams have been drawn.
28
+ * diagrams and formulas have been drawn.
28
29
  */
29
30
  export default class CxMarkdown extends CortexLightElement {
30
31
  #private;
@@ -33,6 +34,8 @@ export default class CxMarkdown extends CortexLightElement {
33
34
  'cx-icon-button': typeof CxIconButton;
34
35
  };
35
36
  private readonly localize;
37
+ /** KaTeX loader, held in a field like other I/O so a test can keep the import pending. */
38
+ private loadKatex;
36
39
  /**
37
40
  * YAML frontmatter parsed from `markdown`, empty when there is none. Derived output — assigning
38
41
  * to it has no effect. Read it after `cx-ready`. Deliberately non-reactive: the disclosure is
@@ -54,6 +57,11 @@ export default class CxMarkdown extends CortexLightElement {
54
57
  * adds `rel="noopener noreferrer"`. Empty (the default) leaves anchors untouched.
55
58
  */
56
59
  linkTarget: string;
60
+ /**
61
+ * Renders `$…$` and `$$…$$` with KaTeX, loaded lazily. Invalid TeX, or a browser without
62
+ * MathML, keeps its source.
63
+ */
64
+ showMathNotation: boolean;
57
65
  /**
58
66
  * The markdown to render.
59
67
  */
@@ -73,6 +81,7 @@ export default class CxMarkdown extends CortexLightElement {
73
81
  rendered: string;
74
82
  connectedCallback(): void;
75
83
  disconnectedCallback(): void;
84
+ protected willUpdate(changedProperties: PropertyValues<this>): void;
76
85
  updateRendered(): void;
77
86
  /**
78
87
  * Light DOM means every click reaches ancestors, which commonly treat one as "start editing".
@@ -1,9 +1,12 @@
1
- import { Marked, Tokens } from 'marked';
1
+ import { CreateParserOptions } from '../../../../types/src/markdown';
2
+ import { Marked, MarkedExtension, Renderer, Tokens } from 'marked';
2
3
 
3
4
  /** Class name cx-markdown looks for when deciding whether to load Mermaid. */
4
5
  export declare const MERMAID_CLASS_NAME = "mermaid";
5
6
  /** Class name on the disclosure wrapping YAML frontmatter. */
6
7
  export declare const FRONTMATTER_CLASS_NAME = "cx-frontmatter";
8
+ /** Class name cx-markdown looks for when deciding whether to load KaTeX. */
9
+ export declare const MATH_CLASS_NAME = "cx-math";
7
10
  export type ExtractedFrontmatter = {
8
11
  /** The markdown with the frontmatter block removed. */
9
12
  body: string;
@@ -16,8 +19,10 @@ export declare function extractFrontmatter(source: string): ExtractedFrontmatter
16
19
  /** Collapsed disclosure shown in place of the frontmatter block. */
17
20
  export declare function renderFrontmatterDetails(raw: string, label: string): string;
18
21
  export declare const baseRenderer: {
19
- code(this: import('marked').Renderer<string, string>, { escaped, lang: infoString, text }: Tokens.Code): string;
22
+ code(this: Renderer<string, string>, { escaped, lang: infoString, text }: Tokens.Code): string;
20
23
  };
24
+ /** Opt-in `$…$` / `$$…$$` support; `createParser({ math })` registers it. */
25
+ export declare const mathExtension: MarkedExtension;
21
26
  /**
22
27
  * https://marked.js.org/using_advanced in Marked instance section.
23
28
  * https://marked.js.org/using_pro in Marked marked.use() section.
@@ -25,5 +30,5 @@ export declare const baseRenderer: {
25
30
  *
26
31
  * Change from Singleton to Factory pattern: returns a new isolated Marked parser.
27
32
  */
28
- export declare function createParser(): Marked<string, string>;
33
+ export declare function createParser({ math }?: CreateParserOptions): Marked<string, string>;
29
34
  export type Parser = ReturnType<typeof createParser>;
@@ -10,4 +10,4 @@ import { Schema } from '@tiptap/pm/model';
10
10
  * Constructs the model cannot represent are not dropped: `html_block` and `html_inline` hold their
11
11
  * source verbatim and are replayed on the way out.
12
12
  */
13
- export declare const markdownSchema: Schema<"image" | "blockquote" | "table" | "text" | "heading" | "paragraph" | "frontmatter" | "doc" | "horizontal_rule" | "bullet_list" | "code_block" | "list_item" | "ordered_list" | "table_row" | "table_cell" | "table_header" | "hard_break" | "html_block" | "html_inline", "link" | "code" | "em" | "strong" | "strike">;
13
+ export declare const markdownSchema: Schema<"image" | "blockquote" | "table" | "text" | "heading" | "paragraph" | "list_item" | "frontmatter" | "doc" | "horizontal_rule" | "bullet_list" | "code_block" | "ordered_list" | "table_row" | "table_cell" | "table_header" | "hard_break" | "html_block" | "html_inline", "link" | "code" | "em" | "strong" | "strike">;
@@ -3527,6 +3527,10 @@
3527
3527
  * Target applied to every rendered link. Set to `_blank` to open links in a new tab, which also adds `rel="noopener noreferrer"`. Empty (the default) leaves anchors untouched.
3528
3528
  */
3529
3529
  linkTarget?: string;
3530
+ /**
3531
+ * Renders `$…$` and `$$…$$` with KaTeX, loaded lazily. Invalid TeX, or a browser without MathML, keeps its source.
3532
+ */
3533
+ showMathNotation?: boolean;
3530
3534
  /**
3531
3535
  * The markdown to render.
3532
3536
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orangelogic/design-system",
3
3
  "type": "module",
4
- "version": "2.221.0",
4
+ "version": "2.222.0",
5
5
  "license": "UNLICENSED",
6
6
  "types": "library/types.d.ts",
7
7
  "scripts": {