Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema Driven Visual Editor #1770

Closed
1 of 4 tasks
yeze322 opened this issue Dec 13, 2019 · 6 comments
Closed
1 of 4 tasks

Schema Driven Visual Editor #1770

yeze322 opened this issue Dec 13, 2019 · 6 comments
Assignees
Labels
R8 Release 8 - March 16th, 2020 Type: Engineering

Comments

@yeze322
Copy link
Contributor

yeze322 commented Dec 13, 2019

Description
Visual Editor and Form Editor are both visualization libs for AdaptiveDialog schema, they work on the same abstraction level.

In Form Editor, we have an uischema.ts file in which render process is defined by a json.
image

We should also have a schema definition file in Visual Editor. Then we can possibily

  1. define multiple versions of schema to support different SDK versions' rendering
  2. let users define their own ui elements for customization

Interface
Ideally, a semantic Visual Editor could be used like this

import  { uischema } from '@bfc/schema/4.7.0'

const customizedSchema = { ...uischema, ...myshema };

const render = () => {
    return (
        <VisualEditor
               data={data}
               schema={customizedSchema}
         />
    );
}

PR plan

  • stage 1 (merged feat: Schema-driven visual editor - migrates 15 simple types #1811 ) - support basic rendering with uischema definition
    • set up uischema definition & implement a generic renderer based on uischema
    • covered $types: 15 simple $types, such as LogAction
  • stage 2 - support complicated content rendering
    • extract more widget to support complicated node content
    • covered $types: SendActivity, ReplaceDialog, BeginDialog
  • stage 3 - support multiple nodes rendering
    • implement a InputWidget which looks like current BaseInput
    • covered $types: all input $types, such as TextInput, NumberInput (but exclude OauthInput)
  • stage 4 - support nested uischema definition
    • extend 'uischema''s definition to support rendering nested $types such as IfConditon, Foreach
    • covered $types: branching - IfCondtion, SwitchConditon; loop - Foreach, ForeachPage;
@yeze322 yeze322 added the Needs-triage A new issue that require triage label Dec 13, 2019
@yeze322 yeze322 self-assigned this Dec 13, 2019
@yeze322 yeze322 added R8 Release 8 - March 16th, 2020 Type: Engineering labels Dec 13, 2019
@yeze322
Copy link
Contributor Author

yeze322 commented Dec 13, 2019

@cwhitten this is the 'schema driven' topic we talked today

@cwhitten cwhitten removed the Needs-triage A new issue that require triage label Dec 17, 2019
@yeze322
Copy link
Contributor Author

yeze322 commented Dec 17, 2019

In FormEditor, uischema contains several types of elements:

  1. ui:widget
  2. ui:field
  3. ui:order
  4. ui:hidden
  5. ui:options

1 & 2 define what a SDK type looks like; 3,4,5 provide us convenience to config the form.


In Visual Editor, we will build something similar with FormEditor. Here is an example on 'SendActivity'.

const FormCard = (title, content, menu) => <div>{title}{content}{menu}</div>;
const AdaptiveTitle = data => ConceptLabels[data.$type].title;
const LgField= value = > <LgContent value={value} />

const uischema = {
  [SDKTypes.SendActivity]: {
    'ui:widget': FormCard,
    'ui:theme': <a group of styles>,
    title: AdaptiveTitle,
    content: data => <LgField value={data.activity} />,
  }
}

It will produce a node like this:
image

@yeze322
Copy link
Contributor Author

yeze322 commented Dec 17, 2019

Another example on IfCondition.

const FormCard = (title, content, menu) => <div>{title}{content}{menu}</div>;
const ActionList = (actions: AdaptiveAction[]) => /* leverage uischema*/

const uischema = {
  [SDKTypes.IfCondition]: {
    'ui:widget': IfCondition,
    condition: {
      'ui:widget': FormCard,
      title: 'Condition',
      content: data => data.condition,
    },
    ifBranch: {
      'ui:widget': ActionList,
      actions: data => data.actions,
    },
    elseBranch: {
      'ui:widget': ActionList,
      actions: data => data.elseActions,
    }
  }
}

It will produce a node like this:
image

@yeze322
Copy link
Contributor Author

yeze322 commented Dec 18, 2019

@cwhitten @a-b-r-o-w-n do you have suggestions on the schema format?

@hibrenda
Copy link
Contributor

#1811

@yeze322
Copy link
Contributor Author

yeze322 commented Jan 25, 2020

closed by

@yeze322 yeze322 closed this as completed Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R8 Release 8 - March 16th, 2020 Type: Engineering
Projects
None yet
Development

No branches or pull requests

3 participants