From 88050d9647ac77f03e10c2ac3d34047ce34997aa Mon Sep 17 00:00:00 2001 From: kurudrive Date: Mon, 27 Dec 2021 15:24:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix=20:=20=E8=A6=8B=E5=87=BA=E3=81=97?= =?UTF-8?q?=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF=E3=81=AE=E3=83=AA=E3=82=AB?= =?UTF-8?q?=E3=83=90=E3=83=AA=E3=83=BC=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/blocks/heading/deprecated/1.20.5a/save.js | 211 ++++++++++++++++++ src/blocks/heading/deprecated/index.js | 40 ++++ 2 files changed, 251 insertions(+) create mode 100644 src/blocks/heading/deprecated/1.20.5a/save.js diff --git a/src/blocks/heading/deprecated/1.20.5a/save.js b/src/blocks/heading/deprecated/1.20.5a/save.js new file mode 100644 index 000000000..bdb366a67 --- /dev/null +++ b/src/blocks/heading/deprecated/1.20.5a/save.js @@ -0,0 +1,211 @@ +import { RichText, useBlockProps } from '@wordpress/block-editor'; + +import ReactHtmlParser from 'react-html-parser'; +import { isHexColor } from '@vkblocks/utils/is-hex-color'; +import classnames from 'classnames'; + +const renderTitle = (level, contents, tStyle, headingStyle) => { + switch (level) { + case 1: + return ( +

+ {contents} +

+ ); + case 2: + return ( +

+ {contents} +

+ ); + case 3: + return ( +

+ {contents} +

+ ); + case 4: + return ( +

+ {contents} +

+ ); + case 5: + return ( +
+ {contents} +
+ ); + case 6: + return ( +
+ {contents} +
+ ); + } +}; + +export default function save(props) { + const { attributes } = props; + const { + level, + align, + title, + titleColor, + titleSize, + subText, + subTextFlag, + subTextColor, + subTextSize, + titleStyle, + titleMarginBottom, + outerMarginBottom, + fontAwesomeIconBefore, + fontAwesomeIconAfter, + fontAwesomeIconColor, + } = attributes; + const containerClass = `vk_heading vk_heading-style-${titleStyle}`; + + const cStyle = { + marginBottom: + outerMarginBottom !== null && outerMarginBottom !== undefined + ? outerMarginBottom + `rem` + : undefined, + }; + + let headingColorClassName = ''; + // if (titleColor !== undefined) { + // headingColorClassName += `has-text-color`; + // if (!isHexColor(titleColor)) { + // headingColorClassName += ` has-${titleColor}-color`; + // } + // } + + const headingStyle = classnames('vk_heading_title', { + [`vk_heading_title-style-${titleStyle}`]: !!titleStyle, + [`${headingColorClassName}`]: !!headingColorClassName, + }); + + const tStyle = { + color: + titleColor !== null && + titleColor !== undefined && + isHexColor(titleColor) + ? titleColor + : undefined, + fontSize: + titleSize !== null && titleSize !== undefined + ? titleSize + 'rem' + : undefined, + marginBottom: + titleMarginBottom !== null && titleMarginBottom !== undefined + ? titleMarginBottom + 'rem' + : undefined, + textAlign: align !== null && align !== undefined ? align : undefined, + }; + + let subTextColorClassName = ''; + // if (subTextColor !== undefined) { + // subTextColorClassName += `has-text-color`; + // if (!isHexColor(subTextColor)) { + // subTextColorClassName += ` has-${subTextColor}-color`; + // } + // } + + const subTextClass = classnames('vk_heading_subtext', { + [`vk_heading_subtext-style-${titleStyle}`]: !!titleStyle, + [`${subTextColorClassName}`]: !!subTextColorClassName, + }); + + const subTextStyle = { + color: + subTextColor !== null && + subTextColor !== undefined && + isHexColor(subTextColor) + ? subTextColor + : undefined, + fontSize: + subTextSize !== null && subTextSize !== undefined + ? subTextSize + 'rem' + : undefined, + textAlign: align !== null && align !== undefined ? align : undefined, + }; + + let iconColorClassName = ''; + // if (fontAwesomeIconColor !== undefined) { + // iconColorClassName += `has-text-color`; + // if (!isHexColor(fontAwesomeIconColor)) { + // iconColorClassName += ` has-${fontAwesomeIconColor}-color`; + // } + // } + + const fontAwesomeIconStyle = + fontAwesomeIconColor && isHexColor(fontAwesomeIconColor) + ? `style="color:${fontAwesomeIconColor};"` + : ''; + + let iconBefore = fontAwesomeIconBefore; + let iconAfter = fontAwesomeIconAfter; + //add class + if (iconBefore && iconColorClassName) { + const faIconFragmentBefore = iconBefore.split(' + {ReactHtmlParser(iconBefore)} + + {ReactHtmlParser(iconAfter)} + + ); + + let subtextContent; + if (subTextFlag === 'on') { + subtextContent = ( + + ); + } + + const blockProps = useBlockProps.save({ + className: ``, + }); + + return ( +
+
+ {renderTitle(level, titleContent, tStyle, headingStyle)} + {subtextContent} +
+
+ ); +} diff --git a/src/blocks/heading/deprecated/index.js b/src/blocks/heading/deprecated/index.js index 4af2016e7..4016ba642 100644 --- a/src/blocks/heading/deprecated/index.js +++ b/src/blocks/heading/deprecated/index.js @@ -13,6 +13,7 @@ import save0_60_1 from './0.60.1/save'; import save1_3_2 from './1.3.2/save'; import save1_9_1 from './1.9.1/save'; import save1_20_5 from './1.20.5/save'; +import save1_20_5a from './1.20.5a/save'; const blockAttributes = { level: { @@ -135,7 +136,46 @@ const blockAttributes4 = { }, } +const blockAttributes5 = { + ...blockAttributes4, + outerMarginBottom: { + type: "number", + default: null + }, + titleColor: { + type: "string", + }, + titleSize: { + type: 'number', + }, + titleMarginBottom: { + type: "number", + default: null + }, + subTextFlag: { + type: "string", + default: "off" + }, + subTextColor: { + type: "string", + }, + subTextSize: { + type: 'number', + }, + fontAwesomeIconColor: { + type: 'string', + }, +} + const deprecated = [ + { + attributes: blockAttributes5, + save: save1_20_5a, + }, + { + attributes: blockAttributes5, + save: save1_20_5, + }, { attributes: blockAttributes4, save: save1_20_5, From f4c26985743d85dc5ee27c2061490884fb297c3d Mon Sep 17 00:00:00 2001 From: kurudrive Date: Mon, 27 Dec 2021 15:29:01 +0900 Subject: [PATCH 2/2] [ Change version ] 1.20.6 --- readme.txt | 6 ++++-- vk-blocks.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/readme.txt b/readme.txt index 9546843c5..17a6a769d 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: Tags: Gutenberg,FAQ,alert Requires at least: 5.7 Tested up to: 5.8.2 -Stable tag: 1.20.5 +Stable tag: 1.20.6 Requires PHP: 7.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -63,7 +63,9 @@ e.g. == Changelog == -[ fix ][ Button ] change option order in panel += 1.20.6 = +[ Bug fix ][ Heading ] cope with custom color palette +[ Bug fix ][ Button ] change option order in panel [ Bug fix ][ Grid Column(Pro) ] cope with custom color palette [ Bug fix ][ Heading ] cope with custom color palette [ Bug fix ][ Balloon ] cope with custom color palette diff --git a/vk-blocks.php b/vk-blocks.php index adb3655b9..ced621ba9 100644 --- a/vk-blocks.php +++ b/vk-blocks.php @@ -3,8 +3,8 @@ * Plugin Name: VK Blocks Pro * Plugin URI: https://github.com/vektor-inc/vk-blocks * Description: This is a plugin that extends Gutenberg's blocks. - * Version: 1.20.5 - * Stable tag: 1.20.5 + * Version: 1.20.6 + * Stable tag: 1.20.6 * Requires at least: 5.7 * Author: Vektor,Inc. * Author URI: https://vektor-inc.co.jp