# extendify/3.1.0/src/QuickEdit/state/edit-mode.js

Extendify, version 3.1.0. 39 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.0/code/src/QuickEdit/state/edit-mode.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.0/raw/src/QuickEdit/state/edit-mode.js
- Modified: 2026-06-11T18:37:12+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/extendify/3.1.0/code/src/QuickEdit/state/edit-mode.js#L10-L20`.

```javascript
import { isEmbedded } from '@shared/lib/embedded-guard';
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { track } from '../lib/insights';

const HTML_CLASS = 'extendify-quick-edit-on';

const DEFAULT_ON = !!window.extQuickEditData?.defaultOn;

export const useEditModeStore = create()(
	persist(
		(set, get) => ({
			on: DEFAULT_ON,
			setOn: (on) => {
				const next = !!on;
				if (get().on === next) return;
				set({ on: next });
			},
			toggle: () => set({ on: !get().on }),
		}),
		{
			name: 'extendify-quick-edit-mode',
			partialize: ({ on }) => ({ on }),
		},
	),
);

// This chunk also ships in the Agent bundle, so guarding the class here keeps
// the page from ever looking edit-on inside another tool's iframe (Customizer
// preview, page-builder previews) regardless of which bundle loaded it.
const applyHtmlClass = (on) =>
	document.documentElement.classList.toggle(HTML_CLASS, on && !isEmbedded());

useEditModeStore.subscribe((state) => {
	applyHtmlClass(state.on);
	track(state.on ? 'edit_mode_on' : 'edit_mode_off');
});
applyHtmlClass(useEditModeStore.getState().on);

```
