Make CollaborationManager a Plugin#144
Conversation
|
⏭️ No files to mutate for |
|
⏭️ No files to mutate for |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🟢 | Statements | 96.43% | 27/28 |
| 🟢 | Branches | 86.96% | 20/23 |
| 🟢 | Functions | 100% | 5/5 |
| 🟢 | Lines | 96.43% | 27/28 |
Test suite run success
11 tests passing in 2 suites.
Report generated by 🧪jest coverage report action from 11fbc61
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🟢 | Statements | 99.8% | 988/990 |
| 🟢 | Branches | 98.98% | 292/295 |
| 🟢 | Functions | 97.45% | 229/235 |
| 🟢 | Lines | 99.79% | 948/950 |
Test suite run success
538 tests passing in 25 suites.
Report generated by 🧪jest coverage report action from 11fbc61
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🟢 | Statements | 88.67% (-3.42% 🔻) |
133/150 |
| 🟢 | Branches | 87.69% (-4.24% 🔻) |
57/65 |
| 🟡 | Functions | 64.29% (-7.14% 🔻) |
27/42 |
| 🟢 | Lines | 87.94% (-3.66% 🔻) |
124/141 |
Show new covered files 🐣
St.❔ |
File | Statements | Branches | Functions | Lines |
|---|---|---|---|---|---|
| 🔴 | ... / DocumentAPI.ts |
45.45% | 0% | 28.57% | 40% |
Test suite run success
75 tests passing in 7 suites.
Report generated by 🧪jest coverage report action from 11fbc61
|
⏭️ No files to mutate for |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🟡 | Statements | 70.97% (-29.03% 🔻) |
22/31 |
| 🔴 | Branches | 20% (-80% 🔻) |
1/5 |
| 🔴 | Functions | 50% (-50% 🔻) |
6/12 |
| 🟡 | Lines | 68.97% (-31.03% 🔻) |
20/29 |
Show new covered files 🐣
St.❔ |
File | Statements | Branches | Functions | Lines |
|---|---|---|---|---|---|
| 🟢 | ... / codex-tooltip.ts |
100% | 100% | 0% | 100% |
| 🟡 | ... / DocumentManager.ts |
70.97% | 20% | 75% | 68.97% |
Test suite run success
4 tests passing in 1 suite.
Report generated by 🧪jest coverage report action from 11fbc61
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🟢 | Statements | 92.27% (-0.23% 🔻) |
394/427 |
| 🟢 | Branches | 85.51% | 118/138 |
| 🟢 | Functions | 88.16% (-9.99% 🔻) |
67/76 |
| 🟢 | Lines | 92.11% (-0.3% 🔻) |
385/418 |
Show new covered files 🐣
St.❔ |
File | Statements | Branches | Functions | Lines |
|---|---|---|---|---|---|
| 🟢 | ... / codex-tooltip.ts |
100% | 100% | 0% | 100% |
| 🟢 | ... / createManager.ts |
92.31% | 100% | 88.89% | 91.67% |
Show files with reduced coverage 🔻
St.❔ |
File | Statements | Branches | Functions | Lines |
|---|---|---|---|---|---|
| 🟢 | ... / CollaborationManager.ts |
88.99% (-1.6% 🔻) |
83.33% | 73.33% (-15.56% 🔻) |
88.57% (-1.9% 🔻) |
Test suite run success
127 tests passing in 7 suites.
Report generated by 🧪jest coverage report action from 11fbc61
There was a problem hiding this comment.
Pull request overview
This PR converts CollaborationManager from a directly-instantiated dependency of Core into a regular Editor.js plugin that consumes the public EditorAPI, decoupling it from the model. It also adds three new write methods (insertData, removeData, modifyData) to the DocumentAPI so the plugin can mutate the document through the public API, and introduces a new core:ready event that triggers the OT-server connection.
Changes:
- Make
CollaborationManageraPluginType.Pluginthat receives{ api, config, eventBus }, listens tocore:undo/redo/ready, applies operations viaDocumentAPI, and renders incoming snapshots viablocks.render. - Extend
DocumentAPI(sdk + core impl) withinsertData/removeData/modifyDatataking{ userId, index, data }, defaultinguserIdto the editor config; addCoreEventType.Readydispatched at the end ofCore.initialize. - Rework collaboration-manager and ot-server tests around the new plugin shape: new
createManagerhelper, refactoredOTClient.spec.tsthat drives the client directly, and a sharedcodex-tooltipmock for jsdom-free Jest envs.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/src/entities/EventBus/events/core/CoreEventType.ts | Adds new Ready core event type. |
| packages/sdk/src/api/DocumentAPI.ts | Adds InsertRemoveDataParams/ModifyDataParams and the three write methods to the DocumentAPI interface. |
| packages/core/src/index.ts | Registers CollaborationManager via use(), removes direct wiring/undo-redo listeners, and dispatches CoreEventType.Ready after model init. Fixes a typo in the class comment. |
| packages/core/src/api/DocumentAPI/DocumentAPI.ts | Implements new write methods using the model and injects editor config for default userId. |
| packages/core/src/api/DocumentAPI/DocumentAPI.spec.ts | Updates constructor call to pass a mocked config. |
| packages/collaboration-manager/src/CollaborationManager.ts | Implements EditorjsPlugin, switches from EditorJSModel to EditorAPI, hooks undo/redo/ready via eventBus, adds destroy(). |
| packages/collaboration-manager/src/CollaborationManager.spec.ts | Replaces direct constructor calls with the new createManager helper. |
| packages/collaboration-manager/src/client/OTClient.spec.ts | Rewrites tests to exercise OTClient directly instead of through CollaborationManager. |
| packages/collaboration-manager/test/mocks/createManager.ts | New helper that builds a CollaborationManager with a model-backed DocumentAPI and stub APIs. |
| packages/collaboration-manager/test/mocks/ws.ts | Minor type/style cleanup of the WebSocket mock. |
| packages/collaboration-manager/test/mocks/codex-tooltip.ts, packages/ot-server/test/mocks/codex-tooltip.ts | New minimal codex-tooltip mocks to avoid window is not defined in Node test env. |
| packages/collaboration-manager/jest.config.ts, packages/ot-server/jest.config.ts | Map codex-tooltip to the new mocks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Destroys the plugin instance: clears the debounce timer | ||
| */ | ||
| public destroy(): void { | ||
| clearTimeout(this.#debounceTimer); | ||
| } |
There was a problem hiding this comment.
Implemented in 6c10274. destroy() now unsubscribes document/core listeners and closes the OT client connection; I also added lifecycle tests (including websocket close coverage).
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/editor-js/document-model/sessions/48043d73-bfdc-4210-8f53-4d2128ebbfc0 Co-authored-by: gohabereg <23050529+gohabereg@users.noreply.github.com>
No description provided.