Created
February 10, 2021 13:05
-
-
Save abdasis/376b7a627e9dc357695481b18fe4d1b9 to your computer and use it in GitHub Desktop.
Membuat tinyMCE dengan file manager di laravel
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
<script src="https://cdn.tiny.cloud/1/3kubek8r1p1mz4kvit7hc1z2mxd8wgg551cbeu82qkmenprf/tinymce/5/tinymce.min.js" | |
referrerpolicy="origin"></script> | |
<script> | |
tinymce.init({ | |
selector: "textarea", | |
height : "480", | |
plugins: "nonbreaking", | |
nonbreaking_force_tab: true, | |
toolbar: "nonbreaking", | |
relative_urls: false, | |
paste_data_images: true, | |
image_title: true, | |
statusbar: false, | |
automatic_uploads: true, | |
images_upload_url: "/images/upload", | |
file_picker_types: "image", | |
codesample_global_prismjs: true, | |
image_class_list: [ | |
{title: 'Full width', value: 'img-fluid img-responsive preview'}, | |
{title: 'Bootstrap', value: 'w-100'}, | |
], | |
plugins: [ | |
"advlist autolink lists link image charmap print preview hr anchor pagebreak", | |
"searchreplace wordcount visualblocks visualchars code fullscreen", | |
"insertdatetime media nonbreaking save table contextmenu directionality", | |
"emoticons template paste textcolor colorpicker textpattern code", | |
"codesample" | |
], | |
toolbar1: | |
"insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | codesample bullist numlist outdent indent | link image", | |
// override default upload handler to simulate successful upload | |
file_picker_callback: function(cb, value, meta) { | |
var input = document.createElement("input"); | |
input.setAttribute("type", "file"); | |
input.setAttribute("accept", "image/*"); | |
input.onchange = function() { | |
var file = this.files[0]; | |
var reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = function() { | |
var id = "blobid" + new Date().getTime(); | |
var blobCache = tinymce.activeEditor.editorUpload.blobCache; | |
var base64 = reader.result.split(",")[1]; | |
var blobInfo = blobCache.create(id, file, base64); | |
blobCache.add(blobInfo); | |
cb(blobInfo.blobUri(), { title: file.name }); | |
}; | |
}; | |
input.click(); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment