Skip to content

fix: some version issue#1267

Merged
hexqi merged 5 commits intoopentiny:release/v2.4.0from
SonyLeo:fix/version-issue
Apr 2, 2025
Merged

fix: some version issue#1267
hexqi merged 5 commits intoopentiny:release/v2.4.0from
SonyLeo:fix/version-issue

Conversation

@SonyLeo
Copy link
Contributor

@SonyLeo SonyLeo commented Mar 31, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • 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
  • 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?

  1. 设置 margin 后画布切换节点时,模态框数值不更新
  2. 插件面板拖拽时,拖拽线不好触发, 拖动时不流畅
  3. 选中节点复制时,粘贴内容可能为 [null]
  4. 国际化插件面板,无词条时有滚动条
    不含词条 - before

Issue Number: N/A

What is the new behavior?

  1. 画布设置 margin 后画布切换节点时节点时,模态框数值更新

margin 数值更新 - after

  1. 插件面板拖拽时,拖拽标记统一,拖拽线更容易触发,拖动流畅

拖拽样式优化 - after

  1. 选中节点复制时,粘贴内容正常显示,不为 [null]
  2. 国际化插件面板,无词条时不展示滚动条

如未生效,请清空浏览器缓存再试

不含词条 - after

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced clipboard copy behavior to ensure only valid selections are processed, reducing unexpected actions.
  • New Features

    • Improved panel interactions with smoother, more responsive resizing.
    • Enabled real-time synchronization in style modals for up-to-date property displays.
  • Style

    • Refined resizer visuals with updated cursor and transition effects.
    • Adjusted grid selection column width for a more balanced layout.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 31, 2025

Walkthrough

This pull request implements several improvements across multiple components. In the canvas package, it enhances the clipboard copy functionality by adding validation to ensure that selected nodes are valid before serialization. The plugin panel component sees improvements in type safety and resizing performance by using explicit type annotations and requestAnimationFrame throttling. A spacing group component now watches for changes in style properties to keep modal values in sync. Finally, a minor layout tweak adjusts the width of a grid column in the i18n package.

Changes

File(s) Summary
packages/canvas/container/src/keyboard.ts Added validation checks in handleCopyEvent to ensure selected nodes exist and are valid before serializing and setting the clipboard schema.
packages/common/component/PluginPanel.vue Enhanced type safety with explicit type annotations, introduced a new updateWidth function using requestAnimationFrame for smoother panel resizing, and refined styling for resizer elements.
packages/settings/styles/src/components/spacing/SpacingGroup.vue Integrated a watch function to monitor the style prop and update modal display values dynamically; updated import statements accordingly.
packages/plugins/i18n/src/Main.vue Adjusted the width of the <tiny-grid-column> (selection column) from 44 to 42, modifying the grid layout.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CopyHandler as handleCopyEvent
    participant Clipboard
    User->>CopyHandler: Trigger copy event
    CopyHandler->>CopyHandler: Check if nodes are selected
    alt No nodes selected
        CopyHandler-->>User: Exit copy operation
    else Nodes selected
        CopyHandler->>CopyHandler: Validate each selected node
        alt Any node invalid
            CopyHandler-->>User: Abort operation
        else All nodes valid
            CopyHandler->>CopyHandler: Serialize nodes to JSON
            CopyHandler->>Clipboard: Set clipboard schema with JSON
            CopyHandler-->>User: Copy complete
        end
    end
Loading
sequenceDiagram
    participant User
    participant MouseEventHandler as onMouseMove
    participant PanelUpdater as updateWidth
    participant RAF as requestAnimationFrame
    User->>MouseEventHandler: Mouse move triggers resize
    MouseEventHandler->>PanelUpdater: Invoke updateWidth
    PanelUpdater->>RAF: Cancel previous frame (if any)
    PanelUpdater->>RAF: Schedule new frame for width update
    RAF->>PanelUpdater: Execute width adjustment
    PanelUpdater-->>User: Updated panel width rendered
Loading

Possibly related PRs

Suggested reviewers

  • hexqi
  • chilingling

Poem

