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 nameValid = textValidator(ev, $nameInput, 0,
|
||||
<%= Constants::NAME_MAX_LENGTH %>);
|
||||
var $descrTextarea = $form.find("#result_result_text_attributes_text");
|
||||
var $tinyMCEInput = TinyMCE.init('#result_result_text_attributes_text');;
|
||||
var $descrTextarea = $form.find("#result_text_attributes_textarea");
|
||||
var $tinyMCEInput = TinyMCE.getContent();
|
||||
textValidator(ev, $descrTextarea, 1, <%= Constants::RICH_TEXT_MAX_LENGTH %>, false, $tinyMCEInput);
|
||||
break;
|
||||
case ResultTypeEnum.COMMENT:
|
||||
|
@ -216,6 +216,7 @@
|
|||
event.stopImmediatePropagation();
|
||||
$(form).remove();
|
||||
toggleResultEditButtons(true);
|
||||
TinyMCE.destroyAll();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
formAjaxResultText($form);
|
||||
Results.initCancelFormButton($form, initNewReslutText);
|
||||
Results.toggleResultEditButtons(false);
|
||||
TinyMCE.refresh();
|
||||
TinyMCE.highlight();
|
||||
TinyMCE.init('#result_text_attributes_textarea');
|
||||
$('#result_name').focus();
|
||||
},
|
||||
error: function() {
|
||||
|
@ -55,11 +54,11 @@
|
|||
$form.after($prevResult);
|
||||
$form.remove();
|
||||
applyEditResultTextCallback();
|
||||
TinyMCE.destroyAll();
|
||||
Results.toggleResultEditButtons(true);
|
||||
});
|
||||
Results.toggleResultEditButtons(false);
|
||||
TinyMCE.refresh();
|
||||
TinyMCE.init('#result_result_text_attributes_text');
|
||||
TinyMCE.init('#result_text_attributes_textarea');
|
||||
$('#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
|
||||
tinyMceContainer = $(selector).closest('form').find('.tinymce-view');
|
||||
tinyMceInitSize = tinyMceContainer.height();
|
||||
$(selector).closest('form').find('.form-group')
|
||||
$(selector).closest('.form-group')
|
||||
.before('<div class="tinymce-placeholder" style="height:' + tinyMceInitSize + 'px"></div>');
|
||||
tinyMceContainer.addClass('hidden');
|
||||
|
||||
|
|
|
@ -300,7 +300,9 @@
|
|||
images = $.map($('img', iframe), e => {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -334,4 +336,4 @@
|
|||
'customimageuploader',
|
||||
tinymce.plugins.CustomImageUploader
|
||||
);
|
||||
})();
|
||||
}());
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<%= bootstrap_form_for(@result, url: result_text_path(format: :json), remote: :true) do |f| %>
|
||||
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
||||
<%= f.fields_for :result_text do |ff| %>
|
||||
<div class="form-group">
|
||||
<%= ff.tiny_mce_editor(:text,
|
||||
value: @result.result_text.tinymce_render(:text),
|
||||
data: { object_type: 'result_text',
|
||||
object_id: @result.result_text.id }) %>
|
||||
</div>
|
||||
<%= ff.tiny_mce_editor(:text,
|
||||
id: :result_text_attributes_textarea,
|
||||
value: @result.result_text.tinymce_render(:text),
|
||||
data: { object_type: 'result_text',
|
||||
object_id: @result.result_text.id,
|
||||
highlightjs_path: asset_path('highlightjs-github-theme.css') }) %>
|
||||
<% end %><br />
|
||||
<div class="align-right">
|
||||
<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| %>
|
||||
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
||||
<%= f.fields_for :result_text do |ff| %>
|
||||
<div class="form-group">
|
||||
<%= ff.tiny_mce_editor(:text, data: { object_type: 'result_text',
|
||||
object_id: @result.result_text.id }) %>
|
||||
</div>
|
||||
<%= ff.tiny_mce_editor(:text,
|
||||
id: :result_text_attributes_textarea,
|
||||
data: { object_type: 'result_text',
|
||||
object_id: @result.result_text.id,
|
||||
highlightjs_path: asset_path('highlightjs-github-theme.css') }) %>
|
||||
<% end %><br />
|
||||
<div class="align-right">
|
||||
<button type="button" class="btn btn-default cancel-new">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="ql-editor">
|
||||
<%= custom_auto_link(result.result_text.text,
|
||||
<%= custom_auto_link(result.result_text.tinymce_render(:text),
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
team: current_team) %>
|
||||
|
|
Loading…
Reference in a new issue