sibiraj-s / ngx-tiptap

Angular bindings for tiptap v2
https://sibiraj-s.github.io/ngx-tiptap/
MIT License
126 stars 19 forks source link

You can't no longer add nodes to the editor, if it's provided from a service #20

Closed matt-zm closed 2 years ago

matt-zm commented 2 years ago

Hey, I found the next bug with the latest update (4.0.2).

Now you aren't able to add nodes to the editor if you provide the Editor via a service, if you try to add the nodes to the editor you get an error like this:

ERROR Error: R3InjectorError(AppModule)[ViewContainerRef -> ViewContainerRef -> ViewContainerRef]: NullInjectorError: No provider for ViewContainerRef!

But if instead you declare the Editor inside the component you can add the nodes normally.

You can check that in the next Stackblitz: https://stackblitz.com/edit/angular-13-template-apxkmf?file=src/app/editor.service.ts

Let me know if in fact that is a bug, I'm doing something wrong or now with the new changes that works as intended, and you can't use services in order to provide the editor.

sibiraj-s commented 2 years ago

Since angular 13, the API to insert dynamic components is simplified, Hence I switched to it in this commit https://github.com/sibiraj-s/ngx-tiptap/commit/454be3e23a8a6925521619089b2202fff38ac222.

It uses ViewContainerRef to create component, where ViewContainerRef can only be injected to components or directives, and not to services. Hence you are facing the issue. May be I can revert that 🤔

sibiraj-s commented 2 years ago

Also having second thoughts, since the editor is typically the view. Should it be initialized in the view layer or it is okay to create from services 🤔

In any case, this is breaking change for v4. I will park this for v5 and revert them for now.

sibiraj-s commented 2 years ago

Fixed in v4.0.3

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in the thread.