@gild-ui/react-markdown 0.0.0-stage → 0.1.0-alpha.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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +179 -2
  3. package/dist/CodeBlock.cjs +136 -0
  4. package/dist/CodeBlock.d.cts +15 -0
  5. package/dist/CodeBlock.d.mts +3 -0
  6. package/dist/CodeBlock.mjs +133 -0
  7. package/dist/Control.cjs +60 -0
  8. package/dist/Control.d.cts +16 -0
  9. package/dist/Control.d.mts +16 -0
  10. package/dist/Control.mjs +59 -0
  11. package/dist/Editor.cjs +131 -0
  12. package/dist/Editor.d.cts +48 -0
  13. package/dist/Editor.d.mts +48 -0
  14. package/dist/Editor.mjs +130 -0
  15. package/dist/LiveEdit-1-8cA5Xw.mjs +215 -0
  16. package/dist/LiveEdit-B83sDZXu.cjs +224 -0
  17. package/dist/LiveEdit.cjs +3 -0
  18. package/dist/LiveEdit.d.cts +29 -0
  19. package/dist/LiveEdit.d.mts +29 -0
  20. package/dist/LiveEdit.mjs +1 -0
  21. package/dist/MarkdownContext-D28Czdll.mjs +10 -0
  22. package/dist/MarkdownContext-DS1X9B6N.cjs +21 -0
  23. package/dist/Mermaid-DW0NuDS-.mjs +248 -0
  24. package/dist/Mermaid-D_tCNrQ9.cjs +253 -0
  25. package/dist/Mermaid.cjs +3 -0
  26. package/dist/Mermaid.d.cts +2 -0
  27. package/dist/Mermaid.d.mts +2 -0
  28. package/dist/Mermaid.mjs +1 -0
  29. package/dist/Preview-BLXtPaa9.mjs +258 -0
  30. package/dist/Preview-D-AL97QU.cjs +268 -0
  31. package/dist/Preview.cjs +3 -0
  32. package/dist/Preview.d.cts +56 -0
  33. package/dist/Preview.d.mts +2 -0
  34. package/dist/Preview.mjs +1 -0
  35. package/dist/Toolbar-Eg7KmYbK.mjs +603 -0
  36. package/dist/Toolbar-gk3KJhCE.cjs +614 -0
  37. package/dist/Toolbar.cjs +4 -0
  38. package/dist/Toolbar.d.cts +18 -0
  39. package/dist/Toolbar.d.mts +18 -0
  40. package/dist/Toolbar.mjs +1 -0
  41. package/dist/applyAction-B3AwrWKV.cjs +121 -0
  42. package/dist/applyAction-CkTQJ5Iy.mjs +116 -0
  43. package/dist/index-BBkHCbE7.d.mts +15 -0
  44. package/dist/index-BVYb370O.d.cts +24 -0
  45. package/dist/index-CfPKWPpM.d.mts +57 -0
  46. package/dist/index-CyddYU7P.d.mts +24 -0
  47. package/dist/index.cjs +21 -0
  48. package/dist/index.d.cts +80 -0
  49. package/dist/index.d.mts +80 -0
  50. package/dist/index.mjs +9 -0
  51. package/dist/mergeOverrides-D2btS1Jb.cjs +19 -0
  52. package/dist/mergeOverrides-DEbU7yDg.mjs +14 -0
  53. package/dist/rolldown-runtime-CmQyd0Gu.cjs +27 -0
  54. package/dist/themeTypes-C4kTtkIA.d.cts +83 -0
  55. package/dist/themeTypes-C4kTtkIA.d.mts +83 -0
  56. package/package.json +168 -3
