PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.2
Secure Custom Fields v6.4.2
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / assets / build / js / pro / acf-pro-blocks.js
secure-custom-fields / assets / build / js / pro Last commit date
acf-pro-blocks.js 1 year ago acf-pro-blocks.js.map 1 year ago acf-pro-blocks.min.js 1 year ago acf-pro-field-group.js 1 year ago acf-pro-field-group.js.map 1 year ago acf-pro-field-group.min.js 1 year ago acf-pro-input.js 1 year ago acf-pro-input.js.map 1 year ago acf-pro-input.min.js 1 year ago acf-pro-ui-options-page.js 1 year ago acf-pro-ui-options-page.js.map 1 year ago acf-pro-ui-options-page.min.js 1 year ago index.php 1 year ago
acf-pro-blocks.js
2586 lines
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/pro/_acf-blocks.js":
5 /*!******************************************!*\
6 !*** ./assets/src/js/pro/_acf-blocks.js ***!
7 \******************************************/
8 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9
10 function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
11 const md5 = __webpack_require__(/*! md5 */ "./node_modules/md5/md5.js");
12 (($, undefined) => {
13 // Dependencies.
14 const {
15 BlockControls,
16 InspectorControls,
17 InnerBlocks,
18 useBlockProps,
19 AlignmentToolbar,
20 BlockVerticalAlignmentToolbar
21 } = wp.blockEditor;
22 const {
23 ToolbarGroup,
24 ToolbarButton,
25 Placeholder,
26 Spinner
27 } = wp.components;
28 const {
29 Fragment
30 } = wp.element;
31 const {
32 Component
33 } = React;
34 const {
35 useSelect
36 } = wp.data;
37 const {
38 createHigherOrderComponent
39 } = wp.compose;
40
41 // Potentially experimental dependencies.
42 const BlockAlignmentMatrixToolbar = wp.blockEditor.__experimentalBlockAlignmentMatrixToolbar || wp.blockEditor.BlockAlignmentMatrixToolbar;
43 // Gutenberg v10.x begins transition from Toolbar components to Control components.
44 const BlockAlignmentMatrixControl = wp.blockEditor.__experimentalBlockAlignmentMatrixControl || wp.blockEditor.BlockAlignmentMatrixControl;
45 const BlockFullHeightAlignmentControl = wp.blockEditor.__experimentalBlockFullHeightAligmentControl || wp.blockEditor.__experimentalBlockFullHeightAlignmentControl || wp.blockEditor.BlockFullHeightAlignmentControl;
46 const useInnerBlocksProps = wp.blockEditor.__experimentalUseInnerBlocksProps || wp.blockEditor.useInnerBlocksProps;
47
48 /**
49 * Storage for registered block types.
50 *
51 * @since ACF 5.8.0
52 * @var object
53 */
54 const blockTypes = {};
55
56 /**
57 * Data storage for Block Instances and their DynamicHTML components.
58 * This is temporarily stored on the ACF object, but this will be replaced later.
59 * Developers should not rely on reading or using any aspect of acf.blockInstances.
60 *
61 * @since ACF 6.3
62 */
63 acf.blockInstances = {};
64
65 /**
66 * Returns a block type for the given name.
67 *
68 * @date 20/2/19
69 * @since ACF 5.8.0
70 *
71 * @param string name The block name.
72 * @return (object|false)
73 */
74 function getBlockType(name) {
75 return blockTypes[name] || false;
76 }
77
78 /**
79 * Returns a block version for a given block name
80 *
81 * @date 8/6/22
82 * @since ACF 6.0
83 *
84 * @param string name The block name
85 * @return int
86 */
87 function getBlockVersion(name) {
88 const blockType = getBlockType(name);
89 return blockType.acf_block_version || 1;
90 }
91
92 /**
93 * Returns a block's validate property. Default true.
94 *
95 * @since ACF 6.3
96 *
97 * @param string name The block name
98 * @return boolean
99 */
100 function blockSupportsValidation(name) {
101 const blockType = getBlockType(name);
102 return blockType.validate;
103 }
104
105 /**
106 * Returns true if a block (identified by client ID) is nested in a query loop block.
107 *
108 * @date 17/1/22
109 * @since ACF 5.12
110 *
111 * @param {string} clientId A block client ID
112 * @return boolean
113 */
114 function isBlockInQueryLoop(clientId) {
115 const parents = wp.data.select('core/block-editor').getBlockParents(clientId);
116 const parentsData = wp.data.select('core/block-editor').getBlocksByClientId(parents);
117 return parentsData.filter(block => block.name === 'core/query').length;
118 }
119
120 /**
121 * Returns true if we're currently inside the WP 5.9+ site editor.
122 *
123 * @date 08/02/22
124 * @since ACF 5.12
125 *
126 * @return boolean
127 */
128 function isSiteEditor() {
129 return typeof pagenow === 'string' && pagenow === 'site-editor';
130 }
131
132 /**
133 * Returns true if the block editor is currently showing the desktop device type preview.
134 *
135 * This function will always return true in the site editor as it uses the
136 * edit-post store rather than the edit-site store.
137 *
138 * @date 15/02/22
139 * @since ACF 5.12
140 *
141 * @return boolean
142 */
143 function isDesktopPreviewDeviceType() {
144 const editPostStore = select('core/edit-post');
145
146 // Return true if the edit post store isn't available (such as in the widget editor)
147 if (!editPostStore) return true;
148
149 // Check if function exists (experimental or not) and return true if it's Desktop, or doesn't exist.
150 if (editPostStore.__experimentalGetPreviewDeviceType) {
151 return 'Desktop' === editPostStore.__experimentalGetPreviewDeviceType();
152 } else if (editPostStore.getPreviewDeviceType) {
153 return 'Desktop' === editPostStore.getPreviewDeviceType();
154 } else {
155 return true;
156 }
157 }
158
159 /**
160 * Returns true if the block editor is currently in template edit mode.
161 *
162 * @date 16/02/22
163 * @since ACF 5.12
164 *
165 * @return boolean
166 */
167 function isEditingTemplate() {
168 const editPostStore = select('core/edit-post');
169
170 // Return false if the edit post store isn't available (such as in the widget editor)
171 if (!editPostStore) return false;
172
173 // Return false if the function doesn't exist
174 if (!editPostStore.isEditingTemplate) return false;
175 return editPostStore.isEditingTemplate();
176 }
177
178 /**
179 * Returns true if we're currently inside an iFramed non-desktop device preview type (WP5.9+)
180 *
181 * @date 15/02/22
182 * @since ACF 5.12
183 *
184 * @return boolean
185 */
186 function isiFramedMobileDevicePreview() {
187 return $('iframe[name=editor-canvas]').length && !isDesktopPreviewDeviceType();
188 }
189
190 /**
191 * Registers a block type.
192 *
193 * @date 19/2/19
194 * @since ACF 5.8.0
195 *
196 * @param object blockType The block type settings localized from PHP.
197 * @return object The result from wp.blocks.registerBlockType().
198 */
199 function registerBlockType(blockType) {
200 // Bail early if is excluded post_type.
201 const allowedTypes = blockType.post_types || [];
202 if (allowedTypes.length) {
203 // Always allow block to appear on "Edit reusable Block" screen.
204 allowedTypes.push('wp_block');
205
206 // Check post type.
207 const postType = acf.get('postType');
208 if (!allowedTypes.includes(postType)) {
209 return false;
210 }
211 }
212
213 // Handle svg HTML.
214 if (typeof blockType.icon === 'string' && blockType.icon.substr(0, 4) === '<svg') {
215 const iconHTML = blockType.icon;
216 blockType.icon = /*#__PURE__*/React.createElement(Div, null, iconHTML);
217 }
218
219 // Remove icon if empty to allow for default "block".
220 // Avoids JS error preventing block from being registered.
221 if (!blockType.icon) {
222 delete blockType.icon;
223 }
224
225 // Check category exists and fallback to "common".
226 const category = wp.blocks.getCategories().filter(({
227 slug
228 }) => slug === blockType.category).pop();
229 if (!category) {
230 //console.warn( `The block "${blockType.name}" is registered with an unknown category "${blockType.category}".` );
231 blockType.category = 'common';
232 }
233
234 // Merge in block settings before local additions.
235 blockType = acf.parseArgs(blockType, {
236 title: '',
237 name: '',
238 category: '',
239 api_version: 2,
240 acf_block_version: 1
241 });
242
243 // Remove all empty attribute defaults from PHP values to allow serialisation.
244 // https://github.com/WordPress/gutenberg/issues/7342
245 for (const key in blockType.attributes) {
246 if ('default' in blockType.attributes[key] && blockType.attributes[key].default.length === 0) {
247 delete blockType.attributes[key].default;
248 }
249 }
250
251 // Apply anchor supports to avoid block editor default writing to ID.
252 if (blockType.supports.anchor) {
253 blockType.attributes.anchor = {
254 type: 'string'
255 };
256 }
257
258 // Append edit and save functions.
259 let ThisBlockEdit = BlockEdit;
260 let ThisBlockSave = BlockSave;
261
262 // Apply alignText functionality.
263 if (blockType.supports.alignText || blockType.supports.align_text) {
264 blockType.attributes = addBackCompatAttribute(blockType.attributes, 'align_text', 'string');
265 ThisBlockEdit = withAlignTextComponent(ThisBlockEdit, blockType);
266 }
267
268 // Apply alignContent functionality.
269 if (blockType.supports.alignContent || blockType.supports.align_content) {
270 blockType.attributes = addBackCompatAttribute(blockType.attributes, 'align_content', 'string');
271 ThisBlockEdit = withAlignContentComponent(ThisBlockEdit, blockType);
272 }
273
274 // Apply fullHeight functionality.
275 if (blockType.supports.fullHeight || blockType.supports.full_height) {
276 blockType.attributes = addBackCompatAttribute(blockType.attributes, 'full_height', 'boolean');
277 ThisBlockEdit = withFullHeightComponent(ThisBlockEdit, blockType.blockType);
278 }
279
280 // Set edit and save functions.
281 blockType.edit = props => {
282 // Ensure we remove our save lock if a block is removed.
283 wp.element.useEffect(() => {
284 return () => {
285 if (!wp.data.dispatch('core/editor')) return;
286 wp.data.dispatch('core/editor').unlockPostSaving('acf/block/' + props.clientId);
287 };
288 }, []);
289 return /*#__PURE__*/React.createElement(ThisBlockEdit, props);
290 };
291 blockType.save = () => /*#__PURE__*/React.createElement(ThisBlockSave, null);
292
293 // Add to storage.
294 blockTypes[blockType.name] = blockType;
295
296 // Register with WP.
297 const result = wp.blocks.registerBlockType(blockType.name, blockType);
298
299 // Fix bug in 'core/anchor/attribute' filter overwriting attribute.
300 // Required for < WP5.9
301 // See https://github.com/WordPress/gutenberg/issues/15240
302 if (result.attributes.anchor) {
303 result.attributes.anchor = {
304 type: 'string'
305 };
306 }
307
308 // Return result.
309 return result;
310 }
311
312 /**
313 * Returns the wp.data.select() response with backwards compatibility.
314 *
315 * @date 17/06/2020
316 * @since ACF 5.9.0
317 *
318 * @param string selector The selector name.
319 * @return mixed
320 */
321 function select(selector) {
322 if (selector === 'core/block-editor') {
323 return wp.data.select('core/block-editor') || wp.data.select('core/editor');
324 }
325 return wp.data.select(selector);
326 }
327
328 /**
329 * Returns the wp.data.dispatch() response with backwards compatibility.
330 *
331 * @date 17/06/2020
332 * @since ACF 5.9.0
333 *
334 * @param string selector The selector name.
335 * @return mixed
336 */
337 function dispatch(selector) {
338 return wp.data.dispatch(selector);
339 }
340
341 /**
342 * Returns an array of all blocks for the given args.
343 *
344 * @date 27/2/19
345 * @since ACF 5.7.13
346 *
347 * @param {object} args An object of key=>value pairs used to filter results.
348 * @return array.
349 */
350 function getBlocks(args) {
351 let blocks = [];
352
353 // Local function to recurse through all child blocks and add to the blocks array.
354 const recurseBlocks = block => {
355 blocks.push(block);
356 select('core/block-editor').getBlocks(block.clientId).forEach(recurseBlocks);
357 };
358
359 // Trigger initial recursion for parent level blocks.
360 select('core/block-editor').getBlocks().forEach(recurseBlocks);
361
362 // Loop over args and filter.
363 for (const k in args) {
364 blocks = blocks.filter(({
365 attributes
366 }) => attributes[k] === args[k]);
367 }
368
369 // Return results.
370 return blocks;
371 }
372
373 /**
374 * Storage for the AJAX queue.
375 *
376 * @const {array}
377 */
378 const ajaxQueue = {};
379
380 /**
381 * Storage for cached AJAX requests for block content.
382 *
383 * @since ACF 5.12
384 * @const {array}
385 */
386 const fetchCache = {};
387
388 /**
389 * Fetches a JSON result from the AJAX API.
390 *
391 * @date 28/2/19
392 * @since ACF 5.7.13
393 *
394 * @param object block The block props.
395 * @query object The query args used in AJAX callback.
396 * @return object The AJAX promise.
397 */
398 function fetchBlock(args) {
399 const {
400 attributes = {},
401 context = {},
402 query = {},
403 clientId = null,
404 delay = 0
405 } = args;
406
407 // Build a unique queue ID from block data, including the clientId for edit forms.
408 const queueId = md5(JSON.stringify({
409 ...attributes,
410 ...context,
411 ...query
412 }));
413 const data = ajaxQueue[queueId] || {
414 query: {},
415 timeout: false,
416 promise: $.Deferred(),
417 started: false
418 };
419
420 // Append query args to storage.
421 data.query = {
422 ...data.query,
423 ...query
424 };
425 if (data.started) return data.promise;
426
427 // Set fresh timeout.
428 clearTimeout(data.timeout);
429 data.timeout = setTimeout(() => {
430 data.started = true;
431 if (fetchCache[queueId]) {
432 ajaxQueue[queueId] = null;
433 data.promise.resolve.apply(fetchCache[queueId][0], fetchCache[queueId][1]);
434 } else {
435 $.ajax({
436 url: acf.get('ajaxurl'),
437 dataType: 'json',
438 type: 'post',
439 cache: false,
440 data: acf.prepareForAjax({
441 action: 'acf/ajax/fetch-block',
442 block: JSON.stringify(attributes),
443 clientId: clientId,
444 context: JSON.stringify(context),
445 query: data.query
446 })
447 }).always(() => {
448 // Clean up queue after AJAX request is complete.
449 ajaxQueue[queueId] = null;
450 }).done(function () {
451 fetchCache[queueId] = [this, arguments];
452 data.promise.resolve.apply(this, arguments);
453 }).fail(function () {
454 data.promise.reject.apply(this, arguments);
455 });
456 }
457 }, delay);
458
459 // Update storage.
460 ajaxQueue[queueId] = data;
461
462 // Return promise.
463 return data.promise;
464 }
465
466 /**
467 * Returns true if both object are the same.
468 *
469 * @date 19/05/2020
470 * @since ACF 5.9.0
471 *
472 * @param object obj1
473 * @param object obj2
474 * @return bool
475 */
476 function compareObjects(obj1, obj2) {
477 return JSON.stringify(obj1) === JSON.stringify(obj2);
478 }
479
480 /**
481 * Converts HTML into a React element.
482 *
483 * @date 19/05/2020
484 * @since ACF 5.9.0
485 *
486 * @param string html The HTML to convert.
487 * @param int acfBlockVersion The ACF block version number.
488 * @return object Result of React.createElement().
489 */
490 acf.parseJSX = (html, acfBlockVersion) => {
491 // Apply a temporary wrapper for the jQuery parse to prevent text nodes triggering errors.
492 html = '<div>' + html + '</div>';
493 // Correctly balance InnerBlocks tags for jQuery's initial parse.
494 html = html.replace(/<InnerBlocks([^>]+)?\/>/, '<InnerBlocks$1></InnerBlocks>');
495 return parseNode($(html)[0], acfBlockVersion, 0).props.children;
496 };
497
498 /**
499 * Converts a DOM node into a React element.
500 *
501 * @date 19/05/2020
502 * @since ACF 5.9.0
503 *
504 * @param DOM node The DOM node.
505 * @param int acfBlockVersion The ACF block version number.
506 * @param int level The recursion level.
507 * @return object Result of React.createElement().
508 */
509 function parseNode(node, acfBlockVersion, level = 0) {
510 // Get node name.
511 const nodeName = parseNodeName(node.nodeName.toLowerCase(), acfBlockVersion);
512 if (!nodeName) {
513 return null;
514 }
515
516 // Get node attributes in React friendly format.
517 const nodeAttrs = {};
518 if (level === 1 && nodeName !== 'ACFInnerBlocks') {
519 // Top level (after stripping away the container div), create a ref for passing through to ACF's JS API.
520 nodeAttrs.ref = React.createRef();
521 }
522 acf.arrayArgs(node.attributes).map(parseNodeAttr).forEach(({
523 name,
524 value
525 }) => {
526 nodeAttrs[name] = value;
527 });
528 if ('ACFInnerBlocks' === nodeName) {
529 return /*#__PURE__*/React.createElement(ACFInnerBlocks, nodeAttrs);
530 }
531
532 // Define args for React.createElement().
533 const args = [nodeName, nodeAttrs];
534 acf.arrayArgs(node.childNodes).forEach(child => {
535 if (child instanceof Text) {
536 const text = child.textContent;
537 if (text) {
538 args.push(text);
539 }
540 } else {
541 args.push(parseNode(child, acfBlockVersion, level + 1));
542 }
543 });
544
545 // Return element.
546 return React.createElement.apply(this, args);
547 }
548
549 /**
550 * Converts a node or attribute name into it's JSX compliant name
551 *
552 * @date 05/07/2021
553 * @since ACF 5.9.8
554 *
555 * @param string name The node or attribute name.
556 * @return string
557 */
558 function getJSXName(name) {
559 const replacement = acf.isget(acf, 'jsxNameReplacements', name);
560 if (replacement) return replacement;
561 return name;
562 }
563
564 /**
565 * Converts the given name into a React friendly name or component.
566 *
567 * @date 19/05/2020
568 * @since ACF 5.9.0
569 *
570 * @param string name The node name in lowercase.
571 * @param int acfBlockVersion The ACF block version number.
572 * @return mixed
573 */
574 function parseNodeName(name, acfBlockVersion) {
575 switch (name) {
576 case 'innerblocks':
577 if (acfBlockVersion < 2) {
578 return InnerBlocks;
579 }
580 return 'ACFInnerBlocks';
581 case 'script':
582 return Script;
583 case '#comment':
584 return null;
585 default:
586 // Replace names for JSX counterparts.
587 name = getJSXName(name);
588 }
589 return name;
590 }
591
592 /**
593 * Functional component for ACFInnerBlocks.
594 *
595 * @since ACF 6.0.0
596 *
597 * @param obj props element properties.
598 * @return DOM element
599 */
600 function ACFInnerBlocks(props) {
601 const {
602 className = 'acf-innerblocks-container'
603 } = props;
604 const innerBlockProps = useInnerBlocksProps({
605 className: className
606 }, props);
607 return /*#__PURE__*/React.createElement("div", innerBlockProps, innerBlockProps.children);
608 }
609
610 /**
611 * Converts the given attribute into a React friendly name and value object.
612 *
613 * @date 19/05/2020
614 * @since ACF 5.9.0
615 *
616 * @param obj nodeAttr The node attribute.
617 * @return obj
618 */
619 function parseNodeAttr(nodeAttr) {
620 let name = nodeAttr.name;
621 let value = nodeAttr.value;
622
623 // Allow overrides for third party libraries who might use specific attributes.
624 let shortcut = acf.applyFilters('acf_blocks_parse_node_attr', false, nodeAttr);
625 if (shortcut) return shortcut;
626 switch (name) {
627 // Class.
628 case 'class':
629 name = 'className';
630 break;
631
632 // Style.
633 case 'style':
634 const css = {};
635 value.split(';').forEach(s => {
636 const pos = s.indexOf(':');
637 if (pos > 0) {
638 let ruleName = s.substr(0, pos).trim();
639 const ruleValue = s.substr(pos + 1).trim();
640
641 // Rename core properties, but not CSS variables.
642 if (ruleName.charAt(0) !== '-') {
643 ruleName = acf.strCamelCase(ruleName);
644 }
645 css[ruleName] = ruleValue;
646 }
647 });
648 value = css;
649 break;
650
651 // Default.
652 default:
653 // No formatting needed for "data-x" attributes.
654 if (name.indexOf('data-') === 0) {
655 break;
656 }
657
658 // Replace names for JSX counterparts.
659 name = getJSXName(name);
660
661 // Convert JSON values.
662 const c1 = value.charAt(0);
663 if (c1 === '[' || c1 === '{') {
664 value = JSON.parse(value);
665 }
666
667 // Convert bool values.
668 if (value === 'true' || value === 'false') {
669 value = value === 'true';
670 }
671 break;
672 }
673 return {
674 name,
675 value
676 };
677 }
678
679 /**
680 * Higher Order Component used to set default block attribute values.
681 *
682 * By modifying block attributes directly, instead of defining defaults in registerBlockType(),
683 * WordPress will include them always within the saved block serialized JSON.
684 *
685 * @date 31/07/2020
686 * @since ACF 5.9.0
687 *
688 * @param Component BlockListBlock The BlockListBlock Component.
689 * @return Component
690 */
691 const withDefaultAttributes = createHigherOrderComponent(BlockListBlock => class WrappedBlockEdit extends Component {
692 constructor(props) {
693 super(props);
694
695 // Extract vars.
696 const {
697 name,
698 attributes
699 } = this.props;
700
701 // Only run on ACF Blocks.
702 const blockType = getBlockType(name);
703 if (!blockType) {
704 return;
705 }
706
707 // Check and remove any empty string attributes to match PHP behaviour.
708 Object.keys(attributes).forEach(key => {
709 if (attributes[key] === '') {
710 delete attributes[key];
711 }
712 });
713
714 // Backward compatibility attribute replacement.
715 const upgrades = {
716 full_height: 'fullHeight',
717 align_content: 'alignContent',
718 align_text: 'alignText'
719 };
720 Object.keys(upgrades).forEach(key => {
721 if (attributes[key] !== undefined) {
722 attributes[upgrades[key]] = attributes[key];
723 } else if (attributes[upgrades[key]] === undefined) {
724 //Check for a default
725 if (blockType[key] !== undefined) {
726 attributes[upgrades[key]] = blockType[key];
727 }
728 }
729 delete blockType[key];
730 delete attributes[key];
731 });
732
733 // Set default attributes for those undefined.
734 for (let attribute in blockType.attributes) {
735 if (attributes[attribute] === undefined && blockType[attribute] !== undefined) {
736 attributes[attribute] = blockType[attribute];
737 }
738 }
739 }
740 render() {
741 return /*#__PURE__*/React.createElement(BlockListBlock, this.props);
742 }
743 }, 'withDefaultAttributes');
744 wp.hooks.addFilter('editor.BlockListBlock', 'acf/with-default-attributes', withDefaultAttributes);
745
746 /**
747 * The BlockSave functional component.
748 *
749 * @date 08/07/2020
750 * @since ACF 5.9.0
751 */
752 function BlockSave() {
753 return /*#__PURE__*/React.createElement(InnerBlocks.Content, null);
754 }
755
756 /**
757 * The BlockEdit component.
758 *
759 * @date 19/2/19
760 * @since ACF 5.7.12
761 */
762 class BlockEdit extends Component {
763 constructor(props) {
764 super(props);
765 this.setup();
766 }
767 setup() {
768 const {
769 name,
770 attributes,
771 clientId
772 } = this.props;
773 const blockType = getBlockType(name);
774
775 // Restrict current mode.
776 function restrictMode(modes) {
777 if (!modes.includes(attributes.mode)) {
778 attributes.mode = modes[0];
779 }
780 }
781 if (isBlockInQueryLoop(clientId) || isSiteEditor() || isiFramedMobileDevicePreview() || isEditingTemplate()) {
782 restrictMode(['preview']);
783 } else {
784 switch (blockType.mode) {
785 case 'edit':
786 restrictMode(['edit', 'preview']);
787 break;
788 case 'preview':
789 restrictMode(['preview', 'edit']);
790 break;
791 default:
792 restrictMode(['auto']);
793 break;
794 }
795 }
796 }
797 render() {
798 const {
799 name,
800 attributes,
801 setAttributes,
802 clientId
803 } = this.props;
804 const blockType = getBlockType(name);
805 const forcePreview = isBlockInQueryLoop(clientId) || isSiteEditor() || isiFramedMobileDevicePreview() || isEditingTemplate();
806 let {
807 mode
808 } = attributes;
809 if (forcePreview) {
810 mode = 'preview';
811 }
812
813 // Show toggle only for edit/preview modes and for blocks not in a query loop/FSE.
814 let showToggle = blockType.supports.mode;
815 if (mode === 'auto' || forcePreview) {
816 showToggle = false;
817 }
818
819 // Configure toggle variables.
820 const toggleText = mode === 'preview' ? acf.__('Switch to Edit') : acf.__('Switch to Preview');
821 const toggleIcon = mode === 'preview' ? 'edit' : 'welcome-view-site';
822 function toggleMode() {
823 setAttributes({
824 mode: mode === 'preview' ? 'edit' : 'preview'
825 });
826 }
827
828 // Return template.
829 return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(BlockControls, null, showToggle && /*#__PURE__*/React.createElement(ToolbarGroup, null, /*#__PURE__*/React.createElement(ToolbarButton, {
830 className: "components-icon-button components-toolbar__control",
831 label: toggleText,
832 icon: toggleIcon,
833 onClick: toggleMode
834 }))), /*#__PURE__*/React.createElement(InspectorControls, null, mode === 'preview' && /*#__PURE__*/React.createElement("div", {
835 className: "acf-block-component acf-block-panel"
836 }, /*#__PURE__*/React.createElement(BlockForm, this.props))), /*#__PURE__*/React.createElement(BlockBody, this.props));
837 }
838 }
839
840 /**
841 * The BlockBody functional component.
842 *
843 * @since ACF 5.7.12
844 */
845 function BlockBody(props) {
846 const {
847 attributes,
848 isSelected,
849 name,
850 clientId
851 } = props;
852 const {
853 mode
854 } = attributes;
855 const index = useSelect(select => {
856 const rootClientId = select('core/block-editor').getBlockRootClientId(clientId);
857 return select('core/block-editor').getBlockIndex(clientId, rootClientId);
858 });
859 let showForm = true;
860 let additionalClasses = 'acf-block-component acf-block-body';
861 if (mode === 'auto' && !isSelected || mode === 'preview') {
862 additionalClasses += ' acf-block-preview';
863 showForm = false;
864 }
865
866 // Setup block cache if required, and update mode.
867 if (!(clientId in acf.blockInstances)) {
868 acf.blockInstances[clientId] = {
869 validation_errors: false,
870 mode: mode
871 };
872 }
873 acf.blockInstances[clientId].mode = mode;
874 if (!isSelected) {
875 if (blockSupportsValidation(name) && acf.blockInstances[clientId].validation_errors) {
876 additionalClasses += ' acf-block-has-validation-error';
877 }
878 acf.blockInstances[clientId].has_been_deselected = true;
879 }
880 if (getBlockVersion(name) > 1) {
881 return /*#__PURE__*/React.createElement("div", useBlockProps({
882 className: additionalClasses
883 }), showForm ? /*#__PURE__*/React.createElement(BlockForm, _extends({}, props, {
884 index: index
885 })) : /*#__PURE__*/React.createElement(BlockPreview, _extends({}, props, {
886 index: index
887 })));
888 } else {
889 return /*#__PURE__*/React.createElement("div", useBlockProps(), /*#__PURE__*/React.createElement("div", {
890 className: "acf-block-component acf-block-body"
891 }, showForm ? /*#__PURE__*/React.createElement(BlockForm, _extends({}, props, {
892 index: index
893 })) : /*#__PURE__*/React.createElement(BlockPreview, _extends({}, props, {
894 index: index
895 }))));
896 }
897 }
898
899 /**
900 * A react component to append HTMl.
901 *
902 * @date 19/2/19
903 * @since ACF 5.7.12
904 *
905 * @param string children The html to insert.
906 * @return void
907 */
908 class Div extends Component {
909 render() {
910 return /*#__PURE__*/React.createElement("div", {
911 dangerouslySetInnerHTML: {
912 __html: this.props.children
913 }
914 });
915 }
916 }
917
918 /**
919 * A react Component for inline scripts.
920 *
921 * This Component uses a combination of React references and jQuery to append the
922 * inline <script> HTML each time the component is rendered.
923 *
924 * @date 29/05/2020
925 * @since ACF 5.9.0
926 *
927 * @param type Var Description.
928 * @return type Description.
929 */
930 class Script extends Component {
931 render() {
932 return /*#__PURE__*/React.createElement("div", {
933 ref: el => this.el = el
934 });
935 }
936 setHTML(html) {
937 $(this.el).html(`<script>${html}</script>`);
938 }
939 componentDidUpdate() {
940 this.setHTML(this.props.children);
941 }
942 componentDidMount() {
943 this.setHTML(this.props.children);
944 }
945 }
946
947 /**
948 * DynamicHTML Class.
949 *
950 * A react componenet to load and insert dynamic HTML.
951 *
952 * @date 19/2/19
953 * @since ACF 5.7.12
954 *
955 * @param void
956 * @return void
957 */
958 class DynamicHTML extends Component {
959 constructor(props) {
960 super(props);
961
962 // Bind callbacks.
963 this.setRef = this.setRef.bind(this);
964
965 // Define default props and call setup().
966 this.id = '';
967 this.el = false;
968 this.subscribed = true;
969 this.renderMethod = 'jQuery';
970 this.passedValidation = false;
971 this.setup(props);
972
973 // Load state.
974 this.loadState();
975 }
976 setup(props) {
977 const constructor = this.constructor.name;
978 const clientId = props.clientId;
979 if (!(clientId in acf.blockInstances)) {
980 acf.blockInstances[clientId] = {
981 validation_errors: false,
982 mode: props.mode
983 };
984 }
985 if (!(constructor in acf.blockInstances[clientId])) {
986 acf.blockInstances[clientId][constructor] = {};
987 }
988 }
989 fetch() {
990 // Do nothing.
991 }
992 maybePreload(blockId, clientId, form) {
993 acf.debug('Preload check', blockId, clientId, form);
994 if (!isBlockInQueryLoop(this.props.clientId)) {
995 const preloadedBlocks = acf.get('preloadedBlocks');
996 const modeText = form ? 'form' : 'preview';
997 if (preloadedBlocks && preloadedBlocks[blockId]) {
998 // Ensure we only preload the correct block state (form or preview).
999 if (form && !preloadedBlocks[blockId].form || !form && preloadedBlocks[blockId].form) {
1000 acf.debug('Preload failed: state not preloaded.');
1001 return false;
1002 }
1003
1004 // Set HTML to the preloaded version.
1005 preloadedBlocks[blockId].html = preloadedBlocks[blockId].html.replaceAll(blockId, clientId);
1006
1007 // Replace blockId in errors.
1008 if (preloadedBlocks[blockId].validation && preloadedBlocks[blockId].validation.errors) {
1009 preloadedBlocks[blockId].validation.errors = preloadedBlocks[blockId].validation.errors.map(error => {
1010 error.input = error.input.replaceAll(blockId, clientId);
1011 return error;
1012 });
1013 }
1014
1015 // Return preloaded object.
1016 acf.debug('Preload successful', preloadedBlocks[blockId]);
1017 return preloadedBlocks[blockId];
1018 }
1019 }
1020 acf.debug('Preload failed: not preloaded.');
1021 return false;
1022 }
1023 loadState() {
1024 const client = acf.blockInstances[this.props.clientId] || {};
1025 this.state = client[this.constructor.name] || {};
1026 }
1027 setState(state) {
1028 acf.blockInstances[this.props.clientId][this.constructor.name] = {
1029 ...this.state,
1030 ...state
1031 };
1032
1033 // Update component state if subscribed.
1034 // - Allows AJAX callback to update store without modifying state of an unmounted component.
1035 if (this.subscribed) {
1036 super.setState(state);
1037 }
1038 acf.debug('SetState', Object.assign({}, this), this.props.clientId, this.constructor.name, Object.assign({}, acf.blockInstances[this.props.clientId][this.constructor.name]));
1039 }
1040 setHtml(html) {
1041 html = html ? html.trim() : '';
1042
1043 // Bail early if html has not changed.
1044 if (html === this.state.html) {
1045 return;
1046 }
1047
1048 // Update state.
1049 const state = {
1050 html
1051 };
1052 if (this.renderMethod === 'jsx') {
1053 state.jsx = acf.parseJSX(html, getBlockVersion(this.props.name));
1054
1055 // Handle templates which don't contain any valid JSX parsable elements.
1056 if (!state.jsx) {
1057 console.warn('Your ACF block template contains no valid HTML elements. Appending a empty div to prevent React JS errors.');
1058 state.html += '<div></div>';
1059 state.jsx = acf.parseJSX(state.html, getBlockVersion(this.props.name));
1060 }
1061
1062 // If we've got an object (as an array) find the first valid React ref.
1063 if (Array.isArray(state.jsx)) {
1064 let refElement = state.jsx.find(element => React.isValidElement(element));
1065 state.ref = refElement.ref;
1066 } else {
1067 state.ref = state.jsx.ref;
1068 }
1069 state.$el = $(this.el);
1070 } else {
1071 state.$el = $(html);
1072 }
1073 this.setState(state);
1074 }
1075 setRef(el) {
1076 this.el = el;
1077 }
1078 render() {
1079 // Render JSX.
1080 if (this.state.jsx) {
1081 // If we're a v2+ block, use the jsx element itself as our ref.
1082 if (getBlockVersion(this.props.name) > 1) {
1083 this.setRef(this.state.jsx);
1084 return this.state.jsx;
1085 } else {
1086 return /*#__PURE__*/React.createElement("div", {
1087 ref: this.setRef
1088 }, this.state.jsx);
1089 }
1090 }
1091
1092 // Return HTML.
1093 return /*#__PURE__*/React.createElement("div", {
1094 ref: this.setRef
1095 }, /*#__PURE__*/React.createElement(Placeholder, null, /*#__PURE__*/React.createElement(Spinner, null)));
1096 }
1097 shouldComponentUpdate({
1098 index
1099 }, {
1100 html
1101 }) {
1102 if (index !== this.props.index) {
1103 this.componentWillMove();
1104 }
1105 return html !== this.state.html;
1106 }
1107 display(context) {
1108 // This method is called after setting new HTML and the Component render.
1109 // The jQuery render method simply needs to move $el into place.
1110 if (this.renderMethod === 'jQuery') {
1111 const $el = this.state.$el;
1112 const $prevParent = $el.parent();
1113 const $thisParent = $(this.el);
1114
1115 // Move $el into place.
1116 $thisParent.html($el);
1117
1118 // Special case for reusable blocks.
1119 // Multiple instances of the same reusable block share the same block id.
1120 // This causes all instances to share the same state (cool), which unfortunately
1121 // pulls $el back and forth between the last rendered reusable block.
1122 // This simple fix leaves a "clone" behind :)
1123 if ($prevParent.length && $prevParent[0] !== $thisParent[0]) {
1124 $prevParent.html($el.clone());
1125 }
1126 }
1127
1128 // Lock block if required.
1129 if (this.getValidationErrors() && this.isNotNewlyAdded()) {
1130 this.lockBlockForSaving();
1131 } else {
1132 this.unlockBlockForSaving();
1133 }
1134
1135 // Call context specific method.
1136 switch (context) {
1137 case 'append':
1138 this.componentDidAppend();
1139 break;
1140 case 'remount':
1141 this.componentDidRemount();
1142 break;
1143 }
1144 }
1145 validate() {
1146 // Do nothing.
1147 }
1148 componentDidMount() {
1149 // Fetch on first load.
1150 if (this.state.html === undefined) {
1151 this.fetch();
1152
1153 // Or remount existing HTML.
1154 } else {
1155 this.display('remount');
1156 }
1157 }
1158 componentDidUpdate(prevProps, prevState) {
1159 // HTML has changed.
1160 this.display('append');
1161 }
1162 componentDidAppend() {
1163 acf.doAction('append', this.state.$el);
1164 }
1165 componentWillUnmount() {
1166 acf.doAction('unmount', this.state.$el);
1167
1168 // Unsubscribe this component from state.
1169 this.subscribed = false;
1170 }
1171 componentDidRemount() {
1172 this.subscribed = true;
1173
1174 // Use setTimeout to avoid incorrect timing of events.
1175 // React will unmount and mount components in DOM order.
1176 // This means a new component can be mounted before an old one is unmounted.
1177 // ACF shares $el across new/old components which is un-React-like.
1178 // This timout ensures that unmounting occurs before remounting.
1179 setTimeout(() => {
1180 acf.doAction('remount', this.state.$el);
1181 });
1182 }
1183 componentWillMove() {
1184 acf.doAction('unmount', this.state.$el);
1185 setTimeout(() => {
1186 acf.doAction('remount', this.state.$el);
1187 });
1188 }
1189 isNotNewlyAdded() {
1190 return acf.blockInstances[this.props.clientId].has_been_deselected || false;
1191 }
1192 hasShownValidation() {
1193 return acf.blockInstances[this.props.clientId].shown_validation || false;
1194 }
1195 setShownValidation() {
1196 acf.blockInstances[this.props.clientId].shown_validation = true;
1197 }
1198 setValidationErrors(errors) {
1199 acf.blockInstances[this.props.clientId].validation_errors = errors;
1200 }
1201 getValidationErrors() {
1202 return acf.blockInstances[this.props.clientId].validation_errors;
1203 }
1204 getMode() {
1205 return acf.blockInstances[this.props.clientId].mode;
1206 }
1207 lockBlockForSaving() {
1208 if (!wp.data.dispatch('core/editor')) return;
1209 wp.data.dispatch('core/editor').lockPostSaving('acf/block/' + this.props.clientId);
1210 }
1211 unlockBlockForSaving() {
1212 if (!wp.data.dispatch('core/editor')) return;
1213 wp.data.dispatch('core/editor').unlockPostSaving('acf/block/' + this.props.clientId);
1214 }
1215 displayValidation($formEl) {
1216 if (!blockSupportsValidation(this.props.name)) {
1217 acf.debug('Block does not support validation');
1218 return;
1219 }
1220 if (!$formEl || $formEl.hasClass('acf-empty-block-fields')) {
1221 acf.debug('There is no edit form available to validate.');
1222 return;
1223 }
1224 const errors = this.getValidationErrors();
1225 acf.debug('Starting handle validation', Object.assign({}, this), Object.assign({}, $formEl), errors);
1226 this.setShownValidation();
1227 let validator = acf.getBlockFormValidator($formEl);
1228 validator.clearErrors();
1229 acf.doAction('blocks/validation/pre_apply', errors);
1230 if (errors) {
1231 validator.addErrors(errors);
1232 validator.showErrors('after');
1233 this.lockBlockForSaving();
1234 } else {
1235 // remove previous error message
1236 if (validator.has('notice')) {
1237 validator.get('notice').update({
1238 type: 'success',
1239 text: acf.__('Validation successful'),
1240 timeout: 1000
1241 });
1242 validator.set('notice', null);
1243 }
1244 this.unlockBlockForSaving();
1245 }
1246 acf.doAction('blocks/validation/post_apply', errors);
1247 }
1248 }
1249
1250 /**
1251 * BlockForm Class.
1252 *
1253 * A react componenet to handle the block form.
1254 *
1255 * @date 19/2/19
1256 * @since ACF 5.7.12
1257 *
1258 * @param string id the block id.
1259 * @return void
1260 */
1261 class BlockForm extends DynamicHTML {
1262 setup(props) {
1263 this.id = `BlockForm-${props.clientId}`;
1264 super.setup(props);
1265 }
1266 fetch(validate_only = false, data = false) {
1267 // Extract props.
1268 const {
1269 context,
1270 clientId,
1271 name
1272 } = this.props;
1273 let {
1274 attributes
1275 } = this.props;
1276 let query = {
1277 form: true
1278 };
1279 if (validate_only) {
1280 query = {
1281 validate: true
1282 };
1283 attributes.data = data;
1284 }
1285 const hash = createBlockAttributesHash(attributes, context);
1286 acf.debug('BlockForm fetch', attributes, query);
1287
1288 // Try preloaded data first.
1289 const preloaded = this.maybePreload(hash, clientId, true);
1290 if (preloaded) {
1291 this.setHtml(acf.applyFilters('blocks/form/render', preloaded.html, true));
1292 if (preloaded.validation) this.setValidationErrors(preloaded.validation.errors);
1293 return;
1294 }
1295 if (!blockSupportsValidation(name)) {
1296 query.validate = false;
1297 }
1298
1299 // Request AJAX and update HTML on complete.
1300 fetchBlock({
1301 attributes,
1302 context,
1303 clientId,
1304 query
1305 }).done(({
1306 data
1307 }) => {
1308 acf.debug('fetch block form promise');
1309 if (!data) {
1310 this.setHtml(`<div class="acf-block-fields acf-fields acf-empty-block-fields">${acf.__('Error loading block form')}</div>`);
1311 return;
1312 }
1313 if (data.form) {
1314 this.setHtml(acf.applyFilters('blocks/form/render', data.form.replaceAll(data.clientId, clientId), false));
1315 }
1316 if (data.validation) this.setValidationErrors(data.validation.errors);
1317 if (this.isNotNewlyAdded()) {
1318 acf.debug("Block has already shown it's invalid. The form needs to show validation errors");
1319 this.validate();
1320 }
1321 });
1322 }
1323 validate(loadState = true) {
1324 if (loadState) {
1325 this.loadState();
1326 }
1327 acf.debug('BlockForm calling validate with state', Object.assign({}, this));
1328 super.displayValidation(this.state.$el);
1329 }
1330 shouldComponentUpdate(nextProps, nextState) {
1331 if (blockSupportsValidation(this.props.name) && this.state.$el && this.isNotNewlyAdded() && !this.hasShownValidation()) {
1332 this.validate(false); // Shouldn't update state in shouldComponentUpdate.
1333 }
1334 return super.shouldComponentUpdate(nextProps, nextState);
1335 }
1336 componentWillUnmount() {
1337 super.componentWillUnmount();
1338
1339 //TODO: either delete this, or clear validations here (if that's a sensible idea)
1340
1341 acf.debug('BlockForm Component did unmount');
1342 }
1343 componentDidRemount() {
1344 super.componentDidRemount();
1345 acf.debug('BlockForm component did remount');
1346 const {
1347 $el
1348 } = this.state;
1349 if (blockSupportsValidation(this.props.name) && this.isNotNewlyAdded()) {
1350 acf.debug("Block has already shown it's invalid. The form needs to show validation errors");
1351 this.validate();
1352 }
1353
1354 // Make sure our on append events are registered.
1355 if ($el.data('acf-events-added') !== true) {
1356 this.componentDidAppend();
1357 }
1358 }
1359 componentDidAppend() {
1360 super.componentDidAppend();
1361 acf.debug('BlockForm component did append');
1362
1363 // Extract props.
1364 const {
1365 attributes,
1366 setAttributes,
1367 clientId,
1368 name
1369 } = this.props;
1370 const thisBlockForm = this;
1371 const {
1372 $el
1373 } = this.state;
1374
1375 // Callback for updating block data and validation status if we're in an edit only mode.
1376 function serializeData(silent = false) {
1377 const data = acf.serialize($el, `acf-block_${clientId}`);
1378 if (silent) {
1379 attributes.data = data;
1380 } else {
1381 setAttributes({
1382 data
1383 });
1384 }
1385 if (blockSupportsValidation(name) && !silent && thisBlockForm.getMode() === 'edit') {
1386 acf.debug('No block preview currently available. Need to trigger a validation only fetch.');
1387 thisBlockForm.fetch(true, data);
1388 }
1389 }
1390
1391 // Add events.
1392 let timeout = false;
1393 $el.on('change keyup', () => {
1394 clearTimeout(timeout);
1395 timeout = setTimeout(serializeData, 300);
1396 });
1397
1398 // Log initialization for remount check on the persistent element.
1399 $el.data('acf-events-added', true);
1400
1401 // Ensure newly added block is saved with data.
1402 // Do it silently to avoid triggering a preview render.
1403 if (!attributes.data) {
1404 serializeData(true);
1405 }
1406 }
1407 }
1408
1409 /**
1410 * BlockPreview Class.
1411 *
1412 * A react componenet to handle the block preview.
1413 *
1414 * @date 19/2/19
1415 * @since ACF 5.7.12
1416 *
1417 * @param string id the block id.
1418 * @return void
1419 */
1420 class BlockPreview extends DynamicHTML {
1421 setup(props) {
1422 const blockType = getBlockType(props.name);
1423 const contextPostId = acf.isget(this.props, 'context', 'postId');
1424 this.id = `BlockPreview-${props.clientId}`;
1425 super.setup(props);
1426
1427 // Apply the contextPostId to the ID if set to stop query loop ID duplication.
1428 if (contextPostId) {
1429 this.id = `BlockPreview-${props.clientId}-${contextPostId}`;
1430 }
1431 if (blockType.supports.jsx) {
1432 this.renderMethod = 'jsx';
1433 }
1434 }
1435 fetch(args = {}) {
1436 const {
1437 attributes = this.props.attributes,
1438 clientId = this.props.clientId,
1439 context = this.props.context,
1440 delay = 0
1441 } = args;
1442 const {
1443 name
1444 } = this.props;
1445
1446 // Remember attributes used to fetch HTML.
1447 this.setState({
1448 prevAttributes: attributes,
1449 prevContext: context
1450 });
1451 const hash = createBlockAttributesHash(attributes, context);
1452
1453 // Try preloaded data first.
1454 let preloaded = this.maybePreload(hash, clientId, false);
1455 if (preloaded) {
1456 if (getBlockVersion(name) == 1) {
1457 preloaded.html = '<div class="acf-block-preview">' + preloaded.html + '</div>';
1458 }
1459 this.setHtml(acf.applyFilters('blocks/preview/render', preloaded.html, true));
1460 if (preloaded.validation) this.setValidationErrors(preloaded.validation.errors);
1461 return;
1462 }
1463 let query = {
1464 preview: true
1465 };
1466 if (!blockSupportsValidation(name)) {
1467 query.validate = false;
1468 }
1469
1470 // Request AJAX and update HTML on complete.
1471 fetchBlock({
1472 attributes,
1473 context,
1474 clientId,
1475 query,
1476 delay
1477 }).done(({
1478 data
1479 }) => {
1480 if (!data) {
1481 this.setHtml(`<div class="acf-block-fields acf-fields acf-empty-block-fields">${acf.__('Error previewing block')}</div>`);
1482 return;
1483 }
1484 let replaceHtml = data.preview.replaceAll(data.clientId, clientId);
1485 if (getBlockVersion(name) == 1) {
1486 replaceHtml = '<div class="acf-block-preview">' + replaceHtml + '</div>';
1487 }
1488 acf.debug('fetch block render promise');
1489 this.setHtml(acf.applyFilters('blocks/preview/render', replaceHtml, false));
1490 if (data.validation) {
1491 this.setValidationErrors(data.validation.errors);
1492 }
1493 if (this.isNotNewlyAdded()) {
1494 this.validate();
1495 }
1496 });
1497 }
1498 validate() {
1499 // Check we've got a block form for this instance.
1500 const client = acf.blockInstances[this.props.clientId] || {};
1501 const blockFormState = client.BlockForm || false;
1502 if (blockFormState) {
1503 super.displayValidation(blockFormState.$el);
1504 }
1505 }
1506 componentDidAppend() {
1507 super.componentDidAppend();
1508 this.renderBlockPreviewEvent();
1509 }
1510 shouldComponentUpdate(nextProps, nextState) {
1511 const nextAttributes = nextProps.attributes;
1512 const thisAttributes = this.props.attributes;
1513
1514 // Update preview if block data has changed.
1515 if (!compareObjects(nextAttributes, thisAttributes) || !compareObjects(nextProps.context, this.props.context)) {
1516 let delay = 0;
1517
1518 // Delay fetch when editing className or anchor to simulate consistent logic to custom fields.
1519 if (nextAttributes.className !== thisAttributes.className) {
1520 delay = 300;
1521 }
1522 if (nextAttributes.anchor !== thisAttributes.anchor) {
1523 delay = 300;
1524 }
1525 acf.debug('Triggering fetch from block preview shouldComponentUpdate');
1526 this.fetch({
1527 attributes: nextAttributes,
1528 context: nextProps.context,
1529 delay
1530 });
1531 }
1532 return super.shouldComponentUpdate(nextProps, nextState);
1533 }
1534 renderBlockPreviewEvent() {
1535 // Extract props.
1536 const {
1537 attributes,
1538 name
1539 } = this.props;
1540 const {
1541 $el,
1542 ref
1543 } = this.state;
1544 var blockElement;
1545
1546 // Generate action friendly type.
1547 const type = attributes.name.replace('acf/', '');
1548 if (ref && ref.current) {
1549 // We've got a react ref from a JSX container. Use the parent as the blockElement
1550 blockElement = $(ref.current).parent();
1551 } else if (getBlockVersion(name) == 1) {
1552 blockElement = $el;
1553 } else {
1554 blockElement = $el.parents('.acf-block-preview');
1555 }
1556
1557 // Do action.
1558 acf.doAction('render_block_preview', blockElement, attributes);
1559 acf.doAction(`render_block_preview/type=${type}`, blockElement, attributes);
1560 }
1561 componentDidRemount() {
1562 super.componentDidRemount();
1563 acf.debug('Checking if fetch is required in BlockPreview componentDidRemount', Object.assign({}, this.state.prevAttributes), Object.assign({}, this.props.attributes), Object.assign({}, this.state.prevContext), Object.assign({}, this.props.context));
1564
1565 // Update preview if data has changed since last render (changing from "edit" to "preview").
1566 if (!compareObjects(this.state.prevAttributes, this.props.attributes) || !compareObjects(this.state.prevContext, this.props.context)) {
1567 acf.debug('Triggering block preview fetch from componentDidRemount');
1568 this.fetch();
1569 }
1570
1571 // Fire the block preview event so blocks can reinit JS elements.
1572 // React reusing DOM elements covers any potential race condition from the above fetch.
1573 this.renderBlockPreviewEvent();
1574 }
1575 }
1576
1577 /**
1578 * Initializes ACF Blocks logic and registration.
1579 *
1580 * @since ACF 5.9.0
1581 */
1582 function initialize() {
1583 // Add support for WordPress versions before 5.2.
1584 if (!wp.blockEditor) {
1585 wp.blockEditor = wp.editor;
1586 }
1587
1588 // Register block types.
1589 const blockTypes = acf.get('blockTypes');
1590 if (blockTypes) {
1591 blockTypes.map(registerBlockType);
1592 }
1593 }
1594
1595 // Run the initialize callback during the "prepare" action.
1596 // This ensures that all localized data is available and that blocks are registered before the WP editor has been instantiated.
1597 acf.addAction('prepare', initialize);
1598
1599 /**
1600 * Returns a valid vertical alignment.
1601 *
1602 * @date 07/08/2020
1603 * @since ACF 5.9.0
1604 *
1605 * @param string align A vertical alignment.
1606 * @return string
1607 */
1608 function validateVerticalAlignment(align) {
1609 const ALIGNMENTS = ['top', 'center', 'bottom'];
1610 const DEFAULT = 'top';
1611 return ALIGNMENTS.includes(align) ? align : DEFAULT;
1612 }
1613
1614 /**
1615 * Returns a valid horizontal alignment.
1616 *
1617 * @date 07/08/2020
1618 * @since ACF 5.9.0
1619 *
1620 * @param string align A horizontal alignment.
1621 * @return string
1622 */
1623 function validateHorizontalAlignment(align) {
1624 const ALIGNMENTS = ['left', 'center', 'right'];
1625 const DEFAULT = acf.get('rtl') ? 'right' : 'left';
1626 return ALIGNMENTS.includes(align) ? align : DEFAULT;
1627 }
1628
1629 /**
1630 * Returns a valid matrix alignment.
1631 *
1632 * Written for "upgrade-path" compatibility from vertical alignment to matrix alignment.
1633 *
1634 * @date 07/08/2020
1635 * @since ACF 5.9.0
1636 *
1637 * @param string align A matrix alignment.
1638 * @return string
1639 */
1640 function validateMatrixAlignment(align) {
1641 const DEFAULT = 'center center';
1642 if (align) {
1643 const [y, x] = align.split(' ');
1644 return `${validateVerticalAlignment(y)} ${validateHorizontalAlignment(x)}`;
1645 }
1646 return DEFAULT;
1647 }
1648
1649 /**
1650 * A higher order component adding alignContent editing functionality.
1651 *
1652 * @date 08/07/2020
1653 * @since ACF 5.9.0
1654 *
1655 * @param component OriginalBlockEdit The original BlockEdit component.
1656 * @param object blockType The block type settings.
1657 * @return component
1658 */
1659 function withAlignContentComponent(OriginalBlockEdit, blockType) {
1660 // Determine alignment vars
1661 let type = blockType.supports.align_content || blockType.supports.alignContent;
1662 let AlignmentComponent;
1663 let validateAlignment;
1664 switch (type) {
1665 case 'matrix':
1666 AlignmentComponent = BlockAlignmentMatrixControl || BlockAlignmentMatrixToolbar;
1667 validateAlignment = validateMatrixAlignment;
1668 break;
1669 default:
1670 AlignmentComponent = BlockVerticalAlignmentToolbar;
1671 validateAlignment = validateVerticalAlignment;
1672 break;
1673 }
1674
1675 // Ensure alignment component exists.
1676 if (AlignmentComponent === undefined) {
1677 console.warn(`The "${type}" alignment component was not found.`);
1678 return OriginalBlockEdit;
1679 }
1680
1681 // Ensure correct block attribute data is sent in intial preview AJAX request.
1682 blockType.alignContent = validateAlignment(blockType.alignContent);
1683
1684 // Return wrapped component.
1685 return class WrappedBlockEdit extends Component {
1686 render() {
1687 const {
1688 attributes,
1689 setAttributes
1690 } = this.props;
1691 const {
1692 alignContent
1693 } = attributes;
1694 function onChangeAlignContent(alignContent) {
1695 setAttributes({
1696 alignContent: validateAlignment(alignContent)
1697 });
1698 }
1699 return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(BlockControls, {
1700 group: "block"
1701 }, /*#__PURE__*/React.createElement(AlignmentComponent, {
1702 label: acf.__('Change content alignment'),
1703 value: validateAlignment(alignContent),
1704 onChange: onChangeAlignContent
1705 })), /*#__PURE__*/React.createElement(OriginalBlockEdit, this.props));
1706 }
1707 };
1708 }
1709
1710 /**
1711 * A higher order component adding alignText editing functionality.
1712 *
1713 * @date 08/07/2020
1714 * @since ACF 5.9.0
1715 *
1716 * @param component OriginalBlockEdit The original BlockEdit component.
1717 * @param object blockType The block type settings.
1718 * @return component
1719 */
1720 function withAlignTextComponent(OriginalBlockEdit, blockType) {
1721 const validateAlignment = validateHorizontalAlignment;
1722
1723 // Ensure correct block attribute data is sent in intial preview AJAX request.
1724 blockType.alignText = validateAlignment(blockType.alignText);
1725
1726 // Return wrapped component.
1727 return class WrappedBlockEdit extends Component {
1728 render() {
1729 const {
1730 attributes,
1731 setAttributes
1732 } = this.props;
1733 const {
1734 alignText
1735 } = attributes;
1736 function onChangeAlignText(alignText) {
1737 setAttributes({
1738 alignText: validateAlignment(alignText)
1739 });
1740 }
1741 return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(BlockControls, {
1742 group: "block"
1743 }, /*#__PURE__*/React.createElement(AlignmentToolbar, {
1744 value: validateAlignment(alignText),
1745 onChange: onChangeAlignText
1746 })), /*#__PURE__*/React.createElement(OriginalBlockEdit, this.props));
1747 }
1748 };
1749 }
1750
1751 /**
1752 * A higher order component adding full height support.
1753 *
1754 * @date 19/07/2021
1755 * @since ACF 5.10.0
1756 *
1757 * @param component OriginalBlockEdit The original BlockEdit component.
1758 * @param object blockType The block type settings.
1759 * @return component
1760 */
1761 function withFullHeightComponent(OriginalBlockEdit, blockType) {
1762 if (!BlockFullHeightAlignmentControl) return OriginalBlockEdit;
1763
1764 // Return wrapped component.
1765 return class WrappedBlockEdit extends Component {
1766 render() {
1767 const {
1768 attributes,
1769 setAttributes
1770 } = this.props;
1771 const {
1772 fullHeight
1773 } = attributes;
1774 function onToggleFullHeight(fullHeight) {
1775 setAttributes({
1776 fullHeight
1777 });
1778 }
1779 return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(BlockControls, {
1780 group: "block"
1781 }, /*#__PURE__*/React.createElement(BlockFullHeightAlignmentControl, {
1782 isActive: fullHeight,
1783 onToggle: onToggleFullHeight
1784 })), /*#__PURE__*/React.createElement(OriginalBlockEdit, this.props));
1785 }
1786 };
1787 }
1788
1789 /**
1790 * Appends a backwards compatibility attribute for conversion.
1791 *
1792 * @since ACF 6.0
1793 *
1794 * @param object attributes The block type attributes.
1795 * @return object
1796 */
1797 function addBackCompatAttribute(attributes, new_attribute, type) {
1798 attributes[new_attribute] = {
1799 type: type
1800 };
1801 return attributes;
1802 }
1803
1804 /**
1805 * Create a block hash from attributes
1806 *
1807 * @since ACF 6.0
1808 *
1809 * @param object attributes The block type attributes.
1810 * @param object context The current block context object.
1811 * @return string
1812 */
1813 function createBlockAttributesHash(attributes, context) {
1814 attributes['_acf_context'] = sortObjectByKey(context);
1815 return md5(JSON.stringify(sortObjectByKey(attributes)));
1816 }
1817
1818 /**
1819 * Key sort an object
1820 *
1821 * @since ACF 6.3.1
1822 *
1823 * @param object toSort The object to be sorted
1824 * @return object
1825 */
1826 function sortObjectByKey(toSort) {
1827 return Object.keys(toSort).sort().reduce((acc, currValue) => {
1828 acc[currValue] = toSort[currValue];
1829 return acc;
1830 }, {});
1831 }
1832 })(jQuery);
1833
1834 /***/ }),
1835
1836 /***/ "./assets/src/js/pro/_acf-jsx-names.js":
1837 /*!*********************************************!*\
1838 !*** ./assets/src/js/pro/_acf-jsx-names.js ***!
1839 \*********************************************/
1840 /***/ (() => {
1841
1842 (function ($, undefined) {
1843 acf.jsxNameReplacements = {
1844 'accent-height': 'accentHeight',
1845 accentheight: 'accentHeight',
1846 'accept-charset': 'acceptCharset',
1847 acceptcharset: 'acceptCharset',
1848 accesskey: 'accessKey',
1849 'alignment-baseline': 'alignmentBaseline',
1850 alignmentbaseline: 'alignmentBaseline',
1851 allowedblocks: 'allowedBlocks',
1852 allowfullscreen: 'allowFullScreen',
1853 allowreorder: 'allowReorder',
1854 'arabic-form': 'arabicForm',
1855 arabicform: 'arabicForm',
1856 attributename: 'attributeName',
1857 attributetype: 'attributeType',
1858 autocapitalize: 'autoCapitalize',
1859 autocomplete: 'autoComplete',
1860 autocorrect: 'autoCorrect',
1861 autofocus: 'autoFocus',
1862 autoplay: 'autoPlay',
1863 autoreverse: 'autoReverse',
1864 autosave: 'autoSave',
1865 basefrequency: 'baseFrequency',
1866 'baseline-shift': 'baselineShift',
1867 baselineshift: 'baselineShift',
1868 baseprofile: 'baseProfile',
1869 calcmode: 'calcMode',
1870 'cap-height': 'capHeight',
1871 capheight: 'capHeight',
1872 cellpadding: 'cellPadding',
1873 cellspacing: 'cellSpacing',
1874 charset: 'charSet',
1875 class: 'className',
1876 classid: 'classID',
1877 classname: 'className',
1878 'clip-path': 'clipPath',
1879 'clip-rule': 'clipRule',
1880 clippath: 'clipPath',
1881 clippathunits: 'clipPathUnits',
1882 cliprule: 'clipRule',
1883 'color-interpolation': 'colorInterpolation',
1884 'color-interpolation-filters': 'colorInterpolationFilters',
1885 'color-profile': 'colorProfile',
1886 'color-rendering': 'colorRendering',
1887 colorinterpolation: 'colorInterpolation',
1888 colorinterpolationfilters: 'colorInterpolationFilters',
1889 colorprofile: 'colorProfile',
1890 colorrendering: 'colorRendering',
1891 colspan: 'colSpan',
1892 contenteditable: 'contentEditable',
1893 contentscripttype: 'contentScriptType',
1894 contentstyletype: 'contentStyleType',
1895 contextmenu: 'contextMenu',
1896 controlslist: 'controlsList',
1897 crossorigin: 'crossOrigin',
1898 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
1899 datetime: 'dateTime',
1900 defaultchecked: 'defaultChecked',
1901 defaultvalue: 'defaultValue',
1902 diffuseconstant: 'diffuseConstant',
1903 disablepictureinpicture: 'disablePictureInPicture',
1904 disableremoteplayback: 'disableRemotePlayback',
1905 'dominant-baseline': 'dominantBaseline',
1906 dominantbaseline: 'dominantBaseline',
1907 edgemode: 'edgeMode',
1908 'enable-background': 'enableBackground',
1909 enablebackground: 'enableBackground',
1910 enctype: 'encType',
1911 enterkeyhint: 'enterKeyHint',
1912 externalresourcesrequired: 'externalResourcesRequired',
1913 'fill-opacity': 'fillOpacity',
1914 'fill-rule': 'fillRule',
1915 fillopacity: 'fillOpacity',
1916 fillrule: 'fillRule',
1917 filterres: 'filterRes',
1918 filterunits: 'filterUnits',
1919 'flood-color': 'floodColor',
1920 'flood-opacity': 'floodOpacity',
1921 floodcolor: 'floodColor',
1922 floodopacity: 'floodOpacity',
1923 'font-family': 'fontFamily',
1924 'font-size': 'fontSize',
1925 'font-size-adjust': 'fontSizeAdjust',
1926 'font-stretch': 'fontStretch',
1927 'font-style': 'fontStyle',
1928 'font-variant': 'fontVariant',
1929 'font-weight': 'fontWeight',
1930 fontfamily: 'fontFamily',
1931 fontsize: 'fontSize',
1932 fontsizeadjust: 'fontSizeAdjust',
1933 fontstretch: 'fontStretch',
1934 fontstyle: 'fontStyle',
1935 fontvariant: 'fontVariant',
1936 fontweight: 'fontWeight',
1937 for: 'htmlFor',
1938 foreignobject: 'foreignObject',
1939 formaction: 'formAction',
1940 formenctype: 'formEncType',
1941 formmethod: 'formMethod',
1942 formnovalidate: 'formNoValidate',
1943 formtarget: 'formTarget',
1944 frameborder: 'frameBorder',
1945 'glyph-name': 'glyphName',
1946 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
1947 'glyph-orientation-vertical': 'glyphOrientationVertical',
1948 glyphname: 'glyphName',
1949 glyphorientationhorizontal: 'glyphOrientationHorizontal',
1950 glyphorientationvertical: 'glyphOrientationVertical',
1951 glyphref: 'glyphRef',
1952 gradienttransform: 'gradientTransform',
1953 gradientunits: 'gradientUnits',
1954 'horiz-adv-x': 'horizAdvX',
1955 'horiz-origin-x': 'horizOriginX',
1956 horizadvx: 'horizAdvX',
1957 horizoriginx: 'horizOriginX',
1958 hreflang: 'hrefLang',
1959 htmlfor: 'htmlFor',
1960 'http-equiv': 'httpEquiv',
1961 httpequiv: 'httpEquiv',
1962 'image-rendering': 'imageRendering',
1963 imagerendering: 'imageRendering',
1964 innerhtml: 'innerHTML',
1965 inputmode: 'inputMode',
1966 itemid: 'itemID',
1967 itemprop: 'itemProp',
1968 itemref: 'itemRef',
1969 itemscope: 'itemScope',
1970 itemtype: 'itemType',
1971 kernelmatrix: 'kernelMatrix',
1972 kernelunitlength: 'kernelUnitLength',
1973 keyparams: 'keyParams',
1974 keypoints: 'keyPoints',
1975 keysplines: 'keySplines',
1976 keytimes: 'keyTimes',
1977 keytype: 'keyType',
1978 lengthadjust: 'lengthAdjust',
1979 'letter-spacing': 'letterSpacing',
1980 letterspacing: 'letterSpacing',
1981 'lighting-color': 'lightingColor',
1982 lightingcolor: 'lightingColor',
1983 limitingconeangle: 'limitingConeAngle',
1984 marginheight: 'marginHeight',
1985 marginwidth: 'marginWidth',
1986 'marker-end': 'markerEnd',
1987 'marker-mid': 'markerMid',
1988 'marker-start': 'markerStart',
1989 markerend: 'markerEnd',
1990 markerheight: 'markerHeight',
1991 markermid: 'markerMid',
1992 markerstart: 'markerStart',
1993 markerunits: 'markerUnits',
1994 markerwidth: 'markerWidth',
1995 maskcontentunits: 'maskContentUnits',
1996 maskunits: 'maskUnits',
1997 maxlength: 'maxLength',
1998 mediagroup: 'mediaGroup',
1999 minlength: 'minLength',
2000 nomodule: 'noModule',
2001 novalidate: 'noValidate',
2002 numoctaves: 'numOctaves',
2003 'overline-position': 'overlinePosition',
2004 'overline-thickness': 'overlineThickness',
2005 overlineposition: 'overlinePosition',
2006 overlinethickness: 'overlineThickness',
2007 'paint-order': 'paintOrder',
2008 paintorder: 'paintOrder',
2009 'panose-1': 'panose1',
2010 pathlength: 'pathLength',
2011 patterncontentunits: 'patternContentUnits',
2012 patterntransform: 'patternTransform',
2013 patternunits: 'patternUnits',
2014 playsinline: 'playsInline',
2015 'pointer-events': 'pointerEvents',
2016 pointerevents: 'pointerEvents',
2017 pointsatx: 'pointsAtX',
2018 pointsaty: 'pointsAtY',
2019 pointsatz: 'pointsAtZ',
2020 preservealpha: 'preserveAlpha',
2021 preserveaspectratio: 'preserveAspectRatio',
2022 primitiveunits: 'primitiveUnits',
2023 radiogroup: 'radioGroup',
2024 readonly: 'readOnly',
2025 referrerpolicy: 'referrerPolicy',
2026 refx: 'refX',
2027 refy: 'refY',
2028 'rendering-intent': 'renderingIntent',
2029 renderingintent: 'renderingIntent',
2030 repeatcount: 'repeatCount',
2031 repeatdur: 'repeatDur',
2032 requiredextensions: 'requiredExtensions',
2033 requiredfeatures: 'requiredFeatures',
2034 rowspan: 'rowSpan',
2035 'shape-rendering': 'shapeRendering',
2036 shaperendering: 'shapeRendering',
2037 specularconstant: 'specularConstant',
2038 specularexponent: 'specularExponent',
2039 spellcheck: 'spellCheck',
2040 spreadmethod: 'spreadMethod',
2041 srcdoc: 'srcDoc',
2042 srclang: 'srcLang',
2043 srcset: 'srcSet',
2044 startoffset: 'startOffset',
2045 stddeviation: 'stdDeviation',
2046 stitchtiles: 'stitchTiles',
2047 'stop-color': 'stopColor',
2048 'stop-opacity': 'stopOpacity',
2049 stopcolor: 'stopColor',
2050 stopopacity: 'stopOpacity',
2051 'strikethrough-position': 'strikethroughPosition',
2052 'strikethrough-thickness': 'strikethroughThickness',
2053 strikethroughposition: 'strikethroughPosition',
2054 strikethroughthickness: 'strikethroughThickness',
2055 'stroke-dasharray': 'strokeDasharray',
2056 'stroke-dashoffset': 'strokeDashoffset',
2057 'stroke-linecap': 'strokeLinecap',
2058 'stroke-linejoin': 'strokeLinejoin',
2059 'stroke-miterlimit': 'strokeMiterlimit',
2060 'stroke-opacity': 'strokeOpacity',
2061 'stroke-width': 'strokeWidth',
2062 strokedasharray: 'strokeDasharray',
2063 strokedashoffset: 'strokeDashoffset',
2064 strokelinecap: 'strokeLinecap',
2065 strokelinejoin: 'strokeLinejoin',
2066 strokemiterlimit: 'strokeMiterlimit',
2067 strokeopacity: 'strokeOpacity',
2068 strokewidth: 'strokeWidth',
2069 suppresscontenteditablewarning: 'suppressContentEditableWarning',
2070 suppresshydrationwarning: 'suppressHydrationWarning',
2071 surfacescale: 'surfaceScale',
2072 systemlanguage: 'systemLanguage',
2073 tabindex: 'tabIndex',
2074 tablevalues: 'tableValues',
2075 targetx: 'targetX',
2076 targety: 'targetY',
2077 templatelock: 'templateLock',
2078 'text-anchor': 'textAnchor',
2079 'text-decoration': 'textDecoration',
2080 'text-rendering': 'textRendering',
2081 textanchor: 'textAnchor',
2082 textdecoration: 'textDecoration',
2083 textlength: 'textLength',
2084 textrendering: 'textRendering',
2085 'underline-position': 'underlinePosition',
2086 'underline-thickness': 'underlineThickness',
2087 underlineposition: 'underlinePosition',
2088 underlinethickness: 'underlineThickness',
2089 'unicode-bidi': 'unicodeBidi',
2090 'unicode-range': 'unicodeRange',
2091 unicodebidi: 'unicodeBidi',
2092 unicoderange: 'unicodeRange',
2093 'units-per-em': 'unitsPerEm',
2094 unitsperem: 'unitsPerEm',
2095 usemap: 'useMap',
2096 'v-alphabetic': 'vAlphabetic',
2097 'v-hanging': 'vHanging',
2098 'v-ideographic': 'vIdeographic',
2099 'v-mathematical': 'vMathematical',
2100 valphabetic: 'vAlphabetic',
2101 'vector-effect': 'vectorEffect',
2102 vectoreffect: 'vectorEffect',
2103 'vert-adv-y': 'vertAdvY',
2104 'vert-origin-x': 'vertOriginX',
2105 'vert-origin-y': 'vertOriginY',
2106 vertadvy: 'vertAdvY',
2107 vertoriginx: 'vertOriginX',
2108 vertoriginy: 'vertOriginY',
2109 vhanging: 'vHanging',
2110 videographic: 'vIdeographic',
2111 viewbox: 'viewBox',
2112 viewtarget: 'viewTarget',
2113 vmathematical: 'vMathematical',
2114 'word-spacing': 'wordSpacing',
2115 wordspacing: 'wordSpacing',
2116 'writing-mode': 'writingMode',
2117 writingmode: 'writingMode',
2118 'x-height': 'xHeight',
2119 xchannelselector: 'xChannelSelector',
2120 xheight: 'xHeight',
2121 'xlink:actuate': 'xlinkActuate',
2122 'xlink:arcrole': 'xlinkArcrole',
2123 'xlink:href': 'xlinkHref',
2124 'xlink:role': 'xlinkRole',
2125 'xlink:show': 'xlinkShow',
2126 'xlink:title': 'xlinkTitle',
2127 'xlink:type': 'xlinkType',
2128 xlinkactuate: 'xlinkActuate',
2129 xlinkarcrole: 'xlinkArcrole',
2130 xlinkhref: 'xlinkHref',
2131 xlinkrole: 'xlinkRole',
2132 xlinkshow: 'xlinkShow',
2133 xlinktitle: 'xlinkTitle',
2134 xlinktype: 'xlinkType',
2135 'xml:base': 'xmlBase',
2136 'xml:lang': 'xmlLang',
2137 'xml:space': 'xmlSpace',
2138 xmlbase: 'xmlBase',
2139 xmllang: 'xmlLang',
2140 'xmlns:xlink': 'xmlnsXlink',
2141 xmlnsxlink: 'xmlnsXlink',
2142 xmlspace: 'xmlSpace',
2143 ychannelselector: 'yChannelSelector',
2144 zoomandpan: 'zoomAndPan'
2145 };
2146 })(jQuery);
2147
2148 /***/ }),
2149
2150 /***/ "./node_modules/charenc/charenc.js":
2151 /*!*****************************************!*\
2152 !*** ./node_modules/charenc/charenc.js ***!
2153 \*****************************************/
2154 /***/ ((module) => {
2155
2156 var charenc = {
2157 // UTF-8 encoding
2158 utf8: {
2159 // Convert a string to a byte array
2160 stringToBytes: function(str) {
2161 return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
2162 },
2163
2164 // Convert a byte array to a string
2165 bytesToString: function(bytes) {
2166 return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
2167 }
2168 },
2169
2170 // Binary encoding
2171 bin: {
2172 // Convert a string to a byte array
2173 stringToBytes: function(str) {
2174 for (var bytes = [], i = 0; i < str.length; i++)
2175 bytes.push(str.charCodeAt(i) & 0xFF);
2176 return bytes;
2177 },
2178
2179 // Convert a byte array to a string
2180 bytesToString: function(bytes) {
2181 for (var str = [], i = 0; i < bytes.length; i++)
2182 str.push(String.fromCharCode(bytes[i]));
2183 return str.join('');
2184 }
2185 }
2186 };
2187
2188 module.exports = charenc;
2189
2190
2191 /***/ }),
2192
2193 /***/ "./node_modules/crypt/crypt.js":
2194 /*!*************************************!*\
2195 !*** ./node_modules/crypt/crypt.js ***!
2196 \*************************************/
2197 /***/ ((module) => {
2198
2199 (function() {
2200 var base64map
2201 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
2202
2203 crypt = {
2204 // Bit-wise rotation left
2205 rotl: function(n, b) {
2206 return (n << b) | (n >>> (32 - b));
2207 },
2208
2209 // Bit-wise rotation right
2210 rotr: function(n, b) {
2211 return (n << (32 - b)) | (n >>> b);
2212 },
2213
2214 // Swap big-endian to little-endian and vice versa
2215 endian: function(n) {
2216 // If number given, swap endian
2217 if (n.constructor == Number) {
2218 return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
2219 }
2220
2221 // Else, assume array and swap all items
2222 for (var i = 0; i < n.length; i++)
2223 n[i] = crypt.endian(n[i]);
2224 return n;
2225 },
2226
2227 // Generate an array of any length of random bytes
2228 randomBytes: function(n) {
2229 for (var bytes = []; n > 0; n--)
2230 bytes.push(Math.floor(Math.random() * 256));
2231 return bytes;
2232 },
2233
2234 // Convert a byte array to big-endian 32-bit words
2235 bytesToWords: function(bytes) {
2236 for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
2237 words[b >>> 5] |= bytes[i] << (24 - b % 32);
2238 return words;
2239 },
2240
2241 // Convert big-endian 32-bit words to a byte array
2242 wordsToBytes: function(words) {
2243 for (var bytes = [], b = 0; b < words.length * 32; b += 8)
2244 bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
2245 return bytes;
2246 },
2247
2248 // Convert a byte array to a hex string
2249 bytesToHex: function(bytes) {
2250 for (var hex = [], i = 0; i < bytes.length; i++) {
2251 hex.push((bytes[i] >>> 4).toString(16));
2252 hex.push((bytes[i] & 0xF).toString(16));
2253 }
2254 return hex.join('');
2255 },
2256
2257 // Convert a hex string to a byte array
2258 hexToBytes: function(hex) {
2259 for (var bytes = [], c = 0; c < hex.length; c += 2)
2260 bytes.push(parseInt(hex.substr(c, 2), 16));
2261 return bytes;
2262 },
2263
2264 // Convert a byte array to a base-64 string
2265 bytesToBase64: function(bytes) {
2266 for (var base64 = [], i = 0; i < bytes.length; i += 3) {
2267 var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
2268 for (var j = 0; j < 4; j++)
2269 if (i * 8 + j * 6 <= bytes.length * 8)
2270 base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
2271 else
2272 base64.push('=');
2273 }
2274 return base64.join('');
2275 },
2276
2277 // Convert a base-64 string to a byte array
2278 base64ToBytes: function(base64) {
2279 // Remove non-base-64 characters
2280 base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
2281
2282 for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
2283 imod4 = ++i % 4) {
2284 if (imod4 == 0) continue;
2285 bytes.push(((base64map.indexOf(base64.charAt(i - 1))
2286 & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
2287 | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
2288 }
2289 return bytes;
2290 }
2291 };
2292
2293 module.exports = crypt;
2294 })();
2295
2296
2297 /***/ }),
2298
2299 /***/ "./node_modules/is-buffer/index.js":
2300 /*!*****************************************!*\
2301 !*** ./node_modules/is-buffer/index.js ***!
2302 \*****************************************/
2303 /***/ ((module) => {
2304
2305 /*!
2306 * Determine if an object is a Buffer
2307 *
2308 * @author Feross Aboukhadijeh <https://feross.org>
2309 * @license MIT
2310 */
2311
2312 // The _isBuffer check is for Safari 5-7 support, because it's missing
2313 // Object.prototype.constructor. Remove this eventually
2314 module.exports = function (obj) {
2315 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
2316 }
2317
2318 function isBuffer (obj) {
2319 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
2320 }
2321
2322 // For Node v0.10 support. Remove this eventually.
2323 function isSlowBuffer (obj) {
2324 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
2325 }
2326
2327
2328 /***/ }),
2329
2330 /***/ "./node_modules/md5/md5.js":
2331 /*!*********************************!*\
2332 !*** ./node_modules/md5/md5.js ***!
2333 \*********************************/
2334 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2335
2336 (function(){
2337 var crypt = __webpack_require__(/*! crypt */ "./node_modules/crypt/crypt.js"),
2338 utf8 = (__webpack_require__(/*! charenc */ "./node_modules/charenc/charenc.js").utf8),
2339 isBuffer = __webpack_require__(/*! is-buffer */ "./node_modules/is-buffer/index.js"),
2340 bin = (__webpack_require__(/*! charenc */ "./node_modules/charenc/charenc.js").bin),
2341
2342 // The core
2343 md5 = function (message, options) {
2344 // Convert to byte array
2345 if (message.constructor == String)
2346 if (options && options.encoding === 'binary')
2347 message = bin.stringToBytes(message);
2348 else
2349 message = utf8.stringToBytes(message);
2350 else if (isBuffer(message))
2351 message = Array.prototype.slice.call(message, 0);
2352 else if (!Array.isArray(message) && message.constructor !== Uint8Array)
2353 message = message.toString();
2354 // else, assume byte array already
2355
2356 var m = crypt.bytesToWords(message),
2357 l = message.length * 8,
2358 a = 1732584193,
2359 b = -271733879,
2360 c = -1732584194,
2361 d = 271733878;
2362
2363 // Swap endian
2364 for (var i = 0; i < m.length; i++) {
2365 m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
2366 ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
2367 }
2368
2369 // Padding
2370 m[l >>> 5] |= 0x80 << (l % 32);
2371 m[(((l + 64) >>> 9) << 4) + 14] = l;
2372
2373 // Method shortcuts
2374 var FF = md5._ff,
2375 GG = md5._gg,
2376 HH = md5._hh,
2377 II = md5._ii;
2378
2379 for (var i = 0; i < m.length; i += 16) {
2380
2381 var aa = a,
2382 bb = b,
2383 cc = c,
2384 dd = d;
2385
2386 a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
2387 d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
2388 c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
2389 b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
2390 a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
2391 d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
2392 c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
2393 b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
2394 a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
2395 d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
2396 c = FF(c, d, a, b, m[i+10], 17, -42063);
2397 b = FF(b, c, d, a, m[i+11], 22, -1990404162);
2398 a = FF(a, b, c, d, m[i+12], 7, 1804603682);
2399 d = FF(d, a, b, c, m[i+13], 12, -40341101);
2400 c = FF(c, d, a, b, m[i+14], 17, -1502002290);
2401 b = FF(b, c, d, a, m[i+15], 22, 1236535329);
2402
2403 a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
2404 d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
2405 c = GG(c, d, a, b, m[i+11], 14, 643717713);
2406 b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
2407 a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
2408 d = GG(d, a, b, c, m[i+10], 9, 38016083);
2409 c = GG(c, d, a, b, m[i+15], 14, -660478335);
2410 b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
2411 a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
2412 d = GG(d, a, b, c, m[i+14], 9, -1019803690);
2413 c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
2414 b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
2415 a = GG(a, b, c, d, m[i+13], 5, -1444681467);
2416 d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
2417 c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
2418 b = GG(b, c, d, a, m[i+12], 20, -1926607734);
2419
2420 a = HH(a, b, c, d, m[i+ 5], 4, -378558);
2421 d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
2422 c = HH(c, d, a, b, m[i+11], 16, 1839030562);
2423 b = HH(b, c, d, a, m[i+14], 23, -35309556);
2424 a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
2425 d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
2426 c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
2427 b = HH(b, c, d, a, m[i+10], 23, -1094730640);
2428 a = HH(a, b, c, d, m[i+13], 4, 681279174);
2429 d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
2430 c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
2431 b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
2432 a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
2433 d = HH(d, a, b, c, m[i+12], 11, -421815835);
2434 c = HH(c, d, a, b, m[i+15], 16, 530742520);
2435 b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
2436
2437 a = II(a, b, c, d, m[i+ 0], 6, -198630844);
2438 d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
2439 c = II(c, d, a, b, m[i+14], 15, -1416354905);
2440 b = II(b, c, d, a, m[i+ 5], 21, -57434055);
2441 a = II(a, b, c, d, m[i+12], 6, 1700485571);
2442 d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
2443 c = II(c, d, a, b, m[i+10], 15, -1051523);
2444 b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
2445 a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
2446 d = II(d, a, b, c, m[i+15], 10, -30611744);
2447 c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
2448 b = II(b, c, d, a, m[i+13], 21, 1309151649);
2449 a = II(a, b, c, d, m[i+ 4], 6, -145523070);
2450 d = II(d, a, b, c, m[i+11], 10, -1120210379);
2451 c = II(c, d, a, b, m[i+ 2], 15, 718787259);
2452 b = II(b, c, d, a, m[i+ 9], 21, -343485551);
2453
2454 a = (a + aa) >>> 0;
2455 b = (b + bb) >>> 0;
2456 c = (c + cc) >>> 0;
2457 d = (d + dd) >>> 0;
2458 }
2459
2460 return crypt.endian([a, b, c, d]);
2461 };
2462
2463 // Auxiliary functions
2464 md5._ff = function (a, b, c, d, x, s, t) {
2465 var n = a + (b & c | ~b & d) + (x >>> 0) + t;
2466 return ((n << s) | (n >>> (32 - s))) + b;
2467 };
2468 md5._gg = function (a, b, c, d, x, s, t) {
2469 var n = a + (b & d | c & ~d) + (x >>> 0) + t;
2470 return ((n << s) | (n >>> (32 - s))) + b;
2471 };
2472 md5._hh = function (a, b, c, d, x, s, t) {
2473 var n = a + (b ^ c ^ d) + (x >>> 0) + t;
2474 return ((n << s) | (n >>> (32 - s))) + b;
2475 };
2476 md5._ii = function (a, b, c, d, x, s, t) {
2477 var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
2478 return ((n << s) | (n >>> (32 - s))) + b;
2479 };
2480
2481 // Package private blocksize
2482 md5._blocksize = 16;
2483 md5._digestsize = 16;
2484
2485 module.exports = function (message, options) {
2486 if (message === undefined || message === null)
2487 throw new Error('Illegal argument ' + message);
2488
2489 var digestbytes = crypt.wordsToBytes(md5(message, options));
2490 return options && options.asBytes ? digestbytes :
2491 options && options.asString ? bin.bytesToString(digestbytes) :
2492 crypt.bytesToHex(digestbytes);
2493 };
2494
2495 })();
2496
2497
2498 /***/ })
2499
2500 /******/ });
2501 /************************************************************************/
2502 /******/ // The module cache
2503 /******/ var __webpack_module_cache__ = {};
2504 /******/
2505 /******/ // The require function
2506 /******/ function __webpack_require__(moduleId) {
2507 /******/ // Check if module is in cache
2508 /******/ var cachedModule = __webpack_module_cache__[moduleId];
2509 /******/ if (cachedModule !== undefined) {
2510 /******/ return cachedModule.exports;
2511 /******/ }
2512 /******/ // Create a new module (and put it into the cache)
2513 /******/ var module = __webpack_module_cache__[moduleId] = {
2514 /******/ // no module.id needed
2515 /******/ // no module.loaded needed
2516 /******/ exports: {}
2517 /******/ };
2518 /******/
2519 /******/ // Execute the module function
2520 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
2521 /******/
2522 /******/ // Return the exports of the module
2523 /******/ return module.exports;
2524 /******/ }
2525 /******/
2526 /************************************************************************/
2527 /******/ /* webpack/runtime/compat get default export */
2528 /******/ (() => {
2529 /******/ // getDefaultExport function for compatibility with non-harmony modules
2530 /******/ __webpack_require__.n = (module) => {
2531 /******/ var getter = module && module.__esModule ?
2532 /******/ () => (module['default']) :
2533 /******/ () => (module);
2534 /******/ __webpack_require__.d(getter, { a: getter });
2535 /******/ return getter;
2536 /******/ };
2537 /******/ })();
2538 /******/
2539 /******/ /* webpack/runtime/define property getters */
2540 /******/ (() => {
2541 /******/ // define getter functions for harmony exports
2542 /******/ __webpack_require__.d = (exports, definition) => {
2543 /******/ for(var key in definition) {
2544 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
2545 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
2546 /******/ }
2547 /******/ }
2548 /******/ };
2549 /******/ })();
2550 /******/
2551 /******/ /* webpack/runtime/hasOwnProperty shorthand */
2552 /******/ (() => {
2553 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
2554 /******/ })();
2555 /******/
2556 /******/ /* webpack/runtime/make namespace object */
2557 /******/ (() => {
2558 /******/ // define __esModule on exports
2559 /******/ __webpack_require__.r = (exports) => {
2560 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
2561 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2562 /******/ }
2563 /******/ Object.defineProperty(exports, '__esModule', { value: true });
2564 /******/ };
2565 /******/ })();
2566 /******/
2567 /************************************************************************/
2568 var __webpack_exports__ = {};
2569 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
2570 (() => {
2571 "use strict";
2572 /*!*********************************************!*\
2573 !*** ./assets/src/js/pro/acf-pro-blocks.js ***!
2574 \*********************************************/
2575 __webpack_require__.r(__webpack_exports__);
2576 /* harmony import */ var _acf_jsx_names_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_acf-jsx-names.js */ "./assets/src/js/pro/_acf-jsx-names.js");
2577 /* harmony import */ var _acf_jsx_names_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_acf_jsx_names_js__WEBPACK_IMPORTED_MODULE_0__);
2578 /* harmony import */ var _acf_blocks_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_acf-blocks.js */ "./assets/src/js/pro/_acf-blocks.js");
2579 /* harmony import */ var _acf_blocks_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_acf_blocks_js__WEBPACK_IMPORTED_MODULE_1__);
2580
2581
2582 })();
2583
2584 /******/ })()
2585 ;
2586 //# sourceMappingURL=acf-pro-blocks.js.map