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

Format API #10209

Merged
merged 28 commits into from Oct 26, 2018
Merged

Format API #10209

Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
944d971
Formatting API
ellatrix Oct 12, 2018
578b5e5
Fix image test
ellatrix Oct 12, 2018
a995887
WIP: create format lib
ellatrix Oct 13, 2018
636cd2f
Adjust internal value to use format attributes and name instead of el…
ellatrix Oct 15, 2018
321402d
Add activeAttributes prop
ellatrix Oct 15, 2018
ac81865
Add FillToolbarSlot and Shortcut
ellatrix Oct 15, 2018
449c789
Editor: Add keyboard shortcuts support for formatters
gziolo Oct 16, 2018
dee3216
Fix rebase error
ellatrix Oct 22, 2018
05b4e58
Fix shortcuts
ellatrix Oct 22, 2018
9b6665f
Remove registerCoreFormats
ellatrix Oct 22, 2018
5b533c7
Address feedback
ellatrix Oct 22, 2018
0aef345
Simplify filling slots
ellatrix Oct 22, 2018
ebb6604
Fix typos
ellatrix Oct 22, 2018
ba72e44
Fix inserter, move url function
ellatrix Oct 23, 2018
e9e3530
Fix rebase error
ellatrix Oct 23, 2018
b489b38
Enqueue format library styles
ellatrix Oct 23, 2018
69c1da4
Fix formatting on collapsed selection
ellatrix Oct 23, 2018
acb1ac1
Remove Token API
ellatrix Oct 23, 2018
6587b97
Remove obsolete RichText.Siblings slot
ellatrix Oct 23, 2018
56ed177
Remove all style imports
ellatrix Oct 24, 2018
a5f2f9a
Fix after rebase
ellatrix Oct 24, 2018
63e96ff
Fix dependency issue
ellatrix Oct 24, 2018
c2c9889
Use stable key for list of blocks in the inserter
gziolo Oct 25, 2018
b6dde3e
Fix Eslint issue for unsuded lodash method
gziolo Oct 25, 2018
f2b1fc9
Move Inline Elements to its own component
gziolo Oct 25, 2018
6ac8887
Import rich-text store only in the entry point (follow other modules)
gziolo Oct 25, 2018
35d017d
Rich Text: Expose unregister format type method
gziolo Oct 25, 2018
7fd020f
Don't use index for React element keys
ellatrix Oct 26, 2018
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+26 −15
Diff settings

Always

Just for now

Fix after rebase

  • Loading branch information...
ellatrix committed Oct 24, 2018
commit a5f2f9ae3e9a76c2e7c8bddb415f23505a6c5671
@@ -3,6 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { Component, Fragment } from '@wordpress/element';
import { withSpokenMessages } from '@wordpress/components';
import {
getTextContent,
applyFormat,
@@ -28,12 +29,13 @@ export const link = {
url: 'href',

This comment has been minimized.

Copy link
@aduth

aduth Oct 25, 2018

Member

For what purpose do we support attributes defined as a mapping. Do we not want the implementation of the edit to be forced to consider them as proper attributes of the element? What other meaning could they adopt, or do we support / intend to support non-attribute-sourced attributes?

i.e. Why is this not attributes: [ 'href', 'target' ],

This comment has been minimized.

Copy link
@ellatrix

ellatrix Oct 26, 2018

Author Member

I thought this is something that could change it the future, so I went for the map. Maybe an attribute could be sourced from part, or several, element attributes, and maybe in the future we'll support more complex objects.

This comment has been minimized.

Copy link
@aduth

aduth Oct 26, 2018

Member

For what purpose do we support attributes defined as a mapping.

I thought this is something that could change it the future, so I went for the map. Maybe an attribute could be sourced from part, or several, element attributes, and maybe in the future we'll support more complex objects.

Well, that was the sort of thing I'd first expected when looking at this, since it appears to mimic the block API for attributes. But what we have here seems more like a confusing middle ground. Why not just have the full verbose attribute definition which matches completely the expectation of the block API? Or, if that's not intended to be supported yet, have the simpler array alternative as the short-term available option, since it's not incompatible with such a future proposed enhancement.

This comment has been minimized.

Copy link
@ellatrix

ellatrix Oct 26, 2018

Author Member

That’s, fine with me as well. I’ll make a separate or for it

target: 'target',
},
edit: class LinkEdit extends Component {
edit: withSpokenMessages( class LinkEdit extends Component {
constructor() {
super( ...arguments );

this.addLink = this.addLink.bind( this );
this.stopAddingLink = this.stopAddingLink.bind( this );
this.onRemoveFormat = this.onRemoveFormat.bind( this );
this.state = {
addingLink: false,
};
@@ -54,39 +56,50 @@ export const link = {
this.setState( { addingLink: false } );
}

onRemoveFormat() {
const { value, onChange, speak } = this.props;

onChange( removeFormat( value, name ) );
speak( __( 'Link removed.' ), 'assertive' );
}

render() {
const { isActive, activeAttributes, value, onChange, ToolbarButton, Shortcut } = this.props;
const onRemoveFormat = () => onChange( removeFormat( value, name ) );

return (
<Fragment>
<Shortcut
type="access"
character="s"
onUse={ onRemoveFormat }
character="a"
onUse={ this.addLink }
/>
<Shortcut
type="access"
character="a"
onUse={ () => this.addLink() }
character="s"
onUse={ this.onRemoveFormat }
/>
<Shortcut
type="primary"
character="k"
onUse={ () => this.addLink() }
onUse={ this.addLink }
/>
<Shortcut
type="primaryShift"
character="k"
onUse={ this.onRemoveFormat }
/>
{ isActive && <ToolbarButton
name="link"
icon="editor-unlink"
title={ __( 'Unlink' ) }
onClick={ onRemoveFormat }
onClick={ this.onRemoveFormat }
isActive={ isActive }
/> }
{ ! isActive && <ToolbarButton
name="link"
icon="admin-links"
title={ __( 'Link' ) }
onClick={ () => this.addLink() }
onClick={ this.addLink }
isActive={ isActive }
/> }
<InlineLinkUI
@@ -100,5 +113,5 @@ export const link = {
</Fragment>
);
}
},
} ),
};
@@ -163,13 +163,11 @@ class InlineLinkUI extends Component {
onChange( applyFormat( value, format ) );
}

if ( this.state.editLink ) {
this.props.speak( __( 'Link edited.' ), 'assertive' );
}

this.resetState();

if ( ! isActive ) {
if ( isActive ) {
speak( __( 'Link edited.' ), 'assertive' );
} else {
speak( __( 'Link added.' ), 'assertive' );
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.