josdejong/jsoneditor

Implement a way to trigger executing onEditable again

开放

#1,261 创建于 2021年3月5日

 (2 条评论) (0 个反应) (0 位负责人)JavaScript (2,078 个派生)batch import
featurehelp wanted

仓库指标

星标
 (12,263 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

We have a case where we dynamically switch the editor from read-only to editable. However, in code or text mode this isn't applied properly because the onEditable callback is only called on creation.

https://github.com/josdejong/jsoneditor/blob/1e79ead1ec96a9acfdb8b35097595a3da5a9bacc/src/js/textmode.js#L255-L256

This is not clear from the docs:

In modes text and code, the callback is invoked as editable(node) where node is an empty object (no field, value, or path). In that case the function can return false to make the text or code editor completely read-only.

If it's not possible to handle this dynamically, having to call .refresh() to update the mode also comes a long way. Currently we recreate the editor when we want to switch from read-only to editable.

贡献者指南