Skip to content

Commit

Permalink
Merge pull request #255 from bacoords/reorder-editor-js
Browse files Browse the repository at this point in the history
Cleans up the order of functions in editorjs to be more intuitive
  • Loading branch information
bacoords authored Apr 25, 2024
2 parents 1a0d20a + 8bd57ce commit 0ad7595
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions src/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,41 @@ import {
import { dispatch } from '@wordpress/data';
import domReady from '@wordpress/dom-ready';

/**
* Register block styles
*
* @type {Object} Add the names of blocks and styles to register here
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/
*/
const registerBlockStyles = {
// "core/cover": [
// {
// name: "hero",
// label: "Hero",
// },
// ]
};

/**
* Register block variations
*
* @type {Object} Add the names of blocks and variations to register here
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/
*/
const registerBlockVariations = {
// "core/columns": {
// name: "three-columns-wide-left",
// title: "50 / 25 / 25",
// description: "Three columns; wide left column",
// innerBlocks: [
// ["core/column", { width: "50%" }],
// ["core/column", { width: "25%" }],
// ["core/column", { width: "25%" }],
// ],
// scope: ["block"],
// },
};

/**
* Unregister blocks
*
Expand Down Expand Up @@ -41,21 +76,6 @@ const unregisterBlockStyles = {
// "core/button": "outline",
};

/**
* Register block styles
*
* @type {Object} Add the names of blocks and styles to register here
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/
*/
const registerBlockStyles = {
// "core/cover": [
// {
// name: "hero",
// label: "Hero",
// },
// ]
};

/**
* Remove block variations
*
Expand All @@ -66,32 +86,18 @@ const unregisterBlockVariations = {
// "core/columns": "two-columns-two-thirds-one-third",
};

/**
* Register block variations
*
* @type {Object} Add the names of blocks and variations to register here
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/
*/
const registerBlockVariations = {
// "core/columns": {
// name: "three-columns-wide-left",
// title: "50 / 25 / 25",
// description: "Three columns; wide left column",
// innerBlocks: [
// ["core/column", { width: "50%" }],
// ["core/column", { width: "25%" }],
// ["core/column", { width: "25%" }],
// ],
// scope: ["block"],
// },
};

/**
* Here we hook into the editor initialization and unregister the blocks,
* remove editor panels, remove block styles, remove block variations,
* register block styles, and register block variations – all as defined above.
*/
domReady( function () {
Object.keys( registerBlockStyles ).forEach( ( block ) => {
registerBlockStyle( block, registerBlockStyles[ block ] );
} );
Object.keys( registerBlockVariations ).forEach( ( block ) => {
registerBlockVariation( block, registerBlockVariations[ block ] );
} );
unregisterBlocks.forEach( ( block ) => {
unregisterBlockType( block );
} );
Expand All @@ -109,10 +115,4 @@ domReady( function () {
Object.keys( unregisterBlockVariations ).forEach( ( block ) => {
unregisterBlockVariation( block, unregisterBlockVariations[ block ] );
} );
Object.keys( registerBlockStyles ).forEach( ( block ) => {
registerBlockStyle( block, registerBlockStyles[ block ] );
} );
Object.keys( registerBlockVariations ).forEach( ( block ) => {
registerBlockVariation( block, registerBlockVariations[ block ] );
} );
} );

0 comments on commit 0ad7595

Please sign in to comment.