Skip to content

ACE Editor alternatives #1025

@hillin

Description

@hillin

ACE is a great code editor, but in some scenarios it's not desirable to integrate it in the project:

One way to overcome these difficulties is to use brace instead, which is our workaround right now, however brace is based on a rather old version of ACE (1.2.9) and stagnated for years. Brace does not work with JSONEditor, namely because it does not support passing the options in the ace.edit function. As a workaround we can set the options manually in the next animation frame:

const editor = new JSONEditor(/*...*/);
requestAnimationFrame(fixAceEditors);

function fixAceEditors() {
    const fieldEditors = editor.editors;
    for (const key in fieldEditors) {
        if (!Object.prototype.hasOwnProperty.call(fieldEditors, key)) {
            continue;
        }

        const fieldEditor = fieldEditors[key];

        if ("ace_editor_instance" in fieldEditor) {
            fieldEditor.ace_editor_instance.setOptions(
                {
                    selectionStyle: "text",
                    minLines: 30,
                    maxLines: 30,
                    mode: `ace/mode/${fieldEditor.input_type}`,
                });

        }
    }
}

On the other hand, Monaco, the editor component backing Visual Studio Code, is a great alternative to ACE. It would be wonderful if JSONEditor supports it too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions