mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 04:32:16 +08:00
Fix TinyMCE for results [SCI-3398]
This commit is contained in:
parent
6bb19ed0be
commit
077ad52d4b
7 changed files with 23 additions and 20 deletions
|
@ -146,8 +146,8 @@
|
||||||
var $nameInput = $form.find('#result_name');
|
var $nameInput = $form.find('#result_name');
|
||||||
var nameValid = textValidator(ev, $nameInput, 0,
|
var nameValid = textValidator(ev, $nameInput, 0,
|
||||||
<%= Constants::NAME_MAX_LENGTH %>);
|
<%= Constants::NAME_MAX_LENGTH %>);
|
||||||
var $descrTextarea = $form.find("#result_result_text_attributes_text");
|
var $descrTextarea = $form.find("#result_text_attributes_textarea");
|
||||||
var $tinyMCEInput = TinyMCE.init('#result_result_text_attributes_text');;
|
var $tinyMCEInput = TinyMCE.getContent();
|
||||||
textValidator(ev, $descrTextarea, 1, <%= Constants::RICH_TEXT_MAX_LENGTH %>, false, $tinyMCEInput);
|
textValidator(ev, $descrTextarea, 1, <%= Constants::RICH_TEXT_MAX_LENGTH %>, false, $tinyMCEInput);
|
||||||
break;
|
break;
|
||||||
case ResultTypeEnum.COMMENT:
|
case ResultTypeEnum.COMMENT:
|
||||||
|
@ -216,6 +216,7 @@
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
$(form).remove();
|
$(form).remove();
|
||||||
toggleResultEditButtons(true);
|
toggleResultEditButtons(true);
|
||||||
|
TinyMCE.destroyAll();
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
formAjaxResultText($form);
|
formAjaxResultText($form);
|
||||||
Results.initCancelFormButton($form, initNewReslutText);
|
Results.initCancelFormButton($form, initNewReslutText);
|
||||||
Results.toggleResultEditButtons(false);
|
Results.toggleResultEditButtons(false);
|
||||||
TinyMCE.refresh();
|
TinyMCE.init('#result_text_attributes_textarea');
|
||||||
TinyMCE.highlight();
|
|
||||||
$('#result_name').focus();
|
$('#result_name').focus();
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
|
@ -55,11 +54,11 @@
|
||||||
$form.after($prevResult);
|
$form.after($prevResult);
|
||||||
$form.remove();
|
$form.remove();
|
||||||
applyEditResultTextCallback();
|
applyEditResultTextCallback();
|
||||||
|
TinyMCE.destroyAll();
|
||||||
Results.toggleResultEditButtons(true);
|
Results.toggleResultEditButtons(true);
|
||||||
});
|
});
|
||||||
Results.toggleResultEditButtons(false);
|
Results.toggleResultEditButtons(false);
|
||||||
TinyMCE.refresh();
|
TinyMCE.init('#result_text_attributes_textarea');
|
||||||
TinyMCE.init('#result_result_text_attributes_text');
|
|
||||||
$('#result_name').focus();
|
$('#result_name').focus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
2
app/assets/javascripts/sitewide/tiny_mce.js
vendored
2
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
@ -46,7 +46,7 @@ var TinyMCE = (function() {
|
||||||
// Hide element containing HTML view of RTE field
|
// Hide element containing HTML view of RTE field
|
||||||
tinyMceContainer = $(selector).closest('form').find('.tinymce-view');
|
tinyMceContainer = $(selector).closest('form').find('.tinymce-view');
|
||||||
tinyMceInitSize = tinyMceContainer.height();
|
tinyMceInitSize = tinyMceContainer.height();
|
||||||
$(selector).closest('form').find('.form-group')
|
$(selector).closest('.form-group')
|
||||||
.before('<div class="tinymce-placeholder" style="height:' + tinyMceInitSize + 'px"></div>');
|
.before('<div class="tinymce-placeholder" style="height:' + tinyMceInitSize + 'px"></div>');
|
||||||
tinyMceContainer.addClass('hidden');
|
tinyMceContainer.addClass('hidden');
|
||||||
|
|
||||||
|
|
|
@ -300,7 +300,9 @@
|
||||||
images = $.map($('img', iframe), e => {
|
images = $.map($('img', iframe), e => {
|
||||||
return e.dataset.mceToken;
|
return e.dataset.mceToken;
|
||||||
});
|
});
|
||||||
$('#' + editor.id).next()[0].value = JSON.stringify(images);
|
if ($('#' + editor.id).next()[0]) {
|
||||||
|
$('#' + editor.id).next()[0].value = JSON.stringify(images);
|
||||||
|
}
|
||||||
return JSON.stringify(images);
|
return JSON.stringify(images);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,4 +336,4 @@
|
||||||
'customimageuploader',
|
'customimageuploader',
|
||||||
tinymce.plugins.CustomImageUploader
|
tinymce.plugins.CustomImageUploader
|
||||||
);
|
);
|
||||||
})();
|
}());
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
<%= bootstrap_form_for(@result, url: result_text_path(format: :json), remote: :true) do |f| %>
|
<%= bootstrap_form_for(@result, url: result_text_path(format: :json), remote: :true) do |f| %>
|
||||||
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
||||||
<%= f.fields_for :result_text do |ff| %>
|
<%= f.fields_for :result_text do |ff| %>
|
||||||
<div class="form-group">
|
<%= ff.tiny_mce_editor(:text,
|
||||||
<%= ff.tiny_mce_editor(:text,
|
id: :result_text_attributes_textarea,
|
||||||
value: @result.result_text.tinymce_render(:text),
|
value: @result.result_text.tinymce_render(:text),
|
||||||
data: { object_type: 'result_text',
|
data: { object_type: 'result_text',
|
||||||
object_id: @result.result_text.id }) %>
|
object_id: @result.result_text.id,
|
||||||
</div>
|
highlightjs_path: asset_path('highlightjs-github-theme.css') }) %>
|
||||||
<% end %><br />
|
<% end %><br />
|
||||||
<div class="align-right">
|
<div class="align-right">
|
||||||
<button type="button" class="btn btn-default cancel-edit">
|
<button type="button" class="btn btn-default cancel-edit">
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
<%= bootstrap_form_for(@result, url: my_module_result_texts_path(format: :json), remote: true) do |f| %>
|
<%= bootstrap_form_for(@result, url: my_module_result_texts_path(format: :json), remote: true) do |f| %>
|
||||||
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
||||||
<%= f.fields_for :result_text do |ff| %>
|
<%= f.fields_for :result_text do |ff| %>
|
||||||
<div class="form-group">
|
<%= ff.tiny_mce_editor(:text,
|
||||||
<%= ff.tiny_mce_editor(:text, data: { object_type: 'result_text',
|
id: :result_text_attributes_textarea,
|
||||||
object_id: @result.result_text.id }) %>
|
data: { object_type: 'result_text',
|
||||||
</div>
|
object_id: @result.result_text.id,
|
||||||
|
highlightjs_path: asset_path('highlightjs-github-theme.css') }) %>
|
||||||
<% end %><br />
|
<% end %><br />
|
||||||
<div class="align-right">
|
<div class="align-right">
|
||||||
<button type="button" class="btn btn-default cancel-new">
|
<button type="button" class="btn btn-default cancel-new">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="ql-editor">
|
<div class="ql-editor">
|
||||||
<%= custom_auto_link(result.result_text.text,
|
<%= custom_auto_link(result.result_text.tinymce_render(:text),
|
||||||
simple_format: false,
|
simple_format: false,
|
||||||
tags: %w(img),
|
tags: %w(img),
|
||||||
team: current_team) %>
|
team: current_team) %>
|
||||||
|
|
Loading…
Reference in a new issue