parisma 51dadabc2c feat(editor): 代码编辑交互优化
1、代码列表中代码块和组件区分不够清晰,查看按钮太靠边,开发模式下未对齐
2、代码编辑/查看弹窗希望可以点击蒙层或者esc键退出
3、代码块绑定到组件的地方和事件绑定UI统一
4、在代码绑定的地方需要支持查看或者编辑
Bug:
1、旧格式的事件联动删除到只剩最后一个时无法成功删除
2023-04-18 07:57:50 +00:00

338 lines
9.3 KiB
TypeScript

/*
* 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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
id: '75f0extui9d7yksklx27hff8xg',
name: 'test',
type: 'app',
codeBlocks: {
code_5336: {
name: 'getData',
// eslint-disable-next-line no-eval
content: eval(`({app, params}) => {\n console.log("this is getData function",params,app)\n}`),
params: [
{
name: 'age',
type: 'number',
tip: '年纪',
},
{
name: 'studentName',
type: 'text',
tip: '学生姓名',
},
],
},
code_5316: {
name: 'getList',
// eslint-disable-next-line no-eval
content: eval(`() => {\n console.log("this is getList function")\n}`),
params: [],
},
},
items: [
{
type: 'page',
id: 'page_299',
name: 'index',
title: '',
layout: 'absolute',
style: {
position: 'relative',
left: 0,
top: 0,
right: '',
bottom: '',
width: '100%',
height: '1728',
backgroundImage: '',
backgroundColor: 'rgba(248, 218, 218, 1)',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '',
fontWeight: '',
},
events: [
{
name: 'magic:common:events:click', // 事件名
actions: [
{
actionType: 'code', // 联动动作类型
codeId: 'code_5336', // 代码块id
params: {
age: 12,
}, // 参数
},
{
actionType: 'comp',
to: 'overlay_2159', // 联动组件id
method: 'openOverlay', // 联动组件方法
},
],
},
{
name: 'magic:common:events:click', // 事件名
actions: [
{
actionType: 'code', // 联动动作类型
codeId: 'code_5316', // 代码块id
params: {},
},
],
},
],
created: {
hookType: 'code',
hookData: [
{
codeId: 'code_5336',
params: {
studentName: 'lisa',
age: 14,
},
},
{
codeId: 'code_5316',
params: {},
},
],
},
items: [
{
type: 'text',
id: 'text_9027',
style: {
width: '280.75',
height: '38.97',
position: 'absolute',
top: '107.90',
left: '46.96',
right: '',
bottom: '',
backgroundImage: '',
backgroundColor: '',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '20',
fontWeight: '',
},
name: '文本',
text: 'Tmagic editor 营销活动编辑器',
multiple: true,
events: [],
},
{
type: 'qrcode',
id: 'qrcode_4738',
style: {
position: 'absolute',
left: '91.92',
width: '176',
height: '176',
top: '565.50',
right: '',
bottom: '',
backgroundImage: '',
backgroundColor: '',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '',
fontWeight: '',
},
name: '二维码',
url: 'https://github.com/Tencent/tmagic-editor',
events: [],
created: [],
},
{
type: 'img',
id: 'img_3877',
style: {
position: 'absolute',
left: '95.91',
width: '176',
height: '176',
top: '325.71',
right: '',
bottom: '',
backgroundImage: '',
backgroundColor: '',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '',
fontWeight: '',
},
name: '图片',
src: 'https://vfiles.gtimg.cn/vupload/20210811/388ed01628667545737.png',
url: '',
events: [],
created: [],
},
{
type: 'button',
id: 'button_430',
style: {
position: 'absolute',
width: '270',
height: '37.5',
border: 0,
backgroundColor: '#fb6f00',
top: '206.82',
left: '55.95',
right: '',
bottom: '',
backgroundImage: '',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '',
fontWeight: '',
},
name: '按钮',
text: '打开弹窗',
multiple: true,
events: [
{
name: 'magic:common:events:click',
to: 'overlay_2159',
method: 'openOverlay',
},
],
created: [],
},
{
type: 'overlay',
id: 'overlay_2159',
style: {
position: 'fixed',
width: '100%',
height: '100%',
top: 0,
left: 0,
backgroundColor: 'rgba(0, 0, 0, 0.8)',
},
name: '蒙层',
items: [
{
type: 'container',
id: 'container_607',
style: {
position: 'absolute',
width: '80%',
height: '400',
top: '143.87',
left: 37.5,
right: '',
bottom: '',
backgroundImage: '',
backgroundColor: 'rgba(255, 255, 255, 1)',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '',
fontWeight: '',
},
name: '组',
items: [
{
type: 'button',
id: 'button_7265',
style: {
position: 'absolute',
width: '270',
height: '37.5',
border: 0,
backgroundColor: '#fb6f00',
top: '322.71',
left: '15.99',
right: '',
bottom: '',
backgroundImage: '',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '',
fontWeight: '',
},
name: '按钮',
text: '关闭弹窗',
multiple: true,
events: [
{
name: 'magic:common:events:click',
to: 'overlay_2159',
method: 'closeOverlay',
},
],
created: [],
},
{
type: 'img',
id: 'img_3291',
style: {
position: 'absolute',
left: '63.94',
width: '176',
height: '176',
top: '105.91',
},
name: '图片',
src: 'https://puui.qpic.cn/vupload/0/1573555382625_bhp0wud8l6w.png/0',
url: '',
},
{
type: 'text',
id: 'text_8598',
style: {
position: 'absolute',
width: '86.92',
height: '37.97',
left: '106.90',
top: '35.97',
right: '',
bottom: '',
backgroundImage: '',
backgroundColor: '',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%',
color: '',
fontSize: '24',
fontWeight: '',
},
name: '文本',
text: 'Tmagic',
multiple: false,
events: [],
created: [],
},
],
layout: 'absolute',
events: [],
created: [],
},
],
},
],
},
],
};