-
Notifications
You must be signed in to change notification settings - Fork 110
fix: UI review bugs #414
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
Closed
Closed
fix: UI review bugs #414
Changes from 26 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
56fc6bd
fix: strip html tags from cloud snippet descriptions
imantsk fb378a7
fix: filter foreign admin notices on code snippets screens
imantsk d3b8440
fix: improve snippet preview modal sizing and theme
imantsk 1d26a35
feat: show line numbers and language badge in snippet preview
imantsk d5b9a60
Merge branch 'core-beta' into fix/166-ui-review-fixes
imantsk db95f8d
fix: use full-size badge in snippet preview modal title
imantsk ae62c8c
fix: register rest collection args with named keys
imantsk 3a5ddfe
fix: convert zero-based cloud api page numbers for display
imantsk d7625fc
fix: report one-based page number for featured cloud results
imantsk 9c67039
fix: preserve the preview modal title contract
imantsk cade6de
fix: load only preview editor assets
imantsk 69ba8cb
fix: degrade snippet preview gracefully when the code editor is unava…
imantsk c2ca74e
fix: cover preview fallback without the code editor
imantsk af3a8ef
fix: harden preview fallback and notice ownership
imantsk 2187066
fix: include Add New hook in notice filtering and allow keyboard focu…
e352952
fix: wrap long lines in preview E2E spec to respect 100-char limit
88c517b
fix: include compact-menu hookname in notice filter screen check
5a56b14
fix: restore notice separator spacing rule for filter-disable path
0cd08d8
fix: handle invokable-object reflection, narrow modal type prop, dele…
1bf989f
fix: restore table view as default
c7c5930
fix: make preview modal 5.5-compatible, normalize cloud descriptions,…
c7ba43d
fix: correct cloud snippet preview output
5cc1582
fix: strip malformed tags with unbalanced quotes in stripTags
87467c3
fix: raise locked badge contrast to WCAG AA
790f741
fix: preserve plain comparison text in stripTags fallback
eac9b35
fix: make stripTags fallback linear
308dc5e
fix: make stripTags comment removal linear
1013055
fix: strengthen stripTags performance regression test
12acf12
fix: remove historical test comment
fa2d4e7
fix: decode cloud description entities
346d28e
fix: correct entity decoding comment
3264d44
fix: resolve cloud per-page default at request time
ebf92d8
feat: new admin UI foundation (#415)
imantsk 3f7f6c3
Merge branch 'core-beta' into fix/166-ui-review-fixes/core
sheabunge d94d2c4
Merge branch 'fix/166-ui-review-fixes' of https://github.com/codesnip…
sheabunge c623fdc
Remove unnecessary ListTable fragmentation.
sheabunge 36f6da5
chore: merge core-beta into UI review fixes
imantsk 8405d42
fix: hide foreign notices with CSS only
imantsk 2e98d89
fix: sanitize cloud descriptions at decode boundary
imantsk 6dc65bd
fix: simplify strip tags helper
imantsk 032b621
fix: use cloud search page size for featured results
imantsk 41ef970
fix: add row selection to cloud table view
imantsk 2579c66
chore: use theme tokens in list table styles
imantsk a6de704
fix: correct pagination i18n
imantsk 56ede7f
chore: address accessibility review feedback
imantsk 5a762e5
chore: remove redundant author translator note
imantsk ddab139
fix: preserve visible cloud description text
imantsk b80b89a
fix: sanitize hydrated cloud snippets
imantsk 92bf71d
fix: restore community cloud snippets tab count
imantsk 43e1314
fix: separate remaining block elements in strip tags helper
imantsk 8ff0f89
fix: wait for snippet view preference to persist in e2e tests
imantsk 7c56daa
fix: hide notices injected into manage root
imantsk c12c94b
fix: refine snippet table, consolidate preview modal and notice prese…
imantsk c074552
fix: keep version switch and migration notices visible
imantsk a66c9eb
chore: remove unused props added by this branch
imantsk 2dea8ba
chore: drop the unused preview modal action slot
imantsk d73d7ae
chore: inline manage menu registration
imantsk 11bc82b
fix: give card view badges the same focus ring
imantsk ff06051
fix: match the kebab priority row height
imantsk 1df1c1b
fix: remove kebab menu popover block padding
imantsk e706e47
fix: apply plugin checkbox styling to screen options
imantsk ba40d96
fix: use translator comments for cloud author and view count strings
imantsk 60bbf7d
chore: count snippet types through the snippets API
imantsk c191a3e
chore: ignore non-object data when setting model fields
imantsk 8f7610b
fix: sanitize cloud snippet descriptions in the model
imantsk 969157d
chore: drop direct access guards from autoloaded menu classes
imantsk 088f1d3
fix: correct the pagination input description and spacing
imantsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,85 @@ | ||
| import React, { useEffect } from 'react' | ||
| import React, { useEffect, useRef } from 'react' | ||
| import { Modal } from '@wordpress/components' | ||
| import { Prism } from '../../utils/Prism' | ||
| import { __ } from '@wordpress/i18n' | ||
| import { Badge } from './Badge' | ||
| import type { EditorFromTextArea } from 'codemirror' | ||
| import type { SnippetType } from '../../types/Snippet' | ||
|
|
||
| export interface SnippetPreviewModalProps { | ||
| title: string | ||
| code: string | ||
| type: string | ||
| type: SnippetType | ||
| isOpen: boolean | ||
| setIsOpen: (isOpen: boolean) => void | ||
| } | ||
|
|
||
| // Mirrors the type-to-mode mapping used by the live editor in SnippetTypeInput. | ||
| const EDITOR_MODES: Record<string, string> = { | ||
| css: 'text/css', | ||
| js: 'javascript', | ||
| php: 'text/x-php', | ||
| html: 'application/x-httpd-php' | ||
| } | ||
|
|
||
| /** | ||
| * Modal for quickly viewing a snippet's code with syntax highlighting, | ||
| * without navigating to the edit page. Shared between local snippets and | ||
| * cloud snippet previews. | ||
| * Modal for quickly viewing a snippet's code in a read-only CodeMirror editor, | ||
| * without navigating to the edit page. Shared between local snippets and cloud | ||
| * snippet previews. | ||
| */ | ||
| export const SnippetPreviewModal: React.FC<SnippetPreviewModalProps> = ({ title, code, type, isOpen, setIsOpen }) => { | ||
| export const SnippetPreviewModal: React.FC<SnippetPreviewModalProps> = ({ | ||
| title, | ||
| code, | ||
| type, | ||
| isOpen, | ||
| setIsOpen | ||
| }) => { | ||
| const textareaRef = useRef<HTMLTextAreaElement>(null) | ||
|
|
||
| useEffect(() => { | ||
| if (isOpen) { | ||
| Prism.highlightAll() | ||
| if (!isOpen || !textareaRef.current || !window.wp.codeEditor) { | ||
| return undefined | ||
| } | ||
|
|
||
| const instance = window.wp.codeEditor.initialize(textareaRef.current, { | ||
| codemirror: { | ||
| readOnly: true, | ||
| lineNumbers: true, | ||
| theme: window.CODE_SNIPPETS_MANAGE?.editorTheme ?? 'default', | ||
| mode: EDITOR_MODES[type] ?? EDITOR_MODES.php | ||
| } | ||
| }) | ||
|
|
||
| // CodeMirror hides the labelled source textarea and creates an unlabelled | ||
| // internal input. The screenReaderLabel option only exists from CodeMirror | ||
| // 5.59, while WordPress 5.5 ships 5.29, so label the input directly. | ||
| instance.codemirror.getInputField().setAttribute( | ||
| 'aria-label', | ||
| __('Snippet code preview', 'code-snippets') | ||
| ) | ||
|
|
||
| return () => { | ||
| (instance.codemirror as EditorFromTextArea).toTextArea() | ||
| } | ||
| }, [isOpen]) | ||
| }, [isOpen, type]) | ||
|
|
||
| return isOpen | ||
| ? <Modal onRequestClose={() => setIsOpen(false)} title={title}> | ||
| <pre className="line-numbers"> | ||
| <code className={`language-${type}`}> | ||
| {'php' === type ? '<?php\n\n' : ''} | ||
| {code} | ||
| </code> | ||
| </pre> | ||
| ? <Modal | ||
| className="code-snippets-preview-modal" | ||
| onRequestClose={() => setIsOpen(false)} | ||
| title={title} | ||
| > | ||
| {/* The minimum-supported WordPress Modal (5.5–6.3) has no headerActions | ||
| * prop, so the badge renders in the content and CSS moves it into the | ||
| * header area. */} | ||
| <div className="code-snippets-preview-modal__badge"> | ||
| <Badge name={type} /> | ||
| </div> | ||
| <textarea | ||
| ref={textareaRef} | ||
| readOnly | ||
| aria-label={__('Snippet code preview', 'code-snippets')} | ||
| defaultValue={`${'php' === type ? '<?php\n\n' : ''}${code}`} | ||
| /> | ||
| </Modal> | ||
| : null | ||
| } |
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
I believe this is still necessary for the front-end code highlighting?
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.
Only the unused admin-side wrapper was removed. The front-end
entries/prism.tsbundle, its webpack entry, andCode_Highlighterare unchanged.