PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / QuickEdit / state / store.js

store.js in Extendify 3.1.0, at src/QuickEdit/state/store.js

52 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { create } from 'zustand';
2
3 export const useQuickEditStore = create((set, get) => ({
4 hovered: null,
5 // Quick Edit canvas-mount target — set when the user clicks the Quick
6 // Edit pill. See click-rule.js's module header for the full unified
7 // selector contract; this and `agentBlock` are the two selection
8 // slots Quick Edit and the AI Agent share.
9 selected: null,
10 dirty: {},
11 saving: false,
12 error: null,
13 // Ask AI staged block — see buildAgentBlockDescriptor for the shape.
14 // Distinct from `selected` by design: a QE canvas opens a modal flow
15 // for one block, while an Ask AI selection stages a block for a
16 // multi-turn workflow.
17 agentBlock: null,
18 agentBlockCode: null,
19 // Sticky pre-pill-action selection — set when the user clicks a tagged
20 // block on the live front end. While set, hover on other tagged blocks
21 // is suppressed and the bar/outline stay pinned. Cleared by an outside
22 // click, a click on a different tagged block, or a pill action (which
23 // hands off to `selected` / `agentBlock`). Shape mirrors buildTarget:
24 // { el, blockType, blockId, source }.
25 committedSelection: null,
26
27 setHovered: (target) => set({ hovered: target }),
28 setSelected: (target) => set({ selected: target, dirty: {}, error: null }),
29 clearSelected: () => set({ selected: null, dirty: {}, error: null }),
30
31 setAgentBlock: (agentBlock) => set({ agentBlock, agentBlockCode: null }),
32 setAgentBlockCode: (agentBlockCode) => set({ agentBlockCode }),
33
34 setCommittedSelection: (committedSelection) => set({ committedSelection }),
35
36 setField: (fieldKey, value) =>
37 set((state) => ({
38 dirty: { ...state.dirty, [fieldKey]: value },
39 })),
40
41 setSaving: (saving) => set({ saving }),
42 setError: (error) => set({ error }),
43
44 getPatches: () => {
45 const dirty = get().dirty;
46 return Object.entries(dirty).map(([fieldKey, value]) => ({
47 fieldKey,
48 value,
49 }));
50 },
51 }));
52