Skip to content

feat(core): implement Document API#130

Open
ilyamore88 wants to merge 5 commits intomainfrom
feat/document-api
Open

feat(core): implement Document API#130
ilyamore88 wants to merge 5 commits intomainfrom
feat/document-api

Conversation

@ilyamore88
Copy link
Copy Markdown
Member

This pull request introduces a new DocumentAPI to the codebase, providing a standardized way to access the serialized document data from the editor. The implementation includes both the interface and the concrete class, integrates the API into the editor's dependency injection system, and adds corresponding tests and exports.

New Document API Implementation and Integration:

  • Added a new DocumentAPI class in packages/core/src/api/DocumentAPI/DocumentAPI.ts, which provides a getter for the serialized document data and is registered as a service for dependency injection.
  • Defined the DocumentAPI interface in packages/sdk/src/api/DocumentAPI.ts to standardize access to the serialized document object.
  • Updated the EditorAPI interface and implementation to include the new document property, making the DocumentAPI accessible as part of the main API surface. [1] [2] [3] [4]
  • Exported the new API from relevant index files for both implementation and type definitions. [1] [2]

Testing:

  • Added unit tests for DocumentAPI in DocumentAPI.spec.ts to verify that the API correctly returns the serialized model data.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

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 179b754

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

Coverage report for ./packages/model

St.
Category Percentage Covered / Total
🟢 Statements 99.89% 893/894
🟢 Branches 99.62% 262/263
🟢 Functions 98.17% 214/218
🟢 Lines 99.88% 858/859

Test suite run success

467 tests passing in 25 suites.

Report generated by 🧪jest coverage report action from 179b754

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

Coverage report for ./packages/core

St.
Category Percentage Covered / Total
🟢 Statements 100% 107/107
🟢 Branches 97.44% 38/39
🟢 Functions 100% 26/26
🟢 Lines 100% 99/99
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / DocumentAPI.ts
100% 100% 100% 100%

Test suite run success

67 tests passing in 6 suites.

Report generated by 🧪jest coverage report action from 179b754

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

Coverage report for ./packages/ot-server

St.
Category Percentage Covered / Total
🟡 Statements 70.97% 22/31
🔴 Branches 20% 1/5
🟡 Functions 75% 6/8
🟡 Lines 68.97% 20/29

Test suite run success

4 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from 179b754

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 18, 2026

Coverage report for ./packages/collaboration-manager

St.
Category Percentage Covered / Total
🟢 Statements 91.99% 356/387
🟢 Branches 84.06% 116/138
🟢 Functions 98.15% 53/54
🟢 Lines 91.88% 351/382

Test suite run success

117 tests passing in 7 suites.

Report generated by 🧪jest coverage report action from 179b754

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a new DocumentAPI to expose serialized editor document data via the main EditorAPI surface, including DI integration in core and a unit test.

Changes:

  • Added DocumentAPI type to the SDK and exported it from the SDK API index.
  • Implemented DocumentAPI service in core and injected it into core’s EditorAPI.
  • Added a unit test validating DocumentAPI.data returns the model’s serialized document.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/sdk/src/api/index.ts Re-exports the new DocumentAPI type.
packages/sdk/src/api/EditorAPI.ts Extends EditorAPI interface with a document property.
packages/sdk/src/api/DocumentAPI.ts Defines the DocumentAPI interface with a data getter.
packages/core/src/api/index.ts Injects DocumentAPI into core EditorAPI (runtime import path issue noted).
packages/core/src/api/DocumentAPI/index.ts Adds barrel export for core DocumentAPI implementation.
packages/core/src/api/DocumentAPI/DocumentAPI.ts Implements DocumentAPI as a typedi service backed by EditorJSModel.serialized.
packages/core/src/api/DocumentAPI/DocumentAPI.spec.ts Adds unit test for DocumentAPI.data getter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/api/index.ts Outdated
Comment thread packages/core/src/api/DocumentAPI/DocumentAPI.spec.ts Outdated
Comment thread packages/core/src/api/DocumentAPI/DocumentAPI.spec.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/api/DocumentAPI/DocumentAPI.spec.ts
*/
@Service()
export class DocumentAPI implements DocumentApiInterface {
#model: EditorJSModel;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

jsdoc missing, you could use @link to definition of the model maybe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants