mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-01 17:17:04 +08:00
Add env variable and check for MarvinJS available
This commit is contained in:
parent
260810fff8
commit
2847ec7609
10 changed files with 32 additions and 14 deletions
|
|
@ -195,7 +195,6 @@ var MarvinJsEditor = (function() {
|
|||
success: function(json) {
|
||||
config.image[0].src = json.url
|
||||
config.saveButton.removeClass('hidden')
|
||||
console.log(config.saveButton)
|
||||
$(marvinJsModal).modal('hide');
|
||||
}
|
||||
});
|
||||
|
|
@ -374,7 +374,7 @@
|
|||
|
||||
function initCallBacks() {
|
||||
applyCreateWopiFileCallback()
|
||||
MarvinJsEditor().initNewButton('.new-marvinjs-upload-button');
|
||||
if (typeof(MarvinJsEditor) !== 'undefined') MarvinJsEditor().initNewButton('.new-marvinjs-upload-button');
|
||||
applyCheckboxCallBack();
|
||||
applyStepCompletedCallBack();
|
||||
applyEditCallBack();
|
||||
|
|
|
|||
11
app/assets/javascripts/sitewide/tiny_mce.js
vendored
11
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
|
@ -42,6 +42,7 @@ var TinyMCE = (function() {
|
|||
init: function(selector, mceConfig = {}) {
|
||||
var tinyMceContainer;
|
||||
var tinyMceInitSize;
|
||||
var plugins;
|
||||
if (typeof tinyMCE !== 'undefined') {
|
||||
// Hide element containing HTML view of RTE field
|
||||
tinyMceContainer = $(selector).closest('form').find('.tinymce-view');
|
||||
|
|
@ -49,14 +50,14 @@ var TinyMCE = (function() {
|
|||
$(selector).closest('form').find('.form-group')
|
||||
.before('<div class="tinymce-placeholder" style="height:' + tinyMceInitSize + 'px"></div>');
|
||||
tinyMceContainer.addClass('hidden');
|
||||
|
||||
|
||||
plugins = 'autosave autoresize customimageuploader link advlist codesample autolink lists charmap hr anchor searchreplace wordcount visualblocks visualchars insertdatetime nonbreaking save directionality paste textcolor colorpicker textpattern'
|
||||
if (typeof(MarvinJsEditor) !== 'undefined') plugins += ' marvinjsplugin'
|
||||
tinyMCE.init({
|
||||
cache_suffix: '?v=4.9.3', // This suffix should be changed any time library is updated
|
||||
selector: selector,
|
||||
menubar: 'file edit view insert format',
|
||||
toolbar: 'undo redo restoredraft | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | forecolor backcolor | customimageuploader marvinjsplugin | codesample',
|
||||
plugins: 'autosave autoresize marvinjsplugin customimageuploader link advlist codesample autolink lists charmap hr anchor searchreplace wordcount visualblocks visualchars insertdatetime nonbreaking save directionality paste textcolor colorpicker textpattern',
|
||||
plugins: plugins,
|
||||
codesample_languages: [
|
||||
{ text: 'R', value: 'r' },
|
||||
{ text: 'MATLAB', value: 'matlab' },
|
||||
|
|
@ -183,8 +184,10 @@ var TinyMCE = (function() {
|
|||
editLink = editorContainer.find('.tinymce-active-object-handler .file-edit-link')
|
||||
if (image[0].dataset.sourceId) {
|
||||
editLink.css('display','inline-block')
|
||||
var marvinJsEdit = (image[0].dataset.sourceType === 'MarvinJsAsset' && typeof(MarvinJsEditor) !== 'undefined')
|
||||
if (!marvinJsEdit) editLink.css('display','none')
|
||||
editLink.on('click', function(){
|
||||
if (image[0].dataset.sourceType === 'MarvinJsAsset'){
|
||||
if (marvinJsEdit){
|
||||
MarvinJsEditor().open({
|
||||
mode: 'edit-tinymce',
|
||||
marvinUrl: '/marvin_js_assets/'+image[0].dataset.sourceId,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module MyModulesHelper
|
|||
def ordered_assets(step)
|
||||
assets=[]
|
||||
assets += step.assets
|
||||
assets += step.marvin_js_assets
|
||||
assets += step.marvin_js_assets if MarvinJsAsset.enabled?
|
||||
assets.sort! { |a, b|
|
||||
a[asset_date_sort_field(a)] <=> b[asset_date_sort_field(b)]
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ module MyModulesHelper
|
|||
def az_ordered_assets_index(step, asset_id)
|
||||
assets=[]
|
||||
assets += step.assets
|
||||
assets += step.marvin_js_assets
|
||||
assets += step.marvin_js_assets if MarvinJsAsset.enabled?
|
||||
assets.sort! { |a, b|
|
||||
(a[asset_name_sort_field(a)] || '').downcase <=> (b[asset_name_sort_field(b)] || '').downcase
|
||||
}.pluck(:id).index(asset_id)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,14 @@ class MarvinJsAsset < ApplicationRecord
|
|||
|
||||
belongs_to :team, inverse_of: :marvin_js_assets, optional: true
|
||||
|
||||
def self.url
|
||||
ENV['MARVINJS_URL']
|
||||
end
|
||||
|
||||
def self.enabled?
|
||||
ENV['MARVINJS_URL'] != nil
|
||||
end
|
||||
|
||||
def self.add_sketch(values,team)
|
||||
if values[:object_type] == 'TinyMceAsset'
|
||||
tiny_mce_img = TinyMceAsset.new(
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@
|
|||
<%= render "shared/about_modal" %>
|
||||
<%= render "shared/file_preview_modal.html.erb" %>
|
||||
<%= render "shared/file_edit_modal.html.erb" %>
|
||||
<%= render "shared/marvinjs_modal.html.erb" %>
|
||||
<% if MarvinJsAsset.enabled? %>
|
||||
<%= render "shared/marvinjs_modal.html.erb" %>
|
||||
<% end %>
|
||||
<%= render "shared/navigation" %>
|
||||
|
||||
<% if user_signed_in? && flash[:system_notification_modal] && current_user.show_login_system_notification? %>
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="marvinjs-editor">
|
||||
<iframe id="marvinjs-sketch" src="/marvinjs/editor.html"
|
||||
<iframe id="marvinjs-sketch" src="<%= MarvinJsAsset.url %>"
|
||||
style="overflow: hidden; min-width: 500px; min-height: 450px" ></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= javascript_include_tag("sitewide/marvinjs_editor") %>
|
||||
<%= javascript_include_tag("marvinjs_editor") %>
|
||||
|
|
@ -24,12 +24,14 @@
|
|||
<%= t("protocols.steps.new.tab_tables") %>
|
||||
</a>
|
||||
</li>
|
||||
<% if MarvinJsAsset.enabled? %>
|
||||
<li role="presentation" id="new-step-sketch-tab">
|
||||
<a href="#new-step-sketch" data-toggle="tab" data-no-turbolink="true">
|
||||
<span class="fas fa-file-invoice"></span>
|
||||
<%= t('marvinjs.checmical_drawing') %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" role="tabpanel" id="new-step-main">
|
||||
|
|
@ -90,6 +92,7 @@
|
|||
<%= t("protocols.steps.new.add_table") %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if MarvinJsAsset.enabled? %>
|
||||
<div class="tab-pane" role="tabpanel" id="new-step-sketch">
|
||||
<div class="sketch-container">
|
||||
<% @step.marvin_js_assets.each do |sketch| %>
|
||||
|
|
@ -98,4 +101,5 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@
|
|||
</div>
|
||||
<div class="col-xl-8 col-md-12">
|
||||
<div class="attachemnts-header pull-right">
|
||||
<%= render partial: '/assets/marvinjs/create_marvin_sketch_button.html.erb',
|
||||
locals: { element_id: step.id, element_type: 'Step', sketch_container: ".attacments#att-#{step.id}" } %>
|
||||
<% if MarvinJsAsset.enabled? %>
|
||||
<%= render partial: '/assets/marvinjs/create_marvin_sketch_button.html.erb',
|
||||
locals: { element_id: step.id, element_type: 'Step', sketch_container: ".attacments#att-#{step.id}" } %>
|
||||
<% end %>
|
||||
<%= render partial: '/assets/wopi/create_wopi_file_button.html.erb',
|
||||
locals: { element_id: step.id, element_type: 'Step' } %>
|
||||
<div class="dropdown attachments-order" id="dd-att-step-<%= step.id %>">
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ Rails.application.config.assets.precompile +=
|
|||
Rails.application.config.assets.precompile += %w(datatables.js)
|
||||
Rails.application.config.assets.precompile += %w(search/index.js)
|
||||
Rails.application.config.assets.precompile += %w(global_activities/side_pane.js)
|
||||
Rails.application.config.assets.precompile += %w( sitewide/marvinjs_editor.js )
|
||||
Rails.application.config.assets.precompile += %w(marvinjs_editor.js)
|
||||
Rails.application.config.assets.precompile += %w(navigation.js)
|
||||
Rails.application.config.assets.precompile += %w(secondary_navigation.js)
|
||||
Rails.application.config.assets.precompile += %w(datatables.css)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue