@haklex/rich-renderer-codeblock 0.31.1 → 0.33.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.
- package/dist/LanguageCombobox.d.ts.map +1 -1
- package/dist/index.mjs +23 -3
- package/dist/shiki.d.ts.map +1 -1
- package/dist/shiki.mjs +1 -1
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageCombobox.d.ts","sourceRoot":"","sources":["../src/LanguageCombobox.tsx"],"names":[],"mappings":"AAoBA,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,qBAAqB,+
|
|
1
|
+
{"version":3,"file":"LanguageCombobox.d.ts","sourceRoot":"","sources":["../src/LanguageCombobox.tsx"],"names":[],"mappings":"AAoBA,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,qBAAqB,+BAiErF"}
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
10
10
|
import { Check, ChevronDown, Copy } from "lucide-react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList } from "@haklex/rich-editor-ui";
|
|
13
|
-
import { bundledLanguagesInfo } from "shiki/bundle/
|
|
13
|
+
import { bundledLanguagesInfo } from "shiki/bundle/full";
|
|
14
14
|
//#region src/CodeBlockCard.tsx
|
|
15
15
|
var CopyIcon = /* @__PURE__ */ jsx(Copy, { size: 16 });
|
|
16
16
|
var CheckIcon = /* @__PURE__ */ jsx(Check, { size: 16 });
|
|
@@ -101,20 +101,40 @@ var languageItems = bundledLanguagesInfo.map((info) => ({
|
|
|
101
101
|
}));
|
|
102
102
|
function LanguageCombobox({ language, onLanguageChange }) {
|
|
103
103
|
const normalizedLanguage = normalizeLanguage(language);
|
|
104
|
+
const [query, setQuery] = useState("");
|
|
104
105
|
const handleValueChange = useCallback((value) => {
|
|
105
106
|
if (value) onLanguageChange?.(value.id);
|
|
106
107
|
}, [onLanguageChange]);
|
|
107
|
-
const selectedValue = useMemo(() =>
|
|
108
|
+
const selectedValue = useMemo(() => {
|
|
109
|
+
const found = languageItems.find((item) => item.id === normalizedLanguage);
|
|
110
|
+
if (found) return found;
|
|
111
|
+
if (normalizedLanguage === "text") return null;
|
|
112
|
+
return {
|
|
113
|
+
id: normalizedLanguage,
|
|
114
|
+
name: normalizedLanguage
|
|
115
|
+
};
|
|
116
|
+
}, [normalizedLanguage]);
|
|
117
|
+
const items = useMemo(() => {
|
|
118
|
+
const all = selectedValue && !languageItems.some((item) => item.id === selectedValue.id) ? [...languageItems, selectedValue] : languageItems;
|
|
119
|
+
const q = query.trim().toLowerCase();
|
|
120
|
+
if (!q || all.some((item) => item.id === q)) return all;
|
|
121
|
+
return [...all, {
|
|
122
|
+
id: q,
|
|
123
|
+
name: `Use "${q}"`
|
|
124
|
+
}];
|
|
125
|
+
}, [query, selectedValue]);
|
|
108
126
|
return /* @__PURE__ */ jsxs("div", {
|
|
109
127
|
className: `${lang} ${semanticClassNames.lang}`,
|
|
110
128
|
children: [hasLanguageIcon(normalizedLanguage) && /* @__PURE__ */ jsx(LanguageIcon, {
|
|
111
129
|
language: normalizedLanguage,
|
|
112
130
|
size: 14
|
|
113
131
|
}), /* @__PURE__ */ jsxs(Combobox, {
|
|
132
|
+
autoHighlight: true,
|
|
114
133
|
itemToStringLabel: (item) => item.id,
|
|
115
134
|
itemToStringValue: (item) => item.id,
|
|
116
|
-
items
|
|
135
|
+
items,
|
|
117
136
|
value: selectedValue,
|
|
137
|
+
onInputValueChange: (value) => setQuery(value),
|
|
118
138
|
onValueChange: handleValueChange,
|
|
119
139
|
children: [/* @__PURE__ */ jsx(ComboboxInput, {
|
|
120
140
|
className: langInput,
|
package/dist/shiki.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shiki.d.ts","sourceRoot":"","sources":["../src/shiki.ts"],"names":[],"mappings":"AAcA,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,gBAe5D;AAED,eAAO,MAAM,iBAAiB;;;CAGpB,
|
|
1
|
+
{"version":3,"file":"shiki.d.ts","sourceRoot":"","sources":["../src/shiki.ts"],"names":[],"mappings":"AAcA,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,gBAe5D;AAED,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC"}
|
package/dist/shiki.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/shiki.ts
|
|
2
2
|
var highlighterPromise = null;
|
|
3
3
|
function getHighlighter() {
|
|
4
|
-
if (!highlighterPromise) highlighterPromise = import("shiki/bundle/
|
|
4
|
+
if (!highlighterPromise) highlighterPromise = import("shiki/bundle/full").then((mod) => mod.createHighlighter({
|
|
5
5
|
langs: [],
|
|
6
6
|
themes: ["github-light", "github-dark"]
|
|
7
7
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-renderer-codeblock",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Code block renderer with Shiki syntax highlighting",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,31 +39,31 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@codemirror/commands": "^6.10.4",
|
|
41
41
|
"@codemirror/state": "^6.7.1",
|
|
42
|
-
"@codemirror/view": "^6.43.
|
|
43
|
-
"@iconify-json/material-icon-theme": "^1.2.
|
|
42
|
+
"@codemirror/view": "^6.43.7",
|
|
43
|
+
"@iconify-json/material-icon-theme": "^1.2.70",
|
|
44
44
|
"@iconify/utils": "^3.1.4",
|
|
45
|
-
"@haklex/cm-editor": "0.
|
|
45
|
+
"@haklex/cm-editor": "0.33.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/react": "^19.2.
|
|
49
|
-
"@types/react-dom": "^19.2.
|
|
50
|
-
"@vanilla-extract/css": "^1.21.
|
|
51
|
-
"@vanilla-extract/vite-plugin": "^5.2.
|
|
52
|
-
"react": "^19.2.
|
|
53
|
-
"react-dom": "^19.2.
|
|
54
|
-
"shiki": "^4.
|
|
55
|
-
"typescript": "^
|
|
48
|
+
"@types/react": "^19.2.18",
|
|
49
|
+
"@types/react-dom": "^19.2.4",
|
|
50
|
+
"@vanilla-extract/css": "^1.21.2",
|
|
51
|
+
"@vanilla-extract/vite-plugin": "^5.2.6",
|
|
52
|
+
"react": "^19.2.8",
|
|
53
|
+
"react-dom": "^19.2.8",
|
|
54
|
+
"shiki": "^4.4.1",
|
|
55
|
+
"typescript": "^7.0.2",
|
|
56
56
|
"unplugin-dts": "^1.0.3",
|
|
57
|
-
"vite": "^8.
|
|
57
|
+
"vite": "^8.2.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"lucide-react": "^1.0.0",
|
|
61
61
|
"react": ">=19",
|
|
62
62
|
"react-dom": ">=19",
|
|
63
63
|
"shiki": ">=4.0.0",
|
|
64
|
-
"@haklex/rich-editor": "^0.
|
|
65
|
-
"@haklex/rich-editor-ui": "^0.
|
|
66
|
-
"@haklex/rich-style-token": "^0.
|
|
64
|
+
"@haklex/rich-editor": "^0.33.0",
|
|
65
|
+
"@haklex/rich-editor-ui": "^0.33.0",
|
|
66
|
+
"@haklex/rich-style-token": "^0.33.0"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|