# code-block-pro/1.11.0/src/state/global.ts

Code Block Pro – Beautiful Syntax Highlighting, version 1.11.0. 40 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.11.0/code/src/state/global.ts
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.11.0/raw/src/state/global.ts
- Modified: 2023-01-04T04:16:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-block-pro/1.11.0/code/src/state/global.ts#L10-L20`.

```typescript
import create from 'zustand';
import { devtools, persist } from 'zustand/middleware';

type GlobalTypes = {
    previousSettings: {
        copyButton: boolean;
    };
    setPreviousSettings: (
        settings: Partial<GlobalTypes['previousSettings']>,
    ) => void;
};

export const useGlobalStore = create<GlobalTypes>()(
    persist(
        devtools(
            (set) => ({
                previousSettings: {
                    // This should go into settings.tsx and persist to the db
                    copyButton: true,
                },
                setPreviousSettings(
                    s: Partial<GlobalTypes['previousSettings']>,
                ) {
                    set((state) => ({
                        previousSettings: { ...state.previousSettings, ...s },
                    }));
                },
            }),
            { name: 'Code Block Pro Globals' },
        ),
        {
            name: 'code-block-pro-last-globals',
            getStorage: () => localStorage,
            partialize: (state) => ({
                previousSettings: state?.previousSettings ?? {},
            }),
        },
    ),
);

```
