1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.settings = exports.name = void 0;
|
7 |
|
8 | var _element = require("@wordpress/element");
|
9 |
|
10 | var _autop = require("@wordpress/autop");
|
11 |
|
12 | var _i18n = require("@wordpress/i18n");
|
13 |
|
14 | var _components = require("@wordpress/components");
|
15 |
|
16 | var _blockEditor = require("@wordpress/block-editor");
|
17 |
|
18 | var _compose = require("@wordpress/compose");
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var name = 'core/shortcode';
|
24 | exports.name = name;
|
25 | var settings = {
|
26 | title: (0, _i18n.__)('Shortcode'),
|
27 | description: (0, _i18n.__)('Insert additional custom elements with a WordPress shortcode.'),
|
28 | icon: (0, _element.createElement)(_components.SVG, {
|
29 | viewBox: "0 0 24 24",
|
30 | xmlns: "http://www.w3.org/2000/svg"
|
31 | }, (0, _element.createElement)(_components.Path, {
|
32 | d: "M8.5,21.4l1.9,0.5l5.2-19.3l-1.9-0.5L8.5,21.4z M3,19h4v-2H5V7h2V5H3V19z M17,5v2h2v10h-2v2h4V5H17z"
|
33 | })),
|
34 | category: 'widgets',
|
35 | attributes: {
|
36 | text: {
|
37 | type: 'string',
|
38 | source: 'html'
|
39 | }
|
40 | },
|
41 | transforms: {
|
42 | from: [{
|
43 | type: 'shortcode',
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | tag: '[a-z][a-z0-9_-]*',
|
52 | attributes: {
|
53 | text: {
|
54 | type: 'string',
|
55 | shortcode: function shortcode(attrs, _ref) {
|
56 | var content = _ref.content;
|
57 | return (0, _autop.removep)((0, _autop.autop)(content));
|
58 | }
|
59 | }
|
60 | },
|
61 | priority: 20
|
62 | }]
|
63 | },
|
64 | supports: {
|
65 | customClassName: false,
|
66 | className: false,
|
67 | html: false
|
68 | },
|
69 | edit: (0, _compose.withInstanceId)(function (_ref2) {
|
70 | var attributes = _ref2.attributes,
|
71 | setAttributes = _ref2.setAttributes,
|
72 | instanceId = _ref2.instanceId;
|
73 | var inputId = "blocks-shortcode-input-".concat(instanceId);
|
74 | return (0, _element.createElement)("div", {
|
75 | className: "wp-block-shortcode"
|
76 | }, (0, _element.createElement)("label", {
|
77 | htmlFor: inputId
|
78 | }, (0, _element.createElement)(_components.Dashicon, {
|
79 | icon: "shortcode"
|
80 | }), (0, _i18n.__)('Shortcode')), (0, _element.createElement)(_blockEditor.PlainText, {
|
81 | className: "input-control",
|
82 | id: inputId,
|
83 | value: attributes.text,
|
84 | placeholder: (0, _i18n.__)('Write shortcode here…'),
|
85 | onChange: function onChange(text) {
|
86 | return setAttributes({
|
87 | text: text
|
88 | });
|
89 | }
|
90 | }));
|
91 | }),
|
92 | save: function save(_ref3) {
|
93 | var attributes = _ref3.attributes;
|
94 | return (0, _element.createElement)(_element.RawHTML, null, attributes.text);
|
95 | }
|
96 | };
|
97 | exports.settings = settings;
|
98 |
|
\ | No newline at end of file |