tanepiper / ngx-tinynodes

Monorepo for components released on NPM @tinynodes
https://tanepiper.github.io/ngx-tinynodes/
Other
38 stars 15 forks source link

[BUG] <ngx-editorjs - 3.0.3>: InjectionToken PluginClasses #12

Closed dmitriytretyakov closed 5 years ago

dmitriytretyakov commented 5 years ago

Which Library? ngx-editorjs

Describe the bug Error with Angular 8 Material when try to add ngx-editorjs package.

ERROR NullInjectorError: R3InjectorError(ResourceModule)[NgxEditorJSService -> NgxEditorJSPluginService -> NgxEditorJSPluginService -> NgxEditorJSPluginService -> InjectionToken PluginClasses]: StaticInjectorError(AppModule)[InjectionToken PluginClasses]: StaticInjectorError(Platform: core)[InjectionToken PluginClasses]: NullInjectorError: No provider for InjectionToken PluginClasses! at NullInjector.get (http://localhost:4200/vendor.js:66780:27) at resolveToken (http://localhost:4200/vendor.js:67107:24) at tryResolveToken (http://localhost:4200/vendor.js:67033:16) at StaticInjector.get (http://localhost:4200/vendor.js:66896:20) at resolveToken (http://localhost:4200/vendor.js:67107:24) at tryResolveToken (http://localhost:4200/vendor.js:67033:16) at StaticInjector.get (http://localhost:4200/vendor.js:66896:20) at R3Injector.get (http://localhost:4200/vendor.js:84106:33) at injectInjectorOnly (http://localhost:4200/vendor.js:65952:33) at ɵɵinject (http://localhost:4200/vendor.js:65962:57)

Used packages: { "name": "noname", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^8.0.2", "@angular/cdk": "^8.0.1", "@angular/common": "~8.0.1", "@angular/compiler": "~8.0.1", "@angular/core": "~8.0.1", "@angular/forms": "~8.0.1", "@angular/material": "^8.0.1", "@angular/platform-browser": "~8.0.1", "@angular/platform-browser-dynamic": "~8.0.1", "@angular/router": "~8.0.1", "@editorjs/code": "^2.4.1", "@editorjs/editorjs": "^2.15.0", "@editorjs/embed": "^2.2.1", "@editorjs/header": "^2.3.0", "@editorjs/image": "^2.3.1", "@editorjs/inline-code": "^1.3.0", "@editorjs/link": "^2.1.3", "@editorjs/list": "^1.4.0", "@editorjs/paragraph": "^2.6.0", "@editorjs/quote": "^2.3.0", "@editorjs/simple-image": "^1.3.2", "@editorjs/warning": "^1.1.1", "@tinynodes/ngx-editorjs": "^3.0.3", "@tinynodes/ngx-editorjs-plugins": "^2.0.3", "hammerjs": "^2.0.8", "rxjs": "~6.4.0", "tslib": "^1.9.0", "zone.js": "~0.9.1" }, "devDependencies": { "@angular-devkit/build-angular": "~0.800.0", "@angular/cli": "~8.0.4", "@angular/compiler-cli": "~8.0.1", "@angular/language-service": "~8.0.1", "@types/node": "~8.9.4", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "codelyzer": "^5.0.0", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.4.3" } }

My steps of installation:

  1. Install packages via npm
  2. Add NgxEditorJSModule to my module like in https://www.npmjs.com/package/@tinynodes/ngx-editorjs
  3. Add <ngx-editorjs-mat-field [formControlName]="field.field" placeholder="EditorJS for {{ 'Page Name' }}"> </ngx-editorjs-mat-field> to module component.
dmitriytretyakov commented 5 years ago

Problem in ResourceModule, but i trying to import it in shared module for using in all modules. How to correct import this module if i want to import it in shared module? I need to export it. This is correct?

@NgModule({ imports: [ CommonModule, RouterModule, ReactiveFormsModule, MaterialModule, NgxEditorJSModule.forRoot({ // Optional Configuration, see all keys below editorjs: { autofocus: false, holder: 'editor', initialBlock: 'paragraph', data: { time: Date.now(), version: EditorJS.version, blocks: [] } } }) ], declarations: [ ServerSideValidationDirective, FormFieldErrorComponent, TabularListComponent, ControlGroupComponent, LookupControlComponent, MultipleLookupControlComponent ], exports: [ ReactiveFormsModule, CommonModule, FormsModule, RouterModule, ServerSideValidationDirective, FormFieldErrorComponent, TabularListComponent, ControlGroupComponent, LookupControlComponent, MultipleLookupControlComponent, NgxEditorJSModule ], providers: [ { provide: ErrorStateMatcher, useClass: CustomErrorStateMatcher } ] }) export class SharedModule { }

dmitriytretyakov commented 5 years ago

I think it my mistake and will try to fix it

tanepiper commented 5 years ago

@dmitriytretyakov Hi, it looks like you didn't include the plugins module?

import { NgxEditorjsPluginsModule } from '@tinynodes/ngx-editorjs-plugins';