Git Product home page Git Product logo

Comments (7)

MohammadYounes avatar MohammadYounes commented on May 14, 2024 13

Found it!

editor.getAction('editor.action.format').run()

Thanks.

from monaco-editor.

risfeng avatar risfeng commented on May 14, 2024 10

I press your code and I'll make a mistake.
editor.getAction('editor.action.format').run()
The execution editor command should be like this:

  • format doc
    editor.trigger(‘anyString’, 'editor.action.formatDocument');
  • selected char to lower case
    editor.trigger(‘anyString’, 'editor.action.transformToLowercase');

Like this command editor.action.transformToLowercase , You can search in the file XX/editor/editor.main.js
vs code online demo :https://toolbag.online/home/index/online-vscode.html

from monaco-editor.

rart avatar rart commented on May 14, 2024 3

editor.getAction('editor.action.formatDocument').run() works for me.

from monaco-editor.

CoderPoet avatar CoderPoet commented on May 14, 2024

@MohammadYounes
why editor.getAction('editor.action.format') return null ?

from monaco-editor.

squareCY avatar squareCY commented on May 14, 2024

@CoderPoet
add this in your js:

let editor=monaco.editor.create(doc, {
            value: this.ngModel,
            language: 'sql',
            formatOnType: true//!important
        });
monaco.languages.registerDocumentFormattingEditProvider('sql', {
                provideDocumentFormattingEdits: function (model, options, token) {
                    return [
                        {
                            range: {
                                startLineNumber: 1,
                                startColumn: 1,
                                endLineNumber: 1,
                                endColumn: 1
                            },
                            text: 'a'
                        }
                    ];
                }
            });

from monaco-editor.

XHappyness avatar XHappyness commented on May 14, 2024

hahaha;

editor.trigger(‘anyString’, 'editor.action.formatDocument'); works for me.

from monaco-editor.

lmxx1234567 avatar lmxx1234567 commented on May 14, 2024

editor.getAction('editor.action.formatDocument').run();

from monaco-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.