Skip to content

Make CollaborationManager a Plugin#144

Merged
gohabereg merged 11 commits into
mainfrom
feautre/collaboration-plugin
May 31, 2026
Merged

Make CollaborationManager a Plugin#144
gohabereg merged 11 commits into
mainfrom
feautre/collaboration-plugin

Conversation

@gohabereg

Copy link
Copy Markdown
Member

No description provided.

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

⏭️ No files to mutate for ./packages/model

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

⏭️ No files to mutate for ./packages/dom-adapters

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

Coverage report for ./packages/dom-adapters

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 ede70c0

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

Coverage report for ./packages/model

St.
Category Percentage Covered / Total
🟢 Statements 99.71% 1043/1046
🟢 Branches 98.44% 315/320
🟢 Functions 98.39% 244/248
🟢 Lines 99.7% 1001/1004

Test suite run success

563 tests passing in 26 suites.

Report generated by 🧪jest coverage report action from ede70c0

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

Coverage report for ./packages/core

St.
Category Percentage Covered / Total
🟢 Statements
91.15% (-2.78% 🔻)
175/192
🟢 Branches
88.24% (-3.23% 🔻)
75/85
🟡 Functions
68.75% (-6.86% 🔻)
33/48
🟢 Lines
90.61% (-2.96% 🔻)
164/181
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / DocumentAPI.ts
45.45% 0% 28.57% 40%

Test suite run success

103 tests passing in 7 suites.

Report generated by 🧪jest coverage report action from ede70c0

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

⏭️ No files to mutate for ./packages/core

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

Coverage report for ./packages/ot-server

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 ede70c0

@gohabereg gohabereg requested a review from Copilot May 19, 2026 17:35
@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

Coverage report for ./packages/collaboration-manager

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 ede70c0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CollaborationManager a PluginType.Plugin that receives { api, config, eventBus }, listens to core:undo/redo/ready, applies operations via DocumentAPI, and renders incoming snapshots via blocks.render.
  • Extend DocumentAPI (sdk + core impl) with insertData/removeData/modifyData taking { userId, index, data }, defaulting userId to the editor config; add CoreEventType.Ready dispatched at the end of Core.initialize.
  • Rework collaboration-manager and ot-server tests around the new plugin shape: new createManager helper, refactored OTClient.spec.ts that drives the client directly, and a shared codex-tooltip mock 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.

Comment thread packages/core/src/api/DocumentAPI/DocumentAPI.ts Outdated
Comment on lines +332 to +337
/**
* Destroys the plugin instance: clears the debounce timer
*/
public destroy(): void {
clearTimeout(this.#debounceTimer);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply the suggested change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Base automatically changed from feature/api-user-id to feature/model-api May 29, 2026 22:45
Base automatically changed from feature/model-api to main May 29, 2026 23:43
@gohabereg gohabereg added this pull request to the merge queue May 31, 2026
Merged via the queue into main with commit 7d121c7 May 31, 2026
24 checks passed
@gohabereg gohabereg deleted the feautre/collaboration-plugin branch May 31, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants