mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 20:12:14 +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
|
* Upload plugin for Rhymix
|
||||||
*/
|
*/
|
||||||
CKEDITOR.plugins.add('rx_upload', {
|
CKEDITOR.plugins.add('rx_paste', {
|
||||||
|
|
||||||
init: function(editor) {
|
init: function(editor) {
|
||||||
|
|
||||||
|
|
@ -20,21 +20,25 @@ CKEDITOR.plugins.add('rx_upload', {
|
||||||
*/
|
*/
|
||||||
editor.on('paste', function(event) {
|
editor.on('paste', function(event) {
|
||||||
|
|
||||||
// Check if the pasted data contains any files.
|
|
||||||
const method = event.data.method;
|
const method = event.data.method;
|
||||||
|
const dataValue = event.data.dataValue;
|
||||||
const dataTransfer = event.data.dataTransfer;
|
const dataTransfer = event.data.dataTransfer;
|
||||||
const files_count = dataTransfer.getFilesCount();
|
const filesCount = dataTransfer.getFilesCount();
|
||||||
if (!files_count) {
|
|
||||||
return;
|
// 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.
|
// Check if the pasted data contains any files.
|
||||||
|
if (filesCount) {
|
||||||
event.stop();
|
event.stop();
|
||||||
|
for (let i = 0; i < filesCount; i++) {
|
||||||
// Read and upload each file.
|
|
||||||
for (let i = 0; i < files_count; i++) {
|
|
||||||
uploadFile(dataTransfer.getFile(i));
|
uploadFile(dataTransfer.getFile(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,7 +15,9 @@ $ckconfig->ios_patch = (bool)preg_match('/i(Phone|Pad|Pod)/', $_SERVER['HTTP_USE
|
||||||
// Plugin configuration
|
// Plugin configuration
|
||||||
$ckconfig->add_plugins = $editor_additional_plugins ?? [];
|
$ckconfig->add_plugins = $editor_additional_plugins ?? [];
|
||||||
$ckconfig->remove_plugins = $editor_remove_plugins ?? [];
|
$ckconfig->remove_plugins = $editor_remove_plugins ?? [];
|
||||||
$ckconfig->add_plugins[] = 'rx_upload';
|
if (!in_array('clipboard', $ckconfig->remove_plugins)) {
|
||||||
|
$ckconfig->add_plugins[] = 'rx_paste';
|
||||||
|
}
|
||||||
if ($ckconfig->ios_patch) {
|
if ($ckconfig->ios_patch) {
|
||||||
$ckconfig->add_plugins[] = 'divarea';
|
$ckconfig->add_plugins[] = 'divarea';
|
||||||
$ckconfig->add_plugins[] = 'ios_enterkey';
|
$ckconfig->add_plugins[] = 'ios_enterkey';
|
||||||
|
|
|
||||||
|
|
@ -162,14 +162,6 @@ function getAutoSavedSrl(ret_obj) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.on('paste', function(e) {
|
|
||||||
if (e.data && e.data.dataValue && e.data.dataValue.replace) {
|
|
||||||
e.data.dataValue = e.data.dataValue.replace(/<(iframe|object)\s[^<>]+<\/\1>/g, function(m) {
|
|
||||||
return String(m).unescape() + '<p> </p>';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$containerEl.data('cke_instance', instance);
|
$containerEl.data('cke_instance', instance);
|
||||||
|
|
||||||
window.editorRelKeys[data.editorSequence] = {};
|
window.editorRelKeys[data.editorSequence] = {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue