Skip to content

Commit 0f53bd7

Browse files
committed
Add insert menu separators
1 parent 30b697d commit 0f53bd7

5 files changed

Lines changed: 39 additions & 11 deletions

File tree

tinymce-single/blocks/core/gallery/register.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ window.wp.blocks.registerBlock( {
22
name: 'gallery',
33
namespace: 'core',
44
displayName: 'Gallery',
5-
type: 'image',
5+
type: 'media',
66
keywords: [],
77
icon: 'gridicons-image-multiple',
88
controls: [

tinymce-single/blocks/core/image/register.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ window.wp.blocks.registerBlock( {
22
name: 'image',
33
namespace: 'core',
44
displayName: 'Image',
5-
type: 'image',
5+
type: 'media',
66
icon: 'gridicons-image',
77
controls: [
88
'block-align-left',

tinymce-single/blocks/my-awesome-plugin/youtube/register.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ window.wp.blocks.registerBlock( {
22
name: 'youtube',
33
namespace: 'my-awesome-plugin',
44
displayName: 'YouTube Video',
5-
type: 'video',
5+
type: 'media',
66
keywords: [],
77
icon: 'gridicons-video',
88
controls: [

tinymce-single/tinymce/block.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ div.mce-inline-toolbar-grp.block-toolbar > div.mce-stack-layout {
259259
float: left;
260260
}
261261

262+
.insert-menu .insert-separator {
263+
clear: both;
264+
background: #f0f2f4;
265+
padding: 4px;
266+
text-transform: uppercase;
267+
}
268+
262269
.insert-menu .mce-txt {
263270
font-size: 16px;
264271
text-align: inherit;
@@ -268,3 +275,7 @@ div.mce-inline-toolbar-grp.block-toolbar > div.mce-stack-layout {
268275
width: 120px;
269276
padding: 4px;
270277
}
278+
279+
.insert-menu .mce-btn-has-text svg.gridicons-heading {
280+
margin: 0;
281+
}

tinymce-single/tinymce/block.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,21 +258,38 @@
258258
return insert;
259259
}
260260

261+
window.tinymce.ui.WPInsertSeparator = tinymce.ui.Control.extend( {
262+
renderHtml: function() {
263+
console.log(this)
264+
return (
265+
'<div id="' + this._id + '" class="insert-separator">' + this.settings.text + '</div>'
266+
);
267+
}
268+
} );
269+
261270
function createInsertMenu() {
262271
var insertMenu = editor.wp._createToolbar( ( function() {
263272
var allSettings = wp.blocks.getBlocks();
264273
var buttons = [];
265274
var key;
275+
var types = [ 'text', 'media', 'separator' ];
276+
277+
types.forEach( function( type ) {
278+
buttons.push( {
279+
type: 'WPInsertSeparator',
280+
text: type
281+
} );
266282

267-
for ( key in allSettings ) {
268-
if ( allSettings[ key ].insert ) {
269-
buttons.push( {
270-
text: allSettings[ key ].displayName,
271-
icon: allSettings[ key ].icon,
272-
onClick: allSettings[ key ].insert
273-
} );
283+
for ( key in allSettings ) {
284+
if ( allSettings[ key ].type === type ) {
285+
buttons.push( {
286+
text: allSettings[ key ].displayName,
287+
icon: allSettings[ key ].icon,
288+
onClick: allSettings[ key ].insert
289+
} );
290+
}
274291
}
275-
}
292+
} );
276293

277294
return buttons;
278295
} )() );

0 commit comments

Comments
 (0)