.
// 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;
this.own.apply(this,
array.map(events, function(item){
var type = item.toLowerCase().replace(/^on/, "");
return on(ap, type, lang.hitch(this, item));
}, this)
);
this.own(
// mouseup in the margin does not generate an onclick event
on(ap, "mouseup", lang.hitch(this, "onClick"))
);
if(has("ie")){ // IE contentEditable
this.own(on(this.document, "mousedown", lang.hitch(this, "_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;
}
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.own(on(this.document, "mouseup", lang.hitch(this, "onDisplayChanged")))[0];
this.own(on(this.document, "mousedown", lang.hitch(this, 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.
this.defer("placeCursorAtEnd");
}
})));
}
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(){
this.setValue(html);
// Tell app that the Editor has finished loading. isFulfilled() check avoids spurious
// console warning when this function is called repeatedly because Editor DOMNode was moved.
if(this.onLoadDeferred && !this.onLoadDeferred.isFulfilled()){
this.onLoadDeferred.resolve(true);
}
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
domReady(lang.hitch(this, "defer", "focus", this.updateInterval));
}
// Save off the initial content now
this.value = this.getValue(true);
});
if(this.setValueDeferred){
this.setValueDeferred.then(setContent);
}else{
setContent();
}
},
onKeyDown: function(/* Event */ e){
// summary:
// Handler for keydown event
// tags:
// protected
// Modifier keys should not cause the onKeyPressed event because they do not cause any change to the
// display
if(e.keyCode === keys.SHIFT ||
e.keyCode === keys.ALT ||
e.keyCode === keys.META ||
e.keyCode === keys.CTRL){
return true;
}
if(e.keyCode === keys.TAB && this.isTabIndent){
//prevent tab from moving focus out of editor
e.stopPropagation();
e.preventDefault();
// 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