-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new block-support example project Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Auto analyze new project Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Update dependencies Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove hardcoded theme.json Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Ignore globalStylesheet.css Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Reduce example to just block things Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add newline to EOF Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Reduce example Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Update lockfile after merge Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Constrain layout using existing core class Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Not being used Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Irrelevant comment Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Scaffold out new plugin files Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add new dependencies Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add blockset command Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add new command to block support example Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Register new REST endpoint to handle unzipping blocks Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Fix example project deps Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Fix namespace issue Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Refactor into testable functions Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Mock custom block Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Ignore .faust Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Fix namespacing issues in WP plugin Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Clean up comments Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Improve readability Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add deps Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add second block example to test blockset Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Export functions for tests Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove unused jest-dom in CLI package Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove unused package Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add new utility function Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Ignore for tests Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Refactor blockset command Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * New line at EOF Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Linting fixes Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Return true upon success Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Use available logging methods Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove code already in handle_uploaded_blockset & setup translations Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add missing dep Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Linting fixes Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Linting fixes Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Resolve merge conflicts Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Feat: Add compileBlocks step. * Automatically load custom blocks from uploads Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Fix enqueues from the uploads directory Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Fix linting issues Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Feat: Check if project uses yarn when compiling blocks * Use enqueue_block_editor_assets to avoid unnecessary runs Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove explicit registration using args Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add required titles Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Correct the asset src for the blocks in uploads Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Linting fixes Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove unused functions Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Deps: Add wp-scripts in peer deps. * Chore: Add changeset. * Deps: Update rimraf * Chore: Update deps. * Refactor: Update hasYarn * Chore: Update package-lock * Chore: update package-lock again * Chore: add missing export. * Chore: remove faust blockset from predev,prebuild * Fix blocks missing from WPGraphQL & prevent unnecessary block registrations Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Fix linting issues Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Example: Add block using `registerFaustBlock` helper * Refactor: Update block comments * Add plugin tests Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add Plugin Tests (#1601) * Add plugin tests Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add test coverage for utility functions Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> --------- Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove orphaned test Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Track possibleTypes & globalStylesheet generated files Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Build possibleTypes Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Add @wordpress/scripts to block-support-example Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Auto run blockset in block example Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Ignore Faust generated files Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Remove previously tracked file Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Fix version regression from merge conflict Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> * Refactor: Change block-C as block-B * Fix: Remove @ts-ignore comment. * CI/CD fix tests with faustwp-cli * Example block support: Remove blockset. * Chore: Code review fixes. * Chore: add Component.fragments * Chore: Update package-lock.json * Chore: Add gql missing import. * Tests: Update fromThemeJson.test snapshot. * Style: Add block styles in front-end * Styles: Consistent styles fixed. * CI/CD: Fix test cases. * Test: Update CoreCode test snapshot. * CI/CD: Update types in Toolbar.test.tsx * CI/CD: Remove examples/next/block-support from bundle analysis. --------- Signed-off-by: Joe Fusco <joe.fusco@wpengine.com> Co-authored-by: theodesp <328805+theodesp@users.noreply.github.com>
- Loading branch information
1 parent
3722ab3
commit c29f83d
Showing
41 changed files
with
13,567 additions
and
24,827 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@faustwp/cli': minor | ||
'@faustwp/wordpress-plugin': minor | ||
--- | ||
|
||
Add blockset command in @faust/cli and faustwp plugin. | ||
|
||
Add your blocks inside `wp-blocks` folder. Then run `faust blockset` to compile and upload the blocks into WordPress. Blocks will be available in the editor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
possibleTypes.json | ||
.faust | ||
globalStylesheet.css | ||
possibleTypes.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "create-block/block-a", | ||
"version": "0.1.0", | ||
"title": "Block A", | ||
"category": "widgets", | ||
"icon": "smiley", | ||
"description": "Example static block scaffolded with Create Block tool.", | ||
"supports": { | ||
"html": false | ||
}, | ||
"textdomain": "block-a", | ||
"editorScript": "file:./index.js", | ||
"editorStyle": "file:./index.css", | ||
"style": "file:./style-index.css" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Retrieves the translation of text. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-i18n/ | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* React hook that is used to mark the block wrapper element. | ||
* It provides all the necessary props like the class name. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps | ||
*/ | ||
import { useBlockProps } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files. | ||
* Those files can contain any CSS code that gets applied to the editor. | ||
* | ||
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css | ||
*/ | ||
import './editor.scss'; | ||
|
||
/** | ||
* The edit function describes the structure of your block in the context of the | ||
* editor. This represents what the editor will render when the block is used. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#edit | ||
* | ||
* @return {WPElement} Element to render. | ||
*/ | ||
export default function Edit() { | ||
return ( | ||
<p {...useBlockProps()}> | ||
{__('Block A – hello from the editor!', 'block-a')} | ||
</p> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* The following styles get applied inside the editor only. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-create-block-block-a { | ||
border: 1px dotted #f00; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Registers a new block provided a unique name and an object defining its behavior. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/ | ||
*/ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files. | ||
* All files containing `style` keyword are bundled together. The code used | ||
* gets applied both to the front of your site and to the editor. | ||
* | ||
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css | ||
*/ | ||
import './style.scss'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Edit from './edit'; | ||
import save from './save'; | ||
import metadata from './block.json'; | ||
|
||
/** | ||
* Every block starts by registering a new block type definition. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/ | ||
*/ | ||
registerBlockType(metadata.name, { | ||
title: 'Block A', | ||
/** | ||
* @see ./edit.js | ||
*/ | ||
edit: Edit, | ||
/** | ||
* @see ./save.js | ||
*/ | ||
save, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Retrieves the translation of text. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-i18n/ | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* React hook that is used to mark the block wrapper element. | ||
* It provides all the necessary props like the class name. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps | ||
*/ | ||
import { useBlockProps } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* The save function defines the way in which the different attributes should | ||
* be combined into the final markup, which is then serialized by the block | ||
* editor into `post_content`. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#save | ||
* | ||
* @return {WPElement} Element to render. | ||
*/ | ||
export default function save() { | ||
return ( | ||
<p {...useBlockProps.save()}> | ||
{__('Block A – hello from the saved content!', 'block-a')} | ||
</p> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* The following styles get applied both on the front of your site | ||
* and in the editor. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-create-block-block-a { | ||
background-color: #21759b; | ||
color: #fff; | ||
padding: 2px; | ||
} |
38 changes: 38 additions & 0 deletions
38
examples/next/block-support/wp-blocks/block-b/Component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
function Component({ style, attributes, children, ...props }) { | ||
const styles = { | ||
...style, | ||
}; | ||
const cssClassName = 'create-block-block-b-message'; | ||
return ( | ||
<div | ||
style={styles} | ||
className={cssClassName} | ||
dangerouslySetInnerHTML={{ __html: attributes.message }} | ||
/> | ||
); | ||
} | ||
|
||
Component.fragments = { | ||
key: `CreateBlockBlockBFragment`, | ||
entry: gql` | ||
fragment CreateBlockBlockBFragment on CreateBlockBlockB { | ||
attributes { | ||
message | ||
} | ||
} | ||
`, | ||
}; | ||
|
||
Component.config = { | ||
name: 'CreateBlockBlockB', | ||
editorFields: { | ||
message: { | ||
type: 'string', | ||
label: 'My Message', | ||
location: 'editor', | ||
}, | ||
}, | ||
}; | ||
export default Component; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "create-block/block-b", | ||
"version": "0.1.0", | ||
"title": "Block B", | ||
"category": "widgets", | ||
"icon": "smiley", | ||
"description": "Example static block scaffolded with Create Block tool.", | ||
"supports": { | ||
"html": false | ||
}, | ||
"attributes": { | ||
"message": { | ||
"type": "string", | ||
"default": "Hello World" | ||
} | ||
}, | ||
"textdomain": "block-b", | ||
"editorScript": "file:./index.js", | ||
"editorStyle": "file:./index.css", | ||
"style": "file:./style-index.css" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { registerFaustBlock } from '@faustwp/block-editor-utils'; | ||
import './style.scss'; | ||
import BlockB from './Component.js' | ||
/** | ||
* Block.json metadata | ||
*/ | ||
import metadata from './block.json'; | ||
/** | ||
* Register React block on the Block Editor | ||
*/ | ||
registerFaustBlock(BlockB, { | ||
blockJson: metadata | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* The following styles get applied both on the front of your site | ||
* and in the editor. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-create-block-block-b { | ||
color: #333; | ||
padding: 2px; | ||
} | ||
|
||
.create-block-block-b-message { | ||
border: 1px solid pink; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.