@@ -0,0 +1,121 @@
1
+ // src/utils/applyAction.ts
2
+ const fusesWithMarker = (char) => !/[\s*_~`]/.test(char);
3
+ function stripWrap(action, { value, selectionStart, selectionEnd }) {
4
+ const { prefix, suffix } = action;
5
+ const selected = value.slice(selectionStart, selectionEnd);
6
+ const keep = (content) => content === action.placeholder ? "" : content;
7
+ if (selected.length >= prefix.length + suffix.length && selected.startsWith(prefix) && selected.endsWith(suffix)) {
8
+ const core = keep(selected.slice(prefix.length, selected.length - suffix.length));
9
+ return {
10
+ value: value.slice(0, selectionStart) + core + value.slice(selectionEnd),
11
+ selectionStart,
12
+ selectionEnd: selectionStart + core.length
13
+ };
14
+ }
15
+ if (selectionStart >= prefix.length && value.slice(selectionStart - prefix.length, selectionStart) === prefix && value.slice(selectionEnd, selectionEnd + suffix.length) === suffix) {
16
+ const start = selectionStart - prefix.length;
17
+ const core = keep(selected);
18
+ return {
19
+ value: value.slice(0, start) + core + value.slice(selectionEnd + suffix.length),
20
+ selectionStart: start,
21
+ selectionEnd: start + core.length
22
+ };
23
+ }
24
+ return null;
25
+ }
26
+ function wrapInline(action, { value, selectionStart, selectionEnd }) {
27
+ const selected = value.slice(selectionStart, selectionEnd);
28
+ const leadingLength = selected.length - selected.trimStart().length;
29
+ const trailingLength = selected.length - selected.trimEnd().length;
30
+ const core = selected.slice(leadingLength, selected.length - trailingLength) || action.placeholder;
31
+ let before = selected.slice(0, leadingLength);
32
+ if (!before && selectionStart > 0 && fusesWithMarker(value[selectionStart - 1])) before = " ";
33
+ let after = selected.slice(selected.length - trailingLength);
34
+ if (!after && selectionEnd < value.length && fusesWithMarker(value[selectionEnd])) after = " ";
35
+ const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
36
+ const start = selectionStart + before.length + action.prefix.length;
37
+ return {
38
+ value: value_,
39
+ selectionStart: start,
40
+ selectionEnd: start + core.length
41
+ };
42
+ }
43
+ function wrapBlock(action, { value, selectionStart, selectionEnd }) {
44
+ const core = value.slice(selectionStart, selectionEnd) || action.placeholder;
45
+ const before = selectionStart > 0 && value[selectionStart - 1] !== "\n" ? "\n" : "";
46
+ const after = selectionEnd < value.length && value[selectionEnd] !== "\n" ? "\n" : "";
47
+ const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
48
+ const start = selectionStart + before.length + action.prefix.length;
49
+ return {
50
+ value: value_,
51
+ selectionStart: start,
52
+ selectionEnd: start + core.length
53
+ };
54
+ }
55
+ function applyWrap(action, selection) {
56
+ if (action.block) return wrapBlock(action, selection);
57
+ return stripWrap(action, selection) ?? wrapInline(action, selection);
58
+ }
59
+ function toggleLinePrefix(action, line) {
60
+ if (!action.family) return action.linePrefix + line;
61
+ const existing = action.family.exec(line)?.[0] ?? "";
62
+ const stripped = line.slice(existing.length);
63
+ if (existing === action.linePrefix && action.toggle !== false) return stripped;
64
+ return action.linePrefix + stripped;
65
+ }
66
+ function applyLinePrefix(action, { value, selectionStart, selectionEnd }) {
67
+ const lineStart = selectionStart === 0 ? 0 : value.lastIndexOf("\n", selectionStart - 1) + 1;
68
+ const nextNewline = value.indexOf("\n", selectionEnd);
69
+ const lineEnd = nextNewline === -1 ? value.length : nextNewline;
70
+ const prefixed = value.slice(lineStart, lineEnd).split("\n").map((line) => toggleLinePrefix(action, line)).join("\n");
71
+ return {
72
+ value: value.slice(0, lineStart) + prefixed + value.slice(lineEnd),
73
+ selectionStart: lineStart,
74
+ selectionEnd: lineStart + prefixed.length
75
+ };
76
+ }
77
+ function fenceEndAfter(value, pos) {
78
+ let offset = 0;
79
+ let openStart = -1;
80
+ for (const line of value.split("\n")) {
81
+ const lineEnd = offset + line.length;
82
+ if (line.startsWith("```")) {
83
+ if (openStart === -1) openStart = offset;
84
+ else {
85
+ if (pos >= openStart && pos <= lineEnd) return lineEnd;
86
+ openStart = -1;
87
+ }
88
+ }
89
+ offset = lineEnd + 1;
90
+ }
91
+ return null;
92
+ }
93
+ function applyInsert(action, { value, selectionStart, selectionEnd }) {
94
+ const fenceEnd = fenceEndAfter(value, selectionStart);
95
+ const at = fenceEnd ?? selectionEnd;
96
+ const from = fenceEnd ?? selectionStart;
97
+ const value_ = value.slice(0, from) + action.snippet + value.slice(at);
98
+ const caret = from + action.snippet.length;
99
+ return {
100
+ value: value_,
101
+ selectionStart: caret,
102
+ selectionEnd: caret
103
+ };
104
+ }
105
+ /**
106
+ * Pure transform: applies a toolbar `action` to the given selection and returns the next
107
+ * source plus the selection to restore around the inserted markdown. No DOM access.
108
+ */
109
+ function applyAction(action, selection) {
110
+ switch (action.kind) {
111
+ case "wrap": return applyWrap(action, selection);
112
+ case "linePrefix": return applyLinePrefix(action, selection);
113
+ case "insert": return applyInsert(action, selection);
114
+ }
115
+ }
116
+ Object.defineProperty(exports, "applyAction", {
117
+ enumerable: true,
118
+ get: function() {
119
+ return applyAction;
120
+ }
121
+ });
@@ -0,0 +1,116 @@
1
+ // src/utils/applyAction.ts
2
+ const fusesWithMarker = (char) => !/[\s*_~`]/.test(char);
3
+ function stripWrap(action, { value, selectionStart, selectionEnd }) {
4
+ const { prefix, suffix } = action;
5
+ const selected = value.slice(selectionStart, selectionEnd);
6
+ const keep = (content) => content === action.placeholder ? "" : content;
7
+ if (selected.length >= prefix.length + suffix.length && selected.startsWith(prefix) && selected.endsWith(suffix)) {
8
+ const core = keep(selected.slice(prefix.length, selected.length - suffix.length));
9
+ return {
10
+ value: value.slice(0, selectionStart) + core + value.slice(selectionEnd),
11
+ selectionStart,
12
+ selectionEnd: selectionStart + core.length
13
+ };
14
+ }
15
+ if (selectionStart >= prefix.length && value.slice(selectionStart - prefix.length, selectionStart) === prefix && value.slice(selectionEnd, selectionEnd + suffix.length) === suffix) {
16
+ const start = selectionStart - prefix.length;
17
+ const core = keep(selected);
18
+ return {
19
+ value: value.slice(0, start) + core + value.slice(selectionEnd + suffix.length),
20
+ selectionStart: start,
21
+ selectionEnd: start + core.length
22
+ };
23
+ }
24
+ return null;
25
+ }
26
+ function wrapInline(action, { value, selectionStart, selectionEnd }) {
27
+ const selected = value.slice(selectionStart, selectionEnd);
28
+ const leadingLength = selected.length - selected.trimStart().length;
29
+ const trailingLength = selected.length - selected.trimEnd().length;
30
+ const core = selected.slice(leadingLength, selected.length - trailingLength) || action.placeholder;
31
+ let before = selected.slice(0, leadingLength);
32
+ if (!before && selectionStart > 0 && fusesWithMarker(value[selectionStart - 1])) before = " ";
33
+ let after = selected.slice(selected.length - trailingLength);
34
+ if (!after && selectionEnd < value.length && fusesWithMarker(value[selectionEnd])) after = " ";
35
+ const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
36
+ const start = selectionStart + before.length + action.prefix.length;
37
+ return {
38
+ value: value_,
39
+ selectionStart: start,
40
+ selectionEnd: start + core.length
41
+ };
42
+ }
43
+ function wrapBlock(action, { value, selectionStart, selectionEnd }) {
44
+ const core = value.slice(selectionStart, selectionEnd) || action.placeholder;
45
+ const before = selectionStart > 0 && value[selectionStart - 1] !== "\n" ? "\n" : "";
46
+ const after = selectionEnd < value.length && value[selectionEnd] !== "\n" ? "\n" : "";
47
+ const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
48
+ const start = selectionStart + before.length + action.prefix.length;
49
+ return {
50
+ value: value_,
51
+ selectionStart: start,
52
+ selectionEnd: start + core.length
53
+ };
54
+ }
55
+ function applyWrap(action, selection) {
56
+ if (action.block) return wrapBlock(action, selection);
57
+ return stripWrap(action, selection) ?? wrapInline(action, selection);
58
+ }
59
+ function toggleLinePrefix(action, line) {
60
+ if (!action.family) return action.linePrefix + line;
61
+ const existing = action.family.exec(line)?.[0] ?? "";
62
+ const stripped = line.slice(existing.length);
63
+ if (existing === action.linePrefix && action.toggle !== false) return stripped;
64
+ return action.linePrefix + stripped;
65
+ }
66
+ function applyLinePrefix(action, { value, selectionStart, selectionEnd }) {
67
+ const lineStart = selectionStart === 0 ? 0 : value.lastIndexOf("\n", selectionStart - 1) + 1;
68
+ const nextNewline = value.indexOf("\n", selectionEnd);
69
+ const lineEnd = nextNewline === -1 ? value.length : nextNewline;
70
+ const prefixed = value.slice(lineStart, lineEnd).split("\n").map((line) => toggleLinePrefix(action, line)).join("\n");
71
+ return {
72
+ value: value.slice(0, lineStart) + prefixed + value.slice(lineEnd),
73
+ selectionStart: lineStart,
74
+ selectionEnd: lineStart + prefixed.length
75
+ };
76
+ }
77
+ function fenceEndAfter(value, pos) {
78
+ let offset = 0;
79
+ let openStart = -1;
80
+ for (const line of value.split("\n")) {
81
+ const lineEnd = offset + line.length;
82
+ if (line.startsWith("```")) {
83
+ if (openStart === -1) openStart = offset;
84
+ else {
85
+ if (pos >= openStart && pos <= lineEnd) return lineEnd;
86
+ openStart = -1;
87
+ }
88
+ }
89
+ offset = lineEnd + 1;
90
+ }
91
+ return null;
92
+ }
93
+ function applyInsert(action, { value, selectionStart, selectionEnd }) {
94
+ const fenceEnd = fenceEndAfter(value, selectionStart);
95
+ const at = fenceEnd ?? selectionEnd;
96
+ const from = fenceEnd ?? selectionStart;
97
+ const value_ = value.slice(0, from) + action.snippet + value.slice(at);
98
+ const caret = from + action.snippet.length;
99
+ return {
100
+ value: value_,
101
+ selectionStart: caret,
102
+ selectionEnd: caret
103
+ };
104
+ }
105
+ /**
106
+ * Pure transform: applies a toolbar `action` to the given selection and returns the next
107
+ * source plus the selection to restore around the inserted markdown. No DOM access.
108
+ */
109
+ function applyAction(action, selection) {
110
+ switch (action.kind) {
111
+ case "wrap": return applyWrap(action, selection);
112
+ case "linePrefix": return applyLinePrefix(action, selection);
113
+ case "insert": return applyInsert(action, selection);
114
+ }
115
+ }
116
+ export { applyAction as t };
@@ -0,0 +1,15 @@
1
+ import { t as CodeBlockSlot } from "./themeTypes-C4kTtkIA.mjs";
2
+ import { ReactNode } from "react";
3
+ import { SlotProps } from "@gild-ui/react";
4
+ import { ViewProps } from "@gild-ui/react/View";
5
+ interface CodeBlockProps extends ViewProps {
6
+ children: ReactNode;
7
+ /** Overrides for the slots a theme can style: `style`, `className`, `data-*` and `aria-*`. */
8
+ slotProps?: SlotProps<CodeBlockSlot>;
9
+ }
10
+ /**
11
+ * Fenced-code block: a horizontally scrollable, syntax-highlighted surface with a
12
+ * copy-to-clipboard button that sticks to the top-right while the block is in view.
13
+ */
14
+ declare function CodeBlock({ children, slotProps, style, className, ...rest }: Readonly<CodeBlockProps>): import("react").JSX.Element;
15
+ export { CodeBlockProps as n, CodeBlock as t };
@@ -0,0 +1,24 @@
1
+ import "./themeTypes-C4kTtkIA.cjs";
2
+ interface DiagramViewerProps {
3
+ /** The rendered mermaid SVG markup. */
4
+ svg: string;
5
+ /** Show the expand-to-fullscreen control and dialog. Off for the nested (in-dialog) viewer. */
6
+ expandable?: boolean;
7
+ /** Fill the parent's height - used by the viewer inside the fullscreen dialog. */
8
+ fill?: boolean;
9
+ }
10
+ /** DiagramViewer props a consumer may set - `svg` and `fill` are managed internally. */
11
+ type DiagramProps = Omit<DiagramViewerProps, 'svg' | 'fill'>;
12
+ interface MermaidProps {
13
+ /** The mermaid diagram source - the body of a ` ```mermaid ` fenced block. */
14
+ chart: string;
15
+ /** Props forwarded to the diagram's zoom/pan viewer (e.g. `expandable`). */
16
+ diagram?: DiagramProps;
17
+ }
18
+ /**
19
+ * Renders a mermaid diagram. Until the client renders the SVG - and if the source is
20
+ * invalid - it falls back to the diagram source in a `CodeBlock`, so server output and
21
+ * no-JS readers still show something useful and hydration stays stable.
22
+ */
23
+ declare function Mermaid({ chart, diagram }: Readonly<MermaidProps>): import("react").JSX.Element;
24
+ export { Mermaid as n, MermaidProps as r, DiagramProps as t };
@@ -0,0 +1,57 @@
1
+ import "./themeTypes-C4kTtkIA.mjs";
2
+ import { n as CodeBlockProps } from "./index-BBkHCbE7.mjs";
3
+ import { r as MermaidProps } from "./index-CyddYU7P.mjs";
4
+ import { TypographyProps } from "@gild-ui/react/Typography";
5
+ import { SlotProps, StyleOverride } from "@gild-ui/react";
6
+ import { ViewProps } from "@gild-ui/react/View";
7
+ import { QuoteProps } from "@gild-ui/react/Quote";
8
+ import { CheckboxProps } from "@gild-ui/react/Checkbox";
9
+ import { ImageProps } from "@gild-ui/react/Image";
10
+ import { LinkProps } from "@gild-ui/react/Link";
11
+ import { TableBodyProps, TableCellProps, TableHeadProps, TableProps, TableRowProps } from "@gild-ui/react/Table";
12
+ /**
13
+ * Per-element prop overrides, merged over the design-system defaults (the caller's props win).
14
+ * Keyed by markdown element - e.g. `slotProps={{ p: { color: 'primary' }, h1: { variant: 'h2' } }}` -
15
+ * and by the one slot a theme can style, `root`, which takes a `style`, a `className` and `data-*`
16
+ * and `aria-*` attributes. No markdown element is named `root`.
17
+ */
18
+ interface PreviewSlotProps extends SlotProps<'root'> {
19
+ h1?: TypographyProps;
20
+ h2?: TypographyProps;
21
+ h3?: TypographyProps;
22
+ h4?: TypographyProps;
23
+ h5?: TypographyProps;
24
+ h6?: TypographyProps;
25
+ p?: TypographyProps;
26
+ strong?: TypographyProps;
27
+ em?: TypographyProps;
28
+ li?: TypographyProps;
29
+ code?: TypographyProps;
30
+ a?: LinkProps;
31
+ ul?: ViewProps;
32
+ ol?: ViewProps;
33
+ hr?: ViewProps;
34
+ blockquote?: QuoteProps;
35
+ img?: ImageProps;
36
+ th?: TableCellProps;
37
+ td?: TableCellProps;
38
+ pre?: CodeBlockProps;
39
+ input?: CheckboxProps;
40
+ table?: TableProps;
41
+ thead?: TableHeadProps;
42
+ tbody?: TableBodyProps;
43
+ tr?: TableRowProps;
44
+ /** Props for a ` ```mermaid ` fence's `Mermaid` renderer - including `diagram` (viewer) props. */
45
+ mermaid?: Omit<MermaidProps, 'chart'>;
46
+ }
47
+ interface PreviewProps {
48
+ /** The markdown source to render. */
49
+ children: string;
50
+ /** Per-element prop overrides, merged over the defaults. */
51
+ slotProps?: PreviewSlotProps;
52
+ /** Overrides the CSS of the root: an entry of `StyleSheet.create`, or a list of them. It wins over `slotProps.root.style`. */
53
+ style?: StyleOverride;
54
+ }
55
+ /** Renders a markdown string with every element mapped to a design-system primitive. */
56
+ declare function Preview({ children, slotProps, style }: Readonly<PreviewProps>): import("react").JSX.Element;
57
+ export { PreviewProps as n, PreviewSlotProps as r, Preview as t };
@@ -0,0 +1,24 @@
1
+ import "./themeTypes-C4kTtkIA.mjs";
2
+ interface DiagramViewerProps {
3
+ /** The rendered mermaid SVG markup. */
4
+ svg: string;
5
+ /** Show the expand-to-fullscreen control and dialog. Off for the nested (in-dialog) viewer. */
6
+ expandable?: boolean;
7
+ /** Fill the parent's height - used by the viewer inside the fullscreen dialog. */
8
+ fill?: boolean;
9
+ }
10
+ /** DiagramViewer props a consumer may set - `svg` and `fill` are managed internally. */
11
+ type DiagramProps = Omit<DiagramViewerProps, 'svg' | 'fill'>;
12
+ interface MermaidProps {
13
+ /** The mermaid diagram source - the body of a ` ```mermaid ` fenced block. */
14
+ chart: string;
15
+ /** Props forwarded to the diagram's zoom/pan viewer (e.g. `expandable`). */
16
+ diagram?: DiagramProps;
17
+ }
18
+ /**
19
+ * Renders a mermaid diagram. Until the client renders the SVG - and if the source is
20
+ * invalid - it falls back to the diagram source in a `CodeBlock`, so server output and
21
+ * no-JS readers still show something useful and hydration stays stable.
22
+ */
23
+ declare function Mermaid({ chart, diagram }: Readonly<MermaidProps>): import("react").JSX.Element;
24
+ export { Mermaid as n, MermaidProps as r, DiagramProps as t };
package/dist/index.cjs ADDED
@@ -0,0 +1,21 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_MarkdownContext = require("./MarkdownContext-DS1X9B6N.cjs");
3
+ const require_Control = require("./Control.cjs");
4
+ const require_Toolbar = require("./Toolbar-gk3KJhCE.cjs");
5
+ const require_Editor = require("./Editor.cjs");
6
+ const require_CodeBlock = require("./CodeBlock.cjs");
7
+ const require_Mermaid = require("./Mermaid-D_tCNrQ9.cjs");
8
+ const require_Preview = require("./Preview-D-AL97QU.cjs");
9
+ const require_LiveEdit = require("./LiveEdit-B83sDZXu.cjs");
10
+ exports.CodeBlock = require_CodeBlock.CodeBlock;
11
+ exports.Control = require_Control.Control;
12
+ exports.Editor = require_Editor.Editor;
13
+ exports.LiveEdit = require_LiveEdit.LiveEdit;
14
+ exports.MarkdownContext = require_MarkdownContext.MarkdownContext;
15
+ exports.Mermaid = require_Mermaid.Mermaid;
16
+ exports.Preview = require_Preview.Preview;
17
+ exports.TablePicker = require_Toolbar.TablePicker;
18
+ exports.Toolbar = require_Toolbar.Toolbar;
19
+ exports.syntaxDark = require_CodeBlock.syntaxDark;
20
+ exports.syntaxLight = require_CodeBlock.syntaxLight;
21
+ exports.useMarkdownContext = require_MarkdownContext.useMarkdownContext;
@@ -0,0 +1,80 @@
1
+ import { Control, ControlProps } from "./Control.cjs";
2
+ import { TablePicker, TablePickerProps, Toolbar, ToolbarProps } from "./Toolbar.cjs";
3
+ import { Editor, EditorProps } from "./Editor.cjs";
4
+ import { LiveEdit, LiveEditProps } from "./LiveEdit.cjs";
5
+ import { Preview, PreviewProps, PreviewSlotProps } from "./Preview.cjs";
6
+ import { CodeBlock, CodeBlockProps } from "./CodeBlock.cjs";
7
+ import { n as Mermaid, r as MermaidProps, t as DiagramProps } from "./index-BVYb370O.cjs";
8
+ import { a as ThemeSyntax, i as MermaidThemeVariables, n as MarkdownLiveEditSlot, o as syntaxDark, r as MarkdownToolbarSlot, s as syntaxLight, t as CodeBlockSlot } from "./themeTypes-C4kTtkIA.cjs";
9
+ import { IconName } from "@gild-ui/react/Icon";
10
+ /** How a text label is rendered - mirrors the mark it inserts. */
11
+ type ToolbarLabelEmphasis = 'bold' | 'italic' | 'strike';
12
+ /** Shared presentation for a toolbar control. */
13
+ interface BaseAction {
14
+ id: string;
15
+ /** Text label shown when no `icon` is set. */
16
+ label: string;
17
+ /** Accessible name - always the control's aria-label. */
18
+ ariaLabel: string;
19
+ /** Registry icon shown instead of the text label. */
20
+ icon?: IconName;
21
+ /** Styles the text label to mirror the mark (e.g. bold `B`). Ignored when `icon` is set. */
22
+ emphasis?: ToolbarLabelEmphasis;
23
+ /** Consecutive actions sharing a group id render as one joined button cluster. */
24
+ group?: string;
25
+ }
26
+ /** Wraps the selection (or a placeholder) in a leading/trailing marker - bold, links, code blocks. */
27
+ interface WrapAction extends BaseAction {
28
+ kind: 'wrap';
29
+ prefix: string;
30
+ suffix: string;
31
+ placeholder: string;
32
+ /** Block-level fence (e.g. code block): separated by newlines and never toggled off. */
33
+ block?: boolean;
34
+ }
35
+ /** Prepends a marker to every line the selection touches - headings, quotes, lists. */
36
+ interface LinePrefixAction extends BaseAction {
37
+ kind: 'linePrefix';
38
+ linePrefix: string;
39
+ /**
40
+ * Line-start pattern for a family of mutually-exclusive markers (e.g. all list types). When
41
+ * set, applying the action strips any matching marker first, then toggles its own off or
42
+ * replaces a sibling's - so the list/ordered/task buttons swap and toggle instead of stacking.
43
+ */
44
+ family?: RegExp;
45
+ /**
46
+ * Whether re-applying an action that already owns the line's marker removes it. Defaults to
47
+ * toggling off; set `false` for replace-only families (e.g. heading levels from a select,
48
+ * where picking a level should set it, not toggle it away).
49
+ */
50
+ toggle?: boolean;
51
+ }
52
+ /** Inserts a standalone snippet at the caret, ignoring the selection - tables, rules. */
53
+ interface InsertAction extends BaseAction {
54
+ kind: 'insert';
55
+ snippet: string;
56
+ }
57
+ type ToolbarAction = WrapAction | LinePrefixAction | InsertAction;
58
+ /** A textarea selection range shared between the Editor and the Toolbar. */
59
+ export interface MarkdownSelection {
60
+ start: number;
61
+ end: number;
62
+ }
63
+ export interface MarkdownContextValue {
64
+ /** Current markdown source. */
65
+ value: string;
66
+ /** Called with the next source on edit or a toolbar action. */
67
+ onChange: (value: string) => void;
68
+ /** Applies a toolbar action at the last remembered selection and queues the caret to restore. */
69
+ dispatch: (action: ToolbarAction) => void;
70
+ /** Records the current textarea selection - the Editor calls this on select/blur. */
71
+ rememberSelection: (selection: MarkdownSelection) => void;
72
+ /** Queues a selection to restore after the next value change (e.g. after Tab). */
73
+ queueSelection: (selection: MarkdownSelection) => void;
74
+ /** Returns and clears the queued selection - the Editor's effect calls this to restore focus. */
75
+ takeQueuedSelection: () => MarkdownSelection | null;
76
+ }
77
+ export declare const MarkdownContext: import("react").Context<MarkdownContextValue | null>;
78
+ /** Reads the Markdown compound context; throws if used outside `<Markdown.Control>`. */
79
+ export declare function useMarkdownContext(): MarkdownContextValue;
80
+ export { CodeBlock, CodeBlockProps, CodeBlockSlot, Control, ControlProps, DiagramProps, Editor, EditorProps, LiveEdit, LiveEditProps, MarkdownLiveEditSlot, MarkdownToolbarSlot, Mermaid, MermaidProps, MermaidThemeVariables, Preview, PreviewProps, PreviewSlotProps, TablePicker, TablePickerProps, ThemeSyntax, Toolbar, ToolbarProps, syntaxDark, syntaxLight };
@@ -0,0 +1,80 @@
1
+ import { Control, ControlProps } from "./Control.mjs";
2
+ import { TablePicker, TablePickerProps, Toolbar, ToolbarProps } from "./Toolbar.mjs";
3
+ import { Editor, EditorProps } from "./Editor.mjs";
4
+ import { LiveEdit, LiveEditProps } from "./LiveEdit.mjs";
5
+ import { n as PreviewProps, r as PreviewSlotProps, t as Preview } from "./index-CfPKWPpM.mjs";
6
+ import { n as CodeBlockProps, t as CodeBlock } from "./index-BBkHCbE7.mjs";
7
+ import { n as Mermaid, r as MermaidProps, t as DiagramProps } from "./index-CyddYU7P.mjs";
8
+ import { a as ThemeSyntax, i as MermaidThemeVariables, n as MarkdownLiveEditSlot, o as syntaxDark, r as MarkdownToolbarSlot, s as syntaxLight, t as CodeBlockSlot } from "./themeTypes-C4kTtkIA.mjs";
9
+ import { IconName } from "@gild-ui/react/Icon";
10
+ /** How a text label is rendered - mirrors the mark it inserts. */
11
+ type ToolbarLabelEmphasis = 'bold' | 'italic' | 'strike';
12
+ /** Shared presentation for a toolbar control. */
13
+ interface BaseAction {
14
+ id: string;
15
+ /** Text label shown when no `icon` is set. */
16
+ label: string;
17
+ /** Accessible name - always the control's aria-label. */
18
+ ariaLabel: string;
19
+ /** Registry icon shown instead of the text label. */
20
+ icon?: IconName;
21
+ /** Styles the text label to mirror the mark (e.g. bold `B`). Ignored when `icon` is set. */
22
+ emphasis?: ToolbarLabelEmphasis;
23
+ /** Consecutive actions sharing a group id render as one joined button cluster. */
24
+ group?: string;
25
+ }
26
+ /** Wraps the selection (or a placeholder) in a leading/trailing marker - bold, links, code blocks. */
27
+ interface WrapAction extends BaseAction {
28
+ kind: 'wrap';
29
+ prefix: string;
30
+ suffix: string;
31
+ placeholder: string;
32
+ /** Block-level fence (e.g. code block): separated by newlines and never toggled off. */
33
+ block?: boolean;
34
+ }
35
+ /** Prepends a marker to every line the selection touches - headings, quotes, lists. */
36
+ interface LinePrefixAction extends BaseAction {
37
+ kind: 'linePrefix';
38
+ linePrefix: string;
39
+ /**
40
+ * Line-start pattern for a family of mutually-exclusive markers (e.g. all list types). When
41
+ * set, applying the action strips any matching marker first, then toggles its own off or
42
+ * replaces a sibling's - so the list/ordered/task buttons swap and toggle instead of stacking.
43
+ */
44
+ family?: RegExp;
45
+ /**
46
+ * Whether re-applying an action that already owns the line's marker removes it. Defaults to
47
+ * toggling off; set `false` for replace-only families (e.g. heading levels from a select,
48
+ * where picking a level should set it, not toggle it away).
49
+ */
50
+ toggle?: boolean;
51
+ }
52
+ /** Inserts a standalone snippet at the caret, ignoring the selection - tables, rules. */
53
+ interface InsertAction extends BaseAction {
54
+ kind: 'insert';
55
+ snippet: string;
56
+ }
57
+ type ToolbarAction = WrapAction | LinePrefixAction | InsertAction;
58
+ /** A textarea selection range shared between the Editor and the Toolbar. */
59
+ export interface MarkdownSelection {
60
+ start: number;
61
+ end: number;
62
+ }
63
+ export interface MarkdownContextValue {
64
+ /** Current markdown source. */
65
+ value: string;
66
+ /** Called with the next source on edit or a toolbar action. */
67
+ onChange: (value: string) => void;
68
+ /** Applies a toolbar action at the last remembered selection and queues the caret to restore. */
69
+ dispatch: (action: ToolbarAction) => void;
70
+ /** Records the current textarea selection - the Editor calls this on select/blur. */
71
+ rememberSelection: (selection: MarkdownSelection) => void;
72
+ /** Queues a selection to restore after the next value change (e.g. after Tab). */
73
+ queueSelection: (selection: MarkdownSelection) => void;
74
+ /** Returns and clears the queued selection - the Editor's effect calls this to restore focus. */
75
+ takeQueuedSelection: () => MarkdownSelection | null;
76
+ }
77
+ export declare const MarkdownContext: import("react").Context<MarkdownContextValue | null>;
78
+ /** Reads the Markdown compound context; throws if used outside `<Markdown.Control>`. */
79
+ export declare function useMarkdownContext(): MarkdownContextValue;
80
+ export { CodeBlock, CodeBlockProps, CodeBlockSlot, Control, ControlProps, DiagramProps, Editor, EditorProps, LiveEdit, LiveEditProps, MarkdownLiveEditSlot, MarkdownToolbarSlot, Mermaid, MermaidProps, MermaidThemeVariables, Preview, PreviewProps, PreviewSlotProps, TablePicker, TablePickerProps, ThemeSyntax, Toolbar, ToolbarProps, syntaxDark, syntaxLight };
package/dist/index.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import { n as useMarkdownContext, t as MarkdownContext } from "./MarkdownContext-D28Czdll.mjs";
2
+ import { Control } from "./Control.mjs";
3
+ import { n as TablePicker, t as Toolbar } from "./Toolbar-Eg7KmYbK.mjs";
4
+ import { Editor } from "./Editor.mjs";
5
+ import { CodeBlock, syntaxDark, syntaxLight } from "./CodeBlock.mjs";
6
+ import { t as Mermaid } from "./Mermaid-DW0NuDS-.mjs";
7
+ import { t as Preview } from "./Preview-BLXtPaa9.mjs";
8
+ import { t as LiveEdit } from "./LiveEdit-1-8cA5Xw.mjs";
9
+ export { CodeBlock, Control, Editor, LiveEdit, MarkdownContext, Mermaid, Preview, TablePicker, Toolbar, syntaxDark, syntaxLight, useMarkdownContext };
@@ -0,0 +1,19 @@
1
+ // src/utils/mergeOverrides.ts
2
+ /**
3
+ * The override of a root: `slotProps.root` first, then the `style` and `className` props, so they
4
+ * win. One style stays as it is, not wrapped in a list, and an unset one adds nothing to the element.
5
+ */
6
+ function mergeOverrides(...parts) {
7
+ const styles = parts.flatMap((part) => part?.style ? [part.style] : []);
8
+ return {
9
+ ...Object.assign({}, ...parts),
10
+ className: parts.flatMap((part) => part?.className ? [part.className] : []).join(" ") || void 0,
11
+ style: styles.length > 1 ? styles : styles[0]
12
+ };
13
+ }
14
+ Object.defineProperty(exports, "mergeOverrides", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return mergeOverrides;
18
+ }
19
+ });
@@ -0,0 +1,14 @@
1
+ // src/utils/mergeOverrides.ts
2
+ /**
3
+ * The override of a root: `slotProps.root` first, then the `style` and `className` props, so they
4
+ * win. One style stays as it is, not wrapped in a list, and an unset one adds nothing to the element.
5
+ */
6
+ function mergeOverrides(...parts) {
7
+ const styles = parts.flatMap((part) => part?.style ? [part.style] : []);
8
+ return {
9
+ ...Object.assign({}, ...parts),
10
+ className: parts.flatMap((part) => part?.className ? [part.className] : []).join(" ") || void 0,
11
+ style: styles.length > 1 ? styles : styles[0]
12
+ };
13
+ }
14
+ export { mergeOverrides as t };
@@ -0,0 +1,27 @@
1
+ // \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ Object.defineProperty(exports, "__toESM", {
23
+ enumerable: true,
24
+ get: function() {
25
+ return __toESM;
26
+ }
27
+ });