Feature Reqquest - Add Font Size and Word Wrap settings to editor pre…#735
Feature Reqquest - Add Font Size and Word Wrap settings to editor pre…#735sureshknxtwave wants to merge 1 commit intoaccordproject:mainfrom
Conversation
…ferences - completed
✅ Deploy Preview for ap-template-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
This is a duplicate of #721 |
There was a problem hiding this comment.
Pull request overview
This PR adds configurable font size and word wrap settings to the Playground's Monaco code editors, enhancing accessibility and user experience. The settings are persisted to localStorage and applied consistently across all three editors (Markdown, Concerto, and JSON).
Changes:
- Added
editorSettingsstate withfontSize(12-20px) andwordWrap('on'/'off') to the global store with localStorage persistence - Extended the Settings modal with a font size dropdown and word wrap toggle switch
- Updated all three Monaco editors to consume and apply the new settings via editor options
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/store/store.ts | Added editorSettings state, persistence helpers, and setter function for font size and word wrap |
| src/editors/MarkdownEditor.tsx | Integrated editorSettings into Monaco editor options and refactored code structure |
| src/editors/JSONEditor.tsx | Integrated editorSettings into Monaco editor options and refactored code structure |
| src/editors/ConcertoEditor.tsx | Integrated editorSettings into Monaco editor options, refactored code structure, and removed Concerto keywords |
| src/components/SettingsModal.tsx | Added Font Size dropdown and Word Wrap toggle controls to the settings UI |
| isTemplateCollapsed: false, | ||
| isDataCollapsed: false, | ||
| showLineNumbers: getInitialLineNumbers(), | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
There was a problem hiding this comment.
The eslint-disable comment for unsafe-assignment is unnecessary here for the same reason as above. Consider removing this comment to maintain consistency and code cleanliness.
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| onChange={(value) => setEditorSettings({ fontSize: value })} |
There was a problem hiding this comment.
The eslint-disable comment for unsafe-assignment is unnecessary. The Select onChange handler receives a number value which matches the fontSize type. Consider removing this comment to keep the codebase clean.
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | |
| onChange={(value) => setEditorSettings({ fontSize: value })} | |
| onChange={(value: number) => setEditorSettings({ fontSize: value })} |
| editorSettings: { | ||
| fontSize: number; | ||
| wordWrap: 'on' | 'off'; | ||
| }; | ||
| setEditorSettings: ( | ||
| partial: Partial<AppState['editorSettings']> | ||
| ) => void; |
There was a problem hiding this comment.
The new editor settings functionality (fontSize and wordWrap) lacks test coverage. Based on the existing test pattern for showLineNumbers in src/tests/store/showLineNumbers.test.tsx, similar tests should be added to verify: 1) default values are correct (fontSize: 14, wordWrap: 'on'), 2) setEditorSettings updates the state correctly, 3) settings persist to localStorage, and 4) settings are loaded from localStorage on initialization.
| {/* Font Size */} | ||
| <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3"> | ||
| <div className="flex-1 min-w-0"> | ||
| <h4 className="font-medium text-sm sm:text-base" style={{ color: textColor }}> | ||
| Font Size | ||
| </h4> | ||
| <p className={`text-xs sm:text-sm ${isDarkMode ? 'text-gray-400' : 'text-gray-500'}`}> | ||
| Adjust editor font size | ||
| </p> | ||
| </div> | ||
| <Select | ||
| value={editorSettings.fontSize} | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| onChange={(value) => setEditorSettings({ fontSize: value })} | ||
| style={{ width: 110 }} | ||
| options={FONT_SIZES.map((size) => ({ | ||
| label: `${size}px`, | ||
| value: size, | ||
| }))} | ||
| /> | ||
| </div> | ||
|
|
||
| <hr className={isDarkMode ? 'border-gray-600' : 'border-gray-200'} /> | ||
|
|
||
| {/* Word Wrap */} | ||
| <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3"> | ||
| <div className="flex-1 min-w-0"> | ||
| <h4 className="font-medium text-sm sm:text-base" style={{ color: textColor }}> | ||
| Word Wrap | ||
| </h4> | ||
| <p className={`text-xs sm:text-sm ${isDarkMode ? 'text-gray-400' : 'text-gray-500'}`}> | ||
| Wrap long lines in editors | ||
| </p> | ||
| </div> | ||
| <Switch | ||
| checked={editorSettings.wordWrap === 'on'} | ||
| onChange={(checked) => | ||
| setEditorSettings({ wordWrap: checked ? 'on' : 'off' }) | ||
| } | ||
| /> | ||
| </div> |
There was a problem hiding this comment.
The new Font Size and Word Wrap settings in the SettingsModal lack test coverage. Based on the existing test pattern in src/tests/components/SettingsModal.test.tsx, tests should be added to verify: 1) the Font Size and Word Wrap settings are rendered with correct labels and descriptions, 2) the Font Size dropdown shows the correct options (12-20px), 3) the Word Wrap switch reflects the correct state, and 4) the controls are interactive and update the store correctly.
| "scalar", | ||
| "extends", | ||
| "default", | ||
| "participant", |
There was a problem hiding this comment.
The "default" keyword has been removed from the concertoKeywords array. This appears to be an unintentional change unrelated to the font size and word wrap feature. The "default" keyword is a valid Concerto language keyword used to specify default values for optional properties. This removal will break syntax highlighting for the "default" keyword in Concerto models.
| string: [ | ||
| [/[^\\"]+/, "string"], | ||
| [/@escapes/, "string.escape"], | ||
| [/\\./, "string.escape.invalid"], |
There was a problem hiding this comment.
The escapes pattern and its usage in the string tokenizer have been removed. The escapes pattern was used to properly tokenize escape sequences in strings. Without it, valid escape sequences like \n, \t, ", etc. will not be properly highlighted as escape sequences in the Concerto editor. This is an unintentional change that degrades the editor's syntax highlighting capabilities.
| const getInitialEditorSettings = () => { | ||
| const defaults = { | ||
| fontSize: 14, | ||
| wordWrap: 'on' as 'on' | 'off', | ||
| }; | ||
|
|
||
| if (typeof window !== 'undefined') { | ||
| try { | ||
| const saved = localStorage.getItem('editor-settings'); | ||
| if (saved) { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
| return { ...defaults, ...(JSON.parse(saved)) }; |
There was a problem hiding this comment.
The eslint-disable comment for unsafe-return is unnecessary here. The function getInitialEditorSettings returns a properly typed object with explicit type annotations. The spread operation merges the defaults with the parsed saved settings, which is safe and correctly typed. Consider removing this comment to keep the codebase clean.
| const getInitialEditorSettings = () => { | |
| const defaults = { | |
| fontSize: 14, | |
| wordWrap: 'on' as 'on' | 'off', | |
| }; | |
| if (typeof window !== 'undefined') { | |
| try { | |
| const saved = localStorage.getItem('editor-settings'); | |
| if (saved) { | |
| // eslint-disable-next-line @typescript-eslint/no-unsafe-return | |
| return { ...defaults, ...(JSON.parse(saved)) }; | |
| const getInitialEditorSettings = (): { fontSize: number; wordWrap: 'on' | 'off' } => { | |
| const defaults: { fontSize: number; wordWrap: 'on' | 'off' } = { | |
| fontSize: 14, | |
| wordWrap: 'on', | |
| }; | |
| if (typeof window !== 'undefined') { | |
| try { | |
| const saved = localStorage.getItem('editor-settings'); | |
| if (saved) { | |
| const parsed = JSON.parse(saved) as Partial<{ fontSize: number; wordWrap: 'on' | 'off' }>; | |
| return { ...defaults, ...parsed }; |
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| const initialEditorSettings = getInitialEditorSettings(); |
There was a problem hiding this comment.
The eslint-disable comment for unsafe-assignment is unnecessary. The getInitialEditorSettings function returns a properly typed object, and TypeScript can infer the correct type. Consider removing this comment to keep the codebase clean.
Add font size and word wrap settings to Playground editors
Closes #<720>
This pull request adds configurable font size and word wrap options to the Playground’s code editors, improving accessibility and overall developer experience. Users can now adjust editor readability based on their screen size and personal preferences, and these settings persist across page reloads.
Changes
Flags
Author Checklist
--signoffoption of git commit.mainfromfork:feature-request.