Extract common types from model to new package#156
Open
gohabereg wants to merge 2 commits into
Open
Conversation
Unit Tests
Mutation Tests
|
Contributor
There was a problem hiding this comment.
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.cjsconstraints to restrict which workspaces may depend on@editorjs/model-typesand@editorjs/model. - Updated package dependencies, TS project references, and imports across
sdk,model,ui,playground, andot-serverto use the newmodel-typespackage (and re-export fromsdk). - Updated
@editorjs/sdkpublic exports to surface model-types types/events, plus added a temporarykeypathre-export throughsdk.
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/uidoesn’t import@editorjs/model-typesdirectly (it imports from@editorjs/sdk), so adding a direct TS project reference to../model-typesunnecessarily couples the build graph tomodel-types. Keeping only thesdkreference still buildsmodel-typestransitively (sincesdkreferences it) and better matches the stated dependency boundaries.
packages/model/src/entities/BlockNode/index.ts:642- This file re-exports multiple
@editorjs/model-typessymbols (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-typesor@editorjs/sdk.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+23
| if (dep.type !== 'dependencies') { | ||
| continue; | ||
| } |
| * @param model - EditorJSModel instance | ||
| */ | ||
| onModelUpdate?: (model: EditorJSModel) => void; | ||
| onModelUpdate?: (model: unknown) => void; |
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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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