plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 15:33:26 -04:00
parent 3751a5a1a6
commit e4e274a9a7
2674 changed files with 0 additions and 507851 deletions

View File

@@ -1,16 +0,0 @@
import React from 'react';
import { RawHTML } from '@wordpress/element';
import { IFormBlockAttributes } from './registerFormBlock';
export default function FormSaveBlock({ attributes }: IFormBlockAttributes) {
const { portalId, formId } = attributes;
if (portalId && formId) {
return (
<RawHTML className="wp-block-leadin-hubspot-form-block">
{`[hubspot portal="${portalId}" id="${formId}" type="form"]`}
</RawHTML>
);
}
return null;
}

View File

@@ -1,14 +0,0 @@
import React, { Fragment } from 'react';
import { pluginPath } from '../../constants/leadinConfig';
import UIImage from '../UIComponents/UIImage';
export default function FormGutenbergPreview() {
return (
<Fragment>
<UIImage
alt="Create a new Hubspot Form"
src={`${pluginPath}/public/assets/images/hubspot-form.png`}
/>
</Fragment>
);
}

View File

@@ -1,73 +0,0 @@
import React from 'react';
import * as WpBlocksApi from '@wordpress/blocks';
import SprocketIcon from '../Common/SprocketIcon';
import FormBlockSave from './FormBlockSave';
import { connectionStatus } from '../../constants/leadinConfig';
import FormGutenbergPreview from './FormGutenbergPreview';
import ErrorHandler from '../../shared/Common/ErrorHandler';
import FormEdit from '../../shared/Form/FormEdit';
import ConnectionStatus from '../../shared/enums/connectionStatus';
import { __ } from '@wordpress/i18n';
import { isFullSiteEditor } from '../../utils/withMetaData';
export interface IFormBlockAttributes {
attributes: {
portalId: string;
formId: string;
preview?: boolean;
formName: string;
};
}
export interface IFormBlockProps extends IFormBlockAttributes {
setAttributes: Function;
isSelected: boolean;
context?: any;
}
export default function registerFormBlock() {
const editComponent = (props: IFormBlockProps) => {
if (props.attributes.preview) {
return <FormGutenbergPreview />;
} else if (connectionStatus === ConnectionStatus.Connected) {
return <FormEdit {...props} origin="gutenberg" preview={true} />;
} else {
return <ErrorHandler status={401} />;
}
};
// We do not support the full site editor: https://issues.hubspotcentral.com/browse/WP-1033
if (!WpBlocksApi || isFullSiteEditor()) {
return null;
}
WpBlocksApi.registerBlockType('leadin/hubspot-form-block', {
title: __('HubSpot Form', 'leadin'),
description: __('Select and embed a HubSpot form', 'leadin'),
icon: SprocketIcon,
category: 'leadin-blocks',
attributes: {
portalId: {
type: 'string',
default: '',
} as WpBlocksApi.BlockAttribute<string>,
formId: {
type: 'string',
} as WpBlocksApi.BlockAttribute<string>,
formName: {
type: 'string',
} as WpBlocksApi.BlockAttribute<string>,
preview: {
type: 'boolean',
default: false,
} as WpBlocksApi.BlockAttribute<boolean>,
},
example: {
attributes: {
preview: true,
},
},
edit: editComponent,
save: props => <FormBlockSave {...props} />,
});
}