From e190295ca2cdde702cf53941d642aabd6f5dc025 Mon Sep 17 00:00:00 2001 From: Kevin Batdorf Date: Thu, 17 Nov 2022 03:07:21 -0500 Subject: [PATCH 1/5] Release 1.8.0 --- code-block-pro.php | 2 +- readme.txt | 16 ++++++++++++++-- src/index.tsx | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/code-block-pro.php b/code-block-pro.php index f10bc93..319083e 100644 --- a/code-block-pro.php +++ b/code-block-pro.php @@ -4,7 +4,7 @@ * Description: Code highlighting powered by the VS Code engine * Requires at least: 6.0 * Requires PHP: 7.0 - * Version: 1.7.0 + * Version: 1.8.0 * Author: Kevin Batdorf * License: GPL-2.0-or-later * License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/readme.txt b/readme.txt index cde9a8e..7a93115 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: kbat82 Tags: block, code, syntax, highlighting, snippet, highlighter, JavaScript, php, vs code, editor Tested up to: 6.1 -Stable tag: 1.7.0 +Stable tag: 1.8.0 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -19,7 +19,8 @@ Beautiful syntax highlighting made easy. - Supports over 140 programming languages - Optionally load programming fonts - Line numbers (custom starting number) -- Various header styles (more coming soon) +- Header styles (more coming) +- Footer styles (more coming) - Optionally add a copy button to let users copy the code - Native Gutenberg block output - no special requirements - No frontend JavaScript required - works in headless mode @@ -220,6 +221,17 @@ Look under the "Styling" tab and turn on "Clamp Values", which will compute the == Changelog == += 1.8.0 - 2022-11-17 = +- Feature: Added footer styles +- Accessability: Increased line number color contrast +- Accessability: Increased copy button contrast +- Tweak: Disabled autocomplete on settings inputs +- Tweak: Added help context to variations that have inputs +- Fix: Fixed a bug where disabling padding on one block would update all +- Fix: Line numbers + disabled padding no longer formats weird in the editor +- Fix: Scrollbars are now using auto instead of scroll +- Fix: The loading screen on the theme viewer now fills the container + = 1.7.0 - 2022-11-09 = - Feature: Add line number support diff --git a/src/index.tsx b/src/index.tsx index 1122154..2436e68 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -69,6 +69,9 @@ registerBlockType(blockConfig.name, { {...blockProps({ className: classnames('code-block-pro-editor', { 'padding-disabled': attributes.disablePadding, + 'padding-bottom-disabled': + attributes?.footerType && + attributes?.footerType !== 'none', 'cbp-has-line-numbers': attributes.lineNumbers, }), style: { From 6a434fd32e3a94e81da50475dee6b59abffd8236 Mon Sep 17 00:00:00 2001 From: Kevin Batdorf Date: Thu, 17 Nov 2022 03:08:14 -0500 Subject: [PATCH 2/5] Fix typo --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 7a93115..2ec09e7 100644 --- a/readme.txt +++ b/readme.txt @@ -223,8 +223,8 @@ Look under the "Styling" tab and turn on "Clamp Values", which will compute the = 1.8.0 - 2022-11-17 = - Feature: Added footer styles -- Accessability: Increased line number color contrast -- Accessability: Increased copy button contrast +- Accessibility: Increased line number color contrast +- Accessibility: Increased copy button contrast - Tweak: Disabled autocomplete on settings inputs - Tweak: Added help context to variations that have inputs - Fix: Fixed a bug where disabling padding on one block would update all From fc8fdc892c90374013b8a42527c222c8dfc85f1d Mon Sep 17 00:00:00 2001 From: Kevin Batdorf Date: Thu, 17 Nov 2022 03:18:18 -0500 Subject: [PATCH 3/5] recalc on line style changes --- readme.txt | 1 + src/editor/Edit.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 2ec09e7..a673bb2 100644 --- a/readme.txt +++ b/readme.txt @@ -231,6 +231,7 @@ Look under the "Styling" tab and turn on "Clamp Values", which will compute the - Fix: Line numbers + disabled padding no longer formats weird in the editor - Fix: Scrollbars are now using auto instead of scroll - Fix: The loading screen on the theme viewer now fills the container +- Fix: With line numbers, changing the font now will recalculate the width = 1.7.0 - 2022-11-09 = - Feature: Add line number support diff --git a/src/editor/Edit.tsx b/src/editor/Edit.tsx index 27c0bb8..94f48fd 100644 --- a/src/editor/Edit.tsx +++ b/src/editor/Edit.tsx @@ -21,6 +21,9 @@ export const Edit = ({ lineNumbers, startingLineNumber, footerType, + fontSize, + fontFamily, + lineHeight, } = attributes; const textAreaRef = useRef(null); const handleChange = (code: string) => setAttributes({ code }); @@ -29,8 +32,7 @@ export const Edit = ({ theme, lang: language ?? previousLanguage, }); - const hasFooter = - attributes?.footerType && attributes?.footerType !== 'none'; + const hasFooter = footerType && footerType !== 'none'; useDefaults({ attributes, setAttributes }); useEffect(() => { @@ -94,6 +96,9 @@ export const Edit = ({ error, textAreaRef, setAttributes, + fontSize, + fontFamily, + lineHeight, ]); if ((loading && code) || error) { From 8ce819cd0b5e34c214ec58738c676ee23f56ac11 Mon Sep 17 00:00:00 2001 From: Kevin Batdorf Date: Thu, 17 Nov 2022 03:34:14 -0500 Subject: [PATCH 4/5] Remove default footer type previous --- src/state/theme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state/theme.ts b/src/state/theme.ts index c864706..410d760 100644 --- a/src/state/theme.ts +++ b/src/state/theme.ts @@ -31,7 +31,7 @@ export const useThemeStore = create()( previousFontFamily: '', previousFontSize: '.875rem', previousHeaderType: 'headlights', - previousFooterType: 'none', + previousFooterType: '', previousClampFonts: false, previousDisablePadding: false, previousLineNumbers: false, From ec0b32d76d6e2d29548b17258370b632b0b9fd60 Mon Sep 17 00:00:00 2001 From: Kevin Batdorf Date: Thu, 17 Nov 2022 03:57:46 -0500 Subject: [PATCH 5/5] Scope font family --- src/hooks/useDefaults.ts | 18 +++++++++++++----- src/state/theme.ts | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/hooks/useDefaults.ts b/src/hooks/useDefaults.ts index 10ba02e..cd6c48f 100644 --- a/src/hooks/useDefaults.ts +++ b/src/hooks/useDefaults.ts @@ -49,7 +49,8 @@ export const useDefaults = ({ }, [previousFontSize, fontSize, setAttributes]); useEffect(() => { - if (fontFamily || !previousFontFamily) return; + if (fontFamily || fontFamily === '' || previousFontFamily === undefined) + return; setAttributes({ fontFamily: previousFontFamily }); }, [previousFontFamily, fontFamily, setAttributes]); @@ -64,22 +65,29 @@ export const useDefaults = ({ }, [previousHeaderType, headerType, setAttributes]); useEffect(() => { - if (footerType || !previousFooterType) return; + if (footerType !== undefined || previousFooterType === undefined) + return; setAttributes({ footerType: previousFooterType }); }, [previousFooterType, footerType, setAttributes]); useEffect(() => { - if (clampFonts !== undefined || !previousClampFonts) return; + if (clampFonts !== undefined || previousClampFonts === undefined) + return; setAttributes({ clampFonts: previousClampFonts }); }, [previousClampFonts, clampFonts, setAttributes]); useEffect(() => { - if (disablePadding !== undefined || !previousDisablePadding) return; + if ( + disablePadding !== undefined || + previousDisablePadding === undefined + ) + return; setAttributes({ disablePadding: previousDisablePadding }); }, [previousDisablePadding, disablePadding, setAttributes]); useEffect(() => { - if (lineNumbers !== undefined || !previousLineNumbers) return; + if (lineNumbers !== undefined || previousLineNumbers === undefined) + return; setAttributes({ lineNumbers: previousLineNumbers }); }, [previousLineNumbers, lineNumbers, setAttributes]); }; diff --git a/src/state/theme.ts b/src/state/theme.ts index 410d760..0549c04 100644 --- a/src/state/theme.ts +++ b/src/state/theme.ts @@ -6,13 +6,13 @@ import { Attributes } from '../types'; type ThemeType = { previousTheme: string; previousLineHeight: string; - previousFontFamily: string; + previousFontFamily?: string; previousFontSize: string; previousHeaderType: string; - previousFooterType: string; - previousClampFonts: boolean; - previousDisablePadding: boolean; - previousLineNumbers: boolean; + previousFooterType?: string; + previousClampFonts?: boolean; + previousDisablePadding?: boolean; + previousLineNumbers?: boolean; updateThemeHistory: (settings: Partial) => void; }; const path = '/wp/v2/settings'; @@ -28,13 +28,13 @@ export const useThemeStore = create()( (set) => ({ previousTheme: 'nord', previousLineHeight: '1.25rem', - previousFontFamily: '', + previousFontFamily: undefined, previousFontSize: '.875rem', previousHeaderType: 'headlights', - previousFooterType: '', - previousClampFonts: false, - previousDisablePadding: false, - previousLineNumbers: false, + previousFooterType: undefined, + previousClampFonts: undefined, + previousDisablePadding: undefined, + previousLineNumbers: undefined, updateThemeHistory(attributes) { set((state) => ({ ...state,