PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.5.0
Code Block Pro – Beautiful Syntax Highlighting v1.5.0
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / src / state / global.ts

global.ts in Code Block Pro – Beautiful Syntax Highlighting 1.5.0, at src/state/global.ts

50 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import create from 'zustand';
2 import { devtools, persist } from 'zustand/middleware';
3
4 type GlobalTypes = {
5 seenNotices: string[];
6 setSeenNotice: (notice: string) => void;
7 previousSettings: {
8 copyButton: boolean;
9 };
10 setPreviousSettings: (
11 settings: Partial<GlobalTypes['previousSettings']>,
12 ) => void;
13 };
14 export const useGlobalStore = create<GlobalTypes>()(
15 persist(
16 devtools(
17 (set) => ({
18 seenNotices: [],
19 setSeenNotice(notice: string) {
20 set((state) => {
21 if (state.seenNotices.includes(notice)) return state;
22 return { seenNotices: [...state.seenNotices, notice] };
23 });
24 },
25 // If any of these values have changed, we will use these for defaults.
26 // Themes and languages are handled separately.
27 previousSettings: {
28 copyButton: true,
29 },
30 setPreviousSettings(
31 s: Partial<GlobalTypes['previousSettings']>,
32 ) {
33 set((state) => ({
34 previousSettings: { ...state.previousSettings, ...s },
35 }));
36 },
37 }),
38 { name: 'Code Block Pro Globals' },
39 ),
40 {
41 name: 'code-block-pro-last-globals',
42 getStorage: () => localStorage,
43 partialize: (state) => ({
44 seenNotices: state?.seenNotices ?? [],
45 previousSettings: state?.previousSettings ?? {},
46 }),
47 },
48 ),
49 );
50