@coldsmirk/inkstone-monaco 0.36.0 → 0.36.1

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 (2) hide show
  1. package/dist/index.js +39 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -183,6 +183,36 @@ function localizeActionDescriptions(editorInstance) {
183
183
  }
184
184
  }
185
185
  //#endregion
186
+ //#region src/composition-scroll-fix.ts
187
+ const INSTALLED_KEY = Symbol.for("coldsmirk.inkstone.monaco.compositionScrollFix");
188
+ const places = /* @__PURE__ */ new WeakMap();
189
+ function composingArea(target) {
190
+ return target instanceof HTMLTextAreaElement && target.classList.contains("inputarea") ? target : null;
191
+ }
192
+ function place(event) {
193
+ const area = composingArea(event.target);
194
+ if (area !== null) places.set(area, area.scrollTop);
195
+ }
196
+ function release(event) {
197
+ const area = composingArea(event.target);
198
+ if (area !== null) places.delete(area);
199
+ }
200
+ function hold(event) {
201
+ const area = composingArea(event.target);
202
+ const top = area === null ? void 0 : places.get(area);
203
+ if (area !== null && top !== void 0 && area.scrollTop !== top) area.scrollTop = top;
204
+ }
205
+ function installCompositionScrollFix(page = typeof document === "undefined" ? void 0 : document) {
206
+ if (page === void 0) return;
207
+ const registry = page;
208
+ if (registry[INSTALLED_KEY] === true) return;
209
+ registry[INSTALLED_KEY] = true;
210
+ page.addEventListener("compositionstart", place);
211
+ page.addEventListener("compositionupdate", place);
212
+ page.addEventListener("compositionend", release);
213
+ page.addEventListener("scroll", hold, { capture: true });
214
+ }
215
+ //#endregion
186
216
  //#region src/context-menu-fix.ts
187
217
  const COMPONENT_CLASS = "monaco-component";
188
218
  function installContextMenuThemeFix(monaco) {
@@ -233,6 +263,13 @@ function installContextViewFix(monaco, internals) {
233
263
  });
234
264
  }
235
265
  //#endregion
266
+ //#region src/font-metrics-fix.ts
267
+ function installFontMetricsRefresh(monaco, fonts = globalThis.document?.fonts) {
268
+ fonts?.addEventListener("loadingdone", () => {
269
+ monaco.editor.remeasureFonts();
270
+ });
271
+ }
272
+ //#endregion
236
273
  //#region src/geometry-fixes.ts
237
274
  const HOVER_GEOMETRY_STYLE_SELECTOR = "style[data-inkstone=\"monaco-hover-geometry\"]";
238
275
  function installHoverGeometryFix() {
@@ -358,11 +395,13 @@ function ensureMonacoHost(options = {}) {
358
395
  installHoverGeometryFix();
359
396
  installSuggestGeometryFix();
360
397
  installHoverFocusFix();
398
+ installCompositionScrollFix();
361
399
  const monaco = await import("monaco-editor");
362
400
  rememberInternals(monaco, await loadMonacoInternals());
363
401
  globalThis.MonacoEnvironment = { getWorker: (workerId, label) => getWorker?.(workerId, label) ?? builtinGetWorker(label) };
364
402
  installContextMenuThemeFix(monaco);
365
403
  installContextViewFix(monaco, await loadContextViewInternals());
404
+ installFontMetricsRefresh(monaco);
366
405
  if (locale === "zh-cn") monaco.editor.onDidCreateEditor(localizeActionDescriptions);
367
406
  return monaco;
368
407
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldsmirk/inkstone-monaco",
3
- "version": "0.36.0",
3
+ "version": "0.36.1",
4
4
  "description": "Framework-agnostic Monaco assembly: lazy offline host (all language workers bundled, no CDN), opt-in Simplified-Chinese UI via monaco's official NLS catalog, a streaming editor controller for AI-typed content, and the shared Shiki highlighting bridge.",
5
5
  "keywords": [
6
6
  "monaco",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@shikijs/vscode-textmate": "^10.0.2",
43
43
  "shiki": "^4.5.0",
44
- "@coldsmirk/inkstone-core": "^0.36.0"
44
+ "@coldsmirk/inkstone-core": "^0.36.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "monaco-editor": "^0.57.0",