josdejong/jsoneditor

Reevaluate "onEditable"

Open

#1.386 aberto em 8 de nov. de 2021

Ver no GitHub
 (4 comments) (0 reactions) (0 assignees)JavaScript (2.034 forks)batch import
featurehelp wanted

Métricas do repositório

Stars
 (10.781 stars)
Métricas de merge de PR
 (Mesclagem média 15h 36m) (3 fundiu PRs em 30d)

Description

I want to use the "code" or "tree" modes for viewing JSON in readonly mode. However, I want to be able to switch the editor into read/write mode dynamically. At the moment "onEditable" is not reevaluated - can I force JSONEditor to reevaluate whether the JSON can be edited? The only method I've found is to switch mode and then back again - but this comes with its own problems (like cursor location changing, tree collapsing).

        const options = {
            mode: 'code',
            modes: ['code', 'form', 'text', 'tree', 'view', 'preview'],
            onEditable: function () {
                return self.editJSON; <-- this can change dynamically.
            }
        };
        this.jsoneditor = new JSONEditor(container, options);

Perhaps something like?:

this.jsoneditor.reevaluateOnEditable();

Thanks, -Neil

Guia do colaborador