forked from ckeditor/ckeditor4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow built-in image paste handling to be disabled (ckeditor#4874).
This will allow 3rd party plugins to handle images being pasted.
- Loading branch information
1 parent
b14851c
commit 7bf898b
Showing
3 changed files
with
70 additions
and
1 deletion.
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,42 @@ | ||
<div id="editor"> | ||
<p>Paste image here</p> | ||
<p></p> | ||
</div> | ||
|
||
<br><br> | ||
|
||
<button id="button"> Disable built-in image paste handling </button> | ||
|
||
<br><br> | ||
|
||
<div id="log">Log output:</div> | ||
|
||
<script> | ||
( function() { | ||
if ( !window.FileReader ) { | ||
return bender.ignore(); | ||
} | ||
|
||
CKEDITOR.plugins.add( 'customImagePasteHandlerPlugin', { | ||
init: function( editor ) { | ||
editor.on( 'paste', function( event ) { | ||
var log = document.querySelector( '#log' ); | ||
var msg = '<br>Custom image paste handling: image data received'; | ||
log.innerHTML += msg; | ||
} ); | ||
} | ||
} ); | ||
|
||
CKEDITOR.replace( 'editor' ); | ||
|
||
var button = document.querySelector( '#button' ); | ||
button.onclick = function() { | ||
CKEDITOR.instances.editor.destroy(); | ||
CKEDITOR.replace( 'editor', { | ||
// Allow 3rd party plugins to handle image pasting | ||
clipboard_handleImagePasting: false, | ||
extraPlugins: "customImagePasteHandlerPlugin" | ||
} ); | ||
} | ||
} )(); | ||
</script> |
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,17 @@ | ||
@bender-ui: collapsed | ||
@bender-tags: 4.17.0, clipboard, 4874 | ||
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, basicstyles, image, clipboard, sourcearea | ||
|
||
1. Paste an image into the editor. | ||
|
||
Observe that the image is inserted and that no "Custom image paste handling" entry is written to "log output" on the page. | ||
|
||
2. Click the "Disable built-in image paste handling" button. | ||
|
||
3. Paste an image into the editor. | ||
|
||
Observe that the image is not inserted, and that "log output" now shows "Custom image paste handling: image data received". | ||
|
||
**Expected** No image is inserted in step 3 but instead produces log output as described. | ||
|
||
**Unexpected** Image pasting is not suppressed in step 3 and/or no log output is produced. |