Extract common types from model to new package#156
Conversation
Unit Tests
Mutation Tests
|
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.
|
If anyone wanna re-run review, I've hit a limit |
…ere's only one artifact
…ntain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…traction # Conflicts: # packages/core/src/api/SelectionAPI.spec.ts # packages/core/src/api/SelectionAPI.ts # packages/core/src/components/SelectionManager.spec.ts # packages/core/src/components/SelectionManager.ts # packages/core/src/index.ts # packages/core/src/tools/internal/inline-tools/bold/index.ts # packages/core/src/tools/internal/inline-tools/italic/index.ts # packages/core/src/tools/internal/inline-tools/link/index.ts # packages/model/src/entities/inline-fragments/FormattingInlineNode/types/FormattingAction.ts # packages/sdk/src/api/SelectionAPI.ts # packages/sdk/src/entities/EventBus/events/core/SelectionChangedCoreEvent.ts # packages/sdk/src/tools/facades/BaseToolFacade.spec.ts # packages/ui/src/InlineToolbar/InlineToolbar.ts
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 236 out of 241 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
packages/ui/tsconfig.build.json:12
@editorjs/model-typesis intended to be depended on directly only by@editorjs/modeland@editorjs/sdk. Adding it as a TS project reference from@editorjs/uitightens coupling and makes the build graph diverge from package.json dependencies.@editorjs/sdkalready referencesmodel-types, souican rely on that transitive reference instead.
…traction # Conflicts: # packages/sdk/src/tools/facades/BlockToolFacade.ts
| TextUnformattedEvent, | ||
| CaretManagerCaretUpdatedEvent, | ||
| BlockAddedEvent, | ||
| BlockRemovedEvent |
There was a problem hiding this comment.
Should we re-export CaretManagerCaretAddedEvent, CaretManagerCaretRemovedEvent, PropertyModifiedEvent, TuneModifiedEvent here?
According on events-catalog.mmd, I assume that yes.
| }, | ||
| { | ||
| "path": "../sdk/tsconfig.build.json" | ||
| "path": "../model/tsconfig.build.json" |
There was a problem hiding this comment.
Since @editorjs/model was moved to devDependencies, should ../model/tsconfig.build.json be here?
tsconfig.json doesn't have it.
document-model/packages/collaboration-manager/tsconfig.json
Lines 17 to 23 in 33b279c
| PropertyModifiedEvent, | ||
| TuneModifiedEvent |
There was a problem hiding this comment.
Seems like unused import.
| PropertyModifiedEvent, | |
| TuneModifiedEvent | |
| PropertyModifiedEvent |
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. There is yarn workspace constraint now to check this on precommit (yarn.config.cjs file)
Copilot instructions