Skip to content

Commit

Permalink
Merge pull request #115 from brendoLoR/patch-1
Browse files Browse the repository at this point in the history
feat: enable file uploads on links and media
  • Loading branch information
mohamedsabil83 authored Dec 13, 2023
2 parents 3ef128e + 9eb754a commit a733823
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions resources/views/tiny-editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ class="relative z-0"
})
})
},
file_picker_callback: (cb, value, meta) => {
const input = document.createElement('input');
input.setAttribute('type', 'file');
input.addEventListener('change', (e) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.addEventListener('load', () => {
console.log('{{ $getStatePath() }}')
$wire.upload(`componentFileAttachments.{{ $getStatePath() }}`, file, () => {
$wire.getFormComponentFileAttachmentUrl('{{ $getStatePath() }}').then((url) => {
if (!url) {
cb('{{ __('Error uploading file') }}')
return
}
cb(url)
})
})
});
reader.readAsDataURL(file);
});
input.click();
},
automatic_uploads: true,
templates: {{ $getTemplate() }},
setup: function(editor) {
Expand Down

0 comments on commit a733823

Please sign in to comment.