Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TinyMCE additionnal features refactoring
- Loading branch information
1 parent
44529ca
commit 53f0f23
Showing
2 changed files
with
41 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,45 @@ | ||
@push('js') | ||
@component('boilerplate::minify') | ||
<script> | ||
tinymce.defaultSettings = $.extend({}, tinymce.defaultSettings, { | ||
image_advtab: true, | ||
images_upload_handler: function (blobInfo, success, failure) { | ||
let formData = new FormData(); | ||
formData.append('file', blobInfo.blob(), blobInfo.filename()); | ||
image_advtab: true, | ||
images_upload_handler: function (blobInfo, success, failure) { | ||
let formData = new FormData(); | ||
formData.append('file', blobInfo.blob(), blobInfo.filename()); | ||
|
||
$.ajax({ | ||
url: '{{ route('mediamanager.ajax.mce-upload') }}', | ||
type: 'post', | ||
data: formData, | ||
processData: false, | ||
contentType: false, | ||
success: function(json){ | ||
if (!json || typeof json.location != 'string') { | ||
failure('Invalid JSON'); | ||
return; | ||
} | ||
success(json.location); | ||
} | ||
}); | ||
}, | ||
file_picker_callback: function (callback, value, meta) { | ||
tinymce.activeEditor.windowManager.openUrl({ | ||
url: '{{ route('mediamanager.index', [], false) }}?mce=1&type=' + meta.filetype + '&selected=' + value, | ||
title: 'File Manager', | ||
width: Math.round(window.innerWidth * 0.8), | ||
height: Math.round(window.innerHeight * 0.8), | ||
onMessage: function (instance, data) { | ||
if (data.mceAction === 'insertMedia') { | ||
if (meta.filetype === 'image') { | ||
callback(data.url, {alt: data.name}); | ||
} | ||
$.ajax({ | ||
url: '{{ route('mediamanager.ajax.mce-upload') }}', | ||
type: 'post', | ||
data: formData, | ||
processData: false, | ||
contentType: false, | ||
success: function(json){ | ||
if (!json || typeof json.location != 'string') { | ||
failure('Invalid JSON'); | ||
return; | ||
} | ||
success(json.location); | ||
} | ||
}); | ||
}, | ||
file_picker_callback: function (callback, value, meta) { | ||
tinymce.activeEditor.windowManager.openUrl({ | ||
url: '{{ route('mediamanager.index', [], false) }}?mce=1&type=' + meta.filetype + '&selected=' + value, | ||
title: 'File Manager', | ||
width: Math.round(window.innerWidth * 0.8), | ||
height: Math.round(window.innerHeight * 0.8), | ||
onMessage: function (instance, data) { | ||
if (data.mceAction === 'insertMedia') { | ||
if (meta.filetype === 'image') { | ||
callback(data.url, {alt: data.name}); | ||
} | ||
|
||
if (meta.filetype === 'file') { | ||
callback(data.url, {text: data.name}); | ||
} | ||
if (meta.filetype === 'file') { | ||
callback(data.url, {text: data.name}); | ||
} | ||
|
||
if (meta.filetype === 'media') { | ||
callback(data.url); | ||
} | ||
} | ||
instance.close(); | ||
} | ||
}); | ||
return false; | ||
if (meta.filetype === 'media') { | ||
callback(data.url); | ||
} | ||
} | ||
}); | ||
</script> | ||
@endcomponent | ||
@endpush | ||
instance.close(); | ||
} | ||
}); | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@once | ||
@include('boilerplate::load.tinymce') | ||
@include('boilerplate-media-manager::load.mceextend') | ||
@php(define('LOAD_TINYMCE_MEDIA', true)) | ||
@endonce |