Clean up command factory
This PR adds utility functions that use built in functions from prosemirror to handle operations related to creating/removing and toggling between list types in the text editor.
Tests are also added for this functionality.
Fixes: https://github.com/Lundalogik/lime-elements/issues/3313
Summary by CodeRabbit
-
New Features
- Enhanced text editor behavior with improved list management—keyboard shortcuts now offer intuitive indenting, outdenting, splitting, and joining of list items.
- Commands are now context-aware, enabling smarter, condition-based execution.
- Link insertion has been refined with stronger URL validation for smoother pasting of links.
-
Documentation
- Updated user guidance and release notes to reflect these text editor improvements.
-
Chores
- Package version and dependency updates for increased overall stability.
Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3431/
If you try to make sub-lists, the behaviour quickly gets quite weird 🤔
https://github.com/user-attachments/assets/573ff9de-5160-4228-9953-46d1220e072e
If you try to make sub-lists, the behaviour quickly gets quite weird 🤔
Screen.Recording.2025-02-15.at.22.05.14.mov
I think I have some ideas of why this is happening. I'll take a look again on Monday.
Yeah, I don't expect you to be working on the weekend just because I am 😂 No stress my friend! 🤗
📝 Walkthrough
Walkthrough
This PR increments the project version to 38.6.0 and updates the changelog, package.json, and sonar configuration accordingly. It introduces new utility functions and refactors for the ProseMirror text editor—improving list command handling (including toggling between ordered and unordered lists), link validation, node and selection utilities, and menu state tracking. Additionally, a broad suite of new test files and documents has been added to support command testing, content generation, editor state/view building, event simulation, and schema creation.
Changes
| File(s) | Change Summary |
|---|---|
CHANGELOG.md, package.json, sonar-project.properties |
Updated version from 38.5.0 to 38.6.0; added changelog entry for new text editor command feature; updated dependency and sonar.projectVersion values. |
src/components/text-editor/list-functionality*.md |
Added documents outlining list functionality progress, implementation plans, and detailed feature descriptions for list management. |
src/components/text-editor/prosemirror-adapter/menu/menu-command-utils/{active-state-utils,link-utils,list-utils,node-utils,selection-utils}.ts |
Introduced new utility functions for managing active states, link validation, list operations, node traversal, and selection adjustments. |
src/components/text-editor/prosemirror-adapter/menu/menu-commands.ts, src/components/text-editor/prosemirror-adapter/menu/menu-list-commands.spec.ts |
Refactored list command handling to use new handlers (handleListNoSelection, handleListWithSelection); updated command interface to include an allowed method; added tests for list command behavior. |
src/components/text-editor/prosemirror-adapter/plugins/{link-plugin,list-key-handler,menu-state-tracking-plugin,table-plugin}.ts and their corresponding spec files |
Added new plugins for list key handling, menu state tracking, and table functionality; modified import sources for link validation; exported previously private functions; added comprehensive tests for plugin behavior. |
src/components/text-editor/prosemirror-adapter/prosemirror-adapter.tsx |
Integrated the new list key handler plugin and updated the action bar update method to incorporate allowed types filtering. |
src/components/text-editor/test-setup/** |
Added extensive test infrastructure including command testers, content generators, editor state/view builders, event simulators, schema builders, and accompanying documentation/logs for overall testing utilities. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant Editor
participant CmdHandler as List Command Handler
participant Util as List Utility Functions
User->>Editor: Trigger toggle list command
Editor->>CmdHandler: Dispatch command request
CmdHandler->>Util: Check selection state (list vs. no selection)
Util-->>CmdHandler: Return list context details
CmdHandler->>Editor: Apply list type conversion (ordered ↔ unordered)
Editor-->>User: Updated document state
Assessment against linked issues
| Objective (#3313) | Addressed | Explanation |
|---|---|---|
| Allow switching between unordered and ordered lists within the text editor | ✅ |
Possibly related PRs
-
Lundalogik/lime-elements#3458: Enhances command handling by adding an
allowedproperty to theCommandWithActiveinterface, aligning with the conditional command execution improvements introduced in this PR.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
‼️ IMPORTANT Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and generate unit testing code. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai planto trigger planning for file edits and PR creation. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.