-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow saving generated text in a media library from block edito…
…r context
- Loading branch information
Showing
5 changed files
with
79 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ToggleControl } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { ComponentProps } from 'react'; | ||
|
||
interface SaveAltInMediaLibraryControlProps { | ||
label?: string; | ||
checked: ComponentProps<typeof ToggleControl>['checked']; | ||
onChange: ComponentProps<typeof ToggleControl>['onChange']; | ||
disabled?: ComponentProps<typeof ToggleControl>['disabled']; | ||
} | ||
|
||
const DEFAULT_LABEL = __( | ||
'Save alt text in media library', | ||
'alt-text-generator-gpt-vision', | ||
); | ||
|
||
export default function SaveAltInMediaLibraryControl({ | ||
label = DEFAULT_LABEL, | ||
checked, | ||
onChange, | ||
disabled = false, | ||
}: SaveAltInMediaLibraryControlProps) { | ||
return ( | ||
<ToggleControl | ||
label={label} | ||
checked={checked} | ||
onChange={onChange} | ||
help={ | ||
checked | ||
? __( | ||
'Alternative text will be saved in the WordPress media library, making it available for reuse across site.', | ||
'alt-text-generator-gpt-vision', | ||
) | ||
: __( | ||
'Alternative text will only be saved for the current editor block.', | ||
'alt-text-generator-gpt-vision', | ||
) | ||
} | ||
disabled={disabled} | ||
/> | ||
); | ||
} |
This file contains 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 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 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