@coldsmirk/inkstone-react 0.34.0 → 0.34.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/README.md CHANGED
@@ -30,6 +30,8 @@ import { MonacoEditor } from "@coldsmirk/inkstone-react/monaco";
30
30
 
31
31
  One component brings: the local `monaco-editor` instance (no CDN), bundled offline workers, Shiki catppuccin highlighting registered before first paint, light/dark switching via `dark`, and VS Code's auto-closing JSX tags on TypeScript/JavaScript models whose `path` ends in `.tsx` / `.jsx` (parser-backed via the bundled TS worker).
32
32
 
33
+ A leading `U+FEFF` in `value` is treated as a BOM rather than displayed text. Edits reported through `onChange` retain that prefix, so a controlled round trip preserves the file's encoding marker. The same applies to `modified` in `<MonacoDiffEditor>`; further `U+FEFF` characters remain document content.
34
+
33
35
  - **Locale** — chrome speaks stock English; `locale="zh-cn"` switches to Monaco's official Simplified-Chinese catalog. Page-global and locked by the first editor to mount, so give every editor the same value.
34
36
  - **Type & metrics** — `fontSize` defaults to 14, `lineHeight` to 1.6 (Monaco's convention: values below 8 multiply the font size); `DEFAULT_MONACO_OPTIONS` is exported for hosts that need the same baseline. `lineWrapping` (opt-in) soft-wraps long lines and ends each wrapped line in Monaco's ↩ (`wordWrapIndicator`), so a soft wrap reads apart from a real line break — on `<MonacoDiffEditor>` too.
35
37
  - **Loading / failure** — the host, the highlighter, and the Monaco chunk each have a loading window; `loading` and `failure` render nodes for them. A host load failure is not cached — a fresh mount retries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as CodeMirrorDiffEditor, i as CodeMirrorEditor, n as normalizeContext, r as searchPhrasesZhCn, t as codeMirrorLanguages } from "./codemirror-bROXidfr.js";
2
- import { a as MonacoEditor, i as MonacoConsoleEditor, n as monacoLanguages, r as MonacoDiffEditor, t as DEFAULT_MONACO_OPTIONS } from "./monaco-CHi4aRfZ.js";
2
+ import { a as MonacoEditor, i as MonacoConsoleEditor, n as monacoLanguages, r as MonacoDiffEditor, t as DEFAULT_MONACO_OPTIONS } from "./monaco-CLTgQmhk.js";
3
3
  import { t as useShikiHighlighter } from "./use-shiki-highlighter-CzSQcX2f.js";
4
4
  import "./shiki.js";
5
5
  export { CodeMirrorDiffEditor, CodeMirrorEditor, DEFAULT_MONACO_OPTIONS, MonacoConsoleEditor, MonacoDiffEditor, MonacoEditor, codeMirrorLanguages, monacoLanguages, normalizeContext, searchPhrasesZhCn, useShikiHighlighter };
@@ -146,11 +146,16 @@ function MonacoEditor({ value, onChange, language = "javascript", dark = false,
146
146
  if (!model.isDisposed() && monaco.editor.getEditors().every((other) => other.getModel() !== model)) model.dispose();
147
147
  });
148
148
  }, []);
149
- const handleChange = useCallback((next) => {
149
+ const handleChange = useCallback((next = "") => {
150
150
  if (pathChangingRef.current || valueTransitionRef.current || reconcilingRef.current) return;
151
- onChangeRef.current?.(next ?? "");
151
+ const bom = valueRef.current.startsWith("") ? "" : "";
152
+ onChangeRef.current?.(`${bom}${next}`);
152
153
  requestControlledReconcile();
153
- }, [onChangeRef, requestControlledReconcile]);
154
+ }, [
155
+ onChangeRef,
156
+ requestControlledReconcile,
157
+ valueRef
158
+ ]);
154
159
  const mergedOptions = useMemo(() => {
155
160
  return {
156
161
  ...DEFAULT_MONACO_OPTIONS,
@@ -424,7 +429,8 @@ function MonacoDiffEditor({ original, modified, onChange, language = "javascript
424
429
  const modifiedEditor = diffEditor.getModifiedEditor();
425
430
  modifiedEditor.onDidChangeModelContent(() => {
426
431
  if (reconcilingRef.current || modifiedTransitionRef.current) return;
427
- onChangeRef.current?.(modifiedEditor.getValue());
432
+ const bom = modifiedRef.current.startsWith("") ? "" : "";
433
+ onChangeRef.current?.(`${bom}${modifiedEditor.getValue()}`);
428
434
  requestControlledReconcile();
429
435
  });
430
436
  reconcilePane(diffEditor.getOriginalEditor().getModel(), originalRef.current, reconcilingRef);
package/dist/monaco.js CHANGED
@@ -1 +1 @@
1
- export { t as DEFAULT_MONACO_OPTIONS, i as MonacoConsoleEditor, r as MonacoDiffEditor, a as MonacoEditor, n as monacoLanguages } from "./monaco-CHi4aRfZ.js";
1
+ export { t as DEFAULT_MONACO_OPTIONS, i as MonacoConsoleEditor, r as MonacoDiffEditor, a as MonacoEditor, n as monacoLanguages } from "./monaco-CLTgQmhk.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldsmirk/inkstone-react",
3
- "version": "0.34.0",
3
+ "version": "0.34.2",
4
4
  "description": "Drop-in React code editors: a preconfigured Monaco <MonacoEditor> (offline workers, Shiki catppuccin themes, dark switching, opt-in zh-CN UI) and a controlled CodeMirror 6 <CodeMirrorEditor> (catppuccin themes, dark switching, sizing).",
5
5
  "keywords": [
6
6
  "react",
@@ -48,9 +48,9 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "@monaco-editor/react": "^4.7.0",
51
- "@coldsmirk/inkstone-codemirror": "^0.34.0",
52
- "@coldsmirk/inkstone-core": "^0.34.0",
53
- "@coldsmirk/inkstone-monaco": "^0.34.0"
51
+ "@coldsmirk/inkstone-codemirror": "^0.34.2",
52
+ "@coldsmirk/inkstone-core": "^0.34.2",
53
+ "@coldsmirk/inkstone-monaco": "^0.34.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@codemirror/autocomplete": "^6.20.3",