ichaoX / ext-codeEditor

1 stars 0 forks source link

RFE: Set up settings for Monaco Editor #1

Open belonesox opened 6 months ago

belonesox commented 6 months ago

Thank you for the extension!

Request to set up settings, by showing "Preferences", and somehow remember settings changes maded interactively.

For example, usecase — Someone use CodeEditor to editing some Wikipedia page.

image

Monaco by default "uglyfied" unambigious characters, and impossible to disable it — no «Preferences» and interactive menu «Adjust settings» not worked (looks like it did not remember changes in settings).

Also, impossible…

For me «WikiMarkup» + «disable minimap» + «disable unambigious characters highliting» already OK for most cases, but access for all settings will be more agile.

ichaoX commented 6 months ago

Request to set up settings, by showing "Preferences", and somehow remember settings changes maded interactively.

I am not sure if the Monaco Editor has exposed any interfaces related to interactive adjustment of settings. I will look into it when I have time.

Monaco by default "uglyfied" unambigious characters, and impossible to disable it — no «Preferences» and interactive menu «Adjust settings» not worked (looks like it did not remember changes in settings).

See: https://github.com/microsoft/monaco-editor/issues/2940

«disable minimap» + «disable unambigious characters highliting»

These can be resolved by editing the "Default Context" in the options page.

     options: {
+        minimap: {
+            enabled: false,
+        },
+        unicodeHighlight: {
+            ambiguousCharacters: false,
+        },
         theme: "vs",
  • to add syntax coloring for markups, that will be very possible in Firefox Textareas — MediaWiki wikitext, etc.

Adding custom syntax is possible, but it may be quite complex, as Monaco Editor lacks some features of VS Code.

     init: [
+        {
+            func() {
+                monaco.languages.register({ id: 'wikitext' });
+                ...
+            },
+            injectImmediately: true,
+        },
         {
belonesox commented 5 months ago

Thank you! Successfully patch simple options, I now hardly working on MediaWiki support

But how to select language by default (without need to call big dropdown listbox), hardcoding in

    options: {
…
        language: "wikitext",
…

do not work for me. Or, even better, how select default language using URL of default textarea tab?

ichaoX commented 5 months ago

But how to select language by default

The subsequent versions may improve. Temporary solution:

Options Page > Standalone Editor > JavaScript

    init: [
        {
            func() {
                (async () => {
                    languages = await this.proxy('monaco.languages.getLanguages', { args: [] });
                    $language.innerHTML = "";
                    for (let l of languages) {
                        let $option = document.createElement("option");
                        $option.value = l.id;
                        $option.textContent = l.aliases && l.aliases[0] || l.id;
                        $language.appendChild($option);
                    }
+                   $language.value = context.options.language || 'html';
+                   $language.dispatchEvent(new Event('change'));
                })();