diff --git a/block-filters/heading/index.php b/block-filters/heading/index.php new file mode 100644 index 00000000..1ae3d3fc --- /dev/null +++ b/block-filters/heading/index.php @@ -0,0 +1,36 @@ + +
diff --git a/blocks/heading/block.json b/blocks/heading/block.json new file mode 100644 index 00000000..442f5f75 --- /dev/null +++ b/blocks/heading/block.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "wp-newsletter-builder/heading", + "version": "0.1.0", + "title": "Newsletter Heading", + "category": "text", + "icon": "heading", + "description": "Heading wrapper that provides email-friendly enhancements", + "textdomain": "heading", + "editorScript": "file:index.ts", + "editorStyle": "file:index.css", + "style": [ + "file:style-index.css" + ], + "render": "file:render.php", + "attributes": { + "elColor": { + "type": "string", + "default": "#000" + } + } +} \ No newline at end of file diff --git a/blocks/heading/edit.tsx b/blocks/heading/edit.tsx new file mode 100644 index 00000000..9768b65d --- /dev/null +++ b/blocks/heading/edit.tsx @@ -0,0 +1,73 @@ +/** + * Retrieves the translation of text. + * + * @see https://developer.wordpress.org/block-editor/reference-guides/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/reference-guides/packages/packages-block-editor/#useblockprops + */ +import { useBlockProps, InspectorControls, InnerBlocks } from '@wordpress/block-editor'; +import { ColorPicker, PanelBody } from '@wordpress/components'; + +/** + * 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 + */ +// Uncomment this line if you want to import a CSS file for this block. +// import './index.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/reference-guides/block-api/block-edit-save/#edit + * + * @return {WPElement} Element to render. + */ +interface EditProps { + attributes: { + elColor?: string; + }; + setAttributes: (attributes: {}) => void; +} + +export default function Edit({ + attributes: { + elColor = '#000', + }, + setAttributes, +}: EditProps) { + const TEMPLATE = [['core/heading']]; + const headingStyles = { + color: elColor, + }; + + return ( + <> + + +

{__('Text color', 'wp-newsletter-builder')}

+ {/* Using ColorPicker instead of ColorPalette to ensure email-friendly values. */} + setAttributes({ elColor: color })} + /> +
+
+
+ +
+ + ); +} diff --git a/blocks/heading/index.php b/blocks/heading/index.php new file mode 100644 index 00000000..62c586cd --- /dev/null +++ b/blocks/heading/index.php @@ -0,0 +1,21 @@ + { + const blockProps = useBlockProps.save(); + return ( +
+ {/* @ts-ignore */} + +
+ ); + }, + title: metadata.title, + }, +); diff --git a/blocks/heading/render.php b/blocks/heading/render.php new file mode 100644 index 00000000..84e246f0 --- /dev/null +++ b/blocks/heading/render.php @@ -0,0 +1,16 @@ +. + * @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered. + * + * @package wp-newsletter-builder + */ + +$wp_newsletter_builder_heading_color = $attributes['elColor'] ?? ''; +?> +
+ +
\ No newline at end of file diff --git a/blocks/list/block.json b/blocks/list/block.json new file mode 100644 index 00000000..58f50262 --- /dev/null +++ b/blocks/list/block.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "wp-newsletter-builder/list", + "version": "0.1.0", + "title": "Newsletter List", + "category": "text", + "icon": "editor-ul", + "description": "List wrapper that provides email-friendly enhancements", + "textdomain": "list", + "editorScript": "file:index.ts", + "editorStyle": "file:index.css", + "style": [ + "file:style-index.css" + ], + "render": "file:render.php", + "attributes": { + "elColor": { + "type": "string", + "default": "#000" + } + } +} \ No newline at end of file diff --git a/blocks/list/edit.tsx b/blocks/list/edit.tsx new file mode 100644 index 00000000..6268c885 --- /dev/null +++ b/blocks/list/edit.tsx @@ -0,0 +1,73 @@ +/** + * Retrieves the translation of text. + * + * @see https://developer.wordpress.org/block-editor/reference-guides/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/reference-guides/packages/packages-block-editor/#useblockprops + */ +import { useBlockProps, InspectorControls, InnerBlocks } from '@wordpress/block-editor'; +import { ColorPicker, PanelBody } from '@wordpress/components'; + +/** + * 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 + */ +// Uncomment this line if you want to import a CSS file for this block. +// import './index.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/reference-guides/block-api/block-edit-save/#edit + * + * @return {WPElement} Element to render. + */ +interface EditProps { + attributes: { + elColor?: string; + }; + setAttributes: (attributes: {}) => void; +} + +export default function Edit({ + attributes: { + elColor = '#000', + }, + setAttributes, +}: EditProps) { + const TEMPLATE = [['core/list']]; + const listStyles = { + color: elColor, + }; + + return ( + <> + + +

{__('Text color', 'wp-newsletter-builder')}

