diff --git a/.wordpress-org/screenshot-3.png b/.wordpress-org/screenshot-3.png new file mode 100644 index 0000000..299fab1 Binary files /dev/null and b/.wordpress-org/screenshot-3.png differ diff --git a/README.md b/README.md index fdd2ac6..fbe93db 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,16 @@ View this block plugin [on WordPress.org](https://wordpress.org/plugins/code-blo ## Features - Includes 28 themes built in to choose from. -- Supports over 140 languages +- Supports over 140 programming languages +- Optionally load programming fonts +- Various header styles (more coming soon) - 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 +- Supports converting from the default code block ## Example Screenshots -![alt text](.wordpress-org/screenshot-1.gif "Example") -![alt text](.wordpress-org/screenshot-2.png "Example 2") +![alt text](.wordpress-org/screenshot-1.png "Example") +![alt text](.wordpress-org/screenshot-2.gif "Example 2") +![alt text](.wordpress-org/screenshot-3.png "Example 3") diff --git a/php/settings.php b/php/settings.php index 47cb179..c787ac6 100644 --- a/php/settings.php +++ b/php/settings.php @@ -18,6 +18,8 @@ function code_block_pro_register_settings() { 'previousFontSize' => [ 'type' => ['string', 'null']], 'previousLineHeight' => [ 'type' => ['string', 'null']], 'previousHeaderType' => [ 'type' => ['string', 'null']], + 'previousClampFonts' => [ 'type' => ['boolean', 'null']], + 'previousDisablePadding' => [ 'type' => ['boolean', 'null']], ], ], ], diff --git a/readme.txt b/readme.txt index 1b9f8d7..a91659a 100644 --- a/readme.txt +++ b/readme.txt @@ -212,13 +212,16 @@ Look under the "Styling" tab and turn on "Clamp Values", which will compute the == Screenshots == -1. Choose from more than 25 themes -2. Customize fonts, themes, and behavior +1. Choose from more than 25 themes. +2. Customize fonts, themes, and behavior. +3. Example showing light theme with padding disabled. == Changelog == = 1.5.1 - 2022-09-05 = +- Tweak: Allow users to disable padding - Fix: Fixes a bug where the header type set to none doesn't persist +- Fix: Clamp font settings were not being persisted = 1.5.0 - 2022-09-05 = - Feature: Add toggle so users can clamp font sizes to reasonable values. diff --git a/src/block.json b/src/block.json index 6ac5cef..2b73f17 100644 --- a/src/block.json +++ b/src/block.json @@ -20,6 +20,7 @@ "lineNumbers": { "type": "boolean" }, "clampFonts": { "type": "boolean", "default": false }, "headerType": { "type": "string" }, + "disablePadding": { "type": "boolean", "default": false }, "startingLineNumber": { "type": "number", "default": 1 }, "frame": { "type": "boolean" }, "renderType": { "type": "string", "default": "code" }, diff --git a/src/editor/Edit.tsx b/src/editor/Edit.tsx index 9691ba1..519a2f8 100644 --- a/src/editor/Edit.tsx +++ b/src/editor/Edit.tsx @@ -18,6 +18,7 @@ export const Edit = ({ code = '', bgColor: backgroundColor, textColor: color, + disablePadding, } = attributes; const textAreaRef = useRef(null); const handleChange = (code: string) => setAttributes({ code }); @@ -72,7 +73,7 @@ export const Edit = ({ diff --git a/src/editor/controls/Sidebar.tsx b/src/editor/controls/Sidebar.tsx index de6e186..0cb7e60 100644 --- a/src/editor/controls/Sidebar.tsx +++ b/src/editor/controls/Sidebar.tsx @@ -151,18 +151,37 @@ export const SidebarControls = ({ - { - setPreviousSettings({ copyButton: value }); - setAttributes({ copyButton: value }); - }} - /> + + { + setPreviousSettings({ copyButton: value }); + setAttributes({ copyButton: value }); + }} + /> + + + { + setAttributes({ disablePadding }); + updateThemeHistory({ + ...attributes, + disablePadding, + }); + }} + /> + ); diff --git a/src/front/BlockOutput.tsx b/src/front/BlockOutput.tsx index 320b1f7..ac78f62 100644 --- a/src/front/BlockOutput.tsx +++ b/src/front/BlockOutput.tsx @@ -7,7 +7,11 @@ import './style.css'; export const BlockOutput = ({ attributes }: { attributes: Attributes }) => (
(blockConfig.name, { clampFonts: { type: 'boolean', default: false }, lineNumbers: { type: 'boolean' }, headerType: { type: 'string' }, + disablePadding: { type: 'boolean', default: false }, startingLineNumber: { type: 'number', default: 1 }, frame: { type: 'boolean' }, renderType: { type: 'string', default: 'code' }, @@ -58,7 +60,9 @@ registerBlockType(blockConfig.name, { />
) => void; }; const path = '/wp/v2/settings'; @@ -29,6 +30,7 @@ export const useThemeStore = create()( previousFontSize: '.875rem', previousHeaderType: 'headlights', previousClampFonts: false, + previousDisablePadding: false, updateThemeHistory(attributes) { set((state) => ({ ...state, @@ -38,6 +40,7 @@ export const useThemeStore = create()( previousFontSize: attributes.fontSize, previousHeaderType: attributes.headerType, previousClampFonts: attributes.clampFonts, + previousDisablePadding: attributes.disablePadding, })); }, }), diff --git a/src/types.ts b/src/types.ts index 2d9d1cd..2c82abc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,6 +14,7 @@ export type Attributes = { lineNumbers: boolean; clampFonts: boolean; headerType: string; + disablePadding: boolean; startingLineNumber: number; frame: boolean; renderType: string;