@gild-ui/react-markdown 0.1.0-alpha.0 → 0.1.0-alpha.2
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/dist/CodeBlock-BFqv_nVv.mjs +134 -0
- package/dist/CodeBlock-BaMe7CiF.cjs +151 -0
- package/dist/CodeBlock.cjs +4 -135
- package/dist/CodeBlock.mjs +1 -133
- package/dist/{LiveEdit-B83sDZXu.cjs → LiveEdit-CXw-vQpD.cjs} +1 -1
- package/dist/{LiveEdit-1-8cA5Xw.mjs → LiveEdit-CzJcNsEo.mjs} +1 -1
- package/dist/LiveEdit.cjs +1 -1
- package/dist/LiveEdit.mjs +1 -1
- package/dist/{Mermaid-DW0NuDS-.mjs → Mermaid-DR4XzGaY.mjs} +1 -1
- package/dist/{Mermaid-D_tCNrQ9.cjs → Mermaid-d1a5LqcK.cjs} +1 -1
- package/dist/Mermaid.cjs +1 -1
- package/dist/Mermaid.mjs +1 -1
- package/dist/{Preview-D-AL97QU.cjs → Preview-CIbu-nRm.cjs} +2 -2
- package/dist/{Preview-BLXtPaa9.mjs → Preview-DQOQ1NKJ.mjs} +2 -2
- package/dist/Preview.cjs +1 -1
- package/dist/Preview.mjs +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +19 -16
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { t as mergeOverrides } from "./mergeOverrides-DEbU7yDg.mjs";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Button } from "@gild-ui/react/Button";
|
|
5
|
+
import { Icon } from "@gild-ui/react/Icon";
|
|
6
|
+
import { styled } from "@gild-ui/react";
|
|
7
|
+
import { View } from "@gild-ui/react/View";
|
|
8
|
+
import { useCopyToClipboard } from "@gild-ui/hooks/useCopyToClipboard";
|
|
9
|
+
// src/CodeBlock/CodeBlock.syntax.ts
|
|
10
|
+
const syntaxStyles = ({ theme }) => ({
|
|
11
|
+
color: theme.syntax.base,
|
|
12
|
+
fontFamily: theme.syntax.font,
|
|
13
|
+
"& .hljs-comment, & .hljs-quote, & .hljs-doctag, & .hljs-meta.prompt_": {
|
|
14
|
+
color: theme.syntax.comment,
|
|
15
|
+
fontStyle: "italic"
|
|
16
|
+
},
|
|
17
|
+
"& .hljs-keyword, & .hljs-built_in, & .hljs-literal, & .hljs-selector-tag, & .hljs-selector-pseudo, & .hljs-selector-attr": { color: theme.syntax.keyword },
|
|
18
|
+
"& .hljs-type, & .hljs-title.class_": { color: theme.syntax.type },
|
|
19
|
+
"& .hljs-string, & .hljs-regexp, & .hljs-char, & .hljs-meta .hljs-string, & .hljs-addition": { color: theme.syntax.string },
|
|
20
|
+
"& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-link": { color: theme.syntax.number },
|
|
21
|
+
"& .hljs-variable.constant_, & .hljs-property": { color: theme.syntax.constant },
|
|
22
|
+
"& .hljs-title, & .hljs-section, & .hljs-attr, & .hljs-attribute, & .hljs-selector-id": { color: theme.syntax.title },
|
|
23
|
+
"& .hljs-tag, & .hljs-name, & .hljs-meta, & .hljs-variable, & .hljs-selector-class, & .hljs-deletion": { color: theme.syntax.tag },
|
|
24
|
+
"& .hljs-emphasis": { fontStyle: "italic" },
|
|
25
|
+
"& .hljs-strong": { fontWeight: "bold" }
|
|
26
|
+
});
|
|
27
|
+
// src/CodeBlock/CodeBlock.tsx
|
|
28
|
+
const CodeSurface = styled(View, {
|
|
29
|
+
name: "CodeBlock",
|
|
30
|
+
slot: "surface",
|
|
31
|
+
label: "CodeSurface"
|
|
32
|
+
})(syntaxStyles);
|
|
33
|
+
const Wrapper = styled(View, {
|
|
34
|
+
name: "CodeBlock",
|
|
35
|
+
label: "CodeBlock"
|
|
36
|
+
})({
|
|
37
|
+
display: "grid",
|
|
38
|
+
gridTemplateColumns: "minmax(0, 1fr)",
|
|
39
|
+
"& .code-copy": {
|
|
40
|
+
opacity: 0,
|
|
41
|
+
transition: "opacity 120ms ease"
|
|
42
|
+
},
|
|
43
|
+
"&:hover .code-copy, &:focus-within .code-copy": { opacity: 1 },
|
|
44
|
+
"@media (hover: none)": { "& .code-copy": { opacity: 1 } }
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Fenced-code block: a horizontally scrollable, syntax-highlighted surface with a
|
|
48
|
+
* copy-to-clipboard button that sticks to the top-right while the block is in view.
|
|
49
|
+
*/
|
|
50
|
+
function CodeBlock({ children, slotProps, style, className, ...rest }) {
|
|
51
|
+
const surfaceRef = useRef(null);
|
|
52
|
+
const { copied, copy } = useCopyToClipboard();
|
|
53
|
+
const handleCopy = () => {
|
|
54
|
+
const raw = surfaceRef.current.textContent;
|
|
55
|
+
let end = raw.length;
|
|
56
|
+
while (end > 0 && raw[end - 1] === "\n") end--;
|
|
57
|
+
const text = raw.slice(0, end);
|
|
58
|
+
if (text) copy(text);
|
|
59
|
+
};
|
|
60
|
+
return /* @__PURE__ */ jsxs(Wrapper, {
|
|
61
|
+
my: 2,
|
|
62
|
+
position: "relative",
|
|
63
|
+
...rest,
|
|
64
|
+
...mergeOverrides(slotProps?.root, {
|
|
65
|
+
style,
|
|
66
|
+
className
|
|
67
|
+
}),
|
|
68
|
+
children: [/* @__PURE__ */ jsx(View, {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
top: "8px",
|
|
71
|
+
right: "8px",
|
|
72
|
+
zIndex: 1,
|
|
73
|
+
bg: "paper",
|
|
74
|
+
borderRadius: "sm",
|
|
75
|
+
className: "code-copy",
|
|
76
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
77
|
+
type: "button",
|
|
78
|
+
variant: "outlined",
|
|
79
|
+
color: "default",
|
|
80
|
+
size: "sm",
|
|
81
|
+
borderRadius: "sm",
|
|
82
|
+
onClick: handleCopy,
|
|
83
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
84
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
85
|
+
name: copied ? "check" : "content_copy",
|
|
86
|
+
color: copied ? "success" : "primary",
|
|
87
|
+
size: "1.1rem"
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
}), /* @__PURE__ */ jsx(CodeSurface, {
|
|
91
|
+
...slotProps?.surface,
|
|
92
|
+
as: "pre",
|
|
93
|
+
tabIndex: 0,
|
|
94
|
+
ref: surfaceRef,
|
|
95
|
+
bg: "terminal",
|
|
96
|
+
p: 3,
|
|
97
|
+
borderRadius: "md",
|
|
98
|
+
borderColor: "light",
|
|
99
|
+
borderWidth: "thin",
|
|
100
|
+
maxWidth: "100%",
|
|
101
|
+
overflow: "auto",
|
|
102
|
+
children
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// src/CodeBlock/CodeBlock.data.ts
|
|
107
|
+
const font = "'JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace";
|
|
108
|
+
/** Matched to the JetBrains "Islands Dark" editor scheme. */
|
|
109
|
+
const syntaxDark = {
|
|
110
|
+
base: "#BBBBBB",
|
|
111
|
+
keyword: "#CF8E6D",
|
|
112
|
+
string: "#6AAB73",
|
|
113
|
+
number: "#2AACB8",
|
|
114
|
+
title: "#6BA9FA",
|
|
115
|
+
constant: "#C77DBB",
|
|
116
|
+
type: "#2AACB8",
|
|
117
|
+
comment: "#919191",
|
|
118
|
+
tag: "#D5B778",
|
|
119
|
+
font
|
|
120
|
+
};
|
|
121
|
+
/** Matched to the JetBrains "Islands Light" editor scheme. */
|
|
122
|
+
const syntaxLight = {
|
|
123
|
+
base: "#080808",
|
|
124
|
+
keyword: "#0033B3",
|
|
125
|
+
string: "#067D17",
|
|
126
|
+
number: "#1750EB",
|
|
127
|
+
title: "#00627A",
|
|
128
|
+
constant: "#871094",
|
|
129
|
+
type: "#007E8A",
|
|
130
|
+
comment: "#8C8C8C",
|
|
131
|
+
tag: "#008077",
|
|
132
|
+
font
|
|
133
|
+
};
|
|
134
|
+
export { syntaxLight as n, CodeBlock as r, syntaxDark as t };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const require_mergeOverrides = require("./mergeOverrides-D2btS1Jb.cjs");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
let _gild_ui_react_Button = require("@gild-ui/react/Button");
|
|
5
|
+
let _gild_ui_react_Icon = require("@gild-ui/react/Icon");
|
|
6
|
+
let _gild_ui_react = require("@gild-ui/react");
|
|
7
|
+
let _gild_ui_react_View = require("@gild-ui/react/View");
|
|
8
|
+
let _gild_ui_hooks_useCopyToClipboard = require("@gild-ui/hooks/useCopyToClipboard");
|
|
9
|
+
// src/CodeBlock/CodeBlock.syntax.ts
|
|
10
|
+
const syntaxStyles = ({ theme }) => ({
|
|
11
|
+
color: theme.syntax.base,
|
|
12
|
+
fontFamily: theme.syntax.font,
|
|
13
|
+
"& .hljs-comment, & .hljs-quote, & .hljs-doctag, & .hljs-meta.prompt_": {
|
|
14
|
+
color: theme.syntax.comment,
|
|
15
|
+
fontStyle: "italic"
|
|
16
|
+
},
|
|
17
|
+
"& .hljs-keyword, & .hljs-built_in, & .hljs-literal, & .hljs-selector-tag, & .hljs-selector-pseudo, & .hljs-selector-attr": { color: theme.syntax.keyword },
|
|
18
|
+
"& .hljs-type, & .hljs-title.class_": { color: theme.syntax.type },
|
|
19
|
+
"& .hljs-string, & .hljs-regexp, & .hljs-char, & .hljs-meta .hljs-string, & .hljs-addition": { color: theme.syntax.string },
|
|
20
|
+
"& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-link": { color: theme.syntax.number },
|
|
21
|
+
"& .hljs-variable.constant_, & .hljs-property": { color: theme.syntax.constant },
|
|
22
|
+
"& .hljs-title, & .hljs-section, & .hljs-attr, & .hljs-attribute, & .hljs-selector-id": { color: theme.syntax.title },
|
|
23
|
+
"& .hljs-tag, & .hljs-name, & .hljs-meta, & .hljs-variable, & .hljs-selector-class, & .hljs-deletion": { color: theme.syntax.tag },
|
|
24
|
+
"& .hljs-emphasis": { fontStyle: "italic" },
|
|
25
|
+
"& .hljs-strong": { fontWeight: "bold" }
|
|
26
|
+
});
|
|
27
|
+
// src/CodeBlock/CodeBlock.tsx
|
|
28
|
+
const CodeSurface = (0, _gild_ui_react.styled)(_gild_ui_react_View.View, {
|
|
29
|
+
name: "CodeBlock",
|
|
30
|
+
slot: "surface",
|
|
31
|
+
label: "CodeSurface"
|
|
32
|
+
})(syntaxStyles);
|
|
33
|
+
const Wrapper = (0, _gild_ui_react.styled)(_gild_ui_react_View.View, {
|
|
34
|
+
name: "CodeBlock",
|
|
35
|
+
label: "CodeBlock"
|
|
36
|
+
})({
|
|
37
|
+
display: "grid",
|
|
38
|
+
gridTemplateColumns: "minmax(0, 1fr)",
|
|
39
|
+
"& .code-copy": {
|
|
40
|
+
opacity: 0,
|
|
41
|
+
transition: "opacity 120ms ease"
|
|
42
|
+
},
|
|
43
|
+
"&:hover .code-copy, &:focus-within .code-copy": { opacity: 1 },
|
|
44
|
+
"@media (hover: none)": { "& .code-copy": { opacity: 1 } }
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Fenced-code block: a horizontally scrollable, syntax-highlighted surface with a
|
|
48
|
+
* copy-to-clipboard button that sticks to the top-right while the block is in view.
|
|
49
|
+
*/
|
|
50
|
+
function CodeBlock({ children, slotProps, style, className, ...rest }) {
|
|
51
|
+
const surfaceRef = (0, react.useRef)(null);
|
|
52
|
+
const { copied, copy } = (0, _gild_ui_hooks_useCopyToClipboard.useCopyToClipboard)();
|
|
53
|
+
const handleCopy = () => {
|
|
54
|
+
const raw = surfaceRef.current.textContent;
|
|
55
|
+
let end = raw.length;
|
|
56
|
+
while (end > 0 && raw[end - 1] === "\n") end--;
|
|
57
|
+
const text = raw.slice(0, end);
|
|
58
|
+
if (text) copy(text);
|
|
59
|
+
};
|
|
60
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Wrapper, {
|
|
61
|
+
my: 2,
|
|
62
|
+
position: "relative",
|
|
63
|
+
...rest,
|
|
64
|
+
...require_mergeOverrides.mergeOverrides(slotProps?.root, {
|
|
65
|
+
style,
|
|
66
|
+
className
|
|
67
|
+
}),
|
|
68
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_gild_ui_react_View.View, {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
top: "8px",
|
|
71
|
+
right: "8px",
|
|
72
|
+
zIndex: 1,
|
|
73
|
+
bg: "paper",
|
|
74
|
+
borderRadius: "sm",
|
|
75
|
+
className: "code-copy",
|
|
76
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_gild_ui_react_Button.Button, {
|
|
77
|
+
type: "button",
|
|
78
|
+
variant: "outlined",
|
|
79
|
+
color: "default",
|
|
80
|
+
size: "sm",
|
|
81
|
+
borderRadius: "sm",
|
|
82
|
+
onClick: handleCopy,
|
|
83
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
84
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_gild_ui_react_Icon.Icon, {
|
|
85
|
+
name: copied ? "check" : "content_copy",
|
|
86
|
+
color: copied ? "success" : "primary",
|
|
87
|
+
size: "1.1rem"
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeSurface, {
|
|
91
|
+
...slotProps?.surface,
|
|
92
|
+
as: "pre",
|
|
93
|
+
tabIndex: 0,
|
|
94
|
+
ref: surfaceRef,
|
|
95
|
+
bg: "terminal",
|
|
96
|
+
p: 3,
|
|
97
|
+
borderRadius: "md",
|
|
98
|
+
borderColor: "light",
|
|
99
|
+
borderWidth: "thin",
|
|
100
|
+
maxWidth: "100%",
|
|
101
|
+
overflow: "auto",
|
|
102
|
+
children
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// src/CodeBlock/CodeBlock.data.ts
|
|
107
|
+
const font = "'JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace";
|
|
108
|
+
/** Matched to the JetBrains "Islands Dark" editor scheme. */
|
|
109
|
+
const syntaxDark = {
|
|
110
|
+
base: "#BBBBBB",
|
|
111
|
+
keyword: "#CF8E6D",
|
|
112
|
+
string: "#6AAB73",
|
|
113
|
+
number: "#2AACB8",
|
|
114
|
+
title: "#6BA9FA",
|
|
115
|
+
constant: "#C77DBB",
|
|
116
|
+
type: "#2AACB8",
|
|
117
|
+
comment: "#919191",
|
|
118
|
+
tag: "#D5B778",
|
|
119
|
+
font
|
|
120
|
+
};
|
|
121
|
+
/** Matched to the JetBrains "Islands Light" editor scheme. */
|
|
122
|
+
const syntaxLight = {
|
|
123
|
+
base: "#080808",
|
|
124
|
+
keyword: "#0033B3",
|
|
125
|
+
string: "#067D17",
|
|
126
|
+
number: "#1750EB",
|
|
127
|
+
title: "#00627A",
|
|
128
|
+
constant: "#871094",
|
|
129
|
+
type: "#007E8A",
|
|
130
|
+
comment: "#8C8C8C",
|
|
131
|
+
tag: "#008077",
|
|
132
|
+
font
|
|
133
|
+
};
|
|
134
|
+
Object.defineProperty(exports, "CodeBlock", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function() {
|
|
137
|
+
return CodeBlock;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "syntaxDark", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function() {
|
|
143
|
+
return syntaxDark;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(exports, "syntaxLight", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function() {
|
|
149
|
+
return syntaxLight;
|
|
150
|
+
}
|
|
151
|
+
});
|
package/dist/CodeBlock.cjs
CHANGED
|
@@ -1,136 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let _gild_ui_react_Icon = require("@gild-ui/react/Icon");
|
|
7
|
-
let _gild_ui_react = require("@gild-ui/react");
|
|
8
|
-
let _gild_ui_react_View = require("@gild-ui/react/View");
|
|
9
|
-
let _gild_ui_hooks_useCopyToClipboard = require("@gild-ui/hooks/useCopyToClipboard");
|
|
10
|
-
// src/CodeBlock/CodeBlock.tsx
|
|
11
|
-
const syntaxStyles = ({ theme }) => ({
|
|
12
|
-
color: theme.syntax.base,
|
|
13
|
-
fontFamily: theme.syntax.font,
|
|
14
|
-
"& .hljs-comment, & .hljs-quote, & .hljs-doctag, & .hljs-meta.prompt_": {
|
|
15
|
-
color: theme.syntax.comment,
|
|
16
|
-
fontStyle: "italic"
|
|
17
|
-
},
|
|
18
|
-
"& .hljs-keyword, & .hljs-built_in, & .hljs-literal, & .hljs-selector-tag, & .hljs-selector-pseudo, & .hljs-selector-attr": { color: theme.syntax.keyword },
|
|
19
|
-
"& .hljs-type, & .hljs-title.class_": { color: theme.syntax.type },
|
|
20
|
-
"& .hljs-string, & .hljs-regexp, & .hljs-char, & .hljs-meta .hljs-string, & .hljs-addition": { color: theme.syntax.string },
|
|
21
|
-
"& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-link": { color: theme.syntax.number },
|
|
22
|
-
"& .hljs-variable.constant_, & .hljs-property": { color: theme.syntax.constant },
|
|
23
|
-
"& .hljs-title, & .hljs-section, & .hljs-attr, & .hljs-attribute, & .hljs-selector-id": { color: theme.syntax.title },
|
|
24
|
-
"& .hljs-tag, & .hljs-name, & .hljs-meta, & .hljs-variable, & .hljs-selector-class, & .hljs-deletion": { color: theme.syntax.tag },
|
|
25
|
-
"& .hljs-emphasis": { fontStyle: "italic" },
|
|
26
|
-
"& .hljs-strong": { fontWeight: "bold" }
|
|
27
|
-
});
|
|
28
|
-
const CodeSurface = (0, _gild_ui_react.styled)(_gild_ui_react_View.View, {
|
|
29
|
-
name: "CodeBlock",
|
|
30
|
-
slot: "surface",
|
|
31
|
-
label: "CodeSurface"
|
|
32
|
-
})(syntaxStyles);
|
|
33
|
-
const Wrapper = (0, _gild_ui_react.styled)(_gild_ui_react_View.View, {
|
|
34
|
-
name: "CodeBlock",
|
|
35
|
-
label: "CodeBlock"
|
|
36
|
-
})({
|
|
37
|
-
display: "grid",
|
|
38
|
-
gridTemplateColumns: "minmax(0, 1fr)",
|
|
39
|
-
"& .code-copy": {
|
|
40
|
-
opacity: 0,
|
|
41
|
-
transition: "opacity 120ms ease"
|
|
42
|
-
},
|
|
43
|
-
"&:hover .code-copy, &:focus-within .code-copy": { opacity: 1 },
|
|
44
|
-
"@media (hover: none)": { "& .code-copy": { opacity: 1 } }
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* Fenced-code block: a horizontally scrollable, syntax-highlighted surface with a
|
|
48
|
-
* copy-to-clipboard button that sticks to the top-right while the block is in view.
|
|
49
|
-
*/
|
|
50
|
-
function CodeBlock({ children, slotProps, style, className, ...rest }) {
|
|
51
|
-
const surfaceRef = (0, react.useRef)(null);
|
|
52
|
-
const { copied, copy } = (0, _gild_ui_hooks_useCopyToClipboard.useCopyToClipboard)();
|
|
53
|
-
const handleCopy = () => {
|
|
54
|
-
const raw = surfaceRef.current.textContent;
|
|
55
|
-
let end = raw.length;
|
|
56
|
-
while (end > 0 && raw[end - 1] === "\n") end--;
|
|
57
|
-
const text = raw.slice(0, end);
|
|
58
|
-
if (text) copy(text);
|
|
59
|
-
};
|
|
60
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Wrapper, {
|
|
61
|
-
my: 2,
|
|
62
|
-
position: "relative",
|
|
63
|
-
...rest,
|
|
64
|
-
...require_mergeOverrides.mergeOverrides(slotProps?.root, {
|
|
65
|
-
style,
|
|
66
|
-
className
|
|
67
|
-
}),
|
|
68
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_gild_ui_react_View.View, {
|
|
69
|
-
position: "absolute",
|
|
70
|
-
top: "8px",
|
|
71
|
-
right: "8px",
|
|
72
|
-
zIndex: 1,
|
|
73
|
-
bg: "paper",
|
|
74
|
-
borderRadius: "sm",
|
|
75
|
-
className: "code-copy",
|
|
76
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_gild_ui_react_Button.Button, {
|
|
77
|
-
type: "button",
|
|
78
|
-
variant: "outlined",
|
|
79
|
-
color: "default",
|
|
80
|
-
size: "sm",
|
|
81
|
-
borderRadius: "sm",
|
|
82
|
-
onClick: handleCopy,
|
|
83
|
-
"aria-label": copied ? "Copied" : "Copy code",
|
|
84
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_gild_ui_react_Icon.Icon, {
|
|
85
|
-
name: copied ? "check" : "content_copy",
|
|
86
|
-
color: copied ? "success" : "primary",
|
|
87
|
-
size: "1.1rem"
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeSurface, {
|
|
91
|
-
...slotProps?.surface,
|
|
92
|
-
as: "pre",
|
|
93
|
-
tabIndex: 0,
|
|
94
|
-
ref: surfaceRef,
|
|
95
|
-
bg: "terminal",
|
|
96
|
-
p: 3,
|
|
97
|
-
borderRadius: "md",
|
|
98
|
-
borderColor: "light",
|
|
99
|
-
borderWidth: "thin",
|
|
100
|
-
maxWidth: "100%",
|
|
101
|
-
overflow: "auto",
|
|
102
|
-
children
|
|
103
|
-
})]
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
// src/CodeBlock/CodeBlock.data.ts
|
|
107
|
-
const font = "'JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace";
|
|
108
|
-
/** Matched to the JetBrains "Islands Dark" editor scheme. */
|
|
109
|
-
const syntaxDark = {
|
|
110
|
-
base: "#BBBBBB",
|
|
111
|
-
keyword: "#CF8E6D",
|
|
112
|
-
string: "#6AAB73",
|
|
113
|
-
number: "#2AACB8",
|
|
114
|
-
title: "#6BA9FA",
|
|
115
|
-
constant: "#C77DBB",
|
|
116
|
-
type: "#2AACB8",
|
|
117
|
-
comment: "#919191",
|
|
118
|
-
tag: "#D5B778",
|
|
119
|
-
font
|
|
120
|
-
};
|
|
121
|
-
/** Matched to the JetBrains "Islands Light" editor scheme. */
|
|
122
|
-
const syntaxLight = {
|
|
123
|
-
base: "#080808",
|
|
124
|
-
keyword: "#0033B3",
|
|
125
|
-
string: "#067D17",
|
|
126
|
-
number: "#1750EB",
|
|
127
|
-
title: "#00627A",
|
|
128
|
-
constant: "#871094",
|
|
129
|
-
type: "#007E8A",
|
|
130
|
-
comment: "#8C8C8C",
|
|
131
|
-
tag: "#008077",
|
|
132
|
-
font
|
|
133
|
-
};
|
|
134
|
-
exports.CodeBlock = CodeBlock;
|
|
135
|
-
exports.syntaxDark = syntaxDark;
|
|
136
|
-
exports.syntaxLight = syntaxLight;
|
|
2
|
+
const require_CodeBlock = require("./CodeBlock-BaMe7CiF.cjs");
|
|
3
|
+
exports.CodeBlock = require_CodeBlock.CodeBlock;
|
|
4
|
+
exports.syntaxDark = require_CodeBlock.syntaxDark;
|
|
5
|
+
exports.syntaxLight = require_CodeBlock.syntaxLight;
|
package/dist/CodeBlock.mjs
CHANGED
|
@@ -1,133 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Button } from "@gild-ui/react/Button";
|
|
5
|
-
import { Icon } from "@gild-ui/react/Icon";
|
|
6
|
-
import { styled } from "@gild-ui/react";
|
|
7
|
-
import { View } from "@gild-ui/react/View";
|
|
8
|
-
import { useCopyToClipboard } from "@gild-ui/hooks/useCopyToClipboard";
|
|
9
|
-
// src/CodeBlock/CodeBlock.tsx
|
|
10
|
-
const syntaxStyles = ({ theme }) => ({
|
|
11
|
-
color: theme.syntax.base,
|
|
12
|
-
fontFamily: theme.syntax.font,
|
|
13
|
-
"& .hljs-comment, & .hljs-quote, & .hljs-doctag, & .hljs-meta.prompt_": {
|
|
14
|
-
color: theme.syntax.comment,
|
|
15
|
-
fontStyle: "italic"
|
|
16
|
-
},
|
|
17
|
-
"& .hljs-keyword, & .hljs-built_in, & .hljs-literal, & .hljs-selector-tag, & .hljs-selector-pseudo, & .hljs-selector-attr": { color: theme.syntax.keyword },
|
|
18
|
-
"& .hljs-type, & .hljs-title.class_": { color: theme.syntax.type },
|
|
19
|
-
"& .hljs-string, & .hljs-regexp, & .hljs-char, & .hljs-meta .hljs-string, & .hljs-addition": { color: theme.syntax.string },
|
|
20
|
-
"& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-link": { color: theme.syntax.number },
|
|
21
|
-
"& .hljs-variable.constant_, & .hljs-property": { color: theme.syntax.constant },
|
|
22
|
-
"& .hljs-title, & .hljs-section, & .hljs-attr, & .hljs-attribute, & .hljs-selector-id": { color: theme.syntax.title },
|
|
23
|
-
"& .hljs-tag, & .hljs-name, & .hljs-meta, & .hljs-variable, & .hljs-selector-class, & .hljs-deletion": { color: theme.syntax.tag },
|
|
24
|
-
"& .hljs-emphasis": { fontStyle: "italic" },
|
|
25
|
-
"& .hljs-strong": { fontWeight: "bold" }
|
|
26
|
-
});
|
|
27
|
-
const CodeSurface = styled(View, {
|
|
28
|
-
name: "CodeBlock",
|
|
29
|
-
slot: "surface",
|
|
30
|
-
label: "CodeSurface"
|
|
31
|
-
})(syntaxStyles);
|
|
32
|
-
const Wrapper = styled(View, {
|
|
33
|
-
name: "CodeBlock",
|
|
34
|
-
label: "CodeBlock"
|
|
35
|
-
})({
|
|
36
|
-
display: "grid",
|
|
37
|
-
gridTemplateColumns: "minmax(0, 1fr)",
|
|
38
|
-
"& .code-copy": {
|
|
39
|
-
opacity: 0,
|
|
40
|
-
transition: "opacity 120ms ease"
|
|
41
|
-
},
|
|
42
|
-
"&:hover .code-copy, &:focus-within .code-copy": { opacity: 1 },
|
|
43
|
-
"@media (hover: none)": { "& .code-copy": { opacity: 1 } }
|
|
44
|
-
});
|
|
45
|
-
/**
|
|
46
|
-
* Fenced-code block: a horizontally scrollable, syntax-highlighted surface with a
|
|
47
|
-
* copy-to-clipboard button that sticks to the top-right while the block is in view.
|
|
48
|
-
*/
|
|
49
|
-
function CodeBlock({ children, slotProps, style, className, ...rest }) {
|
|
50
|
-
const surfaceRef = useRef(null);
|
|
51
|
-
const { copied, copy } = useCopyToClipboard();
|
|
52
|
-
const handleCopy = () => {
|
|
53
|
-
const raw = surfaceRef.current.textContent;
|
|
54
|
-
let end = raw.length;
|
|
55
|
-
while (end > 0 && raw[end - 1] === "\n") end--;
|
|
56
|
-
const text = raw.slice(0, end);
|
|
57
|
-
if (text) copy(text);
|
|
58
|
-
};
|
|
59
|
-
return /* @__PURE__ */ jsxs(Wrapper, {
|
|
60
|
-
my: 2,
|
|
61
|
-
position: "relative",
|
|
62
|
-
...rest,
|
|
63
|
-
...mergeOverrides(slotProps?.root, {
|
|
64
|
-
style,
|
|
65
|
-
className
|
|
66
|
-
}),
|
|
67
|
-
children: [/* @__PURE__ */ jsx(View, {
|
|
68
|
-
position: "absolute",
|
|
69
|
-
top: "8px",
|
|
70
|
-
right: "8px",
|
|
71
|
-
zIndex: 1,
|
|
72
|
-
bg: "paper",
|
|
73
|
-
borderRadius: "sm",
|
|
74
|
-
className: "code-copy",
|
|
75
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
76
|
-
type: "button",
|
|
77
|
-
variant: "outlined",
|
|
78
|
-
color: "default",
|
|
79
|
-
size: "sm",
|
|
80
|
-
borderRadius: "sm",
|
|
81
|
-
onClick: handleCopy,
|
|
82
|
-
"aria-label": copied ? "Copied" : "Copy code",
|
|
83
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
84
|
-
name: copied ? "check" : "content_copy",
|
|
85
|
-
color: copied ? "success" : "primary",
|
|
86
|
-
size: "1.1rem"
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
}), /* @__PURE__ */ jsx(CodeSurface, {
|
|
90
|
-
...slotProps?.surface,
|
|
91
|
-
as: "pre",
|
|
92
|
-
tabIndex: 0,
|
|
93
|
-
ref: surfaceRef,
|
|
94
|
-
bg: "terminal",
|
|
95
|
-
p: 3,
|
|
96
|
-
borderRadius: "md",
|
|
97
|
-
borderColor: "light",
|
|
98
|
-
borderWidth: "thin",
|
|
99
|
-
maxWidth: "100%",
|
|
100
|
-
overflow: "auto",
|
|
101
|
-
children
|
|
102
|
-
})]
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
// src/CodeBlock/CodeBlock.data.ts
|
|
106
|
-
const font = "'JetBrains Mono Variable', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace";
|
|
107
|
-
/** Matched to the JetBrains "Islands Dark" editor scheme. */
|
|
108
|
-
const syntaxDark = {
|
|
109
|
-
base: "#BBBBBB",
|
|
110
|
-
keyword: "#CF8E6D",
|
|
111
|
-
string: "#6AAB73",
|
|
112
|
-
number: "#2AACB8",
|
|
113
|
-
title: "#6BA9FA",
|
|
114
|
-
constant: "#C77DBB",
|
|
115
|
-
type: "#2AACB8",
|
|
116
|
-
comment: "#919191",
|
|
117
|
-
tag: "#D5B778",
|
|
118
|
-
font
|
|
119
|
-
};
|
|
120
|
-
/** Matched to the JetBrains "Islands Light" editor scheme. */
|
|
121
|
-
const syntaxLight = {
|
|
122
|
-
base: "#080808",
|
|
123
|
-
keyword: "#0033B3",
|
|
124
|
-
string: "#067D17",
|
|
125
|
-
number: "#1750EB",
|
|
126
|
-
title: "#00627A",
|
|
127
|
-
constant: "#871094",
|
|
128
|
-
type: "#007E8A",
|
|
129
|
-
comment: "#8C8C8C",
|
|
130
|
-
tag: "#008077",
|
|
131
|
-
font
|
|
132
|
-
};
|
|
133
|
-
export { CodeBlock, syntaxDark, syntaxLight };
|
|
1
|
+
export { r as CodeBlock, t as syntaxDark, n as syntaxLight } from "./CodeBlock-BFqv_nVv.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CmQyd0Gu.cjs");
|
|
2
2
|
const require_MarkdownContext = require("./MarkdownContext-DS1X9B6N.cjs");
|
|
3
|
-
const require_Preview = require("./Preview-
|
|
3
|
+
const require_Preview = require("./Preview-CIbu-nRm.cjs");
|
|
4
4
|
const require_mergeOverrides = require("./mergeOverrides-D2btS1Jb.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as MarkdownContext } from "./MarkdownContext-D28Czdll.mjs";
|
|
2
|
-
import { t as Preview } from "./Preview-
|
|
2
|
+
import { t as Preview } from "./Preview-DQOQ1NKJ.mjs";
|
|
3
3
|
import { t as mergeOverrides } from "./mergeOverrides-DEbU7yDg.mjs";
|
|
4
4
|
import { useContext, useRef, useState } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
package/dist/LiveEdit.cjs
CHANGED
package/dist/LiveEdit.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as LiveEdit } from "./LiveEdit-
|
|
1
|
+
export { t as LiveEdit } from "./LiveEdit-CzJcNsEo.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeBlock } from "./CodeBlock.mjs";
|
|
1
|
+
import { r as CodeBlock } from "./CodeBlock-BFqv_nVv.mjs";
|
|
2
2
|
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Button } from "@gild-ui/react/Button";
|
package/dist/Mermaid.cjs
CHANGED
package/dist/Mermaid.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Mermaid } from "./Mermaid-
|
|
1
|
+
export { t as Mermaid } from "./Mermaid-DR4XzGaY.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CmQyd0Gu.cjs");
|
|
2
|
-
const require_CodeBlock = require("./CodeBlock.cjs");
|
|
3
|
-
const require_Mermaid = require("./Mermaid-
|
|
2
|
+
const require_CodeBlock = require("./CodeBlock-BaMe7CiF.cjs");
|
|
3
|
+
const require_Mermaid = require("./Mermaid-d1a5LqcK.cjs");
|
|
4
4
|
const require_mergeOverrides = require("./mergeOverrides-D2btS1Jb.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CodeBlock } from "./CodeBlock.mjs";
|
|
2
|
-
import { t as Mermaid } from "./Mermaid-
|
|
1
|
+
import { r as CodeBlock } from "./CodeBlock-BFqv_nVv.mjs";
|
|
2
|
+
import { t as Mermaid } from "./Mermaid-DR4XzGaY.mjs";
|
|
3
3
|
import { t as mergeOverrides } from "./mergeOverrides-DEbU7yDg.mjs";
|
|
4
4
|
import { createContext, isValidElement, useContext } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
package/dist/Preview.cjs
CHANGED
package/dist/Preview.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Preview } from "./Preview-
|
|
1
|
+
export { t as Preview } from "./Preview-DQOQ1NKJ.mjs";
|
package/dist/index.cjs
CHANGED
|
@@ -3,10 +3,10 @@ const require_MarkdownContext = require("./MarkdownContext-DS1X9B6N.cjs");
|
|
|
3
3
|
const require_Control = require("./Control.cjs");
|
|
4
4
|
const require_Toolbar = require("./Toolbar-gk3KJhCE.cjs");
|
|
5
5
|
const require_Editor = require("./Editor.cjs");
|
|
6
|
-
const require_CodeBlock = require("./CodeBlock.cjs");
|
|
7
|
-
const require_Mermaid = require("./Mermaid-
|
|
8
|
-
const require_Preview = require("./Preview-
|
|
9
|
-
const require_LiveEdit = require("./LiveEdit-
|
|
6
|
+
const require_CodeBlock = require("./CodeBlock-BaMe7CiF.cjs");
|
|
7
|
+
const require_Mermaid = require("./Mermaid-d1a5LqcK.cjs");
|
|
8
|
+
const require_Preview = require("./Preview-CIbu-nRm.cjs");
|
|
9
|
+
const require_LiveEdit = require("./LiveEdit-CXw-vQpD.cjs");
|
|
10
10
|
exports.CodeBlock = require_CodeBlock.CodeBlock;
|
|
11
11
|
exports.Control = require_Control.Control;
|
|
12
12
|
exports.Editor = require_Editor.Editor;
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { n as useMarkdownContext, t as MarkdownContext } from "./MarkdownContext
|
|
|
2
2
|
import { Control } from "./Control.mjs";
|
|
3
3
|
import { n as TablePicker, t as Toolbar } from "./Toolbar-Eg7KmYbK.mjs";
|
|
4
4
|
import { Editor } from "./Editor.mjs";
|
|
5
|
-
import { CodeBlock, syntaxDark
|
|
6
|
-
import { t as Mermaid } from "./Mermaid-
|
|
7
|
-
import { t as Preview } from "./Preview-
|
|
8
|
-
import { t as LiveEdit } from "./LiveEdit-
|
|
5
|
+
import { n as syntaxLight, r as CodeBlock, t as syntaxDark } from "./CodeBlock-BFqv_nVv.mjs";
|
|
6
|
+
import { t as Mermaid } from "./Mermaid-DR4XzGaY.mjs";
|
|
7
|
+
import { t as Preview } from "./Preview-DQOQ1NKJ.mjs";
|
|
8
|
+
import { t as LiveEdit } from "./LiveEdit-CzJcNsEo.mjs";
|
|
9
9
|
export { CodeBlock, Control, Editor, LiveEdit, MarkdownContext, Mermaid, Preview, TablePicker, Toolbar, syntaxDark, syntaxLight, useMarkdownContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gild-ui/react-markdown",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "A markdown editor and renderer for @gild-ui/react - Control, Toolbar, Editor, Preview, LiveEdit, CodeBlock and a themed, zoomable diagram viewer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"access": "public"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"mermaid": "^12.
|
|
118
|
+
"mermaid": "^12.4.0",
|
|
119
119
|
"react-markdown": "^10.1.0",
|
|
120
120
|
"rehype-highlight": "^7.0.2",
|
|
121
121
|
"rehype-parse": "^9.0.1",
|
|
@@ -124,32 +124,35 @@
|
|
|
124
124
|
"remark-gfm": "^4.0.1",
|
|
125
125
|
"remark-stringify": "^11.0.0",
|
|
126
126
|
"unified": "^11.0.5",
|
|
127
|
-
"@gild-ui/core": "^0.1.0-alpha.
|
|
128
|
-
"@gild-ui/hooks": "^0.1.0-alpha.
|
|
127
|
+
"@gild-ui/core": "^0.1.0-alpha.2",
|
|
128
|
+
"@gild-ui/hooks": "^0.1.0-alpha.2"
|
|
129
129
|
},
|
|
130
130
|
"peerDependencies": {
|
|
131
131
|
"react": "^19.2.8",
|
|
132
132
|
"react-dom": "^19.2.8",
|
|
133
|
-
"@gild-ui/react": "^0.1.0-alpha.
|
|
133
|
+
"@gild-ui/react": "^0.1.0-alpha.2"
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
|
-
"@storybook/react-vite": "^10.6.
|
|
137
|
-
"@testing-library/jest-dom": "^
|
|
136
|
+
"@storybook/react-vite": "^10.6.10",
|
|
137
|
+
"@testing-library/jest-dom": "^8.0.0",
|
|
138
138
|
"@testing-library/react": "^16.3.3",
|
|
139
|
-
"@types/
|
|
140
|
-
"@types/
|
|
139
|
+
"@types/hast": "^3.0.4",
|
|
140
|
+
"@types/node": "^26.6.11",
|
|
141
|
+
"@types/react": "^19.3.3",
|
|
141
142
|
"@types/react-dom": "^19.3.0",
|
|
142
|
-
"@vitest/coverage-v8": "^5.1.
|
|
143
|
-
"jsdom": "^31.0.
|
|
144
|
-
"oxlint": "^1.
|
|
143
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
144
|
+
"jsdom": "^31.0.1",
|
|
145
|
+
"oxlint": "^1.96.0",
|
|
145
146
|
"react": "^19.3.1",
|
|
146
147
|
"react-dom": "^19.3.1",
|
|
147
|
-
"
|
|
148
|
+
"remark-parse": "^11.0.0",
|
|
149
|
+
"remark-rehype": "^11.1.2",
|
|
150
|
+
"storybook": "^10.6.10",
|
|
148
151
|
"tsdown": "^0.23.7",
|
|
149
152
|
"typescript": "~7.0.2",
|
|
150
|
-
"vitest": "^5.1.
|
|
151
|
-
"@
|
|
152
|
-
"@
|
|
153
|
+
"vitest": "^5.1.2",
|
|
154
|
+
"@soroush.tech/eslint-config": "0.0.0",
|
|
155
|
+
"@gild-ui/react": "0.1.0-alpha.2"
|
|
153
156
|
},
|
|
154
157
|
"scripts": {
|
|
155
158
|
"build": "tsdown",
|