mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-22 05:15:29 +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 !== '') {
|
if(temp_code !== '') {
|
||||||
try {
|
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) {
|
catch(err) {
|
||||||
// pass
|
// pass
|
||||||
|
|
@ -392,7 +403,19 @@
|
||||||
if (result) {
|
if (result) {
|
||||||
var html = self.generateHtml($container, result);
|
var html = self.generateHtml($container, result);
|
||||||
try {
|
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) {
|
catch(err) {
|
||||||
// pass
|
// pass
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,9 @@ body.cke_editable {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
@include light-dark($colorset);
|
@include light-dark($colorset);
|
||||||
}
|
}
|
||||||
|
textarea.cke_source.cke_editable {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
body.color_scheme_dark.cke_auto_dark_mode .cke_wysiwyg_div {
|
body.color_scheme_dark.cke_auto_dark_mode .cke_wysiwyg_div {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,13 @@ function _getCkeInstance(editor_sequence) {
|
||||||
return $('#ckeditor_instance_' + editor_sequence).data('cke_instance');
|
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.
|
* Legacy function to get HTML content from CKEditor.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue