PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / html-parser / admin / HtmlParserFooter.js
jetformbuilder / modules / html-parser / admin Last commit date
HtmlParserButton.js 1 year ago HtmlParserFooter.js 1 year ago HtmlParserModal.js 1 year ago index.js 1 year ago serialize.js 1 year ago
HtmlParserFooter.js
68 lines
1 import { Button, Flex } from '@wordpress/components';
2 import { __ } from '@wordpress/i18n';
3 import apiFetch from '@wordpress/api-fetch';
4 import { useState } from '@wordpress/element';
5 import serialize from './serialize';
6
7 const { parseHTMLtoBlocks } = JetFormBuilderParser;
8
9 const getPostEditUrl = id => {
10 const url = new URL( JetFormBuilderAdmin.edit_url );
11 url.searchParams.set( 'post', id );
12
13 return url.href;
14 };
15
16 export default function HtmlParserFooter( { clearHTML, rawHTML, setShowModal } ) {
17 const [ isBusy, setIsBusy ] = useState( false );
18 const createForm = async () => {
19 setIsBusy( true );
20 try {
21 const blocks = parseHTMLtoBlocks( rawHTML );
22
23 if ( !blocks.length ) {
24 console.error( __( 'JFB: Could not parse blocks', 'jet-form-builder' ), rawHTML );
25 setIsBusy( false );
26 return;
27 }
28
29 const serialized = serialize( blocks );
30
31 const response = await apiFetch( {
32 method: 'POST',
33 path: '/wp/v2/jet-form-builder',
34 data: {
35 title: __( 'Imported HTML Form', 'jet-form-builder' ) + ' ' + new Date().toLocaleString('sv-SE').replace('T', ' '),
36 content: serialized,
37 status: 'publish',
38 },
39 } );
40
41 window.location.href = getPostEditUrl( response.id );
42
43 } catch ( error ) {
44 console.error( 'Failed to create form:', error );
45 setIsBusy( false );
46 }
47 };
48
49 return (
50 <Flex justify="space-between">
51 <Button
52 variant="secondary"
53 onClick={ clearHTML }
54 >
55 { __( 'Back', 'jet-form-builder' ) }
56 </Button>
57 <Button
58 variant="primary"
59 onClick={ createForm }
60 isBusy={ isBusy }
61 disabled={ isBusy }
62 >
63 { __( 'Create Form', 'jet-form-builder' ) }
64 </Button>
65 </Flex>
66 );
67 }
68