@blocklet/pages-kit 0.4.117 → 0.4.118

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.
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AGENT_OPTIONS = exports.PAGE_CONTENT_WRITER_AGENT_ID = void 0;
4
+ exports.PAGE_CONTENT_WRITER_AGENT_ID = 'page-content-writer';
5
+ exports.AGENT_OPTIONS = [{ id: exports.PAGE_CONTENT_WRITER_AGENT_ID, name: 'Page Content Writer' }];
@@ -74,4 +74,5 @@ exports.BuiltinModules = {
74
74
  '@blocklet/pages-kit/builtin/async/ai-runtime': {},
75
75
  '@blocklet/pages-kit/builtin/uploader': {},
76
76
  '@blocklet/pages-kit/builtin/color-picker': {},
77
+ '@blocklet/pages-kit/builtin/markdown/index': {},
77
78
  };
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setPageDataSource = setPageDataSource;
4
+ const lodash_1 = require("lodash");
5
+ function setPageDataSource(page, state, locale, pageData) {
6
+ try {
7
+ if (!page.locales) {
8
+ page.locales = {};
9
+ }
10
+ page.locales[locale] = (0, lodash_1.cloneDeep)(page.locales[locale] || {});
11
+ page.locales[locale].title = pageData.title ?? page.locales[locale].title;
12
+ page.locales[locale].image = pageData.image ?? page.locales[locale].image;
13
+ page.locales[locale].description = pageData.description ?? page.locales[locale].description;
14
+ // 遍历 pageData 的每个 key
15
+ Object.entries(pageData.sectionsData).forEach(([sectionKey, sectionData]) => {
16
+ try {
17
+ // 通过 id 或 name 找到对应的 section
18
+ const section = Object.values(page.sections).find((section) => section.id === sectionKey || section.name === sectionKey);
19
+ if (!section) {
20
+ return;
21
+ }
22
+ if (!section.isTemplateSection) {
23
+ return;
24
+ }
25
+ // 确保 section.locales 存在
26
+ section.locales = (0, lodash_1.cloneDeep)(section.locales || {});
27
+ section.locales[locale] = (0, lodash_1.cloneDeep)(section.locales[locale] || {});
28
+ if (section.component === 'custom-component') {
29
+ // 处理自定义组件
30
+ const componentId = section.config?.componentId;
31
+ if (!componentId) {
32
+ return;
33
+ }
34
+ // 从 state 中获取组件定义
35
+ const componentDef = state.components[componentId]?.data || state.resources.components?.[componentId]?.component;
36
+ if (!componentDef) {
37
+ return;
38
+ }
39
+ // 确保 properties 存在
40
+ section.locales[locale].properties = (0, lodash_1.cloneDeep)(section.locales[locale].properties || {});
41
+ // 遍历 sectionData,设置属性值
42
+ Object.entries(sectionData || {}).forEach(([propKey, propValue]) => {
43
+ // 尝试通过 key 或 id 找到属性定义
44
+ const property = componentDef?.properties?.[propKey] ||
45
+ Object.values(componentDef?.properties || {}).find((prop) => prop.data?.key === propKey);
46
+ if (property) {
47
+ // 设置属性值
48
+ section.locales[locale].properties[property.data?.id] = {
49
+ value: propValue,
50
+ };
51
+ }
52
+ });
53
+ }
54
+ else {
55
+ // 普通组件直接设置 properties
56
+ section.locales[locale] = {
57
+ ...(0, lodash_1.cloneDeep)(section.locales[locale]),
58
+ ...(sectionData || {}),
59
+ };
60
+ }
61
+ }
62
+ catch (error) {
63
+ console.error('Failed to set section data source:', error);
64
+ }
65
+ });
66
+ }
67
+ catch (error) {
68
+ console.error('Failed to set page data source:', error);
69
+ }
70
+ }
@@ -42,6 +42,7 @@ const emotionCss = __importStar(require("../builtin/emotion/css"));
42
42
  const iconifyReact = __importStar(require("../builtin/iconify/react"));
43
43
  const immer = __importStar(require("../builtin/immer"));
44
44
  const locale = __importStar(require("../builtin/locale"));
45
+ const markdownRenderer = __importStar(require("../builtin/markdown/index"));
45
46
  const muiLab = __importStar(require("../builtin/mui/lab"));
46
47
  const muiMaterial = __importStar(require("../builtin/mui/material"));
47
48
  const pageHeader = __importStar(require("../builtin/page/header"));
@@ -85,6 +86,7 @@ function injectGlobalComponents() {
85
86
  '@blocklet/pages-kit/builtin/react-dom': reactDOM,
86
87
  '@blocklet/pages-kit/builtin/uploader': uploader,
87
88
  '@blocklet/pages-kit/builtin/color-picker': colorPicker,
89
+ '@blocklet/pages-kit/builtin/markdown/index': markdownRenderer,
88
90
  '@blocklet/pages-kit/builtin/emotion/css': emotionCss,
89
91
  '@blocklet/pages-kit/builtin/mui/material': muiMaterial,
90
92
  '@blocklet/pages-kit/builtin/mui/lab': muiLab,