Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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' );
}
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' );
}
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' );
}
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');
}
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');
}
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');
}
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');
}
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useCallback, useState, useRef } from '@wordpress/element';
import { createHigherOrderComponent, useKeyboardShortcut } from '@wordpress/compose';
import { rawShortcut } from '@wordpress/keycodes';
const defaultShortcuts = {
previous: [ 'ctrl+shift+`', rawShortcut.access( 'p' ) ],
next: [ 'ctrl+`', rawShortcut.access( 'n' ) ],
};
export default createHigherOrderComponent(
( WrappedComponent ) => {
return ( { shortcuts = defaultShortcuts, ...props } ) => {
const container = useRef();
const [ isFocusingRegions, setIsFocusingRegions ] = useState( false );
const className = classnames( 'components-navigate-regions', {
'is-focusing-regions': isFocusingRegions,
} );
function focusRegion( offset ) {
const regions = Array.from( container.current.querySelectorAll( '[role="region"]' ) );
if ( ! regions.length ) {
return;
renderToggle={ ( { isOpen, onToggle } ) => (
<>
{ isEnabled &&
}
<button aria-disabled="{" label="{" aria-expanded="{">
) }
renderContent={ ( { onClose } ) => (</button>
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useCallback, useState, useRef } from '@wordpress/element';
import { createHigherOrderComponent, useKeyboardShortcut } from '@wordpress/compose';
import { rawShortcut } from '@wordpress/keycodes';
const defaultShortcuts = {
previous: [ 'ctrl+shift+`', rawShortcut.access( 'p' ) ],
next: [ 'ctrl+`', rawShortcut.access( 'n' ) ],
};
export default createHigherOrderComponent(
( WrappedComponent ) => {
return ( { shortcuts = defaultShortcuts, ...props } ) => {
const container = useRef();
const [ isFocusingRegions, setIsFocusingRegions ] = useState( false );
const className = classnames( 'components-navigate-regions', {
'is-focusing-regions': isFocusingRegions,
} );
function focusRegion( offset ) {
const regions = Array.from( container.current.querySelectorAll( '[role="region"]' ) );
if ( ! regions.length ) {
return;
}