Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c3f6fb5
Added table block
tiny-james May 3, 2017
2c1fab0
Merge branch 'master' into add/147-table-block
tiny-james May 4, 2017
7eda289
Some exploratory work to see if table functions can be called
tiny-james May 4, 2017
f0fc3cf
Merge branch 'master' into add/147-table-block
tiny-james May 10, 2017
462528f
Pass out the editor on setup and use it for execCommand
tiny-james May 22, 2017
5bc3a62
Renamed table to table2 to avoid collision on merge
tiny-james May 22, 2017
5d8bec7
Merge branch 'master' into add/147-table-block
tiny-james May 22, 2017
172eb3d
Add table plugin via getSettings; fix linter issues
tiny-james May 22, 2017
fbaf6a9
Added temporary icons
tiny-james May 22, 2017
6347878
Added css to show table selection
tiny-james May 22, 2017
55c999a
Merge branch 'master' into add/147-table-block
tiny-james May 22, 2017
e591c31
Moved controls into a menu
tiny-james May 23, 2017
7af4bba
Changed the icon used by the menu
tiny-james May 23, 2017
4f8c24c
Merge branch 'master' into add/147-table-block
androb May 23, 2017
3ec4f0b
Merge branch 'master' into add/147-table-block
tiny-james May 23, 2017
183bb4d
Added the alignment modes and matched the styling of the existing table
tiny-james May 24, 2017
10d42e1
Merge remote-tracking branch 'origin/add/147-table-block' into add/14…
androb May 24, 2017
a1826f6
Merge branch 'master' into add/147-table-block
tiny-james May 26, 2017
6d1ba0f
Added serialization test
tiny-james May 26, 2017
c02da21
Merge branch 'master' into add/147-table-block
tiny-james May 30, 2017
97c3e9d
Merge branch 'master' into add/147-table-block
tiny-james May 31, 2017
e60070b
Moved the editor object into react component private state
tiny-james May 31, 2017
9a1ef91
Fixed unused import
tiny-james May 31, 2017
3ec9506
Fixed spaces used for indenting in toolbar-menu/style.scss
tiny-james May 31, 2017
bd1a183
Move alternate table block to formatting category to match existing t…
tiny-james Jun 1, 2017
ed2d5a5
Vendor the table plugin
tiny-james Jun 1, 2017
e4871d3
Removed class and style attributes from table
tiny-james Jun 1, 2017
2249999
Merge branch 'master' into add/147-table-block
tiny-james Jun 1, 2017
a15a781
Fixed spaces in indentation of table2/style.scss
tiny-james Jun 1, 2017
95c353d
Removed the comments with the unscaled SVG paths
tiny-james Jun 1, 2017
d01937b
Merge branch 'master' into add/147-table-block
tiny-james Jun 1, 2017
7b08fa1
Updated for rename of registerBlock to registerBlockType
tiny-james Jun 2, 2017
f067183
Merge branch 'master' into add/147-table-block
tiny-james Jun 26, 2017
be1791b
Fixed use of now removed title variable in dashicons
tiny-james Jun 26, 2017
2f6d3e4
Readded block alignment toolbar
tiny-james Jun 26, 2017
9d62f49
Used block controls rather than specialized block menu
tiny-james Jun 26, 2017
6d87fcd
Fix php lint error
tiny-james Jun 26, 2017
3494440
Updated table 2 serialization tests
tiny-james Jun 26, 2017
27b6f01
Removed some dead code and moved the alignment toolbar to the index
tiny-james Jun 26, 2017
13fdec5
Merge branch 'master' into add/147-table-block
tiny-james Jun 27, 2017
45ea9ac
Navigate the toolbar menu with key events.
tiny-james Jun 27, 2017
fc27514
Renamed to TinyMCE Table
tiny-james Jun 27, 2017
e9db8b7
Merge branch 'master' into add/147-table-block
tiny-james Jun 28, 2017
79808f6
Merge branch 'master' into add/147-table-block
tiny-james Jun 30, 2017
0404c87
Restyled toolbar menu and improved keyboard behaviour.
tiny-james Jun 30, 2017
07c5262
Merge branch 'master' into add/147-table-block
tiny-james Jun 30, 2017
b9cdc9d
Updated table2 serialization tests to match new naming scheme
tiny-james Jun 30, 2017
0cb4cf5
Added className prop to table
tiny-james Jul 3, 2017
fca185c
Merge branch 'master' into add/147-table-block
tiny-james Jul 3, 2017
dc0dfcf
Moved table styling into .wp-block-table-2 class
tiny-james Jul 3, 2017
9daaef9
Change ToolbarMenu so it can be a subcomponent of a toolbar.
tiny-james Jul 3, 2017
c133e8e
Renamed ToolbarMenu to DropdownMenu
tiny-james Jul 3, 2017
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
Prev Previous commit
Next Next commit
Pass out the editor on setup and use it for execCommand
  • Loading branch information
