if (!this.getButton('PasteToggle').inactive) {
switch (this.currentBehaviour) {
case 'plainText':
- // Only IE and WebKit will allow access to the clipboard content, in plain text only however
- if (Ext.isIE || Ext.isWebKit) {
+ // Only IE before IE9 and Chrome will allow access to the clipboard content by default, in plain text only however
+ if (HTMLArea.isIEBeforeIE9 || Ext.isChrome) {
var clipboardText = this.grabClipboardText(event);
if (clipboardText) {
this.editor.getSelection().insertHtml(clipboardText);
case 'pasteStructure':
case 'pasteFormat':
if (Ext.isIE) {
- // Save the current selection
- this.bookmark = this.editor.getBookMark().get(this.editor.getSelection().createRange());
// Show the pasting pad
this.openPastingPad(
'PasteToggle',
height: 550
},
'PasteToggle'
- ));
- event.browserEvent.returnValue = false;
+ )
+ );
+ if (HTMLArea.isIEBeforeIE9) {
+ event.browserEvent.returnValue = false;
+ } else {
+ event.stopEvent();
+ }
return false;
} else {
// Redirect the paste operation to a hidden section
*/
onPastingPadAfterRender: function () {
var iframe = this.dialog.getComponent('pasting-pad-iframe').getEl().dom;
- var pastingPadDocument = iframe.contentWindow ? iframe.contentWindow.document : iframe.contentDocument;
- this.pastingPadBody = pastingPadDocument.body;
+ this.pastingPadDocument = iframe.contentWindow ? iframe.contentWindow.document : iframe.contentDocument;
+ this.pastingPadBody = this.pastingPadDocument.body;
this.pastingPadBody.contentEditable = true;
- // Start monitoring paste events
+ // Start monitoring paste events
this.dialog.mon(Ext.get(this.pastingPadBody), 'paste', this.onPastingPadPaste, this);
+ // Try to keep focus on the pasting pad
+ this.dialog.mon(Ext.get(this.editor.document.documentElement), 'mouseover', function (event) { this.focusOnPastingPad(); }, this);
+ this.dialog.mon(Ext.get(this.editor.document.body), 'focus', function (event) { this.focusOnPastingPad(); }, this);
+ this.dialog.mon(Ext.get(this.pastingPadDocument.documentElement), 'mouseover', function (event) { this.focusOnPastingPad(); }, this);
+ this.focusOnPastingPad();
+ },
+ /*
+ * Bring focus and selection on the pasting pad
+ */
+ focusOnPastingPad: function () {
this.pastingPadBody.focus();
+ this.pastingPadDocument.getSelection().selectAllChildren(this.pastingPadBody);
+ this.pastingPadDocument.getSelection().collapseToEnd();
},
/*
* Handler invoked when content is pasted into the pasting pad
* Clean the contents of the pasting pad
*/
cleanPastingPadContents: function () {
- this.pastingPadBody.innerHTML = this.cleaners[this.currentBehaviour].render(this.pastingPadBody, false);
+ var content = '';
+ switch (this.currentBehaviour) {
+ case 'plainText':
+ // Get plain text content
+ content = this.pastingPadBody.textContent;
+ break;
+ case 'pasteStructure':
+ case 'pasteFormat':
+ // Get clean content
+ content = this.cleaners[this.currentBehaviour].render(this.pastingPadBody, false);
+ break;
+ }
+ this.pastingPadBody.innerHTML = content;
this.pastingPadBody.focus();
},
/*