Skip to content

Commit

Permalink
fix(designable-next): fix style and support history (#2007)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grapedge authored Aug 13, 2021
1 parent cd9c215 commit 7e9c9cb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
41 changes: 28 additions & 13 deletions designable/next/playground/main.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useMemo } from 'react'
import React from 'react'
import ReactDOM from 'react-dom'
import {
Designer,
IconWidget,
DesignerToolsWidget,
ViewToolsWidget,
Workspace,
OutlineTreeWidget,
DragSourceWidget,
HistoryWidget,
MainPanel,
CompositePanel,
WorkspacePanel,
Expand All @@ -18,7 +18,12 @@ import {
ComponentTreeWidget,
} from '@designable/react'
import { SettingsForm } from '@designable/react-settings-form'
import { createDesigner, GlobalRegistry } from '@designable/core'
import {
createDesigner,
GlobalRegistry,
Shortcut,
KeyCode,
} from '@designable/core'
import { createDesignableField, createDesignableForm } from '../src'
import {
LogoWidget,
Expand All @@ -27,6 +32,7 @@ import {
SchemaEditorWidget,
MarkupSchemaWidget,
} from './widgets'
import { saveSchema } from './service'
import 'antd/dist/antd.less'
import '@alifd/next/dist/next.css'

Expand Down Expand Up @@ -55,27 +61,36 @@ const DesignableField = createDesignableField({
registryName: 'DesignableField',
})

const App = () => {
const engine = useMemo(() => createDesigner(), [])
const SaveShortCut = new Shortcut({
codes: [
[KeyCode.Meta, KeyCode.S],
[KeyCode.Control, KeyCode.S],
],
handler(ctx) {
saveSchema(ctx.engine)
},
})

const engine = createDesigner({
shortcuts: [SaveShortCut],
})

const App = () => {
return (
<Designer engine={engine}>
<MainPanel logo={<LogoWidget />} actions={<ActionsWidget />}>
<CompositePanel>
<CompositePanel.Item
title="panels.Component"
icon={<IconWidget infer="Component" />}
>
<CompositePanel.Item title="panels.Component" icon="Component">
<DragSourceWidget title="sources.Inputs" name="inputs" />
<DragSourceWidget title="sources.Layouts" name="layouts" />
<DragSourceWidget title="sources.Arrays" name="arrays" />
</CompositePanel.Item>
<CompositePanel.Item
title="panels.OutlinedTree"
icon={<IconWidget infer="Outline" />}
>
<CompositePanel.Item title="panels.OutlinedTree" icon="Outline">
<OutlineTreeWidget />
</CompositePanel.Item>
<CompositePanel.Item title="panels.History" icon="History">
<HistoryWidget />
</CompositePanel.Item>
</CompositePanel>
<Workspace id="form">
<WorkspacePanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const DesignableArrayCards: React.FC<CardProps> = observer((props) => {
<ArrayBase disabled>
<ArrayBase.Item index={0}>
<Card
contentHeight="auto"
{...props}
title={
<span>
Expand Down
7 changes: 4 additions & 3 deletions designable/next/src/components/LoadTemplate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { Box, Button } from '@alifd/next'
import { Button } from '@alifd/next'
import { Space, Divider } from 'antd'
import { usePrefix, TextWidget } from '@designable/react'
import cls from 'classnames'
import './styles.scss'
Expand All @@ -22,7 +23,7 @@ export const LoadTemplate: React.FC<ILoadTemplateProps> = (props) => {
return (
<div className={cls(prefix, props.className)} style={props.style}>
<div className={prefix + '-actions'}>
<Box>
<Space split={<Divider type="vertical" />}>
{props.actions?.map((action, key) => {
return (
<Button
Expand All @@ -39,7 +40,7 @@ export const LoadTemplate: React.FC<ILoadTemplateProps> = (props) => {
</Button>
)
})}
</Box>
</Space>
</div>
</div>
)
Expand Down
6 changes: 4 additions & 2 deletions designable/next/src/schemas/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ export const Card: ISchema & { Addition?: ISchema } = {
},
},
contentHeight: {
type: 'number',
'x-decorator': 'FormItem',
'x-component': 'NumberPicker',
'x-component': 'ValueInput',
'x-component-props': {
include: ['NUMBER', 'TEXT'],
},
},
extra: {
type: 'string',
Expand Down

0 comments on commit 7e9c9cb

Please sign in to comment.