Skip to content

Commit

Permalink
Merge pull request #80 from bigbite/fix/avoid-storing-non-user-values
Browse files Browse the repository at this point in the history
Prevents storing non-user values in the database
  • Loading branch information
g-elwell authored Jul 23, 2024
2 parents f796c9a + d0b4f82 commit dd2dc75
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/editor/components/StylesBorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import StylesContext from '../context/StylesContext';
* @param {string} props.selector Property target selector
*/
const Border = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const value = getThemeOption( selector, themeConfig );
const themePalette = getThemeOption(
Expand All @@ -23,7 +23,7 @@ const Border = ( { selector } ) => {
);

const onChange = ( newValue ) => {
let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set( config, selector, newValue );
setUserConfig( config );
};
Expand Down
4 changes: 2 additions & 2 deletions src/editor/components/StylesColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import StylesContext from '../context/StylesContext';
* @param {string} props.selector Property target selector
*/
const Color = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const colorStyles = getThemeOption( selector, themeConfig ) || {};
const themePalette = getThemeOption(
Expand All @@ -24,7 +24,7 @@ const Color = ( { selector } ) => {
);

const onChange = ( newValue, key ) => {
let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set(
config,
[ selector, key ].join( '.' ),
Expand Down
4 changes: 2 additions & 2 deletions src/editor/components/StylesDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const parseUnitValue = ( minHeight, typeValue ) => {
* @param {string} props.selector Property target selector
*/
const Dimensions = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const dimensionsStyles = getThemeOption( selector, themeConfig ) || {};
const { minHeight } = dimensionsStyles;
Expand All @@ -68,7 +68,7 @@ const Dimensions = ( { selector } ) => {
// Updates a property value in the outline object.
const handleNewValue = ( value ) => {
dimensionsStyles.minHeight = value;
let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set( config, selector, dimensionsStyles );
setUserConfig( config );
};
Expand Down
4 changes: 2 additions & 2 deletions src/editor/components/StylesFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { varToDuotone, duotoneToVar } from '../../utils/block-helpers';
* @param {string} props.selector Property target selector
*/
const Filter = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const duotoneThemeObj = getThemeOption(
'settings.color.duotone',
Expand Down Expand Up @@ -47,7 +47,7 @@ const Filter = ( { selector } ) => {
...filterStyles,
duotone: duotoneToVar( newVal, duotoneOptions ),
};
let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set( config, selector, newFilterStyles );
setUserConfig( config );
};
Expand Down
4 changes: 2 additions & 2 deletions src/editor/components/StylesOutline.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const unitControlUnits = ALLOWED_UNITS.map( ( unit ) => {
* @param {string} props.selector Property target selector
*/
const Outline = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const outlineStyles = getThemeOption( selector, themeConfig );
const themePalette = getThemeOption(
Expand Down Expand Up @@ -58,7 +58,7 @@ const Outline = ( { selector } ) => {
// Updates a property value in the outline object.
const handleNewValue = ( value, key ) => {
const newOutlineStyles = { ...outlineStyles, [ key ]: value };
let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set( config, selector, newOutlineStyles );
setUserConfig( config );
};
Expand Down
4 changes: 2 additions & 2 deletions src/editor/components/StylesShadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const parseUserValue = ( value ) => {
* @param {string} props.selector Property target selector
*/
const Shadow = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const shadowStyles = getThemeOption( selector, themeConfig );
const themePalette = getThemeOption(
Expand All @@ -69,7 +69,7 @@ const Shadow = ( { selector } ) => {
.join( ' ' )
.trim();

let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set( config, selector, updatedShadowStyles );
setUserConfig( config );
};
Expand Down
4 changes: 2 additions & 2 deletions src/editor/components/StylesSpacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const parseMarginPaddingValues = ( type, spacingStyles, themeSpacingSizes ) => {
* @param {string} props.selector Property target selector
*/
const Spacing = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const spacingStyles = getThemeOption( selector, themeConfig );
const themeSpacingSizes = getThemeOption(
Expand Down Expand Up @@ -117,7 +117,7 @@ const Spacing = ( { selector } ) => {
};
}

let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set( config, selector, newSpacingStyles );
setUserConfig( config );
};
Expand Down
4 changes: 2 additions & 2 deletions src/editor/components/StylesTypography/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import FontSize from './FontSize';
* @param {string} props.selector Property target selector
*/
const Typography = ( { selector } ) => {
const { themeConfig } = useContext( EditorContext );
const { userConfig, themeConfig } = useContext( EditorContext );
const { setUserConfig } = useContext( StylesContext );
const typographyStyles = getThemeOption( selector, themeConfig );

Expand All @@ -46,7 +46,7 @@ const Typography = ( { selector } ) => {
*/
const handleNewValue = ( newVal ) => {
const newTypographyStyles = { ...typographyStyles, ...newVal };
let config = structuredClone( themeConfig );
let config = structuredClone( userConfig );
config = set( config, selector, newTypographyStyles );
setUserConfig( config );
};
Expand Down
1 change: 1 addition & 0 deletions src/editor/components/ThemerComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const ThemerComponent = () => {
<EditorContext.Provider
value={ {
globalStylesId,
userConfig,
themeConfig,
schema,
previewBlocks,
Expand Down

0 comments on commit dd2dc75

Please sign in to comment.