feat(plugin): add toolbar codesandbox plugin
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our Commit Message Guidelines
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] Built its own designer, fully self-validated
PR Type
What kind of change does this PR introduce?
- [ ] Bugfix
- [x] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
新增 Codesandbox 平台代码预览插件
点击预览按钮后,在 Codesandbox 平台对当前应用进行预览;
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No
Other information
Summary by CodeRabbit
-
New Features
- Added CodeSandbox toolbar integration to the design platform.
- Introduced ability to save and export projects to CodeSandbox.
- Enhanced toolbar configuration with new CodeSandbox option.
-
Dependencies
- Added new dependencies for CodeSandbox functionality.
-
Configuration
- Updated Vite configuration to support new toolbar.
- Added path mappings for CodeSandbox module resolution.
- Introduced new constant for CodeSandbox preview identifiers.
- Enhanced server configuration to allow requests from specified hosts.
Walkthrough
This pull request introduces the CodeSandbox toolbar functionality to the Tiny Engine project. The changes span multiple files across the project, adding a new toolbar option that allows users to save and export their current project to CodeSandbox. The implementation includes creating a new toolbar package, updating configuration files, and integrating the CodeSandbox feature into the existing design system. The changes modify module resolution, import paths, and add necessary dependencies to support the new toolbar functionality.
Changes
| File | Change Summary |
|---|---|
designer-demo/registry.js |
Added Codesandbox import and updated toolbar configuration |
designer-demo/vite.config.js |
Added define property and updated server port |
jsconfig.json |
Added path mappings for CodeSandbox toolbar module |
packages/build/vite-config/src/vite-plugins/devAliasPlugin.js |
Added alias mapping for CodeSandbox toolbar |
packages/design-core/index.js |
Added export for Codesandbox component |
packages/design-core/package.json |
Added new dependencies for CodeSandbox |
packages/toolbars/codesandbox/* |
Created new toolbar package with multiple configuration and source files |
packages/utils/src/constants/index.js |
Added PREVIEW_SANDBOX constant |
packages/vue-generator/src/templates/vue-template/templateFiles/genViteConfig.js |
Added server configuration for allowed hosts |
packages/toolbars/generate-code/src/composable/useSaveLocal.js |
Enhanced functionality with new methods for data handling |
Possibly related PRs
- #850: Integrates the
Codesandboxfunctionality into the toolbar configuration, related to enhancements in canvas functionality with hooks for save and preview features. - #556: Modifies the
packages/design-core/index.jsfile regarding the export of toolbar functionalities, closely linked to changes in this PR. - #1010: Adds the
ViewSettingcomponent to the same toolbar configuration, affecting thetoolbarsarray indesigner-demo/registry.js.
Suggested labels
enhancement, ready_for_review, ready to merge
Suggested reviewers
- hexqi
- rhlin
Poem
🐰 A Rabbit's CodeSandbox Delight
With toolbar magic, code takes flight,
Sandbox opens, a digital might,
Bits and bytes in playful dance,
Engineering with a rabbit's glance! 🚀
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
packages/vue-generator/src/templates/vue-template/templateFiles/genViteConfig.js
Oops! Something went wrong! :(
ESLint: 8.57.1
Error: Cannot read config file: /packages/vue-generator/.eslintrc.cjs Error: Cannot find module '@rushstack/eslint-patch/modern-module-resolution' Require stack:
- /packages/vue-generator/.eslintrc.cjs
- /node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
- /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
- /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
- /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
- /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
- /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15) at Module._load (node:internal/modules/cjs/loader:1074:27) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12) at require (node:internal/modules/helpers:135:16) at Object.
(/packages/vue-generator/.eslintrc.cjs:4:1) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.