+ {/* Using ColorPicker instead of ColorPalette to ensure email-friendly values. */} + setAttributes({ elColor: color })} + /> +
+
+
+ +
+ + ); +} diff --git a/blocks/list/index.php b/blocks/list/index.php new file mode 100644 index 00000000..6f484f99 --- /dev/null +++ b/blocks/list/index.php @@ -0,0 +1,21 @@ + { + const blockProps = useBlockProps.save(); + return ( +
+ {/* @ts-ignore */} + +
+ ); + }, + title: metadata.title, + }, +); diff --git a/blocks/list/render.php b/blocks/list/render.php new file mode 100644 index 00000000..bd3d75c0 --- /dev/null +++ b/blocks/list/render.php @@ -0,0 +1,17 @@ +. + * @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered. + * + * @package wp-newsletter-builder + */ + +$wp_newsletter_builder_list_color = $attributes['elColor'] ?? ''; +?> + +
+ +
diff --git a/blocks/paragraph/block.json b/blocks/paragraph/block.json new file mode 100644 index 00000000..c7aa278e --- /dev/null +++ b/blocks/paragraph/block.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "wp-newsletter-builder/paragraph", + "version": "0.1.0", + "title": "Newsletter Paragraph", + "category": "text", + "icon": "editor-paragraph", + "description": "Paragraph wrapper that provides email-friendly enhancements", + "textdomain": "paragraph", + "editorScript": "file:index.ts", + "editorStyle": "file:index.css", + "style": [ + "file:style-index.css" + ], + "render": "file:render.php", + "attributes": { + "elColor": { + "type": "string", + "default": "#000" + } + } +} \ No newline at end of file diff --git a/blocks/paragraph/edit.tsx b/blocks/paragraph/edit.tsx new file mode 100644 index 00000000..faea1815 --- /dev/null +++ b/blocks/paragraph/edit.tsx @@ -0,0 +1,73 @@ +/** + * Retrieves the translation of text. + * + * @see https://developer.wordpress.org/block-editor/reference-guides/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/reference-guides/packages/packages-block-editor/#useblockprops + */ +import { useBlockProps, InspectorControls, InnerBlocks } from '@wordpress/block-editor'; +import { ColorPicker, PanelBody } from '@wordpress/components'; + +/** + * 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 + */ +// Uncomment this line if you want to import a CSS file for this block. +// import './index.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/reference-guides/block-api/block-edit-save/#edit + * + * @return {WPElement} Element to render. + */ +interface EditProps { + attributes: { + elColor?: string; + }; + setAttributes: (attributes: {}) => void; +} + +export default function Edit({ + attributes: { + elColor = '#000', + }, + setAttributes, +}: EditProps) { + const TEMPLATE = [['core/paragraph']]; + const paragraphStyles = { + color: elColor, + }; + + return ( + <> + + +

{__('Text color', 'wp-newsletter-builder')}

+ {/* Using ColorPicker instead of ColorPalette to ensure email-friendly values. */} + setAttributes({ elColor: color })} + /> +
+
+
+ +
+ + ); +} diff --git a/blocks/paragraph/index.php b/blocks/paragraph/index.php new file mode 100644 index 00000000..d312b20a --- /dev/null +++ b/blocks/paragraph/index.php @@ -0,0 +1,21 @@ + { + const blockProps = useBlockProps.save(); + return ( +
+ {/* @ts-ignore */} + +
+ ); + }, + title: metadata.title, + }, +); diff --git a/blocks/paragraph/render.php b/blocks/paragraph/render.php new file mode 100644 index 00000000..a1bc44a0 --- /dev/null +++ b/blocks/paragraph/render.php @@ -0,0 +1,17 @@ +. + * @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered. + * + * @package wp-newsletter-builder + */ + +$wp_newsletter_builder_paragraph_color = $attributes['elColor'] ?? ''; +?> + +
+ +
diff --git a/package-lock.json b/package-lock.json index fb6a1cf5..fcee7bce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13112,11 +13112,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -17046,9 +17046,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, diff --git a/plugin.php b/plugin.php index 0fe5667b..347915dc 100644 --- a/plugin.php +++ b/plugin.php @@ -3,7 +3,7 @@ * Plugin Name: Newsletter Builder * Plugin URI: https://github.com/alleyinteractive/wp-newsletter-builder * Description: Interface to manage email newsletters - * Version: 0.3.18 + * Version: 0.3.19 * Author: Alley Interactive * Author URI: https://github.com/alleyinteractive/wp-newsletter-builder * Requires at least: 6.2 @@ -50,7 +50,9 @@ function () { require_once __DIR__ . '/src/meta.php'; require_once __DIR__ . '/src/utils.php'; require_once __DIR__ . '/block-filters/separator/index.php'; - +require_once __DIR__ . '/block-filters/heading/index.php'; +require_once __DIR__ . '/block-filters/paragraph/index.php'; +require_once __DIR__ . '/block-filters/list/index.php'; require_once __DIR__ . '/plugins/newsletter-from-post/index.php'; require_once __DIR__ . '/plugins/newsletter-status/index.php'; diff --git a/webpack.config.js b/webpack.config.js index 1d308479..828cd8c1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -25,6 +25,9 @@ module.exports = (env, { mode }) => ({ }, { // All other custom entry points can be included here. 'wp-newsletter-builder-separator/index': './block-filters/separator', + 'wp-newsletter-builder-heading/index': './block-filters/heading', + 'wp-newsletter-builder-paragraph/index': './block-filters/paragraph', + 'wp-newsletter-builder-list/index': './block-filters/list', 'wp-newsletter-builder-from-post/index': './plugins/newsletter-from-post', 'newsletter-status/index': './plugins/newsletter-status', }),