我正在尝试在 SWT 控件中通过Ecilpse Nebula使用嵌入式 CKEditor。它通过 Eclipse RCP 中的内置浏览器引擎使用 CKEditor。控件尝试使用 CKEdior 的startupFocus来初始化 HTML 页面中的简单 HTML 文本区域中的 CKEditor ,但调用失败。它不能始终如一地工作,在一台机器上工作,但在另一台机器上却不行。以下是 Nebula 类的代码片段,请指出正确的方向,为什么它并不总是有效。提前致谢。
CKEDITOR.replace( 'editor',
{
startupFocus : true,
on: {
'instanceReady' : function(event) {
//maximize the editor after the editor instance is ready
maximizeEditorHeight();
event.editor.on('resize', function(resizeEvent) {
if ((prevHeight == null) || prevHeight != resizeEvent.editor.container.$.clientHeight) {
prevHeight = CKEDITOR.instances.editor.container.$.clientHeight;
if (!mouseDown) {
// if the resize is trigger by an external event,
// e.g. toolbar expand/collapse
maximizeEditorHeight();
}
if (resizeCallbackEnabled) {
resizeParentContainer();
}
}
else if (prevHeight == CKEDITOR.instances.editor.container.$.clientHeight) {
prevHeight = null;
}
});
},
//notify the FocusListener
'focus' : function() { focusIn(); },
'blur' : function() { focusOut(); },
//notify the ModifyListener
'change' : function() { textModified(); },
//ensure the key pressed event is fired if Enter is pressed
'key' : function(event) { event.data.preventDefault(false); },
//notify the KeyListener
'contentDom' : function() {
this.document.on('keydown', function(evt) {
if (evt.data.$.ctrlKey && evt.data.getKey() == 70) {
//prevent opening of browser find dialog on CTRL + F
evt.data.preventDefault(false);
//open the ckeditor find and replace dialog
CKEDITOR.instances.editor.execCommand('find')
}
else if (evt.data.$.ctrlKey && evt.data.getKey() == 72) {
evt.data.preventDefault(false);
//open the ckeditor find and replace dialog
CKEDITOR.instances.editor.execCommand('replace')
}
keyPressed(evt.data.getKey(), evt.data.getKeystroke());
});
this.document.on('keyup', function(evt) {
keyReleased(evt.data.getKey(), evt.data.getKeystroke());
});
}
}
});