由於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