-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paste replacement #976
Merged
Merged
Paste replacement #976
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d84763d
Changes in PFW required for images.
eae8e25
Some working example. Base for further improvements.
c434d75
Add fixture generator for PFWImage.
242c8cf
Adding library necessary for auto-generated tests.
08b1490
Add auto-generated unit tests.
693e3f1
Small code improvements such as: renaming variables, extracting code …
091aa2f
Adding manual tests.
5da4676
Hot fixes after rebasing on t/662-2973.
22f7e81
Adding new fixtures.
5d870ea
Little code improvement, adding macos support for test.
54d2498
Set font-family as disallowed to fix Unit tests on Firefox. Remove fo…
17cc5dd
Fix test name for helpers.
d2d8a13
Fix typos.
f1ames 2e852c0
Update PFW autogenerated test to support RTF clipboard. Remove test g…
ab1ff15
Rename test cases to be more consistent.
aa75e08
Move PFW Image logic outside of plugin definition. Update Manual tests.
bd65d9c
Typo fixes.
f1ames b9b878a
Test updates. Small code improvements in plugin.
31f7874
Manual test - ignore on loaded.
f1ames 2055b4d
Review: rename tests, fix links
6388b13
Some rewording.
f1ames File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
* @param {Boolean} [options.compareRawData=false] If `true` test case will assert against raw paste's `data.dataValue` rather than | ||
* what will appear in the editor after all transformations and filtering. | ||
* @param {Boolean} [options.ignoreAll=false] Whenever to ignore all tests. | ||
* @param {Boolean} [options.includeRTF=false] Whether RTF clipboard should be loaded in test case. | ||
* @returns {Object} Test data object which should be passed to `bender.test` function. | ||
*/ | ||
function createTestSuite( options ) { | ||
|
@@ -24,7 +25,8 @@ function createTestSuite( options ) { | |
testData: { _should: { ignore: {} } }, | ||
ignoreAll: false, | ||
compareRawData: false, | ||
customFilters: null | ||
customFilters: null, | ||
includeRTF: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing docs for |
||
} ); | ||
|
||
var testData = options.testData, | ||
|
@@ -52,7 +54,8 @@ function createTestSuite( options ) { | |
wordVersion: wordVersion, | ||
browser: options.browsers[ j ], | ||
compareRawData: options.compareRawData, | ||
customFilters: options.customFilters | ||
customFilters: options.customFilters, | ||
includeRTF: options.includeRTF | ||
} ); | ||
} | ||
} | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could also add a container which will show all images pasted to the CKEditor (in the form already transformed by CKEditor), something like
Extracted Images
? If it's relatively easy to do (like 0,5h) you could take a look at it. From the other hand you can see pasted images inside editor instance, so not sure if it is needed. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this stage of implementation it might be problematic. I could process RTF clipboard, but it might contains also Word Shapes, which are ignored for processing while pasting. That's why preparing similar solution here might be repeating functionality of the plugin, which seems to be not a good thing.
It should be easier, when further changes related to file transfer will be implemented:
https://github.com/ckeditor/ckeditor-dev/blob/128516a52485505176189743962eaf97d52aa067/plugins/pastefromwordimage/plugin.js#L60-L63
There is nice event when will be exposed processed URL and image which is going to be embed. With that implementation it should be like 0,5h of work :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msamsel Ok, so let's leave it as it is for now.