diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 6f7314d5e5188..c4cff0cf5f73e 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -827,6 +827,15 @@ A cloud of your most used tags. ([Source](https://github.com/WordPress/gutenberg - **Supports:** align, anchor, spacing (margin, padding), typography (lineHeight), ~~html~~ - **Attributes:** largestFontSize, numberOfTags, showTagCounts, smallestFontSize, taxonomy +## Template Content + +Use template content to replace the template placeholder. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/template-content)) + +- **Name:** core/template-content +- **Category:** widgets +- **Supports:** ~~className~~, ~~customClassName~~, ~~html~~, ~~inserter~~ +- **Attributes:** content, name + ## Template Part Edit the different global regions of your site, like the header, footer, sidebar, or create your own. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/template-part)) diff --git a/lib/blocks.php b/lib/blocks.php index bbee108b71c5f..cf13f4270f2e5 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -40,6 +40,7 @@ function gutenberg_reregister_core_block_types() { 'spacer', 'table', 'table-of-contents', + 'template-content', 'text-columns', 'verse', 'video', diff --git a/lib/experimental/pattern.php b/lib/experimental/pattern.php new file mode 100644 index 0000000000000..4846477153797 --- /dev/null +++ b/lib/experimental/pattern.php @@ -0,0 +1,42 @@ + esc_html__( 'Get In Touch', 'default' ), + 'categories' => array( 'call-to-action' ), + 'content' => implode( + '', + array( + '', + '

', + '', + '', + '
', + '
', + '

' . esc_html__( '20 Cooper Avenue', 'default' ) . '
' . esc_html__( 'New York, New York 10023', 'default' ) . '

', + '
', + '', + '', + '
', + '

' . esc_html__( '(555) 555-5555', 'default' ) . '
' . esc_html__( 'example@example.com', 'default' ) . '

', + '
', + '
', + '', + '', + '
', + '
' . esc_html__( 'Contact Us', 'default' ) . '
', + '
', + '', + '', + esc_html__( 'Get In Touch', 'default' ), + '', + ) + ), + ) +); diff --git a/lib/load.php b/lib/load.php index b8ec4a4d60784..9352f89a6c400 100644 --- a/lib/load.php +++ b/lib/load.php @@ -103,6 +103,7 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/experimental/kses.php'; require __DIR__ . '/experimental/l10n.php'; require __DIR__ . '/experimental/navigation-fallback.php'; +require __DIR__ . '/experimental/pattern.php'; if ( gutenberg_is_experiment_enabled( 'gutenberg-interactivity-api-core-blocks' ) ) { require __DIR__ . '/experimental/interactivity-api/script-loader.php'; require __DIR__ . '/experimental/interactivity-api/blocks.php'; diff --git a/packages/block-editor/src/components/index.js b/packages/block-editor/src/components/index.js index f113ad3b05f63..4b2295a7c0fff 100644 --- a/packages/block-editor/src/components/index.js +++ b/packages/block-editor/src/components/index.js @@ -84,6 +84,7 @@ export { RichTextToolbarButton, __unstableRichTextInputEvent, } from './rich-text'; +export { default as __experimentalTemplateContent } from './template-content'; export { default as ToolSelector } from './tool-selector'; export { default as __experimentalUnitControl } from './unit-control'; export { default as URLInput } from './url-input'; diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js index 4217d6de58899..09d3410ae8bfb 100644 --- a/packages/block-editor/src/components/rich-text/index.js +++ b/packages/block-editor/src/components/rich-text/index.js @@ -46,6 +46,7 @@ import { useInsertReplacementText } from './use-insert-replacement-text'; import { useFirefoxCompat } from './use-firefox-compat'; import FormatEdit from './format-edit'; import { getMultilineTag, getAllowedFormats } from './utils'; +import TemplateContent from '../template-content'; export const keyboardShortcutContext = createContext(); export const inputEventContext = createContext(); @@ -318,7 +319,7 @@ function RichTextWrapper( } const TagName = tagName; - return ( + const result = ( <> { isSelected && ( @@ -415,6 +416,17 @@ function RichTextWrapper( /> ); + + if ( ! originalValue.startsWith( '' + ); + } + return new Tokenizer( new DecodeEntityParser() ).tokenize( temp ); } catch ( e ) { - logger.warning( 'Malformed HTML detected: %s', html ); + logger.warning( 'Malformed HTML detected: %s', temp ); } return null;