@flogeez/angular-tiptap-editor 0.4.0 → 0.5.0

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Editor, Node, Extension, Mark, EditorOptions } from '@tiptap/core';
1
+ import { Editor, Extension, Node, Mark, EditorOptions } from '@tiptap/core';
2
2
  import * as _angular_core from '@angular/core';
3
3
  import { AfterViewInit, OnDestroy, ElementRef } from '@angular/core';
4
4
  import { Observable } from 'rxjs';
@@ -119,6 +119,7 @@ interface TiptapTranslations {
119
119
  };
120
120
  imageUpload: {
121
121
  selectImage: string;
122
+ loadError: string;
122
123
  uploadingImage: string;
123
124
  uploadProgress: string;
124
125
  uploadError: string;
@@ -132,12 +133,20 @@ interface TiptapTranslations {
132
133
  resizeMedium: string;
133
134
  resizeLarge: string;
134
135
  resizeOriginal: string;
136
+ resizing: string;
137
+ compressing: string;
138
+ compressionError: string;
139
+ validating: string;
140
+ uploadingToServer: string;
141
+ replacingImage: string;
142
+ insertingImage: string;
143
+ noFileSelected: string;
144
+ selectionCancelled: string;
135
145
  };
136
146
  editor: {
137
147
  placeholder: string;
138
148
  character: string;
139
149
  word: string;
140
- imageLoadError: string;
141
150
  linkPrompt: string;
142
151
  linkUrlPrompt: string;
143
152
  confirmDelete: string;
@@ -273,6 +282,7 @@ declare class TiptapI18nService {
273
282
  }>;
274
283
  readonly imageUpload: _angular_core.Signal<{
275
284
  selectImage: string;
285
+ loadError: string;
276
286
  uploadingImage: string;
277
287
  uploadProgress: string;
278
288
  uploadError: string;
@@ -286,12 +296,20 @@ declare class TiptapI18nService {
286
296
  resizeMedium: string;
287
297
  resizeLarge: string;
288
298
  resizeOriginal: string;
299
+ resizing: string;
300
+ compressing: string;
301
+ compressionError: string;
302
+ validating: string;
303
+ uploadingToServer: string;
304
+ replacingImage: string;
305
+ insertingImage: string;
306
+ noFileSelected: string;
307
+ selectionCancelled: string;
289
308
  }>;
290
309
  readonly editor: _angular_core.Signal<{
291
310
  placeholder: string;
292
311
  character: string;
293
312
  word: string;
294
- imageLoadError: string;
295
313
  linkPrompt: string;
296
314
  linkUrlPrompt: string;
297
315
  confirmDelete: string;
@@ -372,10 +390,9 @@ interface SlashCommandItem {
372
390
  keywords: string[];
373
391
  command: (editor: Editor) => void;
374
392
  }
375
- interface SlashCommandsConfig {
393
+ interface CustomSlashCommands {
376
394
  commands?: SlashCommandItem[];
377
395
  }
378
- declare const DEFAULT_SLASH_COMMANDS: SlashCommandItem[];
379
396
 
380
397
  interface ImageData {
381
398
  src: string;
@@ -460,6 +477,8 @@ declare class ImageService {
460
477
  selectedImage: _angular_core.WritableSignal<ImageData | null>;
461
478
  isImageSelected: _angular_core.Signal<boolean>;
462
479
  isResizing: _angular_core.WritableSignal<boolean>;
480
+ private i18n;
481
+ private readonly t;
463
482
  isUploading: _angular_core.WritableSignal<boolean>;
464
483
  uploadProgress: _angular_core.WritableSignal<number>;
465
484
  uploadMessage: _angular_core.WritableSignal<string>;
@@ -574,10 +593,50 @@ declare class EditorCommandsService {
574
593
  blur(editor: Editor): void;
575
594
  setContent(editor: Editor, content: string, emitUpdate?: boolean): void;
576
595
  setEditable(editor: Editor, editable: boolean): void;
596
+ insertContent(editor: Editor, content: string): void;
577
597
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<EditorCommandsService, never>;
578
598
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<EditorCommandsService>;
579
599
  }
580
600
 
601
+ /**
602
+ * Clés des commandes natives dans l'ordre d'affichage
603
+ */
604
+ declare const SLASH_COMMAND_KEYS: readonly ["heading1", "heading2", "heading3", "bulletList", "orderedList", "blockquote", "code", "image", "horizontalRule", "table"];
605
+ type SlashCommandKey = (typeof SLASH_COMMAND_KEYS)[number];
606
+ /**
607
+ * Configuration simplifiée pour activer/désactiver les slash commands natives.
608
+ * Permet aussi d'ajouter des commandes personnalisées.
609
+ */
610
+ interface SlashCommandsConfig extends Partial<Record<SlashCommandKey, boolean>> {
611
+ /**
612
+ * Liste de commandes supplémentaires à ajouter à la fin du menu
613
+ */
614
+ custom?: SlashCommandItem[];
615
+ }
616
+ /**
617
+ * Configuration par défaut : toutes les commandes natives sont activées
618
+ */
619
+ declare const DEFAULT_SLASH_COMMANDS_CONFIG: Record<SlashCommandKey, boolean>;
620
+ /**
621
+ * Factory pour créer les commandes natives avec leurs traductions et leur logique d'exécution.
622
+ * Utilise les services de l'éditeur pour garantir une cohérence de comportement.
623
+ */
624
+ declare function createDefaultSlashCommands(i18n: TiptapI18nService, commands: EditorCommandsService, images: ImageService, imageOptions?: {
625
+ quality?: number;
626
+ maxWidth?: number;
627
+ maxHeight?: number;
628
+ allowedTypes?: string[];
629
+ }): SlashCommandItem[];
630
+ /**
631
+ * Filtre et assemble les commandes selon la configuration fournie.
632
+ */
633
+ declare function filterSlashCommands(config: SlashCommandsConfig, i18n: TiptapI18nService, commands: EditorCommandsService, images: ImageService, imageOptions?: {
634
+ quality?: number;
635
+ maxWidth?: number;
636
+ maxHeight?: number;
637
+ allowedTypes?: string[];
638
+ }): SlashCommandItem[];
639
+
581
640
  interface ToolbarConfig {
582
641
  bold?: boolean;
583
642
  italic?: boolean;
@@ -673,10 +732,11 @@ declare class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
673
732
  maxCharacters: _angular_core.InputSignal<number | undefined>;
674
733
  enableOfficePaste: _angular_core.InputSignal<boolean>;
675
734
  enableSlashCommands: _angular_core.InputSignal<boolean>;
676
- slashCommandsConfig: _angular_core.InputSignal<SlashCommandsConfig | undefined>;
735
+ slashCommands: _angular_core.InputSignal<SlashCommandsConfig>;
736
+ customSlashCommands: _angular_core.InputSignal<CustomSlashCommands | undefined>;
677
737
  locale: _angular_core.InputSignal<SupportedLocale | undefined>;
678
- autofocus: _angular_core.InputSignal<number | boolean | "end" | "start" | "all">;
679
- tiptapExtensions: _angular_core.InputSignal<(Node<any, any> | Extension<any, any> | Mark<any, any>)[]>;
738
+ autofocus: _angular_core.InputSignal<number | boolean | "start" | "end" | "all">;
739
+ tiptapExtensions: _angular_core.InputSignal<(Extension<any, any> | Node<any, any> | Mark<any, any>)[]>;
680
740
  tiptapOptions: _angular_core.InputSignal<Partial<EditorOptions>>;
681
741
  showBubbleMenu: _angular_core.InputSignal<boolean>;
682
742
  bubbleMenu: _angular_core.InputSignal<Partial<BubbleMenuConfig>>;
@@ -759,7 +819,7 @@ declare class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
759
819
  compressImages: boolean;
760
820
  quality: number;
761
821
  }>;
762
- slashCommandsConfigComputed: _angular_core.Signal<SlashCommandsConfig>;
822
+ slashCommandsConfigComputed: _angular_core.Signal<CustomSlashCommands>;
763
823
  private _destroyRef;
764
824
  private ngControl;
765
825
  readonly i18nService: TiptapI18nService;
@@ -770,8 +830,6 @@ declare class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
770
830
  ngOnDestroy(): void;
771
831
  private initEditor;
772
832
  private updateCharacterCount;
773
- onImageUploaded(result: ImageUploadResult): void;
774
- onImageUploadError(error: string): void;
775
833
  onSlashCommandImageUpload(file: File): Promise<void>;
776
834
  onDragOver(event: DragEvent): void;
777
835
  onDrop(event: DragEvent): void;
@@ -788,27 +846,14 @@ declare class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
788
846
  setDisabledState(isDisabled: boolean): void;
789
847
  onEditorClick(event: MouseEvent): void;
790
848
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<AngularTiptapEditorComponent, never>;
791
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<AngularTiptapEditorComponent, "angular-tiptap-editor", never, { "content": { "alias": "content"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "editable": { "alias": "editable"; "required": false; "isSignal": true; }; "minHeight": { "alias": "minHeight"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "maxHeight": { "alias": "maxHeight"; "required": false; "isSignal": true; }; "fillContainer": { "alias": "fillContainer"; "required": false; "isSignal": true; }; "showToolbar": { "alias": "showToolbar"; "required": false; "isSignal": true; }; "showCharacterCount": { "alias": "showCharacterCount"; "required": false; "isSignal": true; }; "maxCharacters": { "alias": "maxCharacters"; "required": false; "isSignal": true; }; "enableOfficePaste": { "alias": "enableOfficePaste"; "required": false; "isSignal": true; }; "enableSlashCommands": { "alias": "enableSlashCommands"; "required": false; "isSignal": true; }; "slashCommandsConfig": { "alias": "slashCommandsConfig"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "tiptapExtensions": { "alias": "tiptapExtensions"; "required": false; "isSignal": true; }; "tiptapOptions": { "alias": "tiptapOptions"; "required": false; "isSignal": true; }; "showBubbleMenu": { "alias": "showBubbleMenu"; "required": false; "isSignal": true; }; "bubbleMenu": { "alias": "bubbleMenu"; "required": false; "isSignal": true; }; "showImageBubbleMenu": { "alias": "showImageBubbleMenu"; "required": false; "isSignal": true; }; "imageBubbleMenu": { "alias": "imageBubbleMenu"; "required": false; "isSignal": true; }; "toolbar": { "alias": "toolbar"; "required": false; "isSignal": true; }; "imageUpload": { "alias": "imageUpload"; "required": false; "isSignal": true; }; "imageUploadHandler": { "alias": "imageUploadHandler"; "required": false; "isSignal": true; }; }, { "contentChange": "contentChange"; "editorCreated": "editorCreated"; "editorUpdate": "editorUpdate"; "editorFocus": "editorFocus"; "editorBlur": "editorBlur"; }, never, never, true, [{ directive: typeof NoopValueAccessorDirective; inputs: {}; outputs: {}; }]>;
849
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<AngularTiptapEditorComponent, "angular-tiptap-editor", never, { "content": { "alias": "content"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "editable": { "alias": "editable"; "required": false; "isSignal": true; }; "minHeight": { "alias": "minHeight"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "maxHeight": { "alias": "maxHeight"; "required": false; "isSignal": true; }; "fillContainer": { "alias": "fillContainer"; "required": false; "isSignal": true; }; "showToolbar": { "alias": "showToolbar"; "required": false; "isSignal": true; }; "showCharacterCount": { "alias": "showCharacterCount"; "required": false; "isSignal": true; }; "maxCharacters": { "alias": "maxCharacters"; "required": false; "isSignal": true; }; "enableOfficePaste": { "alias": "enableOfficePaste"; "required": false; "isSignal": true; }; "enableSlashCommands": { "alias": "enableSlashCommands"; "required": false; "isSignal": true; }; "slashCommands": { "alias": "slashCommands"; "required": false; "isSignal": true; }; "customSlashCommands": { "alias": "customSlashCommands"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; "autofocus": { "alias": "autofocus"; "required": false; "isSignal": true; }; "tiptapExtensions": { "alias": "tiptapExtensions"; "required": false; "isSignal": true; }; "tiptapOptions": { "alias": "tiptapOptions"; "required": false; "isSignal": true; }; "showBubbleMenu": { "alias": "showBubbleMenu"; "required": false; "isSignal": true; }; "bubbleMenu": { "alias": "bubbleMenu"; "required": false; "isSignal": true; }; "showImageBubbleMenu": { "alias": "showImageBubbleMenu"; "required": false; "isSignal": true; }; "imageBubbleMenu": { "alias": "imageBubbleMenu"; "required": false; "isSignal": true; }; "toolbar": { "alias": "toolbar"; "required": false; "isSignal": true; }; "imageUpload": { "alias": "imageUpload"; "required": false; "isSignal": true; }; "imageUploadHandler": { "alias": "imageUploadHandler"; "required": false; "isSignal": true; }; }, { "contentChange": "contentChange"; "editorCreated": "editorCreated"; "editorUpdate": "editorUpdate"; "editorFocus": "editorFocus"; "editorBlur": "editorBlur"; }, never, never, true, [{ directive: typeof NoopValueAccessorDirective; inputs: {}; outputs: {}; }]>;
792
850
  }
793
851
 
794
- /**
795
- * Clés des commandes dans l'ordre de création
796
- */
797
- declare const SLASH_COMMAND_KEYS: readonly ["heading1", "heading2", "heading3", "bulletList", "orderedList", "blockquote", "code", "image", "horizontalRule", "table"];
798
- /**
799
- * Factory function pour créer les slash commands traduits
800
- */
801
- declare function createI18nSlashCommands(i18nService: TiptapI18nService): SlashCommandItem[];
802
- /**
803
- * Fonction utilitaire pour filtrer les slash commands selon les commandes actives
804
- */
805
- declare function filterSlashCommands(activeCommands: Set<string>, i18nService: TiptapI18nService): SlashCommandItem[];
806
-
807
852
  type HeightConfig = {
808
853
  minHeight?: number;
809
854
  height?: number;
810
855
  maxHeight?: number;
811
856
  };
812
857
 
813
- export { AngularTiptapEditorComponent, DEFAULT_BUBBLE_MENU_CONFIG, DEFAULT_CELL_MENU_CONFIG, DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, DEFAULT_SLASH_COMMANDS, DEFAULT_TABLE_MENU_CONFIG, DEFAULT_TOOLBAR_CONFIG, EditorCommandsService, ImageService, NoopValueAccessorDirective, SLASH_COMMAND_KEYS, TiptapI18nService, createI18nSlashCommands, filterSlashCommands };
814
- export type { BubbleMenuConfig, CellBubbleMenuConfig, HeightConfig, ImageBubbleMenuConfig, ImageData, ImageUploadContext, ImageUploadHandler, ImageUploadHandlerResult, ImageUploadResult, ResizeOptions, SlashCommandItem, SlashCommandsConfig, SupportedLocale, TableBubbleMenuConfig, TiptapTranslations, ToolbarConfig };
858
+ export { AngularTiptapEditorComponent, DEFAULT_BUBBLE_MENU_CONFIG, DEFAULT_CELL_MENU_CONFIG, DEFAULT_IMAGE_BUBBLE_MENU_CONFIG, DEFAULT_SLASH_COMMANDS_CONFIG, DEFAULT_TABLE_MENU_CONFIG, DEFAULT_TOOLBAR_CONFIG, EditorCommandsService, ImageService, NoopValueAccessorDirective, SLASH_COMMAND_KEYS, TiptapI18nService, createDefaultSlashCommands, filterSlashCommands };
859
+ export type { BubbleMenuConfig, CellBubbleMenuConfig, CustomSlashCommands, HeightConfig, ImageBubbleMenuConfig, ImageData, ImageUploadContext, ImageUploadHandler, ImageUploadHandlerResult, ImageUploadResult, ResizeOptions, SlashCommandItem, SlashCommandKey, SlashCommandsConfig, SupportedLocale, TableBubbleMenuConfig, TiptapTranslations, ToolbarConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flogeez/angular-tiptap-editor",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "A modern, customizable rich-text editor for Angular (18+), built with Tiptap and featuring complete internationalization support",
5
5
  "keywords": [
6
6
  "angular",
@@ -2,6 +2,8 @@
2
2
  .tippy-box {
3
3
  /* Par défaut Tippy limite à 350px */
4
4
  max-width: none !important;
5
+ background: transparent !important;
6
+ box-shadow: none !important;
5
7
  }
6
8
 
7
9
  .tippy-content {
@@ -10,32 +12,31 @@
10
12
  }
11
13
 
12
14
  .tippy-box .bubble-menu {
13
- display: flex;
15
+ display: flex !important;
14
16
  align-items: center;
15
17
  gap: 6px;
16
- background: rgba(255, 255, 255, 0.95);
17
- backdrop-filter: blur(12px);
18
- border: 1px solid rgba(255, 255, 255, 0.2);
19
- border-radius: 16px;
18
+ background: var(--ate-menu-bg, rgba(255, 255, 255, 0.95)) !important;
19
+ backdrop-filter: blur(var(--ate-menu-blur, 12px));
20
+ border: 1px solid var(--ate-menu-border, rgba(0, 0, 0, 0.1));
21
+ border-radius: var(--ate-border-radius, 16px);
20
22
  padding: 8px 12px;
21
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
23
+ box-shadow: var(--ate-menu-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
22
24
  z-index: 1000;
23
- animation: slideUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
24
- /* Empêcher les retours à la ligne pour des barres d'icônes */
25
+ animation: slideUp 0.18s cubic-bezier(0, 0, 0.2, 1);
25
26
  white-space: nowrap;
26
27
  }
27
28
 
28
29
  .bubble-menu .tiptap-separator {
29
30
  width: 1px;
30
31
  height: 28px;
31
- background: linear-gradient(to bottom, transparent, #e2e8f0, transparent);
32
+ background: color-mix(in srgb, var(--ate-menu-border), transparent 50%);
32
33
  margin: 0 4px;
33
34
  }
34
35
 
35
36
  @keyframes slideUp {
36
37
  from {
37
38
  opacity: 0;
38
- transform: translateY(8px) scale(0.95);
39
+ transform: translateY(6px) scale(0.98);
39
40
  }
40
41
  to {
41
42
  opacity: 1;
@@ -3,23 +3,23 @@
3
3
 
4
4
  /* Styles pour les liens */
5
5
  .tiptap-link {
6
- color: #3b82f6;
6
+ color: var(--ate-primary, #1d4ed8);
7
7
  text-decoration: underline;
8
8
  cursor: pointer;
9
9
  transition: color 0.2s ease;
10
10
  }
11
11
 
12
12
  .tiptap-link:hover {
13
- color: #1d4ed8;
13
+ color: var(--ate-primary-light-alpha, #1d4ed8);
14
14
  text-decoration: underline;
15
15
  }
16
16
 
17
17
  /* Styles pour la surbrillance */
18
18
  .tiptap-highlight {
19
- background-color: #fef08a;
19
+ background-color: var(--ate-highlight-bg, #fef08a);
20
20
  padding: 0.1em 0.2em;
21
21
  border-radius: 2px;
22
- color: #854d0e;
22
+ color: var(--ate-highlight-color, #854d0e);
23
23
  }
24
24
 
25
25
  /* Styles pour les alignements de texte - Tiptap utilise des classes */