@coldsmirk/inkstone-monaco 0.35.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.
- package/dist/index.js +52 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as toMonacoTokens, d as lineAfter, i as defaultMetadata, r as colorIdsFor, s as applyStateDiff } from "./bounds-CZ_iAUoc.js";
|
|
2
|
-
import { CODE_FONT_FAMILY, highlighterSources, inkstoneRadius, inkstoneShadow } from "@coldsmirk/inkstone-core";
|
|
2
|
+
import { CODE_FONT_FAMILY, INKSTONE_DARK_THEME, INKSTONE_LIGHT_THEME, highlighterSources, inkstoneRadius, inkstoneShadow, subscribeEditorColors } from "@coldsmirk/inkstone-core";
|
|
3
3
|
import { EncodedTokenMetadata, INITIAL } from "@shikijs/vscode-textmate";
|
|
4
4
|
//#region src/auto-imports.ts
|
|
5
5
|
const MISSING_LOOKUP_REJECTION$1 = "Missing requestHandler or method: getAutoImportCompletionsAtPosition";
|
|
@@ -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) {
|
|
@@ -1158,6 +1197,18 @@ function registerShikiHighlighting(monaco, highlighter) {
|
|
|
1158
1197
|
throw error;
|
|
1159
1198
|
}
|
|
1160
1199
|
registry.set(monaco, bridge);
|
|
1200
|
+
subscribeEditorColors(() => {
|
|
1201
|
+
relight(monaco, bridge);
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
function relight(monaco, bridge) {
|
|
1205
|
+
for (const themeId of [INKSTONE_LIGHT_THEME, INKSTONE_DARK_THEME]) {
|
|
1206
|
+
if (!bridge.themes.has(themeId)) continue;
|
|
1207
|
+
const theme = monacoThemeOf(bridge.highlighter.getTheme(themeId));
|
|
1208
|
+
bridge.themes.set(themeId, theme);
|
|
1209
|
+
if (bridge.theme === themeId) adoptTheme(bridge, themeId);
|
|
1210
|
+
monaco.editor.defineTheme(themeId, theme);
|
|
1211
|
+
}
|
|
1161
1212
|
}
|
|
1162
1213
|
function registerShikiLanguage(monaco, highlighter, language) {
|
|
1163
1214
|
const registry = bridges();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coldsmirk/inkstone-monaco",
|
|
3
|
-
"version": "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.
|
|
44
|
+
"@coldsmirk/inkstone-core": "^0.36.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"monaco-editor": "^0.57.0",
|