mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-28 01:36:33 +08:00
Simplify TinyMCE assets for MarvinJS
This commit is contained in:
parent
bdc2dbbac1
commit
ad7130d3b2
4 changed files with 5 additions and 7 deletions
|
@ -137,7 +137,6 @@ var MarvinJsEditorApi = (function() {
|
|||
var imgstr = "<img src='" + json.image.url + "'";
|
||||
imgstr += " width='300' height='300'";
|
||||
imgstr += " data-mce-token='" + json.image.token + "'";
|
||||
imgstr += " data-source-id='" + json.image.source_id + "'";
|
||||
imgstr += " data-source-type='" + json.image.source_type + "'";
|
||||
imgstr += " alt='description-" + json.image.token + "' />";
|
||||
return imgstr;
|
||||
|
|
4
app/assets/javascripts/sitewide/tiny_mce.js
vendored
4
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
@ -47,7 +47,7 @@ var TinyMCE = (function() {
|
|||
|
||||
// Edit link
|
||||
editLink = editorContainer.find('.tinymce-active-object-handler .file-edit-link');
|
||||
if (image[0].dataset.sourceId) {
|
||||
if (image[0].dataset.sourceType) {
|
||||
editLink.css('display', 'inline-block');
|
||||
marvinJsEdit = (image[0].dataset.sourceType === 'marvinjs' && typeof (MarvinJsEditor) !== 'undefined');
|
||||
if (!marvinJsEdit) editLink.css('display', 'none');
|
||||
|
@ -55,7 +55,7 @@ var TinyMCE = (function() {
|
|||
if (marvinJsEdit) {
|
||||
MarvinJsEditor.open({
|
||||
mode: 'edit-tinymce',
|
||||
marvinUrl: '/tiny_mce_assets/' + image[0].dataset.sourceId + '/marvinjs',
|
||||
marvinUrl: '/tiny_mce_assets/' + image[0].dataset.mceToken + '/marvinjs',
|
||||
image: image
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class TinyMceAssetsController < ApplicationController
|
|||
end
|
||||
|
||||
def marvinjs_show
|
||||
asset = current_team.tiny_mce_assets.find_by_id(params[:id])
|
||||
asset = current_team.tiny_mce_assets.find_by_id(Base62.decode(params[:id]))
|
||||
return render_404 unless asset
|
||||
|
||||
render json: {
|
||||
|
@ -55,7 +55,6 @@ class TinyMceAssetsController < ApplicationController
|
|||
image: {
|
||||
url: rails_representation_url(result[:asset].preview),
|
||||
token: Base62.encode(result[:asset].id),
|
||||
source_id: result[:asset].id,
|
||||
source_type: result[:asset].image.metadata[:asset_type]
|
||||
}
|
||||
}, content_type: 'text/html'
|
||||
|
@ -76,7 +75,7 @@ class TinyMceAssetsController < ApplicationController
|
|||
private
|
||||
|
||||
def load_vars
|
||||
@asset = current_team.tiny_mce_assets.find_by_id(params[:id])
|
||||
@asset = current_team.tiny_mce_assets.find_by_id(Base62.decode(params[:id]))
|
||||
return render_404 unless @asset
|
||||
|
||||
@assoc ||= @asset.object
|
||||
|
|
|
@ -29,7 +29,7 @@ class MarvinJsService
|
|||
|
||||
def update_sketch(params, current_user)
|
||||
if params[:object_type] == 'TinyMceAsset'
|
||||
asset = current_user.current_team.tiny_mce_assets.find(params[:id])
|
||||
asset = current_user.current_team.tiny_mce_assets.find(Base62.decode(params[:id]))
|
||||
attachment = asset&.image
|
||||
else
|
||||
asset = current_user.current_team.assets.find(params[:id])
|
||||
|
|
Loading…
Reference in a new issue