monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

monaco-vscode-editor-api is missing some files

Open xueerli opened this issue 1 year ago • 11 comments

Description

I upgraded from version 7 to 8 and used monaco-vscode-editor-api to replace monaco-editor-treemended as per the docs. But monaco-vscode-editor-api miss some files. e.g. metadata.js which is used by monaco-editor-webpack-plugin.

Before:

"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.16 <1.84.0",
"monaco-languageclient": "~7.2.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.16 <1.84.0",

Now:

"monaco-editor": "npm:@codingame/[email protected]",
"monaco-languageclient": "8.3.1",
"vscode": "npm:@codingame/[email protected]",

Here is a list of files for monaco-vscode-editor-api1 Here is a list of files for monaco-editor-treemended: 2

Expectation

Upgrade to v8 with minimal changes.

Thanks.

xueerli avatar May 10 '24 07:05 xueerli

As stated in the readme, the webpack plugin can't be used anymore

CGNonofr avatar May 10 '24 07:05 CGNonofr

@xueerli see here: https://github.com/CodinGame/monaco-vscode-api#if-you-use-webpack

kaisalmen avatar May 10 '24 15:05 kaisalmen

@kaisalmen thank you for your response. In addition to monaco-editor-webpack-plugin, there is no setLocale method in monaco-editor/esm/vs/nls . There is also no monaco-editor/esm/vs/platform/actions/common/actions to handle context menus.

xueerli avatar May 14 '24 03:05 xueerli

There is even no vs/nls file in the editor api, why are you trying to access it directly?

Exposed modules are whitelisted, and vs/platform/actions/common/actions is currently not part of it, what do you need it for?

CGNonofr avatar May 14 '24 09:05 CGNonofr

@CGNonofr I use vs/nls setLocale to set locale language. I use vs/platform/actions/common/actions to delete some actions. In previous versions of treemended, it was possible to import from monaco-editor.

xueerli avatar Jun 03 '24 03:06 xueerli

I'm not sure why you would want to call setLocale by hands?

You should be able to import vscode/vscode/XXX instead of monaco-editor/esm/XXX though

CGNonofr avatar Jun 03 '24 07:06 CGNonofr

@xueerli we even have a utility for loading locales available: https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/wrapper_statemachine.html#L18-L22

It must be loaded before anything else. Usage is demonstrate here: https://github.com/TypeFox/monaco-languageclient/blob/main/index.html#L41

kaisalmen avatar Jun 03 '24 07:06 kaisalmen

@CGNonofr I use ESM. Shouldn't I set Locale manually? I couldn't find a better way. Here's a related issue https://github.com/microsoft/monaco-editor/issues/1514.

xueerli avatar Jun 12 '24 08:06 xueerli

We are using our own localization mechanism here, inspired by what is used in VSCode, adpated to work in ESM (VScode is built into commonjs/umd and they inject the localization at runtime, which is not possible with ESM)

setLocale is an internal api and you're not supposed to call it by hands. you would need to give the localization content as parameter

CGNonofr avatar Jun 12 '24 08:06 CGNonofr

@CGNonofr @kaisalmen Thank you so much. Referring to your implementation, I'll try registerLocalization in vscode/l10n.

xueerli avatar Jun 12 '24 09:06 xueerli

Why don't you use what @kaisalmen suggested?

CGNonofr avatar Jun 12 '24 09:06 CGNonofr

https://github.com/TypeFox/monaco-languageclient/issues/655#issuecomment-2144469817 describes the best way forward.

kaisalmen avatar Aug 08 '24 20:08 kaisalmen