@toototech/webbuilder-plugins 0.1.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/LICENSE +1 -0
- package/README.md +3 -0
- package/dist/basic/cssScope.d.ts +3 -0
- package/dist/basic/index.d.ts +81 -0
- package/dist/basic/injectStyle.d.ts +20 -0
- package/dist/basic/plugin.d.ts +19 -0
- package/dist/basic/publisher.d.ts +4 -0
- package/dist/basic/registries/interactive/accordion/index.d.ts +3 -0
- package/dist/basic/registries/interactive/backButton/index.d.ts +3 -0
- package/dist/basic/registries/interactive/button/index.d.ts +10 -0
- package/dist/basic/registries/interactive/countUp/index.d.ts +9 -0
- package/dist/basic/registries/interactive/customCode/index.d.ts +3 -0
- package/dist/basic/registries/interactive/index.d.ts +2 -0
- package/dist/basic/registries/interactive/inquiryForm/index.d.ts +3 -0
- package/dist/basic/registries/interactive/klaviyoSubscribe/index.d.ts +3 -0
- package/dist/basic/registries/interactive/popup/index.d.ts +5 -0
- package/dist/basic/registries/interactive/salesmartlyChatButton/index.d.ts +10 -0
- package/dist/basic/registries/interactive/search/index.d.ts +10 -0
- package/dist/basic/registries/interactive/socialShare/index.d.ts +33 -0
- package/dist/basic/registries/interactive/tabs/index.d.ts +3 -0
- package/dist/basic/registries/layout/container/index.d.ts +19 -0
- package/dist/basic/registries/layout/divider/index.d.ts +7 -0
- package/dist/basic/registries/layout/grid/index.d.ts +11 -0
- package/dist/basic/registries/layout/index.d.ts +2 -0
- package/dist/basic/registries/layout/layoutBase/index.d.ts +10 -0
- package/dist/basic/registries/layout/section/index.d.ts +3 -0
- package/dist/basic/registries/layout/sectionGridBlock/index.d.ts +3 -0
- package/dist/basic/registries/layout/spacer/index.d.ts +7 -0
- package/dist/basic/registries/media/banner/index.d.ts +11 -0
- package/dist/basic/registries/media/carousel/index.d.ts +6 -0
- package/dist/basic/registries/media/flipbook/index.d.ts +5 -0
- package/dist/basic/registries/media/icon/index.d.ts +3 -0
- package/dist/basic/registries/media/image/index.d.ts +3 -0
- package/dist/basic/registries/media/index.d.ts +2 -0
- package/dist/basic/registries/media/industryTabs/index.d.ts +3 -0
- package/dist/basic/registries/media/marquee/index.d.ts +4 -0
- package/dist/basic/registries/media/ourSolutions/helpers.d.ts +289 -0
- package/dist/basic/registries/media/ourSolutions/index.d.ts +4 -0
- package/dist/basic/registries/media/ourSolutions/script.d.ts +1 -0
- package/dist/basic/registries/media/ourSolutions/style.d.ts +1 -0
- package/dist/basic/registries/media/pdfViewer/index.d.ts +3 -0
- package/dist/basic/registries/media/productCategories/index.d.ts +4 -0
- package/dist/basic/registries/media/tabMediaGallery/index.d.ts +3 -0
- package/dist/basic/registries/media/video/index.d.ts +12 -0
- package/dist/basic/registries/navigation/footer/index.d.ts +10 -0
- package/dist/basic/registries/navigation/index.d.ts +2 -0
- package/dist/basic/registries/navigation/languageSwitcher/index.d.ts +6 -0
- package/dist/basic/registries/navigation/logo/index.d.ts +9 -0
- package/dist/basic/registries/navigation/navbar/constants.d.ts +38 -0
- package/dist/basic/registries/navigation/navbar/factories.d.ts +848 -0
- package/dist/basic/registries/navigation/navbar/helpers.d.ts +12 -0
- package/dist/basic/registries/navigation/navbar/index.d.ts +4 -0
- package/dist/basic/registries/navigation/navbar/registerMegaTypes.d.ts +2 -0
- package/dist/basic/registries/navigation/navbar/registerMenuTypes.d.ts +2 -0
- package/dist/basic/registries/navigation/navbar/registerRootTypes.d.ts +2 -0
- package/dist/basic/registries/navigation/navbar/script.d.ts +1 -0
- package/dist/basic/registries/navigation/navbar/style.d.ts +1 -0
- package/dist/basic/registries/navigation/socialLinks/index.d.ts +3 -0
- package/dist/basic/registries/section/allApplications/index.d.ts +3 -0
- package/dist/basic/registries/section/cardCarouselSection/index.d.ts +3 -0
- package/dist/basic/registries/section/caseSpotlight/index.d.ts +3 -0
- package/dist/basic/registries/section/companyScale/index.d.ts +3 -0
- package/dist/basic/registries/section/customizationGrid/index.d.ts +3 -0
- package/dist/basic/registries/section/factoryMap/index.d.ts +3 -0
- package/dist/basic/registries/section/focaHistoryTimeline/index.d.ts +3 -0
- package/dist/basic/registries/section/historyTimeline/index.d.ts +3 -0
- package/dist/basic/registries/section/homeBannerCarousel/index.d.ts +4 -0
- package/dist/basic/registries/section/hotspotShowcase/index.d.ts +30 -0
- package/dist/basic/registries/section/index.d.ts +2 -0
- package/dist/basic/registries/section/map/index.d.ts +4 -0
- package/dist/basic/registries/section/milestoneCardStrip/index.d.ts +3 -0
- package/dist/basic/registries/section/moreCardCarousel/index.d.ts +3 -0
- package/dist/basic/registries/section/ourAdvantages/index.d.ts +4 -0
- package/dist/basic/registries/section/overviewSplit/index.d.ts +3 -0
- package/dist/basic/registries/section/processTimeline/index.d.ts +3 -0
- package/dist/basic/registries/section/productCardStrip/index.d.ts +3 -0
- package/dist/basic/registries/section/resourceSection/index.d.ts +6 -0
- package/dist/basic/registries/section/responsiveHeroCarousel/index.d.ts +4 -0
- package/dist/basic/registries/section/serviceIconGrid/index.d.ts +4 -0
- package/dist/basic/registries/section/servicesCarousel/index.d.ts +4 -0
- package/dist/basic/registries/section/servicesShowcase/index.d.ts +4 -0
- package/dist/basic/registries/section/servicesThb/index.d.ts +4 -0
- package/dist/basic/registries/section/solutionList/index.d.ts +4 -0
- package/dist/basic/registries/section/staticPinMap/index.d.ts +4 -0
- package/dist/basic/registries/section/statsCards/index.d.ts +3 -0
- package/dist/basic/registries/section/swiperRuntime.d.ts +3 -0
- package/dist/basic/registries/shared/sharedTraits.d.ts +37 -0
- package/dist/basic/registries/types.d.ts +5 -0
- package/dist/basic/registries/typography/heading/index.d.ts +8 -0
- package/dist/basic/registries/typography/index.d.ts +2 -0
- package/dist/basic/registries/typography/textEditor/index.d.ts +6 -0
- package/dist/basic/registryManifest.d.ts +9 -0
- package/dist/basic/styleHelpers.d.ts +29 -0
- package/dist/basic/svgIcon.d.ts +11 -0
- package/dist/basic/traitBridge.d.ts +20 -0
- package/dist/basic/traitFactory.d.ts +106 -0
- package/dist/basic.js +1146 -0
- package/dist/cms/cmsFactory.d.ts +164 -0
- package/dist/cms/dynamicRenderPipeline.d.ts +12 -0
- package/dist/cms/index.d.ts +31 -0
- package/dist/cms/plugin.d.ts +12 -0
- package/dist/cms/publisher.d.ts +7 -0
- package/dist/cms/registries/dynamic/cms/constants.d.ts +16 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/bindings.d.ts +78 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/breadcrumbBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/conditionalBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/datetimeBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/htmlBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/imageBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/linkBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/seoBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/textBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/blocks/tocBlock.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/constants.d.ts +19 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/helpers.d.ts +52 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/registerBlock.d.ts +57 -0
- package/dist/cms/registries/dynamic/cms/dynamicField/styles.d.ts +7 -0
- package/dist/cms/registries/dynamic/cms/media/previewMediaTrait.d.ts +7 -0
- package/dist/cms/registries/dynamic/cms/menu/siteMenuAttrs.d.ts +11 -0
- package/dist/cms/registries/dynamic/cms/menuTree/menuTreeAttrs.d.ts +8 -0
- package/dist/cms/registries/dynamic/cms/post/styles.d.ts +6 -0
- package/dist/cms/registries/dynamic/cms/product/detail.styles.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/product/detailV2.styles.d.ts +1 -0
- package/dist/cms/registries/dynamic/cms/product/previewProductTrait.d.ts +6 -0
- package/dist/cms/registries/dynamic/cms/product/styles.d.ts +6 -0
- package/dist/cms/registries/dynamic/dataProvider.d.ts +45 -0
- package/dist/cms/registries/dynamic/loopGrid/paginationStyles.d.ts +5 -0
- package/dist/cms/registries/dynamic/loopGrid/preview.d.ts +16 -0
- package/dist/cms/registries/dynamic/loopGrid/publisher.d.ts +3 -0
- package/dist/cms/registries/dynamic/loopGrid/types.d.ts +97 -0
- package/dist/cms/registries/navigation/navbarThb/index.d.ts +3 -0
- package/dist/cms/registries/navigation/navbarThb/script.d.ts +1 -0
- package/dist/cms/registries/navigation/navbarThb/style.d.ts +1 -0
- package/dist/cms.js +4535 -0
- package/dist/global-settings/components/FontFamilySelect.vue.d.ts +29 -0
- package/dist/global-settings/components/FontManagerPanel.vue.d.ts +37 -0
- package/dist/global-settings/index.d.ts +8 -0
- package/dist/global-settings/plugin.d.ts +3 -0
- package/dist/global-settings/publisher.d.ts +15 -0
- package/dist/global-settings/runtime/canvasInjection.d.ts +13 -0
- package/dist/global-settings/runtime/panelDraftSave.d.ts +17 -0
- package/dist/global-settings/runtime/settingsSource.d.ts +4 -0
- package/dist/global-settings/useFontManager.d.ts +38 -0
- package/dist/global-settings/useGoogleFonts.d.ts +20 -0
- package/dist/global-settings/vue.d.ts +1 -0
- package/dist/global-settings.js +66 -0
- package/dist/i18n/I18nPanel.vue.d.ts +23 -0
- package/dist/i18n/i18n.d.ts +25 -0
- package/dist/i18n/index.d.ts +7 -0
- package/dist/i18n/languageOrder.d.ts +9 -0
- package/dist/i18n/plugin.d.ts +21 -0
- package/dist/i18n/types.d.ts +101 -0
- package/dist/i18n/useWebBuilderI18n.d.ts +164 -0
- package/dist/i18n/vue.d.ts +1 -0
- package/dist/i18n-BYR3l48y.js +959 -0
- package/dist/i18n.js +929 -0
- package/dist/index-CxJlLwvG.js +35378 -0
- package/dist/index-DWfJ4PBm.js +5724 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +12 -0
- package/dist/layout-template/components/LayoutPanel.vue.d.ts +37 -0
- package/dist/layout-template/components/TemplateRulesPanel.vue.d.ts +41 -0
- package/dist/layout-template/config/layoutSharedResources.d.ts +9 -0
- package/dist/layout-template/config/templateSharedResources.d.ts +28 -0
- package/dist/layout-template/index.d.ts +9 -0
- package/dist/layout-template/plugin.d.ts +13 -0
- package/dist/layout-template/runtime/storageAdapter.d.ts +49 -0
- package/dist/layout-template/utils/layoutProjectData.d.ts +15 -0
- package/dist/layout-template/utils/layoutRulePages.d.ts +19 -0
- package/dist/layout-template/utils/layoutSettings.d.ts +45 -0
- package/dist/layout-template/utils/templateRules.d.ts +52 -0
- package/dist/layout-template/vue.d.ts +2 -0
- package/dist/layout-template.js +435 -0
- package/dist/layoutSettings-D4SYUMri.js +252 -0
- package/dist/plugin-BPA8qlaC.js +40 -0
- package/dist/plugin-C0PrxrIe.js +228 -0
- package/dist/plugin-DQshk1sY.js +361 -0
- package/dist/plugin-DebyCjXx.js +191 -0
- package/dist/plugin-Dr6TOtyH.js +73 -0
- package/dist/publisher/index.d.ts +5 -0
- package/dist/publisher/publisherAssets.d.ts +9 -0
- package/dist/publisher/publisherComponents.d.ts +7 -0
- package/dist/publisher/publisherPlugins.d.ts +12 -0
- package/dist/publisher-C6VWXq8u.js +25 -0
- package/dist/publisher.js +1711 -0
- package/dist/solar-BsElUqfQ.js +29843 -0
- package/dist/style.css +1181 -0
- package/dist/templateSharedResources-D1u7eFIs.js +89 -0
- package/dist/types-DNbok59z.js +2359 -0
- package/dist/useFontManager-CdrLq1eG.js +336 -0
- package/dist/vue.d.ts +3 -0
- package/dist/vue.js +2171 -0
- package/package.json +77 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const LAYOUT_TEMPLATE_PLUGIN_ID = "layout-template";
|
|
2
|
+
const createPanel = (id, label, order, panel) => ({
|
|
3
|
+
id,
|
|
4
|
+
label: (panel == null ? void 0 : panel.label) ?? label,
|
|
5
|
+
order: (panel == null ? void 0 : panel.order) ?? order,
|
|
6
|
+
...(panel == null ? void 0 : panel.icon) ? { icon: panel.icon } : {},
|
|
7
|
+
...(panel == null ? void 0 : panel.preserveOnSelection) !== void 0 ? { preserveOnSelection: panel.preserveOnSelection } : {},
|
|
8
|
+
...(panel == null ? void 0 : panel.component) !== void 0 ? { component: panel.component } : {},
|
|
9
|
+
...(panel == null ? void 0 : panel.props) !== void 0 ? { props: panel.props } : {}
|
|
10
|
+
});
|
|
11
|
+
const createLayoutTemplatePlugin = (runtime = {}) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return {
|
|
14
|
+
id: LAYOUT_TEMPLATE_PLUGIN_ID,
|
|
15
|
+
label: "Layout Template",
|
|
16
|
+
order: 40,
|
|
17
|
+
alwaysEnabled: true,
|
|
18
|
+
panels: [
|
|
19
|
+
createPanel("layout", "Layout", 40, (_a = runtime.panels) == null ? void 0 : _a.layout),
|
|
20
|
+
createPanel("template", "Template", 50, (_b = runtime.panels) == null ? void 0 : _b.template)
|
|
21
|
+
],
|
|
22
|
+
resources: [
|
|
23
|
+
(context) => {
|
|
24
|
+
var _a2, _b2;
|
|
25
|
+
return [
|
|
26
|
+
...((_a2 = runtime.collectResourceParticipants) == null ? void 0 : _a2.call(runtime, context)) ?? [],
|
|
27
|
+
...((_b2 = runtime.collectLockParticipants) == null ? void 0 : _b2.call(runtime, context)) ?? []
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
beforeProjectLoad: (context) => {
|
|
32
|
+
var _a2;
|
|
33
|
+
return (_a2 = runtime.beforeProjectLoad) == null ? void 0 : _a2.call(runtime, context);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
LAYOUT_TEMPLATE_PLUGIN_ID as L,
|
|
39
|
+
createLayoutTemplatePlugin as c
|
|
40
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { hasWebBuilderCapability } from "@toototech/webbuilder/core";
|
|
2
|
+
const CMS_COMPONENTS_PLUGIN_ID = "cms-components";
|
|
3
|
+
const CMS_COMPONENTS_CAPABILITY = "webbuilder:cms-components";
|
|
4
|
+
const CMS_COMPONENT_LOAD_TYPES = [
|
|
5
|
+
"wb-cms-post-list",
|
|
6
|
+
"wb-cms-post-card",
|
|
7
|
+
"wb-cms-cases-list",
|
|
8
|
+
"wb-cms-cases-card",
|
|
9
|
+
"wb-cms-post-category-filter",
|
|
10
|
+
"wb-cms-post-latest",
|
|
11
|
+
"wb-cms-post-detail",
|
|
12
|
+
"wb-cms-media-list",
|
|
13
|
+
"wb-cms-technical-service-list",
|
|
14
|
+
"wb-cms-technical-service-card",
|
|
15
|
+
"wb-cms-technical-download-list",
|
|
16
|
+
"wb-cms-technical-download-item",
|
|
17
|
+
"wb-cms-technical-support-detail",
|
|
18
|
+
"wb-cms-media-latest",
|
|
19
|
+
"wb-cms-media-detail",
|
|
20
|
+
"wb-cms-product-list",
|
|
21
|
+
"wb-cms-product-card",
|
|
22
|
+
"wb-cms-product-datasheet-list",
|
|
23
|
+
"wb-cms-product-latest",
|
|
24
|
+
"wb-cms-product-featured",
|
|
25
|
+
"wb-cms-product-related",
|
|
26
|
+
"wb-cms-product-detail",
|
|
27
|
+
"wb-cms-product-detail-v2",
|
|
28
|
+
"wb-cms-faq-section",
|
|
29
|
+
"wb-cms-product-category-faq",
|
|
30
|
+
"wb-cms-search",
|
|
31
|
+
"wb-cms-site-menu",
|
|
32
|
+
"wb-cms-menu-tree",
|
|
33
|
+
"wb-cms-dynamic-text",
|
|
34
|
+
"wb-cms-dynamic-html",
|
|
35
|
+
"wb-cms-dynamic-image",
|
|
36
|
+
"wb-cms-dynamic-link",
|
|
37
|
+
"wb-cms-dynamic-datetime",
|
|
38
|
+
"wb-cms-dynamic-if",
|
|
39
|
+
"wb-cms-dynamic-repeat",
|
|
40
|
+
"wb-cms-dynamic-repeat-item",
|
|
41
|
+
"wb-cms-dynamic-seo",
|
|
42
|
+
"wb-cms-dynamic-toc",
|
|
43
|
+
"wb-cms-dynamic-breadcrumb",
|
|
44
|
+
"wb-loop-grid",
|
|
45
|
+
"wb-ssg-field"
|
|
46
|
+
];
|
|
47
|
+
const CMS_COMPONENT_REQUIRED_HOST_SERVICES = [
|
|
48
|
+
"post",
|
|
49
|
+
"media",
|
|
50
|
+
"product",
|
|
51
|
+
"menu",
|
|
52
|
+
"faq",
|
|
53
|
+
"inquiry"
|
|
54
|
+
];
|
|
55
|
+
const CMS_DYNAMIC_BLOCKS = [
|
|
56
|
+
{
|
|
57
|
+
id: "cms-post-card",
|
|
58
|
+
label: "文章卡片",
|
|
59
|
+
category: "CMS",
|
|
60
|
+
order: 5,
|
|
61
|
+
media: "lucide:newspaper",
|
|
62
|
+
content: { type: "wb-cms-post-card" },
|
|
63
|
+
componentTypes: ["wb-cms-post-card"]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "cms-dynamic-text",
|
|
67
|
+
label: "动态文本",
|
|
68
|
+
category: "CMS Dynamic",
|
|
69
|
+
order: 10,
|
|
70
|
+
media: "lucide:type",
|
|
71
|
+
content: { type: "wb-cms-dynamic-text" },
|
|
72
|
+
componentTypes: ["wb-cms-dynamic-text"]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "cms-dynamic-html",
|
|
76
|
+
label: "动态 HTML",
|
|
77
|
+
category: "CMS Dynamic",
|
|
78
|
+
order: 20,
|
|
79
|
+
media: "lucide:code",
|
|
80
|
+
content: { type: "wb-cms-dynamic-html" },
|
|
81
|
+
componentTypes: ["wb-cms-dynamic-html"]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "cms-dynamic-image",
|
|
85
|
+
label: "动态图片",
|
|
86
|
+
category: "CMS Dynamic",
|
|
87
|
+
order: 30,
|
|
88
|
+
media: "lucide:image",
|
|
89
|
+
content: { type: "wb-cms-dynamic-image" },
|
|
90
|
+
componentTypes: ["wb-cms-dynamic-image"]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: "cms-dynamic-link",
|
|
94
|
+
label: "动态链接",
|
|
95
|
+
category: "CMS Dynamic",
|
|
96
|
+
order: 40,
|
|
97
|
+
media: "lucide:link",
|
|
98
|
+
content: { type: "wb-cms-dynamic-link" },
|
|
99
|
+
componentTypes: ["wb-cms-dynamic-link"]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "cms-dynamic-datetime",
|
|
103
|
+
label: "动态日期",
|
|
104
|
+
category: "CMS Dynamic",
|
|
105
|
+
order: 50,
|
|
106
|
+
media: "lucide:calendar",
|
|
107
|
+
content: { type: "wb-cms-dynamic-datetime" },
|
|
108
|
+
componentTypes: ["wb-cms-dynamic-datetime"]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "cms-dynamic-if",
|
|
112
|
+
label: "条件显示",
|
|
113
|
+
category: "CMS Dynamic",
|
|
114
|
+
order: 60,
|
|
115
|
+
media: "lucide:split",
|
|
116
|
+
content: { type: "wb-cms-dynamic-if" },
|
|
117
|
+
componentTypes: ["wb-cms-dynamic-if"]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: "cms-dynamic-repeat",
|
|
121
|
+
label: "动态循环",
|
|
122
|
+
category: "CMS Dynamic",
|
|
123
|
+
order: 70,
|
|
124
|
+
media: "lucide:repeat",
|
|
125
|
+
content: { type: "wb-cms-dynamic-repeat" },
|
|
126
|
+
componentTypes: ["wb-cms-dynamic-repeat"]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: "cms-dynamic-breadcrumb",
|
|
130
|
+
label: "面包屑导航",
|
|
131
|
+
category: "CMS Dynamic",
|
|
132
|
+
order: 80,
|
|
133
|
+
media: "lucide:chevrons-right",
|
|
134
|
+
content: { type: "wb-cms-dynamic-breadcrumb" },
|
|
135
|
+
componentTypes: ["wb-cms-dynamic-breadcrumb"]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "cms-dynamic-toc",
|
|
139
|
+
label: "文章目录",
|
|
140
|
+
category: "CMS Dynamic",
|
|
141
|
+
order: 90,
|
|
142
|
+
media: "lucide:list-tree",
|
|
143
|
+
content: { type: "wb-cms-dynamic-toc" },
|
|
144
|
+
componentTypes: ["wb-cms-dynamic-toc"]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: "cms-dynamic-seo",
|
|
148
|
+
label: "SEO Meta",
|
|
149
|
+
category: "CMS Dynamic",
|
|
150
|
+
order: 100,
|
|
151
|
+
media: "lucide:search",
|
|
152
|
+
content: { type: "wb-cms-dynamic-seo" },
|
|
153
|
+
componentTypes: ["wb-cms-dynamic-seo"]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "cms-loop-grid",
|
|
157
|
+
label: "CMS Loop Grid",
|
|
158
|
+
category: "CMS Dynamic",
|
|
159
|
+
order: 110,
|
|
160
|
+
media: "lucide:grid-3x3",
|
|
161
|
+
content: { type: "wb-loop-grid" },
|
|
162
|
+
componentTypes: ["wb-loop-grid"]
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: "cms-ssg-field",
|
|
166
|
+
label: "SSG 字段",
|
|
167
|
+
category: "CMS Dynamic",
|
|
168
|
+
order: 120,
|
|
169
|
+
media: "lucide:braces",
|
|
170
|
+
content: { type: "wb-ssg-field" },
|
|
171
|
+
componentTypes: ["wb-ssg-field"]
|
|
172
|
+
}
|
|
173
|
+
];
|
|
174
|
+
const runCleanupStack = (cleanups) => {
|
|
175
|
+
cleanups.slice().reverse().forEach((cleanup) => cleanup());
|
|
176
|
+
};
|
|
177
|
+
const collectRuntimeBlockPacks = (runtime) => (context) => {
|
|
178
|
+
var _a;
|
|
179
|
+
const packs = ((_a = runtime.blockPacks) == null ? void 0 : _a.call(runtime, context)) ?? [
|
|
180
|
+
{
|
|
181
|
+
id: "cms-dynamic-fields",
|
|
182
|
+
label: "CMS Dynamic Fields",
|
|
183
|
+
order: 90,
|
|
184
|
+
blocks: CMS_DYNAMIC_BLOCKS.filter(
|
|
185
|
+
(block) => (block.componentTypes ?? []).every((type) => context.canInsertComponentType(type))
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
];
|
|
189
|
+
return packs.filter((pack) => Boolean(pack));
|
|
190
|
+
};
|
|
191
|
+
const createCmsComponentsPlugin = (runtime = {}) => ({
|
|
192
|
+
id: CMS_COMPONENTS_PLUGIN_ID,
|
|
193
|
+
label: "CMS Components",
|
|
194
|
+
order: 90,
|
|
195
|
+
requiredHostServices: [...CMS_COMPONENT_REQUIRED_HOST_SERVICES],
|
|
196
|
+
loadComponentTypes: [...CMS_COMPONENT_LOAD_TYPES],
|
|
197
|
+
insertComponentTypes: [...CMS_COMPONENT_LOAD_TYPES],
|
|
198
|
+
activateWhen: (context) => hasWebBuilderCapability(context.capabilityIds, CMS_COMPONENTS_CAPABILITY),
|
|
199
|
+
blockPacks: [collectRuntimeBlockPacks(runtime)],
|
|
200
|
+
activateEditor(context) {
|
|
201
|
+
var _a, _b, _c;
|
|
202
|
+
const cleanups = [];
|
|
203
|
+
const addCleanup = (cleanup) => {
|
|
204
|
+
if (cleanup)
|
|
205
|
+
cleanups.push(cleanup);
|
|
206
|
+
};
|
|
207
|
+
try {
|
|
208
|
+
addCleanup((_a = runtime.activateEditor) == null ? void 0 : _a.call(runtime, context));
|
|
209
|
+
addCleanup((_b = runtime.activateCmsPreview) == null ? void 0 : _b.call(runtime, context));
|
|
210
|
+
addCleanup((_c = runtime.activateTemplatePreview) == null ? void 0 : _c.call(runtime, context));
|
|
211
|
+
} catch (error) {
|
|
212
|
+
runCleanupStack(cleanups);
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
return () => runCleanupStack(cleanups);
|
|
216
|
+
},
|
|
217
|
+
publisher: {
|
|
218
|
+
id: "publisher:cms-components",
|
|
219
|
+
order: 90
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
export {
|
|
223
|
+
CMS_COMPONENTS_CAPABILITY as C,
|
|
224
|
+
CMS_COMPONENTS_PLUGIN_ID as a,
|
|
225
|
+
CMS_COMPONENT_LOAD_TYPES as b,
|
|
226
|
+
createCmsComponentsPlugin as c,
|
|
227
|
+
CMS_COMPONENT_REQUIRED_HOST_SERVICES as d
|
|
228
|
+
};
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { WEB_BUILDER_PROJECT_PAINT_EVENT } from "@toototech/webbuilder/core";
|
|
2
|
+
const GLOBAL_SETTINGS_STYLE_IDS = {
|
|
3
|
+
colors: "wb-global-colors",
|
|
4
|
+
typography: "wb-global-font-family",
|
|
5
|
+
customCss: "wb-global-custom-css"
|
|
6
|
+
};
|
|
7
|
+
const GOOGLE_FONT_ATTR = "data-wb-gf";
|
|
8
|
+
const CUSTOM_CODE_ATTR = "data-wb-global-custom-code";
|
|
9
|
+
const CUSTOM_CODE_POSITION_ATTR = "data-wb-global-custom-code-position";
|
|
10
|
+
const HEADING_LEVELS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
11
|
+
const CUSTOM_CODE_POSITIONS = ["head", "body-start", "body-end"];
|
|
12
|
+
const DEFAULT_HEADING_STYLES = {
|
|
13
|
+
h1: {
|
|
14
|
+
fontFamily: "",
|
|
15
|
+
fontSize: "48px",
|
|
16
|
+
lineHeight: "1.15",
|
|
17
|
+
fontWeight: "700",
|
|
18
|
+
textTransform: "none",
|
|
19
|
+
fontStyle: "normal",
|
|
20
|
+
textDecoration: "none",
|
|
21
|
+
letterSpacing: "0px"
|
|
22
|
+
},
|
|
23
|
+
h2: {
|
|
24
|
+
fontFamily: "",
|
|
25
|
+
fontSize: "40px",
|
|
26
|
+
lineHeight: "1.18",
|
|
27
|
+
fontWeight: "700",
|
|
28
|
+
textTransform: "none",
|
|
29
|
+
fontStyle: "normal",
|
|
30
|
+
textDecoration: "none",
|
|
31
|
+
letterSpacing: "0px"
|
|
32
|
+
},
|
|
33
|
+
h3: {
|
|
34
|
+
fontFamily: "",
|
|
35
|
+
fontSize: "32px",
|
|
36
|
+
lineHeight: "1.22",
|
|
37
|
+
fontWeight: "700",
|
|
38
|
+
textTransform: "none",
|
|
39
|
+
fontStyle: "normal",
|
|
40
|
+
textDecoration: "none",
|
|
41
|
+
letterSpacing: "0px"
|
|
42
|
+
},
|
|
43
|
+
h4: {
|
|
44
|
+
fontFamily: "",
|
|
45
|
+
fontSize: "24px",
|
|
46
|
+
lineHeight: "1.28",
|
|
47
|
+
fontWeight: "600",
|
|
48
|
+
textTransform: "none",
|
|
49
|
+
fontStyle: "normal",
|
|
50
|
+
textDecoration: "none",
|
|
51
|
+
letterSpacing: "0px"
|
|
52
|
+
},
|
|
53
|
+
h5: {
|
|
54
|
+
fontFamily: "",
|
|
55
|
+
fontSize: "20px",
|
|
56
|
+
lineHeight: "1.35",
|
|
57
|
+
fontWeight: "600",
|
|
58
|
+
textTransform: "none",
|
|
59
|
+
fontStyle: "normal",
|
|
60
|
+
textDecoration: "none",
|
|
61
|
+
letterSpacing: "0px"
|
|
62
|
+
},
|
|
63
|
+
h6: {
|
|
64
|
+
fontFamily: "",
|
|
65
|
+
fontSize: "16px",
|
|
66
|
+
lineHeight: "1.4",
|
|
67
|
+
fontWeight: "600",
|
|
68
|
+
textTransform: "none",
|
|
69
|
+
fontStyle: "normal",
|
|
70
|
+
textDecoration: "none",
|
|
71
|
+
letterSpacing: "0px"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const isRecord$1 = (value) => Boolean(value) && typeof value === "object";
|
|
75
|
+
const isPresent = (value) => Boolean(value);
|
|
76
|
+
const toCssText = (value, fallback = "") => `${value ?? ""}`.trim().replace(/;+/g, "") || fallback;
|
|
77
|
+
const normalizeGlobalFontFamily = (fontFamily) => {
|
|
78
|
+
const normalized = toCssText(fontFamily);
|
|
79
|
+
if (!normalized)
|
|
80
|
+
return "";
|
|
81
|
+
if (/\bsans-serif\b/i.test(normalized))
|
|
82
|
+
return normalized;
|
|
83
|
+
return `${normalized}, sans-serif`;
|
|
84
|
+
};
|
|
85
|
+
const getTypography = (snapshot) => isRecord$1(snapshot.typography) ? snapshot.typography : {};
|
|
86
|
+
const normalizeHeadingStyles = (headingStyles) => {
|
|
87
|
+
const source = isRecord$1(headingStyles) ? headingStyles : {};
|
|
88
|
+
return HEADING_LEVELS.reduce((result, level) => {
|
|
89
|
+
const defaults = DEFAULT_HEADING_STYLES[level];
|
|
90
|
+
const style = isRecord$1(source[level]) ? source[level] : {};
|
|
91
|
+
result[level] = {
|
|
92
|
+
fontFamily: normalizeGlobalFontFamily(style.fontFamily),
|
|
93
|
+
fontSize: toCssText(style.fontSize, String(defaults.fontSize)),
|
|
94
|
+
lineHeight: toCssText(style.lineHeight, String(defaults.lineHeight)),
|
|
95
|
+
fontWeight: toCssText(style.fontWeight, String(defaults.fontWeight)),
|
|
96
|
+
textTransform: toCssText(style.textTransform, String(defaults.textTransform)),
|
|
97
|
+
fontStyle: toCssText(style.fontStyle, String(defaults.fontStyle)),
|
|
98
|
+
textDecoration: toCssText(style.textDecoration, String(defaults.textDecoration)),
|
|
99
|
+
letterSpacing: toCssText(style.letterSpacing, String(defaults.letterSpacing))
|
|
100
|
+
};
|
|
101
|
+
return result;
|
|
102
|
+
}, {});
|
|
103
|
+
};
|
|
104
|
+
const getOrCreateStyleElement = (doc, id) => {
|
|
105
|
+
let element = doc.getElementById(id);
|
|
106
|
+
if (!element) {
|
|
107
|
+
element = doc.createElement("style");
|
|
108
|
+
element.id = id;
|
|
109
|
+
(doc.head ?? doc.documentElement).appendChild(element);
|
|
110
|
+
}
|
|
111
|
+
return element;
|
|
112
|
+
};
|
|
113
|
+
const setStyleText = (doc, id, cssText) => {
|
|
114
|
+
const existing = doc.getElementById(id);
|
|
115
|
+
if (!cssText) {
|
|
116
|
+
existing == null ? void 0 : existing.remove();
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const element = getOrCreateStyleElement(doc, id);
|
|
120
|
+
element.textContent = cssText;
|
|
121
|
+
return element;
|
|
122
|
+
};
|
|
123
|
+
const buildColorVariables = (colors) => {
|
|
124
|
+
const variables = colors.filter(isRecord$1).map((color) => {
|
|
125
|
+
const id = `${color.id ?? ""}`.trim();
|
|
126
|
+
const value = toCssText(color.value);
|
|
127
|
+
if (!id || !value || /[^a-zA-Z0-9_-]/.test(id))
|
|
128
|
+
return "";
|
|
129
|
+
return ` --wb-gc-${id}: ${value};`;
|
|
130
|
+
}).filter(Boolean);
|
|
131
|
+
return variables.length ? `:root {
|
|
132
|
+
${variables.join("\n")}
|
|
133
|
+
}` : ":root {}";
|
|
134
|
+
};
|
|
135
|
+
const buildTypographyCss = (typography) => {
|
|
136
|
+
const fontFamily = normalizeGlobalFontFamily(typography.fontFamily);
|
|
137
|
+
const headingStyles = normalizeHeadingStyles(typography.headingStyles);
|
|
138
|
+
const headingVariables = HEADING_LEVELS.flatMap((level) => {
|
|
139
|
+
const style = headingStyles[level];
|
|
140
|
+
return [
|
|
141
|
+
` --wb-${level}-font-family: ${style.fontFamily || "var(--wb-global-font-family)"};`,
|
|
142
|
+
` --wb-${level}-font-size: ${style.fontSize};`,
|
|
143
|
+
` --wb-${level}-line-height: ${style.lineHeight};`,
|
|
144
|
+
` --wb-${level}-font-weight: ${style.fontWeight};`,
|
|
145
|
+
` --wb-${level}-text-transform: ${style.textTransform};`,
|
|
146
|
+
` --wb-${level}-font-style: ${style.fontStyle};`,
|
|
147
|
+
` --wb-${level}-text-decoration: ${style.textDecoration};`,
|
|
148
|
+
` --wb-${level}-letter-spacing: ${style.letterSpacing};`
|
|
149
|
+
];
|
|
150
|
+
}).join("\n");
|
|
151
|
+
const headingRules = HEADING_LEVELS.map((level) => `${level} {
|
|
152
|
+
font-family: var(--wb-${level}-font-family, var(--wb-global-font-family));
|
|
153
|
+
font-size: var(--wb-${level}-font-size);
|
|
154
|
+
line-height: var(--wb-${level}-line-height);
|
|
155
|
+
font-weight: var(--wb-${level}-font-weight);
|
|
156
|
+
text-transform: var(--wb-${level}-text-transform);
|
|
157
|
+
font-style: var(--wb-${level}-font-style);
|
|
158
|
+
text-decoration-line: var(--wb-${level}-text-decoration);
|
|
159
|
+
letter-spacing: var(--wb-${level}-letter-spacing);
|
|
160
|
+
}`).join("\n");
|
|
161
|
+
return `:root {
|
|
162
|
+
--wb-global-font-family: ${fontFamily || "inherit"};
|
|
163
|
+
${headingVariables}
|
|
164
|
+
}
|
|
165
|
+
body,
|
|
166
|
+
button,
|
|
167
|
+
input,
|
|
168
|
+
textarea,
|
|
169
|
+
select {
|
|
170
|
+
font-family: var(--wb-global-font-family);
|
|
171
|
+
}
|
|
172
|
+
${headingRules}`;
|
|
173
|
+
};
|
|
174
|
+
const buildGlobalSettingsCss = (snapshot) => {
|
|
175
|
+
const typography = getTypography(snapshot);
|
|
176
|
+
return [
|
|
177
|
+
buildColorVariables(snapshot.colors),
|
|
178
|
+
buildTypographyCss(typography),
|
|
179
|
+
`${snapshot.customCss ?? ""}`.trim()
|
|
180
|
+
].filter(Boolean).join("\n");
|
|
181
|
+
};
|
|
182
|
+
const getGlobalSettingsGoogleFontName = (snapshot) => `${getTypography(snapshot).googleName ?? ""}`.trim();
|
|
183
|
+
const injectGoogleFontLink = (doc, googleName) => {
|
|
184
|
+
var _a, _b;
|
|
185
|
+
const normalized = `${googleName ?? ""}`.trim();
|
|
186
|
+
if (!normalized)
|
|
187
|
+
return null;
|
|
188
|
+
const existing = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector) == null ? void 0 : _b.call(
|
|
189
|
+
_a,
|
|
190
|
+
`link[${GOOGLE_FONT_ATTR}="${normalized}"]`
|
|
191
|
+
);
|
|
192
|
+
if (existing)
|
|
193
|
+
return existing;
|
|
194
|
+
const link = doc.createElement("link");
|
|
195
|
+
link.rel = "stylesheet";
|
|
196
|
+
link.setAttribute(GOOGLE_FONT_ATTR, normalized);
|
|
197
|
+
link.href = `https://fonts.googleapis.com/css2?family=${normalized}:wght@300;400;500;600;700&display=swap`;
|
|
198
|
+
(doc.head ?? doc.documentElement).appendChild(link);
|
|
199
|
+
return link;
|
|
200
|
+
};
|
|
201
|
+
const isCustomCodePosition = (value) => CUSTOM_CODE_POSITIONS.includes(value);
|
|
202
|
+
const getEnabledCustomCodeByPosition = (customCode, position) => customCode.filter(isRecord$1).filter((snippet) => {
|
|
203
|
+
const customSnippet = snippet;
|
|
204
|
+
return customSnippet.enabled === true && isCustomCodePosition(customSnippet.position) && customSnippet.position === position;
|
|
205
|
+
}).map((snippet) => `${snippet.code ?? ""}`.trim()).filter(Boolean).join("\n");
|
|
206
|
+
const getEnabledGlobalCustomCode = (snapshot, position) => getEnabledCustomCodeByPosition(snapshot.customCode, position);
|
|
207
|
+
const createCustomCodeTemplate = (doc, position, code) => {
|
|
208
|
+
var _a;
|
|
209
|
+
if (!code)
|
|
210
|
+
return null;
|
|
211
|
+
const target = position === "head" ? doc.head ?? doc.documentElement : doc.body ?? doc.documentElement;
|
|
212
|
+
const existing = (_a = target.querySelector) == null ? void 0 : _a.call(
|
|
213
|
+
target,
|
|
214
|
+
`template[${CUSTOM_CODE_POSITION_ATTR}="${position}"]`
|
|
215
|
+
);
|
|
216
|
+
existing == null ? void 0 : existing.remove();
|
|
217
|
+
const template = doc.createElement("template");
|
|
218
|
+
template.setAttribute(CUSTOM_CODE_ATTR, "true");
|
|
219
|
+
template.setAttribute(CUSTOM_CODE_POSITION_ATTR, position);
|
|
220
|
+
template.textContent = code;
|
|
221
|
+
if (position === "head") {
|
|
222
|
+
target.appendChild(template);
|
|
223
|
+
return template;
|
|
224
|
+
}
|
|
225
|
+
if (position === "body-start") {
|
|
226
|
+
target.insertBefore(template, target.firstChild);
|
|
227
|
+
return template;
|
|
228
|
+
}
|
|
229
|
+
target.appendChild(template);
|
|
230
|
+
return template;
|
|
231
|
+
};
|
|
232
|
+
const injectCustomCodeTemplates = (doc, customCode) => CUSTOM_CODE_POSITIONS.map(
|
|
233
|
+
(position) => createCustomCodeTemplate(
|
|
234
|
+
doc,
|
|
235
|
+
position,
|
|
236
|
+
getEnabledCustomCodeByPosition(customCode, position)
|
|
237
|
+
)
|
|
238
|
+
).filter(isPresent);
|
|
239
|
+
const injectGlobalSettingsIntoDocument = (doc, snapshot) => {
|
|
240
|
+
const typography = getTypography(snapshot);
|
|
241
|
+
const injectedNodes = [
|
|
242
|
+
setStyleText(doc, GLOBAL_SETTINGS_STYLE_IDS.colors, buildColorVariables(snapshot.colors)),
|
|
243
|
+
setStyleText(doc, GLOBAL_SETTINGS_STYLE_IDS.typography, buildTypographyCss(typography)),
|
|
244
|
+
setStyleText(doc, GLOBAL_SETTINGS_STYLE_IDS.customCss, `${snapshot.customCss ?? ""}`.trim()),
|
|
245
|
+
injectGoogleFontLink(doc, typography.googleName),
|
|
246
|
+
...injectCustomCodeTemplates(doc, snapshot.customCode)
|
|
247
|
+
].filter(isPresent);
|
|
248
|
+
return () => {
|
|
249
|
+
injectedNodes.forEach((node) => node.remove());
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
const escapeHtmlAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
253
|
+
const buildGoogleFontLinkHtml = (googleName) => {
|
|
254
|
+
if (!googleName)
|
|
255
|
+
return "";
|
|
256
|
+
const escapedName = escapeHtmlAttribute(googleName);
|
|
257
|
+
const href = `https://fonts.googleapis.com/css2?family=${escapedName}:wght@300;400;500;600;700&display=swap`;
|
|
258
|
+
return `<link rel="stylesheet" data-wb-gf="${escapedName}" href="${href}">`;
|
|
259
|
+
};
|
|
260
|
+
const joinHtml = (fragments) => fragments.map((fragment) => fragment.trim()).filter(Boolean).join("\n");
|
|
261
|
+
const renderGlobalSettingsPublishedAssets = (snapshot) => {
|
|
262
|
+
const googleName = getGlobalSettingsGoogleFontName(snapshot);
|
|
263
|
+
return {
|
|
264
|
+
css: buildGlobalSettingsCss(snapshot),
|
|
265
|
+
headHtml: joinHtml([
|
|
266
|
+
buildGoogleFontLinkHtml(googleName),
|
|
267
|
+
getEnabledGlobalCustomCode(snapshot, "head")
|
|
268
|
+
]),
|
|
269
|
+
bodyStartHtml: getEnabledGlobalCustomCode(snapshot, "body-start"),
|
|
270
|
+
bodyEndHtml: getEnabledGlobalCustomCode(snapshot, "body-end"),
|
|
271
|
+
metadata: {
|
|
272
|
+
globalSettings: {
|
|
273
|
+
version: snapshot.version,
|
|
274
|
+
hash: snapshot.hash,
|
|
275
|
+
updatedAt: snapshot.updatedAt
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
const GLOBAL_SETTINGS_PLUGIN_ID = "global-settings";
|
|
281
|
+
const isRecord = (value) => Boolean(value) && typeof value === "object";
|
|
282
|
+
const getFrameDocument = (context) => {
|
|
283
|
+
if (!isRecord(context))
|
|
284
|
+
return null;
|
|
285
|
+
const frame = isRecord(context.frame) ? context.frame : context;
|
|
286
|
+
const view = isRecord(frame.view) ? frame.view : null;
|
|
287
|
+
const element = isRecord(view == null ? void 0 : view.el) ? view.el : null;
|
|
288
|
+
const contentDocument = element == null ? void 0 : element.contentDocument;
|
|
289
|
+
if (contentDocument && typeof contentDocument === "object") {
|
|
290
|
+
return contentDocument;
|
|
291
|
+
}
|
|
292
|
+
const getDocument = view == null ? void 0 : view.getDocument;
|
|
293
|
+
if (typeof getDocument === "function") {
|
|
294
|
+
return getDocument.call(view);
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
};
|
|
298
|
+
const createGlobalSettingsPlugin = () => ({
|
|
299
|
+
id: GLOBAL_SETTINGS_PLUGIN_ID,
|
|
300
|
+
label: "Global Settings",
|
|
301
|
+
order: 20,
|
|
302
|
+
alwaysEnabled: true,
|
|
303
|
+
publisher: {
|
|
304
|
+
id: "publisher:global-settings",
|
|
305
|
+
order: 20,
|
|
306
|
+
render: (context) => context.globalSettings ? renderGlobalSettingsPublishedAssets(context.globalSettings) : null
|
|
307
|
+
},
|
|
308
|
+
activateEditor(context) {
|
|
309
|
+
let cleanupCanvasInjection = null;
|
|
310
|
+
const cleanupCurrentInjection = () => {
|
|
311
|
+
cleanupCanvasInjection == null ? void 0 : cleanupCanvasInjection();
|
|
312
|
+
cleanupCanvasInjection = null;
|
|
313
|
+
};
|
|
314
|
+
const injectSnapshot = (eventData) => {
|
|
315
|
+
var _a, _b;
|
|
316
|
+
const snapshot = context.settings.getSnapshot();
|
|
317
|
+
const doc = getFrameDocument(eventData) ?? ((_b = (_a = context.editor.Canvas) == null ? void 0 : _a.getDocument) == null ? void 0 : _b.call(_a)) ?? null;
|
|
318
|
+
cleanupCurrentInjection();
|
|
319
|
+
if (snapshot && doc) {
|
|
320
|
+
cleanupCanvasInjection = injectGlobalSettingsIntoDocument(doc, snapshot);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
const handleLoad = () => injectSnapshot();
|
|
324
|
+
const handleFrameLoad = (eventData) => injectSnapshot(eventData);
|
|
325
|
+
const handleProjectPaint = () => injectSnapshot();
|
|
326
|
+
const unsubscribe = context.settings.subscribe(() => injectSnapshot());
|
|
327
|
+
context.editor.on("load", handleLoad);
|
|
328
|
+
context.editor.on("canvas:frame:load", handleFrameLoad);
|
|
329
|
+
context.editor.on(WEB_BUILDER_PROJECT_PAINT_EVENT, handleProjectPaint);
|
|
330
|
+
injectSnapshot();
|
|
331
|
+
return () => {
|
|
332
|
+
context.editor.off("load", handleLoad);
|
|
333
|
+
context.editor.off("canvas:frame:load", handleFrameLoad);
|
|
334
|
+
context.editor.off(WEB_BUILDER_PROJECT_PAINT_EVENT, handleProjectPaint);
|
|
335
|
+
unsubscribe();
|
|
336
|
+
cleanupCurrentInjection();
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
async beforeProjectLoad(context) {
|
|
340
|
+
if (context.settings.getSnapshot())
|
|
341
|
+
return;
|
|
342
|
+
const service = context.hostServices.globalSettings;
|
|
343
|
+
if (!service)
|
|
344
|
+
return;
|
|
345
|
+
const snapshot = await service.loadDraft({
|
|
346
|
+
resource: context.resource,
|
|
347
|
+
tenantId: context.tenant.tenantId
|
|
348
|
+
});
|
|
349
|
+
context.settings.hydrate(snapshot);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
export {
|
|
353
|
+
GLOBAL_SETTINGS_PLUGIN_ID as G,
|
|
354
|
+
GLOBAL_SETTINGS_STYLE_IDS as a,
|
|
355
|
+
buildGlobalSettingsCss as b,
|
|
356
|
+
createGlobalSettingsPlugin as c,
|
|
357
|
+
getGlobalSettingsGoogleFontName as d,
|
|
358
|
+
getEnabledGlobalCustomCode as g,
|
|
359
|
+
injectGlobalSettingsIntoDocument as i,
|
|
360
|
+
renderGlobalSettingsPublishedAssets as r
|
|
361
|
+
};
|