Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich text formatting filter #6642

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@wordpress/components';
import { ESCAPE, LEFT, RIGHT, UP, DOWN, BACKSPACE, ENTER, displayShortcut } from '@wordpress/keycodes';
import { prependHTTP } from '@wordpress/url';
import { applyFilters } from '@wordpress/hooks';

/**
* Internal dependencies
Expand All @@ -22,7 +23,7 @@ import PositionedAtSelection from './positioned-at-selection';
import URLInput from '../../url-input';
import { filterURLForDisplay } from '../../../utils/url';

const FORMATTING_CONTROLS = [
const getFormattingControls = () => applyFilters( 'editor.RichText.formattingControls', [
{
icon: 'editor-bold',
title: __( 'Bold' ),
Expand All @@ -47,7 +48,7 @@ const FORMATTING_CONTROLS = [
shortcut: displayShortcut.access( 'd' ),
format: 'strikethrough',
},
];
] );

// Default controls shown if no `enabledControls` prop provided
const DEFAULT_CONTROLS = [ 'bold', 'italic', 'strikethrough', 'link' ];
Expand Down Expand Up @@ -180,7 +181,7 @@ class FormatToolbar extends Component {
const { linkValue, settingsVisible, opensInNewWindow } = this.state;
const isAddingLink = formats.link && formats.link.isAdding;

const toolbarControls = FORMATTING_CONTROLS.concat( customControls )
const toolbarControls = getFormattingControls().concat( customControls )
.filter( ( control ) => enabledControls.indexOf( control.format ) !== -1 )
.map( ( control ) => {
if ( control.format === 'link' ) {
Expand Down