Skip to content

Commit

Permalink
Standarize the blockEditor import
Browse files Browse the repository at this point in the history
- Now use @wordpress/block-editor instead
  • Loading branch information
dantovbein committed May 8, 2023
1 parent 7c5cb4f commit 51401b5
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 34 deletions.
4 changes: 2 additions & 2 deletions assets/src/block-templates/edit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useBlockProps} from '@wordpress/block-editor';
import {useBlockProps, InnerBlocks} from '@wordpress/block-editor';

export default function(template, templateLock = false) {
return props => {
return (
<div {...useBlockProps()}>
{
wp.element.createElement(wp.blockEditor.InnerBlocks, {
wp.element.createElement(InnerBlocks, {
template: template(props.attributes ?? {}),
templateLock,
})
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Accordion/AccordionEditor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Fragment, useState} from '@wordpress/element';
import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, RichText} from '@wordpress/block-editor';
import {URLInput} from '../../components/URLInput/URLInput';
import {
PanelBody,
Expand All @@ -9,7 +9,6 @@ import {

import {debounce} from 'lodash';

const {RichText} = wp.blockEditor;
const {__} = wp.i18n;

// Renders the editor view
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Articles/ArticlesEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
PanelBody,
Tooltip,
} from '@wordpress/components';
import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, RichText} from '@wordpress/block-editor';
import withCharacterCounter from '../../components/withCharacterCounter/withCharacterCounter';
import TagSelector from '../../components/TagSelector/TagSelector';
import {PostSelector} from '../../components/PostSelector/PostSelector';
Expand All @@ -15,7 +15,6 @@ import {ArticlesList} from './ArticlesList';
import {useArticlesFetch} from './useArticlesFetch';
import {useSelect} from '@wordpress/data';

const {RichText} = wp.blockEditor;
const {__} = wp.i18n;

const TextControl = withCharacterCounter(BaseTextControl);
Expand Down
2 changes: 1 addition & 1 deletion assets/src/blocks/CarouselHeader/Caption.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {RichText} = wp.blockEditor;
import {RichText} from '@wordpress/block-editor';
const {__} = wp.i18n;

export const Caption = ({slide, index, changeSlideAttribute}) => (
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Columns/ColumnsEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@wordpress/components';
import {useSelect} from '@wordpress/data';
import {useEffect} from '@wordpress/element';
import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, RichText} from '@wordpress/block-editor';

import {URLInput} from '../../components/URLInput/URLInput';
import {EditableColumns} from './EditableColumns';
Expand All @@ -14,7 +14,6 @@ import {MAX_COLUMNS_AMOUNT, MIN_COLUMNS_AMOUNT} from './ColumnConstants';
import {getStyleFromClassName} from '../getStyleFromClassName';

const {__} = wp.i18n;
const {RichText} = wp.blockEditor;

const renderEdit = (attributes, toAttribute, setAttributes, isSelected) => {
const {columns} = attributes;
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Columns/EditableColumns.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {LAYOUT_NO_IMAGE, LAYOUT_ICONS, LAYOUT_TASKS, LAYOUT_IMAGES} from './ColumnConstants';
import {MediaUpload, MediaUploadCheck} from '@wordpress/block-editor';
import {MediaUpload, MediaUploadCheck, RichText} from '@wordpress/block-editor';
import {Button} from '@wordpress/components';
import {ColumnsImagePlaceholder} from './ColumnsImagePlaceholder';
import {ImageHoverControls} from '../../components/ImageHoverControls';

const {__} = wp.i18n;
const {RichText} = wp.blockEditor;

export const EditableColumns = ({
columns_block_style,
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Counter/CounterEditor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, Fragment} from '@wordpress/element';
import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, RichText} from '@wordpress/block-editor';
import {
TextControl,
TextareaControl,
Expand All @@ -10,7 +10,6 @@ import {URLInput} from '../../components/URLInput/URLInput';

import {CounterFrontend} from './CounterFrontend';

const {RichText} = wp.blockEditor;
const {__} = wp.i18n;

export class CounterEditor extends Component {
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Covers/CoversEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@wordpress/components';
import {useEffect} from '@wordpress/element';

import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, RichText} from '@wordpress/block-editor';
import TagSelector from '../../components/TagSelector/TagSelector';
import {PostSelector} from '../../components/PostSelector/PostSelector';
import PostTypeSelector from '../../components/PostTypeSelector/PostTypeSelector';
Expand All @@ -17,7 +17,6 @@ import {useCovers} from './useCovers';
import {getStyleFromClassName} from '../getStyleFromClassName';
import {CoversCarouselLayout} from './CoversCarouselLayout';

const {RichText} = wp.blockEditor;
const {__} = wp.i18n;

const renderEdit = (attributes, toAttribute, setAttributes) => {
Expand Down
5 changes: 1 addition & 4 deletions assets/src/blocks/Gallery/GalleryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import {GalleryCarousel} from './GalleryCarousel';
import {GalleryThreeColumns} from './GalleryThreeColumns';
import {GalleryGrid} from './GalleryGrid';
import {useGalleryImages} from './useGalleryImages';
import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, MediaPlaceholder, MediaUploadCheck, RichText} from '@wordpress/block-editor';

import {MediaPlaceholder, MediaUploadCheck} from '@wordpress/blockEditor';

const {RichText} = wp.blockEditor;
const {__} = wp.i18n;

const renderEdit = (attributes, setAttributes, isSelected) => {
Expand Down
4 changes: 2 additions & 2 deletions assets/src/blocks/Happypoint/HappypointEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {USE_NONE, USE_IFRAME_URL, USE_EMBED_CODE} from './HappyPointConstants';

import {debounce} from 'lodash';

const {
import {
InspectorControls,
BlockControls,
MediaUpload,
MediaUploadCheck,
} = wp.blockEditor;
} from '@wordpress/block-editor';

const {__} = wp.i18n;

Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Media/MediaEditor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Fragment, useCallback} from '@wordpress/element';
import {PanelBody, TextControl} from '@wordpress/components';
import {MediaPlaceholder, InspectorControls} from '@wordpress/block-editor';
import {MediaPlaceholder, InspectorControls, RichText} from '@wordpress/block-editor';
import {debounce} from 'lodash';

import {MediaElementVideo} from './MediaElementVideo';
Expand All @@ -10,7 +10,6 @@ import {lacksAttributes} from './MediaBlock';
const {__} = wp.i18n;
const {apiFetch} = wp;
const {addQueryArgs} = wp.url;
const {RichText} = wp.blockEditor;

const MediaInspectorOptions = ({attributes, setAttributes}) => {
const {media_url} = attributes;
Expand Down
2 changes: 1 addition & 1 deletion assets/src/blocks/SocialMedia/SocialMediaEditorScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
RadioControl,
SelectControl,
PanelBody,
RichText,
} from '@wordpress/components';
import {SocialMediaEmbed} from './SocialMediaEmbed';
import {URLInput} from '../../components/URLInput/URLInput';
Expand All @@ -17,7 +18,6 @@ import {
ALLOWED_OEMBED_PROVIDERS,
} from './SocialMediaConstants.js';

const {RichText} = wp.blockEditor;
const {__} = wp.i18n;
const {apiFetch} = wp;
const {addQueryArgs} = wp.url;
Expand Down
5 changes: 1 addition & 4 deletions assets/src/blocks/SocialMediaCards/SocialMediaCards.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {Component, Fragment} from '@wordpress/element';
import {Preview} from '../../components/Preview';
import {
MediaUpload,
MediaUploadCheck,
} from '@wordpress/block-editor';
import {MediaUpload, MediaUploadCheck} from '@wordpress/block-editor';

import {
TextControl,
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Submenu/SubmenuEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import {Fragment} from '@wordpress/element';
import {Button, PanelBody} from '@wordpress/components';
import {SubmenuLevel} from './SubmenuLevel';
import {SubmenuItems} from './SubmenuItems';
import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, RichText} from '@wordpress/block-editor';
import {getSubmenuStyle} from './getSubmenuStyle';
import {makeHierarchical} from './makeHierarchical';
import {getHeadingsFromBlocks} from './getHeadingsFromBlocks';
import {useSelect} from '@wordpress/data';
import {deepClone} from '../../functions/deepClone';

const {__} = wp.i18n;
const {RichText} = wp.blockEditor;

const renderEdit = (attributes, setAttributes) => {
function addLevel() {
Expand Down
4 changes: 2 additions & 2 deletions assets/src/blocks/TakeActionBoxout/TakeActionBoxoutEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const {__} = wp.i18n;
// Planet 4 settings (Planet 4 >> Defaults content >> Take Action Covers default button text).
const DEFAULT_BUTTON_TEXT = window.p4bk_vars.take_action_covers_button_text || __('Take action', 'planet4-blocks');

const {
import {
RichText,
BlockControls,
MediaUpload,
MediaUploadCheck,
} = wp.blockEditor;
} from '@wordpress/block-editor';

export const TakeActionBoxoutEditor = ({
attributes,
Expand Down
3 changes: 1 addition & 2 deletions assets/src/blocks/Timeline/TimelineEditorScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
CheckboxControl,
Tooltip,
} from '@wordpress/components';
import {InspectorControls} from '@wordpress/block-editor';
import {InspectorControls, RichText} from '@wordpress/block-editor';

import {URLInput} from '../../components/URLInput/URLInput';
import {useScript} from '../../components/useScript/useScript';
Expand All @@ -15,7 +15,6 @@ import {languages} from './TimelineLanguages';
import {URLDescriptionHelp} from './URLDescriptionHelp';
import {debounce, noConflict} from 'lodash';

const {RichText} = wp.blockEditor;
const {__} = wp.i18n;
const TIMELINE_JS_VERSION = '3.8.12';

Expand Down

0 comments on commit 51401b5

Please sign in to comment.