Repository navigation
[BNE-148] Create work package link block via hash command - #246
ihordubas99 merged 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The canOpenHashMenu gating logic (and its unit test) appears to disable the menu at exactly 4 hashes, which can break the intended #### block-card trigger flow.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds support for inserting an OpenProject work package block card via a #### hash trigger, refactors the hash menu wiring into a reusable OpenProjectHashMenu component, and introduces new trigger/insert logic with expanded unit + browser test coverage.
Changes:
- Implemented hash-trigger targeting (
#/##/###=> inline chip sizes,####=> block card; longer runs remain literal) and updated hash menu behavior accordingly. - Introduced
<OpenProjectHashMenu />to encapsulate#menu wiring and updated the demo app + test editor harness to use it. - Refactored/expanded tests (including new browser integration coverage) and added shared headless editor helpers for jsdom tests.
File summaries
| File | Description |
|---|---|
| test/lib/utils/inlineChipActions.test.ts | Refactors tests to use shared headless editor helpers and node-type constants. |
| test/lib/components/integration/editor.undo.browser.test.tsx | Adds undo coverage for block cards inserted via #### hash trigger. |
| test/lib/components/integration/blockWorkPackageHashTrigger.browser.test.tsx | New browser integration coverage for #### block-card trigger behavior and edge cases. |
| test/lib/components/HashMenu/hashTrigger.test.ts | New unit tests for hash targeting and menu-open gating behavior. |
| test/lib/components/HashMenu/editorUtils.test.ts | New unit tests for inserting chips/cards and cleaning up trigger hashes. |
| test/lib/components/hashMenu.test.ts | Removes legacy hash menu tests replaced by more focused new suites. |
| test/helpers/renderEditor.tsx | Switches test editor harness to use <OpenProjectHashMenu />. |
| test/helpers/headlessEditor.ts | Adds shared headless BlockNote editor utilities for jsdom-level unit tests. |
| test/helpers/editorHelpers.ts | Adds helpers for inserting block cards via hash in browser tests; refactors hash insertion utilities. |
| src/App.tsx | Updates demo app to use <OpenProjectHashMenu /> instead of manual wiring. |
| lib/utils/suggestionMenu.ts | Adds utility to programmatically close the suggestion menu. |
| lib/utils/inlineChipActions.ts | Adjusts inline chip lookups/resolution to use editor.transact for doc access. |
| lib/index.ts | Exports OpenProjectHashMenu from the public library entrypoint. |
| lib/components/HashMenu/useHashWpMenu.ts | Adds hash target resolution + closes menu for unsupported hash runs; inserts block card for ####. |
| lib/components/HashMenu/OpenProjectHashMenu.tsx | New component encapsulating hash menu controller wiring. |
| lib/components/HashMenu/index.ts | Re-exports OpenProjectHashMenu. |
| lib/components/HashMenu/HashWpMenu.tsx | Adds data-testid="hash-menu" to support browser tests. |
| lib/components/HashMenu/hashTrigger.ts | New trigger parsing and shouldOpen gating logic. |
| lib/components/HashMenu/editorUtils.ts | Updates insertion logic to support inserting either an inline chip or a block card based on trigger target. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
87a4d1e to
06a5b02
Compare
06a5b02 to
2eb7ece
Compare
judithroth
left a comment
There was a problem hiding this comment.
Sorry it took so long until I could review this 😅
Nice work!
| await expect.element(page.getByTestId('op-bn-work-package--type')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('undoes block card inserted via #### hash — card is gone', async () => { |
Ticket
https://community.openproject.org/wp/BNE-148
What are you trying to accomplish?
#to###insert an inline work package link. This adds####for a block-sized one, so creating a card stays the same gesture people already know instead of inserting a link and then resizing it. A run longer than####stops being a command and stays on screen as typed.Screenshots
demo.mp4
What approach did you choose and why?
The card is built by inserting the chip and promoting it right away, so the line splits through the very code path that already runs when an inline link is resized into a card - which is the behaviour the ticket asks for, without a second implementation of it. Both steps share one transaction, so the intermediate chip never surfaces as an undo step.
The
#####case needs BlockNote'sshouldOpenrather than us closing the menu: BlockNote restarts the menu on every#but only callsgetItemswhen the query text changes, and the fifth hash leaves it empty - so we are never asked, and the menu would hang open swallowing Enter.Wiring the menu moved behind
<OpenProjectHashMenu />, next to<OpenProjectFormattingToolbar />: consumers no longer repeat the trigger character, and anything we need internally later costs them nothing. OpenProject side: opf/openproject#25231 - merge it after this is released, it needs the new export.Merge checklist