mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Fix #877 insert uploaded image even if CKEditor is in source mode
This commit is contained in:
parent
f57cc96e3f
commit
f50772c1dd
3 changed files with 35 additions and 2 deletions
|
|
@ -187,7 +187,18 @@
|
|||
|
||||
if(temp_code !== '') {
|
||||
try {
|
||||
_getCkeInstance(settings.formData.editor_sequence).insertHtml(temp_code, "unfiltered_html");
|
||||
var textarea = _getCkeContainer(settings.formData.editor_sequence).find('.cke_source');
|
||||
var editor = _getCkeInstance(settings.formData.editor_sequence);
|
||||
if (textarea.length && editor.mode == 'source') {
|
||||
var caretPosition = textarea[0].selectionStart;
|
||||
var currentText = textarea[0].value;
|
||||
textarea.val(currentText.substring(0, caretPosition) + "\n" +
|
||||
temp_code + "\n" +
|
||||
currentText.substring(caretPosition)
|
||||
);
|
||||
} else {
|
||||
editor.insertHtml(temp_code, 'unfiltered_html');
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
// pass
|
||||
|
|
@ -392,7 +403,19 @@
|
|||
if (result) {
|
||||
var html = self.generateHtml($container, result);
|
||||
try {
|
||||
_getCkeInstance(data.editorSequence).insertHtml(html, 'unfiltered_html');
|
||||
var textarea = _getCkeContainer(data.editorSequence).find('.cke_source');
|
||||
var editor = _getCkeInstance(data.editorSequence);
|
||||
console.log(textarea, editor.mode);
|
||||
if (textarea.length && editor.mode == 'source') {
|
||||
var caretPosition = textarea[0].selectionStart;
|
||||
var currentText = textarea[0].value;
|
||||
textarea.val(currentText.substring(0, caretPosition) + "\n" +
|
||||
html + "\n" +
|
||||
currentText.substring(caretPosition)
|
||||
);
|
||||
} else {
|
||||
editor.insertHtml(html, 'unfiltered_html');
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
// pass
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ body.cke_editable {
|
|||
padding: 10px;
|
||||
@include light-dark($colorset);
|
||||
}
|
||||
textarea.cke_source.cke_editable {
|
||||
padding: 10px;
|
||||
}
|
||||
body.color_scheme_dark.cke_auto_dark_mode .cke_wysiwyg_div {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
|
|
|
|||
|
|
@ -199,6 +199,13 @@ function _getCkeInstance(editor_sequence) {
|
|||
return $('#ckeditor_instance_' + editor_sequence).data('cke_instance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy function to get the container element for CKEditor.
|
||||
*/
|
||||
function _getCkeContainer(editor_sequence) {
|
||||
return $('#ckeditor_instance_' + editor_sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy function to get HTML content from CKEditor.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue