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

feat: Visual Editor as an extension #2586

Merged
merged 31 commits into from
Apr 14, 2020
Merged

feat: Visual Editor as an extension #2586

merged 31 commits into from
Apr 14, 2020

Conversation

yeze322
Copy link
Contributor

@yeze322 yeze322 commented Apr 9, 2020

Description

Apply the extension pattern to Visual Editor
fix #2120

Extension pattern's impact on Visual Editor

  1. Visual Editor received verbose props before, now it consumes Extension context.
    image

  2. Visual Editor didn't support plugin before, now it supports plugin so we can put complicated $kinds out of visual's core lib.
    image

  3. Visual Editor's uischema (visualSchema) only supported direct import React Component before, now it supports register a widget and consume it by string.
    image

Main changes

  1. naming pattern: uiSchemaXXX -> visualSchemaXXX
  2. integrate Visual Editor to the plugin system
  3. move several complicated $kinds to plugins (SendActivity -> plugin/lg, TextInput / ChoiceInput ... -> plugin/prompts)
  4. create @bfc/ui-shared lib to share ui elements between Visual Editor and plugins (shared as a design language)

Plugin schema that Visual Editor supports

Visual Editor requires two parts of config -- widgets and schema

{
  // register a React component as a visual editor widget named 'LgWidget'
  widgets: {
    LgWidget: (lgTemplateName) => <>Some React nodes</>,
  },
  schema: {
    'Microsoft.SendActivity': {
      // consume the widget
      widget: 'LgWidget',
      field: 'activity',
    }
  }
}

As an example, in plugins/lg, it declares a widget named 'LgWidget' and register the visual node definition of Microsoft.SendActivity.
image

Task Item

closes #2120

Screenshots

@yeze322 yeze322 changed the base branch from stable to master April 9, 2020 13:48
@yeze322 yeze322 changed the title draft: Visual Editor as an extension feat: Visual Editor as an extension Apr 13, 2020
@yeze322 yeze322 marked this pull request as ready for review April 13, 2020 13:09
@yeze322 yeze322 requested a review from cwhitten as a code owner April 13, 2020 13:09
@github-actions
Copy link

Coverage Status

Coverage decreased (-0.07%) to 41.172% when pulling f192fd3 on visual/extension into c74fc2c on master.

@@ -6,6 +6,7 @@ import { PluginConfig } from '@bfc/extension';

const PluginContext = React.createContext<Required<PluginConfig>>({
uiSchema: {},
visual: {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these names here are odd. uiSchema ? visual ? Questions I have as a developer using this interface:

  1. What's the difference? uiSchema corresponds to forms and visual corresponds to the flow editor? Not very self-descriptive.
  2. Why the need for both?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think would be most intuitive?

I think making a change like make sense.

interface uiSchema {
  formSchema: FormSchema;
  flowSchema: FlowSchema;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @yeze322 can you make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-b-r-o-w-n @cwhitten Great! It's a good name, I will update it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visual renamed to flowSchema, renamed uiSchema to formSchema in a separated PR #2634

@yeze322
Copy link
Contributor Author

yeze322 commented Apr 14, 2020

renamed uiSchema to formSchema in a separated PR #2634

* PluginConfig.uiSchema ->formSchema

* fix alphabetical issue in test
@cwhitten cwhitten merged commit c81949c into master Apr 14, 2020
@cwhitten cwhitten deleted the visual/extension branch April 14, 2020 15:42
lei9444 pushed a commit to lei9444/BotFramework-Composer-1 that referenced this pull request Jun 15, 2021
* rename 'ui:widget' field to 'widget'

* change default widget to ActionHeader

* fix visual editor demo

* simplify visual schema

* support loading widgets via reflection

* uischema -> visualSchema

* drive TypesWithoutWrapper as 'nowrap' in schema

* remove outdated files

* hoists visualSchema.types to @bfc/extension

* rename visualSchema to defaultVisualSchema

* fix demo

* consume Extension context in Visual

* declare schema as  Visual Props

* let visual editor consume plugin schema

* split visual config to widgets & schema

* implement visual plugin merge strategy

* migrate SendActivity to Lg plugin

* move styled components to external lib

* move prompts visual schema to 'prompts' plugin

* rename @visual-designer-elements to @ui-shared

* use ui-shared in LG

* fix visual widget type declaration

* add missing workspace dependency

* remove ActivityRenderer (replaced by LgWidget)

* remove unref vars

* rename: visualSchema -> flowSchema

* update config key to `visualSchema`

* chore: rename 'uiSchema' in PluginConfig to 'formSchema' (microsoft#2634)

* PluginConfig.uiSchema ->formSchema

* fix alphabetical issue in test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants