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

优化代码编辑体验,仅在切换模式时同步文件 AST 信息 #188

Closed
wants to merge 11 commits into from

Conversation

wwsun
Copy link
Contributor

@wwsun wwsun commented Jul 23, 2024

Feature

  • 新增 EditorState ,用来独立管理源码编辑器文件状态
  • 仅在切换模式的时候同步编辑器状态:
    • code -> design: EditorState --snyc--> Workspace
    • design -> code: Workspace --sync--> EditorState
  • 模式切换时增加了错误提示浮沉,如果文件错误,不会进行同步操作
    image

if (view === 'dual') {
this.setActiveSidebarPanel('');
this.toggleRightPanel(false);
this.toggleIsPreview(true);
workspace2editor();
} else if (view === 'design') {
this.toggleIsPreview(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

切回设计视图的时候,默认不激活 RightPanel,在用户点击画布节点的时候(use-dnd onClick)中可以自动激活下 RightPanel ?

designer: new Designer({
workspace,
editor: editorState,
Copy link
Contributor

Choose a reason for hiding this comment

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

目前相当于存在 工作区文件和 IDE 文件两种文件,在切换的时候做一次 clear 文件再同步

考虑 API 兼容的话,从关系上是不是 editor 注入在 workspace 中合适一些

workspace >> editor >> designer,API 也可以默认走 workspace,原有的 setActiveFile/CRUD File 相关 API 可以内部判断设计器状态来抹平

例如单边使用的场景:纯使用可视化面板/纯使用 IDE,在最终提交代码的时候消费哪个 API ?

onCancel: () => {},
});
}
editorState.updateFile({ filename: path, code: value });
Copy link
Contributor

Choose a reason for hiding this comment

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

此处直接更新,在 editor2workspace 的时候,如果是错误的代码,在 workspace 重新 addFile的时候会不会有问题(导致设计视图白屏)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

此处可以在切换模式的时候增加 ErrorBoundary-- 提示用户是否代码错误

Copy link
Contributor Author

Choose a reason for hiding this comment

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

模式切换时增加了错误提示浮沉,如果文件错误,不会进行同步操作 image

@wwsun wwsun self-assigned this Jul 26, 2024
@BoBoooooo
Copy link
Contributor

BoBoooooo commented Jul 26, 2024

image

@wwsun wwsun closed this Jul 30, 2024
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