@gem-sdk/pages 1.57.0-staging.8 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/builder/Body.js +9 -1
- package/dist/cjs/components/builder/Header.js +2 -2
- package/dist/cjs/components/builder/InteractionSelectOnPageHeader.js +5 -2
- package/dist/cjs/components/builder/Toolbar.js +21 -42
- package/dist/cjs/components/builder/Toolbox.js +11 -1
- package/dist/cjs/components/builder/toolbar/const.js +0 -4
- package/dist/cjs/components/builder/toolbar/utils/waitForElementToExist.js +4 -2
- package/dist/cjs/libs/api/get-static-page-props-preview.js +1 -2
- package/dist/esm/components/builder/Body.js +10 -2
- package/dist/esm/components/builder/Header.js +2 -2
- package/dist/esm/components/builder/InteractionSelectOnPageHeader.js +5 -2
- package/dist/esm/components/builder/Toolbar.js +22 -43
- package/dist/esm/components/builder/Toolbox.js +11 -1
- package/dist/esm/components/builder/toolbar/const.js +1 -4
- package/dist/esm/components/builder/toolbar/utils/waitForElementToExist.js +4 -2
- package/dist/esm/libs/api/get-static-page-props-preview.js +1 -2
- package/package.json +5 -5
|
@@ -9,12 +9,20 @@ var CollectionGlobalProvider = require('../../pages/CollectionGlobalProvider.js'
|
|
|
9
9
|
|
|
10
10
|
const Body = ({ pageType, isThemeSectionEditor })=>{
|
|
11
11
|
const interactionData = core.usePageStore((s)=>s.interactionData);
|
|
12
|
+
const sidebarMode = core.usePageStore((s)=>s.sidebarMode);
|
|
12
13
|
const isInteractionSelectModeClass = react.useMemo(()=>interactionData?.isSelectOnPage ? 'interaction-select-mode' : '', [
|
|
13
14
|
interactionData?.isSelectOnPage
|
|
14
15
|
]);
|
|
16
|
+
const isInteractionMode = react.useMemo(()=>sidebarMode === 'interaction' && !interactionData?.isSelectOnPage, [
|
|
17
|
+
sidebarMode,
|
|
18
|
+
interactionData?.isSelectOnPage
|
|
19
|
+
]);
|
|
15
20
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
16
21
|
id: "storefront",
|
|
17
|
-
className:
|
|
22
|
+
className: core.cls(isThemeSectionEditor ? 'theme-section-editor' : '', pageType === 'POST_PURCHASE' ? 'post-purchase-page' : '', isInteractionSelectModeClass),
|
|
23
|
+
style: {
|
|
24
|
+
pointerEvents: isInteractionMode ? 'none' : 'auto'
|
|
25
|
+
},
|
|
18
26
|
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
|
|
19
27
|
children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
|
|
20
28
|
uid: "ROOT"
|
|
@@ -22,7 +22,7 @@ const sizeCheck = {
|
|
|
22
22
|
const Header = (props)=>{
|
|
23
23
|
const { pageType, isOriginTemplate, openPageSetting } = props;
|
|
24
24
|
const layoutSetting = core.useShopStore((s)=>s.layoutSettings);
|
|
25
|
-
const
|
|
25
|
+
const sidebarMode = core.usePageStore((s)=>s.sidebarMode);
|
|
26
26
|
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
27
27
|
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
28
28
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -181,7 +181,7 @@ const Header = (props)=>{
|
|
|
181
181
|
]
|
|
182
182
|
})
|
|
183
183
|
}),
|
|
184
|
-
|
|
184
|
+
sidebarMode === 'interaction' && /*#__PURE__*/ jsxRuntime.jsx(InteractionSelectOnPageHeader.default, {})
|
|
185
185
|
]
|
|
186
186
|
});
|
|
187
187
|
};
|
|
@@ -14,6 +14,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
14
14
|
const [hoverOption, setHoverOption] = react.useState(null);
|
|
15
15
|
const [openDropdown, setOpenDropdown] = react.useState(false);
|
|
16
16
|
const popupRef = react.useRef(null);
|
|
17
|
+
const isSelectOnPage = core.usePageStore((s)=>s.interactionData?.isSelectOnPage);
|
|
17
18
|
const handleSetInteraction = (type)=>{
|
|
18
19
|
setOpenDropdown(false);
|
|
19
20
|
setInteractionSelectType(type);
|
|
@@ -70,7 +71,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
70
71
|
};
|
|
71
72
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
72
73
|
children: [
|
|
73
|
-
/*#__PURE__*/ jsxRuntime.jsx("header", {
|
|
74
|
+
isSelectOnPage && /*#__PURE__*/ jsxRuntime.jsx("header", {
|
|
74
75
|
className: "gp-flex gp-text-[12px] gp-justify-center gp-items-center gp-h-10 gp-fixed gp-top-0 gp-left-0 gp-w-full gp-z-[1000] gp-bg-[#151515] gp-text-white interaction-select-mode-header",
|
|
75
76
|
children: /*#__PURE__*/ jsxRuntime.jsxs("section", {
|
|
76
77
|
className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-2",
|
|
@@ -178,7 +179,9 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
178
179
|
})
|
|
179
180
|
}),
|
|
180
181
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
181
|
-
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-mt-[40px] gp-z-[999] ${isShowOverlay ? 'gp-z-[999] gp-bg-[#3c67ff]/[0.25]' : '
|
|
182
|
+
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-mt-[40px] gp-z-[999] ${isShowOverlay ? 'gp-z-[999] gp-bg-[#3c67ff]/[0.25]' : ''}
|
|
183
|
+
${isSelectOnPage ? 'gp-pointer-events-none' : 'gp-pointer-events-auto'}
|
|
184
|
+
`,
|
|
182
185
|
style: {
|
|
183
186
|
height: 'calc(100% - 40px)'
|
|
184
187
|
}
|
|
@@ -259,32 +259,6 @@ const Toolbar = ()=>{
|
|
|
259
259
|
setFocusTextEditor(false);
|
|
260
260
|
if (stopWatchReRenderComponent.current) stopWatchReRenderComponent.current();
|
|
261
261
|
}, []);
|
|
262
|
-
const watchComponentReRender = ($el, callback)=>{
|
|
263
|
-
// editor:component:render
|
|
264
|
-
const onComponentReRender = (e)=>{
|
|
265
|
-
const detail = e.detail;
|
|
266
|
-
if (detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
267
|
-
callback();
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
271
|
-
window.addEventListener('editor:component:render', onComponentReRender);
|
|
272
|
-
const componentTag = $el.getAttribute('data-component-tag');
|
|
273
|
-
// hotfix cho sale funnel release, nhưng cần tìm solution cho phần này
|
|
274
|
-
if (componentTag && !_const.COMPONENTS_TAG_NOT_LOAD_IMAGES.includes(componentTag)) {
|
|
275
|
-
const $images = $el.querySelectorAll('img');
|
|
276
|
-
if ($images?.length) {
|
|
277
|
-
$images.forEach(($img)=>{
|
|
278
|
-
$img.addEventListener('load', ()=>{
|
|
279
|
-
callback();
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
stopWatchReRenderComponent.current = ()=>{
|
|
285
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
286
|
-
};
|
|
287
|
-
};
|
|
288
262
|
const setActiveComponentSpacing = react.useCallback(({ $component })=>{
|
|
289
263
|
if (!$component) return;
|
|
290
264
|
const style = getComputedStyle($component);
|
|
@@ -375,16 +349,6 @@ const Toolbar = ()=>{
|
|
|
375
349
|
$component
|
|
376
350
|
});
|
|
377
351
|
removeHoverComponent();
|
|
378
|
-
// Reactive when component re-render
|
|
379
|
-
watchComponentReRender($component, ()=>{
|
|
380
|
-
setActiveComponent({
|
|
381
|
-
componentUid,
|
|
382
|
-
productId,
|
|
383
|
-
articleId,
|
|
384
|
-
timeAwait: 2000,
|
|
385
|
-
forceReActive: true
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
352
|
}, [
|
|
389
353
|
removeActiveComponent,
|
|
390
354
|
removeHoverComponent,
|
|
@@ -404,9 +368,10 @@ const Toolbar = ()=>{
|
|
|
404
368
|
}
|
|
405
369
|
} else {
|
|
406
370
|
if (currentComponentActive.current?.componentUid) {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
371
|
+
const selector = getSelectorComponent({
|
|
372
|
+
...currentComponentActive.current
|
|
373
|
+
});
|
|
374
|
+
const $component = await waitForElementToExist.waitForElementToExist(selector, 500);
|
|
410
375
|
if ($component) {
|
|
411
376
|
const $toolbar = getChildrenByAttrSelector.getChildrenByAttrSelector($component, 'data-toolbar');
|
|
412
377
|
const $outline = getChildrenByAttrSelector.getChildrenByAttrSelector($component, 'data-outline');
|
|
@@ -442,10 +407,13 @@ const Toolbar = ()=>{
|
|
|
442
407
|
}
|
|
443
408
|
}, []);
|
|
444
409
|
const setShowParents = async ({ value })=>{
|
|
445
|
-
if (!value) {
|
|
410
|
+
if (!value || !currentComponentActive.current) {
|
|
446
411
|
return;
|
|
447
412
|
}
|
|
448
|
-
const
|
|
413
|
+
const selector = getSelectorComponent({
|
|
414
|
+
...currentComponentActive.current
|
|
415
|
+
});
|
|
416
|
+
const $component = await waitForElementToExist.waitForElementToExist(selector, 500);
|
|
449
417
|
if ($component) {
|
|
450
418
|
const $parents = $component?.querySelectorAll('[data-toolbar-parent]');
|
|
451
419
|
if ($parents.length) {
|
|
@@ -685,6 +653,14 @@ const Toolbar = ()=>{
|
|
|
685
653
|
}, [
|
|
686
654
|
isDragging
|
|
687
655
|
]);
|
|
656
|
+
const onComponentReRender = (e)=>{
|
|
657
|
+
const detail = e.detail;
|
|
658
|
+
if (currentComponentActive.current?.componentUid && detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
659
|
+
setActiveComponent({
|
|
660
|
+
...currentComponentActive.current
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
};
|
|
688
664
|
/* Register event */ react.useEffect(()=>{
|
|
689
665
|
document.addEventListener('mousemove', onMouseMove);
|
|
690
666
|
window.addEventListener('editor:active-component', onActiveComponent);
|
|
@@ -694,6 +670,7 @@ const Toolbar = ()=>{
|
|
|
694
670
|
window.addEventListener('editor:toolbar:show-parents', onShowParents);
|
|
695
671
|
window.addEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
696
672
|
window.addEventListener('editor:hover-component', onHoverComponent);
|
|
673
|
+
window.addEventListener('editor:component:render', onComponentReRender);
|
|
697
674
|
return ()=>{
|
|
698
675
|
document.removeEventListener('mousemove', onMouseMove);
|
|
699
676
|
window.removeEventListener('editor:active-component', onActiveComponent);
|
|
@@ -703,6 +680,7 @@ const Toolbar = ()=>{
|
|
|
703
680
|
window.removeEventListener('editor:toolbar:show-parents', onShowParents);
|
|
704
681
|
window.removeEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
705
682
|
window.removeEventListener('editor:hover-component', onHoverComponent);
|
|
683
|
+
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
706
684
|
};
|
|
707
685
|
}, [
|
|
708
686
|
onMouseMove,
|
|
@@ -712,7 +690,8 @@ const Toolbar = ()=>{
|
|
|
712
690
|
onIsEditingTextEditor,
|
|
713
691
|
onShowParents,
|
|
714
692
|
onResizeSpacing,
|
|
715
|
-
onHoverComponent
|
|
693
|
+
onHoverComponent,
|
|
694
|
+
onComponentReRender
|
|
716
695
|
]);
|
|
717
696
|
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
718
697
|
};
|
|
@@ -41,6 +41,7 @@ const Toolbox = ()=>{
|
|
|
41
41
|
const setInteractionItem = core.usePageStore((s)=>s.setInteractionItem);
|
|
42
42
|
const setInteractionSelectType = core.usePageStore((s)=>s.setInteractionSelectType);
|
|
43
43
|
const setInteractionSettingType = core.usePageStore((s)=>s.setInteractionSettingType);
|
|
44
|
+
const setSidebarMode = core.usePageStore((s)=>s.setSidebarMode);
|
|
44
45
|
const fonts = react.useMemo(()=>genFonts.getFontsFromDataBuilder(state), [
|
|
45
46
|
state
|
|
46
47
|
]);
|
|
@@ -359,6 +360,13 @@ const Toolbox = ()=>{
|
|
|
359
360
|
}, [
|
|
360
361
|
setInteractionSettingType
|
|
361
362
|
]);
|
|
363
|
+
const onChangeSidebarMode = react.useCallback((e)=>{
|
|
364
|
+
const mode = e.detail.mode;
|
|
365
|
+
console.log(mode);
|
|
366
|
+
setSidebarMode(mode);
|
|
367
|
+
}, [
|
|
368
|
+
setSidebarMode
|
|
369
|
+
]);
|
|
362
370
|
const onUpdateInteractionItem = react.useCallback((e)=>{
|
|
363
371
|
const interactionItem = e.detail;
|
|
364
372
|
setInteractionItem(interactionItem);
|
|
@@ -396,6 +404,7 @@ const Toolbox = ()=>{
|
|
|
396
404
|
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
397
405
|
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
398
406
|
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
407
|
+
window.addEventListener('change-sidebar-mode', onChangeSidebarMode);
|
|
399
408
|
return ()=>{
|
|
400
409
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
401
410
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -443,7 +452,8 @@ const Toolbox = ()=>{
|
|
|
443
452
|
onLimitCreateThemeSection,
|
|
444
453
|
onUpdateInteractionItem,
|
|
445
454
|
onUpdateInteractionIsSelectOnPage,
|
|
446
|
-
onUpdateInteractionSettingType
|
|
455
|
+
onUpdateInteractionSettingType,
|
|
456
|
+
onChangeSidebarMode
|
|
447
457
|
]);
|
|
448
458
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
449
459
|
className: "toolbox"
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const TOOLBAR_HOVER_HEIGHT = 24;
|
|
4
4
|
const TOOLBAR_ACTIVE_HEIGHT = 32;
|
|
5
|
-
const COMPONENTS_TAG_NOT_LOAD_IMAGES = [
|
|
6
|
-
'PostPurchaseProductImages'
|
|
7
|
-
];
|
|
8
5
|
|
|
9
|
-
exports.COMPONENTS_TAG_NOT_LOAD_IMAGES = COMPONENTS_TAG_NOT_LOAD_IMAGES;
|
|
10
6
|
exports.TOOLBAR_ACTIVE_HEIGHT = TOOLBAR_ACTIVE_HEIGHT;
|
|
11
7
|
exports.TOOLBAR_HOVER_HEIGHT = TOOLBAR_HOVER_HEIGHT;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const waitForElementToExist = (selector, timeout = 200)=>{
|
|
4
4
|
return new Promise((resolve)=>{
|
|
5
|
+
let intervalID = null;
|
|
6
|
+
let timeoutID = null;
|
|
5
7
|
const findEl = ()=>{
|
|
6
8
|
const el = document.body.querySelector('#storefront')?.querySelector(selector);
|
|
7
9
|
if (el) {
|
|
@@ -11,10 +13,10 @@ const waitForElementToExist = (selector, timeout = 200)=>{
|
|
|
11
13
|
}
|
|
12
14
|
};
|
|
13
15
|
findEl();
|
|
14
|
-
|
|
16
|
+
intervalID = setInterval(()=>{
|
|
15
17
|
findEl();
|
|
16
18
|
}, 50);
|
|
17
|
-
|
|
19
|
+
timeoutID = setTimeout(()=>{
|
|
18
20
|
if (intervalID) clearInterval(intervalID);
|
|
19
21
|
if (timeoutID) clearTimeout(timeoutID);
|
|
20
22
|
resolve(null);
|
|
@@ -139,8 +139,7 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
139
139
|
facebookPixelId: dataBuilder.themePageAnalytic?.fbPixelID ?? null,
|
|
140
140
|
tiktokPixelId: dataBuilder.themePageAnalytic?.tiktokPixelID ?? null,
|
|
141
141
|
customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
|
|
142
|
-
customCodeBody: dataBuilder.themePageCustomCode?.body ?? null
|
|
143
|
-
interaction: dataBuilder?.interaction
|
|
142
|
+
customCodeBody: dataBuilder.themePageCustomCode?.body ?? null
|
|
144
143
|
});
|
|
145
144
|
} catch (err) {
|
|
146
145
|
nextjs.captureException(err);
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { usePageStore, RenderPreview } from '@gem-sdk/core';
|
|
3
|
+
import { usePageStore, cls, RenderPreview } from '@gem-sdk/core';
|
|
4
4
|
import CollectionGlobalProvider from '../../pages/CollectionGlobalProvider.js';
|
|
5
5
|
|
|
6
6
|
const Body = ({ pageType, isThemeSectionEditor })=>{
|
|
7
7
|
const interactionData = usePageStore((s)=>s.interactionData);
|
|
8
|
+
const sidebarMode = usePageStore((s)=>s.sidebarMode);
|
|
8
9
|
const isInteractionSelectModeClass = useMemo(()=>interactionData?.isSelectOnPage ? 'interaction-select-mode' : '', [
|
|
9
10
|
interactionData?.isSelectOnPage
|
|
10
11
|
]);
|
|
12
|
+
const isInteractionMode = useMemo(()=>sidebarMode === 'interaction' && !interactionData?.isSelectOnPage, [
|
|
13
|
+
sidebarMode,
|
|
14
|
+
interactionData?.isSelectOnPage
|
|
15
|
+
]);
|
|
11
16
|
return /*#__PURE__*/ jsx("div", {
|
|
12
17
|
id: "storefront",
|
|
13
|
-
className:
|
|
18
|
+
className: cls(isThemeSectionEditor ? 'theme-section-editor' : '', pageType === 'POST_PURCHASE' ? 'post-purchase-page' : '', isInteractionSelectModeClass),
|
|
19
|
+
style: {
|
|
20
|
+
pointerEvents: isInteractionMode ? 'none' : 'auto'
|
|
21
|
+
},
|
|
14
22
|
children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsx(CollectionGlobalProvider, {
|
|
15
23
|
children: /*#__PURE__*/ jsx(RenderPreview, {
|
|
16
24
|
uid: "ROOT"
|
|
@@ -18,7 +18,7 @@ const sizeCheck = {
|
|
|
18
18
|
const Header = (props)=>{
|
|
19
19
|
const { pageType, isOriginTemplate, openPageSetting } = props;
|
|
20
20
|
const layoutSetting = useShopStore((s)=>s.layoutSettings);
|
|
21
|
-
const
|
|
21
|
+
const sidebarMode = usePageStore((s)=>s.sidebarMode);
|
|
22
22
|
const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
|
|
23
23
|
const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
|
|
24
24
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -177,7 +177,7 @@ const Header = (props)=>{
|
|
|
177
177
|
]
|
|
178
178
|
})
|
|
179
179
|
}),
|
|
180
|
-
|
|
180
|
+
sidebarMode === 'interaction' && /*#__PURE__*/ jsx(InteractionSelectOnPageHeader, {})
|
|
181
181
|
]
|
|
182
182
|
});
|
|
183
183
|
};
|
|
@@ -10,6 +10,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
10
10
|
const [hoverOption, setHoverOption] = useState(null);
|
|
11
11
|
const [openDropdown, setOpenDropdown] = useState(false);
|
|
12
12
|
const popupRef = useRef(null);
|
|
13
|
+
const isSelectOnPage = usePageStore((s)=>s.interactionData?.isSelectOnPage);
|
|
13
14
|
const handleSetInteraction = (type)=>{
|
|
14
15
|
setOpenDropdown(false);
|
|
15
16
|
setInteractionSelectType(type);
|
|
@@ -66,7 +67,7 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
66
67
|
};
|
|
67
68
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
68
69
|
children: [
|
|
69
|
-
/*#__PURE__*/ jsx("header", {
|
|
70
|
+
isSelectOnPage && /*#__PURE__*/ jsx("header", {
|
|
70
71
|
className: "gp-flex gp-text-[12px] gp-justify-center gp-items-center gp-h-10 gp-fixed gp-top-0 gp-left-0 gp-w-full gp-z-[1000] gp-bg-[#151515] gp-text-white interaction-select-mode-header",
|
|
71
72
|
children: /*#__PURE__*/ jsxs("section", {
|
|
72
73
|
className: "gp-flex gp-bg-[#151515]/[0.15] gp-items-center gp-h-full gp-rounded-b-lg gp-pt-1 gp-gap-2",
|
|
@@ -174,7 +175,9 @@ const InteractionSelectOnPageHeader = ()=>{
|
|
|
174
175
|
})
|
|
175
176
|
}),
|
|
176
177
|
/*#__PURE__*/ jsx("div", {
|
|
177
|
-
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-mt-[40px] gp-z-[999] ${isShowOverlay ? 'gp-z-[999] gp-bg-[#3c67ff]/[0.25]' : '
|
|
178
|
+
className: `gp-w-full gp-fixed gp-top-0 gp-left-0 gp-mt-[40px] gp-z-[999] ${isShowOverlay ? 'gp-z-[999] gp-bg-[#3c67ff]/[0.25]' : ''}
|
|
179
|
+
${isSelectOnPage ? 'gp-pointer-events-none' : 'gp-pointer-events-auto'}
|
|
180
|
+
`,
|
|
178
181
|
style: {
|
|
179
182
|
height: 'calc(100% - 40px)'
|
|
180
183
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { memo, useRef, useCallback, useEffect } from 'react';
|
|
3
3
|
import { getDOMElementParents } from './toolbar/utils/getDOMElementParents.js';
|
|
4
|
-
import { TOOLBAR_ACTIVE_HEIGHT, TOOLBAR_HOVER_HEIGHT
|
|
4
|
+
import { TOOLBAR_ACTIVE_HEIGHT, TOOLBAR_HOVER_HEIGHT } from './toolbar/const.js';
|
|
5
5
|
import { getChildrenByAttrSelector } from './toolbar/utils/getChildrenByAttrSelector.js';
|
|
6
6
|
import { findOverflowParent } from './toolbar/utils/findOverflowParent.js';
|
|
7
7
|
import { waitForElementToExist } from './toolbar/utils/waitForElementToExist.js';
|
|
@@ -255,32 +255,6 @@ const Toolbar = ()=>{
|
|
|
255
255
|
setFocusTextEditor(false);
|
|
256
256
|
if (stopWatchReRenderComponent.current) stopWatchReRenderComponent.current();
|
|
257
257
|
}, []);
|
|
258
|
-
const watchComponentReRender = ($el, callback)=>{
|
|
259
|
-
// editor:component:render
|
|
260
|
-
const onComponentReRender = (e)=>{
|
|
261
|
-
const detail = e.detail;
|
|
262
|
-
if (detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
263
|
-
callback();
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
267
|
-
window.addEventListener('editor:component:render', onComponentReRender);
|
|
268
|
-
const componentTag = $el.getAttribute('data-component-tag');
|
|
269
|
-
// hotfix cho sale funnel release, nhưng cần tìm solution cho phần này
|
|
270
|
-
if (componentTag && !COMPONENTS_TAG_NOT_LOAD_IMAGES.includes(componentTag)) {
|
|
271
|
-
const $images = $el.querySelectorAll('img');
|
|
272
|
-
if ($images?.length) {
|
|
273
|
-
$images.forEach(($img)=>{
|
|
274
|
-
$img.addEventListener('load', ()=>{
|
|
275
|
-
callback();
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
stopWatchReRenderComponent.current = ()=>{
|
|
281
|
-
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
282
|
-
};
|
|
283
|
-
};
|
|
284
258
|
const setActiveComponentSpacing = useCallback(({ $component })=>{
|
|
285
259
|
if (!$component) return;
|
|
286
260
|
const style = getComputedStyle($component);
|
|
@@ -371,16 +345,6 @@ const Toolbar = ()=>{
|
|
|
371
345
|
$component
|
|
372
346
|
});
|
|
373
347
|
removeHoverComponent();
|
|
374
|
-
// Reactive when component re-render
|
|
375
|
-
watchComponentReRender($component, ()=>{
|
|
376
|
-
setActiveComponent({
|
|
377
|
-
componentUid,
|
|
378
|
-
productId,
|
|
379
|
-
articleId,
|
|
380
|
-
timeAwait: 2000,
|
|
381
|
-
forceReActive: true
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
348
|
}, [
|
|
385
349
|
removeActiveComponent,
|
|
386
350
|
removeHoverComponent,
|
|
@@ -400,9 +364,10 @@ const Toolbar = ()=>{
|
|
|
400
364
|
}
|
|
401
365
|
} else {
|
|
402
366
|
if (currentComponentActive.current?.componentUid) {
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
367
|
+
const selector = getSelectorComponent({
|
|
368
|
+
...currentComponentActive.current
|
|
369
|
+
});
|
|
370
|
+
const $component = await waitForElementToExist(selector, 500);
|
|
406
371
|
if ($component) {
|
|
407
372
|
const $toolbar = getChildrenByAttrSelector($component, 'data-toolbar');
|
|
408
373
|
const $outline = getChildrenByAttrSelector($component, 'data-outline');
|
|
@@ -438,10 +403,13 @@ const Toolbar = ()=>{
|
|
|
438
403
|
}
|
|
439
404
|
}, []);
|
|
440
405
|
const setShowParents = async ({ value })=>{
|
|
441
|
-
if (!value) {
|
|
406
|
+
if (!value || !currentComponentActive.current) {
|
|
442
407
|
return;
|
|
443
408
|
}
|
|
444
|
-
const
|
|
409
|
+
const selector = getSelectorComponent({
|
|
410
|
+
...currentComponentActive.current
|
|
411
|
+
});
|
|
412
|
+
const $component = await waitForElementToExist(selector, 500);
|
|
445
413
|
if ($component) {
|
|
446
414
|
const $parents = $component?.querySelectorAll('[data-toolbar-parent]');
|
|
447
415
|
if ($parents.length) {
|
|
@@ -681,6 +649,14 @@ const Toolbar = ()=>{
|
|
|
681
649
|
}, [
|
|
682
650
|
isDragging
|
|
683
651
|
]);
|
|
652
|
+
const onComponentReRender = (e)=>{
|
|
653
|
+
const detail = e.detail;
|
|
654
|
+
if (currentComponentActive.current?.componentUid && detail?.componentUid == currentComponentActive.current?.componentUid) {
|
|
655
|
+
setActiveComponent({
|
|
656
|
+
...currentComponentActive.current
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
};
|
|
684
660
|
/* Register event */ useEffect(()=>{
|
|
685
661
|
document.addEventListener('mousemove', onMouseMove);
|
|
686
662
|
window.addEventListener('editor:active-component', onActiveComponent);
|
|
@@ -690,6 +666,7 @@ const Toolbar = ()=>{
|
|
|
690
666
|
window.addEventListener('editor:toolbar:show-parents', onShowParents);
|
|
691
667
|
window.addEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
692
668
|
window.addEventListener('editor:hover-component', onHoverComponent);
|
|
669
|
+
window.addEventListener('editor:component:render', onComponentReRender);
|
|
693
670
|
return ()=>{
|
|
694
671
|
document.removeEventListener('mousemove', onMouseMove);
|
|
695
672
|
window.removeEventListener('editor:active-component', onActiveComponent);
|
|
@@ -699,6 +676,7 @@ const Toolbar = ()=>{
|
|
|
699
676
|
window.removeEventListener('editor:toolbar:show-parents', onShowParents);
|
|
700
677
|
window.removeEventListener('editor:toolbar:resize-spacing', onResizeSpacing);
|
|
701
678
|
window.removeEventListener('editor:hover-component', onHoverComponent);
|
|
679
|
+
window.removeEventListener('editor:component:render', onComponentReRender);
|
|
702
680
|
};
|
|
703
681
|
}, [
|
|
704
682
|
onMouseMove,
|
|
@@ -708,7 +686,8 @@ const Toolbar = ()=>{
|
|
|
708
686
|
onIsEditingTextEditor,
|
|
709
687
|
onShowParents,
|
|
710
688
|
onResizeSpacing,
|
|
711
|
-
onHoverComponent
|
|
689
|
+
onHoverComponent,
|
|
690
|
+
onComponentReRender
|
|
712
691
|
]);
|
|
713
692
|
return /*#__PURE__*/ jsx(Fragment, {});
|
|
714
693
|
};
|
|
@@ -37,6 +37,7 @@ const Toolbox = ()=>{
|
|
|
37
37
|
const setInteractionItem = usePageStore((s)=>s.setInteractionItem);
|
|
38
38
|
const setInteractionSelectType = usePageStore((s)=>s.setInteractionSelectType);
|
|
39
39
|
const setInteractionSettingType = usePageStore((s)=>s.setInteractionSettingType);
|
|
40
|
+
const setSidebarMode = usePageStore((s)=>s.setSidebarMode);
|
|
40
41
|
const fonts = useMemo(()=>getFontsFromDataBuilder(state), [
|
|
41
42
|
state
|
|
42
43
|
]);
|
|
@@ -355,6 +356,13 @@ const Toolbox = ()=>{
|
|
|
355
356
|
}, [
|
|
356
357
|
setInteractionSettingType
|
|
357
358
|
]);
|
|
359
|
+
const onChangeSidebarMode = useCallback((e)=>{
|
|
360
|
+
const mode = e.detail.mode;
|
|
361
|
+
console.log(mode);
|
|
362
|
+
setSidebarMode(mode);
|
|
363
|
+
}, [
|
|
364
|
+
setSidebarMode
|
|
365
|
+
]);
|
|
358
366
|
const onUpdateInteractionItem = useCallback((e)=>{
|
|
359
367
|
const interactionItem = e.detail;
|
|
360
368
|
setInteractionItem(interactionItem);
|
|
@@ -392,6 +400,7 @@ const Toolbox = ()=>{
|
|
|
392
400
|
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
393
401
|
window.addEventListener('update-interaction-item', onUpdateInteractionItem);
|
|
394
402
|
window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
|
|
403
|
+
window.addEventListener('change-sidebar-mode', onChangeSidebarMode);
|
|
395
404
|
return ()=>{
|
|
396
405
|
window.removeEventListener('update-shop-info', onChangeShopInfo);
|
|
397
406
|
window.removeEventListener('revalidate-query', onRevalidateQuery);
|
|
@@ -439,7 +448,8 @@ const Toolbox = ()=>{
|
|
|
439
448
|
onLimitCreateThemeSection,
|
|
440
449
|
onUpdateInteractionItem,
|
|
441
450
|
onUpdateInteractionIsSelectOnPage,
|
|
442
|
-
onUpdateInteractionSettingType
|
|
451
|
+
onUpdateInteractionSettingType,
|
|
452
|
+
onChangeSidebarMode
|
|
443
453
|
]);
|
|
444
454
|
return /*#__PURE__*/ jsx("div", {
|
|
445
455
|
className: "toolbox"
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
const TOOLBAR_HOVER_HEIGHT = 24;
|
|
2
2
|
const TOOLBAR_ACTIVE_HEIGHT = 32;
|
|
3
|
-
const COMPONENTS_TAG_NOT_LOAD_IMAGES = [
|
|
4
|
-
'PostPurchaseProductImages'
|
|
5
|
-
];
|
|
6
3
|
|
|
7
|
-
export {
|
|
4
|
+
export { TOOLBAR_ACTIVE_HEIGHT, TOOLBAR_HOVER_HEIGHT };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const waitForElementToExist = (selector, timeout = 200)=>{
|
|
2
2
|
return new Promise((resolve)=>{
|
|
3
|
+
let intervalID = null;
|
|
4
|
+
let timeoutID = null;
|
|
3
5
|
const findEl = ()=>{
|
|
4
6
|
const el = document.body.querySelector('#storefront')?.querySelector(selector);
|
|
5
7
|
if (el) {
|
|
@@ -9,10 +11,10 @@ const waitForElementToExist = (selector, timeout = 200)=>{
|
|
|
9
11
|
}
|
|
10
12
|
};
|
|
11
13
|
findEl();
|
|
12
|
-
|
|
14
|
+
intervalID = setInterval(()=>{
|
|
13
15
|
findEl();
|
|
14
16
|
}, 50);
|
|
15
|
-
|
|
17
|
+
timeoutID = setTimeout(()=>{
|
|
16
18
|
if (intervalID) clearInterval(intervalID);
|
|
17
19
|
if (timeoutID) clearTimeout(timeoutID);
|
|
18
20
|
resolve(null);
|
|
@@ -137,8 +137,7 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
137
137
|
facebookPixelId: dataBuilder.themePageAnalytic?.fbPixelID ?? null,
|
|
138
138
|
tiktokPixelId: dataBuilder.themePageAnalytic?.tiktokPixelID ?? null,
|
|
139
139
|
customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
|
|
140
|
-
customCodeBody: dataBuilder.themePageCustomCode?.body ?? null
|
|
141
|
-
interaction: dataBuilder?.interaction
|
|
140
|
+
customCodeBody: dataBuilder.themePageCustomCode?.body ?? null
|
|
142
141
|
});
|
|
143
142
|
} catch (err) {
|
|
144
143
|
captureException(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "1.57.0
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"next": "latest"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "1.57.0
|
|
30
|
-
"@gem-sdk/plugin-cookie-bar": "1.57.0
|
|
31
|
-
"@gem-sdk/plugin-quick-view": "1.57.0
|
|
32
|
-
"@gem-sdk/plugin-sticky-add-to-cart": "1.57.0
|
|
29
|
+
"@gem-sdk/core": "1.57.0",
|
|
30
|
+
"@gem-sdk/plugin-cookie-bar": "1.57.0",
|
|
31
|
+
"@gem-sdk/plugin-quick-view": "1.57.0",
|
|
32
|
+
"@gem-sdk/plugin-sticky-add-to-cart": "1.57.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"next": ">=13"
|