-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RichText: add non breaking space shortcut on Windows (#43150)
Unlinked contributors: rezeau, pierrefrance, burnuser, zackkatz. Co-authored-by: t-hamano <[email protected]> Co-authored-by: ellatrix <[email protected]> Co-authored-by: yankiara <[email protected]> Co-authored-by: tybor <[email protected]> Co-authored-by: fr-laurentn <[email protected]> Co-authored-by: TonyGravagno <[email protected]> Co-authored-by: noisysocks <[email protected]> Co-authored-by: benjaminpwarren <[email protected]>
- Loading branch information
1 parent
cef411c
commit 810e49d
Showing
6 changed files
with
47 additions
and
0 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
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
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,29 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { insert } from '@wordpress/rich-text'; | ||
import { RichTextShortcut } from '@wordpress/block-editor'; | ||
|
||
const name = 'core/non-breaking-space'; | ||
const title = __( 'Non breaking space' ); | ||
|
||
export const nonBreakingSpace = { | ||
name, | ||
title, | ||
tagName: 'nbsp', | ||
className: null, | ||
edit( { value, onChange } ) { | ||
function addNonBreakingSpace() { | ||
onChange( insert( value, '\u00a0' ) ); | ||
} | ||
|
||
return ( | ||
<RichTextShortcut | ||
type="primaryShift" | ||
character=" " | ||
onUse={ addNonBreakingSpace } | ||
/> | ||
); | ||
}, | ||
}; |