PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
wpforo / blocks / search / index.js

index.js in wpForo Forum 3.1.6, at blocks/search/index.js

64 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function (blocks, editor, components, i18n, element) {
2 var el = element.createElement;
3 var Fragment = element.Fragment;
4 var __ = i18n.__;
5 var InspectorControls = editor.InspectorControls;
6 var useBlockProps = editor.useBlockProps;
7 var PanelBody = components.PanelBody;
8 var TextControl = components.TextControl;
9 var SelectControl = components.SelectControl;
10
11 blocks.registerBlockType('wpforo/search', {
12 title: __('wpForo Search', 'wpforo'),
13 icon: 'search',
14 category: 'widgets',
15 edit: function (props) {
16 var attributes = props.attributes;
17 var setAttributes = props.setAttributes;
18 var blockProps = useBlockProps();
19
20 var boards = window.wpforo_block_data ? window.wpforo_block_data.boards : [];
21 var options = boards.map(function (board) {
22 return { value: board.boardid, label: board.title };
23 });
24
25 return el(Fragment, null,
26 el(InspectorControls, { key: 'inspector' },
27 el(PanelBody, { title: __('Settings', 'wpforo') },
28 el(TextControl, {
29 label: __('Title', 'wpforo'),
30 value: attributes.title,
31 onChange: function (value) {
32 setAttributes({ title: value });
33 },
34 }),
35 el(SelectControl, {
36 label: __('Board', 'wpforo'),
37 value: attributes.boardid,
38 options: options,
39 onChange: function (value) {
40 setAttributes({ boardid: parseInt(value) });
41 },
42 }),
43 ),
44 ),
45 el('div', blockProps,
46 el('div', { className: 'wpf-block-placeholder' },
47 el('span', { className: 'dashicons dashicons-search' }),
48 __('wpForo Search', 'wpforo'),
49 ),
50 ),
51 );
52 },
53 save: function () {
54 return null;
55 },
56 });
57 })(
58 window.wp.blocks,
59 window.wp.blockEditor,
60 window.wp.components,
61 window.wp.i18n,
62 window.wp.element,
63 );
64