@flogeez/angular-tiptap-editor 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  A modern, customizable rich-text editor for Angular applications, built with Tiptap and featuring complete internationalization support.
4
4
 
5
+ [![Try it on StackBlitz](https://img.shields.io/badge/Try%20it-StackBlitz-blue?style=for-the-badge&logo=stackblitz)](https://stackblitz.com/edit/angular-tiptap-editor)
6
+
5
7
  ## 🚀 Features
6
8
 
7
- - **Modern Angular**: Built with Angular 19+ and standalone components
9
+ - **Modern Angular**: Built with Angular 18+
8
10
  - **Rich Text Editing**: Powered by Tiptap with extensive formatting options
9
11
  - **Internationalization**: Full i18n support (English & French) with auto-detection
10
12
  - **Customizable**: Highly configurable toolbar, bubble menus, and slash commands
@@ -3650,6 +3650,7 @@ class AngularTiptapEditorComponent {
3650
3650
  // ControlValueAccessor implementation
3651
3651
  this.onChange = (value) => { };
3652
3652
  this.onTouched = () => { };
3653
+ this.pendingFormValue = null;
3653
3654
  this.i18nService = inject(TiptapI18nService);
3654
3655
  // Effet pour gérer le changement de langue
3655
3656
  effect(() => {
@@ -3662,8 +3663,8 @@ class AngularTiptapEditorComponent {
3662
3663
  effect(() => {
3663
3664
  const editor = this.editor();
3664
3665
  const content = this.content();
3665
- if (editor && content !== editor.getHTML()) {
3666
- editor.commands.setContent(content, false);
3666
+ if (editor && content !== undefined && content !== editor.getHTML()) {
3667
+ this.setContent(content, false);
3667
3668
  }
3668
3669
  });
3669
3670
  // Effet pour mettre à jour les propriétés de hauteur
@@ -3694,10 +3695,8 @@ class AngularTiptapEditorComponent {
3694
3695
  // L'initialisation se fait maintenant dans ngAfterViewInit
3695
3696
  }
3696
3697
  ngAfterViewInit() {
3697
- // Attendre que la vue soit complètement initialisée avant de créer l'éditeur
3698
- setTimeout(() => {
3699
- this.initEditor();
3700
- }, 0);
3698
+ // La vue est déjà complètement initialisée dans ngAfterViewInit
3699
+ this.initEditor();
3701
3700
  }
3702
3701
  ngOnDestroy() {
3703
3702
  const currentEditor = this.editor();
@@ -3775,7 +3774,6 @@ class AngularTiptapEditorComponent {
3775
3774
  // Note: La mise à jour des états des boutons est maintenant gérée par TiptapBubbleMenuComponent
3776
3775
  },
3777
3776
  onCreate: ({ editor }) => {
3778
- this.editor.set(editor);
3779
3777
  this.editorCreated.emit(editor);
3780
3778
  this.updateCharacterCount(editor);
3781
3779
  // Marquer l'éditeur comme complètement initialisé après un court délai
@@ -3792,6 +3790,13 @@ class AngularTiptapEditorComponent {
3792
3790
  this.editorBlur.emit({ editor, event });
3793
3791
  },
3794
3792
  });
3793
+ // Stocker la référence de l'éditeur immédiatement
3794
+ this.editor.set(newEditor);
3795
+ // Appliquer la valeur du FormControl en attente si elle existe
3796
+ if (this.pendingFormValue !== null) {
3797
+ this.setContent(this.pendingFormValue, false);
3798
+ this.pendingFormValue = null;
3799
+ }
3795
3800
  }
3796
3801
  updateCharacterCount(editor) {
3797
3802
  if (this.showCharacterCount() && editor.storage["characterCount"]) {
@@ -3884,7 +3889,12 @@ class AngularTiptapEditorComponent {
3884
3889
  writeValue(value) {
3885
3890
  const currentEditor = this.editor();
3886
3891
  if (currentEditor && value !== currentEditor.getHTML()) {
3887
- currentEditor.commands.setContent(value || "", false);
3892
+ this.setContent(value || "", false);
3893
+ this.pendingFormValue = null; // Valeur appliquée, plus besoin de la stocker
3894
+ }
3895
+ else {
3896
+ // Éditeur pas encore prêt, stocker la valeur du FormControl pour plus tard
3897
+ this.pendingFormValue = value || "";
3888
3898
  }
3889
3899
  }
3890
3900
  registerOnChange(fn) {