Compare commits

...

1010 Commits

Author SHA1 Message Date
roymondchen
084ff6ff68 feat(cli): packages配置不做去重处理,因为组件type与数据源type可能相同 2026-03-02 17:19:32 +08:00
roymondchen
ecaa0f5f28 fix(vue-runtime-help): useApp获取不到页面片中的node 2026-02-02 19:07:44 +08:00
roymondchen
eee87c6d01 docs: 创建组件的默认路径配置修改 2026-01-27 14:05:17 +08:00
roymondchen
0b7b6884ae docs: 修改文档中的错别字 2026-01-27 12:11:30 +08:00
roymondchen
575993fe34 docs: 添加runtime api 2026-01-26 19:33:55 +08:00
roymondchen
c23d02558e docs: 完善组件开发/runtime/表单配置文档 2026-01-26 19:06:39 +08:00
roymondchen
450af8021d style(playground): eslint 2026-01-26 14:37:18 +08:00
roymondchen
0ec8af20e0 refactor(playground): form提交的结果使用代码编辑器显示 2026-01-23 17:03:37 +08:00
roymondchen
b4c2c65ccb fix(form): timerange新增value format配置,默认为HH:mm:ss 2026-01-23 16:51:31 +08:00
roymondchen
06fd5392a9 chore: update lockfile v1.7.6 2026-01-19 20:00:34 +08:00
roymondchen
89ac777a7f chore: release v1.7.6 2026-01-19 19:59:14 +08:00
roymondchen
6cf2f38194 fix(form): onChange中修改model的key中有重复的key会出错 2026-01-19 19:40:58 +08:00
roymondchen
e6e68ae69a refactor(core): 调整eventHelper代码 2026-01-12 20:17:47 +08:00
roymondchen
5110f0cbca chore: update lockfile v1.7.5 2026-01-08 17:17:39 +08:00
roymondchen
da2e2c393b chore: release v1.7.5 2026-01-08 17:16:08 +08:00
roymondchen
e6d1624a6c refactor(form): 优化创建初始值等一些工具函数 2026-01-08 17:11:05 +08:00
roymondchen
8956035e41 fix(form): 初始值为0时会丢失 2026-01-08 17:03:16 +08:00
roymondchen
10c36c1980 chore(editor): 画布拖动组件位置更新dsl添加changeRecordes 2026-01-08 16:44:44 +08:00
roymondchen
5f57d620da fix(form): daterange默认值 2026-01-07 18:33:13 +08:00
roymondchen
cfaaaad66e feat(editor): customCreateMonacoEditor options中新增editorCustomType,可以用于创建不同的editor 2026-01-07 17:38:37 +08:00
roymondchen
df611571c7 feat(form): type配置为函数时,参数中的model等对象设置层readonly 2026-01-07 14:43:14 +08:00
roymondchen
5267381ebf fix(editor): 显示条件中选中的字段类型发生时,值对应做类型转换 2026-01-07 14:41:25 +08:00
roymondchen
3cfec95612 fix(editor): 切换固定定位后坐标转换仅支持left,top为数字的情况 2025-12-31 16:33:06 +08:00
roymondchen
c1b12e6f40 chore: update lockfile v1.7.4 2025-12-29 20:42:34 +08:00
roymondchen
c2d2eee749 chore: release v1.7.4 2025-12-29 20:16:45 +08:00
roymondchen
03b6180a02 fix(editor): 数据源方法编辑后content变成字符串 2025-12-29 19:22:28 +08:00
roymondchen
8150f042ff chore: update lockfile v1.7.3 2025-12-25 20:22:52 +08:00
roymondchen
b71a5ef891 chore: release v1.7.3 2025-12-25 20:02:51 +08:00
roymondchen
01158e01fc chore(table): 添加依赖 2025-12-25 19:23:27 +08:00
roymondchen
98c2e2ff1f fix(table): 行内编辑无法修改表单 2025-12-25 19:16:17 +08:00
roymondchen
9d4324dd6b fix(form): 动态tab自定义onTabAdd后出错 2025-12-25 16:03:52 +08:00
roymondchen
2630f00f13 feat(form): groud-list title支持html 2025-12-24 15:40:17 +08:00
roymondchen
b0d8c5383b fix(editor): cose-select无法删除 2025-12-24 15:38:02 +08:00
roymondchen
f0a39667e1 feat(form): text组件支持配置cleareable 2025-12-23 16:47:12 +08:00
roymondchen
5fe91e89b7 feat(form,tdesign-vue-next-adapter): table 多选框放到默认的操作前面,支持配置copy的干预函数 2025-12-19 20:19:55 +08:00
roymondchen
f7811fdb24 docs: 完善文档 2025-12-11 14:20:39 +08:00
roymondchen
7a0dae9f5a build(tmagic-form): package.json中文件入口配置错误 2025-12-09 20:49:23 +08:00
roymondchen
304aaac8dc chore: update lockfile v1.7.2 2025-12-09 19:15:19 +08:00
roymondchen
0f596b5c42 chore: release v1.7.2 2025-12-09 19:13:51 +08:00
roymondchen
e3db0c93e5 chore: update lockfile v1.7.1 2025-12-09 17:41:35 +08:00
roymondchen
3250c53097 chore: release v1.7.1 2025-12-09 17:23:21 +08:00
roymondchen
756612eda5 feat(vue-components): 不再兼容vue2 2025-12-09 17:20:07 +08:00
roymondchen
2a7ab4e916 feat(vue-runtime-help): 去掉vue2的兼容 2025-12-09 16:20:56 +08:00
roymondchen
d039cee913 fix(tmagic-form): runtime刷新导致root丢失 2025-12-09 16:18:35 +08:00
roymondchen
83664cd440 fix(core): getNode 添加stict参数来表示必须知道页面片容器id才会返回页面内的节点 2025-12-09 15:51:15 +08:00
roymondchen
b3ce1a3b93 fix(form): tabs组件子项配置了name后,配置生成的数据出错 2025-12-09 14:22:57 +08:00
roymondchen
738e8611a4 style(editor): 组件属性配置中表格操作栏会覆盖tab头
fix #664
2025-12-05 19:45:08 +08:00
roymondchen
9815fb7c51 chore: update lockfile v1.7.0 2025-12-04 17:37:17 +08:00
roymondchen
411a28946e chore: release v1.7.0 2025-12-04 17:35:47 +08:00
roymondchen
70d730ca82 refactor(editor): 新增数据源按钮封装成组件 2025-12-04 17:31:38 +08:00
roymondchen
a2a9556ab8 style(editor): 调整已选组件节点右侧按钮样式 2025-12-04 16:36:34 +08:00
roymondchen
7e71c070f1 fix(form): datetime如果设置为时间戳,然后初始值是一个字符串的数字显示不正确 2025-12-04 15:20:30 +08:00
roymondchen
8d55d0cd8d feat(editor): 代码编辑器支持配置自动高度 2025-12-03 17:50:48 +08:00
roymondchen
8d7c8fa725 fix(design): dialog 默认参数 2025-12-03 17:15:26 +08:00
roymondchen
ad746319e9 style(tdesign-vue-next-adapter): 去掉无用prop 2025-12-03 17:09:47 +08:00
roymondchen
0dd7f54ebc feat(form): table支持配置操作按钮的icon 2025-12-02 15:25:34 +08:00
roymondchen
69ac90fe22 feat(form): table支持配置拖动操作中的按钮排序而不是拖动整行 2025-12-01 21:09:11 +08:00
roymondchen
2667981e4c fix(form): table拖拽排序后重新渲染组件 2025-11-26 16:40:26 +08:00
roymondchen
b536eba81c fix(form): 生成表单values时将initValus深拷贝,避免修改到传入的对象 2025-11-26 16:38:37 +08:00
roymondchen
054ed561b6 chore: update lockfile v1.7.0-beta.5 2025-11-24 20:31:39 +08:00
roymondchen
c1dc58c97c chore: release v1.7.0-beta.5 2025-11-24 20:30:11 +08:00
roymondchen
bb7ec0aa1b fix(element-plus-adapter): 构建时将vue源码构建入目标代码中,导致页面存在多个版本vue 2025-11-24 20:27:53 +08:00
roymondchen
849b4dc319 fix(tdesign-vue-next-adapter): 没有extra时form item不渲染help节点 2025-11-24 19:15:50 +08:00
roymondchen
8aef360ed7 chore: update lockfile v1.7.0-beta.4 2025-11-24 16:21:50 +08:00
roymondchen
8d65127cdd chore: release v1.7.0-beta.4 2025-11-24 16:20:19 +08:00
roymondchen
93640257e9 fix(design,editro,element-plus-adapter,tdesign-vue-next-adapter): elememt-plus表单渲染失败 2025-11-24 16:14:21 +08:00
roymondchen
09dfaad2cc feat(design): 在html中添加adapter类型class 2025-11-24 13:56:11 +08:00
roymondchen
5dbe1fb655 feat(core): getNode未指定页面片容器id时取获得到的第一个 2025-11-24 13:54:09 +08:00
roymondchen
82df2a8f5c chore: update deps 2025-11-21 16:50:46 +08:00
roymondchen
4dc5f0a298 style: 优化部分结构 2025-11-21 15:41:41 +08:00
roymondchen
3b913c1af4 feat(form): group list新增添加按钮配置 2025-11-20 18:05:53 +08:00
roymondchen
310054b7d6 feat(form): form dialog新增show close/show cancel 配置 2025-11-20 17:57:44 +08:00
roymondchen
fa0e10f687 feat(form): table操作列支持配置固定在左边还是右边 2025-11-20 15:44:14 +08:00
roymondchen
bf6598c871 feat(form): form dialog新增props 2025-11-20 15:03:17 +08:00
roymondchen
6a7f80c48d feat(form): table新增新增按钮配置 2025-11-20 11:27:12 +08:00
roymondchen
e2708b868b feat(form): 表格拖动支持tdesign 2025-11-19 14:39:49 +08:00
roymondchen
97affb2bff feat(form): tip图标放到label中去 2025-11-19 14:37:24 +08:00
roymondchen
e418130a66 feat(form, design, form-schema): table支持自定义title,table 表单组件支持配置title tip 2025-11-19 13:23:03 +08:00
roymondchen
55a2869818 fix(form): 文本输入change出发太频繁 2025-11-18 19:13:56 +08:00
roymondchen
0ecc116652 feat(design, tdesign-vue-next-adapter): formItem新增labelAlign prop 2025-11-18 19:09:14 +08:00
roymondchen
310aa47c1d feat(form): panel点击标题可以展开或者收缩内容 2025-11-18 19:03:29 +08:00
roymondchen
27555d6b2f fix(design): select visible-change事件名写错 2025-11-13 20:27:49 +08:00
roymondchen
da9884645f fix(playgournd): 存在多个vue版本问题 2025-11-12 19:52:32 +08:00
roymondchen
1a08b16a39 fix(tdesign-vue-next-adapter): select支持allowCreate 2025-11-12 19:52:32 +08:00
roymondchen
a96ca8092c feat(design,tdesign-vue-next-adapter): input添加click事件 2025-11-12 19:52:32 +08:00
roymondchen
489d321677 chore: update lockfile v1.7.0-beta.3 2025-11-12 19:52:32 +08:00
roymondchen
3d0081e48e chore: release v1.7.0-beta.3 2025-11-12 19:52:32 +08:00
roymondchen
acda22d5cb feat(design,tdesign-vue,next-adapter): textarea支持autosize 2025-11-12 19:52:32 +08:00
roymondchen
7b19a01849 chore(playground): adapter改成异步加载 2025-11-12 19:52:32 +08:00
roymondchen
d0179028fb feat(element-plus-adapter, from, tdesign-vue-adapter): button兼容type=default和type为空的情况 2025-11-12 19:52:32 +08:00
roymondchen
564a7f4271 fix(editor): 表单组件保持单向数据流 2025-11-12 19:52:32 +08:00
roymondchen
6f0498a9e7 feat(form): text组件配置的append.hander函数添加setModel/setFormValue方法 2025-11-12 19:52:32 +08:00
roymondchen
4f52fcb122 style(form): group-list样式改成card的样式 2025-11-12 19:52:31 +08:00
roymondchen
1297939db2 style(table): table全屏后居中显示 2025-11-12 19:52:31 +08:00
roymondchen
b3cfc0b5d3 chore: update lockfile v1.7.0-beta.2 2025-11-12 19:52:31 +08:00
roymondchen
b96036b23c chore: release v1.7.0-beta.2 2025-11-12 19:52:31 +08:00
roymondchen
3c3ba6525b style(form): table新增按钮放到右边 2025-11-12 19:52:31 +08:00
roymondchen
0f3dfcf511 fix(form): daterange 配置names后配置失效 2025-11-12 19:52:31 +08:00
roymondchen
12e6dd18b4 feat(design, element-plus-adapter, tdesign-vue-next-adapter): 添加adapterType, 完善tdesign useZIndex 2025-11-12 19:52:31 +08:00
roymondchen
cbec52936d fix(form): dialog submit event获取到的changeRecords为空 2025-11-12 19:52:31 +08:00
roymondchen
979b834fac feat(design, tdesign-vue-next-adapter, table, element-plus-adapter): 完善tdesign适配 2025-11-12 19:52:31 +08:00
roymondchen
dabeba85a0 build(playground): 去掉auto-import 2025-11-12 19:52:31 +08:00
roymondchen
954bd37d52 chore: update lockfile v1.7.0-beta.1 2025-11-12 19:52:31 +08:00
roymondchen
59aa9f14b3 chore: release v1.7.0-beta.1 2025-11-12 19:52:31 +08:00
roymondchen
38192a6d48 feat(design, form, form-schema, tdesign-vue-next-adapter): textarea支持rows配置 2025-11-12 19:52:31 +08:00
roymondchen
ec479b9296 feat(form): 表单校验后的错误信息将name转换成text 2025-11-12 19:52:31 +08:00
roymondchen
7f0aef7bee build(editor): css变量使用错误导致lightingcss构建失败 2025-11-12 19:52:31 +08:00
roymondchen
36508aba88 chore(playgournd): 添加@tmagic/design依赖 2025-11-12 19:52:31 +08:00
roymondchen
f30a8ddc41 chore: update lockfile v1.7.0-beta.0 2025-11-12 19:52:31 +08:00
roymondchen
a28705e3df chore: release v1.7.0-beta.0 2025-11-12 19:52:31 +08:00
roymondchen
ca0f8fc988 feat(design, form, tdesign-vue-next-adapter): 完善tdesign适配 2025-11-12 19:52:31 +08:00
roymondchen
68c69ac405 fix(form): tabel复制行不生效 2025-11-12 19:52:30 +08:00
roymondchen
3a9c94a6a6 feat(form): 新增style,fieldStyle配置;tooltip支持配置placement;配置中的函数新增getFormValue方法 2025-11-12 19:52:30 +08:00
roymondchen
5fe57cd389 feat(form): text新增prepend, append不默认使用button 2025-11-12 19:52:30 +08:00
roymondchen
51e9732894 feat(form): fieldset中checkbox新增name,trueValue,falseValue配置 2025-11-12 19:52:30 +08:00
roymondchen
630301bce2 feat(form): 新增flex-layout组件 2025-11-12 19:52:30 +08:00
roymondchen
507e51a2dc feat(design, element-plus-adapter, tdesign-vue-next-adapter): 新增popconfirm组件 2025-11-12 19:52:30 +08:00
roymondchen
11d25603a8 feat(playground): 支持UI组件库切换 2025-11-12 19:52:30 +08:00
roymondchen
8f0d99a4a6 style(design, editor, tdesign-vue-next-adapter): 编辑器顶部导航按钮tdesign下样式优化 2025-11-12 19:52:30 +08:00
roymondchen
08b476e04f feat(design,editor,element-plus-adapter,form,table,tdesign-vue-next-adapter): 重构table组件,适配tdesign 2025-11-12 19:52:30 +08:00
roymondchen
1cb2d57ade refactor(editor): 调整表单配置 2025-11-12 19:52:30 +08:00
roymondchen
d59428d2d6 refactor(form): 保持单向数据流,表单内部的组件不去修改表单的值,统一通过chang事件通知表单修改 2025-11-12 19:52:30 +08:00
roymondchen
e36da82d29 fix(vue-runtime-hlep): 页面片销毁后需要取消app的事件监听 2025-11-12 19:49:55 +08:00
roymondchen
8809351537 feat(table): action支持配置disabled 2025-10-15 14:32:45 +08:00
roymondchen
5387a18024 chore: release vue-container/react-runtime-help/reate-iterator-conatiner 2025-10-14 15:49:20 +08:00
roymondchen
2b80ba3efd chore: update lockfile v1.6.1 2025-10-14 15:37:33 +08:00
roymondchen
6c3916c580 chore: release v1.6.1 2025-10-14 15:36:00 +08:00
roymondchen
4dfdc836f6 chore: update deps 2025-10-14 14:18:50 +08:00
roymondchen
fef1e2c2b4 style(editor): 组件列表标题样式调整 2025-10-14 14:14:48 +08:00
roymondchen
51f95aef6f feat(data-source, editor, schema, react-runtime-help, vue-components): 新增条件成立时隐藏的配置功能 2025-10-13 20:31:54 +08:00
roymondchen
81aa8f151d feat(editor): 属性配置中的样式面板样式优化 2025-10-13 19:32:29 +08:00
roymondchen
cae11dce12 fix(form): text与同行元素不对齐问题 2025-10-13 19:28:18 +08:00
roymondchen
83bf36d980 style(form): radio-group选项中icon大小根据size变化 2025-10-13 19:25:30 +08:00
roymondchen
2888004c17 chore: update deps 2025-10-13 15:57:48 +08:00
roymondchen
abab44ad24 chore: update deps 2025-09-16 19:49:48 +08:00
roymondchen
849b561933 feat(data-source): 数据源数据变化事件监听响应支持立即执行 2025-09-16 19:44:16 +08:00
roymondchen
1031595a97 fix(core): 异步加载数据源时,数据源事件配置失效 2025-09-16 19:34:15 +08:00
roymondchen
f5cb19dfa4 style(editor): 页面列表长度超过可视窗口时出现滚动条 2025-09-12 15:32:03 +08:00
roymondchen
e400175ffe fix: 组件声明周期函数配置中配置数据源自有方法生效 2025-09-10 16:24:44 +08:00
roymondchen
958c78d968 chore: update lockfile v1.6.0 2025-08-27 19:27:29 +08:00
roymondchen
9f81597596 chore: release v1.6.0 2025-08-27 19:26:01 +08:00
roymondchen
001f2b6c9e build(runtime): escape % if URI malformed 2025-08-27 19:18:17 +08:00
roymondchen
a56bb562d8 build: 构建playground失败 2025-08-27 19:08:57 +08:00
roymondchen
7695f005f6 style(runtime): 配置格式化 2025-08-27 17:01:08 +08:00
roymondchen
a10f9d230d fix(cli): 在pnpm工作空间中的项目,保持package.json不受配置中的packages影响 2025-08-27 16:48:51 +08:00
roymondchen
9f350541bf feat(cli): 支持tmagic.config.local配置文件,会与tmagic.config配置合并,可用于本地开发时的临时配置 2025-08-27 16:19:43 +08:00
roymondchen
0643699fac chore: 删除ui/ui-react 2025-08-27 15:43:28 +08:00
roymondchen
9f63dff49b build(runtime): 构建playground示例失败 2025-08-27 14:31:24 +08:00
roymondchen
7d3a2df793 chore: 删除vue2 runtime,后续vue-components里的组件不再考虑vue2的支持 2025-08-27 14:24:15 +08:00
roymondchen
0967c3449e build(runtime): 重构vue3 runtime的构建配置 2025-08-26 20:40:24 +08:00
roymondchen
f267643c42 chore: update deps 2025-08-26 17:27:37 +08:00
roymondchen
f3387ed5e9 chore: update lockfile v1.6.0-beta.6 2025-08-15 12:30:41 +08:00
roymondchen
71d1aab69e chore: release v1.6.0-beta.6 2025-08-15 12:29:06 +08:00
roymondchen
4c6118f50f feat(core): 事件支持关联数据源自身方法 2025-08-15 12:25:00 +08:00
roymondchen
77da3f9762 chore: update lockfile v1.6.0-beta.5 2025-08-08 16:00:48 +08:00
roymondchen
8b3cb63f77 chore: release v1.6.0-beta.5 2025-08-08 15:59:17 +08:00
roymondchen
fc1c9feafd fix(core): 事件行为应该为串行执行 2025-08-08 15:51:54 +08:00
roymondchen
371be8aa27 chore: update lockfile v1.6.0-beta.4 2025-07-24 16:49:05 +08:00
roymondchen
7bb14e6c25 chore: release v1.6.0-beta.4 2025-07-24 16:47:31 +08:00
roymondchen
cdb07dfaea fix(editor): 避免services plugin重复添加 2025-07-24 16:43:40 +08:00
roymondchen
c2830fca6b fix(editor): runtime url更新后恢复当前选中状态 2025-07-24 15:55:59 +08:00
roymondchen
bba67b5533 chore: update lockfile v1.6.0-beta.3 2025-07-24 14:14:37 +08:00
roymondchen
eda9924327 chore: release v1.6.0-beta.3 2025-07-24 14:12:58 +08:00
qyaniwu
07b8f5fe83 fix(editor): 修复代码块编辑器的更新内容后按下ctrl+s光标会偏移的问题 2025-07-24 04:13:02 +00:00
roymondchen
d31a544a23 fix(editor): runtimeUrl更新后需要重新设置runtime的dsl 2025-07-24 11:24:36 +08:00
roymondchen
01b7b58065 chore: update lockfile v1.6.0-beta.2 2025-07-22 20:31:48 +08:00
roymondchen
870dd99e2c chore: release v1.6.0-beta.2 2025-07-22 20:30:18 +08:00
roymondchen
01b88dba25 feat(core): 异步加载dsl片段下,事件触发时node可能不存在 2025-07-22 20:23:14 +08:00
roymondchen
2605011df4 feat(utile): replaceChildNode找不多目标不报错 2025-07-22 20:16:37 +08:00
roymondchen
00cf312a91 chore(vue-runtime-help): release 2025-07-17 19:08:50 +08:00
roymondchen
e3ed80b121 chore: update lockfile v1.6.0-beta.1 2025-07-17 18:51:31 +08:00
roymondchen
0752abc312 chore: release v1.6.0-beta.1 2025-07-17 18:50:02 +08:00
roymondchen
ded24c8b4f feat(editor): 页面片容器内的组件不允许选中 2025-07-17 18:26:29 +08:00
roymondchen
7799a5da61 fix(vue-components): iterator-container 传递 page-fragment-contianer-id 参数 2025-07-17 17:24:41 +08:00
roymondchen
6cb08cf458 style(vue-runtime-help): 完善类型 2025-07-17 17:22:11 +08:00
roymondchen
305ea4619f fix(data-source): 页面未初始化好之前,数据源数据变化后需要修改page.data 2025-07-17 17:20:58 +08:00
roymondchen
291de2005d feat(core): Node中的instance初始为null,用于判断是否与组件产生关联 2025-07-17 17:19:03 +08:00
roymondchen
34bc223f02 feat(vue-components): page-fragment-container编辑器中不去除内部组件id,不然会导致无法从app中获取dsl 2025-07-17 14:09:11 +08:00
roymondchen
bf9fad18b6 fix(vue-components): page-fragment-container不标记为不是node节点 2025-07-15 16:40:53 +08:00
roymondchen
cebf3506d4 build: 升级rollup 4.45.0后playground构建失败,回滚回4.44.1 2025-07-15 16:31:12 +08:00
roymondchen
a43825caa2 feat(vue-components): 添加页面片容器id prop 2025-07-15 15:31:51 +08:00
roymondchen
1736d495fd chore: update lockfile v1.6.0-beta.0 2025-07-15 15:14:30 +08:00
roymondchen
44b592f36a chore: release v1.6.0-beta.0 2025-07-15 15:13:01 +08:00
roymondchen
6a54720068 feat(core,data-source,utils,react-runtime-help,vue-runtime-help): 新增对页面片节点的管理 2025-07-15 15:08:53 +08:00
roymondchen
aaf8046c63 fix(editor): 依赖收集后没有同步到dsl中 2025-07-11 19:02:56 +08:00
roymondchen
5242585500 chore: update copyright 2025-07-11 15:04:22 +08:00
roymondchen
4637c80125 style(editor,stage): 完善moveableOptions prop类型定义 2025-07-04 14:25:05 +08:00
roymondchen
5b7d2dd248 chore: update lockfile v1.5.24 2025-07-03 20:55:54 +08:00
roymondchen
5ab7030c3a chore: release v1.5.24 2025-07-03 20:54:08 +08:00
roymondchen
84bf9ba2f9 fix(editor): 初始化收集依赖后编译数据源不能使用源数据 2025-07-03 20:50:46 +08:00
roymondchen
c87e539dd3 chore: update lockfile v1.5.23 2025-07-03 14:22:13 +08:00
roymondchen
49f3f6853e chore: release v1.5.23 2025-07-03 14:20:41 +08:00
roymondchen
222a96e465 feat(editor): 数据源属性/方法表格可以拖动列宽 2025-07-03 14:11:44 +08:00
roymondchen
2f4a7a33b8 feat(core,data-source,dep,editor,schema): 新增组件禁用代码块/数据源的配置开关 2025-07-03 14:10:20 +08:00
roymondchen
c984c1a0cf fix(editor): 树组件搜索后不展开所有节点 2025-07-02 19:47:52 +08:00
roymondchen
727af1058d fix(editor): 页面列表滚动条 2025-07-02 18:00:21 +08:00
roymondchen
68abaae750 chore: update deps 2025-07-02 17:55:12 +08:00
roymondchen
0e8043664e chore: update deps 2025-07-02 17:06:37 +08:00
roymondchen
3f7d03959c feat(dep,schema): 添加组件没用数据源或者代码块的配置key 2025-07-02 16:42:55 +08:00
roymondchen
ee06c26ca5 refactor(editor): dsl更新后通知runtime更新代码优化 2025-07-02 16:21:03 +08:00
roymondchen
9e590c5cf7 feat(editor): 新增props-panel-unmounted事件 2025-06-26 21:06:21 +08:00
roymondchen
8d6da3712e feat(editor): service新增removePlugin方法 2025-06-26 16:49:32 +08:00
roymondchen
b78ef20602 feat(playground): 新增按比例拖动组件大小快捷键 2025-06-25 14:19:18 +08:00
roymondchen
18e8df4a55 fix(editor): 防止快捷键重复注册 2025-06-25 14:17:43 +08:00
roymondchen
b6a260471d fix(editor,react-runtime-help,vue-runtime-help): 修复拖动页面顺序失效问题 2025-06-20 20:10:24 +08:00
roymondchen
32681964b3 feat(editor): stage overlay 支持放大缩小 2025-06-20 19:47:51 +08:00
roymondchen
95d6263f42 feat(stage): 新增禁用标尺配置 2025-06-20 19:08:10 +08:00
roymondchen
bbf93cb2b5 style(vue-runtime-help): 新增组件props的统一类型定义 2025-06-20 15:22:44 +08:00
roymondchen
3b1e41b217 refactor(playground): 整理代码 2025-06-20 15:05:47 +08:00
roymondchen
bdd59cff9b feat(stage): 添加updateMoveableOptions api,用于更新选中框状态 2025-06-20 14:38:36 +08:00
roymondchen
c3633b0481 chore: update lockfile v1.5.22 2025-06-09 19:44:08 +08:00
roymondchen
652670fa4c chore: release v1.5.22 2025-06-09 19:42:22 +08:00
roymondchen
1614b62d2a feat(editor): 样式中的position选项加上中文 2025-06-09 19:36:54 +08:00
roymondchen
6152a78467 feat(editor): 支持禁用数据源与代码块 2025-06-09 16:35:08 +08:00
roymondchen
b1f020d532 fix(data-source,utils): 不使用replaceAll,安卓10不支持 2025-06-09 14:18:36 +08:00
roymondchen
6b4ca4b83a feat(form,form-schema): group list支持配置默认展开数量 2025-06-06 20:13:34 +08:00
roymondchen
b72f4dae28 fix(vue-runtime-help): 修复页面片中组件拖动位置异常问题 2025-06-06 19:33:15 +08:00
roymondchen
0bd8496fac refactor(editor,stage): 完善页面变化后画布大小更新 2025-06-06 19:29:20 +08:00
roymondchen
b78b2011e5 chore: 更新commit-msg 2025-06-06 16:05:26 +08:00
roymondchen
3097e8eddb feat(editor): 支持配置自定义创建Monaco editor函数 2025-06-06 16:03:56 +08:00
roymondchen
cd4656e54f feat(design): dialog支持配置destroyOnClose 2025-06-06 14:55:06 +08:00
roymondchen
5f246bbc98 chore: update deps 2025-06-05 20:14:23 +08:00
roymondchen
e01ce2128e feat(eslint-conft): 添加import-sort的本地目录 2025-06-04 19:34:17 +08:00
roymondchen
9ee748710b chore: update lockfile v1.5.21 2025-06-04 17:07:40 +08:00
roymondchen
2565d67add chore: release v1.5.21 2025-06-04 17:05:53 +08:00
roymondchen
92534fc915 feat(editor,stage): 支持切换runtimeUrl 2025-05-29 20:17:15 +08:00
roymondchen
0196eb343a feat(editor): 获取联动组件的方法函数中添加组件id参数 2025-05-28 17:47:12 +08:00
roymondchen
8142a7ab6d feat(form): select before/after request配置函数支持异步 2025-05-27 14:58:29 +08:00
roymondchen
c7b2734090 fix(data-source): 没有异步加载数据源的情况下,数据源init方法没有执行 2025-05-26 20:04:40 +08:00
roymondchen
1cee0bf4aa chore: update lockfile v1.5.20 2025-05-21 17:02:30 +08:00
roymondchen
4288ab9873 chore: release v1.5.20 2025-05-21 17:00:45 +08:00
roymondchen
b78d2fda1f feat(core): 新增事件处理前后的钩子函数配置 2025-05-21 16:58:06 +08:00
roymondchen
dc37d4e8bd feat(data-source): 新增判断所有数据源加载完成的方法 2025-05-21 16:27:49 +08:00
roymondchen
a35789c0cf feat(data-source): 由于存在异步加载数据源,新增所有数据源加载完毕事件 2025-05-21 16:24:35 +08:00
roymondchen
1e396d4a8d fix(editor): 新增数据源时,由于方法列表为空出现的报错 2025-05-21 16:20:23 +08:00
roymondchen
444858491d fix(editor): getTMagicApp中对runtime-ready可能存在多次事件监听 2025-05-21 16:18:12 +08:00
roymondchen
1f7ad2fbb8 chore: update lockfile v1.5.19 2025-05-20 13:59:03 +08:00
roymondchen
d66ee4db48 chore: release v1.5.19 2025-05-20 13:57:18 +08:00
roymondchen
abe27db47a feat(core): 支持统一设置node.store的初始值 2025-05-20 11:46:25 +08:00
roymondchen
d628ffad26 fix(data-source): 异步加载数据源时,初始化第一次编译时数据源可能未加载,需要优先设置数据源默认值 2025-05-19 20:14:29 +08:00
roymondchen
79f65fb516 chore(ui): 将ui/ui-react从packages移入runtime中,不再跟随packags发布 2025-05-19 16:16:03 +08:00
roymondchen
fc886715c7 fix(data-source): 异步加载数据源时,初始化第一次编译时数据源可能未加载,需要优先设置数据源默认值 2025-05-19 14:13:52 +08:00
roymondchen
1444eb6ae7 fix(editor): 由于数据源可能有内部方法,所以去掉事件联动中数据源选项置灰的逻辑 2025-05-16 17:14:50 +08:00
roymondchen
5b8c2c2111 chore: update lockfile v1.5.18 2025-05-14 15:49:28 +08:00
roymondchen
7dbf464e38 chore: release v1.5.18 2025-05-14 15:47:34 +08:00
roymondchen
936eb08a94 fix(editor): 选中组件时,如果组件处于所在容器可视范围外,不要将组件滚动至可视范围,而是滚动组件容器至可视范围 2025-05-14 14:17:57 +08:00
roymondchen
d1e99a46a7 feat(core): 新增数据源初始数据配置字段 2025-05-14 11:07:55 +08:00
roymondchen
e0d5efb022 feat(editor): 组件高级配置中添加display 2025-05-13 16:31:14 +08:00
roymondchen
054d12601b feat(editor): eventsServic支持插件扩展 2025-05-13 16:29:34 +08:00
roymondchen
6b481c4473 fix(editor): 根节点修改在update事件中不要触发依赖收集 2025-05-12 17:48:03 +08:00
roymondchen
8195c105c0 style(form-schema): EventSelectConfig添加公共配置 2025-05-07 14:06:56 +08:00
roymondchen
06a3dc8436 chore: update lockfile v1.5.17 2025-05-06 20:14:13 +08:00
roymondchen
b88ca14fde chore: release v1.5.17 2025-05-06 20:12:11 +08:00
roymondchen
9289ffd187 build(docs): 文档构建失败 2025-05-06 20:00:25 +08:00
roymondchen
179b797c5c feat(editor): dsl初始化时收集依赖使用worker 2025-05-06 19:59:27 +08:00
roymondchen
9252822c58 refactor(data-source): 注册base/http数据源的代码有副作用 2025-04-30 17:03:36 +08:00
roymondchen
50b74d10e6 feat(editor,form,form-schema): 新增form-schema,将表单schema放入其中 2025-04-30 16:05:31 +08:00
roymondchen
85284e54f5 feat(cli): 指定组件不使用动态加载,dynamicImport为true时有效 2025-04-30 11:40:56 +08:00
roymondchen
ed01cfca87 feat(form): select before/after request函数配置中增加prop字段 2025-04-29 19:27:01 +08:00
roymondchen
687bf33eb2 chore: update lockfile v1.5.16 2025-04-28 20:26:30 +08:00
roymondchen
1852560b55 chore: release v1.5.16 2025-04-28 20:24:40 +08:00
roymondchen
2dc0bbc679 feat(editor): 组件默认的名称,id配置只要在业务不提供时才加入 2025-04-28 20:14:01 +08:00
roymondchen
e5bcd762b2 feat(core): instance设定不再限制只有方法 2025-04-28 20:11:28 +08:00
roymondchen
6dc007388b feat(core): 添加error hander配置 2025-04-28 17:25:00 +08:00
roymondchen
378c75658d fix(data-source): 异步加载数据源后,数据源未初始化 2025-04-27 17:07:08 +08:00
roymondchen
7eded0e44a chore: update lockfile v1.5.15 2025-04-25 16:23:29 +08:00
roymondchen
cdfb3adfa9 chore: release v1.5.15 2025-04-25 16:21:44 +08:00
roymondchen
ba05ecbf60 fix(editor): getTMagicApp返回类型错误 2025-04-25 15:00:37 +08:00
roymondchen
9d8ee4b2d3 chore: update lockfile v1.5.14 2025-04-24 15:02:24 +08:00
roymondchen
e774c9ff5f chore: release v1.5.14 2025-04-24 15:00:40 +08:00
roymondchen
604ae1eb52 chore: release脚本__dirname变量 2025-04-24 14:50:53 +08:00
roymondchen
105de9d2c6 feat(utils): 添加设置删除获取url参数的方法 2025-04-24 14:38:57 +08:00
roymondchen
0987901a46 build: github workflows 安装node失败 2025-04-24 14:07:30 +08:00
roymondchen
de52ff4fe1 fix(editor): 编辑数据源/代码块时,列表高亮 2025-04-24 14:02:34 +08:00
roymondchen
0e911337b8 fix(dep): 配置了数据源内部方法无法收集到依赖 2025-04-24 11:34:22 +08:00
roymondchen
fd7e737e8c feat(vue-runtime-help): app不存在时抛异常,保证app一定存在,避免多余的可选链 2025-04-23 15:05:14 +08:00
roymondchen
e7e9197ae3 style: 更新eslint版本,更新eslint配置 2025-04-21 20:35:54 +08:00
roymondchen
5e0e776d40 feat(form): onChange添加setModel参数,用于修改model并添加至修改记录中 2025-04-21 19:42:22 +08:00
roymondchen
31515c4046 chore: update lockfile v1.5.13 2025-04-10 20:56:00 +08:00
roymondchen
42adb962fd chore: release v1.5.13 2025-04-10 20:54:13 +08:00
roymondchen
0bcd7d0755 feat(core): 支持传入env 2025-04-10 20:36:38 +08:00
roymondchen
54e00f2852 feat(editor): 编辑代码块/数据源时高亮列表中对应的项 2025-04-10 20:36:38 +08:00
marchyang
f91eb415db fix: 修复表格拖拽排序与表单选字操作冲突的问题 2025-04-04 10:56:52 +08:00
roymondchen
18524d89fb feat(core): 支持自定义Node类 2025-04-02 17:24:02 +08:00
roymondchen
840c2c3c7d fix(data-source): 数据源初始化时机比注册早回出现死循环 2025-04-02 17:17:30 +08:00
roymondchen
9b546645f3 chore: update deps 2025-03-31 20:31:29 +08:00
roymondchen
38ea57c6cb chore: update lockfile v1.5.12 2025-03-27 16:32:44 +08:00
roymondchen
c8fc2f7bfb chore: release v1.5.12 2025-03-27 16:30:51 +08:00
roymondchen
b715a87f40 feat(cli): 如果识别不要组件文件,则默认从npm包的default导入 2025-03-27 16:25:58 +08:00
roymondchen
f17ef325b1 chore: update vite 2025-03-27 11:29:18 +08:00
roymondchen
4ddc55aa6d fix(design): card没有slots时隐藏对应slot 2025-03-27 11:12:27 +08:00
roymondchen
2a714ae9cc fix(vue-components): button删除调试代码,text支持富文本 2025-03-18 16:54:55 +08:00
roymondchen
d53a479b21 style(vue-runtime-help): 更新ts定义 2025-03-18 16:52:21 +08:00
roymondchen
f5742c107a fix(editor): 获取关联组件的方法默认值 2025-03-13 14:30:28 +08:00
roymondchen
9c7d711c16 fix(editor): 数据源修改后,依赖重新收集不准确 2025-03-12 14:22:33 +08:00
roymondchen
11c027c71b chore: update lockfile v1.5.11 2025-03-11 17:14:17 +08:00
roymondchen
16f1c47db6 chore: release v1.5.11 2025-03-11 17:12:29 +08:00
roymondchen
72108e0019 fix(dep): 数据源方法收集判断 2025-03-11 17:01:32 +08:00
roymondchen
0c207c7b83 fix(dep): 依赖收集不能过滤id/name 2025-03-10 11:32:27 +08:00
roymondchen
f671c670db feat(vue-runtime-help): useDsl/useEditorDsl添加app默认参数 2025-03-07 14:33:13 +08:00
roymondchen
a293bd8d3f chore: update lockfile v1.5.10 2025-03-07 11:33:33 +08:00
roymondchen
7dad6720e4 chore: release v1.5.10 2025-03-07 11:31:46 +08:00
roymondchen
402f05f3d6 test(editor): 删除eventsService.init用例 2025-03-06 20:36:10 +08:00
roymondchen
0736646c63 feat(vue-components,react-components): 增加点击事件,使用组件状态hook 2025-03-06 20:29:38 +08:00
roymondchen
8d0040da53 chore(runtime): 更新runtime-help 2025-03-06 20:22:52 +08:00
roymondchen
6f5bb84c04 feat(reate-runtime-help,vue-runtime-help): 新增组件状态hook 2025-03-06 20:20:01 +08:00
roymondchen
63fe6ec68b fix(stage): 防止runtime重复注册 2025-03-06 20:10:52 +08:00
roymondchen
ff07147270 feat(core): node新增registerMethod方法,用于组件注册供其他组件通过事件配置调用 2025-03-06 20:08:47 +08:00
roymondchen
c8e1cffca9 feat(core, editor): 删除公共的点击事件实现,由组件自行添加 2025-03-06 20:05:49 +08:00
roymondchen
5ba2a73c70 feat(core): hook函数调用添加node参数 2025-03-04 19:11:36 +08:00
roymondchen
a4d021d2fb feat(core): app添加dsl-change事件 2025-03-04 17:07:45 +08:00
roymondchen
3c66319b03 fix(data-source): 处理异步动态加载数据源时,初始化数据源还未加载完毕的情况 2025-03-04 17:05:05 +08:00
roymondchen
775fcf5693 fix(editor): 样式配置宽度不能为负 2025-03-04 14:09:28 +08:00
roymondchen
f5315122e4 chore(vue-components): 添加name option 2025-02-27 19:33:57 +08:00
roymondchen
90abde57cc feat(runtime): vue2 h传参与vue3不一样,需要自定义render 2025-02-27 19:32:48 +08:00
roymondchen
91cde30d75 feat(vue-container): 支持自定义render 2025-02-27 19:31:07 +08:00
roymondchen
2114b71d47 style(vue-runtime-help): 添加UserRenderFunction定义 2025-02-27 19:28:08 +08:00
roymondchen
94d0ed1fd0 chore(playground): 恢复dsl本地存储的key 2025-02-27 11:31:20 +08:00
roymondchen
4026c0c305 feat(runtime): 支持页面切换 2025-02-26 15:20:32 +08:00
roymondchen
6d2b9d5f21 chore: update lockfile v1.5.9 2025-02-20 17:34:45 +08:00
roymondchen
f2f9044be0 chore: release v1.5.9 2025-02-20 17:32:53 +08:00
roymondchen
ebc873d6f3 style(stage): 完善Runtime定义 2025-02-20 15:16:20 +08:00
roymondchen
4d77b669ba feat(table): formatter添加index信息 2025-02-18 19:46:00 +08:00
roymondchen
6f2c6b151d feat(table): 支持type: index的序号列 2025-02-18 19:40:28 +08:00
roymondchen
6e2b5aea47 fix(editor): 编辑器销毁不应该移除依赖收集任务的事件监听 2025-02-12 14:08:27 +08:00
roymondchen
098351bb21 chore: update lockfile v1.5.8 2025-02-11 19:39:18 +08:00
roymondchen
a0e7ee7292 chore: release v1.5.8 2025-02-11 19:37:31 +08:00
roymondchen
3fbcbf25ca test(editor): 完善测试用例 2025-02-11 19:34:42 +08:00
roymondchen
413134b21d feat(editor): 优化依赖收集状态显示,新增剩余任务数量显示 2025-02-11 19:25:28 +08:00
roymondchen
6d82c0f730 fix(editor): 组件配置列大小缓存不生效 2025-02-11 17:25:58 +08:00
roymondchen
900b701c80 refactor(editor): 新增useServices hook,减少使用可选链 2025-02-11 16:24:24 +08:00
roymondchen
9cabbe8c7c chore: update lockfile v1.5.7 2025-02-11 10:56:29 +08:00
roymondchen
155c4a75b3 chore: release v1.5.7 2025-02-11 10:54:45 +08:00
roymondchen
aec80388f0 build: vite6.0后构建的css文件名需配置回style 2025-02-11 10:47:43 +08:00
roymondchen
51b62cfe92 chore: update lockfile v1.5.6 2025-02-10 20:14:25 +08:00
roymondchen
8136477dd9 chore: release v1.5.6 2025-02-10 20:12:39 +08:00
roymondchen
877a4eaa49 feat(editor): 优化浏览器变小时各列大小变化 2025-02-10 19:59:11 +08:00
roymondchen
7fa3181376 chore(vue3-runtime): 更新vue cdn 2025-02-10 14:20:52 +08:00
roymondchen
c524cd4086 build: 统一构建加入runtime 2025-01-21 19:56:04 +08:00
roymondchen
5c0cfe44dd build: 统一构建 2025-01-21 19:13:01 +08:00
roymondchen
51ca1e60af fix(editor): 编辑器组件销毁后重置依赖收集 2025-01-20 19:55:14 +08:00
roymondchen
e234428965 chore: update deps 2025-01-20 19:34:12 +08:00
roymondchen
701a9d6f30 fix(core): deep-state-observer update 的data与初始化时相同,导致get data为空 2025-01-20 14:58:20 +08:00
roymondchen
e8461f91e6 fix(editor): 已经配置了的样式无法删除 2025-01-17 19:49:56 +08:00
roymondchen
e9c6a3bb2f fix(editor): 修改数据源可能造成页面卡死 2025-01-17 19:48:02 +08:00
roymondchen
215ef93173 chore: update lockfile v1.5.5 2025-01-14 16:37:34 +08:00
roymondchen
34878d26f8 chore: release v1.5.5 2025-01-14 16:33:37 +08:00
roymondchen
040b787e8f feat(editor): 优化依赖收集,数据源代码块分开收集 2025-01-14 16:27:04 +08:00
roymondchen
b215062177 feat(dep): 性能优化,收集时节点配置中id与name不需要做判断 2025-01-14 16:22:04 +08:00
roymondchen
ad2545c2e2 chore: update lockfile v1.5.4 2025-01-10 19:58:51 +08:00
roymondchen
df1cb5f3e7 chore: release v1.5.4 2025-01-10 19:55:39 +08:00
roymondchen
8b1201626d fix(element-plus-adapter): 只有当前没注册loading指令时才注册 2025-01-10 19:52:32 +08:00
roymondchen
ab7df6c21e refactor(editor): 优化dsl更新后画布更新逻辑 2025-01-10 19:44:40 +08:00
roymondchen
895c461e2b refactor(editor): 优化依赖收集,优先收集数据源依赖 2025-01-10 19:31:41 +08:00
roymondchen
1baec3f1d4 refactor(editor): useTemplateRef参数不能与变量名一样,不然会有一个warn 2025-01-09 20:48:35 +08:00
roymondchen
552df3a614 refactor(editor): service中state改完使用shallowReactive 2025-01-09 20:43:54 +08:00
roymondchen
1bcefdb1e8 fix(element-plus-adapter): 增加loading指令 2025-01-09 20:41:30 +08:00
roymondchen
e57fc7b718 refactor(editor): form-panel mounted事件参数 2025-01-06 19:32:40 +08:00
roymondchen
8feac3861e chore: update lockfile v1.5.3 2025-01-06 18:28:23 +08:00
roymondchen
ee0b10746c chore: release v1.5.3 2025-01-06 18:26:39 +08:00
roymondchen
ac2b8dbfcf refactor(editor): form-panel mounted参数改成proxy 2025-01-06 17:47:06 +08:00
roymondchen
8aaf941d24 refactor(form): type component需要配置component 2025-01-06 17:41:28 +08:00
roymondchen
4313ddca54 style(editor): 显示条件表格配置 2025-01-06 16:23:43 +08:00
roymondchen
a831413151 feat(form): groupList支持复制单条记录,支持移动单条记得到指定位置,table支持复制单条记录 2025-01-03 19:47:25 +08:00
roymondchen
833dbcd8b4 fix(editor): select配置项无法清空 2025-01-03 17:28:57 +08:00
roymondchen
7b0a476677 feat(editor): 配置组件时将样式中的空配置移除 2025-01-03 17:27:29 +08:00
roymondchen
9e35642879 style(editor): 优化样式配置面板 2025-01-03 17:25:25 +08:00
roymondchen
e8bbdf613b feat(editor): 样式配置面板支持拖动大小 2024-12-30 20:44:27 +08:00
moonszhang
246e6941d5 feat(editor,form,schema): 组件样式配置可视化 2024-12-30 12:17:43 +00:00
roymondchen
ec94eed787 fix(core): 公共点击事件在非浏览器环境不执行 2024-12-27 14:52:04 +08:00
roymondchen
46a26af5d6 chore(vue-components): update version 2024-12-26 14:33:19 +08:00
roymondchen
616a4a506d build(runtime): _plugin-vue_export-helper js file cant not be access with Github Pages 2024-12-25 14:52:39 +08:00
roymondchen
a9b4ac0879 chore: update lockfile v1.5.2 2024-12-18 20:40:47 +08:00
roymondchen
5939f1d487 chore: release v1.5.2 2024-12-18 20:36:46 +08:00
roymondchen
af46d775f0 build: vite6.0后构建的css文件名需配置回style 2024-12-18 20:29:54 +08:00
roymondchen
d48d40a2b7 fix(editor): data-source-field-select透传eventData 2024-12-18 20:27:46 +08:00
roymondchen
c29afba89e chore: update lockfile v1.5.1 2024-12-18 16:22:30 +08:00
roymondchen
18f92823c2 chore: release v1.5.1 2024-12-18 16:20:38 +08:00
roymondchen
7887a14f6b style(editor): 完善emit定义 2024-12-18 16:10:07 +08:00
roymondchen
712e317e40 feat(editor): 样式添加display配置,右侧边栏最小值设置成420 2024-12-18 16:01:45 +08:00
roymondchen
957b0d9b40 fix(form): table 开启dropSort后,多次拖动row后会报错 2024-12-18 15:34:04 +08:00
roymondchen
432f1f5a55 feat(design): table添加row/cell class name 2024-12-18 15:31:22 +08:00
roymondchen
039ab9d192 test(editor): 修复测试用例 2024-12-17 20:52:01 +08:00
roymondchen
5cd6d21b2e feat(editor): 组件配置中的样式支持单独一列显示 2024-12-17 20:47:33 +08:00
roymondchen
7a8da68edb feat(form): 新增labelPosition配置 2024-12-17 20:36:29 +08:00
roymondchen
e421a58f4e feat(vue-components,react-components): 组件表单配置修改 2024-12-17 20:33:57 +08:00
roymondchen
74f76d0ba3 feat(editor): 数据源/代码编辑列表新增右键菜单 2024-12-16 20:20:02 +08:00
roymondchen
4f23aebd7f docs: 更新教程中使用的tmagic版本 2024-12-13 17:30:48 +08:00
roymondchen
98f45d2334 chore: update deps 2024-12-13 16:54:56 +08:00
roymondchen
6cf20cee34 refactor(editor): scss中使用use替换import 2024-12-13 16:39:55 +08:00
roymondchen
cf104e64aa style(editor): 修改拼写错误 2024-12-13 16:38:20 +08:00
roymondchen
7109df9deb refactor(editor): 模板改成使用useTemplateRef 2024-12-13 16:19:44 +08:00
roymondchen
23eafb135d chore: update lockfile v1.5.0 2024-12-10 16:36:11 +08:00
roymondchen
4c54355a42 chore: release v1.5.0 2024-12-10 16:34:23 +08:00
roymondchen
d8815237f5 fix(core): devtools更新代码块函数可能没有name,导致失败 2024-12-10 16:05:25 +08:00
roymondchen
3cae4fbc1c feat(cli): 新增npm install 参数配置 2024-12-09 20:21:34 +08:00
roymondchen
e6909dc052 fix(cli): 组件库未npm包时其中的组件无法识别 2024-12-09 20:21:34 +08:00
roymondchen
a569d51f6b fix(cli): keepPackageJsonClean开启后lock不要修改 2024-12-09 20:21:34 +08:00
roymondchen
35ad61034d docs: 1.5.0升级指南 2024-12-09 20:21:34 +08:00
roymondchen
d56b5873ff chore(design): scss兼容性修改 2024-12-09 20:21:34 +08:00
roymondchen
d58cac7909 fix(editor): 事件中选择联动组件无法再组件树中选择 2024-12-09 20:21:34 +08:00
roymondchen
2fd646fdea chore: update lockfile v1.5.0-beta.16 2024-12-09 20:21:34 +08:00
roymondchen
cf2382ac55 chore: release v1.5.0-beta.16 2024-12-09 20:21:34 +08:00
roymondchen
a0f39d90d6 feat(core): 新增调试api 2024-12-09 20:21:34 +08:00
roymondchen
0d6420215c fix(editor): 修改未包含数据源的配置,画布中没有实时更新 2024-12-09 20:21:34 +08:00
roymondchen
945aaaddcb chore(core): setTimeout后清除timeid 2024-12-09 20:21:34 +08:00
roymondchen
5caae4e953 fix(data-source): 执行时机函数需要await 2024-12-09 20:21:34 +08:00
roymondchen
12230c2f4e feat(utils): 新增getGlobalThis方法 2024-12-09 20:21:34 +08:00
roymondchen
e3f6ef48e6 feat(form): formState现在, 2024-12-09 20:21:34 +08:00
roymondchen
9948360435 feat(vue-components): 添加className配置,page新增css、cssFile、jsFile配置 2024-12-09 20:21:34 +08:00
roymondchen
d1197279fd fix(vue-runtime-help): 更新dsl时,设置默认选中项与默认页面 2024-12-09 20:21:34 +08:00
roymondchen
2186fc4e87 fix(core): 没有数据源配置时,不初始化数据源事件 2024-12-09 20:21:34 +08:00
roymondchen
f79e89e0ec docs: 新增快速创建命令 2024-12-09 20:21:34 +08:00
roymondchen
6e2c12f5ff chore: update lockfile v1.5.0-beta.15 2024-12-09 20:21:34 +08:00
roymondchen
ade98ff924 chore: release v1.5.0-beta.15 2024-12-09 20:21:34 +08:00
roymondchen
e3f28abe1a feat(editor): 代码块与数据源列表节点中新增依赖收集中tag 2024-12-09 20:21:34 +08:00
roymondchen
6030ed1684 feat(edtior,stage): 重新渲染改成重新收集依赖后渲染 2024-12-09 20:21:34 +08:00
roymondchen
b51bafe509 style(stage): 选中框上方按钮改成可点击样式 2024-12-09 20:21:34 +08:00
roymondchen
03942dc49e feat(data-source,editor): http数据源params,data,headers支持函数配置 2024-12-09 20:21:34 +08:00
roymondchen
7a47315bc1 feat(editor): 选中页面后页面列表自动滚动到选中项 2024-12-09 20:21:34 +08:00
roymondchen
0727fe4fea feat(stage,editor): 在选中框新增支持触发画布中组件重新渲染 2024-12-09 20:21:34 +08:00
roymondchen
cdf2dc2b36 chore(editor): 优化页面tab体验 2024-12-09 20:21:34 +08:00
roymondchen
b4136c91c2 feat(editor): 优化依赖收集体验,减小收集任务粒度,修改配置时识别是否需要触发重新收集 2024-12-09 20:21:34 +08:00
roymondchen
9f7d67b17b feat(form,editor): 表单新增修改数据记录 2024-12-09 20:21:34 +08:00
roymondchen
0a1f03b5c7 chore(app): 删除无用log,export FlowState 2024-12-09 20:21:34 +08:00
parisma
52c1124e97 feat(editor): 事件流支持上下文对象传递和abort方法中断 2024-12-09 20:21:34 +08:00
roymondchen
f33f965354 chore(ui): 去掉package.json中export字段 2024-12-09 20:21:34 +08:00
roymondchen
eb614c47b0 chore: 更新依赖 2024-12-09 20:21:34 +08:00
roymondchen
7cd1bc7aec chore: 更新依赖 2024-12-09 20:21:34 +08:00
roymondchen
aaba8bff03 chore: update lockfile v1.5.0-beta.14 2024-12-09 20:21:34 +08:00
roymondchen
a6e9ecbe50 chore: release v1.5.0-beta.14 2024-12-09 20:21:34 +08:00
roymondchen
9741c4f3df style(form): 优化feildset,grouplist样式 2024-12-09 20:21:34 +08:00
roymondchen
b24b3749c4 fix(form): datatime没有初始值时异常 2024-12-09 20:21:34 +08:00
roymondchen
7964921389 chore: update lockfile v1.5.0-beta.13 2024-12-09 20:21:34 +08:00
roymondchen
88b243a8f4 chore: release v1.5.0-beta.13 2024-12-09 20:21:34 +08:00
roymondchen
13abe898a9 feat(editor): 支持配置页面过滤函数 2024-12-09 20:21:34 +08:00
roymondchen
12ce5c568e feat(form): 支持配置阻止默认的submit行为 2024-12-09 20:21:34 +08:00
roymondchen
d33ddcfa65 fix(editor): 更新组件配置后,如果当前没有任何依赖,不会触发收集,导致画布不更新 2024-12-09 20:21:34 +08:00
roymondchen
6521fdc988 chore: update lockfile v1.5.0-beta.12 2024-12-09 20:21:34 +08:00
roymondchen
8d231e14cc chore: release v1.5.0-beta.12 2024-12-09 20:21:34 +08:00
roymondchen
6e2a41afbc style(editor): import 错误 2024-12-09 20:21:34 +08:00
roymondchen
ed6d9b2b67 feat(editor): 页面/页面片不再使用tab分开显示,新增搜索页面 2024-12-09 20:21:34 +08:00
roymondchen
fc38fc3957 fix(editor): 修复修改页面配置后可能改造页面卡死问题 2024-12-09 20:21:34 +08:00
roymondchen
5dad9f0ec9 chore: update lockfile v1.5.0-beta.11 2024-12-09 20:21:34 +08:00
roymondchen
b1b1229a0b chore: release v1.5.0-beta.11 2024-12-09 20:21:34 +08:00
roymondchen
25646317ae fix(data-source): http数据源中mock数据应该是数据源定义好的数据,不再是请求的数据源 2024-12-09 20:21:34 +08:00
roymondchen
8b7dca8e23 chore: update lockfile v1.5.0-beta.10 2024-12-09 20:21:34 +08:00
roymondchen
f587a99385 chore: release v1.5.0-beta.10 2024-12-09 20:21:34 +08:00
roymondchen
5267b4bb93 feat(data-source): http数据源参数裁剪与响应裁剪支持异步函数配置 2024-12-09 20:21:34 +08:00
roymondchen
f6885a06b6 fix(data-source): 避免http数据源在编辑器中的响应裁剪中修改到mock配置的数据 2024-12-09 20:21:34 +08:00
roymondchen
eb8126c32f refactor(editor,utils): 将traverseNode方法挪到utils中 2024-12-09 20:21:34 +08:00
roymondchen
8aba06ac38 fix(data-source): 编辑器中迭代器容器中的容器添加组件并关联数据源后没有编译 2024-12-09 20:21:34 +08:00
roymondchen
2885e81c8b chore: update lockfile v1.5.0-beta.9 2024-12-09 20:21:34 +08:00
roymondchen
815a83f9ad chore: release v1.5.0-beta.9 2024-12-09 20:21:34 +08:00
roymondchen
995a9c9b57 chore: 将dist/style.css加入到sideEffects中 2024-12-09 20:21:34 +08:00
roymondchen
fd80bada97 fix(data-source): manager初始化数据源时,如果失败了要把data中对应的数据删掉,不然在ssr中会导致客户端不会重新尝试请求 2024-12-09 20:21:34 +08:00
roymondchen
054474634e fix(stage): 流水布局拖动无效 2024-12-09 20:21:34 +08:00
aldlss
dbb58e507d refactor(types): core 导出 AppOptionsConfig 2024-12-09 20:21:34 +08:00
roymondchen
c343fe4775 chore: update lockfile v1.5.0-beta.8 2024-12-09 20:21:34 +08:00
roymondchen
34bd98a815 chore: release v1.5.0-beta.8 2024-12-09 20:21:34 +08:00
roymondchen
e6239af7d8 fix(form): datarange组件如果传入utc时间,显示会出错 2024-12-09 20:21:34 +08:00
roymondchen
d3f5b2ec91 chore: update lockfile v1.5.0-beta.7 2024-12-09 20:21:34 +08:00
roymondchen
a99da7aa00 chore: release v1.5.0-beta.7 2024-12-09 20:21:34 +08:00
roymondchen
1de4d95bd4 chore: 更新依赖,vue@3.5.1 2024-12-09 20:21:34 +08:00
roymondchen
0c665c6b3c fix(form): date组件初始化时不显示值 2024-12-09 20:21:34 +08:00
roymondchen
7a19b7204c chore(runtime): 更新依赖 2024-12-09 20:21:34 +08:00
roymondchen
d9ef4b91fa fix(vue-component): 从core中获取utils的方法 2024-12-09 20:21:34 +08:00
roymondchen
368c9afc7f chore: update lockfile v1.5.0-beta.6 2024-12-09 20:21:34 +08:00
roymondchen
9da15002ff chore: release v1.5.0-beta.6 2024-12-09 20:21:34 +08:00
roymondchen
595d3cc7ca style(table): 完善ts定义 2024-12-09 20:21:34 +08:00
roymondchen
54c8169c34 chore: pnpm@9.9.0 2024-12-09 20:21:34 +08:00
roymondchen
7b9ceb9cfb style(editor): 修改indent prop 名称 2024-12-09 20:21:34 +08:00
roymondchen
6fd30242c0 feat(table): 新增createColumns函数 2024-12-09 20:21:34 +08:00
roymondchen
8cd2962b4b chore(core): npm包中增加resetcss.css 2024-12-09 20:21:34 +08:00
roymondchen
f17ff8e58b style: 完善ts 2024-12-09 20:21:34 +08:00
roymondchen
45d676f38f chore: update lockfile v1.5.0-beta.5 2024-12-09 20:21:34 +08:00
roymondchen
59417e8248 chore(vue-runtime-help): release 0.1.4 2024-12-09 20:21:34 +08:00
roymondchen
65c7ac919b chore: release v1.5.0-beta.5 2024-12-09 20:21:34 +08:00
roymondchen
f30f8ab13b feat(table): expand支持width fixed配置 2024-12-09 20:21:34 +08:00
roymondchen
815854bad8 chore(vue-components): release 2024-12-09 20:21:34 +08:00
roymondchen
0d901c018f fix(editor): stage销毁问题 2024-12-09 20:21:34 +08:00
roymondchen
a2c79c79cd fix(tmagic-form-runtime): 画布无法点击选中组件 2024-12-09 20:21:34 +08:00
roymondchen
47a21d6544 feat(editor): 新增已选组件、代码编辑、数据源及其子节点增量缩进配置 2024-12-09 20:21:34 +08:00
roymondchen
34fc0a15b9 refactor: 将data-source,dep,schema,utils收敛到core,将form,table,stage,design,util收敛到editor 2024-12-09 20:21:34 +08:00
洩氏诹诹子
c3bc1035ad feat(vue-component, runtime): 使用 app.resolveComponent 获取组件 (#631) 2024-12-09 20:21:34 +08:00
roymondchen
6e71448158 feat(stage): export MoveableActionsAble; 在选中框上面自定义按钮 2024-12-09 20:21:34 +08:00
roymondchen
2bb2a35fcc chore(react-component,vue-component): 更新依赖 2024-12-09 20:21:34 +08:00
roymondchen
ee469dfd65 refactor: 及时释放没用变量 2024-12-09 20:21:34 +08:00
roymondchen
0be82bedee chore: update lockfile v1.5.0-beta.4 2024-12-09 20:21:34 +08:00
roymondchen
735af70af6 chore: release v1.5.0-beta.4 2024-12-09 20:21:34 +08:00
roymondchen
e057ddc187 fix(data-source): 迭代内容多层嵌套下子组件条件配置不生效 2024-12-09 20:21:34 +08:00
roymondchen
b2410a8739 chore: release v1.5.0-beta.3 2024-12-09 20:21:34 +08:00
roymondchen
c82e3257c1 refactor(stage,editor): stage销毁后释放内部变量 2024-12-09 20:21:34 +08:00
roymondchen
6754c3a8a5 fix(dep): 数据源条件依赖收集默认不收集迭代器内部组件的依赖 2024-12-09 20:21:34 +08:00
roymondchen
79767c8ec1 chore: update lockfile v1.5.0-beta.2 2024-12-09 20:21:34 +08:00
roymondchen
f589df7303 chore: release v1.5.0-beta.2 2024-12-09 20:21:34 +08:00
roymondchen
ea79a0d601 fix(data-source): http数据源中mock配置中关闭启用后,不会执行request 2024-12-09 20:21:34 +08:00
roymondchen
798ace76f3 chore: 更新pnpm版本,修复ts错误 2024-12-09 20:21:34 +08:00
roymondchen
0979282504 feat(form): 添加tmagicFormItemProp 2024-12-09 20:21:34 +08:00
roymondchen
feaa295606 chore(playground): playground添加design style 2024-12-09 20:21:34 +08:00
roymondchen
c73a27eb1a feat(design): popover 添加destroyOnClose props 2024-12-09 20:21:34 +08:00
roymondchen
0e44372a7e chore: 更新版本号 2024-12-09 20:21:34 +08:00
roymondchen
7384e8babe chore: update lockfile v1.5.0-beta.1 2024-12-09 20:21:34 +08:00
roymondchen
ee1a019727 chore: release v1.5.0-beta.1 2024-12-09 20:21:34 +08:00
roymondchen
b0d42d79aa style(stage): 完善render配置的定义 2024-12-09 20:21:34 +08:00
roymondchen
c5ce6d3c10 style(editor): 优化数据源新增列表样式 2024-12-09 20:21:34 +08:00
roymondchen
4f7b6cede4 feat(editor): export tree组件 2024-12-09 20:21:34 +08:00
roymondchen
e53c0e1ce5 fix(design): popover zindex不生效 2024-12-09 20:21:34 +08:00
roymondchen
d4408aaa32 chore(runtime): 更新版本号 2024-12-09 20:21:34 +08:00
roymondchen
9dd10d7ea1 chore: release v1.5.0-beta.0 2024-12-09 20:21:34 +08:00
roymondchen
9494ed79a3 feat(uitls): 只是自定义dsl与dom el的关联关系函数 2024-12-09 20:21:34 +08:00
roymondchen
39e68bd33a chore: 升级elememt-plus版本 2024-12-09 20:21:34 +08:00
roymondchen
80040a69ef style(data-source): 删除无用注释 2024-12-09 20:21:34 +08:00
roymondchen
5e61f23106 feat(design,element-plus-adapter,tdesign-vue-next-adapter): 重新实现Popover组件,不再使用element-plus或tdesign组件 2024-12-09 20:21:34 +08:00
roymondchen
cab36b49a3 feat: 将ui-react中的组件独立成包 2024-12-09 20:21:34 +08:00
roymondchen
60d2b64aa5 fix: 迭代器内的组件配置了声明周期代码块无效 2024-12-09 20:21:34 +08:00
roymondchen
9e4da0a5c2 feat: dsl id渲染到dom上的data-tamgic-id,不再是id属性 2024-12-09 20:21:34 +08:00
roymondchen
b00e7aec13 build: 删除多余构建配置,构建ui 2024-12-09 20:21:34 +08:00
roymondchen
3758cf8e0a feat: 统一vue ui组件,将ui中的组件独立成包 2024-12-09 20:21:34 +08:00
roymondchen
5ed534e364 feat(cli): 组件库支持import npm包组件 2024-12-09 20:21:34 +08:00
roymondchen
7aeca39521 build: 不在每个package中构建dts,解决package间相互依赖问题 2024-12-09 20:21:34 +08:00
roymondchen
de47514f69 feat: 完善迭代器嵌套使用问题,重构事件配置处理代码
* feat(editor,core,data-source,dep,schema,ui,utils,vue-runtime-help): 完善迭代器

* test: 完善测试用例

* chore: 构建

* feat: 迭代器嵌套事件传递数据

---------

Co-authored-by: roymondchen <roymondchen@tencent.com>
2024-12-09 20:21:34 +08:00
roymondchen
5e7ac69929 chore: update lockfile v1.4.19 2024-12-09 20:21:34 +08:00
roymondchen
fc2fd851c3 chore: release v1.4.19 2024-12-09 20:21:34 +08:00
roymondchen
3a7bfef5cf fix(form): text组件配置了tooltip无效 2024-10-31 15:52:18 +08:00
roymondchen
1fa27e1239 chore: update lockfile v1.4.18 2024-09-14 10:35:53 +08:00
roymondchen
7173d28e5b chore: release v1.4.18 2024-09-14 10:33:40 +08:00
roymondchen
a750fcd108 chore: 将dist/style.css加入到sideEffects中 2024-09-13 20:27:00 +08:00
roymondchen
4ce3f3e34e style(form): form-item上的hidden class容易冲突,改成tmagic-form-hidden 2024-09-13 20:25:02 +08:00
roymondchen
e5a0fb7eca chore: update lockfile v1.4.17 2024-08-30 17:42:18 +08:00
roymondchen
65f7816c59 chore: release v1.4.17 2024-08-30 17:40:02 +08:00
roymondchen
883e227d54 fix(form): date相关的field,在没有配置valueFormat的情况下与默认的valueFormat不符 2024-08-30 17:35:04 +08:00
roymondchen
45d246abce chore: github action 使用dev分支作为构建分支 2024-08-06 14:42:06 +08:00
roymondchen
8d54bcafc1 style(editor): 代码参数配置label width设置长些 2024-08-06 14:35:19 +08:00
roymondchen
fa2d00ba36 fix(data-source): 编辑器的runtime不能对数据源的mock配置有影响 2024-08-06 14:33:21 +08:00
roymondchen
69f3cb2f12 feat(vue-runtime-help): 只有dsl中的组件才触发生命周期hook 2024-08-02 14:07:27 +08:00
roymondchen
831cdfb2d6 chore: update lockfile v1.4.16 2024-08-02 13:58:24 +08:00
roymondchen
5e95f56c34 chore: release v1.4.16 2024-08-02 13:56:15 +08:00
roymondchen
92e6d40e75 chore: 更新依赖 2024-08-01 20:44:36 +08:00
roymondchen
81a221e561 fix(ui): 页面style没有响应式了 2024-08-01 20:26:46 +08:00
roymondchen
c8d6a4f4d1 refactor(ui): 通过解析dsl渲染的组件,渲染时往config中加入IS_DSL_NODE_KEY,用于识别是系统渲染的 2024-08-01 20:25:02 +08:00
roymondchen
59f05270ae feat(core): 完善屏幕大小自动适配 2024-08-01 17:01:15 +08:00
roymondchen
9f8088164e chore: update lockfile v1.4.15 2024-07-26 13:08:09 +08:00
roymondchen
211673c6a5 chore: release v1.4.15 2024-07-26 13:05:51 +08:00
roymondchen
96224b4d92 fix(stage): 页面失焦时将alt键按下状态重置 2024-07-25 21:04:51 +08:00
roymondchen
b249563f94 feat(editor): 优化编辑器左边栏拖出体验,需要拖出一定距离才行 2024-07-25 20:58:07 +08:00
roymondchen
837daf6cab feat(editor): 编辑器左边栏支持配置不可拖出,支持before-click函数配置 2024-07-25 20:53:03 +08:00
roymondchen
72a7c151e9 fix(editor): 组件树右键菜单在组件树面板拖出时被面板遮挡
fix #624
2024-07-25 19:30:50 +08:00
roymondchen
3fa21fd3eb feat(editor): 数据源选择器编辑按钮添加tooltip 2024-07-25 19:23:34 +08:00
roymondchen
ea556d69f6 style(playground): 完善ts定义 2024-07-25 17:51:49 +08:00
roymondchen
0bbf7c5643 feat(editor): 添加component-list slot,用于自定义组件列表
re #621
2024-07-25 17:49:40 +08:00
roymondchen
16d4eff385 fix(editor): 组件树中将容器拖入自身中会导致容器丢失
fix #622
2024-07-25 17:20:36 +08:00
roymondchen
c456798751 fix(editor): 在组件树中多选时不能选中页面 2024-07-25 16:23:36 +08:00
linzisong
57be30cf6b docs: select选择器远程选项文档补充 2024-07-25 11:25:46 +08:00
roymondchen
8d111ea976 feat(data-source): 数据源新增setValue方法 2024-07-16 16:24:32 +08:00
roymondchen
059c0056c4 fix(editor): 数据源方法配置,设置后再次修改参数配置不显示 2024-07-16 16:16:05 +08:00
roymondchen
e209aa36e8 fix(data-source): 迭代器数据编译支持容器嵌套 2024-07-15 21:32:13 +08:00
roymondchen
a67058e1e5 chore: update lockfile v1.4.14 2024-07-12 16:08:13 +08:00
roymondchen
d85c6c1b2c chore: release v1.4.14 2024-07-12 16:05:59 +08:00
roymondchen
1fc04b4464 fix(data-source): 迭代条件条件组编译逻辑不对 2024-07-12 14:14:04 +08:00
roymondchen
2b8648ed35 chore: update lockfile v1.4.13 2024-07-04 15:34:09 +08:00
roymondchen
602da25b6d chore: release v1.4.13 2024-07-04 15:32:33 +08:00
roymondchen
eb376b261b fix(editor): 修复新增第一个显示条件时会重置表单状态 2024-07-04 15:27:27 +08:00
roymondchen
1e93e9bacc fix(data-source): 按需加载数据源时需要分享数据源方法依赖 2024-07-04 14:41:34 +08:00
roymondchen
5d6de7c405 chore: update lockfile v1.4.12 2024-07-02 21:13:56 +08:00
roymondchen
033ef19d6b chore: release v1.4.12 2024-07-02 21:12:16 +08:00
roymondchen
aabca93c27 fix(editor): 更新容器后,需要将容器内的依赖重新收集 2024-07-02 21:09:18 +08:00
roymondchen
c8870c5c12 fix(dep): 数据源源方法依赖收集,数据源类内定义的方法需要被收集 2024-07-02 21:02:26 +08:00
roymondchen
58a34b0ad6 chore: update lockfile v1.4.11 2024-07-02 16:24:07 +08:00
roymondchen
9989b97fe9 chore: release v1.4.11 2024-07-02 16:22:30 +08:00
roymondchen
6cdeaa0c1b feat(editor): 方法参数支持选择数据源字段 2024-07-02 16:16:15 +08:00
roymondchen
ecfaff2e0d feat(data-source): 迭代器容器内容支持显示条件配置 2024-07-02 16:14:33 +08:00
roymondchen
ef04fd31f0 feat(editor): 优化数据源字段选择器交互 2024-07-02 13:02:21 +08:00
roymondchen
882d222800 feat(data-source): 迭代器容器内容支持显示条件配置 2024-07-01 21:31:55 +08:00
roymondchen
022c10f2df fix(editor): 迭代器容器子项条件配置中值输入类型 2024-07-01 19:33:22 +08:00
洩氏诹诹子
c089adae9e fix(form): 修复 grouplist 添加项时没有调用 changeHandler 的问题 2024-07-01 16:55:25 +08:00
roymondchen
dd243c6c5e chore: update lockfile v1.4.10 2024-06-28 19:27:12 +08:00
roymondchen
f112abf246 chore: release v1.4.10 2024-06-28 19:25:36 +08:00
roymondchen
079679997a fix(stage): 标尺销毁后没有移除对应的dom
fix #617
2024-06-28 19:12:36 +08:00
roymondchen
a164e2be62 feat(dats-source,editor,form,schema,ui): 迭代器容器支持配置子项显示条件 2024-06-28 17:44:04 +08:00
parisma
0c5485b1d0 feat(editor): 支持拖拽调整页面顺序 2024-06-28 08:54:00 +00:00
roymondchen
0ffc223459 feat(editor): 优化数据源字段选择器交互 2024-06-27 19:55:06 +08:00
roymondchen
77f13fa898 fix(form,design): 支持行内表单 2024-06-24 14:20:47 +08:00
roymondchen
654961b349 refactor(util): 完善datetimeFormatter方法ts定义 2024-06-21 16:26:23 +08:00
roymondchen
c63c807232 chore: update lockfile v1.4.9 2024-06-17 16:43:47 +08:00
roymondchen
c2f25c8c7f chore: release v1.4.9 2024-06-17 16:42:05 +08:00
roymondchen
3f974a27b2 chore(ui,playgournd,runtime): 更新版本 2024-06-17 16:38:52 +08:00
roymondchen
e4a06bd12d build: package.json 中files增加src,移除sideEffects 2024-06-17 16:24:06 +08:00
roymondchen
80e42cc997 chore: release v1.4.8 2024-06-17 15:27:15 +08:00
roymondchen
f4c2cdce2b chore: 更新依赖 2024-06-17 15:06:16 +08:00
roymondchen
a66ef3273a build: 发布后更新pnpm lockfile 2024-06-17 14:35:49 +08:00
roymondchen
5c43fbfd96 fix(data-source): 多页面时数据源依赖中可能包含其他页面的,导致更新时失败 2024-06-13 20:53:45 +08:00
roymondchen
948c194a60 feat(ui,runtime): vue-runtime-help中添加use-app方法 2024-06-13 20:44:58 +08:00
roymondchen
7ee7f53938 fix(data-source): 兼容Promise.allSettled 2024-06-13 17:03:48 +08:00
roymondchen
5873842260 style(runtime): 完善ts定义 2024-06-12 15:00:52 +08:00
roymondchen
9eb99ed176 feat(editor): 组件表单配置支持函数 2024-06-12 14:54:15 +08:00
roymondchen
a30e8a3eea feat(editor): 支持数据源模板输入宽选中文本后编辑(在有数据源变量时还有问题) 2024-06-11 20:28:12 +08:00
roymondchen
094635cc0e fix(ui): overlay销毁需要异常page上的事件 2024-06-11 19:31:34 +08:00
roymondchen
5ac768f15b feat(editor): 组件树中支持多选拖动 2024-06-11 19:28:40 +08:00
roymondchen
83b14767b3 style(editor): 属性配置中的源码编辑器添加class,防止样式污染 2024-06-11 13:57:08 +08:00
roymondchen
653cafbe81 chore(runtime): 使用DeepObservedData做完数据源事件模型 2024-06-06 17:42:27 +08:00
roymondchen
ac7bb93a37 fix(data-source): 默认事件处理支持path为空字符串 2024-06-06 17:40:13 +08:00
roymondchen
e1f8392261 chore: 更新依赖 2024-06-05 19:44:39 +08:00
roymondchen
0cd83825b7 fix(runtime): 使用vue-demi cdn 2024-05-31 20:02:53 +08:00
roymondchen
b198417ad1 chore: 补充package.json files字段 2024-05-31 17:45:09 +08:00
roymondchen
78e9a0ab15 fix(editor,runtime): 编辑器中,依赖收集改成异步以后,可能出现配置更新了,但是依赖信息还未更新,导致渲染出来的组件不对 2024-05-31 17:26:37 +08:00
roymondchen
aa25aa6d85 fix(vue-runtime-help): inject app 无效 2024-05-31 17:02:19 +08:00
roymondchen
3b87589d01 chore: update lock v1.4.7 2024-05-31 15:17:36 +08:00
roymondchen
697442ba63 chore: release v1.4.7 2024-05-31 15:14:06 +08:00
roymondchen
4670adadc0 Revert "build: 发布时在更版本号后执行reinstall来生成新lock"
This reverts commit 7dad24737454c99c6f164a6e7699f1e560d7155b.
2024-05-31 15:11:26 +08:00
roymondchen
9448d94e99 docs: editor props sidebar 例子中少了] 2024-05-31 14:49:29 +08:00
roymondchen
94db430b85 fix(ui,runtime): 迭代器容器迭代数据兼容
re #613
2024-05-31 14:45:21 +08:00
roymondchen
7fb4d96cb0 fix(editor): 已选组件树中如果出现items不是数组会导致节点渲染失败 2024-05-30 17:23:41 +08:00
roymondchen
7dad247374 build: 发布时在更版本号后执行reinstall来生成新lock 2024-05-30 17:22:05 +08:00
roymondchen
2d133f47f1 feat(core,editor,form): 页面片容器支持配置容器内组件的事件 2024-05-30 17:14:50 +08:00
parisma
cd191f6815 feat(editor): 复制组件时收集依赖性能优化改造 2024-05-30 07:44:27 +00:00
roymondchen
50d238a48c feat(playground): 设置配置表单的label-width 2024-05-30 11:29:02 +08:00
roymondchen
49e9d5b985 fix(playground): tmagic-form样式丢失
fix #610
2024-05-29 20:10:32 +08:00
Evan Wu
d98029d5e7
fix(editor): 修复pad大屏模式下粘贴位置计算错误偏移问题 (#612)
* fix: 修复moveable中custom able旋转中心错误问题

* fix: 修复修复pad大屏模式下粘贴位置偏差问题
2024-05-29 20:01:51 +08:00
roymondchen
a66da8de9e fix(editor): 数据源模板输入框输入数字索引后浏览器卡死
fix #611
2024-05-29 19:57:14 +08:00
roymondchen
ee269917f8 feat(dep,editor,data-source,schema): 优化编辑器中依赖收集性能 2024-05-29 19:32:16 +08:00
roymondchen
cc8ec39dad chore: release v1.4.6 2024-05-27 19:18:48 +08:00
roymondchen
92e9d888e9 chore: 更新typescript依赖 2024-05-27 19:14:09 +08:00
parisma
faabf1bb3a feat(editor,dep): 支持复制组件时将组件绑定的数据源一并复制 2024-05-27 10:52:07 +00:00
roymondchen
2ea876a2a0 style(utils): 完善ts定义 2024-05-27 17:22:04 +08:00
roymondchen
15e9cdc2d6 fix(runtime): vue runtime App组件中缺失inject 2024-05-24 19:57:22 +08:00
roymondchen
d5ce54f35e docs: 更新vitepress 2024-05-24 17:58:24 +08:00
roymondchen
f8dd062a50 feat(runtime): vue2/vue3公共部分提出到vue-runtime-help中 2024-05-24 17:44:01 +08:00
roymondchen
66001dae04 docs: 数据源文档
re #603
2024-05-24 15:16:30 +08:00
roymondchen
47c42222b3 fix(editor): stageOverlay不应受编辑器zoom影响 2024-05-23 19:32:00 +08:00
roymondchen
5ce099c11d feat(editor): export FloatingBox 2024-05-23 11:03:44 +08:00
roymondchen
c6ac0a0a2b chore(runtime:tmagic-form): 更新版本 2024-05-23 11:02:58 +08:00
roymondchen
20a540f0fc chore(runtime:tmagic-form): 更新版本 2024-05-22 19:20:56 +08:00
Li Ming
af3f621424
fix(runtime:react): update page时出错 2024-05-22 19:17:29 +08:00
roymondchen
58466dbb0a chore: 更新package 2024-05-22 17:34:15 +08:00
roymondchen
fbac2f820e chore: release v1.4.5 2024-05-20 14:24:27 +08:00
roymondchen
22eb7453be build: release git commit 2024-05-20 14:19:13 +08:00
roymondchen
238762dd0f style(core,schema): 完善dsl定义 2024-05-15 20:25:35 +08:00
roymondchen
7a13cd851b refactor(ui): 完善props定义,优化冗余代码 2024-05-15 20:23:51 +08:00
roymondchen
901fe4dd94 chore: 完善依赖 2024-05-14 14:25:47 +08:00
roymondchen
5074c9e68b refactor(core): 完善事件逻辑 2024-05-14 14:05:01 +08:00
qwertyyb
88c04c6dac
feat: 支持数据源事件 (#605)
* feat: 添加observedData

* feat: 修改错误

* fix: 修复单测报错问题

* feat: 完善数据源事件

* fix: 修复数据源事件调用组件方法时报错的异常

* fix: 修复多个相同类型的数据源数据变化的事件混淆的问题

* chore: 删除无用代码

* feat: 默认使用SimpleObservedData

* feat: 删除无用代码

---------

Co-authored-by: marchyang <marchyang@tencent.com>
2024-05-13 17:23:23 +08:00
roymondchen
831204663a test: 完善测试用例 2024-05-09 20:49:54 +08:00
roymondchen
ff60d0238b chore: 更新依赖 2024-05-09 19:58:48 +08:00
roymondchen
c665bf3ccc fix(core,data-source): 事件参数中关联数据源字段无法自动更新 2024-05-09 17:01:34 +08:00
roymondchen
708d3db4bb feat(data-source): manager init 事件增加error数据 2024-05-08 19:26:53 +08:00
roymondchen
9034cef0d2 fix(form): select option label不生效 2024-05-08 14:44:04 +08:00
roymondchen
0f2bd3f01d build: editor version写错
fix #601
2024-05-08 11:46:31 +08:00
roymondchen
6b081fdc53 chore: 包内依赖改成workspace:*,更新release脚本 2024-04-26 17:15:28 +08:00
Evan Wu
e39a7d140f
fix(editor,stage,utils): 修复在ipad等大屏场景下编辑画布中元素位置计算偏差问题 (#598) 2024-04-25 20:13:21 +08:00
roymondchen
71c90d1d4d chore(element-plus-adapter): 移除vue依赖 2024-04-25 19:42:39 +08:00
roymondchen
ad2146f3bd fix(form): select option 在没有adapter的时候默认使用el-option 2024-04-25 19:38:43 +08:00
roymondchen
9174e775ae chore: 更新github action node 版本 2024-04-23 15:50:28 +08:00
roymondchen
7a9e5ca6f6 build: pre-commit检查改成检查ts类型 2024-04-23 15:24:25 +08:00
roymondchen
883e5d60fa build: 按依赖顺序构建 2024-04-23 15:09:29 +08:00
roymondchen
f467c88b10 chore: 更新packageManager 2024-04-22 20:01:56 +08:00
roymondchen
013365388d style(editor): 调整数据源字段选择器样式 2024-04-16 20:38:34 +08:00
roymondchen
03be7bcbd3 chore: release v1.4.4 2024-04-16 17:05:21 +08:00
roymondchen
69c555f567 fix(runtime): 更新page后,在编辑器中无法打开蒙层
由于更新page后,会去判断app.page.data对象是否为dsl中page的配置,如果不是会销毁page,重新new,就导致overlay中page的监听失效

fix #587
2024-04-16 16:28:22 +08:00
roymondchen
fc1a7a09ff feat(editor): 优化数据源选择器与代码选择的编辑按钮 2024-04-16 11:52:11 +08:00
roymondchen
4054c6ed57 feat(editor): 支持配置左侧边栏tab style 2024-04-12 20:20:40 +08:00
roymondchen
b1e79c1e05 fix(editor): 在组件属性配置表单中编辑数据源方法无法保存问题 2024-04-12 20:11:34 +08:00
roymondchen
92049cf251 feat(editor): 新增配置控制属性配置面板右下角的源码按钮是否显示 2024-04-12 19:31:09 +08:00
roymondchen
006133102f feat(cli,data-source,runtime): 数据源支持动态按需加载 2024-04-12 16:52:58 +08:00
roymondchen
872c978b9b fix(editor): floating-box高度无法改变 2024-04-11 17:23:31 +08:00
roymondchen
3af247febb fix(playground): 画布尺寸切换无效
由于element-plus2.6后radio-button label属性改成value

fix #586
2024-04-08 14:25:33 +08:00
roymondchen
f35fca0eeb chore: release v1.4.3 2024-03-29 14:20:35 +08:00
roymondchen
05527a41a1 fix(editor): 数据源字段选择器初始化状态 2024-03-29 14:17:58 +08:00
roymondchen
0e0f50187e fix(data-source,dep,utils): 迭代器数据源配置编译 2024-03-29 12:20:30 +08:00
roymondchen
47b19ae7fa feat(playground): 缓存上次保存dsl 2024-03-28 21:02:15 +08:00
roymondchen
edfe5c6973 chore: release v1.4.2 2024-03-26 17:21:59 +08:00
roymondchen
ceff0d4147 fix(editor): element-plus更新到2.6后表单项清除后是undefined,改回是空字符串 2024-03-26 17:15:42 +08:00
roymondchen
934398911d feat(data-srouce): manager新增init事件 2024-03-26 17:02:14 +08:00
roymondchen
66e16452a8 feat(editor): 数据源字段选择器增加编辑按钮 2024-03-26 16:12:01 +08:00
roymondchen
f92127e3d6 fix(editor): 代码块配置表单项大小不受配置控制 2024-03-26 15:28:06 +08:00
roymondchen
7049b1ff45 fix(editor): 初始化时如果浏览器切到后台编辑器列宽度计算出问题 2024-03-26 15:20:41 +08:00
roymondchen
15b88c97fc fix(form): select 支持tdesign-vue-next
fix #584
2024-03-25 20:17:00 +08:00
roymondchen
3f06ca3623 build(data-source): umd构建版本将lodash打包进去 2024-03-25 19:14:41 +08:00
roymondchen
a4fc95775e fix(editor): element-plus更新到2.6后表单项清除后是undefined,除了string外其他统一改成null 2024-03-25 14:52:11 +08:00
roymondchen
03fe553344 chore: release v1.4.1 2024-03-22 13:31:58 +08:00
roymondchen
6ccd8bb06b fix(design): element-plus select中scrollbar变量名改变 2024-03-22 13:27:09 +08:00
Yang Gao
b564907b12
fix(editor): 数据源列表搜索过滤无响应问题 (#582) 2024-03-21 19:30:29 +08:00
roymondchen
f999b60a79 chore: 完善代码 2024-03-20 14:26:05 +08:00
roymondchen
1dcdab8f92 chore(tmagic-form-runtime): 更新版本 2024-03-19 19:27:29 +08:00
roymondchen
da2da0827d chore: release v1.4.0 2024-03-19 19:22:40 +08:00
roymondchen
b3cf919273 chore(editor): 解决warning 2024-03-19 19:18:03 +08:00
moonszhang
96149bd2ae feat(editor): 数据源抽屉切floatbox 2024-03-19 11:07:43 +00:00
roymondchen
e2326ff4f6 chore: README新增贡献者 2024-03-19 17:29:12 +08:00
roymondchen
92b7a2aecf feat: 完善tdesign-vue-next适配 2024-03-19 17:26:08 +08:00
Evan Wu
0c746aa3d9
feat(runtime, utils): Fix issue #503, setPage实现跳转页面 (#581)
* fix: 修复moveable中custom able旋转中心错误问题

* feat(runtime): fix issue #503, 增加page-change回调

* feat(core, runtime): 增加页面不存在时调用报错

* fix(runtime, core, utils): 提取addParamsToUrl公共方法且更改'page-change'逻辑

* fix(utils): 优化addParamToUrl方法
2024-03-19 16:18:14 +08:00
roymondchen
9d405428be chore(tmagic-form-runtime): 更新版本 2024-03-18 19:47:03 +08:00
roymondchen
24d029574f style(table): 完善ts定义 2024-03-18 19:15:24 +08:00
roymondchen
d5354c11d6 chore(tmagic-form-runtime): 更新依赖 2024-03-18 17:41:06 +08:00
roymondchen
2e11d7cf42 chore: release v1.4.0-beta.2 2024-03-18 17:32:30 +08:00
roymondchen
fff56a97f7 feat(stage,editor): 选中的元素不存在时不报错,并完善事件ts定义
fix #579
2024-03-18 17:25:40 +08:00
roymondchen
42f1f28b02 fix(editor): 拖动浮动窗口会导致窗口变大 2024-03-15 17:14:56 +08:00
roymondchen
de1711d713 feat(editor): 属性面板支持切换源码 2024-03-15 16:44:58 +08:00
roymondchen
c83e76e641 feat(editor): 优化代码块编辑弹窗 2024-03-15 15:24:16 +08:00
roymondchen
36a1a18615 fix(editor): 修复第一次打开编辑器左右边栏宽度可能为0问题 2024-03-15 15:22:30 +08:00
roymondchen
62e7888fcf fix(editor): 修复直接关闭代码块编辑窗口告警 2024-03-13 19:59:45 +08:00
roymondchen
f881b9ea3b chore: 修复报错 2024-03-13 19:57:35 +08:00
roymondchen
38145ff461 style(table): 完善ts定义 2024-03-13 19:55:45 +08:00
roymondchen
523545ec7e chore: release v1.4.0-beta.1 2024-03-13 16:45:20 +08:00
roymondchen
d9b95563b5 chore: 发布时条件git加上no-verify 2024-03-13 16:40:52 +08:00
roymondchen
8c9018407a chore(tmagic-form-runtime): 销毁app 2024-03-13 16:34:40 +08:00
roymondchen
52f09f9f22 style(tmagic-form-runtime): 完善ts定义 2024-03-13 16:25:11 +08:00
roymondchen
ca2c6af060 chore: 更新依赖 2024-03-13 16:17:00 +08:00
moonszhang
7ce60b223e feat(editor): 增加FloatBox的beforeClose函数 2024-03-13 06:00:22 +00:00
moonszhang
cae928f7f9 fix(editor): 修复点击floatbox时更新zindex导致宽高被重置的问题 2024-03-13 06:00:22 +00:00
moonszhang
5fc649607a fix(editor): 修复高级中打开代码块没有floatbox嵌套的问题,floatbox支持beforeClose事件 2024-03-13 06:00:22 +00:00
roymondchen
4f31eed71a style(editor): use-plugin ts定义完善 2024-03-12 14:08:37 +08:00
roymondchen
d71e6b1933 style(editor): float-box限制最大宽高 2024-03-11 20:36:21 +08:00
moonszhang
a035f02f83 feat(editor): 使用 floatbox 替换原抽屉栏 2024-03-11 12:25:19 +00:00
roymondchen
260286f9cf refactor(ui,playground): 优化编码 2024-03-11 20:22:53 +08:00
roymondchen
c68d4e05de feat(data-source,runtime): 数据源编译组件时新增一个参数控制是否要编辑子元素
编译时只需要关注组件本身的配置,子组件有自己的依赖,不需要由父组件来控制,但是在编辑器中就需要,因为为了不改动到编辑器中的dsl,编译后的配置是不会保存起来的,所以容器编译时需要把子组件也一同编译
2024-03-11 20:21:10 +08:00
roymondchen
a3b41caf06 chore: 删除babel配置 2024-03-11 16:29:25 +08:00
roymondchen
cda6c0f791 feat(editor): 样式配置支持配置数据源字段 2024-03-08 20:04:48 +08:00
roymondchen
900acb6eb0 chore(tmagic-form-runtime): 更新依赖 2024-03-08 11:24:06 +08:00
Evan Wu
842fa221aa
fix(stage): 修复moveable中custom able旋转中心错误问题 (#575) 2024-03-08 11:23:40 +08:00
roymondchen
e692e01c4f feat: 支持迭代器容器 2024-03-07 16:56:05 +08:00
roymondchen
6dbac52c50 feat(design,form): cascader新增popper-class prop 2024-03-07 15:18:04 +08:00
Steven Qiang
94a6004608
fix(design): Autocomplete default slot 名称拼写错误
Co-authored-by: Steven <admin@qiangmou.ren>
2024-03-07 15:17:36 +08:00
roymondchen
032f7c03e0 style(dep,editor,schema,stage): 完善注释与ts定义 2024-03-05 19:04:36 +08:00
roymondchen
e272370fea feat(form): label 标签的title属性配置 2024-03-05 15:30:29 +08:00
roymondchen
8e18336fa3 fix(editor): 设置配置时使用的key统一转换成kebab-cased形式
fix #576
2024-03-05 15:07:27 +08:00
roymondchen
16e45cb45d style(editor): 完善service use-plugin的ts类型定义 2024-03-05 14:55:41 +08:00
roymondchen
5cf137e5e8 fix(stage): 多选后拖动没有响应 2024-03-05 14:51:01 +08:00
roymondchen
0315389ce9 feat(editor): props-service支持通过fill-config设置label-width 2024-03-04 14:18:21 +08:00
roymondchen
0e314ef5ad chore: release v1.3.16 2024-03-01 16:36:32 +08:00
roymondchen
ffc3e57aa1 fix(design,editor,tdesign-vue-next-adapter): tMagicPopover在TDesign下异常
fix #574
2024-03-01 16:30:40 +08:00
roymondchen
1b3c598a66 fix(tmagic-form-runtime): useRuntime添加默认参数 2024-03-01 15:19:28 +08:00
roymondchen
6821ce5fbf feat(editor): 新增data-source-panel-search slot 2024-03-01 15:13:33 +08:00
roymondchen
a073b8c50d feat(editor): 新增code-block-panel-search slot 2024-03-01 13:56:53 +08:00
roymondchen
c65470186c chore: release v1.3.15 2024-02-29 17:21:45 +08:00
roymondchen
0df98bc226 fix(runtime): 数据源变化更新页面出错 2024-02-29 16:54:49 +08:00
roymondchen
58b62d18e4 feat(editor): 代码选择器,数据源方法选择新增不可编辑配置,与disabled区分开 2024-02-29 16:47:18 +08:00
roymondchen
d59f5abdf5 chore: release v1.3.14 2024-02-29 14:52:26 +08:00
roymondchen
aec37c35cc build: 发布时不更新tmagic-form runtime的版本号 2024-02-29 14:50:30 +08:00
roymondchen
a1e09c3b54 chore(playground): 更新tmagic-from-runtime版本 2024-02-29 14:09:14 +08:00
roymondchen
3fe83f9fa4 fix(editor): 从页面切换成页面片时不会默认选中第一个页面片 2024-02-28 16:38:32 +08:00
roymondchen
b4df7f5eea fix(editor): 复制页面后,组件树选中状态不对 2024-02-28 16:08:32 +08:00
roymondchen
fcede5c0ac feat(editor): menu配置支持事件 2024-02-28 15:18:36 +08:00
roymondchen
33fcee66df fix(utils): 数据源条件解析空字符出错 2024-02-28 15:09:14 +08:00
roymondchen
455c696ff0 fix(data-source, ui): 页面配置配置数据源字段模块出错 2024-02-28 14:56:45 +08:00
roymondchen
06ff39b800 build: npm发布时更新tmagic-form runtime依赖 2024-02-28 14:38:22 +08:00
roymondchen
074d76456b feat(editor,core,schema): 组件高级配置支持配置数据源方法 2024-02-28 14:33:57 +08:00
moonszhang
0d471a96ed style(editor): 修改floatbox 样式问题 2024-02-27 07:35:40 +00:00
moonszhang
cda5413fd1 refactor(editor): floatbox 使用公共组件 2024-02-27 03:01:38 +00:00
roymondchen
8d1ba220c1 fix(tmagic-form-runtime): 完善form-runtime 2024-01-31 17:09:04 +08:00
roymondchen
7db8d8f45f docs: 启动runtime命令出错 2024-01-23 15:29:32 +08:00
roymondchen
fbb5b3c947 chore: release v1.3.13 2024-01-19 16:31:46 +08:00
roymondchen
2432bc5a69 fix(editor): stage-overlay状态更新 2024-01-19 11:29:11 +08:00
roymondchen
01f8040a1a fix(stage): scrollIntoView不能有横向滚动 2024-01-18 19:47:50 +08:00
roymondchen
9e263f9e23 chore(cli): 修改注释 2024-01-18 19:27:07 +08:00
roymondchen
2114b89365 fix(editor): 弹层画布响应组件树点击 2024-01-18 14:22:31 +08:00
roymondchen
2d5bd2ddb4 chore: release v1.3.12 2024-01-18 11:47:54 +08:00
roymondchen
c30e7d340b feat(editor,stage): 完善双击画布可以已弹层方向显示并显示完整的组件 2024-01-18 11:40:00 +08:00
roymondchen
3613237350 docs(editor): 完善editor props的注释 2024-01-18 11:40:00 +08:00
leon Li
edc7c11929
fix(editor): 移动元素到容器中的时候root没有更新问题 (#569)
* fix(editor/stage): 拖动组件进画布后,父容器位置计算有误

* fix(editorService): 移动元素时候root没有更新问题

---------

Co-authored-by: fanliming <fanlm@novastar.tech>
2024-01-18 11:39:37 +08:00
roymondchen
30929e8bd3 chore: release v1.3.11 2024-01-12 16:43:16 +08:00
roymondchen
2679969cb6 build: 不生成sourcemap 2024-01-12 16:40:24 +08:00
roymondchen
e4af8cadb0 feat(editor,stage): 双击画布可以已弹层方向显示并显示完整的组件 2024-01-12 16:36:59 +08:00
roymondchen
22e8ae47f1 Merge branch 'master' of https://github.com/Tencent/tmagic-editor 2024-01-10 16:41:54 +08:00
leon Li
115123a0bc
fix(editor): 拖动组件进画布后,父容器位置计算有误 (#565)
Co-authored-by: fanliming <fanlm@novastar.tech>
2024-01-10 16:39:15 +08:00
roymondchen
6f7415e116 refactor(form): button text prop 改成 link element-plus将废弃text 2024-01-10 16:34:46 +08:00
roymondchen
b4bf5ddc0a chore: release v1.3.10 2024-01-10 16:07:19 +08:00
roymondchen
84cbc745c7 fix(runtime): 更新Vue3 cdn链接 2024-01-09 15:18:31 +08:00
roymondchen
f8443ed316 feat: 新增tmagic-form-runtime 2024-01-09 14:58:13 +08:00
roymondchen
a10ae0ddd1 refactor(form): 优化代码 2024-01-09 14:50:25 +08:00
roymondchen
5c54f50365 refactor: button text prop 改成 link element-plus将废弃text 2024-01-08 17:49:41 +08:00
roymondchen
aa601f8703 fix(form): table全屏后zindex问题 2024-01-08 16:47:21 +08:00
roymondchen
81e3d0a18e feat(design,element-plus-adapter): 新增获取浮层zIndex的方法 2024-01-08 16:42:45 +08:00
roymondchen
eeb4566a69 style(form): table设置width 100% 2024-01-05 17:07:59 +08:00
marchyang
511acfdb5b Merge branch 'master' of git.woa.com:vft-magic/tmagic-editor 2024-01-05 14:39:11 +08:00
marchyang
ab5e31dfea feat: 输入文本含有空格时,弹窗提示 2024-01-05 14:35:42 +08:00
roymondchen
acab44aaa4 fix(utils): <=条件编译出错 2024-01-04 17:00:58 +08:00
roymondchen
5a5288c9da build(util): umd版本将lodash-es打进去 2024-01-03 16:32:44 +08:00
roymondchen
3c167f3b54 chore: release v1.3.9 2024-01-03 14:49:19 +08:00
roymondchen
783f7c3fc1 fix(stage): 组件添加粗一点的边框后resize操作 选中样式没有和组件本身对齐
fix #562
2024-01-03 14:45:25 +08:00
roymondchen
310c1c21ce chore(form): table新增一个根节点 2024-01-02 20:59:09 +08:00
roymondchen
d3777b236d feat(data-source,utils,runtime): 数据源setData支持指定路径 2024-01-02 20:57:37 +08:00
marchyang
6b4bfae30b feat: 代码编辑器支持emmet插件 --story=115432867 2023-12-28 07:23:03 +00:00
roymondchen
23269625e1 fix(editor): 上下移一层溢出
fix #563
2023-12-27 19:57:33 +08:00
roymondchen
320420478c fix(stage): 有margin的组件拖动大小时top偏移
re #559
2023-12-22 14:31:53 +08:00
roymondchen
1073204858 chore: release v1.3.8 2023-12-21 19:49:08 +08:00
roymondchen
fbe1d88d27 feat(editor,form): 新增属性配置表单error事件
re #557
2023-12-21 16:30:31 +08:00
parisma
d981014160 feat(editor,dep): watcher新增方法:清除指定类型的依赖 2023-12-21 07:38:58 +00:00
parisma
2dc810a9fd feat(editor,ui): 页面片下拉选择框支持点击跳转编辑,修改页面片组件initvalue 2023-12-21 07:38:58 +00:00
moonszhang
2dcef449bf feat(form): table 增加 beforeAddRow 钩子函数校验是否可增加行 2023-12-20 07:44:16 +00:00
roymondchen
7c90b9339d feat(editor): 新增page-bar slot 2023-12-20 15:08:24 +08:00
roymondchen
f9cf6fa500 style(editor): tree empty 样式调整 2023-12-20 15:05:20 +08:00
roymondchen
bd8bbc6154 feat(editor): data-source-service支持扩展 2023-12-20 14:59:58 +08:00
roymondchen
e385ed5d34 chore: release v1.3.7 2023-12-19 14:55:18 +08:00
roymondchen
41a3b8c7c7 feat(editor): 右键菜单兼容页面片 2023-12-19 14:50:54 +08:00
roymondchen
7b6dcedfad feat(core,editor,ui): 新增页面片 2023-12-19 06:39:03 +00:00
roymondchen
698c3451ff feat(editor): 新增自定义右键菜单函数配置 2023-12-18 20:37:10 +08:00
roymondchen
4ec0b69a8d fix(form): table全屏后蒙层在最上一层 2023-12-18 20:18:46 +08:00
roymondchen
86bdb9f099 feat(data-source): 支持在指定js环境下不执行init的配置 2023-12-18 17:27:37 +08:00
roymondchen
2a5b9ec6bd feat(editor, stage): 新增禁用多选的props 2023-12-18 15:00:26 +08:00
roymondchen
09fe6d29e2 chore(editor): 修改拼写错误 2023-12-18 14:17:04 +08:00
roymondchen
538f96c082 feat(playground): 完善form editor 2023-12-15 20:05:29 +08:00
roymondchen
b72e487b58 chore: 使用on-before-unmount替换on-unmouted 2023-12-15 16:20:50 +08:00
roymondchen
f212be136e feat(editor,stage): 新增标尺配置props
re #558
2023-12-15 14:32:32 +08:00
roymondchen
7305f878f3 feat(editor, stage): 初始化加载runtime loading 2023-12-15 14:09:44 +08:00
roymondchen
978391fe90 chore: 修改发布脚本,使用pnpm发布 2023-12-12 19:54:49 +08:00
roymondchen
04a72da06c Revert "chore: 去掉pnpm的限制"
This reverts commit 25a0604073b55bbf72dee32d739d70e307c614f0.
2023-12-12 19:31:19 +08:00
roymondchen
a2ee21faba chore: release v1.3.6 2023-12-12 16:10:17 +08:00
roymondchen
25a0604073 chore: 去掉pnpm的限制 2023-12-12 16:08:10 +08:00
roymondchen
268ec4c27a feat(editor): 修改code-block-list code-block-panel-tool slot data 2023-12-12 15:46:08 +08:00
roymondchen
cf72039ff1 feat(playground): 新增表单编辑器 2023-12-12 15:17:28 +08:00
roymondchen
ba2f1e5ac5 feat(stage, editor): runtime支持直接渲染模式不用iframe 2023-12-12 15:09:33 +08:00
moonszhang
0c994f1e23 fix(table): 修复element table tooltip position 默认使用 fixed 定位导致气泡偏移的问题 2023-12-12 11:02:38 +08:00
roymondchen
a9d794dc19 feat(editor): propsService.setNewItemId新增force参数 2023-12-11 20:19:17 +08:00
parisma
456692ff8a fix(editor): 有复制的内容时展示粘贴菜单 2023-12-11 11:57:46 +00:00
roymondchen
fc89d4cbe8 chore: 更新vite@5.0.7 2023-12-11 11:29:06 +08:00
roymondchen
25a8456312 chore: 更新element-plus版本 2023-12-08 19:54:29 +08:00
roymondchen
fe26ac5ffc fix(editor): 新增数据源方法不会收集依赖 2023-12-08 19:49:09 +08:00
roymondchen
cc202d79f9 fix(form): cascader options不会自动更新 2023-12-08 19:48:10 +08:00
roymondchen
70f2b11df5 fix(dep): get-tagert需要指定type 2023-12-08 19:47:12 +08:00
roymondchen
e50e332818 feat(editor): 可选组件按钮只有在可选组件长度大于3时才显示 2023-12-08 17:27:19 +08:00
roymondchen
741140fa71 refactor(editor): 代码编辑、数据源重构 2023-12-08 17:20:43 +08:00
roymondchen
258d2bc2ea feat(editor,stage): 优化可选组件交互 2023-12-07 19:40:40 +08:00
roymondchen
5c6a3455b0 feat(editor): service扩展支持设置成同步的 2023-12-06 15:28:18 +08:00
roymondchen
75dd89f2fe fix(data-source,utils): 显示条件编译对于undefined理解不正确 2023-12-04 20:35:03 +08:00
roymondchen
4870babc43 chore: release v1.3.5 2023-12-01 15:30:58 +08:00
roymondchen
78762b920e fix(data-source): 数据源初始化 2023-12-01 15:26:36 +08:00
roymondchen
7f9c4f3855 chore: release v1.3.4 2023-11-28 19:47:15 +08:00
roymondchen
6299d286ba feat(editor): 数据源数据定义快速添加支持与已有数据合并 2023-11-28 19:32:12 +08:00
roymondchen
141e1c7130 feat(editor): http数据源请求体配置支持写json 2023-11-28 17:12:12 +08:00
roymondchen
f8125aa149 feat(stage): 支持配置对齐元素 2023-11-28 16:19:00 +08:00
roymondchen
eb43deb9f5 feat(editor): 画布大小支持配置百分比 2023-11-27 16:55:23 +08:00
roymondchen
b0fcafd089 fix(editor): 从组件树中拖入画布新增的情况如果初始position为fixed不改变布局 2023-11-23 15:47:09 +08:00
roymondchen
33c8f8bf5a fix(util): 条件编译对应is与not实现对应value为false的情况出错 2023-11-23 14:51:52 +08:00
roymondchen
4bbde1a5f6 chore: 去掉调试log 2023-11-23 14:49:52 +08:00
roymondchen
c9aab11e03 fix(editor): 修改根节点不添加历史记录 2023-11-22 15:46:00 +08:00
roymondchen
19d24f4089 chore: release v1.3.3 2023-11-21 20:40:30 +08:00
roymondchen
8765cf10f6 style(schema): 完善request-function定义 2023-11-21 19:30:45 +08:00
roymondchen
f305f0a93e style(editor): DepTargetType是枚举类型,不能用type修饰 2023-11-21 19:29:45 +08:00
roymondchen
5547eb4ee8 fix(dep): 数据源依赖收集 2023-11-21 19:17:53 +08:00
roymondchen
5549e8cff9 feat(data-sources): http数据裁剪函数content参数添加options 2023-11-21 19:14:45 +08:00
roymondchen
979d6e2e31 chore: release v1.3.2 2023-11-21 14:13:26 +08:00
roymondchen
e35a963b67 fix(editor): 更新dsl,组件树列表不更新
fix #554
2023-11-21 14:05:43 +08:00
roymondchen
ad008b66b4 style(form): 完善filterFunction类型定义 2023-11-21 11:37:38 +08:00
roymondchen
ab02c2f3ee feat(editor): dataSourceService.add返回添加的数据源 2023-11-21 11:35:53 +08:00
roymondchen
eea8032f0d fix(dep): 数据源依赖收集不收集单独的id,因为id不需要编译 2023-11-21 11:34:33 +08:00
roymondchen
cdba8aeaf2 feat(editor): 数据源选择器支持选择数据源id 2023-11-21 11:32:59 +08:00
moonszhang
c80ea829ac fix(editor): 修复slide 全部拖出来再关闭回去时不展示slide操作栏的问题 2023-11-17 03:05:35 +00:00
roymondchen
fded26251f fix(editor): 不允许容器节点拖动到自己里面
fix #553
2023-11-16 20:01:23 +08:00
roymondchen
2e6d8afb93 feat(data-source): 新增指定数据源的字符串模板编译 2023-11-16 19:54:21 +08:00
roymondchen
94641bad76 refactor: 依赖收集相关代码抽出独立成库 2023-11-16 19:34:50 +08:00
moonszhang
2b10e7eda9 feat(editor): 支持 slide 侧边栏可拖拽悬浮 2023-11-16 11:00:05 +00:00
roymondchen
9098504e5f chore: release v1.3.1 2023-11-15 15:34:37 +08:00
roymondchen
ffd8130269 feat(data-source): 数据源支持ssr 2023-11-15 15:27:23 +08:00
roymondchen
ce0c941bf1 fix(editor): 在组件树将组件拖入不同布局的容器内,需要改变其布局
fix #552
2023-11-13 20:01:32 +08:00
roymondchen
7f6ba9de99 fix(stage): 设置margin后拖动位置出现漂移
fix #549
2023-11-13 19:43:17 +08:00
roymondchen
3b789f4d13 fix(stage): 当页面大小小于画布时,组件又处于画布边缘,moveable边框会超出画布,导致获取到画布外的元素
fix #546
2023-11-13 16:22:13 +08:00
roymondchen
436fb3f5aa feat(core): 将事件响应中的剩余事件参数传入到配置的代码块与数据源方法中
re #551
2023-11-13 14:34:10 +08:00
roymondchen
8dcff6b731 chore(editor): 删除调试信息 2023-11-08 17:35:24 +08:00
roymondchen
fb7bac8bfd chore: release v1.3.0 2023-11-06 16:36:38 +08:00
roymondchen
f0f94d4fcc fix(editor): model-value变化后需要重新生成依赖后再通知runtime更新 2023-11-06 16:33:30 +08:00
roymondchen
7a228b13e6 fix(stage): 隐藏标尺后再显示标尺,拖出来的线没有吸附作用
fix #548
2023-11-06 14:16:16 +08:00
roymondchen
168ec281aa fix(core): 设置page时查找原page兼容数字id情况
fix #547
2023-11-06 11:35:44 +08:00
roymondchen
6fda0e6e44 chore: release v1.3.0-beta.8 2023-11-03 19:34:23 +08:00
roymondchen
4e6b1fe6aa chore: release改成cjs后缀 2023-11-03 19:32:41 +08:00
roymondchen
263533f09a feat(editor): 缓存可选组件菜单置于顶层状态 2023-11-03 19:27:39 +08:00
roymondchen
1c3f8abaf4 fix(editor): 画布区域不允许宽度为0 2023-11-03 16:40:46 +08:00
roymondchen
2d5b7726ef fix(editor): 数据源列表中依赖的key会重复出现 2023-11-03 14:58:19 +08:00
roymondchen
801399777b chore: eslintrc改成cjs后缀 2023-11-03 14:52:02 +08:00
roymondchen
ae0b206c4c docs: 补充数据源相关props 2023-11-02 17:07:06 +08:00
roymondchen
5880dfbe15 chore: release v1.3.0-beta.7 2023-11-01 15:22:12 +08:00
roymondchen
480d013994 feat(editor): 新增组件树、数据源slots 2023-11-01 15:17:52 +08:00
roymondchen
5021c746fc fix(editor): 不允许拖动的节点不允许被拖入
fix #544
2023-11-01 14:13:15 +08:00
roymondchen
905f34ae24 refactor(form): lodash-es import问题 2023-11-01 14:07:37 +08:00
roymondchen
7d251f04e8 refactor(editor): 新增tree组件 2023-11-01 14:06:04 +08:00
roymondchen
8d8c8df82f chore: release v1.3.0-beta.6 2023-10-31 15:34:51 +08:00
roymondchen
f48afa98f2 feat(editor, data-source): 支持http数据源请求、响应裁剪配置 2023-10-31 15:29:04 +08:00
roymondchen
cb2ff28129 fix(editor): 数据源参数、请求头、请求体无法删除
fix #543
2023-10-31 14:28:10 +08:00
roymondchen
1876ccb377 build(playground): dev playgournd时项目启动时runtime加载失败
re #539
2023-10-31 14:14:46 +08:00
roymondchen
7d1bd60ea8 build: package.json中添加exports.types
re #541
2023-10-30 20:00:27 +08:00
roymondchen
58951caa2f docs: 联动原理文档中错别字
fix #540
2023-10-30 19:51:47 +08:00
roymondchen
8d8b30441b build(playground): dev playgournd时项目启动时runtime加载失败
plaground项目启动完后runtime项目还未启动完成,导致自动打开时runtime加载失败

fix #539
2023-10-30 19:48:45 +08:00
roymondchen
b9a7d002f1 chore: release v1.3.0-beta.5 2023-10-24 16:08:54 +08:00
roymondchen
808c82f193 fix(utils): 完善生成数据源默认值 2023-10-24 16:06:07 +08:00
roymondchen
257c8c9fa1 fix(editor): 组件树注册快捷方式 2023-10-24 15:52:01 +08:00
roymondchen
af72d819fe fix(editor): 组件树多选后右键点击不会变回单选 2023-10-24 15:41:54 +08:00
roymondchen
5e7a0a0c53 fix(editor): 粘贴容器,组件树中子组件没有显示 2023-10-24 15:35:27 +08:00
roymondchen
6a5374726e feat(editor): 组件列表支持设置tooltip显示详情 2023-10-24 14:58:37 +08:00
roymondchen
2e5b5665ce style(editor): 组件树节点名称不换行 2023-10-24 14:08:21 +08:00
roymondchen
2d5afb1646 style(editor): 事件配置样式调整 2023-10-23 20:49:04 +08:00
roymondchen
5a345575c4 refactor(editor): ui-slect事件名使用常量 2023-10-23 19:54:26 +08:00
roymondchen
6cfcbdb76e chore: release v1.3.0-beta.4 2023-10-23 16:12:22 +08:00
roymondchen
359806da96 fix(data-source): http数据源参数透传入base 2023-10-23 16:10:18 +08:00
roymondchen
bfb30923e1 chore: release v1.3.0-beta.3 2023-10-23 11:20:38 +08:00
roymondchen
bd9686dbd8 fix(form): table分页lastData初始化异常 2023-10-23 11:14:36 +08:00
roymondchen
1c516bb24b refactor(editor): 优化性能,组件树重写,不再使用el-tree 2023-10-20 19:32:11 +08:00
roymondchen
d3171f4c69 feat(editor): 搜索防抖 2023-10-20 16:56:06 +08:00
roymondchen
04025682d5 refactor(stage): node-list转成数组使用array.from 2023-10-20 16:52:42 +08:00
roymondchen
921867f650 style(form): 优化表格功能按钮显示 2023-10-18 11:20:02 +08:00
roymondchen
70b6bcd66b style(editor): 优化显示条件展示 2023-10-18 11:18:44 +08:00
roymondchen
c25be06441 fix(editor): data-source-field-select出现两个label 2023-10-18 10:59:13 +08:00
roymondchen
ed3c3d60ce feat(form): cascader支持check-strictly/emit-path配置 2023-10-17 20:22:52 +08:00
roymondchen
e4613ba053 feat(editor,data-source): 组件配置支持关联数据源字段 2023-10-17 20:21:18 +08:00
roymondchen
83ab94fcad feat(data-source,editor,schema): 数据源mock新增在编辑器中使用的配置 2023-10-17 17:05:36 +08:00
roymondchen
588ec68b21 feat(editor): 事件关联数据源方法支持预置 2023-10-07 20:10:50 +08:00
roymondchen
803bf323ce refactor(editor): editor组件改成setup 2023-10-07 17:01:33 +08:00
roymondchen
65854d9c0a test(data-source,utils): 生成默认值函数放到utils库中 2023-10-02 17:14:14 +08:00
roymondchen
9072642f22 feat(runtime): 支持数据源mock 2023-10-02 17:11:32 +08:00
roymondchen
4c46a4e575 feat(core,data-source): 数据源支持mock 2023-10-02 17:10:15 +08:00
roymondchen
56dfacbaaa feat(editor): 支持通过json快速配置数据源字段 2023-10-02 16:30:34 +08:00
roymondchen
163f630959 refactor(data-source,utils): 生成默认值函数放到utils库中 2023-10-02 16:28:53 +08:00
roymondchen
d4a8b89e6f feat(editor,schema): 支持配置数据源mock 2023-10-01 17:44:27 +08:00
roymondchen
2b2a9c6706 feat(cli): 新增datasoucreSuperClass配置 2023-10-01 12:18:15 +08:00
roymondchen
1ce6411e05 fix(editor): 右键菜单消失子菜单可能不会跟着消失 2023-09-26 15:57:00 +08:00
roymondchen
a22e59e2bd chore: playground调试启用严格访问模式 2023-09-21 14:10:29 +08:00
roymondchen
355c2f983f chore: release v1.3.0-beta.2 2023-09-21 11:06:44 +08:00
roymondchen
8b7a1e4e3c feat(editor): 数据源事件配置 2023-09-21 10:58:39 +08:00
roymondchen
36988cd3e0 fix(data-source): 组件配置与条件关联了不同数据源时,编译问题 2023-09-20 19:11:03 +08:00
roymondchen
740c2a73fa style(editor): 悬停组件菜单样式优化 2023-09-20 15:36:48 +08:00
roymondchen
5a25899b57 fix(editor,stage): 优化悬停出现组件列表的交互体验 2023-09-20 14:46:57 +08:00
roymondchen
578af946b3 chore: release v1.3.0-beta.1 2023-09-19 19:46:21 +08:00
roymondchen
5840ee537f feat(editor,util): 完善数据源配置 2023-09-19 19:43:05 +08:00
roymondchen
28b3d2e4b3 feat(data-source): timing改成串行 2023-09-19 19:41:53 +08:00
roymondchen
1c6c9ab3e8 feat(editor,stage): 新增鼠标悬停在组件上显示当前位置下所有组件菜单 2023-09-19 17:39:36 +08:00
roymondchen
e9eb47308a chore: release v1.3.0-beta.0 2023-09-15 16:21:47 +08:00
roymondchen
436914e7ee feat(editor): 新增代码块编辑时查看修改 2023-09-15 16:18:13 +08:00
roymondchen
ac303405ef feat(form,editor): 代码块编辑后关闭新增确认弹窗 2023-09-15 15:08:09 +08:00
roymondchen
a9c5004f4d feat(design): drawer增加handleClose方法 2023-09-15 15:06:55 +08:00
roymondchen
75b0d9cdf3 fix(editor): 新增数据源时,设置初始值 2023-09-14 20:33:11 +08:00
roymondchen
7a617d4a17 fix(utils): 编译条件函数异常兼容 2023-09-14 20:28:05 +08:00
roymondchen
502e59cfd7 refactor(core,data-source,schema): 将AppCore定义移到schema中 2023-09-13 16:47:34 +08:00
roymondchen
ea1cae7968 feat(editor): 已选组件新增根节点右键菜单项:全部折叠 2023-09-11 15:57:21 +08:00
roymondchen
13ff7f8d8a chore: release v1.3.0-alpha.24 2023-09-07 19:04:30 +08:00
roymondchen
3cd1ac1cc4 fix(editor): 代码变化时,参数表单需要重新渲染 2023-09-07 19:01:01 +08:00
roymondchen
7bf59929b0 feat(form): form-dialog,form-drawer新增inline,label-position配置 2023-09-06 16:59:22 +08:00
roymondchen
2bd1033665 docs: 删除失效描述 2023-09-06 16:30:04 +08:00
teeniechen
a0a2242341 feat(form): 时间容器增加每日周期显示 2023-09-06 06:45:57 +00:00
teeniechen
17ff5c38f3 Revert "feat(form): 时间容器支持设置多个时间段以及设置每日周期"
This reverts commit c94cde293181712e602f24903c755afa3dca41a2.
2023-09-05 05:05:30 +00:00
teeniechen
c94cde2931 feat(form): 时间容器支持设置多个时间段以及设置每日周期 2023-09-04 06:07:15 +00:00
roymondchen
e3bffde883 chore: release v1.3.0-alpha.23 2023-08-31 16:40:52 +08:00
roymondchen
eacb1e6475 refactor(editor): sidebar不使用tmagic-design tabs 2023-08-31 16:36:17 +08:00
roymondchen
a8eea1a73b fix(core): node销毁后重新渲染再销毁不会触发destroy事件 2023-08-31 15:47:04 +08:00
roymondchen
cda3b04b85 fix(editor): 当组件设置的bottom/right是,上下左右快捷键失效 2023-08-31 15:29:27 +08:00
teeniechen
2ccf47f7dd feat(editor): fixed布局水平居中处理 2023-08-31 06:54:21 +00:00
roymondchen
372c36893d chore: release v1.3.0-alpha.22 2023-08-29 19:02:06 +08:00
roymondchen
7b2fd6ebd4 fix(editor): datasource自动补全用鼠标操作出错 2023-08-29 18:56:02 +08:00
roymondchen
f9ba8b8df5 fix(editor): 新增数据源字段受上一次新增数据影响 2023-08-29 18:47:11 +08:00
roymondchen
cd50d36394 chore(data-source): 单独定义Core,避免循环引用 2023-08-29 18:37:15 +08:00
roymondchen
2bd86d2101 feat(editor): 新增数据源时先选类型 2023-08-29 18:24:15 +08:00
roymondchen
c5a1c2db76 feat(data-source): 数据源中新增app属性,http数据源新增钩子 2023-08-29 17:12:34 +08:00
roymondchen
0865cf4952 fix(cli): packages设置npm包初始化报错 2023-08-29 16:53:29 +08:00
roymondchen
131ec6fff3 style(data-source): 去掉any 2023-08-25 17:44:57 +08:00
roymondchen
7f48b4d9f5 chore(core,data-source): 将app传入datasourceManager 2023-08-25 17:39:37 +08:00
roymondchen
8c93d9a5be chore: release v1.3.0-alpha.21 2023-08-25 11:53:01 +08:00
roymondchen
5c9fd9a0f4 feat(table): action新增tooltip配置 2023-08-25 11:45:57 +08:00
roymondchen
54ec6de4f2 feat(editor): 组件列表中的tooltip改成title 2023-08-25 11:40:01 +08:00
roymondchen
bd6fae9aed feat(table): 新增支持配置组件 2023-08-25 11:37:34 +08:00
roymondchen
644fa4f7c0 chore: release v1.3.0-alpha.20 2023-08-24 15:24:02 +08:00
roymondchen
5319afa563 chore(editor): export getDisplayField 方法 2023-08-24 15:18:32 +08:00
roymondchen
5de5fc933a chore(stage): 优化高亮性能 2023-08-21 19:39:14 +08:00
roymondchen
0274c36afd Revert "chore(stage): 优化高亮与单选性能"
This reverts commit babaadb0cf87829197dbfa820f0141aefea48076.
2023-08-21 19:38:19 +08:00
roymondchen
573f1a2c17 feat(cli,data-source,editor,playground,runtime): 支持自定义数据源 2023-08-21 16:57:18 +08:00
roymondchen
60e14fe53e chore(data-source): 将manager中dataSourceClassMap设置为私有 2023-08-18 15:59:54 +08:00
roymondchen
3f833d41f3 fix(editor): 置顶计算错误 2023-08-15 16:21:46 +08:00
roymondchen
ec8e8a17d2 feat(editor): 历史记录最多存储20条 2023-08-15 16:15:10 +08:00
roymondchen
ccd6fd2be3 chore: 删除无用log 2023-08-15 16:13:53 +08:00
roymondchen
2b07a6de2d feat(form): date,date-time值默认的日期格式改成/,以兼容ios 2023-08-14 14:43:03 +08:00
roymondchen
07a02714df fix(editor): 数据源字符串模板提示出错
fix #530
2023-08-14 14:34:15 +08:00
roymondchen
babaadb0cf chore(stage): 优化高亮与单选性能 2023-08-11 20:23:23 +08:00
roymondchen
df236d172d chore: release v1.3.0-alpha.19 2023-08-10 17:20:17 +08:00
roymondchen
07c49bee4e feat(editor,data-source): 支持数据源方法配置执行时机 2023-08-10 16:04:12 +08:00
roymondchen
e3b2594c57 fix(stage): 拖动出现left -1 2023-08-10 15:02:17 +08:00
roymondchen
d8a2a1f805 chore(editor): 将hooks放到同一个文件夹中 2023-08-09 19:22:42 +08:00
roymondchen
a8f8f488ad fix(cli): 组件配置json key支持使用字符串常量 2023-08-09 16:09:26 +08:00
roymondchen
5927b394a7 chore: release v1.3.0-alpha.18 2023-08-09 15:37:33 +08:00
roymondchen
b1ea4cebad fix(cli): npm包会被转成相对路径 2023-08-09 15:29:58 +08:00
roymondchen
4c9ef87975 fix(stage,playground): moveableOptions对多选无效
fix #529
2023-08-08 20:58:22 +08:00
roymondchen
dacec716bc chore: release v1.3.0-alpha.17 2023-08-08 17:22:50 +08:00
roymondchen
aabc77d903 fix(form): group-list上移下移行为不对 2023-08-08 16:34:23 +08:00
roymondchen
26cd37be23 feat(form): text配置支持函数 2023-08-08 16:20:56 +08:00
roymondchen
63d8c98822 feat(design): input支持textarea rows 2023-08-08 16:14:36 +08:00
roymondchen
44efb3a967 chore(form,editor): 代码块编辑中按esc不会退出 2023-08-04 20:02:51 +08:00
roymondchen
f9dc628ef4 fix(editor): diff code editor中全屏按钮点击无效 2023-08-04 20:00:14 +08:00
roymondchen
cc195d2f5f chore: 更新依赖 2023-08-04 19:58:54 +08:00
roymondchen
92df80e711 feat(core,data-source,ui,ui-react,ui-vue2,utils,runtime): 解析显示条件配置 2023-08-04 19:50:44 +08:00
roymondchen
c389c614d7 style(editor,form): 统一表单组件props定义 2023-08-04 16:39:46 +08:00
roymondchen
46f6aeaaf7 feat(utils): 新增isObject 2023-08-04 15:59:18 +08:00
roymondchen
5887977e45 feat(form): 新增数字范围控件 2023-08-04 15:54:55 +08:00
roymondchen
35862078b3 feat(editor,schema): 支持组件显示条件配置 2023-08-04 15:52:55 +08:00
roymondchen
0d3cd11ade fix(editor): 使用画布上的删除按钮删除组件时依赖没有清空 2023-08-02 20:13:05 +08:00
roymondchen
2f28252c64 chore: release v1.3.0-alpha.16 2023-08-02 17:37:21 +08:00
roymondchen
b424abd17a fix(editor): 删除组件后,依赖清除出现可能出现大量重复循环 2023-08-02 17:23:29 +08:00
roymondchen
d79c9686e5 style(stage): 调整拖动图标 2023-07-27 14:42:33 +08:00
roymondchen
ded82aae41 fix(form): dialog,drawer disable时确认按钮置灰 2023-07-27 14:22:24 +08:00
roymondchen
90205f5395 feat(editor): 新增拖动按钮 2023-07-26 17:29:47 +08:00
roymondchen
1f6ae515f3 chore: release v1.3.0-alpha.15 2023-07-24 20:10:24 +08:00
roymondchen
23bee0b3ae fix(editor): 代码块节点slot参数丢失 2023-07-24 20:07:24 +08:00
roymondchen
ce6d2684b7 fix(editor): 流式布局下通过组件树拖动layout判断不正确 2023-07-21 19:36:51 +08:00
roymondchen
5e316e4d54 docs: 完善编辑器扩展文档 2023-07-21 17:06:46 +08:00
roymondchen
434e163626 chore: release v1.3.0-alpha.14 2023-07-19 19:18:51 +08:00
roymondchen
eccc27e91a chore: 更新vite 2023-07-19 19:16:30 +08:00
roymondchen
e577628852 style(editor): 代码块编辑中代码编辑器高度自动设置保持表单不出现滚动条 2023-07-19 14:57:26 +08:00
roymondchen
2a0680c707 feat(core,editor,data-source,form,schema): 新增数据源方法配置,支持事件联动数据源方法 2023-07-18 19:35:54 +08:00
roymondchen
1a546c326c fix(editor): 修复CodeSelectColConfig interface找不到问题
fix #525
2023-07-18 15:58:01 +08:00
roymondchen
fa2862090f chore(editor): 重构代码块编辑表单 2023-07-14 20:01:15 +08:00
roymondchen
0a9c7c9dda feat(editor): 代码块参数注释改用extra来显示 2023-07-14 16:38:22 +08:00
roymondchen
21f445dc13 chore: release v1.3.0-alpha.13 2023-07-10 17:10:54 +08:00
roymondchen
8e82d38bbb feat(editor): 代码块删除新增确认 2023-07-10 17:08:29 +08:00
roymondchen
6ddac803a2 style(editor): 完善codeBlock.setCodeDslById ts定义 2023-07-07 17:12:56 +08:00
roymondchen
07cd3065b2 feat(editor): 组件选择器点击已选择组件由重新选择改成选择组件 2023-07-07 17:10:51 +08:00
roymondchen
ee3ad63aa3 feat(stage): 新增清除高亮方法 2023-07-07 16:40:34 +08:00
930 changed files with 57038 additions and 24665 deletions

View File

@ -1,14 +0,0 @@
dist
coverage
node_modules
dest
types
public/entry
public/runtime
comp-entry.ts
config-entry.ts
value-entry.ts
magic-admin/web/public/runtime
magic-admin/server/static

View File

@ -1,69 +0,0 @@
module.exports = {
env: {
node: true,
browser: true,
es2021: true,
},
globals: {
describe: true,
it: true,
expect: true,
beforeEach: true,
},
extends: [
'eslint-config-tencent',
'eslint-config-tencent/ts',
'plugin:vue/vue3-essential',
'./prettier',
],
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 12,
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.vue'],
sourceType: 'module',
},
plugins: [
'vue',
'@typescript-eslint',
'simple-import-sort'
],
ignorePatterns: ['.eslintrc.js'],
rules: {
'vue/no-mutating-props': 'off',
'vue/multi-word-component-names': 'off',
'no-param-reassign': 'off',
'@typescript-eslint/no-require-imports': 'off',
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksVoidReturn": false
}
],
'simple-import-sort/imports': [
"error", {
groups: [
['./polyfills'],
// Node.js builtins. You could also generate this regex if you use a `.js` config.
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
[
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)",
],
// Packages. `react|vue` related packages come first.
["^(react|vue|vite)", "^@?\\w"],
["^(@tmagic)(/.*|$)"],
// Internal packages.
["^(@|@editor|@data-source)(/.*|$)"],
// Side effect imports.
["^\\u0000"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.s?css$"],
],
}
]
},
};

View File

@ -2,7 +2,7 @@ name: pages
on:
push:
branches: [master]
branches: [dev]
workflow_dispatch:
jobs:
@ -10,17 +10,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: dev
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
- name: Set node version to 16
uses: actions/setup-node@v2
- name: Set node version to 22
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 22
cache: 'pnpm'
- run: pnpm bootstrap

4
.gitignore vendored
View File

@ -5,6 +5,7 @@ types
.temp
.cache
temp
# local env files
.env.local
@ -30,3 +31,6 @@ coverage
auto-imports.d.ts
components.d.ts
docs/.vitepress/cache
.eslintcache
.npmrc

View File

@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit $1
npx --no-install commitlint --edit $1

View File

@ -1,5 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
pnpm --filter "@tmagic/*" build:type
npx lint-staged && npm run check:type

View File

@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm test

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
Tencent is pleased to support the open source community by making TMagicEditor available.
Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
Copyright (C) 2025 Tencent. All rights reserved.
TMagicEditor is licensed under the Apache License Version 2.0 except for the third-party components listed below.

View File

@ -16,9 +16,9 @@ https://tencent.github.io/tmagic-editor/playground/index.html
## 环境准备
node.js >= 16
node.js >= 18
pnpm >= 8
pnpm >= 9
先安装 pnpm
@ -83,6 +83,13 @@ tmagic-editor主要定位是搭建生成移动端H5页面如果有搭建PC端
如果你有好的意见或建议,欢迎给我们提 Issues 或 Pull Requests为提升魔方可视化编辑器开发体验贡献力量。<br>详见:[CONTRIBUTING.md](./CONTRIBUTING.md)
## 贡献者
<a href="https://github.com/Tencent/tmagic-editor/graphs/contributors">
<img src="https://contrib.rocks/image?repo=Tencent/tmagic-editor" />
</a>
### 欢迎入群交流
<img src="https://vfiles.gtimg.cn/vupload/20220412/b85d331649748582992.jpg" width=375>

View File

@ -1,3 +0,0 @@
module.exports = {
presets: ['@vue/cli-plugin-babel/preset'],
};

View File

@ -1 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
export default { extends: ['@commitlint/config-conventional'] };

View File

@ -24,12 +24,13 @@ export default defineConfig({
footer: {
message: 'Powered by 腾讯视频会员平台技术中心',
copyright: 'Copyright (C) 2023 THL A29 Limited, a Tencent company.'
copyright: 'Copyright (C) 2025 Tencent.'
},
nav: [
{ text: '文档', link: '/guide/', activeMatch: '/guide/' },
{ text: 'API', link: '/api/editor/props', activeMatch: '/api/' },
{ text: 'Editor API', link: '/api/editor/props', activeMatch: '/api/' },
{ text: 'Runtime API', link: '/runtime-api/core/app', activeMatch: '/runtime-api/' },
{ text: '表单配置', link: '/form-config/fields/text', activeMatch: '/form-config/' },
{ text: '更新日志', link: 'https://github.com/Tencent/tmagic-editor/releases' },
{ text: 'Playground', link: 'https://tencent.github.io/tmagic-editor/playground/index.html' },
@ -48,14 +49,6 @@ export default defineConfig({
text: '快速开始',
link: '/guide/'
},
{
text: '基础概念',
link: '/guide/conception.md',
},
{
text: '页面发布',
link: '/guide/publish.md'
},
{
text: 'RUNTIME',
link: '/guide/runtime.md'
@ -64,10 +57,22 @@ export default defineConfig({
text: '组件开发',
link: '/guide/component.md'
},
{
text: '基础概念',
link: '/guide/conception.md',
},
{
text: '页面发布',
link: '/guide/publish.md'
},
{
text: '编辑器扩展',
link: '/guide/editor-expand.md'
},
{
text: '升级到1.5.x',
link: '/guide/migration.md'
},
]
},
{
@ -93,6 +98,10 @@ export default defineConfig({
text: '代码块',
link: '/guide/advanced/code-block.md',
},
{
text: '数据源',
link: '/guide/advanced/data-source.md'
},
{
text: '@tmagic/ui',
link: '/guide/advanced/tmagic-ui.md',
@ -303,6 +312,10 @@ export default defineConfig({
text: 'InputNumber计数器',
link: '/form-config/fields/number.md'
},
{
text: 'NumberRange数字范围',
link: '/form-config/fields/number-range.md'
},
{
text: 'Display只读文本',
link: '/form-config/fields/display.md'
@ -343,6 +356,10 @@ export default defineConfig({
text: 'DatePick日期选择器',
link: '/form-config/fields/date-picker.md'
},
{
text: 'DateRangePick日期范围选择器',
link: '/form-config/fields/daterange-picker.md'
},
{
text: 'DatetimePick日期时间选择器',
link: '/form-config/fields/datetime-picker.md'
@ -350,9 +367,90 @@ export default defineConfig({
{
text: 'TimePick时间选择器',
link: '/form-config/fields/time-picker.md'
},
{
text: 'TimeRangePick时间范围选择器',
link: '/form-config/fields/timerange-picker.md'
},
{
text: 'DynamicField动态表单',
link: '/form-config/fields/dynamic-field.md'
}
]
},
{
text: '编辑器中可用配置',
items: [
{
text: 'Code代码编辑器',
link: '/form-config/editor-fields/code.md'
},
{
text: 'CodeLink代码链接',
link: '/form-config/editor-fields/code-link.md'
},
{
text: 'CodeSelect代码块选择器',
link: '/form-config/editor-fields/code-select.md'
},
{
text: 'CodeSelectCol代码块选择列',
link: '/form-config/editor-fields/code-select-col.md'
},
{
text: 'DataSourceSelect数据源选择器',
link: '/form-config/editor-fields/data-source-select.md'
},
{
text: 'DataSourceFieldSelect数据源字段选择器',
link: '/form-config/editor-fields/data-source-field-select.md'
},
{
text: 'DataSourceMethodSelect数据源方法选择器',
link: '/form-config/editor-fields/data-source-method-select.md'
},
{
text: 'DataSourceFields数据源字段配置',
link: '/form-config/editor-fields/data-source-fields.md'
},
{
text: 'DataSourceInput数据源输入框',
link: '/form-config/editor-fields/data-source-input.md'
},
{
text: 'DataSourceMethods数据源方法配置',
link: '/form-config/editor-fields/data-source-methods.md'
},
{
text: 'DataSourceMocks数据源Mock配置',
link: '/form-config/editor-fields/data-source-mocks.md'
},
{
text: 'UISelect组件选择器',
link: '/form-config/editor-fields/ui-select.md'
},
{
text: 'KeyValue键值对',
link: '/form-config/editor-fields/key-value.md'
},
{
text: 'PageFragmentSelect页面片选择器',
link: '/form-config/editor-fields/page-fragment-select.md'
},
{
text: 'EventSelect事件选择器',
link: '/form-config/editor-fields/event-select.md'
},
{
text: 'DisplayConds显示条件配置',
link: '/form-config/editor-fields/display-conds.md'
},
{
text: 'CondOpSelect条件操作选择器',
link: '/form-config/editor-fields/cond-op-select.md'
}
],
},
{
text: '布局配置',
items: [
@ -380,6 +478,74 @@ export default defineConfig({
}
]
}
],
'/runtime-api/': [
{
text: '@tmagic/core',
items: [
{
text: 'App',
link: '/runtime-api/core/app',
},
{
text: 'Node',
link: '/runtime-api/core/node',
},
{
text: 'Page',
link: '/runtime-api/core/page',
},
{
text: 'EventHelper',
link: '/runtime-api/core/eventHelper',
},
{
text: 'Env',
link: '/runtime-api/core/env',
},
{
text: 'IteratorContainer',
link: '/runtime-api/core/iteratorContainer',
},
{
text: 'FlowState',
link: '/runtime-api/core/flowState',
},
{
text: 'DevtoolApi',
link: '/runtime-api/core/devtoolApi',
},
{
text: '工具函数',
link: '/runtime-api/core/utils',
},
],
},
{
text: '@tmagic/data-source',
items: [
{
text: 'DataSourceManager',
link: '/runtime-api/data-source/dataSourceManager',
},
{
text: 'DataSource',
link: '/runtime-api/data-source/dataSource',
},
{
text: 'HttpDataSource',
link: '/runtime-api/data-source/httpDataSource',
},
{
text: '观察者数据类',
link: '/runtime-api/data-source/observedData',
},
{
text: '工具函数',
link: '/runtime-api/data-source/utils',
},
],
},
]
},
},
@ -394,6 +560,7 @@ export default defineConfig({
},
resolve: {
alias:[
{ find: /^@tmagic\/form-schema/, replacement: path.join(__dirname, '../../packages/form-schema/src/index.ts') },
{ find: /^@tmagic\/form/, replacement: path.join(__dirname, '../../packages/form/src/index.ts') },
{ find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../../packages/utils/src/index.ts') },
{ find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../../packages/schema/src/index.ts') },

View File

@ -17,11 +17,7 @@
<slot name="highlight"></slot>
</div>
</div>
<div
class="demo-block-control"
ref="control"
@click="isExpanded = !isExpanded"
>
<div class="demo-block-control" ref="control" @click="isExpanded = !isExpanded">
<transition name="arrow-slide">
<i :class="[iconClass, hovering]"></i>
</transition>
@ -30,23 +26,14 @@
</transition>
<el-tooltip effect="dark" :content="'前往 codepen.io 运行此示例'" placement="right">
<transition name="text-slide">
<el-button
size="small"
type="primary"
text
class="control-button"
@click.stop="goCodepen"
>
{{type === 'form' ? '查看结果' : '在线运行'}}
<el-button size="small" type="primary" text class="control-button" @click.stop="goCodepen">
{{ type === 'form' ? '查看结果' : '在线运行' }}
</el-button>
</transition>
</el-tooltip>
</div>
<el-dialog
v-model="resultVisible"
title="result"
>
<el-dialog v-model="resultVisible" title="result">
<pre><code class="language-javascript hljs" v-html="result"></code></pre>
</el-dialog>
</div>
@ -60,7 +47,9 @@
transition: 0.2s;
&.hover {
box-shadow: 0 0 8px 0 rgba(232, 237, 250, 0.6), 0 2px 4px 0 rgba(232, 237, 250, 0.5);
box-shadow:
0 0 8px 0 rgba(232, 237, 250, 0.6),
0 2px 4px 0 rgba(232, 237, 250, 0.5);
}
code {
@ -219,9 +208,7 @@ export function stripTemplate(content) {
}
export default {
props: [
'type', 'config'
],
props: ['type', 'config'],
data() {
return {
@ -293,12 +280,15 @@ export default {
},
text() {
return this.isStringConfig ?
hljs.highlight('js', this.config).value :
hljs.highlight('js', serialize(this.config, {
space: 2,
unsafe: true,
}).replace(/"(\w+)":\s/g, '$1: ')).value;
return this.isStringConfig
? hljs.highlight('js', this.config).value
: hljs.highlight(
'js',
serialize(this.config, {
space: 2,
unsafe: true,
}).replace(/"(\w+)":\s/g, '$1: '),
).value;
},
formConfig() {
@ -307,7 +297,7 @@ export default {
isStringConfig() {
return typeof this.config === 'string';
}
},
},
watch: {
@ -356,7 +346,7 @@ export default {
});
},
beforeDestroy() {
beforeUnmount() {
this.removeScrollHandler();
},
};

View File

@ -4,34 +4,101 @@
- **参数:**
-
- {[ComponentGroup](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/editor/src/type.ts#L355)[]} componentGroupList 组件列表配置
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
设置左侧面板的组件列表配置
:::tip
该方法通常由编辑器内部调用,开发者可以通过 [m-editor 的 componentGroupList prop](./props.md#componentgrouplist) 来配置组件列表
:::
- **示例:**
```js
import { componentListService } from '@tmagic/editor';
componentListService.setList([
{
title: '基础组件',
items: [
{
icon: 'text-icon',
text: '文本',
type: 'text',
},
{
icon: 'button-icon',
text: '按钮',
type: 'button',
},
],
},
]);
```
## getList
- **参数:**
-
- **参数:**
- **返回:**
- `{Promise<void>}`
- {[ComponentGroup](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/editor/src/type.ts#L355)[]} 组件列表配置
- **详情:**
获取当前的组件列表配置
- **示例:**
```js
import { componentListService } from '@tmagic/editor';
const list = componentListService.getList();
console.log(list);
```
## resetState
- **参数:**
- **返回:**
- `{void}`
- **详情:**
重置组件列表状态,清空所有配置
- **示例:**
```js
import { componentListService } from '@tmagic/editor';
componentListService.resetState();
```
## destroy
- **参数:**
-
- **参数:**
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
销毁 componentListService清空状态并移除所有事件监听和插件
- **示例:**
```js
import { componentListService } from '@tmagic/editor';
componentListService.destroy();
```

View File

@ -0,0 +1,541 @@
# dataSourceService方法
## get
- **参数:**
- `{StateKey}` name 状态键名
- **返回:**
- `{any}` 对应的状态值
- **详情:**
获取数据源服务的内部状态
可用的状态键:
- `datasourceTypeList`: 数据源类型列表
- `dataSources`: 当前数据源列表
- `editable`: 是否可编辑
- `configs`: 数据源表单配置
- `values`: 数据源默认值
- `events`: 数据源事件列表
- `methods`: 数据源方法列表
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const dataSources = dataSourceService.get('dataSources');
console.log(dataSources);
```
## set
- **参数:**
- `{StateKey}` name 状态键名
- `{any}` value 状态值
- **返回:**
- `{void}`
- **详情:**
设置数据源服务的内部状态
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.set('editable', false);
```
## getFormConfig
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型,默认为 'base'
- **返回:**
- {[FormConfig](https://github.com/Tencent/tmagic-editor/blob/c143a5f7670ae61d80c1a2cfcc780cfb5259849d/packages/form/src/schema.ts#L706)} 表单配置
- **详情:**
获取指定类型数据源的表单配置
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const config = dataSourceService.getFormConfig('http');
console.log(config);
```
## setFormConfig
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型
- {[FormConfig](https://github.com/Tencent/tmagic-editor/blob/c143a5f7670ae61d80c1a2cfcc780cfb5259849d/packages/form/src/schema.ts#L706)} config 表单配置
- **返回:**
- `{void}`
- **详情:**
设置指定类型数据源的表单配置
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.setFormConfig('http', [
{
name: 'url',
text: '请求地址',
type: 'text',
},
{
name: 'method',
text: '请求方法',
type: 'select',
options: [
{ text: 'GET', value: 'GET' },
{ text: 'POST', value: 'POST' },
],
},
]);
```
## getFormValue
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型,默认为 'base'
- **返回:**
- {Partial<[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221)>} 数据源默认值
- **详情:**
获取指定类型数据源的默认值
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const defaultValue = dataSourceService.getFormValue('http');
console.log(defaultValue);
```
## setFormValue
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型
- {Partial<[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221)>} value 数据源默认值
- **返回:**
- `{void}`
- **详情:**
设置指定类型数据源的默认值
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.setFormValue('http', {
type: 'http',
method: 'GET',
url: '',
});
```
## getFormEvent
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型,默认为 'base'
- **返回:**
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} 事件列表
- **详情:**
获取指定类型数据源的事件列表
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const events = dataSourceService.getFormEvent('http');
console.log(events);
```
## setFormEvent
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} value 事件列表
- **返回:**
- `{void}`
- **详情:**
设置指定类型数据源的事件列表
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.setFormEvent('http', [
{ label: '请求成功', value: 'success' },
{ label: '请求失败', value: 'error' },
]);
```
## getFormMethod
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型,默认为 'base'
- **返回:**
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} 方法列表
- **详情:**
获取指定类型数据源的方法列表
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const methods = dataSourceService.getFormMethod('http');
console.log(methods);
```
## setFormMethod
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` type 数据源类型
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} value 方法列表
- **返回:**
- `{void}`
- **详情:**
设置指定类型数据源的方法列表
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.setFormMethod('http', [
{ label: '发起请求', value: 'request' },
{ label: '重试', value: 'retry' },
]);
```
## add
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- {[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221)} config 数据源配置
- **返回:**
- {[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221)} 添加后的数据源配置
- **详情:**
添加一个数据源如果配置中没有id或id已存在会自动生成新的id
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const newDs = dataSourceService.add({
type: 'http',
title: '用户信息',
url: '/api/user',
method: 'GET',
});
console.log(newDs.id); // 自动生成的id
```
## update
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- {[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221)} config 数据源配置
- `{Object}` options 可选配置
- {[ChangeRecord](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/form/src/schema.ts#L27-L39)[]} changeRecords 变更记录
- **返回:**
- {[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221)} 更新后的数据源配置
- **详情:**
更新数据源
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const updatedDs = dataSourceService.update({
id: 'ds_123',
type: 'http',
title: '用户详情',
url: '/api/user/detail',
});
console.log(updatedDs);
```
## remove
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{string}` id 数据源id
- **返回:**
- `{void}`
- **详情:**
删除指定id的数据源
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.remove('ds_123');
```
## createId
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- **返回:**
- `{string}` 生成的唯一id
- **详情:**
生成一个唯一的数据源id格式为 `ds_` + guid
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const id = dataSourceService.createId();
console.log(id); // 'ds_xxx-xxx-xxx'
```
## getDataSourceById
- **参数:**
- `{string}` id 数据源id
- **返回:**
- {[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221) | undefined} 数据源配置
- **详情:**
根据id获取数据源配置
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
const ds = dataSourceService.getDataSourceById('ds_123');
console.log(ds);
```
## copyWithRelated
- **参数:**
- {[MNode](https://github.com/Tencent/tmagic-editor/blob/c143a5f7670ae61d80c1a2cfcc780cfb5259849d/packages/schema/src/index.ts#L99) | [MNode](https://github.com/Tencent/tmagic-editor/blob/c143a5f7670ae61d80c1a2cfcc780cfb5259849d/packages/schema/src/index.ts#L99)[]} config 组件节点配置
- `{TargetOptions}` collectorOptions 可选的收集器配置
- **返回:**
- `{void}`
- **详情:**
复制组件时会带上组件关联的数据源,将关联的数据源存储到 localStorage
- **示例:**
```js
import { dataSourceService, editorService } from '@tmagic/editor';
const node = editorService.get('node');
dataSourceService.copyWithRelated(node);
```
## paste
- **参数:**
- **返回:**
- `{void}`
- **详情:**
粘贴数据源,从 localStorage 中读取复制的数据源并添加到当前页面
如果数据源id已存在则不会覆盖
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.paste();
```
## resetState
- **参数:**
- **返回:**
- `{void}`
- **详情:**
重置数据源服务状态,清空所有数据源
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.resetState();
```
## destroy
- **参数:**
- **返回:**
- `{void}`
- **详情:**
销毁 dataSourceService移除所有事件监听并重置状态
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.destroy();
```
## usePlugin
- **详情:**
相对于[use](#use), usePlugin支持更加灵活更加细致的扩展 上述方法中标记有`扩展支持: 是`的方法都支持使用usePlugin扩展
每个支持扩展的方法都支持定制before、after两个hook来干预原有方法的行为before可以用于修改传入参数after可以用于修改返回的值
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.usePlugin({
beforeAdd(config) {
console.log('添加前:', config);
return [config];
},
afterAdd(result, config) {
console.log('添加后:', result);
return result;
},
});
```
## removeAllPlugins
- **详情:**
删掉当前设置的所有扩展
- **示例:**
```js
import { dataSourceService } from '@tmagic/editor';
dataSourceService.removeAllPlugins();
```

View File

@ -1,97 +1,244 @@
# eventService方法
# eventsService方法
## init
- **参数:**
-
- {Record<string, { events: [EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]; methods: [EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[] }>} eventMethodList 事件方法列表配置
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
初始化事件服务,设置所有组件的事件和方法列表
:::tip
该方法通常由编辑器内部调用,开发者可以通过 [m-editor 的 eventMethodList prop](./props.md#eventmethodlist) 来配置
:::
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
eventsService.init({
page: {
events: [
{ label: '页面加载', value: 'load' },
{ label: '页面卸载', value: 'unload' },
],
methods: [
{ label: '刷新', value: 'refresh' },
{ label: '返回', value: 'back' },
],
},
button: {
events: [
{ label: '点击', value: 'click' },
],
methods: [],
},
});
```
## setEvents
- **参数:**
-
- {Record<string, [EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]>} events 事件配置对象
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
批量设置多个组件类型的事件列表
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
eventsService.setEvents({
page: [
{ label: '页面加载', value: 'load' },
{ label: '页面显示', value: 'show' },
],
text: [
{ label: '点击', value: 'click' },
],
});
```
## setEvent
- **参数:**
-
- `{string}` type 组件类型
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} events 事件列表
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
设置指定组件类型的事件列表
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
eventsService.setEvent('button', [
{ label: '点击', value: 'click' },
{ label: '长按', value: 'longpress' },
]);
```
## getEvent
- **参数:**
-
- `{string}` type 组件类型
- **返回:**
- `{Promise<void>}`
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} 事件列表
- **详情:**
获取指定组件类型的事件列表
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
const events = eventsService.getEvent('button');
console.log(events); // [{ label: '点击', value: 'click' }, ...]
```
## setMethods
- **参数:**
-
- {Record<string, [EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]>} methods 方法配置对象
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
批量设置多个组件类型的方法列表
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
eventsService.setMethods({
page: [
{ label: '刷新', value: 'refresh' },
{ label: '滚动到顶部', value: 'scrollToTop' },
],
video: [
{ label: '播放', value: 'play' },
{ label: '暂停', value: 'pause' },
],
});
```
## setMethod
- **参数:**
-
- `{string}` type 组件类型
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} methods 方法列表
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
设置指定组件类型的方法列表
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
eventsService.setMethod('video', [
{ label: '播放', value: 'play' },
{ label: '暂停', value: 'pause' },
{ label: '停止', value: 'stop' },
]);
```
## getMethod
- **参数:**
-
- `{string}` type 组件类型
- **返回:**
- `{Promise<void>}`
- {[EventOption](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/core/src/events.ts#L26-L29)[]} 方法列表
- **详情:**
获取指定组件类型的方法列表
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
const methods = eventsService.getMethod('video');
console.log(methods); // [{ label: '播放', value: 'play' }, ...]
```
## resetState
- **参数:**
- **返回:**
- `{void}`
- **详情:**
重置事件服务状态,清空所有事件和方法配置
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
eventsService.resetState();
```
## destroy
- **参数:**
-
- **参数:**
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
销毁 eventsService重置状态并移除所有事件监听和插件
- **示例:**
```js
import { eventsService } from '@tmagic/editor';
eventsService.destroy();
```

View File

@ -49,7 +49,7 @@ const dsl = ref({
- **默认值:** `[]`
- **类型:** [ComponentGroup](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/editor/src/type.ts#L279-L284)
- **类型:** [ComponentGroup](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/editor/src/type.ts#L355)
::: tip
icon使用的是[element-plus icon](https://element-plus.org/zh-CN/component/icon.html)
@ -60,6 +60,19 @@ icon使用的是[element-plus icon](https://element-plus.org/zh-CN/component/ico
icon: 'https://vfiles.gtimg.cn/vupload/20220614/9cc3091655207317835.png'
}
```
url支持相对路径或者绝对路径例如
```js
{
icon: './icon.png'
}
{
icon: '/icon.png'
}
```
:::
:::warning
请注意如果只是文件名的话是不行的会被认为是css class
:::
- **示例:**
@ -107,6 +120,39 @@ const componentGroupList = ref([
此配置仅在[sidebar](#sidebar)中配置了'component-list'时有效
:::
## datasourceList
- **详情:**
左侧数据源面板中可新增的自定义数据源列表
- **默认值:** `[]`
- **类型:** [DatasourceTypeOption](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/editor/src/type.ts#L589)
- **示例:**
```html
<template>
<m-editor :datasource-list="datasourceTypeList"></m-editor>
</template>
<script setup>
import { ref } from 'Vue';
const datasourceTypeList = ref([
{
type: 'http',
text: 'Http数据源'
}
])
</script>
```
:::tip
系统默认已提供了base,http两种基础数据源此处配置的使用者新增的数据源
:::
## sidebar
- **详情:**
@ -149,6 +195,7 @@ const sidebar = ref({
component: markRaw(ModListPanel),
text: '模块',
},
],
});
</script>
@ -328,7 +375,7 @@ const stageContentMenu = ref([
```html
<template>
<m-editor
runtime-url="https://tencent.github.io/tmagic-editor/playground/runtime/vue3/playground/index.html"
runtime-url="https://tencent.github.io/tmagic-editor/playground/runtime/vue/playground/index.html"
></m-editor>
</template>
```
@ -368,6 +415,26 @@ const renderFunction = async (stage) => {
</script>
```
## renderType
- **详情:**
是用iframe渲染还是直接渲染
- **默认值:** `iframe`
- **类型:** `string`
'iframe' | 'native'
- **示例:**
```html
<template>
<m-editor render-type="native"></m-editor>
</template>
```
## autoScrollIntoView
- **详情:**
@ -514,6 +581,92 @@ const eventMethodList = {
</script>
```
## datasourceValues
- **详情:**
`propsValues` 类似,新增数据源时的默认值
:::tip
该属性最终会设置到[dataSourceService](./dataSourceServiceMethods.md)中,所以也可直接调用[dataSourceService.setFormValue()](./dataSourceServiceMethods.md#setFormValue)方法来配置
:::
- **默认值:** `{}`
- **类型:** Record<string, Partial<[DataSourceSchema](https://github.com/Tencent/tmagic-editor/blob/5880dfbe15fcead63e9dc7c91900f8c4e7a574d8/packages/schema/src/index.ts#L221)>>
- **示例:**
```html
<template>
<m-editor :datasource-values="datasourceValues"></m-editor>
</template>
<script setup>
const datasourceValues = {
'user-info': {
type: 'user-info',
title: '用户信息',
description: '用户信息',
fields: [
{
type: 'string',
name: 'nick',
title: '昵称',
defaultValue: '请登录',
enable: true,
},
]
},
};
</script>
```
## datasourceConfigs
- **详情:**
`propsConfigs` 类似,数据源的属性配置[表单的dsl](../../form-config/fields/text.md)
:::tip
该属性最终会设置到[dataSourceService](./dataSourceServiceMethods.md)中,所以也可直接调用[dataSourceService.setFormConfig()](./dataSourceServiceMethods.md#setFormConfig)方法来配置
:::
- **默认值:** `{}`
- **类型:** Record<string, [FormConfig](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/form/src/schema.ts#L706)>
- **示例:**
```html
<template>
<m-editor :datasource-configs="datasourceConfigs"></m-editor>
</template>
<script setup>
const datasourceConfigs = {
'user-info': [
{
type: 'select',
name: 'type',
text: '类型'
options: [
{ text: 'qq', value: 'qq'}
]
}
],
};
</script>
```
## datasourceEventMethodList
- **详情:**
组件属性配置中事件tab中的事件名与动作的下拉选项列表
- **默认值:** `{}`
## moveableOptions
- **详情:**
@ -522,7 +675,7 @@ const eventMethodList = {
- **默认值:** `{}`
- **类型:** ((config?: [CustomizeMoveableOptionsCallbackConfig](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/stage/src/types.ts#L97-L109)) => MoveableOptions) | [MoveableOptions](https://daybrush.com/moveable/release/latest/doc/)
- **类型:** ((config: [CustomizeMoveableOptionsCallbackConfig](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/stage/src/types.ts#L97-L109)) => MoveableOptions) | [MoveableOptions](https://daybrush.com/moveable/release/latest/doc/)
- **示例:**
@ -791,4 +944,339 @@ const updateDragEl = (el, target) => {
<m-editor :disabled-drag-start="true"></m-editor>
</template>
```
## disabledMultiSelect
- **详情:**
禁止多选
- **类型:** `boolean`
- **默认值:** `false`
- **示例:**
```html
<template>
<m-editor :disabled-multi-select="true"></m-editor>
</template>
```
## guidesOptions
- **详情:**
画布标尺和参考线的配置选项
- **默认值:** `undefined`
- **类型:** `Partial<GuidesOptions>`
- **示例:**
```html
<template>
<m-editor :guides-options="guidesOptions"></m-editor>
</template>
<script setup>
const guidesOptions = {
// 标尺刻度单位
unit: 1,
// 标尺背景色
backgroundColor: '#f0f0f0',
// 标尺文字颜色
textColor: '#333',
// 参考线颜色
lineColor: '#ff0000',
};
</script>
```
## disabledPageFragment
- **详情:**
禁用页面片功能
页面片是可以在多个页面中复用的组件集合
- **默认值:** `false`
- **类型:** `boolean`
- **示例:**
```html
<template>
<m-editor :disabled-page-fragment="true"></m-editor>
</template>
```
## disabledStageOverlay
- **详情:**
禁用双击在浮层中单独编辑选中组件的功能
启用时,双击组件可以在浮层中单独编辑,避免其他组件干扰
- **默认值:** `false`
- **类型:** `boolean`
- **示例:**
```html
<template>
<m-editor :disabled-stage-overlay="true"></m-editor>
</template>
```
## disabledShowSrc
- **详情:**
禁用属性配置面板右下角"显示源码"的按钮
该按钮可以查看和编辑组件的 JSON 配置
- **默认值:** `false`
- **类型:** `boolean`
- **示例:**
```html
<template>
<m-editor :disabled-show-src="true"></m-editor>
</template>
```
## disabledDataSource
- **详情:**
禁用数据源功能
禁用后,左侧面板将不显示数据源选项卡
- **默认值:** `false`
- **类型:** `boolean`
- **示例:**
```html
<template>
<m-editor :disabled-data-source="true"></m-editor>
</template>
```
## disabledCodeBlock
- **详情:**
禁用代码块功能
禁用后,左侧面板将不显示代码块选项卡
- **默认值:** `false`
- **类型:** `boolean`
- **示例:**
```html
<template>
<m-editor :disabled-code-block="true"></m-editor>
</template>
```
## treeIndent
- **详情:**
组件树、代码块列表、数据源列表的缩进配置单位px
- **默认值:** `undefined`
- **类型:** `number`
- **示例:**
```html
<template>
<m-editor :tree-indent="20"></m-editor>
</template>
```
## treeNextLevelIndentIncrement
- **详情:**
组件树、代码块列表、数据源列表子节点缩进增量配置单位px
每一级子节点会在父节点缩进基础上增加该值
- **默认值:** `undefined`
- **类型:** `number`
- **示例:**
```html
<template>
<!-- 第一级缩进20px第二级缩进35px第三级缩进50px -->
<m-editor :tree-indent="20" :tree-next-level-indent-increment="15"></m-editor>
</template>
```
## customContentMenu
- **详情:**
用于自定义组件树与画布的右键菜单
该函数会在显示右键菜单前被调用,接收默认菜单项作为参数,返回最终显示的菜单项
- **默认值:** `(menus) => menus`
- **类型:** `(menus: (MenuButton | MenuComponent)[], data: { node?: MNode; page?: MPage; parent?: MContainer; stage?: StageCore }) => (MenuButton | MenuComponent)[]`
- **示例:**
```html
<template>
<m-editor :custom-content-menu="customContentMenu"></m-editor>
</template>
<script setup>
const customContentMenu = (menus, { node }) => {
// 为特定类型的组件添加自定义菜单
if (node?.type === 'container') {
menus.push({
type: 'button',
text: '清空容器',
handler: () => {
// 清空容器的逻辑
},
});
}
// 可以过滤掉某些菜单项
return menus.filter(menu => menu.text !== '删除');
};
</script>
```
## extendFormState
- **详情:**
扩展表单状态
用于在属性表单中注入自定义的状态数据,这些数据可以在表单配置的各个字段为函数时的第一个参数中获取
- **默认值:** `undefined`
- **类型:** `(state: FormState) => Record<string, any> | Promise<Record<string, any>>`
- **示例:**
```html
<template>
<m-editor :extend-form-state="extendFormState"></m-editor>
</template>
<script setup>
const extendFormState = async (state) => {
// 返回自定义的状态数据
return {
// 可以是同步数据
currentUser: {
name: 'Admin',
role: 'admin',
},
// 也可以是异步获取的数据
projectConfig: await fetchProjectConfig(),
};
};
</script>
```
:::tip
扩展的状态可以在表单配置中通过 `state` 访问,例如:
```js
{
name: 'title',
text: '标题',
// 根据扩展的状态动态设置
disabled: (state) => state.currentUser.role !== 'admin',
}
```
:::
## pageBarSortOptions
- **详情:**
页面标签栏的拖拽排序配置参数
用于配置页面标签的拖拽排序行为
- **默认值:** `undefined`
- **类型:** [PageBarSortOptions](https://github.com/Tencent/tmagic-editor/blob/master/packages/editor/src/type.ts)
- **示例:**
```html
<template>
<m-editor :page-bar-sort-options="sortOptions"></m-editor>
</template>
<script setup>
const sortOptions = {
// 是否启用拖拽排序
animation: 150,
// 拖拽手柄的class
handle: '.page-bar-item',
// 其他 sortablejs 配置
};
</script>
```
## pageFilterFunction
- **详情:**
页面搜索/过滤函数
用于自定义页面的搜索逻辑,在页面列表中输入关键词时会调用该函数进行过滤
- **默认值:** `undefined`
- **类型:** `(page: MPage | MPageFragment, keyword: string) => boolean`
- **示例:**
```html
<template>
<m-editor :page-filter-function="pageFilterFunction"></m-editor>
</template>
<script setup>
const pageFilterFunction = (page, keyword) => {
// 自定义搜索逻辑
// 不仅搜索页面名称,还搜索页面的其他属性
return (
page.name?.includes(keyword) ||
page.title?.includes(keyword) ||
page.id?.includes(keyword)
);
};
</script>
```

View File

@ -1,29 +1,111 @@
# Editor组件 slots
## header
- **详情:** 编辑器最顶部区域
- **默认:**
- **示例:**
```html
<template>
<m-editor>
<template #header>
<div class="custom-header">自定义头部内容</div>
</template>
</m-editor>
</template>
```
## nav
- **详情:** 编辑器顶部菜单栏
- **默认:** [NavMenu.vue](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/editor/src/layouts/NavMenu.vue)
- **插槽 Props**
- `editorService`: editorService 实例
:::warning
属性配置[menu](./props.md#menu)由默认组件接收如设置该slot[menu](./props.md#menu)配置将失效
:::
- **示例:**
```html
<template>
<m-editor>
<template #nav="{ editorService }">
<div class="custom-nav">
<button @click="save">保存</button>
</div>
</template>
</m-editor>
</template>
```
## content-before
- **详情:** 编辑器主要内容区域之前
- **默认:**
## src-code
- **详情:** 源码查看区域
- **默认:** 默认的代码编辑器
- **插槽 Props**
- `editorService`: editorService 实例
## sidebar
- **详情:** 左边栏
- **默认:** [Sidebar.vue](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/editor/src/layouts/sidebar/Sidebar.vue)
- **插槽 Props**
- `editorService`: editorService 实例
:::warning
属性配置[sidebar](./props.md#sidebar)由默认组件接收如设置该slot[sidebar](./props.md#sidebar)配置将失效
:::
- **示例:**
```html
<template>
<m-editor>
<template #sidebar="{ editorService }">
<div class="custom-sidebar">
<!-- 自定义侧边栏内容 -->
</div>
</template>
</m-editor>
</template>
```
## component-list
- **详情:** 左边栏中的组件列表
- **默认:** 默认的组件列表
- **插槽 Props**
- `componentGroupList`: 组件分组列表
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
## component-list-panel-header
- **详情:** 左边栏中的组件列表内上方位置
- **默认:**
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
@ -34,24 +116,84 @@
- **默认:** 图片加文案
- **插槽 Props**
- `component`: 组件配置对象
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
- **示例:**
```html
<template>
<m-editor>
<template #component-list-item="{ component }">
<div class="custom-item">
<span>{{ component.text }}</span>
</div>
</template>
</m-editor>
</template>
```
## layer-panel-header
- **详情:** 左边栏中的已选组件(组件树)内顶部位置
- **默认:**
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
## layer-node-content
- **详情:** 左边栏中的已选组件(组件树)节点
- **详情:** 左边栏中的已选组件(组件树)节点完整内容
- **默认:** 组件名称加id和工具按钮
- **插槽 Props**
- `data`: 节点数据
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
## layer-node-label
- **详情:** 左边栏中的已选组件(组件树)节点标签部分
- **默认:** 组件名称加id
- **插槽 Props**
- `data`: 节点数据
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
- **示例:**
```html
<template>
<m-editor>
<template #layer-node-label="{ data }">
<span>{{ data.type }} - {{ data.name }}</span>
</template>
</m-editor>
</template>
```
## layer-node-tool
- **详情:** 左边栏中的已选组件(组件树)节点右侧工具区域
- **默认:**
- **插槽 Props**
- `data`: 节点数据
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
@ -60,6 +202,8 @@
- **详情:** 左边栏中的代码块列表内顶部位置
- **默认:**
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
@ -68,13 +212,44 @@
- **详情:** 左边栏中的代码块列表中代码块右侧位置
- **默认:**
- **插槽 Props**
- `id`: 代码块id
- `data`: 代码块数据
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
## code-block-edit-panel-header
## code-block-panel-search
- **详情:** 代码块弹窗编辑器中弹窗顶部区域
- **详情:** 左边栏中的代码块列表搜索框位置
- **默认:**
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
## data-source-panel-tool
- **详情:** 左边栏中的数据源列表中数据源右侧位置
- **默认:**
- **插槽 Props**
- `data`: 数据源数据
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
:::
## data-source-panel-search
- **详情:** 左边栏中的数据源列表搜索框位置
- **默认:**
:::warning
如设置了[sidebar](#sidebar)插槽,此插槽将失效
@ -86,6 +261,9 @@
- **默认:** [Workspace.vue](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/editor/src/layouts/workspace/Workspace.vue)
- **插槽 Props**
- `editorService`: editorService 实例
## stage
- **详情:** 画布
@ -94,15 +272,63 @@
## workspace-content
- **详情:** 编辑器中间区域内
- **详情:** 编辑器中间区域内,画布上方位置
- **默认:**
- **插槽 Props**
- `editorService`: editorService 实例
## page-bar
- **详情:** 编辑器中间区域底部页面标签栏
- **默认:** 默认的页面标签栏
## page-bar-add-button
- **详情:** 页面标签栏中的"添加页面"按钮
- **默认:** 默认的添加按钮
## page-bar-title
- **详情:** 编辑器中间区域底部页面标题
- **默认:** 页面名称
- **插槽 Props**
- `page`: 页面配置对象
- **示例:**
```html
<template>
<m-editor>
<template #page-bar-title="{ page }">
<span>{{ page.name }} - {{ page.id }}</span>
</template>
</m-editor>
</template>
```
## page-bar-popover
- **详情:** 编辑器中间区域底部页面标题悬浮框
- **详情:** 编辑器中间区域底部页面标题悬浮框内容
- **默认:** 页面详细信息
- **插槽 Props**
- `page`: 页面配置对象
## page-list-popover
- **详情:** 页面列表弹出框内容
- **默认:** 页面列表
- **插槽 Props**
- `list`: 页面列表
## props-panel
@ -114,8 +340,40 @@
- **详情:** 编辑器右侧属性配置内顶部区域
- **默认:**
## content-after
- **详情:** 编辑器主要内容区域之后
- **默认:**
## footer
- **详情:** 编辑器底部区域
- **默认:**
## empty
- **详情:** 当前没有页面时,编辑器中间区域
- **默认:** [AddPageBox.vue](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/editor/src/layouts/AddPageBox.vue)
- **插槽 Props**
- `editorService`: editorService 实例
- **示例:**
```html
<template>
<m-editor>
<template #empty="{ editorService }">
<div class="custom-empty">
<p>暂无页面</p>
<button @click="createFirstPage">创建第一个页面</button>
</div>
</template>
</m-editor>
</template>
```

View File

@ -4,114 +4,250 @@
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
-
- **参数:**
- **返回:**
- `{Promise<void>}`
- `{Storage}` Storage 对象
- **详情:**
获取数据存储对象,默认返回 localStorage
可以通过插件机制替换为其他存储对象(如 sessionStorage
- **示例:**
```js
import { storageService } from '@tmagic/editor';
const storage = storageService.getStorage();
console.log(storage); // localStorage
// 通过插件替换为 sessionStorage
storageService.usePlugin({
afterGetStorage() {
return window.sessionStorage;
},
});
```
## getNamespace
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
-
- **参数:**
- **返回:**
- `{Promise<void>}`
- `{string}` 命名空间字符串
- **详情:**
获取存储项的命名空间,默认为 'tmagic'
命名空间用于区分不同应用的存储数据
- **示例:**
```js
import { storageService } from '@tmagic/editor';
const namespace = storageService.getNamespace();
console.log(namespace); // 'tmagic'
```
## clear
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
-
- **参数:**
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
清空当前存储对象中的所有数据
- **示例:**
```js
import { storageService } from '@tmagic/editor';
storageService.clear();
```
## getItem
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
-
- `{string}` key 存储项的键名
- `{Options}` options 可选配置
- `namespace?: string` 自定义命名空间
- `protocol?: Protocol` 数据协议类型
- **返回:**
- `{Promise<void>}`
- `{any}` 存储的值,如果不存在返回 null
- **详情:**
获取存储项,支持多种数据类型的自动解析
支持的协议类型:
- `Protocol.OBJECT`: JavaScript 对象
- `Protocol.JSON`: JSON 格式
- `Protocol.NUMBER`: 数字类型
- `Protocol.BOOLEAN`: 布尔类型
- `Protocol.STRING`: 字符串类型
- **示例:**
```js
import { storageService } from '@tmagic/editor';
// 获取字符串
const str = storageService.getItem('myKey');
// 使用自定义命名空间
const value = storageService.getItem('key', { namespace: 'custom' });
// 指定协议类型
const num = storageService.getItem('count', { protocol: Protocol.NUMBER });
```
## key
- **参数:**
-
- `{number}` index 索引位置
- **返回:**
- `{Promise<void>}`
- `{string | null}` 指定位置的键名,不存在返回 null
- **详情:**
获取存储对象中指定索引位置的键名
- **示例:**
```js
import { storageService } from '@tmagic/editor';
const firstKey = storageService.key(0);
console.log(firstKey);
```
## removeItem
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
-
- `{string}` key 存储项的键名
- `{Options}` options 可选配置
- `namespace?: string` 自定义命名空间
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
移除指定的存储项
- **示例:**
```js
import { storageService } from '@tmagic/editor';
// 移除默认命名空间下的存储项
storageService.removeItem('myKey');
// 移除自定义命名空间下的存储项
storageService.removeItem('key', { namespace: 'custom' });
```
## setItem
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
-
- `{string}` key 存储项的键名
- `{any}` value 要存储的值
- `{Options}` options 可选配置
- `namespace?: string` 自定义命名空间
- `protocol?: Protocol` 数据协议类型
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
设置存储项,自动序列化复杂数据类型
- **示例:**
```js
import { storageService, Protocol } from '@tmagic/editor';
// 存储字符串
storageService.setItem('name', 'tmagic');
// 存储对象
storageService.setItem('config', { a: 1, b: 2 }, { protocol: Protocol.OBJECT });
// 存储数字
storageService.setItem('count', 100, { protocol: Protocol.NUMBER });
// 使用自定义命名空间
storageService.setItem('key', 'value', { namespace: 'custom' });
```
## destroy
- **参数:**
-
- **参数:**
- **返回:**
- `{Promise<void>}`
- `{void}`
- **详情:**
销毁 storageService移除所有事件监听和插件
- **示例:**
```js
import { storageService } from '@tmagic/editor';
storageService.destroy();
```
## use
使用中间件的方式扩展方法,上述方法中标记有`扩展支持: 是`的方法都支持使用use扩展
- **示例:**
```js
import { storageService } from '@tmagic/editor';
storageService.use({
getItem(key, options, next) {
console.log('获取存储项:', key);
return next();
},
});
```
## usePlugin
- **详情:**
@ -120,9 +256,35 @@
每个支持扩展的方法都支持定制before、after两个hook来干预原有方法的行为before可以用于修改传入参数after可以用于修改返回的值
- **示例:**
```js
import { storageService } from '@tmagic/editor';
storageService.usePlugin({
beforeSetItem(key, value, options) {
console.log('设置前:', key, value);
return [key, value, options];
},
afterGetItem(result, key, options) {
console.log('获取后:', result);
return result;
},
});
```
## removeAllPlugins
- **详情:**
删掉当前设置的所有扩展
- **示例:**
```js
import { storageService } from '@tmagic/editor';
storageService.removeAllPlugins();
```

View File

@ -1,12 +1,89 @@
# uiService方法
## set
- **参数:**
- `{keyof UiState}` name 状态键名
- `{any}` value 状态值
- **返回:**
- `{void}`
- **详情:**
设置UI服务的状态
可用的状态键:
- `uiSelectMode`: UI选择模式
- `showSrc`: 是否显示源码
- `showStylePanel`: 是否显示样式面板
- `zoom`: 缩放比例
- `stageContainerRect`: 画布容器尺寸
- `stageRect`: 画布尺寸
- `columnWidth`: 列宽度配置
- `showGuides`: 是否显示参考线
- `showRule`: 是否显示标尺
- `propsPanelSize`: 属性面板尺寸
- `showAddPageButton`: 是否显示添加页面按钮
- `showPageListButton`: 是否显示页面列表按钮
- `hideSlideBar`: 是否隐藏侧边栏
- `sideBarItems`: 侧边栏项目
- `navMenuRect`: 导航菜单尺寸
- `frameworkRect`: 框架尺寸
- **示例:**
```js
import { uiService } from '@tmagic/editor';
// 设置缩放比例
uiService.set('zoom', 1.5);
// 设置画布尺寸
uiService.set('stageRect', { width: 375, height: 667 });
// 显示/隐藏参考线
uiService.set('showGuides', true);
// 显示/隐藏标尺
uiService.set('showRule', true);
```
## get
- **参数:**
- `{keyof UiState}` name 状态键名
- **返回:**
- `{any}` 对应的状态值
- **详情:**
获取UI服务的状态值
- **示例:**
```js
import { uiService } from '@tmagic/editor';
const zoom = uiService.get('zoom');
console.log('当前缩放:', zoom);
const stageRect = uiService.get('stageRect');
console.log('画布尺寸:', stageRect);
```
## zoom
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- `{number}` zoom 缩放倍数
- `{number}` zoom 缩放增量(可以为负数)
- **返回:**
@ -14,24 +91,111 @@
- **详情:**
设置缩放倍数最小为0.1
调整缩放倍数最小为0.1
传入的值会被累加到当前缩放倍数上
- **示例:**
```js
import { uiService } from '@tmagic/editor';
// 放大0.1倍
await uiService.zoom(0.1);
// 缩小0.1倍
await uiService.zoom(-0.1);
// 当前缩放如果是1.0执行zoom(0.5)后变为1.5
await uiService.zoom(0.5);
```
## calcZoom
- **[扩展支持](../../guide/editor-expand#行为扩展)** 是
- **参数:**
- **返回:**
- `{Promise<number>}`
- `{Promise<number>}` 计算出的缩放倍数
- **详情:**
计算出缩放以适应的倍数
计算"缩放以适应"的倍数
根据画布容器的尺寸和画布尺寸自动计算出合适的缩放比例,使画布完全显示在容器内
- **示例:**
```js
import { uiService } from '@tmagic/editor';
const fitZoom = await uiService.calcZoom();
console.log('适应缩放:', fitZoom);
// 应用缩放以适应
uiService.set('zoom', fitZoom);
```
## resetState
- **参数:**
- **返回:**
- `{void}`
- **详情:**
重置UI服务状态到初始值
- **示例:**
```js
import { uiService } from '@tmagic/editor';
uiService.resetState();
```
## destroy
- **参数:**
- **返回:**
- `{void}`
- **详情:**
销毁 uiService重置状态并移除所有事件监听和插件
- **示例:**
```js
import { uiService } from '@tmagic/editor';
uiService.destroy();
```
## use
使用中间件的方式扩展方法,上述方法中标记有`扩展支持: 是`的方法都支持使用use扩展
- **示例:**
```js
import { uiService } from '@tmagic/editor';
uiService.use({
async zoom(value, next) {
console.log('缩放前:', uiService.get('zoom'));
await next();
console.log('缩放后:', uiService.get('zoom'));
},
});
```
## usePlugin
- **详情:**
@ -40,9 +204,36 @@
每个支持扩展的方法都支持定制before、after两个hook来干预原有方法的行为before可以用于修改传入参数after可以用于修改返回的值
- **示例:**
```js
import { uiService } from '@tmagic/editor';
uiService.usePlugin({
beforeZoom(value) {
console.log('缩放增量:', value);
return [value];
},
afterCalcZoom(result) {
console.log('计算的缩放:', result);
// 可以修改返回值
return result;
},
});
```
## removeAllPlugins
- **详情:**
删掉当前设置的所有扩展
- **示例:**
```js
import { uiService } from '@tmagic/editor';
uiService.removeAllPlugins();
```

View File

@ -2,14 +2,109 @@
## sort-change
- **参数:**
- `{ column, prop, order }` - 排序信息对象
- `column: Object` - 排序的列配置
- `prop: string` - 排序的列属性名
- `order: 'ascending' | 'descending' | null` - 排序方式
- **说明:** 当表格的排序条件发生变化时触发
- **示例:**
```js
const handleSortChange = ({ column, prop, order }) => {
console.log('排序变化:', prop, order);
};
```
## after-action
- **参数:**
- `action: string` - 操作类型
- `data: any` - 操作相关数据
- **说明:** 表格操作完成后触发
- **示例:**
```js
const handleAfterAction = (action, data) => {
console.log('操作完成:', action, data);
};
```
## select
- **参数:**
- `selection: Array<any>` - 当前选中的行数据数组
- `row: any` - 刚刚被选中的行数据
- **说明:** 当用户手动勾选某一行时触发
- **示例:**
```js
const handleSelect = (selection, row) => {
console.log('选中行:', row);
console.log('当前选中:', selection);
};
```
## select-all
- **参数:**
- `selection: Array<any>` - 当前选中的行数据数组
- **说明:** 当用户手动勾选全选 Checkbox 时触发
- **示例:**
```js
const handleSelectAll = (selection) => {
console.log('全选/取消全选:', selection.length);
};
```
## selection-change
- **参数:**
- `selection: Array<any>` - 当前选中的行数据数组
- **说明:** 当选择项发生变化时触发
- **示例:**
```js
const handleSelectionChange = (selection) => {
console.log('选中项变化:', selection);
};
```
## expand-change
- **参数:**
- `row: any` - 被展开/收起的行数据
- `expandedRows: Array<any>` - 当前所有展开的行数据数组
- **说明:** 当用户展开或收起某一行时触发(用于可展开表格)
- **示例:**
```js
const handleExpandChange = (row, expandedRows) => {
console.log('展开状态变化:', row);
console.log('当前展开行:', expandedRows);
};
```
## cell-click
- **参数:**
- `row: any` - 行数据
- `column: Object` - 列配置
- `cell: HTMLElement` - 单元格 DOM 元素
- `event: Event` - 原生事件对象
- **说明:** 当某个单元格被点击时触发
- **示例:**
```js
const handleCellClick = (row, column, cell, event) => {
console.log('单元格点击:', row, column.property);
};
```

View File

@ -2,6 +2,40 @@
## toggleRowSelection
- **参数:**
- `row: any` - 要切换选中状态的行数据
- `selected?: boolean` - 是否选中,不传则切换当前状态
- **说明:** 切换某一行的选中状态
- **示例:**
```js
tableRef.value.toggleRowSelection(row, true); // 选中
tableRef.value.toggleRowSelection(row, false); // 取消选中
tableRef.value.toggleRowSelection(row); // 切换状态
```
## toggleRowExpansion
- **参数:**
- `row: any` - 要展开/收起的行数据
- `expanded?: boolean` - 是否展开,不传则切换当前状态
- **说明:** 切换某一行的展开状态(用于可展开表格)
- **示例:**
```js
tableRef.value.toggleRowExpansion(row, true); // 展开
tableRef.value.toggleRowExpansion(row, false); // 收起
```
## clearSelection
- **参数:**
- **说明:** 清空所有选中的行
- **示例:**
```js
tableRef.value.clearSelection();
```

View File

@ -2,123 +2,122 @@
## data
- **详情:**
- **详情:** 表格数据,数组格式
- **默认值:** `[]`
- **默认值:**
- **类型:**
- **类型:** `Array<any>`
- **示例:**
```js
[
{ id: 1, name: '张三', age: 20 },
{ id: 2, name: '李四', age: 25 }
]
```
## columns
- **详情:**
- **详情:** 表格列配置
- **默认值:** `[]`
- **默认值:**
- **类型:**
- **类型:** `Array<ColumnConfig>`
- **示例:**
```js
[
{ prop: 'name', label: '姓名', width: 120 },
{ prop: 'age', label: '年龄', width: 80 }
]
```
## spanMethod
- **详情:** 合并行或列的计算方法
- **默认值:** `undefined`
- **类型:** `Function`
- **参数:**
- `{ row, column, rowIndex, columnIndex }`
- **返回值:** `[rowspan, colspan]``{ rowspan, colspan }`
- **默认值:**
- **类型:**
- **示例:**
```js
({ rowIndex, columnIndex }) => {
if (rowIndex % 2 === 0) {
if (columnIndex === 0) {
return [1, 2];
} else if (columnIndex === 1) {
return [0, 0];
}
}
}
```
## loading
- **详情:**
- **详情:** 是否显示加载状态
- **默认值:** `false`
- **默认值:**
- **类型:**
- **类型:** `boolean`
## showHeader
- **详情:** 是否显示表头
- **默认值:** `true`
- **默认值:**
- **类型:**
- **类型:** `boolean`
## bodyHeight
- **详情:** Table的最大高度。合法的值为数字或者单位为 px 的高度
- **详情:** Table 的最大高度。合法的值为数字或者单位为 px 的高度
- **默认值:**
- **默认值:** `undefined`
- **类型:** `string | number`
- **类型:**
- **示例:**
```js
bodyHeight: 400
bodyHeight: '400px'
```
## emptyText
- **详情:** 空数据时显示的文本内容
- **默认值:**
- **类型:**
- **默认值:** `'暂无数据'`
- **类型:** `string`
## defaultExpandAll
- **详情:** 是否默认展开所有行当Table包含展开行存在或者为树形表格时有效
- **详情:** 是否默认展开所有行,当 Table 包含展开行存在或者为树形表格时有效
- **默认值:**
- **类型:**
- **默认值:** `false`
- **类型:** `boolean`
## rowkeyName
- **详情:**
- **详情:** 行数据的 Key用来优化 Table 的渲染
- **默认值:** `'id'`
- **默认值:**
- **类型:**
- **类型:** `string`
- **说明:** 在使用 reserve-selection 功能与显示树形数据时,该属性是必填的
## border
- **详情:**
- **详情:** 是否显示边框
- **默认值:** `false`
- **默认值:**
- **类型:**
- **类型:** `boolean`

View File

@ -0,0 +1,38 @@
# CodeLink 代码链接
通过弹窗链接的方式编辑代码内容。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'code-link',
name: 'codeLink',
text: '代码配置'
}
```
## 自定义弹窗标题
```js
{
type: 'code-link',
name: 'codeLink',
text: '代码配置',
formTitle: '编辑代码'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| formTitle | 弹窗标题 | string | — | — |
| codeOptions | 代码编辑器配置项 | object | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,37 @@
# CodeSelectCol 代码块选择列
代码块选择器的列组件,支持选择代码块并配置参数。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'code-select-col',
name: 'codeId',
text: '代码块'
}
```
## 禁止编辑
```js
{
type: 'code-select-col',
name: 'codeId',
text: '代码块',
notEditable: true
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| notEditable | 是否不可编辑代码块disable控制是否可选择 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,33 @@
# CodeSelect 代码块选择器
用于选择代码块并配置参数的组件。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'code-select',
name: 'codeSelect',
text: '代码块'
}
```
## 功能说明
CodeSelect 组件支持:
- 选择代码块
- 选择数据源方法
- 配置代码块参数
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| className | 自定义类名 | string | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,61 @@
# Code 代码编辑器
代码编辑器字段,用于编辑代码内容。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'code',
name: 'code',
text: '代码'
}
```
## 指定语言
```js
{
type: 'code',
name: 'code',
text: '代码',
language: 'javascript'
}
```
## 自动调整大小
```js
{
type: 'code',
name: 'code',
text: '代码',
autosize: {
minRows: 3,
maxRows: 10
}
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| language | 代码语言 | string | javascript/typescript/json等 | — |
| height | 编辑器高度 | string | — | — |
| parse | 是否解析代码 | boolean | — | false |
| options | 编辑器配置项 | object | — | — |
| autosize | 自动调整大小配置 | object | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
## autosize Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| minRows | 最小行数 | number | — | — |
| maxRows | 最大行数 | number | — | — |

View File

@ -0,0 +1,37 @@
# CondOpSelect 条件操作选择器
用于选择条件操作符的选择器。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'cond-op',
name: 'op',
text: '操作符'
}
```
## 指定父级字段
```js
{
type: 'cond-op',
name: 'op',
text: '操作符',
parentFields: ['field1', 'field2']
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| parentFields | 父级字段 | string[] | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,67 @@
# DataSourceFieldSelect 数据源字段选择器
用于选择数据源字段的级联选择器。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'data-source-field-select',
name: 'field',
text: '数据源字段'
}
```
## 返回字段key
```js
{
type: 'data-source-field-select',
name: 'field',
text: '数据源字段',
value: 'key'
}
```
## 限制字段类型
```js
{
type: 'data-source-field-select',
name: 'field',
text: '数据源字段',
dataSourceFieldType: ['string', 'number']
}
```
## 父子节点不关联
```js
{
type: 'data-source-field-select',
name: 'field',
text: '数据源字段',
checkStrictly: true
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| value | 返回值类型 | string | key/value | — |
| checkStrictly | 是否严格遵守父子节点不互相关联 | boolean / Function | — | — |
| dataSourceFieldType | 允许选择的字段类型 | DataSourceFieldType[] | — | — |
| fieldConfig | 自定义字段配置 | ChildConfig | — | — |
| notEditable | 是否不可编辑数据源disable控制是否可选择 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
## value说明
- `key`: 不编译返回数据源id和字段name
- `value`: 编译后返回数据源data[field]

View File

@ -0,0 +1,25 @@
# DataSourceFields 数据源字段配置
用于配置数据源字段的表单组件。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'data-source-fields',
name: 'fields',
text: '字段配置'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,25 @@
# DataSourceInput 数据源输入框
支持绑定数据源的输入框组件。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'data-source-input',
name: 'input',
text: '输入框'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,37 @@
# DataSourceMethodSelect 数据源方法选择器
用于选择数据源方法的选择器。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'data-source-method-select',
name: 'method',
text: '数据源方法'
}
```
## 禁止编辑
```js
{
type: 'data-source-method-select',
name: 'method',
text: '数据源方法',
notEditable: true
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| notEditable | 是否不可编辑数据源disable控制是否可选择 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,25 @@
# DataSourceMethods 数据源方法配置
用于配置数据源方法的表单组件。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'data-source-methods',
name: 'methods',
text: '方法配置'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,25 @@
# DataSourceMocks 数据源Mock配置
用于配置数据源Mock数据的表单组件。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'data-source-mocks',
name: 'mocks',
text: 'Mock配置'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,55 @@
# DataSourceSelect 数据源选择器
用于选择数据源的下拉选择器。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'data-source-select',
name: 'dataSource',
text: '数据源'
}
```
## 过滤数据源类型
```js
{
type: 'data-source-select',
name: 'dataSource',
text: '数据源',
dataSourceType: 'http'
}
```
## 返回数据源ID
```js
{
type: 'data-source-select',
name: 'dataSource',
text: '数据源',
value: 'id'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| dataSourceType | 数据源类型过滤 | string | base/http等 | — |
| value | 返回值类型 | string | id/value | — |
| notEditable | 是否不可编辑数据源disable控制是否可选择 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
## value说明
- `id`: 不编译返回数据源id
- `value`: 编译后返回数据源data

View File

@ -0,0 +1,38 @@
# DisplayConds 显示条件配置
用于配置组件显示条件的表单组件。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'display-conds',
name: 'displayConds',
text: '显示条件'
}
```
## 带标题前缀
```js
{
type: 'display-conds',
name: 'displayConds',
text: '显示条件',
titlePrefix: '条件'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| titlePrefix | 标题前缀 | string | — | — |
| parentFields | 父级字段 | string[] / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,49 @@
# EventSelect 事件选择器
用于配置组件或数据源事件的选择器。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'event-select',
name: 'events',
text: '事件配置',
src: 'component'
}
```
## 数据源事件
```js
{
type: 'event-select',
name: 'events',
text: '事件配置',
src: 'datasource'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| src | 事件来源 | string | datasource/component | — |
| labelWidth | 标签宽度 | string | — | — |
| eventNameConfig | 事件名称表单配置 | FormItem | — | — |
| actionTypeConfig | 动作类型配置 | FormItem | — | — |
| targetCompConfig | 联动组件配置 | FormItem | — | — |
| compActionConfig | 联动组件动作配置 | FormItem | — | — |
| codeActionConfig | 联动代码配置 | FormItem | — | — |
| dataSourceActionConfig | 联动数据源配置 | FormItem | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
## src说明
- `component`: 组件事件
- `datasource`: 数据源事件

View File

@ -0,0 +1,39 @@
# KeyValue 键值对
用于配置键值对数据的表单组件。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'key-value',
name: 'params',
text: '参数'
}
```
## 高级模式
设置 `advanced``true`,可切换到代码编辑模式。
```js
{
type: 'key-value',
name: 'params',
text: '参数',
advanced: true
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| advanced | 是否支持高级模式(代码编辑) | boolean | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -0,0 +1,30 @@
# PageFragmentSelect 页面片选择器
用于选择页面片的下拉选择器。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'page-fragment-select',
name: 'pageFragment',
text: '页面片'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
## 使用说明
1. 下拉框会自动列出当前项目中所有的页面片
2. 选中页面片后,点击编辑图标可跳转到对应页面片进行编辑

View File

@ -0,0 +1,33 @@
# UISelect 组件选择器
用于在画布中选择组件的选择器。
::: warning 注意
此组件仅在编辑器环境中可用,需要配合 `@tmagic/editor` 使用。
:::
## 基础用法
```js
{
type: 'ui-select',
name: 'targetId',
text: '目标组件'
}
```
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
## 使用说明
1. 点击"点击此处选择"按钮进入选择模式
2. 在画布中点击目标组件完成选择
3. 选择后会显示组件名称和ID
4. 可通过清除按钮清空选择
5. 点击组件名称可跳转到对应组件

View File

@ -214,3 +214,241 @@
</p>
</template>
</demo-block>
## 任意一级可选
在单选模式下,你只能选择叶子节点;而在多选模式下,勾选父节点真正选中的都是叶子节点。启用该功能后,可让父子节点取消关联,选择任意一级选项。
可通过 `checkStrictly = true` 来设置父子节点取消选中关联,从而达到选择任意一级选项的目的。
<demo-block type="form" :config="[{
type: 'cascader',
name: 'cascader',
text: '选项',
placeholder: '请选择',
checkStrictly: true,
options: [
{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '设计原则',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反馈'
}]
}]
},
{
value: 'zujian',
label: '组件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}]
}]
}
]
}]">
<template #source>
<p>
配置 checkStrictly 为 true可选择任意一级选项
</p>
</template>
</demo-block>
## 仅返回选中节点的值
在选中节点改变时,默认返回由该节点所在的各级菜单的值所组成的数组。可通过 `emitPath = false` 设置仅返回该节点的值。
<demo-block type="form" :config="[{
type: 'cascader',
name: 'cascader',
text: '选项',
placeholder: '请选择',
emitPath: false,
checkStrictly: true,
options: [
{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '设计原则',
children: [{
value: 'yizhi',
label: '一致'
}, {
value: 'fankui',
label: '反馈'
}]
}]
},
{
value: 'zujian',
label: '组件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}, {
value: 'color',
label: 'Color 色彩'
}]
}]
}
]
}]">
<template #source>
<p>
配置 emitPath 为 false仅返回选中节点的值而非完整路径数组
</p>
</template>
</demo-block>
## 值分隔符
当需要将选中值以字符串形式存储时,可通过 `valueSeparator` 指定分隔符,组件会自动将数组转换为字符串存储,读取时也会自动还原。
<demo-block type="form" :config="[{
type: 'cascader',
name: 'cascader',
text: '选项',
placeholder: '请选择',
valueSeparator: '/',
options: [
{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '设计原则',
children: [{
value: 'yizhi',
label: '一致'
}]
}]
},
{
value: 'zujian',
label: '组件',
children: [{
value: 'basic',
label: 'Basic',
children: [{
value: 'layout',
label: 'Layout 布局'
}]
}]
}
]
}]">
<template #source>
<p>
配置 valueSeparator 为 '/',选中值将以 'zhinan/shejiyuanze/yizhi' 的字符串形式存储
</p>
</template>
</demo-block>
## 远程选项
通过接口请求获取选项列表
<demo-block type="form" :config="[{
type: 'cascader',
name: 'cascader',
text: '选项',
placeholder: '请选择',
remote: true,
option: {
url: 'cascader/remote',
root: 'data',
cache: true,
timeout: 5000,
body: { query: '' },
item: (data) => data
}
}]">
<template #source>
<p>
配置 remote 为 true然后配置 option 对象,而不是 options 数组
</p>
</template>
</demo-block>
同时在 `src/main.ts` 中需要自定义实现请求:
```typescript
app.use(MagicForm, {
request: async (options: any) => {
// 自定义请求实现
},
});
```
## 动态选项
options 支持传入函数,可根据表单其他字段动态生成选项列表
```typescript
{
type: 'cascader',
name: 'cascader',
text: '选项',
options: (mForm, { model, formValue }) => {
// 根据表单值动态返回选项
return [
{ value: 'a', label: '选项A', children: [] }
];
}
}
```
## Cascader Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------|------|------|--------|--------|
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | false |
| multiple | 是否多选 | boolean | — | false |
| emitPath | 在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false则只返回该节点的值 | boolean | — | true |
| checkStrictly | 是否严格的遵守父子节点不互相关联 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | false |
| valueSeparator | 合并成字符串时的分隔符 | string / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | — |
| popperClass | 弹出内容的自定义类名 | string | — | — |
| remote | 是否为远程搜索 | boolean | — | false |
| options | 选项数据源 | Array / Function | — | — |
| option | 远程选项配置 | Object | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | — |
## options item
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------|------|------|--------|--------|
| value | 选项的值 | any | — | — |
| label | 选项的标签 | string | — | — |
| children | 子选项 | Array | — | — |
## option远程配置
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------|------|------|--------|--------|
| url | 请求地址 | string | — | — |
| root | 响应数据的根路径 | string | — | — |
| cache | 是否缓存请求结果 | boolean | — | false |
| timeout | 请求超时时间(毫秒) | number | — | — |
| body | 请求体 | Object / Function | — | — |
| item | 数据转换函数,将响应数据转换为选项格式 | Function | — | — |

View File

@ -1,4 +1,5 @@
# Checkbox 多选框
一组备选项中进行多选
## 基础用法
@ -12,7 +13,7 @@
}]">
<template #source>
<p>
要使用 Checkbox 组件只需要配置type: 'checkbox'选中意味着变量的值为true。默认绑定变量的值会是 Boolean ,选中为 true
要使用 Checkbox 组件,只需要配置 type: 'checkbox',选中意味着变量的值为 true。默认绑定变量的值会是 Boolean选中为 true。
</p>
</template>
</demo-block>
@ -29,7 +30,59 @@
}]">
<template #source>
<p>
设置 disabled 属性即可,它接受一个 Boolean true 为禁用,也可以接受一个返回 Boolean 的函数。
设置 disabled 属性即可,它接受一个 Booleantrue 为禁用,也可以接受一个返回 Boolean 的函数。
</p>
</template>
</demo-block>
## 自定义选中值
通过 `activeValue``inactiveValue` 自定义选中和未选中时的值。
<demo-block type="form" :config="[{
type: 'checkbox',
name: 'checkbox',
text: '选项',
activeValue: 'yes',
inactiveValue: 'no'
}]">
<template #source>
<p>
设置 activeValue 为选中时的值inactiveValue 为未选中时的值。
</p>
</template>
</demo-block>
## 数值类型
当需要绑定数值类型时,可以使用 `filter: 'number'` 配合默认的 activeValue/inactiveValue。
<demo-block type="form" :config="[{
type: 'checkbox',
name: 'checkbox',
text: '选项',
filter: 'number'
}]">
<template #source>
<p>
配置 filter 为 'number' 时,默认 activeValue 为 1inactiveValue 为 0。
</p>
</template>
</demo-block>
## 使用 Label 显示
通过 `useLabel` 属性控制是否使用 label 作为显示内容。
<demo-block type="form" :config="[{
type: 'checkbox',
name: 'checkbox',
text: '选项',
useLabel: true
}]">
<template #source>
<p>
设置 useLabel 为 true 时,不显示 text 内容,由外部 label 控制显示。
</p>
</template>
</demo-block>
@ -44,32 +97,84 @@
text: '选项',
options: [
{ text: '选项1', value: 1 },
{ text: '选项2', value: 2 }
{ text: '选项2', value: 2 },
{ text: '选项3', value: 3 }
]
}]">
<template #source>
<p>
checkbox-group 元素能把多个 checkbox 管理为一组。
checkbox-group 元素能把多个 checkbox 管理为一组,绑定值为数组类型
</p>
</template>
</demo-block>
## 多选框组禁用选项
在选项中设置 `disabled` 可禁用单个选项。
<demo-block type="form" :config="[{
type: 'checkbox-group',
name: 'checkbox',
text: '选项',
options: [
{ text: '选项1', value: 1 },
{ text: '选项2', value: 2, disabled: true },
{ text: '选项3', value: 3 }
]
}]">
<template #source>
<p>
在 options 中设置 disabled: true 可禁用该选项。
</p>
</template>
</demo-block>
## 动态选项
options 支持函数形式,可根据表单状态动态生成选项。
```typescript
{
type: 'checkbox-group',
name: 'checkbox',
text: '选项',
options: (mForm, { model, formValue }) => {
// 根据表单值动态返回选项
return [
{ text: '选项A', value: 'a' },
{ text: '选项B', value: 'b' }
];
}
}
```
## Checkbox Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------|------|------|--------|--------|
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| activeValue | 选中时的值 | string / number / Function | — | 1 |
| inactiveValue | 没有选中时的值 | string / number / Function | — | 0 |
| onChange | 值变化时触发的函数 | [OnChangeHandler ](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | false |
| activeValue | 选中时的值 | string / number | — | truefilter 为 'number' 时默认 1 |
| inactiveValue | 未选中时的值 | string / number | — | falsefilter 为 'number' 时默认 0 |
| useLabel | 是否使用外部 label 显示 | boolean | — | false |
| filter | 值过滤器 | 'number' / Function | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | — |
## CheckboxGroup Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------|------|------|--------|--------|
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
| options | 选项 | Array | — | - |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | false |
| options | 选项列表 | Array / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | — |
## options item
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------|------|------|--------|--------|
| value | 选项的值 | any | — | — |
| text | 选项的标签 | string | — | — |
| disabled | 是否禁用该选项 | boolean | — | false |

View File

@ -1,17 +1,86 @@
# ColorPicker 颜色选择器
用于颜色选择,支持多种格式。
用于颜色选择,支持多种颜色格式,包括透明度设置
## 基础用法
<demo-block type="form" :config="[{
text: '颜色选择器',
type: 'colorPicker',
name: 'color',
name: 'color'
}]">
<template #source>
<p>
在开启多选模式后默认情况下会展示所有已选中的选项的Tag
type 为 'colorPicker'默认支持透明度选择showAlpha: true
</p>
</template>
</demo-block>
## 禁用状态
<demo-block type="form" :config="[{
text: '颜色选择器',
type: 'colorPicker',
name: 'color',
disabled: true
}]">
<template #source>
<p>
设置 disabled 属性可禁用颜色选择器。
</p>
</template>
</demo-block>
## 设置默认值
<demo-block type="form" :config="[{
text: '颜色选择器',
type: 'colorPicker',
name: 'color',
defaultValue: '#409EFF'
}]">
<template #source>
<p>
通过 defaultValue 设置默认颜色值。
</p>
</template>
</demo-block>
## 带透明度的颜色
颜色选择器默认开启透明度选择,返回值为 rgba 格式。
<demo-block type="form" :config="[{
text: '颜色选择器',
type: 'colorPicker',
name: 'color',
defaultValue: 'rgba(64, 158, 255, 0.5)'
}]">
<template #source>
<p>
支持 rgba 格式的颜色值,可以设置透明度。
</p>
</template>
</demo-block>
## ColorPicker Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------|------|------|--------|--------|
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | false |
| defaultValue | 默认颜色值 | string | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form-schema/src/base.ts) | — | — |
## 颜色格式说明
支持以下颜色格式:
| 格式 | 示例 | 说明 |
|------|------|------|
| HEX | #409EFF | 十六进制颜色值 |
| RGB | rgb(64, 158, 255) | RGB 颜色值 |
| RGBA | rgba(64, 158, 255, 0.5) | 带透明度的 RGBA 颜色值 |
| HSL | hsl(210, 100%, 63%) | HSL 颜色值 |
| HSLA | hsla(210, 100%, 63%, 0.5) | 带透明度的 HSLA 颜色值 |

View File

@ -11,7 +11,7 @@
}]">
<template #source>
<p>
在开启多选模式后默认情况下会展示所有已选中的选项的Tag
以日期为基本单位,基础的日期选择控件
</p>
</template>
</demo-block>
@ -26,15 +26,31 @@
}]">
<template #source>
<p>
在开启多选模式后默认情况下会展示所有已选中的选项的Tag
通过 <code>disabled</code> 属性禁用日期选择器
</p>
</template>
</demo-block>
## 日期格式
## 占位符
<demo-block type="form" :config="[{
type: 'date',
name: 'date',
text: '日期选择器',
placeholder: '请选择日期'
}]">
<template #source>
<p>
通过 <code>placeholder</code> 属性设置输入框占位文本
</p>
</template>
</demo-block>
## 日期格式
使用`format`指定输入框的格式;使用`valueFormat`指定绑定值的格式。
默认情况下,组件接受并返回`Date`对象。以下为可用的格式化字串,以 UTC 2017年1月2日 03:04:05 为例:
默认情况下,组件`format` 默认值为 `YYYY/MM/DD``valueFormat` 默认值为 `YYYY/MM/DD`。以下为可用的格式化字串,以 UTC 2017年1月2日 03:04:05 为例:
:::warning
请注意大小写
@ -42,13 +58,11 @@
| 格式 | 含义 | 备注 | 举例 |
|------|------|------|------|
| `yyyy` | 年 | | 2017 |
| `YYYY` | 年 | | 2017 |
| `M` | 月 | 不补0 | 1 |
| `MM` | 月 | | 01 |
| `W` | 周 | 仅周选择器的 `format` 可用不补0 | 1 |
| `WW` | 周 | 仅周选择器的 `format` 可用 | 01 |
| `d` | 日 | 不补0 | 2 |
| `dd` | 日 | | 02 |
| `D` | 日 | 不补0 | 2 |
| `DD` | 日 | | 02 |
| `H` | 小时 | 24小时制不补0 | 3 |
| `HH` | 小时 | 24小时制 | 03 |
| `h` | 小时 | 12小时制须和 `A``a` 使用不补0 | 3 |
@ -57,30 +71,42 @@
| `mm` | 分钟 | | 04 |
| `s` | 秒 | 不补0 | 5 |
| `ss` | 秒 | | 05 |
| `timestamp` | JS时间戳 | 组件绑定值为`number`类型 | 1483326245000 |
| `x` | JS时间戳 | 组件绑定值为`number`类型 | 1483326245000 |
| `[MM]` | 不需要格式化字符 | 使用方括号标识不需要格式化的字符 (如 [A] [MM]) | MM |
<demo-block type="form" :config="[{
type: 'date',
name: 'date',
text: '日期选择器',
valueFormat: 'timestamp'
format: 'YYYY-MM-DD',
valueFormat: 'x'
}]">
<template #source>
<p>
在开启多选模式后默认情况下会展示所有已选中的选项的Tag
设置 <code>valueFormat</code><code>timestamp</code>,绑定值将返回时间戳格式
</p>
</template>
</demo-block>
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| value-format | 可选,绑定值的格式。不指定则绑定值为 Date 对象 | string | 见[日期格式](#/zh-CN/component/date-picker#ri-qi-ge-shi) | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
| name | 绑定值的字段名 | string | — | — |
| text | 表单标签 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| format | 显示在输入框中的格式 | string | 见[日期格式](#日期格式) | YYYY/MM/DD |
| valueFormat | 绑定值的格式。不指定则绑定值为 Date 对象 | string | 见[日期格式](#日期格式) | YYYY/MM/DD |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | — |
## TypeScript 定义
```typescript
interface DateConfig extends FormItem, Input {
type: 'date';
format?: 'YYYY-MM-dd HH:mm:ss' | string;
valueFormat?: 'YYYY-MM-dd HH:mm:ss' | string;
}
```

View File

@ -0,0 +1,46 @@
# DateRangePicker 日期范围选择器
用于选择或输入日期范围
## 基础用法
<demo-block type="form" :config="[{
type: 'daterange',
name: 'daterange',
text: '日期范围'
}]">
<template #source>
<p>
type为'daterange'
</p>
</template>
</demo-block>
## 绑定多个字段
可以通过配置 `names` 来将日期范围绑定到两个不同的字段上。
<demo-block type="form" :config="[{
type: 'daterange',
names: ['startTime', 'endTime'],
text: '日期范围'
}]">
<template #source>
<p>
配置 names 属性,将开始时间和结束时间分别绑定到 startTime 和 endTime 字段。
</p>
</template>
</demo-block>
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| name | 绑定值(数组形式) | string | — | — |
| names | 绑定值(拆分为两个字段) | string[] | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| dateFormat | 日期格式 | string | — | YYYY/MM/DD |
| timeFormat | 时间格式 | string | — | HH:mm:ss |
| valueFormat | 绑定值的格式 | string | — | YYYY/MM/DD HH:mm:ss |
| defaultTime | 默认时间 | Date[] | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -11,7 +11,22 @@
}]">
<template #source>
<p>
在开启多选模式后默认情况下会展示所有已选中的选项的Tag
通过设置 <code>type: 'datetime'</code> 使用日期时间选择器,可以同时选择日期和时间。
</p>
</template>
</demo-block>
## 带占位符
<demo-block type="form" :config="[{
type: 'datetime',
name: 'dateTime',
text: '日期时间选择器',
placeholder: '请选择日期时间'
}]">
<template #source>
<p>
通过 <code>placeholder</code> 属性设置输入框的占位文本。
</p>
</template>
</demo-block>
@ -26,16 +41,16 @@
}]">
<template #source>
<p>
在开启多选模式后默认情况下会展示所有已选中的选项的Tag
通过 <code>disabled</code> 属性禁用日期时间选择器,支持布尔值或函数。
</p>
</template>
</demo-block>
## 日期格式
## 日期格式
使用`format`指定输入框的格式;使用`valueFormat`指定绑定值的格式。
使用 `format` 指定输入框的格式;使用 `valueFormat` 指定绑定值的格式。
默认情况下,组件接受并返回`Date`对象。以下为可用的格式化字串,以 UTC 2017年1月2日 03:04:05 为例:
默认情况下,组件接受并返回格式化后的字符串。以下为可用的格式化字串,以 UTC 2017年1月2日 03:04:05 为例:
:::warning
请注意大小写
@ -43,13 +58,11 @@
| 格式 | 含义 | 备注 | 举例 |
|------|------|------|------|
| `yyyy` | 年 | | 2017 |
| `YYYY` | 年 | | 2017 |
| `M` | 月 | 不补0 | 1 |
| `MM` | 月 | | 01 |
| `W` | 周 | 仅周选择器的 `format` 可用不补0 | 1 |
| `WW` | 周 | 仅周选择器的 `format` 可用 | 01 |
| `d` | 日 | 不补0 | 2 |
| `dd` | 日 | | 02 |
| `D` | 日 | 不补0 | 2 |
| `DD` | 日 | | 02 |
| `H` | 小时 | 24小时制不补0 | 3 |
| `HH` | 小时 | 24小时制 | 03 |
| `h` | 小时 | 12小时制须和 `A``a` 使用不补0 | 3 |
@ -60,29 +73,32 @@
| `ss` | 秒 | | 05 |
| `A` | AM/PM | 仅 `format` 可用,大写 | AM |
| `a` | am/pm | 仅 `format` 可用,小写 | am |
| `timestamp` | JS时间戳 | 仅 `valueFormat` 可用;组件绑定值为`number`类型 | 1483326245000 |
| `[MM]` | 不需要格式化字符 | 使用方括号标识不需要格式化的字符 (如 [A] [MM]) | MM |
| `x` | JS时间戳毫秒 | 仅 `valueFormat` 可用 | 1483326245000 |
| `X` | Unix时间戳 | 仅 `valueFormat` 可用 | 1483326245 |
<demo-block type="form" :config="[{
type: 'datetime',
name: 'dateTime',
text: '日期时间选择器',
format: 'yyyy-MM-dd',
valueFormat: 'timestamp'
format: 'YYYY-MM-DD HH:mm',
valueFormat: 'x'
}]">
<template #source>
<p>
在开启多选模式后默认情况下会展示所有已选中的选项的Tag
自定义格式化:显示格式为 <code>YYYY-MM-DD HH:mm</code>,绑定值格式为时间戳。
</p>
</template>
</demo-block>
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| name | 绑定值 | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| format | 显示在输入框中的格式 | string | 见[日期格式](#/zh-CN/component/date-picker#ri-qi-ge-shi) | yyyy-MM-dd HH:mm:ss |
| value-format | 可选,绑定值的格式。不指定则绑定值为 Date 对象 | string | 见[日期格式](#/zh-CN/component/date-picker#ri-qi-ge-shi) | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
| name | 绑定值的字段名 | string | — | — |
| text | 表单标签 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| format | 显示在输入框中的格式 | string | 见[日期格式](#日期格式) | YYYY/MM/DD HH:mm:ss |
| valueFormat | 绑定值的格式 | string | 见[日期格式](#日期格式) | YYYY/MM/DD HH:mm:ss |
| defaultTime | 选择日期后的默认时间值 | Date | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | — |

View File

@ -0,0 +1,52 @@
# DynamicField 动态表单
根据模型中某个字段的值,动态生成一组表单字段。
## 基础用法
<demo-block type="form" :config="[{
type: 'select',
name: 'type',
text: '类型',
options: [
{ label: '类型A', value: 'a' },
{ label: '类型B', value: 'b' }
]
}, {
type: 'dynamic-field',
text: '动态字段',
dynamicKey: 'type',
returnFields: async (config, model, request) => {
if (model.type === 'a') {
return [{ name: 'fieldA', label: '字段A', defaultValue: 'valueA' }];
} else if (model.type === 'b') {
return [{ name: 'fieldB', label: '字段B', defaultValue: 'valueB' }];
}
return [];
}
}]">
<template #source>
<p>
当“类型”发生变化时,“动态字段”会根据 `returnFields` 返回的配置生成不同的输入框。
</p>
</template>
</demo-block>
:::warning
特别注意:`dynamic-field` 的上一级配置必须设置 `extensible: true`,才能保存未在 schema 中声明的动态字段。
:::
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| type | 组件类型 | string | dynamic-field | — |
| text | 表单标签 | string | — | — |
| dynamicKey | 监听的字段名。当该字段值变化时,触发 `returnFields` 重新计算 | string | — | — |
| returnFields | 返回字段列表的函数 | (config, model, request) => Promise<Field[]> | — | — |
### Field 对象结构
| 参数 | 说明 | 类型 | 默认值 |
|---------- |-------------- |---------- |-------- |
| name | 字段名 | string | — |
| label | 标签名 | string | — |
| defaultValue | 默认值 | any | — |

View File

@ -0,0 +1,26 @@
# NumberRange 数字范围输入框
用于输入数字范围
## 基础用法
<demo-block type="form" :config="[{
type: 'number-range',
name: 'numberRange',
text: '数字范围'
}]">
<template #source>
<p>
type为'number-range'
</p>
</template>
</demo-block>
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| name | 绑定值(数组形式 [min, max] | string | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| clearable | 是否可清空 | boolean | — | true |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -53,10 +53,11 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|----------|-------------- |----------|-------------------------------- |-------- |
| name | 绑定值 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| text | 表单标签 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| min | 设置计数器允许的最小值 | number | — | -Infinity |
| max | 设置计数器允许的最大值 | number | — | Infinity |
| step | 计数器步长 | number | — | 1 |
| tooltip | 输入框提示信息 | string | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -5,8 +5,8 @@
## TS 定义
```typescript
interface RedioGroup extends FormItem {
type: 'redioGroup';
interface RadioGroup extends FormItem {
type: 'radio-group';
options: {
value: any;
text: string;

View File

@ -162,6 +162,15 @@
</template>
</demo-block>
同时在 `src/main.ts` 中需要自定义实现请求
```typescript
app.use(MagicForm, {
request: async (options: any) => {
// 自定义请求实现
},
});
```
:::tip
如果 Select 的绑定值为对象类型,请务必指定 valueKey 作为它的唯一性标识。
:::

View File

@ -110,15 +110,16 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| name | 绑定值 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| text | 表单标签 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| tooltip | 输入时显示内容 | boolean | — | false |
| placeholder | 输入框占位文本 | string | — | — |
| clearable | 是否可清空 | boolean | — | true |
| tooltip | 输入时显示内容 | string | — | — |
| trim | 是否去掉首尾空格 | boolean | — | false |
| filter | 过滤值 | string / Function | number | - |
| onChange | 值变化时触发的函数 | [OnChangeHandler ](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
| prepend | 前置内容 | string | — | - |
| append | 后置内容 | string / Object | — | - |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |
## append Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |

View File

@ -0,0 +1,45 @@
# TimeRangePicker 时间范围选择器
用于选择或输入时间范围
## 基础用法
<demo-block type="form" :config="[{
type: 'timerange',
name: 'timerange',
text: '时间范围'
}]">
<template #source>
<p>
type为'timerange'
</p>
</template>
</demo-block>
## 绑定多个字段
可以通过配置 `names` 来将时间范围绑定到两个不同的字段上。
<demo-block type="form" :config="[{
type: 'timerange',
names: ['startTime', 'endTime'],
text: '时间范围'
}]">
<template #source>
<p>
配置 names 属性,将开始时间和结束时间分别绑定到 startTime 和 endTime 字段。
</p>
</template>
</demo-block>
## Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| name | 绑定值(数组形式) | string | — | — |
| names | 绑定值(拆分为两个字段) | string[] | — | — |
| text | 表单标签 | string | — | — |
| disabled | 是否禁用 | boolean / [FilterFunction](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | false |
| format | 显示格式 | string | — | HH:mm:ss |
| valueFormat | 绑定值的格式 | string | — | HH:mm:ss |
| defaultTime | 默认时间 | Date[] | — | — |
| onChange | 值变化时触发的函数 | [OnChangeHandler](https://github.com/Tencent/tmagic-editor/blob/master/packages/form/src/schema.ts) | — | - |

View File

@ -178,3 +178,38 @@
label: '配置1',
}]
}]"></demo-block>
### step
<demo-block type="form" :config="[{
type: 'step',
items: [{
title: '步骤1',
items: [{
name: 'text',
text: '配置1',
}]
}, {
title: '步骤2',
items: [{
name: 'text2',
text: '配置2',
}]
}]
}]"></demo-block>
### flex-layout
<demo-block type="form" :config="[{
type: 'flex-layout',
gap: '20px',
items: [{
name: 'text',
text: '配置1',
span: 12
}, {
name: 'text2',
text: '配置2',
span: 12
}]
}]"></demo-block>

View File

@ -3,10 +3,10 @@
## 能力展示
代码块支持的能力有
1、在线编辑
2、参数定义包括参数类型定义
3、自动保存草稿
4、参数注释
- 1、在线编辑
- 2、参数定义包括参数类型定义
- 3、自动保存草稿
- 4、参数注释
下面将主要介绍代码块的实现原理包含dsl结构定义以及代码块挂载执行时机等
## 协议描述
我们将在线编写的代码内容保存在[DSL](../advanced/js-schema.md)中与app同一层级这样的好处是代码块可以在同一活动不同页面中实现灵活编排。
@ -38,7 +38,7 @@
在页面中创建代码块也就是会将新的代码内容添加到DSL中的codeBlocks数组并保存下来这里涉及的逻辑可以参见CodeBlock类中的[setCodeDslById](https://github.com/Tencent/tmagic-editor/blob/c143a5f7670ae61d80c1a2cfcc780cfb5259849d/packages/editor/src/services/codeBlock.ts#L107)方法。
并且可以在编辑器左侧的“代码块”tab下看到当前活动的代码块列表
<img src="https://vip.image.video.qpic.cn/vupload/20230228/4d17861677585336888.png" alt="代码块列表">
<img src="/code-block.png" alt="代码块列表">
## 组件绑定
代码块的初衷是为了实现对组件逻辑的在线干预代码执行的时机平台提供了组件created, mounted两个钩子因此我们需要将创建的代码与组件进行关联。
@ -78,7 +78,7 @@
## 代码块界面展示
侧边栏的代码块列表可以查看当前创建的代码块以及每个代码块绑定的组件点击代码块下方展示的组件icon可以在画布中选中该组件
<img src="https://vip.image.video.qpic.cn/vupload/20230228/92dcfe1677636899649.png" alt="代码块列表">
<img src="/code-block-list.png" alt="代码块列表">
代码块编辑面板,可以在这里编写代码内容,申明参数
<img src="https://vip.image.video.qpic.cn/vupload/20230228/1fd2e11677637006239.png" alt="代码块编辑面板">

View File

@ -56,7 +56,7 @@ export default {
};
```
其中events 的 value 是个事件名,是 `string` 类型,了避免和其他组件事件名重复,应该添加上一些前缀。
其中events 的 value 是个事件名,是 `string` 类型,了避免和其他组件事件名重复,应该添加上一些前缀。
而 methods 中的 value 则是一个挂载在组件上的可执行函数。我们会在事件触发时,分发到对应组件上,并执行对应组件实例上的方法。
@ -83,30 +83,29 @@ export default {
</template>
<script lang="ts" setup>
import { defineComponent, inject } from 'vue';
import { type ComponentProps, registerNodeHooks, useApp } from '@tmagic/vue-runtime-help';
const props = defineProps({
config: {
type: Object,
default: () => ({}),
},
})
const props = defineProps<ComponentProps>()
const app: Core | undefined = inject('app');
const node = app?.page?.getNode(props.config.id);
const { app, node } = useApp(props);
const onClick = () => {
// app.emit 第一个参数为事件名,其余参数为你要传给接受事件组件的参数
app?.emit("yourComponent:finishSomething", node, /*可以传参给接收方*/);
app.emit("yourComponent:finishSomething", node, /*可以传参给接收方*/);
};
// 此处实现事件动作
const toast = () => {
toast('测试 vue3')
};
// 实际触发时是调用node上的方法所以需要将改方法暴露到node上
registerNodeHooks(node, {
toast,
});
defineExpose({
// 此处实现事件动作
// 实际触发时是调用vue实例上的方法所以需要将改方法暴露到实例上
toast: (/*触发组件node*/, /*接收触发事件组件传进来的参数*/) => {
toast('测试 vue3')
}
toast,
});
</script>
```
@ -151,10 +150,3 @@ function Test({ config }) {
export default Test;
```
按照上述实现触发事件和事件动作,就可以完成组件的联动事件分发响应。
:::tip
组件事件的联动是借助了@tmagic/core,需要在组件实例化的时候将需要暴露的方法提供给@tmagic/core在上述例子中useApp方法的调用就是完成这个操作useApp返回的app对象就是@tmagic/core的实例。在vue的实现中useApp是将整个vue实例都提供给了app所以需要defineExpose来定义vue instance上的方法react则是将需要暴露的方法作为useApp的参数传入
:::

View File

@ -0,0 +1,105 @@
# 数据源
## 使用数据源
### 添加数据源
在编辑器左侧边栏中选中数据源,在数据源面板右上角添加中选择对应的数据源类型(默认提供了两种基础的数据源)
[![alt 数据源列表](/data-source.png "数据源列表")](/data-source.png){target="_blank"}
### 配置属性字段
[![alt 新增数据源](/create-data-source.png "新增数据源")](/create-data-source.png){target="_blank"}
#### 基础数据源
静态数据,不会自动更新,可以通过配置方法,在方法中更新数据源
```js
({ dataSource, app }) => {
dataSource.setData({
// 数据
});
}
```
然后再组件的事件联动中关联此方法,来触发数据源更新
#### HTTP数据源
通过配置HTTP相关参数(url, query, body, header等)通过网络api获取数据该数据源拥有request方法可通过此方法来刷新数据源
```js
({ dataSource, app }) => {
dataSource.request();
}
```
### 在组件中使用
#### 数据源模板输入框data-source-input
formConfig.js
```js
[
{
type: 'data-source-input'
}
]
```
[![alt 数据源模版](/data-source-input.png "数据源模版")](/data-source-input.png){target="_blank"}
#### 数据源字段选择器输入框data-source-field-select)
formConfig.js
```js
[
{
type: 'data-source-filed-select'
}
]
```
#### 数据源选择器data-source-select)
formConfig.js
```js
[
{
type: 'data-source-select'
}
]
```
#### 数据源方法选择器data-source-method-select)
formConfig.js
```js
[
{
type: 'data-source-method-select'
}
]
```
#### 显示条件
当配置的条件成立时显示,反之隐藏
[![alt 显示条件](/display-cond.png "显示条件")](/display-cond.png){target="_blank"}
## 数据源开发
### 数据源规范
数据源的基础形式,需要有四个文件
- index 入口文件,引入下面几个文件
- formConfig 表单配置描述
- initValue 表单初始值
- event 定义联动事件,具体可以参考[组件联动](./coupling.html#组件联动)
- dataSource 数据源逻辑代码

View File

@ -60,6 +60,5 @@ export default defineComponent({
## 渲染器示例
在tmagic-editor的示例项目中我们提供了三个版本的 @tmagic/ui。可以参考对应前端框架的渲染器实现。
- [vue3 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/packages/ui/src/container/src/Container.vue)
- [vue2 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/packages/ui-vue2/src/container/Container.vue)
- [react 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/packages/ui-react/src/container/Container.tsx)
- [vue 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/vue-components/container/src/Container.vue)
- [react 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/react-components/container/src/Container.tsx)

View File

@ -5,15 +5,13 @@ tmagic-editor的设计是希望发布的页面支持多个前端框架即各
所以tmagic-editor的设计中针对每个前端框架都需要有一个对应的 @tmagic/ui 来承担渲染器职责。同时,也需要一个使用和 @tmagic/ui 相同前端框架的 runtime 来 @tmagic/ui 和业务组件的,具体 runtime 概念,可以参考[页面发布](../publish)。
@tmagic/ui 在tmagic-editor设计中承担的是业务逻辑无关的基础组件渲染的功能。一切和业务相关的逻辑都应该在 [runtime](../runtime.html) 中实现。这样 @tmagic/ui 就能保持其通用性。
我们以项目代码中提供的 vue3 版本的 @tmagic/ui 作为示例介绍其中包含的内容。
我们以项目代码中提供的 vue 版本的 [vue-components](https://tencent.github.io/tmagic-editor/vue-components) 作为示例介绍其中包含的内容。
## 渲染器
在 vue3 中,实现渲染器的具体形式参考[页面渲染](../advanced/page)中描述的[容器渲染](../advanced/page.html#容器渲染)和[组件渲染](../advanced/page.html#容器渲染)。
在 vue 中,实现渲染器的具体形式参考[页面渲染](../advanced/page)中描述的[容器渲染](../advanced/page.html#容器渲染)和[组件渲染](../advanced/page.html#容器渲染)。
## 基础组件
@tmagic/ui vue3 中,我们提供了几个基础组件,可以在项目源码中找到对应内容。
[vue-components](https://tencent.github.io/tmagic-editor/vue-components) 中,我们提供了几个基础组件,可以在项目源码中找到对应内容。
- page tmagic-editor的页面基础
- container tmagic-editor的容器渲染器
@ -23,8 +21,3 @@ tmagic-editor的设计是希望发布的页面支持多个前端框架即各
其中 page/container/Component 是 UI 的基础,是每个框架的 UI 都应该实现的。
button/text 其实就是一个组件开发的示例,具体组件开发相关规范可以参考[组件开发](../component)。
## @tmagic/ui 示例
- [vue3 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/packages/ui)
- [vue2 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/packages/ui-vue2)
- [react 渲染器](https://github.com/Tencent/tmagic-editor/blob/master/packages/ui-react)

View File

@ -1,28 +1,48 @@
# 如何开发一个组件
tmagic-editor支持业务方进行自定义组件开发。在tmagic-editor中组件是以 npm 包形式存在的组件和插件只要按照规范开发就可以在tmagic-editor的 runtime 中被加入并正确渲染组件。
## 组件开发
以 vue3 的组件开发为例。运行项目中的 playground 示例,会自动加载 vue3 的 runtime。runtime会加载[@tmagic/ui](https://github.com/Tencent/tmagic-editor/tree/master/packages/ui)
## 组件注册
在 [playground](https://tencent.github.io/tmagic-editor/playground/index.html#/) 中,我们可以尝试点击添加一个组件,在模拟器区域里,就会出现这个组件。其中就涉及到组件注册。
这一步需要开发者基于tmagic-editor搭建了平台后实现组件列表的注册、获取机制tmagic-editor组件注册其实就是保存好组件 `type` 的映射关系。`type` 可以参考[组件介绍](../guide/conception.html#组件)。
可以参考 vue3 版本的 @tmagic/ui 中,[组件渲染](../guide/advanced/page.html#组件渲染)逻辑里type 会作为组件名进入渲染。所以在 vue3 的组件开发中,我们也需要在为 vue 组件声明 name 字段时,和 type 值对应起来,才能正确渲染组件。
### 组件规范
组件的基础形式,需要有四个文件
- index 入口文件,引入下面几个文件
- formConfig 表单配置描述
- initValue 表单初始值
- form-config 表单配置描述
- init-value 表单初始值
- event 定义联动事件,具体可以参考[组件联动](../guide/advanced/coupling.html#组件联动)
- component.{vue,jsx} 组件样式、逻辑代码
@tmagic/ui 中的 button/text 就是基础的组件示例。我们要求声明 index 入口,因为我们希望在后续的配套打包工具实现上,可以有一个统一规范入口。
### 1. 创建组件
在项目中,如 runtime vue3 目录中,创建一个名为 test-component 的组件目录,其中包含上面四个规范文件。
可以使用`npm create tmagic` 选择 `components:组件库(组件/插件/数据源)` 来快速创建一个组件库。
然后继续使用`npm create tmagic` 选择 `component:组件` 来快速创建一个组件。
:::tip
组件库并不是必须,组件如何管理可以根据具体情况来选择。直接放到 runtime 目录中也是一个不错的选择如果选择放到runtime中可以在runtime中的package.json添加
```json
{
"createTmagic": {
"componentsPath": "./components",
"pluginsPath": "./plugins",
"dataSourcesPath": "./dataSources"
}
}
```
来指定组件库的路径。这样在使用`npm create tmagic` 来创建组件时,会自动将组件添加到组件库中。
:::
:::tip
如需为组件添加npm scope name可以在runtime中的package.json中添加
```json
{
"createTmagic": {
"npmScopeName": "@tmagic"
}
}
```
:::
手动创建组件,可以在项目中,如 runtime 目录中,创建一个名为 test-component 的组件目录,其中包含上面四个规范文件。
```javascript
// index.js
// vue
@ -30,14 +50,18 @@ import Test from './Test.vue';
// react
import Test from './Test.tsx';
export { default as config } from './formConfig';
export { default as value } from './initValue';
export { default as config } from './form-config';
export { default as value } from './init-value';
export default Test;
```
:::tip
如果在runtime中使用了@tmagic/cli,则必须保持此规范;不使用则可以自由书写。
:::
```javascript
// formConfig.js
// form-config.js
export default [
{
type: 'select',
@ -61,15 +85,40 @@ export default [
];
```
:::tip
配置内容必须是一个数组,每个元素是一个对象,包含 type、text、name 等属性,每个对象代表一个表单项。
type 是表单项的类型
text 是表单项的文本
name 是表单项值的key。
上述实例对应生成的值为
```json
{
"color": "red",
"text": "一段文字",
}
```
type 在@tmagic/form@tmagic/editor 中默认提供了一些,@tmagic/form提供的可以前往[表单配置](/form-config/fields/text.html)查看。
:::
```javascript
// initValue.js
// init-value.js
export default {
color: 'red',
text: '一段文字',
};
```
vue3 版本的组件代码示例
:::tip
在编辑器中添加组件时使用,作为初始值。
:::
Vue版本的组件代码示例
```vue
<!-- Test.vue -->
<template>
@ -79,22 +128,24 @@ vue3 版本的组件代码示例
</div>
</template>
<script>
export default {
<script setup>
defineOptions({
name: 'magic-ui-test',
});
props: {
config: {
type: Object,
default: () => ({}),
},
defineProps({
config: {
type: Object,
default: () => ({}),
},
setup() {},
};
}):
</script>
```
:::tip
编辑器中配置的 config 对象,会作为 props 传入组件中。
:::
react 版本组件代码示例
```javascript
// Test.tsx
@ -118,83 +169,52 @@ export default Test;
```
### 2. 使用tmagic-cli
在 runtime vue3 中,我们已经提供好一份示例。在 tmagic.config.ts 文件中。只需要在 packages 加入你创建的组件的路径(如果是个 npm 包,则将路径替换为包名即可),打包工具就会自动识别到你的组件。
## 插件开发
插件开发和组件开发形式类似,但是插件开发不需要有组件的规范。
我们只需要在插件中提供一个入口文件。插件需要提供一个 install 方法。
### 3. 启动 playground
在上面的步骤完成后,在 playground/src/configs/componentGroupList 中。找到组件栏的基础组件列表,在其中加入你的开发组件
```javascript
{
title: '基础组件',
items: [
// 在Vue的runtime中
export default {
install(vueApp, { app: tmagicApp }) {}
}
```
```javascript
// 在React的runtime中
export default {
install({ app: tmagicApp }) {}
}
```
在插件中开发者可以自由实现需要的业务逻辑。
## 集成到runtime中
### 使用@tmagic/cli
在使用`npm create tmagic` 创建的runtime中自动集成了@tmagic/cli将组件集成到此runtime中只需要在`tmagic.config.ts`中的packages字段中添加
```javascript
import { defineConfig } from '@tmagic/cli';
export default defineConfig({
// other config
packages: [
{
text: '文本',
type: 'text',
},
{
text: '按钮',
type: 'button',
},
// 加入这个测试组件
{
text: '测试',
type: 'test',
'组件type': '组件目录或者npm包名',
},
],
}
```
然后,在 magic 项目根目录中,运行
});
```
npm run playground
```
至此,我们打开 playground 后,就能添加开发的中的组件,并且得到这个开发中的组件**在编辑器中的表现**了。
:::tip
组件type需要与[componentGroupList](../api/editor/props.html#componentgrouplist)中的type对应。
:::
<img src="https://image.video.qpic.cn/oa_fd3c9c-3_548108267_1636719045199471">
### 4. 启动 runtime
在完成开发中组件在编辑器中的实现后,我们将编辑器中的 DSL 源码📄 打开,复制 DSL。并在 runtime/vue3/src/page 下。创建一个 page-config.js 文件。将 DSL 作为配置导出。
配置到packages字段中后执行`npm run tmagic`来创建组件库的入口文件。
```javascript
window.magicDSL = [
// DSL
]
```
然后使用`npm run build:libs`命令来构建用于编辑器中的组件配置、组件初始值、组件事件联动的资源文件。
在 page/main.ts 中,将这份配置读入
```javascript
import './page-config.js';
```
然后执行在 runtime/vue3 目录下执行
```
npm run start
```
至此,我们就可以得到这个开发中组件在编辑器中进行了配置并保存后,在真实页面中应该有的样子。
<img src="https://image.video.qpic.cn/oa_fd3c9c-3_1731965034_1636719708671597?imageView2/q/70" width="50%">
## 插件开发
插件开发和组件开发形式类似,但是插件开发不需要有组件的规范。在以 vue 为基础的 ui 和 runtime 中,插件其实就是一个 vue 插件。
我们只需要在插件中提供一个入口文件,其中包含 vue 的 install 方法即可。
```javascript
export default {
install() {}
}
```
在插件中开发者可以自由实现需要的业务逻辑。插件和组件一样,只需要在 units.js 中,加入导出的 units 对象里即可。
## 业务定制
上述的步骤,如
1. 组件/插件初始化
2. 编辑器中的组件调试
3. 真实页面的组件调试
4. 编辑器中的 DSL 同步至本地调试页面
等许多步骤,都可以交由业务方进行定制,开发业务自定义的脚手架工具,或者如示例中一样,使用打包脚本来处理。

View File

@ -1,6 +1,8 @@
# 基础概念
我们通过讲述tmagic-editor的一些基础概念。帮助开发者可以了解tmagic-editor是如何运行以及如何在基础项目之上开发、使用它。
[![alt 原理](/flow.png "原理")](/flow.png){target="_blank"}
## 编辑器
编辑器基础布局上分为:左面板、工作区、右面板、工具栏,如下图。
- **左面板**,包含了组件库的展示,以及工作区中已添加组件的组件树展示。
@ -58,11 +60,6 @@ DSL 是编辑器搭建页面的最终产物(描述文件),其中包含了
### runtime
我们把页面统一称为 runtime更具体的 runtime 概念可以查看[页面发布](./publish.html#runtime)。**runtime 是承载tmagic-editor项目页面的运行环境**。编辑器的工作区是 runtime 的一个具体实例,另一个就是我们发布上线后,用户访问的真实项目页面。
### @tmagic/ui
@tmagic/ui 包含了tmagic-editor的基础组件库提供了容器、文本、按钮这样的基础组件。我们提供了不同语言框架的 @tmagic/ui,如 vue2 和 vue3。
@tmagic/ui 和 runtime 是配套出现的runtime 必须基于 @tmagic/ui 才可以实现渲染。因为 @tmagic/ui 需要提供 runtime 所需要的渲染器。
## 联动
页面搭建过程中,会涉及到两种联动形式
- 在编辑器中,组件的表单配置项之间需要联动。
@ -73,4 +70,4 @@ DSL 是编辑器搭建页面的最终产物(描述文件),其中包含了
### 组件联动
组件 A 在完成点击事件后,希望组件 B 可以展示一个弹窗就是组件联动的一个示例。tmagic-editor通过事件绑定方式可以为组件 A 和 B 配置事件关联,实现上述的组件联动。
<img src="https://image.video.qpic.cn/oa_88b7d-37_723692309_1636032154483681" alt="组件联动">
<img src="https://vip.image.video.qpic.cn/vupload/20231027/3e02d31698914788006.png" alt="组件联动">

View File

@ -1,5 +1,220 @@
# 编辑器扩展
编辑器布局组成部分名称如下图,后续将直接使用图中名称指代其部分
<img src="/layout.png" width="100%">
## UI扩展
### 一、顶部菜单栏定制
通常使用 `m-editor` 组件的 [menu](/api/editor/props.html#menu) `prop` 来对齐进行设置;
顶部菜单栏分为`左` `中` `右`三个部分组成,所以 [menu](/api/editor/props.html#menu) `prop`的数据格式如下:
```js
{ left: [], center: [], right: [] }
```
数组的内容可以有三种种形式:`内部定义好的字符串``其他字符串``MenuButton 或者 MenuComponent 对象`
#### 1. 内部定义好的字符串:
```ts
'/' | 'delete' | 'undo' | 'redo' | 'zoom' | 'zoom-in' | 'zoom-out' | 'guides' | 'rule' | 'scale-to-original' | 'scale-to-fit'
```
是组件内部定义的可直接使用的内置功能,具体含义可以查看 [menu](/api/editor/props.html#menu)
#### 2. 其他字符串
除去[内部定好的字符串](#内部定义好的字符串)的其他字符串,则会被当成普通文本直接显示
#### 3. `MenuButton` 或者 `MenuComponent` 对象
MenuButton 的[定义](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/editor/src/type.ts#L168)
用于自定义一个按钮,例如定义一个返回按钮可以由如下配置实现
```js
{
type: 'buuton',
text: '返回',
handler: () => window.history.back(),
}
```
如果需要更复杂的功能则可以使用 `MenuComponent`, 可以用于实现渲染任意一个Vue组件
`MenuComponent` 的[定义](https://github.com/Tencent/tmagic-editor/blob/239b5d3efeae916a8cf3e3566d88063ecccc0553/packages/editor/src/type.ts#L197C18-L197C32)
:::tip
如果对内置的顶部菜单栏实现不满意还可以使用自定义的实现完全替换掉
```html
<m-editor>
<template #nav>
<your-nav></your-nav>
</template>
</m-editor>
```
:::
### 二、左侧菜单栏
左侧菜单栏主要展示组件列表、组件树、代码块、数据源等内容。可以通过 `m-editor` 组件的 [sidebar](/api/editor/props.html#sidebar) `prop` 来进行配置。
#### 1. 自定义左侧面板
可以使用 `sidebar` slot 来完全自定义左侧面板:
```html
<m-editor>
<template #sidebar>
<your-sidebar></your-sidebar>
</template>
</m-editor>
```
#### 2. 扩展组件列表
通过 [componentGroupList](/api/editor/props.html#componentgrouplist) prop 配置组件分组和列表:
```js
const componentGroupList = [
{
title: '基础组件',
items: [
{
text: '文本',
type: 'text',
icon: 'text-icon'
},
{
text: '按钮',
type: 'button',
icon: 'button-icon'
}
]
},
{
title: '业务组件',
items: [
// 自定义业务组件
]
}
]
```
#### 3. 组件树扩展
组件树会自动根据页面配置生成,可以通过 `editorService` 监听组件树相关事件:
```js
editorService.on('select', (node) => {
console.log('选中组件:', node);
});
```
### 三、右侧属性配置栏
默认的属性配置栏会分为属性、样式、事件、高级4个tab分页其中只有属性是在组件中的`formConfig`文件中定义,其他三个分页都是自动生成的,所有组件都是一样的。
默认的属性读取流程如下:
组件中定义`formConfig` -> 通过`tamgic-cli`构建成 `runtime``/config/index.umd.cjs` -> `m-editor`中加载然后配置到[propsConfig](/api/editor/props.html#propsconfigs) prop中 -> `m-editor`保存到`propsService`中 -> 选中组件时`editorService`会去`propsService`调用`getPropsConfig`中读取
`propsService.getPropsConfig`会调取`propsService.fillConfig`添加样式、事件、高级3个tab分页
#### 1. 定制属性配置栏中顶部的属性、样式、事件、高级 tab分页
可以通过干预`propsService.fillConfig`来实现自定义。例如:
实现去掉样式、事件、高级3个tab分页直接显示组件内定义好的配置
```js
propsService.usePlugin({
/**
* result为生成好的默认配置
* config为组件中定义好的配置
*/
afterFillConfig(result, config) {
return config
}
});
```
#### 2. 定制属性配置栏中配置的来源
如果觉得上述属性读取流程不满足需要,可以通过干预`propsService.getPropsConfig`来实现自定义的流程
```js
propsService.usePlugin({
/**
* result为生成好的默认配置
* config为组件中定义好的配置
*/
afterGetPropsConfig(result, type) {
// 返回配置DSL即可
return []
}
});
```
#### 3. 自定义属性配置栏
默认属性配置栏是是使用`@tmagic/form`来实现的,如果需要使用其他组件来实现可以使用`props-panel`slot来将其替换掉
```html
<m-editor>
<template #props-panel>
<your-props-panel></your-props-panel>
</template>
</m-editor>
```
## 行为扩展
### 二、服务扩展
可以通过监听事件和使用插件来扩展 EditorService
```js
// 监听编辑器事件
editorService.on('add', (node) => {
console.log('添加组件:', node);
});
// 使用插件扩展
editorService.usePlugin({
beforeAdd(node) {
// 在添加组件前执行
return node;
},
afterAdd(node) {
// 在添加组件后执行
return node;
}
});
```
#### 2. PropsService 扩展
自定义属性配置的处理逻辑:
```js
propsService.usePlugin({
// 修改属性配置
beforeGetPropsConfig(type) {
console.log('获取配置前:', type);
},
afterGetPropsConfig(config, type) {
// 添加自定义配置
return config;
},
// 自定义配置填充逻辑
afterFillConfig(config, type) {
return config;
}
});
```

View File

@ -1,23 +1,49 @@
# 快速开始
tmagic-editor的编辑器我们已经封装成一个 npm 包,可以直接安装使用。编辑器是使用 vue3 开发的,但使用编辑器的业务可以不限框架,可以用 vue2、react 等开发业务组件。
tmagic-editor的编辑器我们已经封装成一个 npm 包,可以直接安装使用。编辑器是使用 vue3 开发的(仅支持vue3),但使用编辑器的业务(runtime)可以不限框架,可以用 vue2、react 等开发业务组件。
## 安装
::: code-group
node.js > 14
```bash [npm]
$ npm create tmagic@latest
```
```bash [pnpm]
$ pnpm create tmagic
```
:::
按照提示操作可以创建`6`中项目:
* runtime:运行时DSL渲染
* admin-client:管理端(编辑器)
* components:组件库(组件/插件/数据源)
* component:组件
* data-source:数据源
* plugin:插件
至少需要一个runtime与admin-client后就可以运行起一个最简单的项目了。
后续还需要新增组件、插件、数据源等,可以继续添加后面几种类型的项目。
新增好一个组件/插件/数据源后可以到runtime/tmagic.config.ts中配置到packages中
## 手动安装
node.js >= 18
可以通过[Vite](https://cn.vitejs.dev/) 或 [Vue CLI](https://cli.vuejs.org/zh/)快速创建项目。
> 使用Vue CLI生成的项目需要在vue.config.js中加上配置transpileDependencies: [/@tmagic/]
```bash
$ npm install @tmagic/editor @tmagic/form -S
$ npm install @tmagic/editor -S
```
由于在实际应用中项目常常会用到例如[element-plus](https://element-plus.org/)、[tdesign-vue-next](https://tdesign.tencent.com/vue-next/overview)等UI组件库。为了能让使用者能够选择不同UI库[@tmagic/editor](https://github.com/Tencent/tmagic-editor/tree/master/packages/editor)将其中使用到的UI组件封装到[@tmagic/design](https://github.com/Tencent/tmagic-editor/tree/master/packages/design)中然后通过不同的adapter来指定使用具体的对应的UI库我们提供了[@tmagic/element-plus-adapter](https://github.com/Tencent/tmagic-editor/tree/master/packages/element-plus-adapter)来支持[element-plus](https://element-plus.org/),所以还需要安装相关的依赖。
```bash
$ npm install @tmagic/element-plus-adapter @tmagic/design element-plus -S
$ npm install @tmagic/element-plus-adapter element-plus -S
```
editor 中还包含了[monaco-editor](https://microsoft.github.io/monaco-editor/)所以还需安装monaco-editor可以参考 monaco-editor 的[配置指引](https://github.com/microsoft/monaco-editor/blob/main/docs/integrate-esm.md)。
@ -37,25 +63,21 @@ import { createApp } from 'vue';
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import TMagicDesign from '@tmagic/design';
import MagicEditor from '@tmagic/editor';
import editorPlugin from '@tmagic/editor';
import MagicElementPlusAdapter from '@tmagic/element-plus-adapter';
import MagicForm from '@tmagic/form';
import App from './App.vue';
import 'element-plus/dist/index.css';
import '@tmagic/editor/dist/style.css';
import '@tmagic/form/dist/style.css';
const app = createApp(App);
app.use(ElementPlus, {
locale: zhCn,
});
app.use(TMagicDesign, MagicElementPlusAdapter);
app.use(MagicEditor);
app.use(MagicForm);
app.mount("#app");
app.use(router);
app.use(editorPlugin, MagicElementPlusAdapter);
app.mount('#app');
```
以上代码便完成了 @tmagic/editor 的引入。需要注意的是,样式文件需要单独引入。
@ -103,7 +125,7 @@ app.mount("#app");
// 初始化页面数据
}),
runtimeUrl: "/runtime/vue3/playground/index.html",
runtimeUrl: "/runtime/vue/playground/index.html",
propsConfigs: [
// 组件属性列表
@ -173,9 +195,8 @@ npm install sass -D
## runtimeUrl
该配置涉及到 [runtime 概念](runtime.md)tmagic-editor编辑器中心的模拟器画布是一个 iframe这里的 `runtimeUrl` 配置的,就是你提供的 iframe 的 url其中渲染了一个 runtime用来响应编辑器中的组件增删改等操作。
::: tip 如何快速得到一个 runtime
如果要快速启动,可以使用[tmagic-editor项目源码](https://github.com/Tencent/tmagic-editor)中的 runtime在提供的三个框架 vue2/vue3/react runtime 目录中选择一个,执行 `npm run build:admin` 得到产物,并将产物放到你的项目中,此处的 runtimeUrl 指向你放置 runtime/playground/index.html 的路径。
:::tip
可以使用`npm create tmagic` 来快速创建一个runtime项目。
:::
## componentGroupList
@ -190,10 +211,10 @@ npm install sass -D
```javascript
setup() {
asyncLoadJs(`/runtime/vue3/assets/config.js`).then(() => {
asyncLoadJs(`/runtime/vue/assets/config.js`).then(() => {
propsConfigs.value = window.magicPresetConfigs;
});
asyncLoadJs(`/runtime/vue3/assets/value.js`).then(() => {
asyncLoadJs(`/runtime/vue/assets/value.js`).then(() => {
propsValues.value = window.magicPresetValues;
});
}

View File

@ -2,7 +2,7 @@
tmagic-editor可视化开源项目是从魔方平台演化而来的开源项目意在提供一个供开发者快速搭建可视化搭建平台的解决方案。
<img src="https://image.video.qpic.cn/oa_88b7d-32_509802977_1635842258505918" alt="魔方demo图">
<img src="/tmagic.png" alt="魔方demo图">
## 特性
@ -22,20 +22,20 @@ tmagic-editor可视化开源项目是从魔方平台演化而来的开源项目
- **模拟器**,居中位置渲染了当前页面配置的组件内容,模拟真实页面的展示内容。
- **组件库**左侧展示当前业务下的相关组件内容包含tmagic-editor提供的基础组件和业务自定义组件。
- **组件树**,左侧展示当前页面添加的组件内容,以树状结构展示。
- **[代码块](./advanced/code-block.md)**,左侧展示添加的函数,可供组件事件中联动所用,或者组件声明周期中调用。
- **[数据源](./advanced/data-source.md)**,左侧展示添加的数据源,用于组件中的各项配置。
- **表单配置**,右侧表单项目,展示由组件内提供的配置描述,提供修改组件行为的配置项。
- **DSL 源码**,右上角的 📄 图标可以展示当前页面,各个组件配置,页面基础配置组合而成的配置源码。
通过编辑器,可以创建、编辑、保存一个项目页面。同时tmagic-editor开源项目提供了一个页面搭建管理平台的示例magic-admin可以用于快速构建一个完整的页面可视化搭建系统。
通过编辑器,可以创建、编辑、保存一个项目页面。
## 核心库
- **@tmagic/editor** 实现一个可视化编辑器。
- **@tmagic/form** 实现组件在编辑器中自定义表单配置。
- **@tmagic/core** 实现对组件进行跨框架管理与一些通用复杂逻辑的实现。
- **@tmagic/data-source** 实现数据源的管理与编译。
- **@tmagic/stage** 实现在编辑器中对组件的位置拖动与大小拖拉。
- **@tmagic/ui** 提供一些vue3基础组件。
- **@tmagic/ui-vue2** 提供一些vue2基础组件。
- **@tmagic/ui-react** 提供一些react基础组件。
- **runtime** 实现在编辑器中对使用不同框架的组件的渲染。
可以查阅 tmagic 的[源代码](https://github.com/Tencent/tmagic-editor),与文档描述内容可以逐一对应上,希望文档内容可以为开发者带来比较好的开发体验。
@ -44,3 +44,5 @@ tmagic-editor可视化开源项目是从魔方平台演化而来的开源项目
- 腾讯视频视频会员体育会员WETV 国际版TVdoki 商城,小企鹅,小说,漫画
- 腾讯会议
- 腾讯新闻
- 58同城本地生活服务

89
docs/guide/migration.md Normal file
View File

@ -0,0 +1,89 @@
# 升级到1.5.x
## ui npm包的变化
ui中包含的组件被移除这些组件由单独的npm包提供。1.5.0以后ui包将变得不重要只是为了兼容而保留后续将变废弃。
建议将runtime中的tmagic.config中的packages配置的ui包改成
```js
{
packages: [
{ button: '@tmagic/vue-button',
{ container: '@tmagic/vue-container' },
{ img: '@tmagic/vue-img' },
{ 'iterator-container': '@tmagic/vue-iterator-container' },
{ page: '@tmagic/vue-page' },
{ 'page-fragment': '@tmagic/vue-page-fragment' },
{ 'page-fragment-container': '@tmagic/vue-page-fragment-container' },
{ text: '@tmagic/vue-text' },
{ overlay: '@tmagic/vue-overlay' },
{ qrcode: '@tmagic/vue-qrcode' },
],
}
```
:::tip
react的也是类似上面的修改
:::
:::tip
上述这些组件中只有container是最重要的不可缺少的其他都可以换成自己实现的版本。
iterator-container/page/page-fragment/page-fragment-container这几个组件编辑中是有做特殊识别的所以如果希望有完整的功能也尽量保留
:::
## 对编辑画布中组件的识别
1.5.0之前是通过识别dom中是否拥有id属性是判断该dom是不是组件的根节点之后默认会变成识别是否拥有data-tmagic-id
:::tip
此变化是通过container组件来实现的之前vue是`@tmagic/ui`或者`tmagic/ui-vue2`中的Component组件来实现`tmagic/ui-react`则是各个组件自己实现之后vue是由`@tmagic/vue-container`实现react依然由各个组件自己实现。
:::
如果希望依然保留对id属性的识别我们也提供方法
```ts
import { setDslDomRelateConfig } from '@tmagic/editor';
setDslDomRelateConfig('getIdFromEl', (el?: HTMLElement | SVGElement | null) => el?.id);
setDslDomRelateConfig(
'getElById',
(doc?: Document, id?: string | number) => doc?.querySelector(`[id="${id}"]`) as HTMLElement,
);
setDslDomRelateConfig('setIdToEl', (el: HTMLElement | SVGElement, id: string | number) => {
el.id = `${id}`;
});
```
:::tip
与此相关的`m-editor`组件的[canSelect](/api/editor/props.html#canselect)/[isContainer](/api/editor/props.html#iscontainer)这里配置
:::
## 组件对迭代器容器的支持
迭代器容器是通过绑定一个数据源的数组字段,然后会去迭代这个数组来渲染容器中的内容,这个是同一个配置的组件将会被渲染多次,这个时候组件配置的事件或者代码块中将无法准确获取中组件,所以需要将迭代的信息提供出来。
已vue组件为例需要添加iteratorIndex和iteratorContainerId两个prop
```ts
{
props: {
// other props
iteratorIndex: Array as PropType<number[]>,
iteratorContainerId: Array as PropType<Id[]>,
}
}
```
然后传个useApp
```ts
useApp({
// other args
iteratorContainerId: props.iteratorContainerId,
iteratorIndex: props.iteratorIndex,
})
```
:::tip
如果对迭代器容器没有需求的,可以不用
:::

View File

@ -13,7 +13,7 @@ runtime 的概念是理解tmagic-editor项目页运行的重要概念runti
所以更深入描述runtime 是tmagic-editor页面的渲染环境提供不同场景下的能力封装。如果理解了tmagic-editor的设计阅读了tmagic-editor的源码可以发现runtime 只是对tmagic-editor的渲染器做了一层包装在不同 runtime 中tmagic-editor的渲染逻辑和组件代码都是相同的。
并且由于tmagic-editor在编辑器中的模拟器是通过 iframe 渲染的和tmagic-editor平台本身可以做到框架解耦所以 runtime 也可以用不同框架开发。目前tmagic-editor提供了 vue2/vue3 和 react 的 runtime 示例。
并且由于tmagic-editor在编辑器中的模拟器是通过 iframe 渲染的和tmagic-editor平台本身可以做到框架解耦所以 runtime 也可以用不同框架开发。目前tmagic-editor提供了 vue 和 react 的 runtime 示例。
各个 runtime 的作用除了作为不同场景下的渲染环境同时也是不同环境的打包构建载体。tmagic-editor示例代码中的打包就是基于 runtime 进行的。
@ -21,8 +21,7 @@ runtime 的概念是理解tmagic-editor项目页运行的重要概念runti
由于 runtime 是页面渲染的承载环境,其中会加载 @tmagic/ui 以及各个业务组件,业务发布项目页也是基于 runtime所以在 runtime 中实现业务方的自定义逻辑是最合适的。runtime 可以提供一些全局 API供业务组件调用。我们可以把下面的模拟器中的 runtime 视为一个业务方runtime。
tmagic-editor提供了三个版本的 runtime 示例,可以参考:
- [vue3 runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue3)
- [vue2 runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue2)
- [vue runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue)
- [react runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/react)
### 真实页面渲染Page

View File

@ -1,72 +1,29 @@
# RUNTIME
本章详细介绍如何深入理解tmagic-editor的打包以及如何根据需求定制修改tmagic-editor的页面打包发布方案。页面发布、打包相关的定制化开发需要使用tmagic-editor的业务方搭建好基于开源tmagic-editor的管理平台、存储服务等配套设施。
## runtime 是什么
runtime是用来解析DSL的执行环境用于渲染 DSL 呈现页面。
编辑器生成出来的DSL需要通过 runtime 来渲染。
## 实现一个 runtime
在 [@tmagic/ui](./advanced/tmagic-ui.html) 部分我们已经说过runtime 和 UI 是配套实现的。每个版本的 runtime 都需要一个对应的 UI 来作为渲染器,实现渲染 DSL 呈现页面的功能。
### UI
一个 UI 应该至少包含一个渲染器,来实现[页面渲染](./advanced/page.html)。同时可以提供一些基础组件。具体实现可以参考[@tmagic/ui](./advanced/tmagic-ui.html)。
:::tip
可以使用`npm create tmagic` 来快速创建一个runtime项目。
:::
### page
runtime 的 `page` 部分,就是真实项目页面的渲染环境。发布出去的项目页都需要基于该部分来实现渲染功能。而 `page` 的主要逻辑,就是需要加载 UI同时实现业务方需要的业务逻辑比如
- 提供页面需要的全局 api
- 业务需要的特殊实现逻辑
- 加载第三方全局组件/插件等
具体的 page 实现示例,可以参考
- [vue3 runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue3/page)
- [vue2 runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue2/page)
- [react runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/react/page)
### playground
runtime 的 `playground` 部分,和 `page` 做的事情几乎一致,业务方可以包含上述 `page` 所拥有的全部能力。但是,因为 playground 需要被编辑器加载,作为编辑器中页面模拟器的渲染容器,和编辑器通信,接受编辑器中组件的增删改查。所以,除了保持和 `page` 一样的渲染逻辑之外,`playground` 还要额外实现一套既定通信内容和 api才能实现和编辑器的通信功能。
#### onRuntimeReady
**在 playground 页面渲染后**,需要调用接口通知编辑器完成加载。该调用需要传入一个参数 API即挂载了增删改查功能的对象示例提供给编辑器。
```javascript
window.magic?.onRuntimeReady(API)
创建出来的项目会包含page、playground两个目录。
```bash
.
├── page
├── playground
```
#### onPageElUpdate
**playground 在每次更新了页面配置后**,调用一次 onPageElUpdate 并传入一个 DOM 节点,该方法作用是传入一个页面渲染组件的根节点,用来告知编辑器的模拟器遮罩如何作出反应。
```javascript
window.magic.onPageElUpdate(document.querySelector('.magic-ui-page'));
```
page用于生产环境
#### 提供 API
| API | 说明 | 参数 |
|---------- |-------- |---------- |
|updateRootConfig| 根节点更新 | `root: MApp` |
|updatePageId| 更新当前页面 id | `id: string` |
|select| 选中组件 | `id: string`|
|add| 增加组件 | { `config` , `root` }: `UpdateData` |
|update| 更新组件 | { `config` , `root` }: `UpdateData` |
|remove| 删除组件 | { `config` , `root` }: `UpdateData` |
|sortNode| 组件在容器间排序 |{ `src` , `dist`, `root` }: `SortEventData` |
playground用于编辑器中
runtime 的实现示例可以参考tmagic-editor提供的
- [vue3 runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue3)
- [vue2 runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/vue2)
- [react runtime](https://github.com/Tencent/tmagic-editor/blob/master/runtime/react)
### 页面发布
如介绍中提到的tmagic-editor页面发布方案是对构建产物 `page/index.html` 进行项目信息注入。项目信息就是搭建平台存储的页面配置。发布时,将注入项目信息的 `page/index.html` 发布出去即可。
## 版本管理
基于上一步提到的打包原理,每次构建后,得到的产物都可以进行归档编号,存为版本。涉及到的组件改动和新增修改,体现在各个版本中。
<img src="https://image.video.qpic.cn/oa_88b7d-32_1233288257_1633783105283986" width="40%" alt="版本选择">
版本管理具体如何实现这取决于使用tmagic-editor的业务方。版本管理具有如下优点
1. 对于已经配置好发布的项目,使用固定版本,不会被新版本的特性影响,保证项目线上稳定运行
2. 发布的新版本如果出现问题,可以及时回退选择使用旧版本
## 结合业务定制
tmagic-editor的静态资源构建项目配置保存页面发布在tmagic-editor的提供的示例方案中流程是
1. 触发构建,执行流水线,基于 runtime 执行 build
2. 将构建产物归档推送至 cdn存为一个ui版本
3. 项目配保存后,项目发布时,将项目配置发布至 CDN 存储为 DSL.js同时根据当前项目使用的ui版本获取到 page/index.html将 DSL.js 引用方式以 script 标签形式写入。
4. 将注入信息的 page/index.html 发布为项目静态资源 act.html
5. 线上可加载 act.html 访问项目
其中各个步骤的定制可以交由业务方根据tmagic-editor提供的示例进行自定义修改。
:::tip
想要了解DSL的解析以及runtime与编辑器的通信可以前往[教程](/guide/tutorial/index.md)
:::

View File

@ -51,7 +51,7 @@ cd hello-world
## 添加依赖
```bash
npm install --save @tmagic/editor @tmagic/form @tmagic/stage @tmagic/design @tmagic/element-plus-adapter element-plus
npm install --save @tmagic/editor @tmagic/element-plus-adapter element-plus
```
## 注册组件
@ -61,25 +61,19 @@ npm install --save @tmagic/editor @tmagic/form @tmagic/stage @tmagic/design @tma
```ts
import 'element-plus/dist/index.css';
import '@tmagic/editor/dist/style.css';
import '@tmagic/form/dist/style.css';
import { createApp } from 'vue';
import ElementPlus from 'element-plus';
import TMagicDesign from '@tmagic/design';
import TMagicEditor from '@tmagic/editor';
import TMagicElementPlusAdapter from '@tmagic/element-plus-adapter';
import TMagicForm from '@tmagic/form';
import App from './App.vue';
createApp(App)
.use(ElementPlus)
.use(TMagicDesign, TMagicElementPlusAdapter)
.use(TMagicEditor)
.use(TMagicForm)
.use(TMagicEditor, TMagicElementPlusAdapter)
.mount('#app');
```
## 渲染编辑器
@ -185,7 +179,7 @@ const render = () => {
createApp(
{
template: '<p v-for="node in config.items" :key="node.id" :id="node.id">hello world</p>',
template: '<p v-for="node in config.items" :key="node.id" :data-tmagic-id="node.id">hello world</p>',
props: ['config'],
},
{
@ -249,7 +243,7 @@ const render = async ({ renderer }: StageCore) => {
createApp(
{
template: '<div v-for="node in config.items" :key="node.id" :id="node.id">hello world</div>',
template: '<div v-for="node in config.items" :key="node.id" :data-tmagic-id="node.id">hello world</div>',
props: ['config'],
},
{

View File

@ -1,14 +1,12 @@
# 3.[DSL](../conception.md#dsl) 解析渲染
tmagic 提供了 vue3/vue2/react 三个版本的解析渲染组件,可以直接使用
tmagic 提供了 vue/react 两个个版本的解析渲染组件,可以直接使用
[@tmagic/ui](https://www.npmjs.com/package/@tmagic/ui)
[@tmagic/ui-vue2](https://www.npmjs.com/package/@tmagic/ui-vue2)
[@tmagic/ui-react](https://www.npmjs.com/package/@tmagic/ui-react)
接下来是以vue3为基础,来讲述如何实现一个[@tmagic/ui](https://www.npmjs.com/package/@tmagic/ui)
接下来是以vue为基础来讲述如何实现一个[@tmagic/ui](https://www.npmjs.com/package/@tmagic/ui)
## 准备工作
@ -71,7 +69,7 @@ app.component('hello-world', HelloWorld);
```vue
<template>
<component v-if="config" :is="type" :id="`${id}`" :style="style" :config="config"></component>
<component v-if="config" :is="type" :tmagic-data-id="`${id}`" :style="style" :config="config"></component>
</template>
<script lang=ts setup>

View File

@ -22,7 +22,7 @@ cd editor-runtime
按钮需要用的ts types依赖
```bash
npm install --save @tmagic/schema @tmagic/stage
npm install --save @tmagic/core @tmagic/stage
```
## 实现runtime
@ -33,8 +33,8 @@ npm install --save @tmagic/schema @tmagic/stage
```vue
<template>
<div v-if="config" :id="config.id" :style="style">
<div v-for="node in config.items" :key="node.id" :id="node.id">hello world</div>
<div v-if="config" :data-tmagic-id="config.id" :style="style">
<div v-for="node in config.items" :key="node.id" :data-tmagic-id="node.id">hello world</div>
</div>
</template>
@ -179,8 +179,8 @@ declare global {
```
```ts
import type { Id, MApp, MNode } from '@tmagic/core';
import type { RemoveData, UpdateData } from '@tmagic/stage';
import type { Id, MApp, MNode } from '@tmagic/schema';
const root = ref<MApp>();

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
docs/public/code-block.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
docs/public/data-source.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
docs/public/flow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

BIN
docs/public/layout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

BIN
docs/public/tmagic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -0,0 +1,321 @@
# App
`App``@tmagic/core` 的核心类,继承自 `EventEmitter`,用于管理整个应用的状态和配置。
## 构造函数
```typescript
new App(options: AppOptionsConfig)
```
### AppOptionsConfig
| 参数 | 类型 | 说明 |
|------|------|------|
| `ua` | `string` | User Agent 字符串 |
| `env` | `Env` | 环境信息实例 |
| `config` | `MApp` | DSL 配置 |
| `platform` | `'editor' \| 'mobile' \| 'tv' \| 'pc'` | 平台类型 |
| `jsEngine` | `JsEngine` | JS 引擎类型 |
| `designWidth` | `number` | 设计稿宽度 |
| `curPage` | `Id` | 当前页面 ID |
| `useMock` | `boolean` | 是否使用 Mock 数据 |
| `disabledFlexible` | `boolean` | 是否禁用 flexible |
| `pageFragmentContainerType` | `string \| string[]` | 页面片段容器类型 |
| `iteratorContainerType` | `string \| string[]` | 迭代器容器类型 |
| `transformStyle` | `(style: Record<string, any>) => Record<string, any>` | 样式转换函数 |
| `request` | `RequestFunction` | 请求函数 |
| `dataSourceManagerInitialData` | `DataSourceManagerData` | 数据源管理器初始数据 |
| `nodeStoreInitialData` | `() => any` | 节点存储初始数据工厂函数 |
| `errorHandler` | `ErrorHandler` | 错误处理器 |
| `beforeEventHandler` | `BeforeEventHandler` | 事件处理前钩子 |
| `afterEventHandler` | `AfterEventHandler` | 事件处理后钩子 |
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `env` | `Env` | 环境信息实例 |
| `dsl` | `MApp` | DSL 配置 |
| `codeDsl` | `CodeBlockDSL` | 代码块配置 |
| `dataSourceManager` | `DataSourceManager \| undefined` | 数据源管理器 |
| `page` | `Page \| undefined` | 当前页面 |
| `pageFragments` | `Map<Id, Page>` | 页面片段集合 |
| `platform` | `string` | 平台类型 |
| `jsEngine` | `JsEngine` | JS 引擎类型 |
| `components` | `Map<string, any>` | 已注册的组件 |
| `eventHelper` | `EventHelper` | 事件助手实例 |
## 静态方法
### registerNode
- **参数:**
- `{string} type` 节点类型
- `{typeof Node} NodeClass` 节点类
- **返回:**
- `{void}`
- **详情:**
注册自定义节点类型,用于扩展节点功能。
- **示例:**
```typescript
import App from '@tmagic/core';
class CustomNode extends Node {
// 自定义实现
}
App.registerNode('custom', CustomNode);
```
## 实例方法
### setEnv
- **参数:**
- `{string} ua` User Agent 字符串
- **返回:**
- `{void}`
- **详情:**
设置环境信息,会根据 UA 字符串更新 `env` 属性。
- **示例:**
```typescript
import App from '@tmagic/core';
const app = new App({});
app.setEnv(navigator.userAgent);
```
### setDesignWidth
- **参数:**
- `{number} width` 设计稿宽度
- **返回:**
- `{void}`
- **详情:**
设置设计稿宽度,用于响应式布局计算。
- **示例:**
```typescript
app.setDesignWidth(375);
```
### setConfig
- **参数:**
- `{MApp} config` DSL 配置
- `{Id} curPage` 当前页面 ID可选
- `{DataSourceManagerData} initialData` 初始数据(可选)
- **返回:**
- `void`
- **详情:**
设置 DSL 配置,会初始化数据源管理器和当前页面。
- **示例:**
```typescript
app.setConfig({
id: 'app_1',
type: 'app',
items: [
{
id: 'page_1',
type: 'page',
items: []
}
]
});
```
### setPage
- **参数:**
- `{Id} id` 页面 ID
- **返回:**
- `{void}`
- **详情:**
切换当前页面。
- **示例:**
```typescript
app.setPage('page_2');
```
### deletePage
- **返回:**
- `{void}`
- **详情:**
删除当前页面。
### getPage
- **参数:**
- `{Id} id` 页面 ID可选
- **返回:**
- `{Page | undefined}`
- **详情:**
获取指定 ID 的页面,不传 ID 则返回当前页面。
- **示例:**
```typescript
const page = app.getPage('page_1');
```
### getNode
- **参数:**
- `{Id} id` 节点 ID
- `{GetNodeOptions} options` 获取选项(可选)
- **返回:**
- `{Node | undefined}`
- **详情:**
获取指定 ID 的节点。
- **GetNodeOptions**
| 参数 | 类型 | 说明 |
|------|------|------|
| `iteratorContainerId` | `Id[]` | 迭代器容器 ID 数组 |
| `iteratorIndex` | `number[]` | 迭代器索引数组 |
| `pageFragmentContainerId` | `Id` | 页面片段容器 ID |
| `strict` | `boolean` | 是否严格模式 |
- **示例:**
```typescript
const node = app.getNode('button_1');
```
### registerComponent
- **参数:**
- `{string} type` 组件类型
- `{any} Component` 组件
- **返回:**
- `{void}`
- **详情:**
注册组件。
- **示例:**
```typescript
app.registerComponent('my-button', MyButton);
```
### unregisterComponent
- **参数:**
- `{string} type` 组件类型
- **返回:**
- `{void}`
- **详情:**
取消注册组件。
### resolveComponent
- **参数:**
- `{string} type` 组件类型
- **返回:**
- `{any}`
- **详情:**
解析组件,返回已注册的组件。
### runCode
- **参数:**
- `{Id} codeId` 代码块 ID
- `{object} params` 参数
- `{any[]} args` 额外参数
- `{FlowState} flowState` 流程状态(可选)
- `{Node} node` 节点(可选)
- **返回:**
- `{any}`
- **详情:**
执行代码块。
- **示例:**
```typescript
const result = await app.runCode('code_1', { key: 'value' });
```
### runDataSourceMethod
- **参数:**
- `{Id} dsId` 数据源 ID
- `{string} methodName` 方法名
- `{object} params` 参数
- `{any[]} args` 额外参数
- `{FlowState} flowState` 流程状态(可选)
- `{Node} node` 节点(可选)
- **返回:**
- `{any}`
- **详情:**
执行数据源方法。
- **示例:**
```typescript
const result = await app.runDataSourceMethod('ds_1', 'fetchData', { id: 123 });
```
### destroy
- **返回:**
- `{void}`
- **详情:**
销毁应用实例,清理所有资源。
- **示例:**
```typescript
app.destroy();
```

View File

@ -0,0 +1,191 @@
# DevtoolApi
`DevtoolApi``@tmagic/core` 提供给开发工具使用的 API 接口类。
## 构造函数
```typescript
new DevtoolApi(options: DevtoolApiOptions)
```
### DevtoolApiOptions
| 参数 | 类型 | 说明 |
|------|------|------|
| `app` | `App` | 应用实例 |
## 实例方法
### openPop
- **参数:**
- `{Id} popId` 弹窗组件 ID
- **返回:**
- `{void}`
- **详情:**
打开指定的弹窗组件。
- **示例:**
```typescript
devtoolApi.openPop('dialog_1');
```
### setDataSourceData
- **参数:**
- `{Id} dsId` 数据源 ID
- `{any} data` 数据
- `{string} path` 数据路径(可选)
- **返回:**
- `{void}`
- **详情:**
设置数据源的数据。
- **示例:**
```typescript
// 设置整个数据源数据
devtoolApi.setDataSourceData('ds_1', { name: 'test' });
// 设置数据源的某个字段
devtoolApi.setDataSourceData('ds_1', 'newValue', 'user.name');
```
### requestDataSource
- **参数:**
- `{Id} dsId` 数据源 ID
- **返回:**
- `{Promise<void>}`
- **详情:**
触发 HTTP 数据源的请求。
- **示例:**
```typescript
await devtoolApi.requestDataSource('http_ds_1');
```
### getDisplayCondRealValue
- **参数:**
- `{Id} nodeId` 节点 ID
- `{CondItem} condItem` 条件项
- **返回:**
- `{any}`
- **详情:**
获取显示条件的实际计算值。
### callHook
- **参数:**
- `{Id} nodeId` 节点 ID
- `{string} hookName` 钩子名称
- `{any} hookData` 钩子数据
- **返回:**
- `{Promise<any>}`
- **详情:**
调用节点的钩子函数。
- **示例:**
```typescript
await devtoolApi.callHook('button_1', 'mounted', { data: 'test' });
```
### trigger
- **参数:**
- `{Id} nodeId` 节点 ID
- `{EventConfig[]} events` 事件配置数组
- **返回:**
- `{Promise<void>}`
- **详情:**
触发节点的事件。
- **示例:**
```typescript
await devtoolApi.trigger('button_1', [
{
name: 'click',
actions: [{ actionType: 'code', codeId: 'code_1' }]
}
]);
```
### isValueIncludeDataSource
- **参数:**
- `{any} value` 要检查的值
- **返回:**
- `{boolean}`
- **详情:**
检查值是否包含数据源引用。
- **示例:**
```typescript
const hasDs = devtoolApi.isValueIncludeDataSource('${ds_1.field}');
console.log(hasDs); // true
```
### compileDataSourceValue
- **参数:**
- `{any} value` 包含数据源引用的值
- **返回:**
- `{any}`
- **详情:**
编译数据源值,将数据源引用替换为实际值。
- **示例:**
```typescript
const compiled = devtoolApi.compileDataSourceValue('用户名:${ds_1.user.name}');
```
### updateCode
- **参数:**
- `{Id} codeId` 代码块 ID
- `{any} value` 新值
- `{string} path` 路径(可选)
- **返回:**
- `{void}`
- **详情:**
更新代码块的内容。
- **示例:**
```typescript
devtoolApi.updateCode('code_1', 'return data.value * 2;', 'content');
```

View File

@ -0,0 +1,69 @@
# Env
`Env``@tmagic/core` 的环境检测类,用于检测当前运行环境的设备和系统信息。
## 构造函数
```typescript
new Env(ua?: string)
```
### 参数
| 参数 | 类型 | 说明 |
|------|------|------|
| `ua` | `string` | User Agent 字符串(可选,默认使用 `navigator.userAgent` |
## 属性
所有属性均为只读布尔值:
| 属性 | 类型 | 说明 |
|------|------|------|
| `isIos` | `boolean` | 是否为 iOS 系统 |
| `isIphone` | `boolean` | 是否为 iPhone 设备 |
| `isIpad` | `boolean` | 是否为 iPad 设备 |
| `isAndroid` | `boolean` | 是否为 Android 系统 |
| `isAndroidPad` | `boolean` | 是否为 Android 平板 |
| `isMac` | `boolean` | 是否为 Mac 系统 |
| `isWin` | `boolean` | 是否为 Windows 系统 |
| `isMqq` | `boolean` | 是否在手机 QQ 中 |
| `isWechat` | `boolean` | 是否在微信中 |
| `isWeb` | `boolean` | 是否为 Web 环境 |
| `isOpenHarmony` | `boolean` | 是否为鸿蒙系统 |
## 使用示例
```typescript
import { Env } from '@tmagic/core';
// 使用当前浏览器的 UA
const env = new Env();
if (env.isIos) {
console.log('当前是 iOS 设备');
}
if (env.isWechat) {
console.log('在微信中打开');
}
// 使用自定义 UA
const customEnv = new Env('Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)');
console.log(customEnv.isIphone); // true
```
## 在 App 中使用
```typescript
import App from '@tmagic/core';
const app = new App({
ua: navigator.userAgent
});
// 通过 app.env 访问环境信息
if (app.env.isAndroid) {
// Android 特定逻辑
}
```

View File

@ -0,0 +1,150 @@
# EventHelper
`EventHelper``@tmagic/core` 的事件助手类,继承自 `EventEmitter`,用于管理组件间的事件联动。
## 构造函数
```typescript
new EventHelper(options: EventHelperOptions)
```
### EventHelperOptions
| 参数 | 类型 | 说明 |
|------|------|------|
| `app` | `App` | 应用实例 |
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `app` | `App` | 应用实例 |
## 实例方法
### initEvents
- **返回:**
- `{void}`
- **详情:**
初始化所有节点的事件。通常在页面加载时调用。
- **示例:**
```typescript
eventHelper.initEvents();
```
### bindNodeEvents
- **参数:**
- `{Node} node` 节点实例
- **返回:**
- `{void}`
- **详情:**
为单个节点绑定事件处理。
- **示例:**
```typescript
eventHelper.bindNodeEvents(node);
```
### removeNodeEvents
- **返回:**
- `{void}`
- **详情:**
移除所有节点的事件绑定。
### bindDataSourceEvents
- **返回:**
- `{void}`
- **详情:**
绑定数据源事件,监听数据源变化并触发相应的组件更新。
### removeDataSourceEvents
- **参数:**
- `{DataSourceSchema[]} dataSourceList` 数据源列表(可选)
- **返回:**
- `{void}`
- **详情:**
移除数据源事件绑定。
### getEventQueue
- **返回:**
- `{EventConfig[]}`
- **详情:**
获取当前事件队列。
### addEventToQueue
- **参数:**
- `{EventConfig} event` 事件配置
- **返回:**
- `{void}`
- **详情:**
将事件添加到队列中等待处理。
### destroy
- **返回:**
- `{void}`
- **详情:**
销毁事件助手,清理所有事件绑定。
## 支持的动作类型
EventHelper 支持以下动作类型ActionType
| 类型 | 说明 |
|------|------|
| `ActionType.COMP` | 组件动作,调用目标组件的方法 |
| `ActionType.CODE` | 代码块执行 |
| `ActionType.DATA_SOURCE` | 数据源方法调用 |
### 事件配置示例
```typescript
const eventConfig = {
name: 'click',
actions: [
{
actionType: 'comp',
to: 'button_2',
method: 'show'
},
{
actionType: 'code',
codeId: 'code_1'
},
{
actionType: 'dataSource',
dataSourceId: 'ds_1',
methodName: 'fetchData'
}
]
};
```

View File

@ -0,0 +1,82 @@
# FlowState
`FlowState``@tmagic/core` 的流程状态类,用于控制事件动作流程的执行。
## 构造函数
```typescript
new FlowState()
```
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `isAbort` | `boolean` | 当前流程是否已中止 |
## 实例方法
### abort
- **返回:**
- `{void}`
- **详情:**
中止当前流程。调用后 `isAbort` 变为 `true`,后续的事件动作将不再执行。
- **示例:**
```typescript
import { FlowState } from '@tmagic/core';
const flowState = new FlowState();
// 在某个条件下中止流程
if (shouldStop) {
flowState.abort();
}
// 检查是否已中止
if (flowState.isAbort) {
console.log('流程已中止');
}
```
### reset
- **返回:**
- `{void}`
- **详情:**
重置流程状态,将 `isAbort` 恢复为 `false`
- **示例:**
```typescript
flowState.reset();
console.log(flowState.isAbort); // false
```
## 使用场景
FlowState 常用于控制事件动作链的执行流程:
```typescript
import App, { FlowState } from '@tmagic/core';
const app = new App({ /* options */ });
// 创建流程状态
const flowState = new FlowState();
// 执行代码块时传入流程状态
await app.runCode('validateCode', {}, [], flowState);
// 如果验证失败,代码块内部可以调用 flowState.abort()
// 后续的动作将不会执行
if (!flowState.isAbort) {
await app.runCode('submitCode', {}, [], flowState);
}
```

View File

@ -0,0 +1,142 @@
# IteratorContainer
`IteratorContainer``@tmagic/core` 的迭代容器类,继承自 `Node`,用于循环渲染的容器组件。
## 构造函数
```typescript
new IteratorContainer(options: NodeOptions)
```
参数与 [Node](./node.md) 构造函数相同。
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `nodes` | `Map<Id, Node>[]` | 每个迭代项的节点映射数组 |
继承自 Node 的属性请参见 [Node 属性](./node.md#属性)。
## 实例方法
### setData
- **参数:**
- `{MNode} data` 节点数据
- **返回:**
- `{void}`
- **详情:**
设置数据,会重置所有迭代项的节点。
- **示例:**
```typescript
iteratorContainer.setData({
id: 'iterator_1',
type: 'iterator-container',
iteratorData: [{ name: 'item1' }, { name: 'item2' }],
items: [/* 子节点配置 */]
});
```
### resetNodes
- **返回:**
- `{void}`
- **详情:**
重置所有迭代项的节点,会清空并重新初始化。
### initNode
- **参数:**
- `{MNode} config` 节点配置
- `{Node} parent` 父节点
- `{Map<Id, Node>} map` 节点映射表
- **返回:**
- `{Node}`
- **详情:**
在指定的节点映射表中初始化节点。
### setNodes
- **参数:**
- `{Map<Id, Node>} nodes` 节点映射表
- `{number} index` 迭代索引
- **返回:**
- `{void}`
- **详情:**
设置指定索引的节点映射表。
- **示例:**
```typescript
iteratorContainer.setNodes(nodesMap, 0);
```
### getNode
- **参数:**
- `{Id} id` 节点 ID
- `{number} index` 迭代索引(可选,默认为 0
- **返回:**
- `{Node | undefined}`
- **详情:**
获取指定迭代索引中的节点。
- **示例:**
```typescript
// 获取第一个迭代项中的节点
const node = iteratorContainer.getNode('button_1', 0);
// 获取第二个迭代项中的节点
const node2 = iteratorContainer.getNode('button_1', 1);
```
### destroy
- **返回:**
- `{void}`
- **详情:**
销毁迭代容器及其所有迭代项的节点。
## 使用场景
IteratorContainer 常用于列表渲染场景,例如:
```typescript
// DSL 配置示例
const iteratorConfig = {
id: 'iterator_1',
type: 'iterator-container',
iteratorData: [
{ id: 1, title: '项目1' },
{ id: 2, title: '项目2' },
{ id: 3, title: '项目3' }
],
items: [
{
id: 'text_tpl',
type: 'text',
text: '${item.title}'
}
]
};
```

View File

@ -0,0 +1,139 @@
# Node
`Node``@tmagic/core` 的节点基类,继承自 `EventEmitter`,表示 DSL 中的一个节点。
## 构造函数
```typescript
new Node(options: NodeOptions)
```
### NodeOptions
| 参数 | 类型 | 说明 |
|------|------|------|
| `config` | `MNode` | 节点配置 |
| `parent` | `Node` | 父节点(可选) |
| `page` | `Page` | 所属页面 |
| `app` | `App` | 应用实例 |
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `data` | `MNode` | 节点配置数据 |
| `style` | `object` | 节点样式 |
| `events` | `EventConfig[]` | 事件配置 |
| `instance` | `any` | 组件实例 |
| `page` | `Page` | 所属页面 |
| `parent` | `Node \| undefined` | 父节点 |
| `app` | `App` | 应用实例 |
| `store` | `Store` | 节点存储 |
| `eventKeys` | `Map<string, symbol>` | 事件键映射 |
## 实例方法
### setData
- **参数:**
- `{MNode} data` 节点数据
- **返回:**
- `{void}`
- **详情:**
设置节点数据,会更新 `data``style``events` 属性。
- **示例:**
```typescript
node.setData({
id: 'button_1',
type: 'button',
style: { width: 100 },
events: []
});
```
### addEventToQueue
- **参数:**
- `{EventConfig} event` 事件配置
- **返回:**
- `{void}`
- **详情:**
将事件添加到事件队列,等待绑定到组件实例。
### setInstance
- **参数:**
- `{any} instance` 组件实例
- **返回:**
- `{void}`
- **详情:**
设置组件实例,并绑定队列中的事件。
- **示例:**
```typescript
// 通常在组件挂载时调用
node.setInstance(componentInstance);
```
### runHookCode
- **参数:**
- `{'created' | 'mounted'} hook` 钩子名称
- `{object} params` 参数
- **返回:**
- `{Promise<any>}`
- **详情:**
执行节点的钩子代码。
- **示例:**
```typescript
await node.runHookCode('mounted', { data: someData });
```
### destroy
- **返回:**
- `{void}`
- **详情:**
销毁节点,清理事件监听和组件实例。
## 生命周期事件
Node 实例会触发以下生命周期事件:
| 事件名 | 说明 |
|--------|------|
| `created` | 组件创建完成时触发 |
| `mounted` | 组件挂载完成时触发 |
| `destroy` | 组件销毁时触发 |
| `update-data` | 数据更新时触发 |
### 监听示例
```typescript
node.on('mounted', () => {
console.log('组件已挂载');
});
node.on('update-data', (newData) => {
console.log('数据已更新', newData);
});
```

View File

@ -0,0 +1,126 @@
# Page
`Page``@tmagic/core` 的页面类,继承自 `Node`,用于管理页面及其子节点。
## 构造函数
```typescript
new Page(options: PageOptions)
```
### PageOptions
继承自 NodeOptions参见 [Node](./node.md) 构造函数。
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `nodes` | `Map<Id, Node>` | 页面内所有节点的映射表 |
继承自 Node 的属性请参见 [Node 属性](./node.md#属性)。
## 实例方法
### initNode
- **参数:**
- `{MNode} config` 节点配置
- `{Node} parent` 父节点(可选)
- **返回:**
- `{Node}`
- **详情:**
初始化节点,根据配置创建节点实例并添加到页面。会递归初始化子节点。
- **示例:**
```typescript
const node = page.initNode({
id: 'button_1',
type: 'button',
style: { width: 100 }
});
```
### getNode
- **参数:**
- `{Id} id` 节点 ID
- `{GetNodeOptions} options` 获取选项(可选)
- **返回:**
- `{Node | undefined}`
- **详情:**
获取页面中指定 ID 的节点。支持从迭代器容器和页面片段中获取节点。
- **GetNodeOptions**
| 参数 | 类型 | 说明 |
|------|------|------|
| `iteratorContainerId` | `Id[]` | 迭代器容器 ID 数组 |
| `iteratorIndex` | `number[]` | 迭代器索引数组 |
| `pageFragmentContainerId` | `Id` | 页面片段容器 ID |
| `strict` | `boolean` | 是否严格模式 |
- **示例:**
```typescript
const node = page.getNode('button_1');
// 从迭代器中获取
const iteratorNode = page.getNode('item_1', {
iteratorContainerId: ['iterator_1'],
iteratorIndex: [0]
});
```
### setNode
- **参数:**
- `{Id} id` 节点 ID
- `{Node} node` 节点实例
- **返回:**
- `{void}`
- **详情:**
设置页面中的节点。
### deleteNode
- **参数:**
- `{Id} id` 节点 ID
- **返回:**
- `{void}`
- **详情:**
删除页面中指定 ID 的节点。
- **示例:**
```typescript
page.deleteNode('button_1');
```
### destroy
- **返回:**
- `{void}`
- **详情:**
销毁页面及其所有子节点。
- **示例:**
```typescript
page.destroy();
```

View File

@ -0,0 +1,107 @@
# 工具函数
`@tmagic/core` 导出的工具函数。
## style2Obj
- **参数:**
- `{string} style` CSS 样式字符串
- **返回:**
- `{object}` 样式对象
- **详情:**
将 CSS 样式字符串转换为对象格式。
- **示例:**
```typescript
import { style2Obj } from '@tmagic/core';
const styleObj = style2Obj('width: 100px; height: 200px;');
console.log(styleObj); // { width: '100px', height: '200px' }
```
## fillBackgroundImage
- **参数:**
- `{string} value` 背景图片 URL
- **返回:**
- `{string}` 完整的 CSS 背景图片值
- **详情:**
填充背景图片 URL 为完整的 CSS 格式。
- **示例:**
```typescript
import { fillBackgroundImage } from '@tmagic/core';
const bg = fillBackgroundImage('https://example.com/image.png');
console.log(bg); // 'url(https://example.com/image.png)'
```
## getTransform
- **参数:**
- `{object} value` transform 配置
- `{JsEngine} jsEngine` JS 引擎类型
- **返回:**
- `{string}` CSS transform 字符串
- **详情:**
根据配置生成 CSS transform 字符串,会根据 JS 引擎类型进行适配。
## transformStyle
- **参数:**
- `{object} style` 样式对象
- `{JsEngine} jsEngine` JS 引擎类型
- **返回:**
- `{object}` 转换后的样式对象
- **详情:**
转换样式对象,将数值转换为 rem 单位(移动端适配)。
- **示例:**
```typescript
import { transformStyle } from '@tmagic/core';
const style = transformStyle({ width: 100, height: 200 }, 'browser');
console.log(style); // { width: '1rem', height: '2rem' }
```
## 常量
### COMMON_EVENT_PREFIX
- **值:** `'magic:common:events:'`
- **详情:**
通用事件前缀。
### COMMON_METHOD_PREFIX
- **值:** `'magic:common:actions:'`
- **详情:**
通用方法前缀。
- **示例:**
```typescript
import { COMMON_EVENT_PREFIX, COMMON_METHOD_PREFIX } from '@tmagic/core';
const eventKey = `${COMMON_EVENT_PREFIX}click`;
const methodKey = `${COMMON_METHOD_PREFIX}show`;
```

View File

@ -0,0 +1,198 @@
# DataSource基础数据源
`DataSource``@tmagic/data-source` 的基础数据源类,用于静态数据管理。
## 构造函数
```typescript
new DataSource(options: DataSourceOptions)
```
### DataSourceOptions
| 参数 | 类型 | 说明 |
|------|------|------|
| `schema` | `DataSourceSchema` | 数据源配置 |
| `app` | `TMagicApp` | 应用实例 |
| `initialData` | `Record<string, any>` | 初始数据(可选) |
| `useMock` | `boolean` | 使用 Mock 数据(可选) |
| `request` | `RequestFunction` | 请求函数(可选) |
| `ObservedDataClass` | `ObservedDataClass` | 观察者数据类(可选) |
### DataSourceSchema
| 参数 | 类型 | 说明 |
|------|------|------|
| `id` | `string` | 数据源 ID |
| `type` | `'base'` | 数据源类型 |
| `title` | `string` | 数据源标题(可选) |
| `description` | `string` | 数据源描述(可选) |
| `fields` | `DataSchema[]` | 字段配置 |
| `methods` | `CodeBlockContent[]` | 自定义方法配置(可选) |
| `mocks` | `MockSchema` | Mock 数据配置(可选) |
| `events` | `EventConfig[]` | 事件配置(可选) |
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `id` | `string` | 数据源 ID只读 |
| `type` | `string` | 数据源类型,值为 `'base'` |
| `schema` | `DataSourceSchema` | 配置 schema |
| `fields` | `DataSchema[]` | 字段配置 |
| `methods` | `CodeBlockContent[]` | 自定义方法配置 |
| `data` | `any` | 当前数据 |
| `isInit` | `boolean` | 是否已初始化 |
## 实例方法
### setData
- **参数:**
- `{any} data` 数据
- `{string} path` 数据路径(可选)
- **返回:**
- `{void}`
- **详情:**
设置数据源数据。如果指定路径,则只更新该路径的数据。
- **示例:**
```typescript
// 设置整个数据
ds.setData({ name: 'test', count: 10 });
// 设置特定路径的数据
ds.setData('newValue', 'user.name');
```
### setValue
- **参数:**
- `{string} path` 数据路径
- `{any} data` 数据
- **返回:**
- `{void}`
- **详情:**
按路径设置数据,等同于 `setData(data, path)`
- **示例:**
```typescript
ds.setValue('user.age', 25);
```
### onDataChange
- **参数:**
- `{string} path` 数据路径
- `{Function} callback` 回调函数
- **返回:**
- `{void}`
- **详情:**
监听指定路径的数据变化。
- **示例:**
```typescript
ds.onDataChange('user.name', (newVal) => {
console.log('用户名变更:', newVal);
});
```
### offDataChange
- **参数:**
- `{string} path` 数据路径
- `{Function} callback` 回调函数
- **返回:**
- `{void}`
- **详情:**
取消监听数据变化。
### getDefaultData
- **返回:**
- `{any}` 默认数据
- **详情:**
根据字段配置获取默认数据。
### init
- **返回:**
- `{Promise<void>}`
- **详情:**
初始化数据源。
### destroy
- **返回:**
- `{void}`
- **详情:**
销毁数据源,清理资源。
## 事件
DataSource 继承自 EventEmitter支持以下事件
| 事件名 | 说明 |
|--------|------|
| `change` | 数据变化时触发 |
### 示例
```typescript
ds.on('change', () => {
console.log('数据已变化', ds.data);
});
```
## 字段配置 (DataSchema)
| 参数 | 类型 | 说明 |
|------|------|------|
| `name` | `string` | 字段名 |
| `type` | `string` | 字段类型 |
| `title` | `string` | 字段标题(可选) |
| `description` | `string` | 字段描述(可选) |
| `defaultValue` | `any` | 默认值(可选) |
| `fields` | `DataSchema[]` | 子字段(对象类型时)(可选) |
### 字段配置示例
```typescript
const schema = {
id: 'user_ds',
type: 'base',
fields: [
{ name: 'id', type: 'number', defaultValue: 0 },
{ name: 'name', type: 'string', defaultValue: '' },
{
name: 'profile',
type: 'object',
fields: [
{ name: 'avatar', type: 'string' },
{ name: 'bio', type: 'string' }
]
}
]
};
```

View File

@ -0,0 +1,335 @@
# DataSourceManager
`DataSourceManager``@tmagic/data-source` 的核心类,用于管理所有数据源的生命周期、数据编译和事件分发。
## 构造函数
```typescript
new DataSourceManager(options: DataSourceManagerOptions)
```
### DataSourceManagerOptions
| 参数 | 类型 | 说明 |
|------|------|------|
| `app` | `TMagicApp` | 应用实例 |
| `initialData` | `DataSourceManagerData` | 初始数据(可选,用于 SSR |
| `useMock` | `boolean` | 是否使用 Mock 数据(可选) |
## 属性
| 属性 | 类型 | 说明 |
|------|------|------|
| `app` | `TMagicApp` | 应用实例 |
| `dataSourceMap` | `Map<string, DataSource>` | 数据源映射表 |
| `data` | `DataSourceManagerData` | 所有数据源的数据 |
| `initialData` | `DataSourceManagerData` | 初始化数据 |
| `useMock` | `boolean` | 是否使用 Mock 数据 |
## 静态方法
### register
- **参数:**
- `{string} type` 数据源类型
- `{typeof DataSource} dataSourceClass` 数据源类
- **返回:**
- `{void}`
- **详情:**
注册自定义数据源类型。
- **示例:**
```typescript
import { DataSourceManager } from '@tmagic/data-source';
class CustomDataSource extends DataSource {
// 自定义实现
}
DataSourceManager.register('custom', CustomDataSource);
```
### getDataSourceClass
- **参数:**
- `{string} type` 数据源类型
- **返回:**
- `{typeof DataSource | undefined}`
- **详情:**
获取已注册的数据源类。
### clearDataSourceClass
- **返回:**
- `{void}`
- **详情:**
清除所有已注册的数据源类(保留 `base``http`)。
### registerObservedData
- **参数:**
- `{ObservedDataClass} observedDataClass` 观察者数据类
- **返回:**
- `{void}`
- **详情:**
注册自定义的观察者数据类。
## 实例方法
### init
- **参数:**
- `{DataSourceSchema[]} ds` 数据源配置数组
- **返回:**
- `{Promise<void>}`
- **详情:**
初始化数据源,会创建所有配置的数据源实例并初始化。
- **示例:**
```typescript
await dataSourceManager.init([
{
id: 'ds_1',
type: 'base',
fields: [{ name: 'count', defaultValue: 0 }]
},
{
id: 'http_1',
type: 'http',
options: { url: '/api/data' }
}
]);
```
### get
- **参数:**
- `{string} id` 数据源 ID
- **返回:**
- `{DataSource | undefined}`
- **详情:**
获取指定 ID 的数据源实例。
- **示例:**
```typescript
const ds = dataSourceManager.get('ds_1');
```
### addDataSource
- **参数:**
- `{DataSourceSchema} config` 数据源配置
- **返回:**
- `{DataSource}`
- **详情:**
添加新的数据源。
- **示例:**
```typescript
const ds = dataSourceManager.addDataSource({
id: 'new_ds',
type: 'base',
fields: []
});
```
### removeDataSource
- **参数:**
- `{string} id` 数据源 ID
- **返回:**
- `{void}`
- **详情:**
移除指定的数据源。
### setData
- **参数:**
- `{DataSourceSchema} ds` 数据源配置
- `{ChangeEvent} changeEvent` 变化事件(可选)
- **返回:**
- `{void}`
- **详情:**
设置数据源数据。
### updateSchema
- **参数:**
- `{DataSourceSchema[]} schemas` 数据源配置数组
- **返回:**
- `{Promise<void>}`
- **详情:**
更新数据源 DSL 配置,会自动处理新增、更新和删除。
### compiledNode
- **参数:**
- `{MNode} node` 节点配置
- `{string} sourceId` 数据源 ID可选
- `{boolean} deep` 是否深度编译(可选)
- **返回:**
- `{MNode}`
- **详情:**
编译节点 DSL 中的数据源配置,将数据源引用替换为实际值。
- **示例:**
```typescript
const compiledNode = dataSourceManager.compiledNode({
id: 'text_1',
type: 'text',
text: '${ds_1.username}'
});
// compiledNode.text 会被替换为实际的用户名
```
### compliedConds
- **参数:**
- `{MNode} node` 节点配置
- `{object} data` 数据上下文(可选)
- **返回:**
- `{boolean}`
- **详情:**
编译显示条件,返回节点是否应该显示。
- **示例:**
```typescript
const shouldShow = dataSourceManager.compliedConds(node);
```
### compliedIteratorItemConds
- **参数:**
- `{object} itemData` 迭代项数据
- `{MNode} node` 节点配置
- `{string} field` 条件字段名
- **返回:**
- `{boolean}`
- **详情:**
编译迭代器项的显示条件。
### compliedIteratorItems
- **参数:**
- `{object} itemData` 迭代项数据
- `{MNode[]} nodes` 节点配置数组
- `{string} field` 字段名
- **返回:**
- `{MNode[]}`
- **详情:**
编译迭代器项的节点配置。
### onDataChange
- **参数:**
- `{string} id` 数据源 ID
- `{string} path` 数据路径
- `{Function} callback` 回调函数
- **返回:**
- `{void}`
- **详情:**
监听数据源数据变化。
- **示例:**
```typescript
dataSourceManager.onDataChange('ds_1', 'user.name', (newVal) => {
console.log('用户名变更:', newVal);
});
```
### offDataChange
- **参数:**
- `{string} id` 数据源 ID
- `{string} path` 数据路径
- `{Function} callback` 回调函数
- **返回:**
- `{void}`
- **详情:**
取消监听数据源数据变化。
### destroy
- **返回:**
- `{void}`
- **详情:**
销毁数据源管理器,清理所有数据源。
## 事件
DataSourceManager 继承自 EventEmitter支持以下事件
| 事件名 | 说明 | 回调参数 |
|--------|------|----------|
| `change` | 数据源数据变化 | `(dsId, path, newVal)` |
| `init` | 所有数据源初始化完成 | 无 |
| `registered-all` | 所有数据源注册完成 | 无 |
| `update-data` | 更新节点数据 | `(node, sourceId)` |
### 事件监听示例
```typescript
dataSourceManager.on('change', (dsId, path, newVal) => {
console.log(`数据源 ${dsId} 的 ${path} 变更为:`, newVal);
});
dataSourceManager.on('init', () => {
console.log('所有数据源初始化完成');
});
```

View File

@ -0,0 +1,221 @@
# HttpDataSourceHTTP 数据源)
`HttpDataSource``@tmagic/data-source` 的 HTTP 数据源类,继承自 `DataSource`,用于通过 HTTP 请求获取数据。
## 构造函数
```typescript
new HttpDataSource(options: DataSourceOptions<HttpDataSourceSchema>)
```
参数参见 [DataSource](./dataSource.md) 构造函数。
### HttpDataSourceSchema
继承自 DataSourceSchema额外包含
| 参数 | 类型 | 说明 |
|------|------|------|
| `type` | `'http'` | 数据源类型 |
| `options` | `HttpOptionsSchema` | HTTP 请求配置 |
| `responseOptions` | `{ dataPath?: string }` | 响应数据配置(可选) |
| `autoFetch` | `boolean` | 是否自动请求(可选) |
| `beforeRequest` | `Function \| string` | 请求前钩子(可选) |
| `afterResponse` | `Function \| string` | 响应后钩子(可选) |
### HttpOptionsSchema
| 参数 | 类型 | 说明 |
|------|------|------|
| `url` | `string \| Function` | 请求链接 |
| `method` | `'GET' \| 'POST'` | 请求方法(可选,默认 GET |
| `params` | `object \| Function` | Query 参数(可选) |
| `data` | `object \| Function` | Body 数据(可选) |
| `headers` | `object \| Function` | 请求头(可选) |
## 属性
继承自 DataSource 的属性,额外包含:
| 属性 | 类型 | 说明 |
|------|------|------|
| `isLoading` | `boolean` | 是否正在请求 |
| `error` | `{ msg?: string, code?: string }` | 错误信息 |
| `httpOptions` | `HttpOptionsSchema` | 请求配置 |
## 实例方法
### request
- **参数:**
- `{HttpOptionsSchema} options` 请求选项(可选)
- **返回:**
- `{Promise<any>}` 响应数据
- **详情:**
发起 HTTP 请求。可以传入选项覆盖默认配置。
- **示例:**
```typescript
// 使用默认配置请求
const data = await httpDs.request();
// 覆盖部分配置
const data = await httpDs.request({
params: { page: 1, size: 10 }
});
```
### get
- **参数:**
- `{HttpOptionsSchema} options` 请求选项
- **返回:**
- `{Promise<any>}` 响应数据
- **详情:**
发起 GET 请求。
- **示例:**
```typescript
const data = await httpDs.get({
url: '/api/users',
params: { id: 1 }
});
```
### post
- **参数:**
- `{HttpOptionsSchema} options` 请求选项
- **返回:**
- `{Promise<any>}` 响应数据
- **详情:**
发起 POST 请求。
- **示例:**
```typescript
const data = await httpDs.post({
url: '/api/users',
data: { name: 'test' }
});
```
## 配置示例
### 基础配置
```typescript
const httpDsSchema = {
id: 'user_api',
type: 'http',
title: '用户接口',
options: {
url: '/api/user',
method: 'GET',
params: { id: 1 }
},
autoFetch: true,
fields: [
{ name: 'id', type: 'number' },
{ name: 'name', type: 'string' }
]
};
```
### 动态参数配置
```typescript
const httpDsSchema = {
id: 'dynamic_api',
type: 'http',
options: {
url: (app) => `/api/users/${app.page.data.userId}`,
params: (app) => ({ token: app.getToken() })
}
};
```
### 请求钩子配置
```typescript
const httpDsSchema = {
id: 'hooked_api',
type: 'http',
options: {
url: '/api/data',
method: 'POST'
},
// 请求前处理
beforeRequest: (options, app) => {
options.headers = {
...options.headers,
Authorization: `Bearer ${app.token}`
};
return options;
},
// 响应后处理
afterResponse: (response, app) => {
if (response.code !== 0) {
throw new Error(response.message);
}
return response.data;
},
// 响应数据路径
responseOptions: {
dataPath: 'data.list'
}
};
```
### 使用代码块作为钩子
```typescript
const httpDsSchema = {
id: 'code_hook_api',
type: 'http',
options: {
url: '/api/data'
},
// 引用代码块 ID
beforeRequest: 'code_before_request',
afterResponse: 'code_after_response'
};
```
## 自动请求
`autoFetch` 设置为 `true` 时,数据源在初始化时会自动发起请求:
```typescript
const httpDsSchema = {
id: 'auto_api',
type: 'http',
options: {
url: '/api/init-data'
},
autoFetch: true // 初始化时自动请求
};
```
## 错误处理
```typescript
httpDs.on('change', () => {
if (httpDs.error) {
console.error('请求失败:', httpDs.error.msg);
} else {
console.log('数据:', httpDs.data);
}
});
```

View File

@ -0,0 +1,148 @@
# 观察者数据类
`@tmagic/data-source` 提供了三种观察者数据类,用于实现数据的响应式监听。
## ObservedData抽象类
所有观察者数据类的抽象基类,定义了统一的接口。
### 抽象方法
| 方法 | 参数 | 返回值 | 说明 |
|------|------|--------|------|
| `update` | `(data: any, path?: string)` | `void` | 更新数据 |
| `on` | `(path: string, callback: Function, options?: { immediate?: boolean })` | `void` | 监听数据变化 |
| `off` | `(path: string, callback: Function)` | `void` | 取消监听 |
| `getData` | `(path: string)` | `any` | 获取指定路径的数据 |
| `destroy` | `()` | `void` | 销毁 |
## SimpleObservedData
基于 EventEmitter 的简单观察者实现,只支持单层路径监听。
### 使用示例
```typescript
import { SimpleObservedData } from '@tmagic/data-source';
const observed = new SimpleObservedData({ name: 'test' });
// 监听数据变化
observed.on('name', (newVal) => {
console.log('name 变更为:', newVal);
});
// 更新数据
observed.update({ name: 'new name' });
// 更新特定路径
observed.update('another name', 'name');
// 获取数据
const name = observed.getData('name');
// 取消监听
observed.off('name', callback);
// 销毁
observed.destroy();
```
### 特点
- 轻量级实现
- 只支持单层路径监听(如 `'name'`,不支持 `'user.name'`
- 适用于简单数据结构
## DeepObservedData
基于 `deep-state-observer` 的深度观察者实现,支持深层路径监听。
### 使用示例
```typescript
import { DeepObservedData } from '@tmagic/data-source';
const observed = new DeepObservedData({
user: {
name: 'test',
profile: {
avatar: 'url'
}
}
});
// 监听深层路径
observed.on('user.profile.avatar', (newVal) => {
console.log('头像变更为:', newVal);
});
// 监听整个对象
observed.on('user', (newVal) => {
console.log('user 对象变更:', newVal);
});
// 立即执行回调
observed.on('user.name', callback, { immediate: true });
// 更新深层数据
observed.update('new avatar', 'user.profile.avatar');
// 获取深层数据
const avatar = observed.getData('user.profile.avatar');
```
### 特点
- 支持深层路径监听(如 `'user.profile.avatar'`
- 支持 `immediate` 选项立即执行回调
- 适用于复杂嵌套数据结构
- 性能更优,只在相关路径变化时触发回调
## 在 DataSourceManager 中注册
可以通过静态方法注册自定义的观察者数据类:
```typescript
import { DataSourceManager, DeepObservedData } from '@tmagic/data-source';
// 注册深度观察者类
DataSourceManager.registerObservedData(DeepObservedData);
```
## 自定义观察者类
可以继承 `ObservedData` 实现自定义的观察者类:
```typescript
import { ObservedData } from '@tmagic/data-source';
class CustomObservedData extends ObservedData {
private data: any;
constructor(data: any) {
super();
this.data = data;
}
update(data: any, path?: string): void {
// 自定义更新逻辑
}
on(path: string, callback: Function, options?: { immediate?: boolean }): void {
// 自定义监听逻辑
}
off(path: string, callback: Function): void {
// 自定义取消监听逻辑
}
getData(path: string): any {
// 自定义获取数据逻辑
}
destroy(): void {
// 自定义销毁逻辑
}
}
```

View File

@ -0,0 +1,200 @@
# 工具函数
`@tmagic/data-source` 导出的工具函数。
## createDataSourceManager
- **参数:**
- `{TMagicApp} app` 应用实例
- `{boolean} useMock` 是否使用 Mock 数据(可选)
- `{DataSourceManagerData} initialData` 初始数据(可选)
- **返回:**
- `{DataSourceManager}` 数据源管理器实例
- **详情:**
创建数据源管理器的工厂函数,会自动设置数据变化监听。
- **示例:**
```typescript
import { createDataSourceManager } from '@tmagic/data-source';
const dsManager = createDataSourceManager(app, false, initialData);
```
## compiledCondition
- **参数:**
- `{CondItem} cond` 条件项
- `{object} data` 数据上下文
- **返回:**
- `{boolean}` 条件是否满足
- **详情:**
编译单个显示条件。
- **示例:**
```typescript
import { compiledCondition } from '@tmagic/data-source';
const result = compiledCondition(
{ field: 'user.age', op: '>', value: 18 },
{ user: { age: 20 } }
);
console.log(result); // true
```
## compliedConditions
- **参数:**
- `{MNode} node` 节点配置
- `{object} data` 数据上下文(可选)
- **返回:**
- `{boolean}` 节点是否应该显示
- **详情:**
编译条件组,支持 AND/OR 逻辑。
## compiledNodeField
- **参数:**
- `{any} value` 字段值
- `{object} data` 数据上下文
- **返回:**
- `{any}` 编译后的值
- **详情:**
编译节点字段中的数据源配置。
- **示例:**
```typescript
import { compiledNodeField } from '@tmagic/data-source';
const compiled = compiledNodeField(
{ isBindDataSource: true, dataSourceId: 'ds_1', template: '${name}' },
{ ds_1: { name: 'test' } }
);
```
## compliedDataSourceField
- **参数:**
- `{any} value` 字段值
- `{object} data` 数据上下文
- **返回:**
- `{any}` 编译后的值
- **详情:**
编译数据源字段选择器的值。
## template
- **参数:**
- `{string} value` 模板字符串
- `{object} data` 数据上下文
- **返回:**
- `{string}` 替换后的字符串
- **详情:**
模板字符串替换,支持 `${id.field}` 格式。
- **示例:**
```typescript
import { template } from '@tmagic/data-source';
const result = template(
'用户名:${ds_1.user.name},年龄:${ds_1.user.age}',
{ ds_1: { user: { name: '张三', age: 20 } } }
);
console.log(result); // '用户名张三年龄20'
```
## createIteratorContentData
- **参数:**
- `{object} itemData` 迭代项数据
- `{string} dsId` 数据源 ID
- `{DataSchema[]} fields` 字段配置
- `{object} dsData` 数据源数据
- **返回:**
- `{object}` 迭代器数据上下文
- **详情:**
创建迭代器的数据上下文。
## compliedIteratorItem
- **参数:**
- `{object} options` 编译选项
- **返回:**
- `{MNode}` 编译后的节点
- **详情:**
编译迭代器项。
## updateNode
- **参数:**
- `{MNode} node` 节点配置
- `{MApp} dsl` DSL 配置
- **返回:**
- `{MApp}` 更新后的 DSL
- **详情:**
更新 DSL 中的指定节点。
- **示例:**
```typescript
import { updateNode } from '@tmagic/data-source';
const newDsl = updateNode(
{ id: 'button_1', type: 'button', text: '新文本' },
dsl
);
```
## registerDataSourceOnDemand
- **参数:**
- `{MApp} dsl` DSL 配置
- `{Record<string, () => Promise<any>>} modules` 数据源模块映射
- **返回:**
- `{Promise<void>}`
- **详情:**
按需加载数据源模块。根据 DSL 中使用的数据源类型动态加载对应模块。
- **示例:**
```typescript
import { registerDataSourceOnDemand } from '@tmagic/data-source';
await registerDataSourceOnDemand(dsl, {
custom: () => import('./CustomDataSource'),
socket: () => import('./SocketDataSource')
});
```

566
eslint-config/flat/base.mjs Normal file
View File

@ -0,0 +1,566 @@
export default {
rules: {
/**
* 不要在中括号中添加空格
*/
'array-bracket-spacing': ['error', 'never'],
/**
* 数组的方法除了 forEach 之外回调函数必须有返回值
*/
'array-callback-return': 'warn',
/**
* 要求箭头函数体使用大括号
*/
'arrow-body-style': ['warn', 'as-needed'],
/**
* 要求箭头函数的参数使用圆括号
*/
'arrow-parens': [
'warn',
'as-needed',
{
requireForBlockBody: true,
},
],
/**
* 强制箭头函数的箭头前后使用一致的空格
*/
'arrow-spacing': 'warn',
/**
* 要求打开的块标志和同一行上的标志拥有一致的间距此规则还会在同一行关闭的块标记和前边的标记强制实施一致的间距
*/
'block-spacing': 'error',
/**
* 强制在代码块中使用一致的大括号风格
*/
'brace-style': 'error',
/**
* 使用驼峰命名法camelCase命名对象函数和实例
*/
camelcase: [
'error',
{
ignoreDestructuring: true,
properties: 'never',
},
],
/**
* 添加尾随逗号
*/
'comma-dangle': ['warn', 'always-multiline'],
/**
* 强制在逗号前后使用一致的空格
*/
'comma-spacing': [
'error',
{
before: false,
after: true,
},
],
/**
* 强制使用一致的逗号风格
*/
'comma-style': ['error', 'last'],
/**
* 强制在计算的属性的方括号中使用一致的空格
*/
'computed-property-spacing': ['warn', 'never'],
/**
* 禁止使用 foo['bar']必须写成 foo.bar
*/
'dot-notation': 'warn',
/**
* 要求或禁止文件末尾存在空行
*/
'eol-last': ['error', 'always'],
/**
* 必须使用 === !==禁止使用 == !=
*/
eqeqeq: ['warn', 'always'],
/**
* 要求或禁止在函数标识符和其调用之间有空格
*/
'func-call-spacing': ['error', 'never'],
/**
* 必须只使用函数声明或只使用函数表达式
*/
'func-style': ['off', 'expression'],
/**
* 强制在函数括号内使用一致的换行
*/
'function-paren-newline': ['warn', 'multiline'],
/**
* 强制 generator 函数中 * 号周围使用一致的空格
*/
'generator-star-spacing': [
'warn',
{
before: false,
after: true,
},
],
/**
* 限制变量名长度
*/
'id-length': 'off',
/**
* 强制隐式返回的箭头函数体的位置
*/
'implicit-arrow-linebreak': ['warn', 'beside'],
/**
* 使用 2 个空格缩进
*/
indent: [
'warn',
2,
{
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
FunctionDeclaration: {
parameters: 1,
body: 1,
},
FunctionExpression: {
parameters: 1,
body: 1,
},
CallExpression: {
arguments: 1,
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
ignoredNodes: [
'JSXElement',
'JSXElement > *',
'JSXAttribute',
'JSXIdentifier',
'JSXNamespacedName',
'JSXMemberExpression',
'JSXSpreadAttribute',
'JSXExpressionContainer',
'JSXOpeningElement',
'JSXClosingElement',
'JSXFragment',
'JSXOpeningFragment',
'JSXClosingFragment',
'JSXText',
'JSXEmptyExpression',
'JSXSpreadChild',
],
ignoreComments: false,
},
],
/**
* 强制在对象字面量的属性中键和值之间使用一致的间距
*/
'key-spacing': 'error',
/**
* 强制在关键字前后使用一致的空格
*/
'keyword-spacing': [
'error',
{
overrides: {
if: {
after: true,
},
for: {
after: true,
},
while: {
after: true,
},
else: {
after: true,
},
},
},
],
/**
* 只允许使用 unix LF 作为换行符Windows CRLF 不可以使用
*/
'linebreak-style': ['warn', 'unix'],
/**
* 强制一行的最大长度限制单行不能超过100个字符字符串和正则表达式除外
*/
'max-len': [
'off',
{
code: 120,
ignoreStrings: true,
ignoreUrls: true,
ignoreRegExpLiterals: true,
ignoreTemplateLiterals: true,
},
],
/**
* 只有在命名构造器或者类的时候才用帕斯卡拼命名法PascalCase即首字母大写
*/
'new-cap': [
'error',
{
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
properties: false,
},
],
/**
* 在编写多个方法链式调用(超过两个方法链式调用) 使用前导点强调这行是一个方法调用而不是一个语句
*/
'newline-per-chained-call': [
'warn',
{
ignoreChainWithDepth: 2,
},
],
/**
* 使用字面量语法创建数组
*/
'no-array-constructor': ['error'],
/**
* case default 的子句中如果存在声明 (例如. let, const, function, class)使用大括号来创建块级作用域
*/
'no-case-declarations': 'error',
/**
* 避免搞混箭头函数符号 (=>) 和比较运算符 (<=, >=)
*/
'no-confusing-arrow': 'warn',
/**
* 禁止对使用 const 定义的常量重新赋值
*/
'no-const-assign': 'error',
/**
* 禁止重复定义类的成员
*/
'no-dupe-class-members': 'error',
/**
* 禁止在 else 内使用 return必须改为提前结束
*/
'no-else-return': [
'warn',
{
allowElseIf: false,
},
],
/**
* 禁止使用 eval
*/
'no-eval': 'error',
/**
* 不要使用迭代器
* @reason 推荐使用 JavaScript 的高阶函数代替 for-in
*/
'no-iterator': 'warn',
/**
* 禁止在循环内的函数内部出现循环体条件语句中定义的变量
*/
'no-loop-func': 'error',
/**
* 禁止混合使用不同的操作符:
* - 禁止 `%`, `**` 之间混用
* - 禁止 `%` 与其它运算符之间混用
* - 禁止乘除运算符之间混用
* - 禁止位运算符之间的任何混用
* - 禁止比较运算符之间混用
* - 禁止 `&&`, `||` 之间混用
*/
'no-mixed-operators': [
'error',
{
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['&', '|', '<<', '>>', '>>>'],
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false,
},
],
/**
* 禁止连续赋值比如 foo = bar = 1
*/
'no-multi-assign': 'error',
/**
* 不要使用多个空行填充代码
*/
'no-multiple-empty-lines': 'error',
/**
* 禁止使用嵌套的三元表达式比如 a ? b : c ? d : e
*/
'no-nested-ternary': 'warn',
/**
* 禁止使用 new Function
* @reason 这和 eval 是等价的
*/
'no-new-func': 'error',
/**
* 禁止直接 new Object
*/
'no-new-object': 'error',
/**
* 禁止使用 new 来生成 String, Number Boolean
*/
'no-new-wrappers': 'warn',
/**
* 禁止对函数的参数重新赋值
*/
'no-param-reassign': [
'warn',
{
props: true,
ignorePropertyModificationsFor: [
'acc',
'accumulator',
'e',
'ctx',
'req',
'request',
'res',
'response',
'$scope',
'staticContext',
'state',
],
},
],
/**
* 禁止使用 ++ --
*/
'no-plusplus': [
'error',
{
allowForLoopAfterthoughts: true,
},
],
/**
* 禁止使用 hasOwnProperty, isPrototypeOf propertyIsEnumerable
*/
'no-prototype-builtins': 'error',
/**
* 计算指数时可以使用 ** 运算符
*/
'no-restricted-properties': [
'warn',
{
object: 'Math',
property: 'pow',
message: 'Please use ** instand',
},
],
/**
* 推荐使用 JavaScript 的高阶函数代替 for-in
*/
'no-restricted-syntax': [
'warn',
{
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
/**
* 避免在行尾添加空格
*/
'no-trailing-spaces': 'error',
/**
* 变量应先声明再使用禁止引用任何未声明的变量除非你明确知道引用的变量存在于当前作用域链上
*/
'no-undef': ['error'],
/**
* 禁止变量名出现下划线
*/
'no-underscore-dangle': 'warn',
/**
* 必须使用 !a 替代 a ? false : true
*/
'no-unneeded-ternary': 'warn',
/**
* 已定义的变量必须使用
* 但不检查最后一个使用的参数之前的参数
* 也不检查 rest 属性的兄弟属性
*/
'no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_.+',
varsIgnorePattern: '^_.+',
},
],
/**
* 禁止出现没必要的 constructor
*/
'no-useless-constructor': 'warn',
/**
* 禁止出现没必要的转义
*/
'no-useless-escape': 'error',
/**
* 禁止使用 var
*/
'no-var': 'error',
/**
* 禁止属性前有空白
*/
'no-whitespace-before-property': 'warn',
/**
* 强制单个语句的位置
*/
'nonblock-statement-body-position': ['error', 'beside'],
/**
* 强制在大括号中使用一致的空格
*/
'object-curly-spacing': ['warn', 'always'],
/**
* 将对象方法属性简写且间歇属性放在前面
*/
'object-shorthand': 'warn',
/**
* 禁止变量申明时用逗号一次申明多个
*/
'one-var': ['warn', 'never'],
/**
* 避免在赋值语句 = 前后换行如果你的代码单行长度超过了 max-len 定义的长度而不得不换行那么使用括号包裹
*/
'operator-linebreak': [
'error',
'before',
{
overrides: {
'=': 'none',
},
},
],
/**
* 要求或禁止块内填充
*/
'padded-blocks': ['error', 'never'],
/**
* 要求回调函数使用箭头函数
*/
'prefer-arrow-callback': 'warn',
/**
* 申明后不再被修改的变量必须使用 const 来申明
*/
'prefer-const': [
'error',
{
destructuring: 'any',
ignoreReadBeforeAssign: false,
},
],
/**
* 优先使用解构赋值
*/
'prefer-destructuring': [
'warn',
{
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
},
{
enforceForRenamedProperties: false,
},
],
/**
* 必须使用 ...args 而不是 arguments
*/
'prefer-rest-params': 'warn',
/**
* 必须使用 ... 而不是 apply比如 foo(...args)
*/
'prefer-spread': 'warn',
/**
* 必须使用模版字符串而不是字符串连接
*/
'prefer-template': 'error',
/**
* 要求对象字面量属性名称用引号括起来
*/
'quote-props': [
'error',
'as-needed',
{
keywords: false,
},
],
/**
* 使用单引号 '' 定义字符串
*/
quotes: [
'warn',
'single',
{
allowTemplateLiterals: false,
},
],
/**
* parseInt 必须传入第二个参数
*/
radix: 'warn',
/**
* 要加分号
*/
semi: ['error', 'always'],
/**
* 强制在块之前使用一致的空格
*/
'space-before-blocks': 'error',
/**
* 强制在 function 的左括号之前使用一致的空格
*/
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
},
],
/**
* 强制在圆括号内使用一致的空格
*/
'space-in-parens': ['error', 'never'],
/**
* 要求操作符周围有空格
*/
'space-infix-ops': 'error',
/**
* 注释的斜线或 * 后必须有空格
*/
'spaced-comment': ['error', 'always'],
/**
* 要求或禁止模板字符串中的嵌入表达式周围空格的使用
*/
'template-curly-spacing': ['error', 'never'],
/**
* 要求立即执行的函数使用括号括起来
*/
'wrap-iife': ['error', 'outside'],
},
};

View File

@ -0,0 +1,38 @@
import simpleImportSort from 'eslint-plugin-simple-import-sort';
export default {
files: ['**/*.{js,mjs,cjs,ts,vue}'],
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
['./polyfills'],
['^(node)(:.*|$)'],
// Node.js builtins. You could also generate this regex if you use a `.js` config.
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
[
'^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)',
],
// Packages. `react|vue` related packages come first.
['^(react|vue|vite|vitest)', '^@?\\w'],
['^(@tencent)(/.*|$)'],
['^(@tmagic)(/.*|$)'],
// Internal packages.
['^(@|src|editor-page|@editor|@data-source)(/.*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Style imports.
['^.+\\.s?css$'],
],
},
],
},
};

View File

@ -0,0 +1,37 @@
import { rules } from 'eslint-plugin-import';
export default {
plugins: {
import: {
meta: { name: 'eslint-plugin-import' },
rules,
},
},
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
/**
* 导入语句前不允许有任何非导入语句
*/
'import/first': 'error',
/**
* 禁止重复导入模块
*/
'import/no-duplicates': 'error',
/**
* 禁止使用 let 导出
*/
'import/no-mutable-exports': 'warn',
/**
* 禁用导入的模块时使用 webpack 特有的语法感叹号
*/
'import/no-webpack-loader-syntax': 'warn',
/**
* 当只有一个导出时必须使用 export default 来导出
*/
'import/prefer-default-export': 'off',
},
};

View File

@ -1,5 +1,4 @@
module.exports = {
plugins: ['prettier'],
export default {
rules: {
'wrap-iife': 'off',
'template-curly-spacing': 'off',

376
eslint-config/flat/ts.mjs Normal file
View File

@ -0,0 +1,376 @@
export default {
files: ['**/*.ts', '**/*.tsx'],
rules: {
'brace-style': 'off',
'no-empty-function': 'off',
// https://github.com/typescript-eslint/typescript-eslint/issues/491
'no-invalid-this': 'off',
'no-magic-numbers': 'off',
'react/sort-comp': 'off',
'func-call-spacing': 'off',
'comma-spacing': 'off',
'dot-notation': 'off',
indent: 'off',
'keyword-spacing': 'off',
camelcase: 'off',
'no-underscore-dangle': 'off',
'no-array-constructor': 'off',
'no-dupe-class-members': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-useless-constructor': 'off',
quotes: 'off',
semi: 'off',
'space-before-function-paren': 'off',
// https://github.com/typescript-eslint/typescript-eslint/issues/600
'spaced-comment': ['error', 'always', { markers: ['/'] }],
/**
* 重载的函数必须写在一起
* @reason 增加可读性
*/
'@typescript-eslint/adjacent-overload-signatures': 'error',
/** 同 JS 规则的 TS 版本 */
'@stylistic/ts/brace-style': 'error',
/** 同 JS 规则的 TS 版本 */
'@stylistic/comma-spacing': [
'error',
{
before: false,
after: true,
},
],
/**
* 类型断言必须使用 as Type禁止使用 <Type>禁止对对象字面量进行类型断言断言成 any 是允许的
* @reason <Type> 容易被理解为 jsx
*/
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never',
},
],
/**
* 优先使用 interface 而不是 type
*/
'@typescript-eslint/consistent-type-definitions': 'off',
/** 同 JS 规则的 TS 版本 */
'@typescript-eslint/dot-notation': 'warn',
/**
* 必须设置类的成员的可访问性
* @reason 将不需要公开的成员设为私有的可以增强代码的可理解性对文档输出也很友好
*/
'@typescript-eslint/explicit-member-accessibility': 'off',
/**
* 要求或禁止在函数标识符和其调用之间有空格
*/
'@stylistic/ts/func-call-spacing': ['error', 'never'],
/** 同 JS 规则的 TS 版本 */
'@stylistic/ts/indent': [
'warn',
2,
{
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
FunctionDeclaration: {
parameters: 1,
body: 1,
},
FunctionExpression: {
parameters: 1,
body: 1,
},
CallExpression: {
arguments: 1,
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
ignoredNodes: [
'JSXElement',
'JSXElement > *',
'JSXAttribute',
'JSXIdentifier',
'JSXNamespacedName',
'JSXMemberExpression',
'JSXSpreadAttribute',
'JSXExpressionContainer',
'JSXOpeningElement',
'JSXClosingElement',
'JSXFragment',
'JSXOpeningFragment',
'JSXClosingFragment',
'JSXText',
'JSXEmptyExpression',
'JSXSpreadChild',
],
ignoreComments: false,
},
],
/** 同 JS 规则的 TS 版本 */
'@stylistic/ts/keyword-spacing': [
'error',
{
overrides: {
if: {
after: true,
},
for: {
after: true,
},
while: {
after: true,
},
else: {
after: true,
},
},
before: true,
after: true,
},
],
/**
* 指定类成员的排序规则
* @reason 优先级
* 1. static > instance
* 2. field > constructor > method
* 3. public > protected > private
*/
'@typescript-eslint/member-ordering': [
'error',
{
default: [
'public-static-field',
'protected-static-field',
'private-static-field',
'static-field',
'public-static-method',
'protected-static-method',
'private-static-method',
'static-method',
'public-instance-field',
'protected-instance-field',
'private-instance-field',
'public-field',
'protected-field',
'private-field',
'instance-field',
'field',
'constructor',
'public-instance-method',
'protected-instance-method',
'private-instance-method',
'public-method',
'protected-method',
'private-method',
'instance-method',
'method',
],
},
],
/**
* 接口中的方法必须用属性的方式定义
*/
'@typescript-eslint/method-signature-style': 'off',
/** 代替 JS 规则 camelCase 的 TS 规则 */
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
},
{
selector: 'variable',
modifiers: ['global'],
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{
selector: 'variable',
format: ['camelCase', 'PascalCase'],
types: ['function'],
},
{
selector: 'variable',
modifiers: ['exported'],
format: ['UPPER_CASE'],
types: ['boolean', 'string', 'number', 'array'],
},
{
selector: 'variable',
modifiers: ['exported'],
format: ['camelCase', 'PascalCase'],
types: ['function'],
},
{
selector: ['class', 'typeLike'],
format: ['PascalCase'],
},
{
selector: ['classMethod', 'classProperty'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
format: ['camelCase'],
},
],
/** 同 JS 规则的 TS 版本 */
'@typescript-eslint/no-array-constructor': 'error',
/** 同 JS 规则的 TS 版本 */
'@typescript-eslint/no-dupe-class-members': 'error',
/**
* 禁止定义空的接口
*/
'@typescript-eslint/no-empty-interface': 'error',
/**
* 禁止给一个初始化时直接赋值为 number, string 的变量显式的声明类型
* @reason 可以简化代码
*/
'@typescript-eslint/no-inferrable-types': 'warn',
/**
* 禁止对 promise 的误用详见示例
*/
'@typescript-eslint/no-misused-promises': [
'error',
{
checksConditionals: true,
},
],
/**
* 禁止使用 namespace 来定义命名空间
* @reason 使用 es6 引入模块才是更标准的方式
* 但是允许使用 declare namespace ... {} 来定义外部命名空间
*/
'@typescript-eslint/no-namespace': [
'error',
{
allowDeclarations: true,
allowDefinitionFiles: true,
},
],
/**
* 禁止在 optional chaining 之后使用 non-null 断言感叹号
* @reason optional chaining 后面的属性一定是非空的
*/
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
/**
* 禁止给类的构造函数的参数添加修饰符
*/
'@typescript-eslint/no-parameter-properties': 'off',
/**
* 禁止使用 require
* @reason 统一使用 import 来引入模块特殊情况使用单行注释允许 require 引入
*/
'@typescript-eslint/no-require-imports': 'error',
/**
* 禁止将 this 赋值给其他变量除非是解构赋值
*/
'@typescript-eslint/no-this-alias': [
'error',
{
allowDestructuring: true,
},
],
/**
* 禁止无用的表达式
*/
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
},
],
/** 同 JS 规则的 TS 版本 */
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_.+',
varsIgnorePattern: '^_.+',
},
],
/**
* 禁止出现没必要的 constructor
*/
'@typescript-eslint/no-useless-constructor': 'warn',
/**
* 使用 for 循环遍历数组时如果索引仅用于获取成员则必须使用 for of 循环替代 for 循环
* @reason for of 循环更加易读
*/
'@typescript-eslint/prefer-for-of': 'warn',
/**
* 使用函数类型别名替代包含函数调用声明的接口
*/
'@typescript-eslint/prefer-function-type': 'warn',
/**
* 禁止使用 module 来定义命名空间
* @reason module 已成为 js 的关键字
*/
'@typescript-eslint/prefer-namespace-keyword': 'error',
/**
* 使用 optional chaining 替代 &&
*/
'@typescript-eslint/prefer-optional-chain': 'error',
/** 同 JS 规则的 TS 版本 */
'@stylistic/ts/quotes': [
'warn',
'single',
{
allowTemplateLiterals: false,
},
],
/** 同 JS 规则的 TS 版本 */
'@stylistic/ts/semi': ['error', 'always'],
/** 同 JS 规则的 TS 版本 */
'@stylistic/ts/space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
},
],
/**
* 禁止使用三斜杠导入文件
* @reason 三斜杠是已废弃的语法但在类型声明文件中还是可以使用的
*/
'@typescript-eslint/triple-slash-reference': [
'error',
{
path: 'never',
types: 'always',
lib: 'always',
},
],
/**
* 在类型注释周围需要一致的间距
*/
'@stylistic/ts/type-annotation-spacing': 'error',
/**
* interface type 定义时必须声明成员的类型
*/
'@typescript-eslint/typedef': [
'error',
{
arrayDestructuring: false,
arrowParameter: false,
memberVariableDeclaration: false,
objectDestructuring: false,
parameter: false,
propertyDeclaration: true,
variableDeclaration: false,
},
],
/**
* 函数重载时若能通过联合类型将两个函数的类型声明合为一个则使用联合类型而不是两个函数声明
*/
'@typescript-eslint/unified-signatures': 'error',
},
};

37
eslint-config/index.mjs Normal file
View File

@ -0,0 +1,37 @@
import js from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import parserTs from '@typescript-eslint/parser';
import { defineConfig } from 'eslint/config';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import tencentEslintBaseConfig from './flat/base.mjs';
import tencentEslintImportexport from './flat/import.mjs';
import ImportSortConfig from './flat/import-sort.mjs';
import tencentEslintPrettierConfig from './flat/prettier.mjs';
import tencentEslintTsConfig from './flat/ts.mjs';
export default (tsconfigRootDir) =>
defineConfig([
{ files: ['**/*.{js,mjs,cjs}'], plugins: { js }, extends: ['js/recommended'] },
{ files: ['**/*.{js,mjs,cjs,ts,vue}'], languageOptions: { globals: { ...globals.browser, ...globals.node } } },
...tseslint.config(tencentEslintBaseConfig, tencentEslintImportexport, tseslint.configs.base, {
plugins: {
'@stylistic': stylistic,
},
languageOptions: {
parser: parserTs,
parserOptions: {
project: tsconfigRootDir,
},
},
...tencentEslintTsConfig,
}),
pluginVue.configs['flat/essential'],
{ files: ['**/*.vue'], languageOptions: { parserOptions: { parser: tseslint.parser } } },
eslintPluginPrettierRecommended,
tencentEslintPrettierConfig,
ImportSortConfig,
]);

Some files were not shown because too many files have changed in this diff Show More