diff --git a/packages/customize-widgets/src/components/keyboard-shortcut-help-modal/config.js b/packages/customize-widgets/src/components/keyboard-shortcut-help-modal/config.js index bd8bb53f5453d..4edf46204c75a 100644 --- a/packages/customize-widgets/src/components/keyboard-shortcut-help-modal/config.js +++ b/packages/customize-widgets/src/components/keyboard-shortcut-help-modal/config.js @@ -46,4 +46,8 @@ export const textFormattingShortcuts = [ 'Convert the current paragraph or heading to a heading of level 1 to 6.' ), }, + { + keyCombination: { modifier: 'primaryShift', character: 'SPACE' }, + description: __( 'Add non breaking space.' ), + }, ]; diff --git a/packages/edit-post/src/components/keyboard-shortcut-help-modal/config.js b/packages/edit-post/src/components/keyboard-shortcut-help-modal/config.js index bd8bb53f5453d..a206fa6c71d77 100644 --- a/packages/edit-post/src/components/keyboard-shortcut-help-modal/config.js +++ b/packages/edit-post/src/components/keyboard-shortcut-help-modal/config.js @@ -46,4 +46,8 @@ export const textFormattingShortcuts = [ 'Convert the current paragraph or heading to a heading of level 1 to 6.' ), }, + { + keyCombination: { modifier: 'primaryShift', character: '\u00a0' }, + description: __( 'Add non breaking space.' ), + }, ]; diff --git a/packages/edit-site/src/components/keyboard-shortcut-help-modal/config.js b/packages/edit-site/src/components/keyboard-shortcut-help-modal/config.js index bd8bb53f5453d..4edf46204c75a 100644 --- a/packages/edit-site/src/components/keyboard-shortcut-help-modal/config.js +++ b/packages/edit-site/src/components/keyboard-shortcut-help-modal/config.js @@ -46,4 +46,8 @@ export const textFormattingShortcuts = [ 'Convert the current paragraph or heading to a heading of level 1 to 6.' ), }, + { + keyCombination: { modifier: 'primaryShift', character: 'SPACE' }, + description: __( 'Add non breaking space.' ), + }, ]; diff --git a/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js b/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js index bd8bb53f5453d..4edf46204c75a 100644 --- a/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js +++ b/packages/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js @@ -46,4 +46,8 @@ export const textFormattingShortcuts = [ 'Convert the current paragraph or heading to a heading of level 1 to 6.' ), }, + { + keyCombination: { modifier: 'primaryShift', character: 'SPACE' }, + description: __( 'Add non breaking space.' ), + }, ]; diff --git a/packages/format-library/src/default-formats.js b/packages/format-library/src/default-formats.js index c94c347156ff0..3ccfc92cb40c1 100644 --- a/packages/format-library/src/default-formats.js +++ b/packages/format-library/src/default-formats.js @@ -14,6 +14,7 @@ import { superscript } from './superscript'; import { keyboard } from './keyboard'; import { unknown } from './unknown'; import { language } from './language'; +import { nonBreakingSpace } from './non-breaking-space'; export default [ bold, @@ -29,4 +30,5 @@ export default [ keyboard, unknown, language, + nonBreakingSpace, ]; diff --git a/packages/format-library/src/non-breaking-space/index.js b/packages/format-library/src/non-breaking-space/index.js new file mode 100644 index 0000000000000..829b0960f28a9 --- /dev/null +++ b/packages/format-library/src/non-breaking-space/index.js @@ -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 ( + + ); + }, +};