diff --git a/compile-sass.sh b/compile-sass.sh index 9e52b8489..6f3caf246 100644 --- a/compile-sass.sh +++ b/compile-sass.sh @@ -54,9 +54,11 @@ sass -E 'UTF-8' --cache-location .tmp/sass-cache-23 src/views/gutenberg-blocks/b sass -E 'UTF-8' --cache-location .tmp/sass-cache-24 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-metadata-section-name.css -sass -E 'UTF-8' --cache-location .tmp/sass-cache-25 src/views/gutenberg-blocks/scss/gutenberg-blocks-editor-style.scss:src/assets/css/tainacan-gutenberg-block-common-editor-styles.css +sass -E 'UTF-8' --cache-location .tmp/sass-cache-25 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-metadata-section-description.css -sass -E 'UTF-8' --cache-location .tmp/sass-cache-26 src/views/gutenberg-blocks/scss/gutenberg-blocks-theme-style.scss:src/assets/css/tainacan-gutenberg-block-common-theme-styles.css +sass -E 'UTF-8' --cache-location .tmp/sass-cache-26 src/views/gutenberg-blocks/scss/gutenberg-blocks-editor-style.scss:src/assets/css/tainacan-gutenberg-block-common-editor-styles.css + +sass -E 'UTF-8' --cache-location .tmp/sass-cache-27 src/views/gutenberg-blocks/scss/gutenberg-blocks-theme-style.scss:src/assets/css/tainacan-gutenberg-block-common-theme-styles.css echo "Compilação do Sass Concluído!" exit 0 diff --git a/src/views/gutenberg-blocks/blocks/item-metadata-section/block.json b/src/views/gutenberg-blocks/blocks/item-metadata-section/block.json index e026f14df..03f0db6c7 100644 --- a/src/views/gutenberg-blocks/blocks/item-metadata-section/block.json +++ b/src/views/gutenberg-blocks/blocks/item-metadata-section/block.json @@ -63,7 +63,9 @@ } }, "providesContext": { - "tainacan/itemId": "itemId" + "tainacan/metadataSectionId": "sectionId", + "tainacan/metadataSectionName": "sectionName", + "tainacan/metadataSectionDescription": "sectionDescription" }, "supports": { "align": ["full", "wide"], diff --git a/src/views/gutenberg-blocks/blocks/item-metadata-section/edit.js b/src/views/gutenberg-blocks/blocks/item-metadata-section/edit.js index 102c2c3fa..38a58e177 100644 --- a/src/views/gutenberg-blocks/blocks/item-metadata-section/edit.js +++ b/src/views/gutenberg-blocks/blocks/item-metadata-section/edit.js @@ -98,18 +98,11 @@ export default function ({ attributes, setAttributes, className, isSelected }) { if (sectionName) { metadataSectionTemplate.push([ 'tainacan/metadata-section-name', - { - sectionId: sectionId, - sectionName: sectionName, - } ]); } if (sectionDescription) { metadataSectionTemplate.push([ - 'core/paragraph', - { - content: sectionDescription, - } + 'tainacan/metadata-section-description', ]); } if (sectionMetadata.length) { diff --git a/src/views/gutenberg-blocks/blocks/item-metadata-sections/edit.js b/src/views/gutenberg-blocks/blocks/item-metadata-sections/edit.js index f4efb6f3f..1b2a0a090 100644 --- a/src/views/gutenberg-blocks/blocks/item-metadata-sections/edit.js +++ b/src/views/gutenberg-blocks/blocks/item-metadata-sections/edit.js @@ -124,8 +124,8 @@ export default function ({ attributes, setAttributes, className, isSelected }) {
+ { sectionDescription } +
+ > + ); +}; \ No newline at end of file diff --git a/src/views/gutenberg-blocks/blocks/metadata-section-description/icon.js b/src/views/gutenberg-blocks/blocks/metadata-section-description/icon.js new file mode 100644 index 000000000..9067dba1d --- /dev/null +++ b/src/views/gutenberg-blocks/blocks/metadata-section-description/icon.js @@ -0,0 +1,14 @@ + const { SVG, Path } = wp.components; + + export default ( + + ); + \ No newline at end of file diff --git a/src/views/gutenberg-blocks/blocks/metadata-section-description/index.js b/src/views/gutenberg-blocks/blocks/metadata-section-description/index.js new file mode 100644 index 000000000..f8cd05987 --- /dev/null +++ b/src/views/gutenberg-blocks/blocks/metadata-section-description/index.js @@ -0,0 +1,15 @@ +import tainacanRegisterBlockType from '../../js/compatibility/tainacan-blocks-compat-register.js'; + +import metadata from './block.json'; +import icon from './icon.js'; +import edit from './edit.js'; +import save from './save.js'; +import deprecated from './deprecated.js'; + +tainacanRegisterBlockType({ + metadata, + icon, + edit, + save, + deprecated +}); diff --git a/src/views/gutenberg-blocks/blocks/metadata-section-description/save.js b/src/views/gutenberg-blocks/blocks/metadata-section-description/save.js new file mode 100644 index 000000000..63d29c9a3 --- /dev/null +++ b/src/views/gutenberg-blocks/blocks/metadata-section-description/save.js @@ -0,0 +1,16 @@ +const { useBlockProps } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor ); + +export default function({ attributes }) { + const { textAlign, style, sectionId, sectionDescription } = attributes; + + // Gets blocks props from hook + const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: `has-text-align-${ textAlign }`, style } : useBlockProps.save( { + className: `has-text-align-${ textAlign }`, + style, + } ); + return ( ++ { sectionDescription } +
+ ); +}; \ No newline at end of file diff --git a/src/views/gutenberg-blocks/blocks/metadata-section-description/style.scss b/src/views/gutenberg-blocks/blocks/metadata-section-description/style.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/views/gutenberg-blocks/blocks/metadata-section-name/block.json b/src/views/gutenberg-blocks/blocks/metadata-section-name/block.json index 3b919b733..7a262e03f 100644 --- a/src/views/gutenberg-blocks/blocks/metadata-section-name/block.json +++ b/src/views/gutenberg-blocks/blocks/metadata-section-name/block.json @@ -4,7 +4,7 @@ "title": "Tainacan Metadata Section Name", "apiVersion": 2, "category": "tainacan-blocks", - "keywords": ["metadata", "field", "section", "region" ], + "keywords": ["metadata", "name", "field", "section"], "description": "A metadata section label, used to identify different metadata sections.", "textdomain": "tainacan", "parent": [ "tainacan/item-metadata-section" ], @@ -35,6 +35,10 @@ "type": "string" } }, + "usesContext": [ + "tainacan/metadataSectionId", + "tainacan/metadataSectionName" + ], "supports": { "align": ["full", "wide"], "multiple": true, diff --git a/src/views/gutenberg-blocks/blocks/metadata-section-name/edit.js b/src/views/gutenberg-blocks/blocks/metadata-section-name/edit.js index 19b110119..ffb42fbbc 100644 --- a/src/views/gutenberg-blocks/blocks/metadata-section-name/edit.js +++ b/src/views/gutenberg-blocks/blocks/metadata-section-name/edit.js @@ -12,7 +12,7 @@ const levelToPath = { 6: 'M9 15H7v-4H3v4H1V5h2v4h4V5h2v10zm8.6-7.5c-.2-.2-.5-.4-.8-.5-.6-.2-1.3-.2-1.9 0-.3.1-.6.3-.8.5l-.6.9c-.2.5-.2.9-.2 1.4.4-.3.8-.6 1.2-.8.4-.2.8-.3 1.3-.3.4 0 .8 0 1.2.2.4.1.7.3 1 .6.3.3.5.6.7.9.2.4.3.8.3 1.3s-.1.9-.3 1.4c-.2.4-.5.7-.8 1-.4.3-.8.5-1.2.6-1 .3-2 .3-3 0-.5-.2-1-.5-1.4-.9-.4-.4-.8-.9-1-1.5-.2-.6-.3-1.3-.3-2.1s.1-1.6.4-2.3c.2-.6.6-1.2 1-1.6.4-.4.9-.7 1.4-.9.6-.3 1.1-.4 1.7-.4.7 0 1.4.1 2 .3.5.2 1 .5 1.4.8 0 .1-1.3 1.4-1.3 1.4zm-2.4 5.8c.2 0 .4 0 .6-.1.2 0 .4-.1.5-.2.1-.1.3-.3.4-.5.1-.2.1-.5.1-.7 0-.4-.1-.8-.4-1.1-.3-.2-.7-.3-1.1-.3-.3 0-.7.1-1 .2-.4.2-.7.4-1 .7 0 .3.1.7.3 1 .1.2.3.4.4.6.2.1.3.3.5.3.2.1.5.2.7.1z', }; -export default function ({ attributes, setAttributes, className }) { +export default function ({ attributes, setAttributes, className, context }) { let { content, @@ -31,6 +31,15 @@ export default function ({ attributes, setAttributes, className }) { style, } ); + if (context['tainacan/metadataSectionId']) + sectionId = context['tainacan/metadataSectionId']; + + if (context['tainacan/metadataSectionName']) + sectionName = context['tainacan/metadataSectionName']; + + if ( context['tainacan/metadataSectionId'] || context['tainacan/metadataSectionName'] ) + setAttributes({ sectionId, sectionName }); + return content == 'preview' ?