plugin updates
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import { leadinPluginVersion, pluginPath } from '../../constants/leadinConfig';
|
||||
import { useRefEffect } from '@wordpress/compose';
|
||||
|
||||
function StylesheetErrorBondary({ children }: React.PropsWithChildren) {
|
||||
const ref = useRefEffect(element => {
|
||||
const { ownerDocument } = element;
|
||||
if (
|
||||
ownerDocument &&
|
||||
!ownerDocument.getElementById('leadin-gutenberg-css')
|
||||
) {
|
||||
const link = ownerDocument.createElement('link');
|
||||
link.id = 'leadin-gutenberg-css';
|
||||
link.rel = 'stylesheet';
|
||||
link.href = `${pluginPath}/build/gutenberg.css?ver=${leadinPluginVersion}`;
|
||||
ownerDocument.head.appendChild(link);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return <div ref={ref}>{children}</div>;
|
||||
}
|
||||
|
||||
export default StylesheetErrorBondary;
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import * as WpBlocksApi from '@wordpress/blocks';
|
||||
import SprocketIcon from '../Common/SprocketIcon';
|
||||
import StylesheetErrorBondary from '../Common/StylesheetErrorBondary';
|
||||
import FormBlockSave from './FormBlockSave';
|
||||
import { connectionStatus } from '../../constants/leadinConfig';
|
||||
import FormGutenbergPreview from './FormGutenbergPreview';
|
||||
@@ -27,17 +28,28 @@ export interface IFormBlockProps extends IFormBlockAttributes {
|
||||
|
||||
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} />;
|
||||
}
|
||||
const isPreview = props.attributes.preview;
|
||||
const isConnected = connectionStatus === ConnectionStatus.Connected;
|
||||
return (
|
||||
<StylesheetErrorBondary>
|
||||
{isPreview ? (
|
||||
<FormGutenbergPreview />
|
||||
) : isConnected ? (
|
||||
<FormEdit
|
||||
{...props}
|
||||
origin="gutenberg"
|
||||
preview={true}
|
||||
fullSiteEditor={isFullSiteEditor()}
|
||||
/>
|
||||
) : (
|
||||
<ErrorHandler status={401} />
|
||||
)}
|
||||
</StylesheetErrorBondary>
|
||||
);
|
||||
};
|
||||
|
||||
// We do not support the full site editor: https://issues.hubspotcentral.com/browse/WP-1033
|
||||
if (!WpBlocksApi || isFullSiteEditor()) {
|
||||
if (!WpBlocksApi) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import MeetingEdit from '../../shared/Meeting/MeetingEdit';
|
||||
import ErrorHandler from '../../shared/Common/ErrorHandler';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isFullSiteEditor } from '../../utils/withMetaData';
|
||||
import StylesheetErrorBondary from '../Common/StylesheetErrorBondary';
|
||||
|
||||
const ConnectionStatus = {
|
||||
Connected: 'Connected',
|
||||
@@ -28,17 +29,28 @@ export interface IMeetingBlockProps extends IMeetingBlockAttributes {
|
||||
|
||||
export default function registerMeetingBlock() {
|
||||
const editComponent = (props: IMeetingBlockProps) => {
|
||||
if (props.attributes.preview) {
|
||||
return <MeetingGutenbergPreview />;
|
||||
} else if (connectionStatus === ConnectionStatus.Connected) {
|
||||
return <MeetingEdit {...props} preview={true} origin="gutenberg" />;
|
||||
} else {
|
||||
return <ErrorHandler status={401} />;
|
||||
}
|
||||
const isPreview = props.attributes.preview;
|
||||
const isConnected = connectionStatus === ConnectionStatus.Connected;
|
||||
return (
|
||||
<StylesheetErrorBondary>
|
||||
{isPreview ? (
|
||||
<MeetingGutenbergPreview />
|
||||
) : isConnected ? (
|
||||
<MeetingEdit
|
||||
{...props}
|
||||
preview={true}
|
||||
origin="gutenberg"
|
||||
fullSiteEditor={isFullSiteEditor()}
|
||||
/>
|
||||
) : (
|
||||
<ErrorHandler status={401} />
|
||||
)}
|
||||
</StylesheetErrorBondary>
|
||||
);
|
||||
};
|
||||
|
||||
// We do not support the full site editor: https://issues.hubspotcentral.com/browse/WP-1033
|
||||
if (!WpBlocksApi || isFullSiteEditor()) {
|
||||
if (!WpBlocksApi) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { BackgroudAppContext } from '../../iframe/useBackgroundApp';
|
||||
import { refreshToken } from '../../constants/leadinConfig';
|
||||
import { getOrCreateBackgroundApp } from '../../utils/backgroundAppUtils';
|
||||
import { isFullSiteEditor } from '../../utils/withMetaData';
|
||||
|
||||
export function registerHubspotSidebar() {
|
||||
const ContentTypeLabelStyle = styled.div`
|
||||
@@ -27,7 +28,7 @@ export function registerHubspotSidebar() {
|
||||
);
|
||||
|
||||
const LeadinPluginSidebar = ({ postType }: { postType: string }) =>
|
||||
postType ? (
|
||||
postType && !isFullSiteEditor() ? (
|
||||
<PluginSidebar
|
||||
name="leadin"
|
||||
title="HubSpot"
|
||||
|
||||
Reference in New Issue
Block a user