Add the possibility to set markdown editor placeholder and disabled s… - #785
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for placeholder text and disabled state functionality to both the markdown and code editors in the panel. The changes enable editors to display placeholder text when empty and to be dynamically enabled/disabled through a consistent API.
Key Changes
- Added placeholder plugin for ProseMirror-based markdown editor with custom styling
- Implemented editable state management for both markdown and code editors using their respective APIs (ProseMirror props and CodeMirror facets/compartments)
- Enhanced menu toolbar to respect editor disabled state by disabling buttons appropriately
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| panel/src/ts/components/inputs/editor/markdown/placeholder.ts | New plugin that displays placeholder text in empty markdown editors using ProseMirror decorations |
| panel/src/ts/components/inputs/editor/markdown/view.ts | Refactored constructor to accept options object including editable state and placeholder, added editable getter/setter |
| panel/src/ts/components/inputs/editor/markdown/menu.ts | Updated menu to check editor's editable state and disable buttons/dropdowns accordingly |
| panel/src/ts/components/inputs/editor/code/view.ts | Added CodeView options interface, implemented editable getter/setter using CodeMirror's Compartment API, integrated placeholder extension |
| panel/src/ts/components/inputs/editor-input.ts | Enhanced to pass placeholder and disabled state to editors, added disabled getter/setter, improved null safety with optional chaining |
| panel/src/scss/components/forms/_forms-editor.scss | Added styles for placeholder text and disabled editor state with appropriate visual feedback |
| panel/package.json | Added @codemirror/state dependency for Compartment API usage |
| panel/pnpm-lock.yaml | Updated lockfile with new @codemirror/state dependency |
Files not reviewed (1)
- panel/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request enhances the editor input components in the panel by improving support for disabled and read-only states, adding placeholder functionality, and refining styling for better accessibility and user experience. The changes span TypeScript, SCSS, and dependency updates, focusing on making both Markdown and CodeMirror editors more robust and user-friendly.
Editor functionality and accessibility improvements:
Both the Markdown and CodeMirror editors now properly support
disabledandreadOnlystates, ensuring the editors become non-editable and update their UI accordingly. The toolbar toggle button and menu items also reflect the disabled state. (panel/src/ts/components/inputs/editor-input.ts[1] [2] [3] [4];panel/src/ts/components/inputs/editor/code/view.ts[5] [6] [7];panel/src/ts/components/inputs/editor/markdown/menu.ts[8] [9];panel/src/ts/components/inputs/editor/markdown/view.ts[10] [11] [12]Placeholders are now supported in both Markdown and CodeMirror editors, improving usability when the input is empty. For Markdown, a custom ProseMirror plugin displays the placeholder. (
panel/src/ts/components/inputs/editor-input.ts[1] [2];panel/src/ts/components/inputs/editor/code/view.ts[3] [4];panel/src/ts/components/inputs/editor/markdown/placeholder.ts[5];panel/src/ts/components/inputs/editor/markdown/view.ts[6] [7]Styling and user interface:
panel/src/scss/components/forms/_forms-editor.scss[1] [2] [3] [4]Code quality and maintainability:
panel/src/ts/components/inputs/editor-input.tspanel/src/ts/components/inputs/editor-input.tsL68-R68)Dependencies:
@codemirror/stateas a dependency to support the new editor features. (panel/package.json[1]panel/pnpm-lock.yaml[2]