-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #976 from ckeditor/t/662-2974
Paste replacement
- Loading branch information
Showing
76 changed files
with
61,649 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Get Clipboard HTML and RTF</title> | ||
<style> | ||
|
||
textarea { | ||
border: 1px solid #808080; | ||
float: left; | ||
height: 200px; | ||
width: 100%; | ||
overflow: auto; | ||
margin-bottom: 20px;; | ||
} | ||
|
||
</style> | ||
<script src="../../ckeditor.js"></script> | ||
</head> | ||
<body> | ||
<p>Paste Inside the Editor:</p> | ||
<div><textarea id="input"></textarea></div> | ||
<div> | ||
<div style="float: left; width: 49%"> | ||
<p>Raw HTML Data Received:</p> | ||
<textarea data-name="input.html" id="rawHtml" readonly="readonly"></textarea> | ||
<button id="htmlData">Save HTML Data</button> | ||
</div> | ||
<div style="float: right; width: 49%"> | ||
<p>Raw RTF Data Received:</p> | ||
<textarea data-name="input.rtf" id="rawRtf" readonly="readonly"></textarea> | ||
<button id="rtfData">Save RTF Data</button> | ||
</div> | ||
</div> | ||
<div style="width: 100%; float: left;"> | ||
<p>After Paste Processing:</p> | ||
<textarea id="output" readonly="readonly"></textarea> | ||
</div> | ||
|
||
<script> | ||
var editor = CKEDITOR.replace( 'input', { | ||
height: 100, | ||
allowedContent: true, | ||
plugins: 'pastefromword,pastefromwordimage,wysiwygarea' | ||
} ); | ||
|
||
editor.on( 'paste', function( evt ) { | ||
var val = evt.data.dataValue; | ||
|
||
if ( evt.data.dataTransfer && evt.data.dataTransfer.getData( 'text/html', true ) ) { | ||
val = evt.data.dataTransfer.getData( 'text/html', true ); | ||
} | ||
document.getElementById( 'rawHtml' ).value = val; | ||
|
||
if ( evt.data.dataTransfer && evt.data.dataTransfer.getData( 'text/rtf', true ) ) { | ||
val = evt.data.dataTransfer.getData( 'text/rtf', true ); | ||
} | ||
document.getElementById( 'rawRtf' ).value = val; | ||
|
||
}, null, null, -1 ); | ||
|
||
editor.on( 'paste', function( evt ) { | ||
setTimeout( function() { | ||
document.getElementById( 'output' ).value = editor.getData(); | ||
}, 0 ); | ||
}, null, null, 999 ); | ||
|
||
var rtfButton = document.getElementById( 'rtfData' ), | ||
htmlButton = document.getElementById( 'htmlData' ); | ||
|
||
rtfButton.onclick = save( document.getElementById( 'rawRtf' ) ); | ||
htmlButton.onclick = save( document.getElementById( 'rawHtml' ) ); | ||
|
||
function save( input ) { | ||
return function() { | ||
var textBlob = new Blob( [ input.value ], { type: 'text/plain' } ); | ||
var saveLink = document.createElement( 'a' ); | ||
|
||
saveLink.download = input.dataset.name; | ||
saveLink.innerHTML = 'Save file'; | ||
if ( CKEDITOR.env.webkit ) { | ||
saveLink.href = window.URL.createObjectURL( textBlob ); | ||
} else { | ||
saveLink.href = window.URL.createObjectURL( textBlob ); | ||
saveLink.onclick = function( evt ) { | ||
document.body.removeChild( evt.target ) | ||
}; | ||
saveLink.style.display = 'none'; | ||
document.body.appendChild( saveLink ); | ||
} | ||
saveLink.click(); | ||
} | ||
} | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+22.3 KB
...efromwordimage/generated/_fixtures/Online_and_offline_image/Online_and_offline_image.docx
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/plugins/pastefromwordimage/generated/_fixtures/Online_and_offline_image/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p style="margin-left:0in; margin-right:0in"><span style="font-size:11pt"><span style="line-height:107%"><span>Kitty from internet: <img alt="http://placekitten.com/200/305" style="width:200px; height:305px" src="http://placekitten.com/200/305" /></span></span></span></p><p style="margin-left:0in; margin-right:0in"><span style="font-size:11pt"><span style="line-height:107%"><span>My drawing: <img style="width:32px; height:32px" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOwgAADsIBFShKgAAAAOdJREFUSEvtljEWgjAQRA0HsLG19P4nsrS18QK6efFBMpMsS1hS+KQDNn+YAbIbntfb5XE/lcf7BRdMp+GMZQIPvLSPPnNAphDYia5qLAI6ne0b678CrWrm2iNNazUBC33Wqz6iEKIA39uEVjSigBc9yTBtMn3h5iK2jgJ94SgPUAi40AHiHBFbGSjgkk9ykKMGOjB/itsK/w5W81oi8uo2sCP92DtwSQkgwyPaaaLSvo5umfWIOnw055JWL+V9sfVP6SPPqMFL97G6H0BB3g9w+O1IX6HLrUkm7Lwijko0hRsd8FqBfwBKE0DK1O0llgAAAABJRU5ErkJggg==" /> hehehehe :D <img style="width:32px; height:32px" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOwgAADsIBFShKgAAAAU1JREFUSEu9ljEOwjAMRZvuXZhhAiQOADvszNwBcQkugbgDMzvscAAkxNQZBjhAsIjaJnaT2m1p1aWN/Z/tOK3Vsz/qpfcIXR+F33CeE42sXoOx0hq/jeqp59ouxgU0lC5jWICg+vC0ROk/FsdQ2bI8MoBHnepSUS/pxwgBOOo5rxyT6B/ADX++unJaxmdzPkyLpUTHTXsmHMtHxU2C5fhigKjuYkAr6khE6XcRh1kb7Ld2aOnaeaRRU3u7ozrcA1F9Lpsb3L49sKUEGRjRsDRFcgE03tluIu4in0OgGpUMVgYQbH5XKiIDFoCKMusDjgWg4vueQUwq4Tw6PQfVJ1ladDj53gyYVeLXx9kDaaRMe9xFrSRhs+OITEvM0Fhmpf9k4yn69oF98KcP638fW/wMX0LCwcvI/GF0dLuolQ13RWKYsJ1+gOXaGOIL4l+GAZPNqBWlOAAAAABJRU5ErkJggg==" /></span></span></span></p> |
Oops, something went wrong.