mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-02 16:52:16 +09:00
Rename rx_upload CKEditor plugin to rx_paste, and move paste handler from editor.app.js to it
This commit is contained in:
parent
3e5951174e
commit
e15c913b21
3 changed files with 18 additions and 20 deletions
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* Upload plugin for Rhymix
|
||||
*/
|
||||
CKEDITOR.plugins.add('rx_upload', {
|
||||
CKEDITOR.plugins.add('rx_paste', {
|
||||
|
||||
init: function(editor) {
|
||||
|
||||
|
|
@ -20,20 +20,24 @@ CKEDITOR.plugins.add('rx_upload', {
|
|||
*/
|
||||
editor.on('paste', function(event) {
|
||||
|
||||
// Check if the pasted data contains any files.
|
||||
const method = event.data.method;
|
||||
const dataValue = event.data.dataValue;
|
||||
const dataTransfer = event.data.dataTransfer;
|
||||
const files_count = dataTransfer.getFilesCount();
|
||||
if (!files_count) {
|
||||
return;
|
||||
const filesCount = dataTransfer.getFilesCount();
|
||||
|
||||
// Replace iframe code in pasted text.
|
||||
if (method === 'paste' && dataValue && dataValue.replace) {
|
||||
event.data.dataValue = dataValue.replace(/<(iframe|object)\s[^<>]+<\/\1>/g, function(m) {
|
||||
return String(m).unescape() + '<p> </p>';
|
||||
});
|
||||
}
|
||||
|
||||
// Prevent the default plugin from touching these files.
|
||||
event.stop();
|
||||
|
||||
// Read and upload each file.
|
||||
for (let i = 0; i < files_count; i++) {
|
||||
uploadFile(dataTransfer.getFile(i));
|
||||
// Check if the pasted data contains any files.
|
||||
if (filesCount) {
|
||||
event.stop();
|
||||
for (let i = 0; i < filesCount; i++) {
|
||||
uploadFile(dataTransfer.getFile(i));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue