diff --git a/src/block.json b/src/block.json index 9465bac..03935ed 100644 --- a/src/block.json +++ b/src/block.json @@ -18,14 +18,14 @@ "fontFamily": { "type": "string" }, "lineHeight": { "type": "string" }, "lineNumbers": { "type": "boolean" }, - "clampFonts": { "type": "boolean", "default": false }, + "clampFonts": { "type": "boolean" }, "headerType": { "type": "string" }, "footerType": { "type": "string" }, "headerString": { "type": "string" }, + "disablePadding": { "type": "boolean" }, "footerString": { "type": "string" }, "footerLink": { "type": "string" }, "footerLinkTarget": { "type": "boolean" }, - "disablePadding": { "type": "boolean", "default": false }, "startingLineNumber": { "type": "number", "default": 1 }, "lineNumbersWidth": { "type": "number" }, "frame": { "type": "boolean" }, diff --git a/src/editor/editor.css b/src/editor/editor.css index 29929f4..fd53bc8 100644 --- a/src/editor/editor.css +++ b/src/editor/editor.css @@ -50,6 +50,11 @@ position: absolute; left: 18px; } + +.code-block-pro-editor.cbp-has-line-numbers.padding-disabled pre .line:not(.cbp-line-number-disabled)::before { + @apply static; +} + /* Will make sure the line numbers are full width before calculating */ .code-block-pro-editor.cbp-has-line-numbers pre .line.cbp-line-number-width-forced::before { width: auto !important; diff --git a/src/hooks/useDefaults.ts b/src/hooks/useDefaults.ts index ed8c1c5..10ba02e 100644 --- a/src/hooks/useDefaults.ts +++ b/src/hooks/useDefaults.ts @@ -34,7 +34,7 @@ export const useDefaults = ({ } = useThemeStore(); useEffect(() => { - if (copyButton || !previousSettings.copyButton) return; + if (copyButton !== undefined || !previousSettings.copyButton) return; setAttributes({ copyButton: previousSettings.copyButton }); }, [previousSettings, copyButton, setAttributes]); @@ -69,17 +69,17 @@ export const useDefaults = ({ }, [previousFooterType, footerType, setAttributes]); useEffect(() => { - if (clampFonts || !previousClampFonts) return; + if (clampFonts !== undefined || !previousClampFonts) return; setAttributes({ clampFonts: previousClampFonts }); }, [previousClampFonts, clampFonts, setAttributes]); useEffect(() => { - if (disablePadding || !previousDisablePadding) return; + if (disablePadding !== undefined || !previousDisablePadding) return; setAttributes({ disablePadding: previousDisablePadding }); }, [previousDisablePadding, disablePadding, setAttributes]); useEffect(() => { - if (lineNumbers || !previousLineNumbers) return; + if (lineNumbers !== undefined || !previousLineNumbers) return; setAttributes({ lineNumbers: previousLineNumbers }); }, [previousLineNumbers, lineNumbers, setAttributes]); }; diff --git a/src/index.tsx b/src/index.tsx index 3836754..1122154 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,7 +3,6 @@ import { createBlock, registerBlockType } from '@wordpress/blocks'; import { addFilter } from '@wordpress/hooks'; import { __ } from '@wordpress/i18n'; import classnames from 'classnames'; -import { colord, AnyColor } from 'colord'; import { Lang } from 'shiki'; import blockConfig from './block.json'; import { Edit } from './editor/Edit'; @@ -34,15 +33,15 @@ registerBlockType(blockConfig.name, { fontSize: { type: 'string' }, fontFamily: { type: 'string' }, lineHeight: { type: 'string' }, - clampFonts: { type: 'boolean', default: false }, + clampFonts: { type: 'boolean' }, lineNumbers: { type: 'boolean' }, headerType: { type: 'string' }, headerString: { type: 'string' }, + disablePadding: { type: 'boolean' }, footerType: { type: 'string' }, footerString: { type: 'string' }, footerLink: { type: 'string' }, footerLinkTarget: { type: 'boolean' }, - disablePadding: { type: 'boolean', default: false }, startingLineNumber: { type: 'string' }, lineNumbersWidth: { type: 'number' }, frame: { type: 'boolean' },