-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Document and Remove experimental mark from URLPopover.LinkVie…
…wer and URLPopover.LinkEditor. (#16566)
- Loading branch information
1 parent
f598210
commit 442ff9d
Showing
6 changed files
with
185 additions
and
82 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
42 changes: 42 additions & 0 deletions
42
packages/block-editor/src/components/url-popover/link-editor.js
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 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
IconButton, | ||
} from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import URLInput from '../url-input'; | ||
|
||
export default function LinkEditor( { | ||
autocompleteRef, | ||
className, | ||
onChangeInputValue, | ||
value, | ||
...props | ||
} ) { | ||
return ( | ||
<form | ||
className={ classnames( | ||
'block-editor-url-popover__link-editor', | ||
className | ||
) } | ||
{ ...props } | ||
> | ||
<URLInput | ||
value={ value } | ||
onChange={ onChangeInputValue } | ||
autocompleteRef={ autocompleteRef } | ||
/> | ||
<IconButton icon="editor-break" label={ __( 'Apply' ) } type="submit" /> | ||
</form> | ||
); | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/block-editor/src/components/url-popover/link-viewer.js
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,56 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
ExternalLink, | ||
IconButton, | ||
} from '@wordpress/components'; | ||
import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url'; | ||
|
||
function LinkViewerUrl( { url, urlLabel, className } ) { | ||
const linkClassName = classnames( | ||
className, | ||
'block-editor-url-popover__link-viewer-url' | ||
); | ||
|
||
if ( ! url ) { | ||
return <span className={ linkClassName }></span>; | ||
} | ||
|
||
return ( | ||
<ExternalLink | ||
className={ linkClassName } | ||
href={ url } | ||
> | ||
{ urlLabel || filterURLForDisplay( safeDecodeURI( url ) ) } | ||
</ExternalLink> | ||
); | ||
} | ||
|
||
export default function LinkViewer( { | ||
className, | ||
linkClassName, | ||
onEditLinkClick, | ||
url, | ||
urlLabel, | ||
...props | ||
} ) { | ||
return ( | ||
<div | ||
className={ classnames( | ||
'block-editor-url-popover__link-viewer', | ||
className | ||
) } | ||
{ ...props } | ||
> | ||
<LinkViewerUrl url={ url } urlLabel={ urlLabel } className={ linkClassName } /> | ||
{ onEditLinkClick && <IconButton icon="edit" label={ __( 'Edit' ) } onClick={ onEditLinkClick } /> } | ||
</div> | ||
); | ||
} |
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