I'm a bunny hopping through the code,
Checking each node along the road.
Validations now lead the way,
Ensuring smooth copying every day.
With a twirl of keys and a festive cheer,
CodeRabbit Inc. makes bugs disappear!
🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82e158a and b12f11e.

📒 Files selected for processing (2)
  • packages/plugins/i18n/src/Main.vue (1 hunks)
  • packages/settings/styles/src/components/spacing/SpacingGroup.vue (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/plugins/i18n/src/Main.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/settings/styles/src/components/spacing/SpacingGroup.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: push-check

🪧 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

@github-actions github-actions bot added the bug Something isn't working label Mar 31, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/common/component/PluginPanel.vue (1)

165-237: Consider refactoring duplicate mouse event handlers.

While the current implementation works well, there's some duplication between the left and right resizer mouse event handlers. Consider refactoring to extract common logic into shared functions.

- const onMouseUpRight = () => {
-   changeMoveDragBarState(false)
-   document.removeEventListener('mousemove', throttledMouseMoveRight)
-   document.removeEventListener('mouseup', onMouseUpRight)
-   document.body.style.cursor = ''
-   if (rightResizer.value) {
-     rightResizer.value.classList.remove('dragging')
-   }
- 
-   // 清理 requestAnimationFrame
-   if (rafId) {
-     cancelAnimationFrame(rafId)
-     rafId = null
-   }
- }
- 
- const onMouseDownRight = (event: MouseEvent) => {
-   changeMoveDragBarState(true)
-   startX = event.clientX
-   startWidth = panel.value?.offsetWidth || 0
-   document.addEventListener('mousemove', throttledMouseMoveRight)
-   document.addEventListener('mouseup', onMouseUpRight)
-   document.body.style.cursor = 'col-resize'
-   if (rightResizer.value) {
-     rightResizer.value.classList.add('dragging')
-   }
- }
- 
- const onMouseUpLeft = () => {
-   changeMoveDragBarState(false)
-   document.removeEventListener('mousemove', throttledMouseMoveLeft)
-   document.removeEventListener('mouseup', onMouseUpLeft)
-   document.body.style.cursor = ''
-   if (leftResizer.value) {
-     leftResizer.value.classList.remove('dragging')
-   }
- 
-   if (rafId) {
-     cancelAnimationFrame(rafId)
-     rafId = null
-   }
- }
- 
- const onMouseDownLeft = (event: MouseEvent) => {
-   changeMoveDragBarState(true)
-   startX = event.clientX
-   startWidth = panel.value?.offsetWidth || 0
-   document.addEventListener('mousemove', throttledMouseMoveLeft)
-   document.addEventListener('mouseup', onMouseUpLeft)
-   document.body.style.cursor = 'col-resize'
-   if (leftResizer.value) {
-     leftResizer.value.classList.add('dragging')
-   }
- }

+ // Generic cleanup function for mouse up events
+ const cleanupResizing = (resizer: ResizerElement, moveHandler: (event: MouseEvent) => void, upHandler: () => void) => {
+   changeMoveDragBarState(false)
+   document.removeEventListener('mousemove', moveHandler)
+   document.removeEventListener('mouseup', upHandler)
+   document.body.style.cursor = ''
+   if (resizer) {
+     resizer.classList.remove('dragging')
+   }
+ 
+   if (rafId) {
+     cancelAnimationFrame(rafId)
+     rafId = null
+   }
+ }
+ 
+ // Generic setup function for mouse down events
+ const setupResizing = (
+   event: MouseEvent,
+   resizer: ResizerElement,
+   moveHandler: (event: MouseEvent) => void,
+   upHandler: () => void
+ ) => {
+   changeMoveDragBarState(true)
+   startX = event.clientX
+   startWidth = panel.value?.offsetWidth || 0
+   document.addEventListener('mousemove', moveHandler)
+   document.addEventListener('mouseup', upHandler)
+   document.body.style.cursor = 'col-resize'
+   if (resizer) {
+     resizer.classList.add('dragging')
+   }
+ }
+ 
+ const onMouseUpRight = () => {
+   cleanupResizing(rightResizer.value, throttledMouseMoveRight, onMouseUpRight)
+ }
+ 
+ const onMouseDownRight = (event: MouseEvent) => {
+   setupResizing(event, rightResizer.value, throttledMouseMoveRight, onMouseUpRight)
+ }
+ 
+ const onMouseUpLeft = () => {
+   cleanupResizing(leftResizer.value, throttledMouseMoveLeft, onMouseUpLeft)
+ }
+ 
+ const onMouseDownLeft = (event: MouseEvent) => {
+   setupResizing(event, leftResizer.value, throttledMouseMoveLeft, onMouseUpLeft)
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24a3bcc and 82e158a.

📒 Files selected for processing (4)
  • packages/canvas/container/src/keyboard.ts (1 hunks)
  • packages/common/component/PluginPanel.vue (3 hunks)
  • packages/plugins/i18n/meta.js (1 hunks)
  • packages/settings/styles/src/components/spacing/SpacingGroup.vue (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: push-check
🔇 Additional comments (11)
packages/plugins/i18n/meta.js (1)

6-6: Resolves unnecessary scrollbar with precise width adjustment.

This small adjustment from 600px to 602px resolves the issue where the internationalization plugin panel was showing a scrollbar even when no entries were present. The 2px increase provides just enough space to prevent the browser from rendering a scrollbar in empty states.

packages/canvas/container/src/keyboard.ts (1)

146-157: Added validation prevents [null] content when copying nodes.

The added validation logic effectively resolves the issue where pasted content could appear as [null]. The implementation now:

  1. Checks if any nodes are selected before proceeding
  2. Verifies that all selected nodes are valid (non-null and have at least one property)
  3. Only proceeds with the clipboard operation when these conditions are met

This defensive approach ensures that only valid node data is copied to the clipboard.

packages/settings/styles/src/components/spacing/SpacingGroup.vue (2)

391-392: Added missing Vue watch import.

Added import of the watch API from Vue, which is now used to implement reactivity for style changes.


484-496: Fixed modal values not updating when switching nodes.

This watch function solves the issue where margin settings in the modal wouldn't update when switching between different nodes on the canvas. Now when the user selects a different node while the modal is open, the displayed property values will immediately reflect the newly selected node's styles.

The deep watching ensures all nested property changes are detected, providing a seamless user experience when navigating between different elements.

packages/common/component/PluginPanel.vue (7)

124-138: Improved type safety with TypeScript annotations.

Adding proper TypeScript type definitions improves code robustness and helps catch potential errors at compile time. The interface definition for PanelState makes the contract more explicit for components that interact with this panel.


154-163: Enhanced resizing performance with requestAnimationFrame.

This new updateWidth function significantly improves the panel resizing experience by:

  1. Using requestAnimationFrame for smoother visual updates
  2. Canceling previous animation requests to prevent jank
  3. Centralizing the width calculation and update logic

This is a key improvement addressing the "drag-and-drop functionality is not smooth" issue from the PR objectives.


176-177: Increased responsiveness by reducing throttle time.

Reducing the throttle time from 50ms to 16ms (approximately matching 60fps) makes the resizing feel much more responsive and natural to users, while still preventing excessive DOM updates.


193-197: Improved resource management for animations.

Properly cleaning up animation frames prevents potential memory leaks and performance issues when resizing operations complete. This is good practice for maintaining application performance.

Also applies to: 221-224


329-368: Enhanced resizer visual feedback.

The styling improvements make the drag handles more visible and provide better visual feedback during interaction:

  1. Wider clickable area (3px instead of the default)
  2. More distinctive appearance when hovering and dragging
  3. Smoother transitions for a polished feel

These changes directly address the "drag line is difficult to trigger" issue mentioned in the PR objectives.


371-398: Consistent styling for left resizer.

Applied the same styling improvements to the left resizer for consistency, ensuring both sides of the panel have the same interaction quality.


206-206: Better cursor indication for resizing.

Changed the cursor from ew-resize to col-resize, which is the standard cursor for column resizing operations in most applications. This provides users with more familiar visual feedback.

Also applies to: 233-233

@hexqi hexqi merged commit c7da837 into opentiny:release/v2.4.0 Apr 2, 2025
2 checks passed
@SonyLeo SonyLeo deleted the fix/version-issue branch August 24, 2025 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants