ace-editor在大括号之间获取文本

时间:2013-04-02 13:16:08

标签: javascript ace-editor

ace-editor如何获得大括号之间的代码值:

 {
        "name":"Product",
        "properties":
        {
                "id":
                {
                        "type":"number",
                        "description":"Product identifier",
                        "required":true
                },
                "name":
                {
                        "description":"Name of the product",
                        "type":"string",
                        "required":true
                }
        }
}

如果光标开启:"type":"number"

然后它应该返回

                {
                        "type":"number",
                        "description":"Product identifier",
                        "required":true
                }

1 个答案:

答案 0 :(得分:1)

查看jumpToMatching中找到下一个{}的代码,然后调用findMatchingBracket,一旦你有范围调用editor.session.getTextRange(range)