Skip to content

feat(core): extract ShortcutsPlugin into @editorjs/shortcuts-plugin#180

Open
ilyamore88 wants to merge 1 commit into
mainfrom
worktree-shortcuts-plugin-extraction
Open

feat(core): extract ShortcutsPlugin into @editorjs/shortcuts-plugin#180
ilyamore88 wants to merge 1 commit into
mainfrom
worktree-shortcuts-plugin-extraction

Conversation

@ilyamore88

Copy link
Copy Markdown
Member

Closes #171.

Extracts the last remaining in-tree EditorjsPlugin out of packages/core into a standalone @editorjs/shortcuts-plugin package, mirroring the ClipboardPlugin extraction (#129).

What changed

  • New package packages/plugins/shortcuts-plugin (@editorjs/shortcuts-plugin), scaffolded from clipboard-plugin (package.json, tsconfig{,.build,.eslint}.json, eslint.config.mjs, jest.config.ts, stryker.conf.mjs, .gitignore, README.md).
  • Source moved verbatimShortcutsPlugin.tssrc/index.ts with zero content change (git detects a pure rename). The plugin already imported only from @editorjs/sdk, so no code edits were needed.
  • New test suite src/index.spec.ts — 12 cases at 100% coverage (statements/branches/functions/lines), closing the pre-existing gap (there was no ShortcutsPlugin.spec.ts). Covers shortcut registration from tool options, keydown match/dispatch, first-match-wins, the IME-composition guard, IndexError tolerance vs. rethrow of other errors, and destroy().
  • Core wiring — added the workspace:^ dependency, added project references in both tsconfig.json and tsconfig.build.json, switched the import to @editorjs/shortcuts-plugin, and removed the now-empty src/plugins/ directory. Registration order in Core is unchanged.
  • CI — new .github/workflows/shortcuts-plugin.yml, same package-check.yml-based shape as clipboard-plugin.yml (include-mutations: true).
  • OpenSpec — moved the "Keyboard shortcuts plugin" requirement out of specs/core/spec.md into a new specs/shortcuts-plugin/spec.md; openspec validate passes for all 12 specs.

Notes / scope

  • Per the request, the plugin source is unchanged. The two reserved-but-unused private methods (#processBlockTool / #processBlockTune) are moved as-is; they carry no statements so coverage stays at 100%. Consequently the issue's suggestion to also test the reserved block-tool/tune shortcuts map isn't applicable yet — it's documented as reserved in the new spec instead.

Verification

  • yarn workspace @editorjs/shortcuts-plugin lint:ci — clean
  • yarn workspace @editorjs/shortcuts-plugin test:coverage — 12 passed, 100%
  • yarn workspace @editorjs/shortcuts-plugin build — ok
  • yarn workspace @editorjs/core lint:ci / build — clean
  • yarn constraints — clean
  • openspec validate — 12 passed

Follow-ups (not in this PR)

  • matchKeyboardShortcut has no unit test in @editorjs/sdk.
  • .github/scripts/should-run-ci.sh only scans depth-1 packages/*, so it's blind to dependency changes for packages/plugins/* and packages/tools/* (pre-existing).

🤖 Generated with Claude Code

Move the last in-tree EditorjsPlugin out of packages/core into a
standalone @editorjs/shortcuts-plugin package, mirroring the
clipboard-plugin extraction (#129). Closes #171.

- New package packages/plugins/shortcuts-plugin scaffolded from
  clipboard-plugin (package.json, tsconfigs, eslint, jest, stryker).
- ShortcutsPlugin.ts moved verbatim into src/index.ts (no source
  changes) and covered by a new index.spec.ts (12 cases, 100% coverage)
  that closes the pre-existing test gap.
- Wire core: add the workspace dependency, tsconfig project references
  (tsconfig + tsconfig.build), and switch the import to the package;
  delete the now-empty src/plugins directory.
- Dedicated CI workflow shortcuts-plugin.yml (package-check shape).
- Move the "Keyboard shortcuts plugin" requirement out of the core
  OpenSpec spec into a new specs/shortcuts-plugin/spec.md.
- Ignore .claude/worktrees/ in .gitignore.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

Unit Tests

Package Coverage Delta
@editorjs/shortcuts-plugin 100% N/A
@editorjs/core 90.47% 0% ⚪️

Mutation Tests

Package Mutation score Dashboard URL
@editorjs/shortcuts-plugin 100.00% 🟢 Dashboard
@editorjs/core 0.00% 🔴 Dashboard

@ilyamore88
ilyamore88 requested review from Reversean and neSpecc July 23, 2026 21:01
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.

Extract ShortcutsPlugin into a separate @editorjs/shortcuts-plugin package

2 participants