.
// See #4996 IE wants to focus the BODY tag.
this.beforeIframeNode = domConstruct.place("
", this.iframe, "before");
this.afterIframeNode = domConstruct.place("
", this.iframe, "after");
this.iframe.onfocus = this.document.onfocus = function(){
_this.editNode.focus();
};
this.focusNode = this.editNode; // for InlineEditBox
var events = this.events.concat(this.captureEvents);
var ap = this.iframe ? this.document : this.editNode;
array.forEach(events, function(item){
this.connect(ap, item.toLowerCase(), item);
}, this);
this.connect(ap, "onmouseup", "onClick"); // mouseup in the margin does not generate an onclick event
if(has("ie")){ // IE contentEditable
this.connect(this.document, "onmousedown", "_onIEMouseDown"); // #4996 fix focus
// give the node Layout on IE
// TODO: this may no longer be needed, since we've reverted IE to using an iframe,
// not contentEditable. Removing it would also probably remove the need for creating
// the extra
in _getIframeDocTxt()
this.editNode.style.zoom = 1.0;
}else{
this.connect(this.document, "onmousedown", function(){
// Clear the moveToStart focus, as mouse
// down will set cursor point. Required to properly
// work with selection/position driven plugins and clicks in
// the window. refs: #10678
delete this._cursorToStart;
});
}
if(has("webkit")){
//WebKit sometimes doesn't fire right on selections, so the toolbar
//doesn't update right. Therefore, help it out a bit with an additional
//listener. A mouse up will typically indicate a display change, so fire this
//and get the toolbar to adapt. Reference: #9532
this._webkitListener = this.connect(this.document, "onmouseup", "onDisplayChanged");
this.connect(this.document, "onmousedown", function(e){
var t = e.target;
if(t && (t === this.document.body || t === this.document)){
// Since WebKit uses the inner DIV, we need to check and set position.
// See: #12024 as to why the change was made.
setTimeout(lang.hitch(this, "placeCursorAtEnd"), 0);
}
});
}
if(has("ie")){
// Try to make sure 'hidden' elements aren't visible in edit mode (like browsers other than IE
// do). See #9103
try{
this.document.execCommand('RespectVisibilityInDesign', true, null);
}catch(e){/* squelch */}
}
this.isLoaded = true;
this.set('disabled', this.disabled); // initialize content to editable (or not)
// Note that setValue() call will only work after isLoaded is set to true (above)
// Set up a function to allow delaying the setValue until a callback is fired
// This ensures extensions like dijit.Editor have a way to hold the value set
// until plugins load (and do things like register filters).
var setContent = lang.hitch(this, function(){
var copyValue = this.value;
this.setValue(html);
// Defect #247392 - We added try/catch block in order to handle exception "This deferred has already been resolved".
// This happens in Cognos Workspace (BUX), while changing tab's order on the dashdoard, which contain "Text Editor" widget(s).
try {
if(this.onLoadDeferred){
this.onLoadDeferred.callback(true);
}
} catch (err) {
// This error message is hard coded in DOJO in english language version only so we safely can use it to decrease the impact of code change.
if (err.message === "This deferred has already been resolved") {
this.setValue(copyValue);
console.log("Caught exception: " + err.message);
} else {
throw err;
}
}
this.onDisplayChanged();
if(this.focusOnLoad){
// after the document loads, then set focus after updateInterval expires so that
// onNormalizedDisplayChanged has run to avoid input caret issues
ready(lang.hitch(this, function(){ setTimeout(lang.hitch(this, "focus"), this.updateInterval); }));
}
// Save off the initial content now
this.value = this.getValue(true);
});
if(this.setValueDeferred){
this.setValueDeferred.addCallback(setContent);
}else{
setContent();
}
},
onKeyDown: function(/* Event */ e){
// summary:
// Handler for onkeydown event
// tags:
// protected
// we need this event at the moment to get the events from control keys
// such as the backspace. It might be possible to add this to Dojo, so that
// keyPress events can be emulated by the keyDown and keyUp detection.
if(e.keyCode === keys.TAB && this.isTabIndent){
event.stop(e); //prevent tab from moving focus out of editor
// FIXME: this is a poor-man's indent/outdent. It would be
// better if it added 4 " " chars in an undoable way.
// Unfortunately pasteHTML does not prove to be undoable
if(this.queryCommandEnabled((e.shiftKey ? "outdent" : "indent"))){
this.execCommand((e.shiftKey ? "outdent" : "indent"));
}
}
// Make tab and shift-tab skip over the