mohamedsabil83 / filament-forms-tinyeditor

A TinyMce Editor component for filament
MIT License
164 stars 37 forks source link

[Bug]: Editor in modal break when opened second time #89

Closed rahmanramsi closed 9 months ago

rahmanramsi commented 10 months ago

What happened?

CleanShot 2023-08-18 at 11 18 49

How to reproduce the bug

Package Version

2.0.1

PHP Version

8.1.22

Laravel Version

10.19.0

Which operating systems does with happen with?

macOS

Notes

No response

mohamedsabil83 commented 10 months ago

Any issues appear in the browser console?

olehlong commented 10 months ago

Try this version https://github.com/olehlong/filament-forms-tinyeditor/blob/2.x/resources/views/tiny-editor.blade.php . I have a slightly modified local version in my project, so I'm not sure it will work in the plugin. Just adding destroy to x-data without Editor variable might work as well

destroy: () => tinymce.get('tiny-editor-{{ $getId() }}')?.remove()

but it didn't work in a custom page's action form. Firefox throws an error sometimes, but editor still works every time.

Edit: although destroy() function and editor variable are not needed (editor is already undefined when destroy called) and just using createEditor and render works:

let editor = tinymce.createEditor('tiny-editor-{{ $getId() }}', {
...
editor.render();
mohamedsabil83 commented 9 months ago

By saying it didn't work in a custom page's action form you mean outside panel?

olehlong commented 9 months ago

No, inside a panel. Custom resource page https://filamentphp.com/docs/3.x/panels/resources/custom-pages with an action modal form https://filamentphp.com/docs/3.x/actions/modals#modal-forms

mohamedsabil83 commented 9 months ago

I just released a new tag. Can you check?

rahmanramsi commented 9 months ago

@mohamedsabil83 its working now