sibiraj-s / ngx-editor

🖋️ Rich Text Editor for angular using ProseMirror
https://sibiraj-s.github.io/ngx-editor/
MIT License
424 stars 183 forks source link

Fix: Export InjectionToken editor configuration #398

Closed ludoviccarretti closed 2 years ago

ludoviccarretti commented 2 years ago

Export NGX_EDITOR_CONFIG_TOKEN to enable editor configuration by using a provider instead of static configuration.

This PR contains:

Breaking Changes?

Checklist

Describe Your Changes

Add the ability to provide NGX_EDITOR_CONFIG_TOKEN by using a provider. Just below an example when using @ngx-translate package for internationalization :

export function ngxEditorConfigFactory(translateService: TranslateService): NgxEditorConfig {
  return {
    locals: {
      italic: translateService.instant('styles.italic'),
      bold: translateService.instant('styles.bold'),
    },
  };
}

@NgModule({
  imports: [CommonModule, ReactiveFormsModule, NgxEditorModule.forRoot()],
  providers: [
    {
      useFactory: ngxEditorConfigFactory,
      provide: NGX_EDITOR_CONFIG_TOKEN,
      deps: [TranslateService],
    },
  ],
})
export class MyModule {}

Does this PR affects any existing issues?

sibiraj-s commented 2 years ago

Thanks @ludoviccarretti . Will this fix https://github.com/sibiraj-s/ngx-editor/discussions/397?

ludoviccarretti commented 2 years ago

Thanks @ludoviccarretti . Will this fix #397?

Yes it will !

sibiraj-s commented 2 years ago

Published in v12.4.0

github-actions[bot] commented 1 year ago

This pull request 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.