tiny-james committed May 22, 2017
commit 462528f7a6ad86cb7797a1a9d4ef982c9fa6b193
4 changes: 4 additions & 0 deletions blocks/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export default class Editable extends wp.element.Component {
editor.on( 'focusin', this.onFocus );
editor.on( 'nodechange', this.onNodeChange );
editor.on( 'keydown', this.onKeyDown );

if ( this.props.onSetup ) {
this.props.onSetup( editor );
}
}

onInit() {
Expand Down
1 change: 1 addition & 0 deletions blocks/editable/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class TinyMCE extends wp.element.Component {
browser_spellcheck: true,
entity_encoding: 'raw',
convert_urls: false,
plugins: [ 'table' ],
setup: ( editor ) => {
this.editor = editor;
this.props.onSetup( editor );
Expand Down
60 changes: 41 additions & 19 deletions blocks/library/table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
* Internal dependencies
*/
import './style.scss';
import { registerBlock, query as hpq } from 'api';
import Editable from 'components/editable';
import { registerBlock, query as hpq } from '../../api';
import Editable from '../../editable';

const { children, prop } = hpq;

let editable = null;

function execCommand( commandId ) {
const editorNode = editable !== null ? editable.editorNode : null;
const editor = tinymce.editors.find( ( e ) => e.targetElm === editorNode );
editor.execCommand( commandId, false, editor );
function execCommand( command ) {
return ( { editor } ) => {
if ( editor ) {
editor.execCommand( command );
}
};
}

registerBlock( 'core/table', {
Expand All @@ -27,30 +27,52 @@ registerBlock( 'core/table', {

controls: [
{
icon: 'editor-table',
icon: 'table-row-before',
title: wp.i18n.__( 'Insert Row Before' ),
isActive: () => false, //TODO
onClick() {
execCommand( 'mceTableInsertRowBefore', false );
}
isActive: () => false,
onClick: execCommand( 'mceTableInsertRowBefore' )
},
{
icon: 'editor-table',
icon: 'table-row-after',
title: wp.i18n.__( 'Insert Row After' ),
isActive: () => false, //TODO
onClick() {
execCommand( 'mceTableInsertRowAfter', false );
}
isActive: () => false,
onClick: execCommand( 'mceTableInsertRowAfter' )
},
{
icon: 'table-row-delete',
title: wp.i18n.__( 'Delete Row' ),
isActive: () => false,
onClick: execCommand( 'mceTableDeleteRow' )
},
{
icon: 'table-col-before',
title: wp.i18n.__( 'Insert Column Before' ),
isActive: () => false,
onClick: execCommand( 'mceTableInsertColBefore' )
},
{
icon: 'table-col-after',
title: wp.i18n.__( 'Insert Column After' ),
isActive: () => false,
onClick: execCommand( 'mceTableInsertColAfter' )
},
{
icon: 'table-col-delete',
title: wp.i18n.__( 'Delete Column' ),
isActive: () => false,
onClick: execCommand( 'mceTableDeleteCol' )
},
],

edit( { attributes, setAttributes, focus, setFocus } ) {
const { nodeName = 'TABLE', rows = [ <tr key="1"><td><br /></td><td><br /></td></tr>, <tr key="2"><td><br /></td><td><br /></td></tr> ] } = attributes;
return (
<Editable
ref={ ( e ) => editable = e }
tagName={ nodeName.toLowerCase() }
style={ { width: '100%' } }
onSetup={ ( nextEditor ) => {
setAttributes( { editor: nextEditor } );
} }
onChange={ ( nextRows ) => {
setAttributes( { rows: nextRows } );
} }
Expand Down