Extjs htmleditor获取光标位置

标签 extjs

{

        xtype: 'htmleditor',
        name: 'msg',
        value : 'abcd',
        id: 'myeditor',
        listeners: {
            afterrender: function(t2){  
                var but = Ext.create('Ext.Button', {
                    text: 'Click me',
                    handler: function() {
                        Ext.getCmp('myeditor').insertAtCursor('bbbb');                      
                    }
                });

                t2.getToolbar().add(but)
            }
        }
    }

如果cursers不在html编辑器中,我不会在“abcd”末尾插入“bbbb”,如果cursers位于编辑器中的任何点,我不会在光标点插入“bbbb”。你能帮我做这件事吗?

最佳答案

我已经使用了这个解决方法:

var before = Ext.getCmp('yourHtmlEditor').getValue();
Ext.getCmp('yourHtmlEditor').insertAtCursor('something');
var after = Ext.getCmp('noteEditor').getValue();
if (before==after) {       
    Ext.getCmp('yourHtmlEditor').setValue(before+'something');
}

关于Extjs htmleditor获取光标位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10234254/

相关文章:

Extjs 4 MVC 通过小部件名称加载类

javascript - ExtJS 5 : confusion with persisting changes to view model/form record

json - ExtJS Grid 不加载数据

java - 通过 Ajax 请求的 Servlet 流

javascript - 提交前的 Extjs 表单验证

javascript - 为 Intellij IDEA 添加 ExtJS 代码辅助

extjs - 访问 Nexus 配置 - Ext.JSON.decode() : You're trying to decode an invalid JSON String:

java - 我可以在同一个操作中使用多种方法吗?

javascript - 一个单元格中的多个值作为组合框

extjs - Sencha : Cannot satisfy requirements for "ext"