Skip to content

Extract common types from model to new package#156

Open
gohabereg wants to merge 2 commits into
mainfrom
chore/common-types-extraction
Open

Extract common types from model to new package#156
gohabereg wants to merge 2 commits into
mainfrom
chore/common-types-extraction

Conversation

@gohabereg

Copy link
Copy Markdown
Member

Added model-types packages with the types that might be used by external developers.

model-types package is intended to be used only within model and sdk packages. Tools/Plugins should only import sdk package, mode package only should be used by internal packages such as core and ot-server

Copilot instructions

  1. Make sure there's no duplicate definitions (all definitions are migrated to model-types package)
  2. model-types package is used only within model and sdk packages
  3. model-types entities are not re-exported from the model, only from sdk
  4. There's no changes to business logic, only imports updates

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

Unit Tests

Package Coverage Delta
@editorjs/model null% N/A
@editorjs/dom-adapters 88% -1.05% 🔴
@editorjs/collaboration-manager null% N/A
@editorjs/ot-server null% N/A
@editorjs/core null% N/A
@editorjs/model-types null% N/A

Mutation Tests

Package Mutation score Dashboard URL
@editorjs/dom-adapters 8.81% 🔴 Dashboard

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 introduces a new @editorjs/model-types workspace to host low-level shared types/events previously defined in @editorjs/model, and updates the monorepo so that tools/plugins consume these types via @editorjs/sdk (not via model or model-types directly). It also adds Yarn constraints to enforce the intended workspace dependency boundaries.

Changes:

  • Added yarn.config.cjs constraints to restrict which workspaces may depend on @editorjs/model-types and @editorjs/model.
  • Updated package dependencies, TS project references, and imports across sdk, model, ui, playground, and ot-server to use the new model-types package (and re-export from sdk).
  • Updated @editorjs/sdk public exports to surface model-types types/events, plus added a temporary keypath re-export through sdk.

Reviewed changes

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

Show a summary per file
File Description
yarn.config.cjs Adds Yarn constraints logic to enforce allowed dependency relationships between workspaces.
README.md Documents @editorjs/model-types and clarifies intended consumption paths (sdk for tools/plugins).
packages/ui/tsconfig.json Removes direct TS project reference to model.
packages/ui/tsconfig.build.json Updates build references (currently includes model-types).
packages/ui/src/InlineToolbar/InlineToolbar.ts Switches model-derived types to be imported from @editorjs/sdk.
packages/ui/package.json Removes direct dependency on @editorjs/model.
packages/sdk/tsconfig.json Updates TS project reference to model-types.
packages/sdk/tsconfig.build.json Updates TS build reference to model-types.
packages/sdk/src/utils/keypath.ts Adds temporary re-export of keypath helpers from model-types via sdk.
packages/sdk/src/utils/index.ts Adds a utils barrel exporting keyboardShortcut + keypath helpers.
packages/sdk/src/tools/facades/BlockToolFacade.ts Switches BlockChildType/constants/types to come from model-types and keypath via sdk utils.
packages/sdk/src/tools/facades/BaseToolFacade.spec.ts Updates test imports from model to model-types.
packages/sdk/src/index.ts Re-exports model-types types/events from the SDK public entrypoint.
packages/sdk/src/entities/InlineTool.ts Updates type imports from model to model-types.
packages/sdk/src/entities/index.ts Adds Index re-export (in addition to SDK root exports).
packages/sdk/src/entities/EventBus/events/core/SelectionChangedCoreEvent.ts Updates Index/fragment/tool-name type sourcing post-extraction.
packages/sdk/src/entities/EventBus/events/adapter/ValueNodeChanged.ts Switches ValueSerialized import from model to model-types.
packages/sdk/src/entities/EventBus/EventBus.ts Re-exports EventBus from model-types instead of defining it locally.
packages/sdk/src/entities/EditorjsAdapterPlugin.ts Switches BlockId type import to model-types.
packages/sdk/src/entities/Config.ts Removes EditorJSModel type dependency by changing onModelUpdate typing.
packages/sdk/src/entities/BlockToolAdapter.ts Switches event/type imports from model to model-types.
packages/sdk/src/entities/BlockTool.ts Switches ValueSerialized type import to model-types.
packages/sdk/src/api/TextAPI.ts Switches InlineFragment type import to model-types.
packages/sdk/src/api/SelectionAPI.ts Switches Caret/CaretManagerEvents type imports to model-types.
packages/sdk/src/api/DocumentAPI.ts Updates document/data types to come from model-types and Index from SDK entities.
packages/sdk/src/api/BlocksAPI.ts Updates serialized document type usage to model-types document data shape.
packages/sdk/package.json Switches dependency from @editorjs/model to @editorjs/model-types and bumps Jest tooling.
packages/model-types/package.json Defines the new @editorjs/model-types package (including Jest tooling versions).
packages/playground/src/components/CaretIndex.vue Switches event/index imports to come from @editorjs/sdk while keeping EditorJSModel local.
packages/playground/src/App.vue Adapts to the SDK onModelUpdate typing change by casting.
packages/playground/package.json Adds @editorjs/sdk dependency for direct usage.
packages/ot-server/src/DocumentManager.spec.ts Switches IndexBuilder import from model to sdk.
packages/ot-server/package.json Adds @editorjs/sdk dependency and bumps Jest typings/version.
packages/model/tsconfig.json Adds TS project reference to model-types.
packages/model/src/utils/textUtils.ts Switches inline-fragment-related type imports to @editorjs/model-types.
packages/model/src/EventBus/index.ts Re-exports model-types event enums from the model package.
packages/model/src/utils/index.ts Re-exports model-types nominal/create helpers from the model package.
packages/model/src/entities/BlockNode/index.ts Re-exports several model-types types/helpers from the model package.
Comments suppressed due to low confidence (2)

