tinymce / tinymce-angular

Official TinyMCE Angular Component
MIT License
327 stars 92 forks source link

feat: Editor as directive #342

Open javiermarinros opened 1 year ago

javiermarinros commented 1 year ago

I separated the Editor component logic into a directive and a component that inherits from it.

With this change, the directive can be directly attached to a host element like a textarea without having to create custom nodes.

Example:

<textarea editor [(ngModel)]="text"
   [init]="{
     height: 500,
     menubar: false,
     plugins: [
       'advlist autolink lists link image charmap print preview anchor',
       'searchreplace visualblocks code fullscreen',
       'insertdatetime media table paste code help wordcount'
     ],
     toolbar:
       'undo redo | formatselect | bold italic backcolor | \
       alignleft aligncenter alignright alignjustify | \
       bullist numlist outdent indent | removeformat | help'
   }"
></textarea>

It should be compatible with all previous implementations, as the component have the same inputs and outputs as it used to have, and the directive has mostly the same API as the component, except for the id and tagName inputs.

danoaky-tiny commented 8 months ago

Hi @javiermarinros, thanks for putting in the time to make this PR.

I think it's an interesting idea and novel. In my opinion though I think it's quite narrow in its use case. A directive to me should be able to be used across a variety of elements, whereas this one can only be used on a textarea. The changes it makes to the textarea is quite substantial as well, giving more support to the idea that it's a full blown component and should look as such in the template it's used. It should also be said that it does add more complexity in having a directive that the component now uses and a whole relationship there that wasn't needed before.

That's my thoughts on it for now. If others think differently or if there's significant want/need for this in the future we'll certainly consider it.

javiermarinros commented 8 months ago

Hi @danoaky-tiny thank you for your review. Just some remarks: