(component: VisualEditorComponent)
| 229 | }; |
| 230 | |
| 231 | export function createNewBlock(component: VisualEditorComponent): VisualEditorBlockData { |
| 232 | return { |
| 233 | _vid: `vid_${generateNanoid()}`, |
| 234 | moduleName: component.moduleName, |
| 235 | componentKey: component!.key, |
| 236 | label: component!.label, |
| 237 | adjustPosition: true, |
| 238 | focus: false, |
| 239 | styles: { |
| 240 | display: 'flex', |
| 241 | justifyContent: 'flex-start', |
| 242 | paddingTop: '0', |
| 243 | paddingRight: '0', |
| 244 | paddingLeft: '0', |
| 245 | paddingBottom: '0', |
| 246 | tempPadding: '0', |
| 247 | }, |
| 248 | hasResize: false, |
| 249 | props: Object.entries(component.props || {}).reduce((prev, [propName, propSchema]) => { |
| 250 | const { propObj, prop } = useDotProp(prev, propName); |
| 251 | if (propSchema?.defaultValue) { |
| 252 | propObj[prop] = prev[propName] = propSchema?.defaultValue; |
| 253 | } |
| 254 | return prev; |
| 255 | }, {}), |
| 256 | draggable: component.draggable ?? true, // 是否可以拖拽 |
| 257 | showStyleConfig: component.showStyleConfig ?? true, // 是否显示组件样式配置 |
| 258 | animations: [], // 动画集 |
| 259 | actions: [], // 动作集合 |
| 260 | events: component.events || [], // 事件集合 |
| 261 | model: {}, |
| 262 | }; |
| 263 | } |
| 264 | |
| 265 | export type VisualDragEvent = { |
| 266 | dragstart: { |
no test coverage detected