packages/ui/tsconfig.build.json:12

  • @editorjs/ui doesn’t import @editorjs/model-types directly (it imports from @editorjs/sdk), so adding a direct TS project reference to ../model-types unnecessarily couples the build graph to model-types. Keeping only the sdk reference still builds model-types transitively (since sdk references it) and better matches the stated dependency boundaries.
    packages/model/src/entities/BlockNode/index.ts:642
  • This file re-exports multiple @editorjs/model-types symbols (BlockNodeInit, BlockIndexOrId, createDataKey, createBlockId, etc.) from @editorjs/model. That violates the intended rule that model-types entities are not re-exported from the model package (only from @editorjs/sdk). To keep a single public surface, remove these re-exports from the model package and update internal imports/tests to consume them from @editorjs/model-types or @editorjs/sdk.

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

Comment thread yarn.config.cjs
Comment on lines +21 to +23
if (dep.type !== 'dependencies') {
continue;
}
* @param model - EditorJSModel instance
*/
onModelUpdate?: (model: EditorJSModel) => void;
onModelUpdate?: (model: unknown) => void;
Comment thread packages/sdk/package.json
Comment on lines +20 to 27
"@types/jest": "^30.0.0",
"@types/node": "^22.10.2",
"eslint": "^9.24.0",
"eslint-config-codex": "^2.0.3",
"eslint-plugin-import": "^2.31.0",
"jest": "^29.7.0",
"jest": "^30.4.2",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
Comment on lines +21 to +27
"@types/jest": "^30.0.0",
"eslint": "^9.24.0",
"eslint-config-codex": "^2.0.3",
"eslint-plugin-import": "^2.31.0",
"jest": "^30.4.2",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
export * from './EventBus.js';
export * from './events/index.js';
export * from './types/EventAction.js';
export { EventAction, EventType } from '@editorjs/model-types';
Comment on lines +1 to +2
export type { Nominal } from '@editorjs/model-types';
export { create } from '@editorjs/model-types';
export * from './IndexError.js';
export type * from './EditorjsAdapterPlugin.js';

export { Index } from '@editorjs/model-types';
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.

2 participants