How to use the @wordpress/keycodes.rawShortcut.primaryShift function in @wordpress/keycodes

To help you get started, we’ve selected a few @wordpress/keycodes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / editor / components / rich-text / index.js View on Github external
onInit() {
		this.registerCustomFormatters();

		this.editor.shortcuts.add( rawShortcut.primary( 'k' ), '', () => this.changeFormats( { link: { isAdding: true } } ) );
		this.editor.shortcuts.add( rawShortcut.access( 'a' ), '', () => this.changeFormats( { link: { isAdding: true } } ) );
		this.editor.shortcuts.add( rawShortcut.access( 's' ), '', () => this.changeFormats( { link: undefined } ) );
		this.editor.shortcuts.add( rawShortcut.access( 'd' ), '', () => this.changeFormats( { strikethrough: ! this.state.formats.strikethrough } ) );
		this.editor.shortcuts.add( rawShortcut.access( 'x' ), '', () => this.changeFormats( { code: ! this.state.formats.code } ) );
		this.editor.shortcuts.add( rawShortcut.primary( 'z' ), '', 'Undo' );
		this.editor.shortcuts.add( rawShortcut.primaryShift( 'z' ), '', 'Redo' );

		// Remove TinyMCE Core shortcut for consistency with global editor
		// shortcuts. Also clashes with Mac browsers.
		this.editor.shortcuts.remove( 'meta+y', '', 'Redo' );
	}
github front / gutenberg-js / src / js / gutenberg-overrides / packages / editor / build-module / components / rich-text / index.js View on Github external
onInit () {
    this.registerCustomFormatters();

    this.editor.shortcuts.add(rawShortcut.primary('k'), '', () => this.changeFormats({ link: { isAdding: true } }));
    this.editor.shortcuts.add(rawShortcut.access('a'), '', () => this.changeFormats({ link: { isAdding: true } }));
    this.editor.shortcuts.add(rawShortcut.access('s'), '', () => this.changeFormats({ link: undefined }));
    this.editor.shortcuts.add(rawShortcut.access('d'), '', () => this.changeFormats({ strikethrough: ! this.state.formats.strikethrough }));
    this.editor.shortcuts.add(rawShortcut.access('x'), '', () => this.changeFormats({ code: ! this.state.formats.code }));
    this.editor.shortcuts.add(rawShortcut.primary('z'), '', 'Undo');
    this.editor.shortcuts.add(rawShortcut.primaryShift('z'), '', 'Redo');

    // Remove TinyMCE Core shortcut for consistency with global editor
    // shortcuts. Also clashes with Mac browsers.
    this.editor.shortcuts.remove('meta+y', '', 'Redo');
  }
github WordPress / gutenberg / packages / edit-post / src / keyboard-shortcuts.js View on Github external
/**
 * WordPress dependencies
 */
import { rawShortcut, displayShortcut, shortcutAriaLabel } from '@wordpress/keycodes';

export default {
	toggleEditorMode: {
		raw: rawShortcut.secondary( 'm' ),
		display: displayShortcut.secondary( 'm' ),
	},
	toggleSidebar: {
		raw: rawShortcut.primaryShift( ',' ),
		display: displayShortcut.primaryShift( ',' ),
		ariaLabel: shortcutAriaLabel.primaryShift( ',' ),
	},
};
github WordPress / gutenberg / packages / editor / src / components / block-settings-menu / index.js View on Github external
import BlockModeToggle from './block-mode-toggle';
import ReusableBlockConvertButton from './reusable-block-convert-button';
import ReusableBlockDeleteButton from './reusable-block-delete-button';
import BlockHTMLConvertButton from './block-html-convert-button';
import BlockUnknownConvertButton from './block-unknown-convert-button';
import _BlockSettingsMenuFirstItem from './block-settings-menu-first-item';
import _BlockSettingsMenuPluginsExtension from './block-settings-menu-plugins-extension';

const preventDefault = ( event ) => {
	event.preventDefault();
	return event;
};

const shortcuts = {
	duplicate: {
		raw: rawShortcut.primaryShift( 'd' ),
		display: displayShortcut.primaryShift( 'd' ),
	},
	removeBlock: {
		raw: rawShortcut.primaryShift( 'x' ),
		display: displayShortcut.primaryShift( 'x' ),
	},
	insertBefore: {
		raw: rawShortcut.primaryAlt( 't' ),
		display: displayShortcut.primaryAlt( 't' ),
	},
	insertAfter: {
		raw: rawShortcut.primaryAlt( 'y' ),
		display: displayShortcut.primaryAlt( 'y' ),
	},
};
github WordPress / gutenberg / packages / block-editor / src / components / rich-text / remove-browser-shortcuts.js View on Github external
import { fromPairs } from 'lodash';

/**
 * WordPress dependencies
 */
import { rawShortcut } from '@wordpress/keycodes';
import { KeyboardShortcuts } from '@wordpress/components';

/**
 * Set of keyboard shortcuts handled internally by RichText.
 *
 * @type {Array}
 */
const HANDLED_SHORTCUTS = [
	rawShortcut.primary( 'z' ),
	rawShortcut.primaryShift( 'z' ),
	rawShortcut.primary( 'y' ),
];

/**
 * An instance of a KeyboardShortcuts element pre-bound for the handled
 * shortcuts. Since shortcuts never change, the element can be considered
 * static, and can be skipped in reconciliation.
 *
 * @type {WPElement}
 */
const SHORTCUTS_ELEMENT = (
	 {
			return [ shortcut, ( event ) => event.preventDefault() ];
		} ) ) }
github WordPress / gutenberg / packages / editor / src / components / block-settings-menu / index.js View on Github external
import BlockUnknownConvertButton from './block-unknown-convert-button';
import _BlockSettingsMenuFirstItem from './block-settings-menu-first-item';
import _BlockSettingsMenuPluginsExtension from './block-settings-menu-plugins-extension';

const preventDefault = ( event ) => {
	event.preventDefault();
	return event;
};

const shortcuts = {
	duplicate: {
		raw: rawShortcut.primaryShift( 'd' ),
		display: displayShortcut.primaryShift( 'd' ),
	},
	removeBlock: {
		raw: rawShortcut.primaryShift( 'x' ),
		display: displayShortcut.primaryShift( 'x' ),
	},
	insertBefore: {
		raw: rawShortcut.primaryAlt( 't' ),
		display: displayShortcut.primaryAlt( 't' ),
	},
	insertAfter: {
		raw: rawShortcut.primaryAlt( 'y' ),
		display: displayShortcut.primaryAlt( 'y' ),
	},
};

export class BlockSettingsMenu extends Component {
	constructor() {
		super( ...arguments );
		this.state = {