由于tinyMCE 4与以前的版本相比有很大的变化,有人已经试图将extjs 4. *集成到新版本的tinyMCE中吗?将tinyMCE 4集成到extJS中4
4
A
回答
1
基本集成是非常简单的实现:
Ext.define('TinyMceField', {
extend: 'Ext.form.field.TextArea'
,alias: 'widget.tinymce'
/**
* TinyMCE editor configuration.
*
* @cfg {Object}
*/
,editorConfig: undefined
,afterRender: function() {
this.callParent(arguments);
var me = this,
id = this.inputEl.id;
var editor = tinymce.createEditor(id, Ext.apply({
selector: '#' + id
,resize: false
,height: this.height
,width: this.width
,menubar: false
}, this.editorConfig));
this.editor = editor;
// set initial value when the editor has been rendered
editor.on('init', function() {
editor.setContent(me.value || '');
});
// render
editor.render();
// --- Relay events to Ext
editor.on('focus', function() {
me.previousContent = editor.getContent();
me.fireEvent('focus', me);
});
editor.on('blur', function() {
me.fireEvent('blur', me);
});
editor.on('change', function(e) {
var content = editor.getContent(),
previousContent = me.previousContent;
if (content !== previousContent) {
me.previousContent = content;
me.fireEvent('change', me, content, previousContent);
}
});
}
,getRawValue: function() {
var editor = this.editor,
value = editor && editor.initialized ? editor.getContent() : Ext.value(this.rawValue, '');
this.rawValue = value;
return value;
}
,setRawValue: function(value) {
this.callParent(arguments);
var editor = this.editor;
if (editor && editor.initialized) {
editor.setContent(value);
}
return this;
}
});
用法示例(see fiddle):
Ext.widget('window', {
width: 400
,height: 350
,layout: 'form'
,items: [{
xtype: 'textfield'
,fieldLabel: 'Foo'
}, {
xtype: 'tinymce'
,id: 'tinyEditor'
,fieldLabel: 'Bar'
,value: '<p>Foo</p><p><strong>Bar</strong></p>'
,listeners: {
change: function(me, newValue, oldValue) {
console.log('content changed: ' + oldValue + ' => ' + newValue);
}
,blur: function() { console.log('editor blurred'); }
,focus: function() { console.log('editor focused'); }
}
}]
,bbar: [{
text: 'Get value'
,handler: function() {
var e = Ext.getCmp('tinyEditor');
alert(e.getValue());
}
}]
});
1
我创建了一个分机4.2.1插件TinyMCE的4.0.20以及一个相关的Sencha Architect扩展,可轻松将TinyMCE插入到您的Ext 4应用程序中。
全部细节在此说明,链接到Git仓库沿着:
相关问题
- 1. TinyMCE的4 elFinder集成
- 2. 将TinyMce 3.x升级到TinyMce 4.x
- 3. EXTJS 4和CakePHP 1.3模型集成
- 4. 如何将AsMock集成到AsUnit 4中?
- 5. 将TinyMCE集成到django中
- 6. 无法将extjs 3迁移到extjs 4
- 7. Rails 4:如何将payumoney网关集成到rails 4中?
- 8. 在角4集成OnsenUI 4
- 9. Autofac集成到棱镜4
- 10. extjs 4
- 11. ExtJs 4 ...如何扩展Extjs 4组件?
- 12. TinyMCE 4 with elFinder
- 13. Extjs 3 to Extjs 4
- 14. 在Xcode 4中集成mogenerator
- 15. Xcode 4 git集成
- 16. 将extjs 4字段POST到store.load
- 17. 将项目添加到窗口Extjs 4
- 18. Highcharts和Extjs 4
- 19. TinyMCE 4 valid_elements默认规则集
- 20. 将Ext.data.JsonReader从ExtJs 3转换为ExtJs 4
- 21. ExtJs 4 comboboxes loading
- 22. 在EXTJS 4
- 23. ExtJS 4 Set Reader
- 24. 在ExtJS 4中拖放小部件4
- 25. 从ExtJS的4
- 26. 将elFinder,TinyMCE集成到Laravel 5.1中
- 27. 将tinymce集成到rails + backbone中
- 28. 拖放到ExtJS的4
- 29. 得到一排ExtJS的4
- 30. 在EXTJS 4