PluginProbe
Prismatic / 2.7
Prismatic v2.7
trunk 1.3 1.4 1.5 1.6 1.6.1 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.9.1 3.0 3.1 3.1.1 3.2 3.2.1 All 40 releases
prismatic / js / blocks-plain.js

blocks-plain.js in Prismatic 2.7, at js/blocks-plain.js

62 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* Prismatic - Plain Flavor Block */
2
3 var
4 el = wp.element.createElement,
5 registerBlockType = wp.blocks.registerBlockType,
6 PlainText = wp.editor.PlainText,
7 __ = wp.i18n.__;
8
9 registerBlockType('prismatic/blocks', {
10
11 title : 'Prismatic',
12 icon : 'editor-code',
13 category : 'formatting',
14 keywords : [
15 __('code', 'prismatic'),
16 __('pre', 'prismatic'),
17 __('prism', 'prismatic'),
18 __('highlight', 'prismatic'),
19 __('prismatic', 'prismatic')
20 ],
21 attributes : {
22 content : {
23 type : 'string',
24 source : 'text',
25 selector : 'pre code',
26 },
27 backgroundColor : {
28 type : 'string',
29 default : '#f7f7f7',
30 },
31 textColor : {
32 type : 'string',
33 default : '#373737',
34 },
35 },
36
37 edit : function(props) {
38
39 function onChangeContent(newValue) {
40 props.setAttributes({ content: newValue });
41 }
42
43 return el(
44 PlainText,
45 {
46 tagName : 'pre',
47 key : 'editable',
48 placeholder : __('Add code..', 'prismatic'),
49 onChange : onChangeContent,
50 className : props.className,
51 style : { backgroundColor : props.attributes.backgroundColor, color : props.attributes.textColor },
52 value : props.attributes.content,
53 }
54 );
55
56 },
57
58 save : function(props) {
59 return el('pre', null, el('code', null, props.attributes.content));
60 },
61
62 });