Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
62 lines
1.4 KiB
Plaintext
62 lines
1.4 KiB
Plaintext
'use client';
|
|
|
|
import { createContext, use } from 'react';
|
|
export const LivePreviewContext = createContext({
|
|
appIsReady: false,
|
|
breakpoint: undefined,
|
|
breakpoints: undefined,
|
|
iframeRef: undefined,
|
|
isLivePreviewEnabled: undefined,
|
|
isLivePreviewing: false,
|
|
isPopupOpen: false,
|
|
isPreviewEnabled: undefined,
|
|
measuredDeviceSize: {
|
|
height: 0,
|
|
width: 0
|
|
},
|
|
openPopupWindow: () => {},
|
|
popupRef: undefined,
|
|
previewURL: undefined,
|
|
previewWindowType: 'iframe',
|
|
setAppIsReady: () => {},
|
|
setBreakpoint: () => {},
|
|
setHeight: () => {},
|
|
setIsLivePreviewing: () => {},
|
|
setLoadedURL: () => {},
|
|
setMeasuredDeviceSize: () => {},
|
|
setPreviewURL: () => {},
|
|
setPreviewWindowType: () => {},
|
|
setSize: () => {},
|
|
setToolbarPosition: () => {},
|
|
setURL: () => {},
|
|
setWidth: () => {},
|
|
setZoom: () => {},
|
|
size: {
|
|
height: 0,
|
|
width: 0
|
|
},
|
|
toolbarPosition: {
|
|
x: 0,
|
|
y: 0
|
|
},
|
|
typeofLivePreviewURL: undefined,
|
|
url: undefined,
|
|
zoom: 1
|
|
});
|
|
export const useLivePreviewContext = () => use(LivePreviewContext);
|
|
/**
|
|
* Hook to access live preview context values. Separated to prevent breaking changes. In the future this hook can be removed in favour of just using the LivePreview one.
|
|
*/
|
|
export const usePreviewURL = () => {
|
|
const {
|
|
isPreviewEnabled,
|
|
previewURL,
|
|
setPreviewURL
|
|
} = use(LivePreviewContext);
|
|
return {
|
|
isPreviewEnabled,
|
|
previewURL,
|
|
setPreviewURL
|
|
};
|
|
};
|
|
//# sourceMappingURL=context.js.map |