@haklex/rich-renderer-codeblock 0.31.1 → 0.32.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.
@@ -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,+BAkDrF"}
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/web";
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(() => languageItems.find((item) => item.id === normalizedLanguage) ?? null, [normalizedLanguage]);
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: languageItems,
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,
@@ -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,CAAA"}
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/web").then((mod) => mod.createHighlighter({
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.31.1",
3
+ "version": "0.32.0",
4
4
  "description": "Code block renderer with Shiki syntax highlighting",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,17 +42,17 @@
42
42
  "@codemirror/view": "^6.43.6",
43
43
  "@iconify-json/material-icon-theme": "^1.2.69",
44
44
  "@iconify/utils": "^3.1.4",
45
- "@haklex/cm-editor": "0.31.1"
45
+ "@haklex/cm-editor": "0.32.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/react": "^19.2.17",
49
49
  "@types/react-dom": "^19.2.3",
50
50
  "@vanilla-extract/css": "^1.21.1",
51
51
  "@vanilla-extract/vite-plugin": "^5.2.5",
52
- "react": "^19.2.7",
53
- "react-dom": "^19.2.7",
52
+ "react": "^19.2.8",
53
+ "react-dom": "^19.2.8",
54
54
  "shiki": "^4.3.1",
55
- "typescript": "^6.0.3",
55
+ "typescript": "^7.0.2",
56
56
  "unplugin-dts": "^1.0.3",
57
57
  "vite": "^8.1.5"
58
58
  },
@@ -61,9 +61,9 @@
61
61
  "react": ">=19",
62
62
  "react-dom": ">=19",
63
63
  "shiki": ">=4.0.0",
64
- "@haklex/rich-editor": "^0.31.1",
65
- "@haklex/rich-editor-ui": "^0.31.1",
66
- "@haklex/rich-style-token": "^0.31.1"
64
+ "@haklex/rich-editor": "^0.32.0",
65
+ "@haklex/rich-editor-ui": "^0.32.0",
66
+ "@haklex/rich-style-token": "^0.32.0"
67
67
  },
68
68
  "publishConfig": {
69
69
  "access": "public"