Content lock all blocks in the product editor (#37382)

* Lock all blocks in the product editor to content only

* Add changelog entry

* Add content role to summary field to allow editing

* Remove unused BlockControls
This commit is contained in:
Joshua T Flowers 2023-03-28 15:18:00 -07:00 committed by GitHub
parent 2f4f0bea54
commit 49cde4cad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 6 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Content lock all blocks in the product editor

View File

@ -9,7 +9,8 @@
"textdomain": "default",
"attributes": {
"name": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
}
},
"supports": {

View File

@ -17,6 +17,10 @@
},
"label": {
"type": "string"
},
"content": {
"type": "string",
"__experimentalRole": "content"
}
},
"supports": {

View File

@ -9,7 +9,8 @@
"textdomain": "default",
"attributes": {
"name": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
},
"label": {
"type": "string"

View File

@ -21,7 +21,10 @@
"multiple": true,
"reusable": false,
"inserter": false,
"lock": false
"lock": false,
"__experimentalToolbar": false
},
"usesContext": [ "selectedTab" ]
"usesContext": [ "selectedTab" ],
"editorStyle": "file:./editor.css",
"templateLock": "contentOnly"
}

View File

@ -1,9 +1,9 @@
/**
* External dependencies
*/
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import classnames from 'classnames';
import { createElement } from '@wordpress/element';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import type { BlockAttributes } from '@wordpress/blocks';
/**
@ -39,7 +39,9 @@ export function Edit( {
role="tabpanel"
className={ classes }
>
<InnerBlocks templateLock="all" />
{ /* eslint-disable-next-line @typescript-eslint/ban-ts-comment */ }
{ /* @ts-ignore Content only template locking does exist for this property. */ }
<InnerBlocks templateLock="contentOnly" />
</div>
</div>
);

View File

@ -2,4 +2,9 @@
&:not(.is-selected) {
display: none;
}
}
// Remove the Gutenberg selected outline.
.wp-block-woocommerce-product-tab:after {
display: none;
}