Skip to content

Commit

Permalink
TinyMCE additionnal features refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienheyd committed Oct 27, 2021
1 parent 44529ca commit 53f0f23
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 50 deletions.
90 changes: 41 additions & 49 deletions src/resources/views/load/mceextend.blade.php
@@ -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;
}
1 change: 0 additions & 1 deletion src/resources/views/load/tinymce.blade.php
@@ -1,5 +1,4 @@
@once
@include('boilerplate::load.tinymce')
@include('boilerplate-media-manager::load.mceextend')
@php(define('LOAD_TINYMCE_MEDIA', true))
@endonce

0 comments on commit 53f0f23

Please sign in to comment.