mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-10-28 13:30:46 +00:00
- 新增 packages/editor/src/sdk,通过 sdk.ts 对外导出 - 将 services 下的核心服务迁移至 sdk/services - 工具函数拆分至 sdk/utils,校验逻辑迁移至 sdk/validate,新增 sdk/wiring - services/sdk-instance.ts 负责在编辑器中实例化 SDK - 补充 SDK 相关单元测试,新增 docs/api/editor/sdk.md 文档
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import type { MApp } from '@tmagic/core';
|
|
|
|
import type { SdkOptions } from '@editor/sdk';
|
|
import { createDslSdk } from '@editor/sdk';
|
|
|
|
export const createDsl = (): MApp =>
|
|
({
|
|
id: 'app_1',
|
|
type: 'app',
|
|
items: [
|
|
{
|
|
id: 'page_1',
|
|
type: 'page',
|
|
name: 'page',
|
|
items: [
|
|
{ id: 'text_1', type: 'text', text: '${ds_1.name}' },
|
|
{ id: 'container_1', type: 'container', items: [{ id: 'button_1', type: 'button', text: 'btn' }] },
|
|
],
|
|
},
|
|
],
|
|
dataSources: [{ id: 'ds_1', type: 'base', title: 'ds', fields: [{ name: 'name' }], methods: [], events: [] }],
|
|
codeBlocks: { code_1: { name: 'code', content: '() => {}', params: [] } },
|
|
}) as any;
|
|
|
|
export const COMPONENT_GROUP_LIST = [
|
|
{
|
|
title: '基础',
|
|
items: [
|
|
{ text: '文本', type: 'text' },
|
|
{ text: '按钮', type: 'button' },
|
|
],
|
|
},
|
|
];
|
|
|
|
export const createSdk = (options: SdkOptions = {}) =>
|
|
createDslSdk({
|
|
dsl: createDsl(),
|
|
componentGroupList: COMPONENT_GROUP_LIST,
|
|
...options,
|
|
});
|