Skip to content

Commit b265993

Browse files
committed
feat: introduce global AteEditorRegistry and AteEditorRef
1 parent f5e418f commit b265993

8 files changed

Lines changed: 477 additions & 64 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to `@flogeez/angular-tiptap-editor` will be documented in th
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), with the exception that the major version is specifically aligned with the major version of [Tiptap](https://tiptap.dev).
77

8+
## [3.2.0] - 2026-06-09
9+
10+
### Added
11+
12+
- **Global Editor Registry**: Introduced `AteEditorRegistry` and `AteEditorRef` to control and track editor instances anywhere in the application via standard Dependency Injection. Exposes direct facade commands (formatting, tables, exports) without raw Tiptap manipulation.
13+
814
## [3.1.5] - 2026-06-09
915

1016
### Added

projects/angular-tiptap-editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flogeez/angular-tiptap-editor",
3-
"version": "3.1.5",
3+
"version": "3.2.0",
44
"description": "A modern, customizable rich-text editor for Angular (18+), built with Tiptap and featuring complete internationalization support",
55
"keywords": [
66
"angular",

projects/angular-tiptap-editor/src/lib/components/editor/angular-tiptap-editor.component.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { AteEditorCommandsService } from "../../services/ate-editor-commands.ser
4848
import { AteColorPickerService } from "../../services/ate-color-picker.service";
4949
import { AteLinkService } from "../../services/ate-link.service";
5050
import { AteExportService } from "../../services/ate-export.service";
51+
import { AteEditorRegistry } from "../../services/ate-editor-registry.service";
5152
import { AteNoopValueAccessorDirective } from "../../directives/ate-noop-value-accessor.directive";
5253
import { AteStateCalculator } from "../../models/ate-editor-state.model";
5354
import { NgControl } from "@angular/forms";
@@ -1053,6 +1054,12 @@ export class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
10531054
*/
10541055
imageUploadHandler = input<AteImageUploadHandler | undefined>(undefined);
10551056

1057+
/**
1058+
* Optional unique identifier for the editor instance in the registry.
1059+
* If not specified, a unique ID is automatically generated.
1060+
*/
1061+
editorId = input<string | undefined>(undefined);
1062+
10561063
// Nouveaux outputs
10571064
contentChange = output<string>();
10581065
editorCreated = output<Editor>();
@@ -1357,6 +1364,11 @@ export class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
13571364
readonly editorCommandsService = inject(AteEditorCommandsService);
13581365
// Access editor state via service
13591366
readonly editorState = this.editorCommandsService.editorState;
1367+
1368+
private editorRegistry = inject(AteEditorRegistry);
1369+
private _registeredId = signal<string | null>(null);
1370+
readonly registeredId = this._registeredId.asReadonly();
1371+
13601372
private injector = inject(Injector);
13611373
private globalConfig = inject(ATE_GLOBAL_CONFIG, { optional: true });
13621374

@@ -1492,6 +1504,12 @@ export class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
14921504
currentEditor.destroy();
14931505
}
14941506
this._editorFullyInitialized.set(false);
1507+
1508+
// Unregister from the global registry
1509+
const id = this.registeredId();
1510+
if (id) {
1511+
this.editorRegistry.unregister(id);
1512+
}
14951513
}
14961514

14971515
private initEditor() {
@@ -1719,6 +1737,10 @@ export class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
17191737
}, 100);
17201738
},
17211739
onFocus: ({ editor, event }) => {
1740+
const id = this.registeredId();
1741+
if (id) {
1742+
this.editorRegistry.setActive(id);
1743+
}
17221744
this.editorFocus.emit({ editor, event });
17231745
},
17241746
onBlur: ({ editor, event }) => {
@@ -1732,6 +1754,14 @@ export class AngularTiptapEditorComponent implements AfterViewInit, OnDestroy {
17321754

17331755
// Stocker la référence de l'éditeur immédiatement
17341756
this._editor.set(newEditor);
1757+
1758+
// Register editor in the global registry
1759+
const registeredId = this.editorRegistry.register(
1760+
this.editorId(),
1761+
() => this.editor(),
1762+
this.editorCommandsService
1763+
);
1764+
this._registeredId.set(registeredId);
17351765
}
17361766

17371767
toggleEditMode(event: Event): void {

0 commit comments

Comments
 (0)