-
Notifications
You must be signed in to change notification settings - Fork 63
Disable linting for CSS mode in CodeMirror editor #2457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Disable linting for CSS mode in CodeMirror editor #2457
Conversation
…SS syntax in WordPress. This change ensures compatibility with the WordPress CSS editor, which does not handle modern CSS features.
WalkthroughAdds a conditional in setupCodeMirror to disable CodeMirror linting when mode is set to 'css' after merging data-codemirror attributes, affecting only CSS mode initialization. Changes
Sequence Diagram(s)sequenceDiagram
participant AdminUI as Admin UI
participant CMInit as setupCodeMirror()
participant CM as CodeMirror
AdminUI->>CMInit: Initialize editor with config
CMInit->>CMInit: Merge data-codemirror attrs
alt mode === 'css'
Note over CMInit: Disable lint
CMInit->>CMInit: codemirrorConfig.codemirror.lint = false
else
CMInit->>CMInit: Keep existing lint setting
end
CMInit->>CM: CodeMirror.fromTextArea(config)
CM-->>AdminUI: Editor instance
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
assets/js/admin-views.js (1)
1345-1349
: Broaden CSS-mode check and read the merged config, not just data-attribute.Covers cases where mode is 'text/css' or an object ({name:'css'}) and when mode comes from defaults (no data-codemirror on the textarea). Optionally removes empty lint gutter.
- // Disable linting for CSS mode as WordPress CSS editor does not support modern CSS syntax. - if ( attributeValue && 'css' === attributeValue.mode ) { - codemirrorConfig.codemirror.lint = false; - } + // Disable linting for CSS mode as WordPress CSS editor does not support modern CSS syntax. + const modeOpt = codemirrorConfig?.codemirror?.mode; + const modeName = typeof modeOpt === 'string' ? modeOpt : modeOpt?.name; + if ( modeName === 'css' || modeName === 'text/css' ) { + codemirrorConfig.codemirror.lint = false; + // Optional: drop lint gutter to avoid an empty column. + if ( Array.isArray( codemirrorConfig.codemirror.gutters ) ) { + codemirrorConfig.codemirror.gutters = + codemirrorConfig.codemirror.gutters.filter( g => g !== 'CodeMirror-lint-markers' ); + } + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
assets/js/admin-views.min.js
is excluded by!**/*.min.js
📒 Files selected for processing (1)
assets/js/admin-views.js
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test_and_package
💾 Build file (4ffc051).
Summary by CodeRabbit