PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / views / shared / edit-page-js.php

edit-page-js.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.7, at classes/views/shared/edit-page-js.php

62 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5 ?>
6 <script>
7 ( function() {
8 const handleDomReady = () => {
9 if ( 'undefined' === typeof wp || 'undefined' === typeof wp.data || 'function' !== typeof wp.data.subscribe ) {
10 return;
11 }
12
13 const closeListener = wp.data.subscribe(
14 () => {
15 const editor = wp.data.select( 'core/editor' );
16
17 if ( 'function' !== typeof editor.__unstableIsEditorReady ) {
18 closeListener();
19 return;
20 }
21
22 const isReady = editor.__unstableIsEditorReady();
23 if ( isReady ) {
24 closeListener();
25 requestAnimationFrame( () => injectFormidableBlock() );
26 }
27 }
28 );
29 }
30
31 document.addEventListener( 'DOMContentLoaded', handleDomReady );
32
33 const injectFormidableBlock = () => {
34 insertedBlock = wp.blocks.createBlock(
35 '<?php echo esc_js( $block_name ); ?>',
36 { <?php echo esc_js( $object_key ); ?>: '<?php echo absint( $object_id ); ?>' }
37 );
38
39 const getBlocks = () => wp.data.select( 'core/editor' ).getBlocks();
40 const blockList = getBlocks();
41
42 const closeListener = wp.data.subscribe(
43 () => {
44 const currentBlocks = getBlocks();
45 if ( currentBlocks === blockList ) {
46 return;
47 }
48
49 closeListener();
50 const block = currentBlocks[ currentBlocks.length - 1 ];
51 setTimeout(
52 () => document.getElementById( 'block-' + block.clientId ).scrollIntoView({ behavior: 'smooth' }),
53 1
54 );
55 }
56 );
57
58 wp.data.dispatch( 'core/block-editor' ).insertBlocks( insertedBlock );
59 };
60 }() );
61 </script>
62