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: custom widget #325

Merged
merged 6 commits into from
Mar 7, 2022
Merged

feat: custom widget #325

merged 6 commits into from
Mar 7, 2022

Conversation

MrWindlike
Copy link
Contributor

@MrWindlike MrWindlike commented Mar 2, 2022

Changes:

  • Adding new @sunmao-ui/editor-sdk package
  • Adding ChakraUI components into the kit object and exporting it
  • Changing all the form widgets according to the proposal
  • Fix the editor crash problem when the default values are not right

Ref ISSUE: #313

@netlify
Copy link

netlify bot commented Mar 2, 2022

✔️ Deploy Preview for mystifying-kirch-d00a2f ready!

🔨 Explore the source changes: 5ec71b1

🔍 Inspect the deploy log: https://app.netlify.com/sites/mystifying-kirch-d00a2f/deploys/622579d596b92e0007f813cc

😎 Browse the preview: https://deploy-preview-325--mystifying-kirch-d00a2f.netlify.app/

@MrWindlike MrWindlike marked this pull request as draft March 2, 2022 10:34
@@ -12,6 +13,7 @@ import {
import { genComponent } from './utils';

export class AppModel implements IAppModel {
widgets: Record<string, Widget> = {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

AppModel is the model of application schema. Widgets are not part of application schema, so they should not be registered here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will use a new model to manage the widgets.

@MrWindlike MrWindlike marked this pull request as ready for review March 4, 2022 01:32
@MrWindlike MrWindlike changed the title WIP: custom widget feat: custom widget Mar 4, 2022
"typings": "tsc --emitDeclarationOnly",
"prepublish": "npm run build && npm run typings"
},
"dependencies": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add peer dependencies like other project.

"@sunmao-ui/chakra-ui-lib": "^0.2.0",
"@sunmao-ui/core": "^0.4.0",
"@sunmao-ui/editor-sdk": "^0.5.0-alpha1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did editor-sdk publish this version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has not yet been, but the lerna would parse it as a local package. What version of editor-sdk should use here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

0.0.0 for now.

packages/editor/src/components/CodeEditor/CssEditor.tsx Outdated Show resolved Hide resolved
import { Component, ComponentSchema } from '@sunmao-ui/core';
import { EditorServices } from './editor';

export type Schema = Component<string, string, string, string>['spec']['properties'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is JSONSchema7


export type WidgetProps<WidgetOptions = Record<string, any>> = {
component: ComponentSchema;
schema: Schema & EditorSchema<WidgetOptions>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess here is actually spec. The spec of component properties.

onChange: (v: any) => void;
};

export type WidgetOptions = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name should be Widget according to the naming rule in core.

};
};

export type Widget<T = Record<string, any>> = WidgetOptions & {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be ImplementedWidget

@tanbowensg
Copy link
Collaborator

Still has conflicts. And why there are 15000 lines change?

@MrWindlike MrWindlike changed the base branch from main to feat/windlike-patch March 7, 2022 03:08
@MrWindlike MrWindlike changed the base branch from feat/windlike-patch to main March 7, 2022 03:08
@MrWindlike
Copy link
Contributor Author

@tanbowensg OK. I think there is a problem with GitHub displaying the changes. After I solve the conflicts the changes become correct.

@tanbowensg tanbowensg merged commit 2a69eb9 into main Mar 7, 2022
@tanbowensg tanbowensg deleted the feat/custom-widget branch March 7, 2022 06:09
xzdry pushed a commit that referenced this pull request Nov 3, 2022
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.

2 participants