|
2 | 2 |
|
3 | 3 | ## Purpose |
4 | 4 |
|
5 | | -Cross-cutting structural invariants that span multiple packages and aren't owned by any single capability spec: the dependency direction between packages, the event-channel naming convention used across the `EventBus`, the single-adapter contract `core` enforces, and which undo/redo implementation takes precedence when collaboration is enabled. These constrain how packages may depend on and communicate with each other; package-specific behavior lives in the respective capability specs ([[model-types]], [[sdk]], [[model]], [[dom-adapters]], [[collaboration-manager]], [[core]], [[ui]], [[ot-server]], [[tools]]). |
| 5 | +Cross-cutting structural invariants that span multiple packages and aren't owned by any single capability spec: the dependency direction between packages, the event-channel naming convention used across the `EventBus`, the single-adapter contract `core` enforces, and which undo/redo implementation takes precedence when collaboration is enabled. These constrain how packages may depend on and communicate with each other; package-specific behavior lives in the respective capability specs ([[model-types]], [[sdk]], [[model]], [[dom-adapters]], [[collaboration-manager]], [[core]], [[ui]], [[ot-server]], [[tools]], [[editorjs-bundle]]). |
6 | 6 |
|
7 | 7 | ## Requirements |
8 | 8 |
|
@@ -42,19 +42,19 @@ Every event dispatched on an `EventBus` SHALL be namespaced by its origin as a ` |
42 | 42 | Implemented in `packages/sdk/src/entities/EventBus/events/core/CoreEventBase.ts`, `.../ui/UIEventBase.ts`, `.../core/CoreEventType.ts`, `.../adapter/AdapterEventType.ts`. |
43 | 43 |
|
44 | 44 | ### Requirement: Exactly one adapter plugin is bound |
45 | | -`Core` SHALL require exactly one `PluginType.Adapter` plugin bound in its plugin container at initialization time. Registering a second adapter via `use()` SHALL replace the previously bound one rather than error or bind both. |
| 45 | +`Core` SHALL require exactly one `PluginType.Adapter` plugin bound in its plugin container at initialization time, and SHALL NOT bind one itself — every adapter reaches the container through a `use()` call. Registering a second adapter via `use()` SHALL replace the previously bound one rather than error or bind both. |
46 | 46 |
|
47 | 47 | #### Scenario: Registering a second adapter replaces the first |
48 | 48 | - **GIVEN** an adapter plugin has already been registered via `core.use(SomeAdapter)` |
49 | 49 | - **WHEN** `core.use(AnotherAdapter)` is called with another `PluginType.Adapter` plugin |
50 | 50 | - **THEN** the container rebinds `PluginType.Adapter` to the new adapter, so only the most recently registered adapter is active when `#initializeAdapter()` runs |
51 | 51 |
|
52 | | -#### Scenario: Default adapter is DOMAdapters |
| 52 | +#### Scenario: No adapter is bound by default |
53 | 53 | - **GIVEN** a `Core` instance is constructed without an explicit adapter registration |
54 | | -- **WHEN** the constructor runs |
55 | | -- **THEN** it calls `this.use(DOMAdapters)`, so `@editorjs/dom-adapters` is bound as the default adapter |
| 54 | +- **WHEN** `initialize()` is called |
| 55 | +- **THEN** it throws rather than falling back to a built-in adapter, because `Core` is headless: binding `@editorjs/dom-adapters` is the caller's job, which [[editorjs-bundle]] does on the caller's behalf |
56 | 56 |
|
57 | | -Implemented in `packages/core/src/index.ts` (`use()`, `#initializeAdapter()`), `packages/core/src/tokens.ts` (`TOKENS.Adapter`). |
| 57 | +Implemented in `packages/core/src/index.ts` (`use()`, `#validatePreconditions()`, `#initializeAdapter()`), `packages/core/src/tokens.ts` (`TOKENS.Adapter`), `packages/editorjs/src/index.ts` (`this.#core.use(DOMAdapters)`). |
58 | 58 |
|
59 | 59 | ### Requirement: Collaboration's undo/redo preempts core's local undo/redo |
60 | 60 | When `@editorjs/collaboration-manager` is registered, it SHALL intercept `core:undo`/`core:redo` events and call `preventDefault()` on them before `core`'s own `UndoRedoManager` acts, substituting its own OT-aware undo/redo (which accounts for remote operations) for `core`'s local-only undo/redo. This is an intentional override, not a duplicated/competing implementation. |
|
0 commit comments