-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock.js
57 lines (51 loc) · 1.37 KB
/
block.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* BLOCK: Basic
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*
* Styles:
* editor.css — Editor styles for the block.
* style.css — Editor & Front end styles for the block.
*/
( function() {
var el = wp.element.createElement;
var registerBlockType = wp.blocks.registerBlockType;
registerBlockType( 'shin1kt/nyanko', { //任意の名前 プリフィックス的
title: 'nyanko', // ブロック名
icon: function(){
//ブロックアイコン imgタグとかでもOK
return el(
'img',
{src: mywp.plugin_url + '/neko-icon.svg',class:'nyanko-icon'}
);
},
category: 'common',//ブロックのカテゴリ
edit: function( props ) {
//エディタ画面で挿入される要素
return el(
'div',
{
class: 'nyan-block',
},
React.createElement('div', {class:'nyan-ballon'},
React.createElement('p', {},'にゃーん')
),
React.createElement('img', {src: mywp.plugin_url + '/neko.svg'})
);
},
save: function( props ) {
//表示側でのHTML要素
return el(
'div',
{
class: 'nyan-block',
},
React.createElement('div', {class:'nyan-ballon'},
React.createElement('p', {},'にゃーん')
),
React.createElement('img', {src: mywp.plugin_url + '/neko.svg'})
);
},
} );
})();