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: inertnal fix screenshot dom display bug #82

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

zzxming
Copy link
Collaborator

@zzxming zzxming commented Sep 25, 2024

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)

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:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • [] No

Other information

Summary by CodeRabbit

  • New Features

    • Introduced a new utility for converting images to Base64 format, enhancing image handling during screenshot processes.
    • Improved the screenshot functionality by simplifying image processing logic and handling fixed/sticky positioned elements more effectively.
    • Added new CSS styles for improved scrolling behavior in fullscreen mode.
  • Bug Fixes

    • Removed outdated image conversion logic that complicated the screenshot process.
  • Chores

    • Disabled Prettier formatting in the development environment by removing related configurations and dependencies.

Copy link

coderabbitai bot commented Sep 25, 2024

Walkthrough

The changes involve the removal of the imgToBase64 function from two demo files, simplifying the image processing logic during screenshot capture. The onclone method in the screenshot configuration has been updated to eliminate the logic that awaited image conversion. A new utility function imgToBase64 has been introduced in a separate file to handle image conversion, while a new function findParentFixed has been added to manage fixed or sticky positioned elements during image rendering. Additionally, Prettier configuration has been removed, affecting formatting rules in the project.

Changes

Files Change Summary
packages/docs/fluent-editor/demos/screenshot-upload-to-server.vue, packages/docs/fluent-editor/demos/screenshot.vue Removed the imgToBase64 function and simplified the screenshot configuration by removing the onclone logic related to image conversion.
packages/fluent-editor/src/screenshot/index.ts Added findParentFixed function for checking fixed/sticky positioning and updated onclone to process fixed/sticky elements and convert images to base64.
packages/fluent-editor/src/utils/image.ts Introduced a new utility function imgToBase64 to convert image URLs to base64 format, handling image loading and error management.
packages/fluent-editor/package.json Removed the prettier dependency and the format script from scripts.
.prettierignore Removed several entries, indicating that those files/directories will now be formatted by Prettier.
.prettierrc Completely removed, meaning that previous formatting rules will no longer apply.
.vscode/settings.json Added a setting to disable Prettier in Visual Studio Code.
packages/fluent-editor/src/assets/fullscreen.scss Updated existing fullscreen CSS rules and added new styles for a .scroll class with nested classes for scrolling behavior in fullscreen mode.
packages/fluent-editor/src/toolbar/index.ts Updated the focus method call in BetterToolbar to conditionally prevent scrolling based on the format.
packages/fluent-editor/src/utils/scroll-lock.ts Introduced functions to measure scrollbar width and lock scroll behavior on specified elements.

Possibly related PRs

  • feat: screenshot #75: The main PR and this PR both involve changes to the imgToBase64 function, which is responsible for converting image URLs to base64 format. The main PR removes this function, while this PR introduces a new implementation of it in the context of a screenshot feature.
  • fix: screenshot functional bug #81: This PR addresses functional bugs related to the screenshot feature, which is directly connected to the changes made in the main PR regarding the handling of images during the screenshot process.
  • fix: word paste missing formats #67: This PR focuses on ensuring that pasted content retains its formatting, which may relate to the overall image handling and processing logic that has been simplified in the main PR.

Suggested labels

bug

Suggested reviewers

  • kagol

Poem

In the garden of code, where rabbits play,
We’ve tidied up functions, made clutter sway.
With images bright, now captured with glee,
A hop and a skip, as simple as can be!
Let’s celebrate changes, both swift and spry,
For in every line, our dreams can fly! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 07f34b2 and 5698789.

📒 Files selected for processing (1)
  • packages/fluent-editor/src/screenshot/index.ts (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/fluent-editor/src/screenshot/index.ts

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?

❤️ Share
🪧 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 resolve resolve all the CodeRabbit review comments.
  • @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 enhancement New feature or request label Sep 25, 2024
Copy link

@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: 4

🧹 Outside diff range and nitpick comments (2)
packages/docs/fluent-editor/demos/screenshot.vue (1)

Remaining References to imgToBase64 Found

The imgToBase64 function still exists and is being used in the following files:

  • packages/fluent-editor/src/utils/image.ts
  • packages/fluent-editor/src/screenshot/index.ts

Please ensure that all usages of imgToBase64 are addressed accordingly.

🔗 Analysis chain

Line range hint 1-35: Clarify the removal of the imgToBase64 function

The imgToBase64 function has been removed from this file. While this might be related to fixing the screenshot display bug, I have a few questions:

  1. Is the functionality of converting images to base64 no longer required for the screenshot feature or anywhere else in the application?
  2. If it's still needed, how is this conversion being handled now?
  3. If it's no longer needed, could you please add a comment explaining why this functionality was removed? This would help future maintainers understand the reasoning behind this change.

Let's check if there are any remaining references to imgToBase64 in the codebase:

This will help us ensure that all references to this function have been properly removed or updated.


Adjusting the search command to correctly include .vue files

The previous search command failed to recognize the vue file type. Please run the following script to search for any remaining references to imgToBase64 in .vue, .ts, and .js files:

[/run_scripts]

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to imgToBase64
rg 'imgToBase64' --type vue --type typescript --type javascript

Length of output: 103


Script:

#!/bin/bash
# Search for any remaining references to imgToBase64 in .vue, .ts, and .js files
rg 'imgToBase64' -g '*.vue' -g '*.ts' -g '*.js'

Length of output: 366

packages/fluent-editor/src/screenshot/index.ts (1)

78-78: Correct typo in comment for clarity

There's a typo in the comment on line 78: "transform will be settle". Consider changing it to "transform will be set" or "transform will be applied" for clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f03dfab and 592fb2b.

📒 Files selected for processing (4)
  • packages/docs/fluent-editor/demos/screenshot-upload-to-server.vue (0 hunks)
  • packages/docs/fluent-editor/demos/screenshot.vue (1 hunks)
  • packages/fluent-editor/src/screenshot/index.ts (3 hunks)
  • packages/fluent-editor/src/utils/image.ts (1 hunks)
💤 Files not reviewed due to no reviewable changes (1)
  • packages/docs/fluent-editor/demos/screenshot-upload-to-server.vue
🔇 Additional comments not posted (5)
packages/fluent-editor/src/utils/image.ts (4)

1-1: LGTM: Function signature is well-defined.

The function signature is clear, descriptive, and properly typed. The use of a Promise for this asynchronous operation is appropriate.


17-20: LGTM: Error handling is appropriate.

The error handling for image loading failures is well implemented. The error message is clear and includes the problematic URL, which will be helpful for debugging.


1-20: Please clarify how this function addresses the PR objectives.

While the imgToBase64 function is well-implemented, it's not immediately clear how it relates to the "screenshot dom display bug" mentioned in the PR objectives. Could you provide more context on how this utility function helps resolve the issue?

To find related changes or usage of this function, run:

#!/bin/bash
# Search for files that import or use the imgToBase64 function
rg --type typescript -e 'import.*imgToBase64' -e 'imgToBase64\('

This will help understand the broader context of the changes and how they relate to the PR objectives.


2-5: 🛠️ Refactor suggestion

Consider security implications and add input validation.

The use of crossOrigin = 'Anonymous' allows loading images from different origins, which is flexible but may have security implications. Additionally, consider adding input validation for the imageUrl parameter.

To check if this function is used with user-provided URLs, run:

Consider adding URL validation:

if (!imageUrl || !/^https?:\/\/.+/.test(imageUrl)) {
  return Promise.reject(new Error('Invalid image URL'));
}
packages/docs/fluent-editor/demos/screenshot.vue (1)

Line range hint 1-35: Summary of changes and potential impact

The changes in this file primarily involve simplifying the screenshot configuration and removing custom image processing logic. While these changes appear to address the screenshot display bug mentioned in the PR objectives, there are a few points to consider:

  1. The removal of custom behavior in the screenshot configuration might affect how screenshots are captured and processed.
  2. The elimination of the imgToBase64 function suggests a change in how images are handled during the screenshot process.

These changes could potentially impact the overall functionality of the screenshot feature. It's crucial to ensure that:

  • The screenshot feature still works as expected after these simplifications.
  • Any dependent code that might have relied on the removed functionality has been updated accordingly.
  • The changes are well-documented, especially if they represent a significant shift in how the screenshot feature operates.

To get a broader view of the impact, let's check for any other files that might be affected by these changes:

#!/bin/bash
# Search for files that mention 'screenshot' in the context of the editor
rg 'screenshot.*editor' --type vue --type typescript --type javascript -l

This will help us identify any other files that might need to be updated or reviewed in light of these changes.

* fix: focus call scrollIntoView effect screenshot position

* fix: scroll bar hide effect page width
kagol
kagol previously approved these changes Sep 26, 2024
@kagol
Copy link
Member

kagol commented Sep 26, 2024

@zzxming 需要解决下冲突哈

@kagol
Copy link
Member

kagol commented Sep 26, 2024

@zzxming 好像现在截图不准确了,不知道是不是和合入 #81 这个PR有关
https://opentiny.github.io/fluent-editor/docs/screenshot

@zzxming
Copy link
Collaborator Author

zzxming commented Sep 27, 2024

@zzxming 好像现在截图不准确了,不知道是不是和合入 #81 这个PR有关 https://opentiny.github.io/fluent-editor/docs/screenshot

哪方面有错误,我这里看好像是正常
image

Copy link

@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

🧹 Outside diff range and nitpick comments (4)
packages/fluent-editor/src/assets/fullscreen.scss (1)

17-20: Approved addition of .scroll__wrap with a suggestion.

The .scroll__wrap class creates a scrollable container that takes up the full height of its parent, which is a good approach for managing overflow content.

Consider adding width: 100%; to ensure the container also takes up the full width of its parent, which is often desirable for scrollable containers:

 .scroll {
   &__wrap {
     overflow: auto;
     height: 100%;
+    width: 100%;
   }
 }
packages/fluent-editor/src/utils/scroll-lock.ts (2)

2-25: Approved with minor suggestions for improvement

The getScrollBarWidth function is well-implemented, using an efficient caching mechanism and a common technique for measuring scrollbar width. However, consider the following improvements:

  1. Add error handling for cases where the target element doesn't exist.
  2. Use more specific class names for temporary elements to avoid potential conflicts.

Here's a suggested implementation with these improvements:

let scrollBarWidth: number
export const getScrollBarWidth = ({ target = document.body } = {}): number => {
  if (scrollBarWidth !== undefined) return scrollBarWidth
  if (!target) throw new Error('Target element not found')

  const outer = document.createElement('div')
  outer.className = 'fluent-editor__scrollbar-measure-outer'
  outer.style.visibility = 'hidden'
  outer.style.width = '100px'
  outer.style.position = 'absolute'
  outer.style.top = '-9999px'
  target.appendChild(outer)

  const widthNoScroll = outer.offsetWidth
  outer.style.overflow = 'scroll'

  const inner = document.createElement('div')
  inner.className = 'fluent-editor__scrollbar-measure-inner'
  inner.style.width = '100%'
  outer.appendChild(inner)

  const widthWithScroll = inner.offsetWidth
  outer.parentNode?.removeChild(outer)
  scrollBarWidth = widthNoScroll - widthWithScroll

  return scrollBarWidth
}

27-52: Approved with suggestions for improvement

The lockScroll function is well-implemented, providing a mechanism to lock scrolling and adjust for the scrollbar width. However, consider the following improvements:

  1. Add error handling for cases where the target element doesn't exist.
  2. Use a more specific class name to avoid potential conflicts.
  3. Make the cleanup function more robust.
  4. Address the static analysis hint about assignment in expressions.

Here's a suggested implementation with these improvements:

const LOCK_CLASS = 'fluent-editor__scroll-lock'

export const lockScroll = ({ target = document.body } = {}) => {
  if (!target) throw new Error('Target element not found')

  let scrollBarWidth = 0
  let originWidth = target.style.width

  const hasLockClass = target.classList.contains(LOCK_CLASS)
  if (hasLockClass) return () => {} // Already locked, return no-op cleanup

  scrollBarWidth = getScrollBarWidth({ target })
  const hasOverflow = (target === document.body ? document.documentElement : target).clientHeight < target.scrollHeight
  const overflowY = window.getComputedStyle(target).overflowY

  if (scrollBarWidth > 0 && (hasOverflow || overflowY === 'scroll')) {
    target.style.width = `calc(100% - ${scrollBarWidth}px)`
  }
  target.classList.add(LOCK_CLASS)

  return () => {
    if (target.classList.contains(LOCK_CLASS)) {
      target.style.width = originWidth
      target.classList.remove(LOCK_CLASS)
    }
  }
}

This implementation addresses the static analysis hint by avoiding assignment in the cleanup function's expression. It also includes other suggested improvements.

🧰 Tools
🪛 Biome

[error] 34-34: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

packages/fluent-editor/src/screenshot/index.ts (1)

69-101: Improved handling of fixed/sticky elements and images.

The new onclone callback effectively addresses the positioning of fixed and sticky elements in screenshots and ensures proper encoding of images. These changes should significantly improve the accuracy of the screenshot output.

However, the suggestion to use getComputedStyle for more reliable style detection has not been implemented. Consider incorporating this change for even more accurate results.

Apply this diff to use getComputedStyle:

- if (dom.style.top !== 'auto') {
+ if (getComputedStyle(dom).top !== 'auto') {
    y = window.scrollY
  }
- if (dom.style.left !== 'auto') {
+ if (getComputedStyle(dom).left !== 'auto') {
    x = window.scrollX
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 592fb2b and 07f34b2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .prettierignore (0 hunks)
  • .prettierrc (0 hunks)
  • .vscode/settings.json (1 hunks)
  • packages/fluent-editor/package.json (2 hunks)
  • packages/fluent-editor/src/assets/fullscreen.scss (1 hunks)
  • packages/fluent-editor/src/screenshot/index.ts (5 hunks)
  • packages/fluent-editor/src/toolbar/index.ts (1 hunks)
  • packages/fluent-editor/src/utils/scroll-lock.ts (1 hunks)
💤 Files not reviewed due to no reviewable changes (2)
  • .prettierignore
  • .prettierrc
🧰 Additional context used
🪛 Biome
packages/fluent-editor/src/utils/scroll-lock.ts

[error] 34-34: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (14)
packages/fluent-editor/src/assets/fullscreen.scss (4)

2-2: Improved code formatting for fullscreen selectors.

The indentation of the background-color property has been standardized across all fullscreen selectors, enhancing code readability and maintaining consistent formatting.

Also applies to: 5-5, 8-8, 11-11


13-21: Excellent use of SCSS nesting and BEM naming convention.

The structure of the new .scroll class and its nested classes demonstrates good use of SCSS features and follows the BEM (Block Element Modifier) naming convention. This approach enhances code readability, maintainability, and scalability.


14-16: Consider the use of !important in .scroll--lock.

The .scroll--lock class uses overflow: hidden !important; which will forcefully prevent scrolling. While this achieves the desired effect, the use of !important can make styles harder to maintain and override in the future.

Consider if !important is absolutely necessary here. If it is, please add a comment explaining why. To check for potential conflicts, let's run:

#!/bin/bash
# Description: Check for other overflow styles that might conflict

# Search for other overflow styles
rg --type css 'overflow:' -C 2

13-13: New .scroll class added.

A new .scroll class has been introduced, which appears to be a container for scroll-related styles.

Could you please provide documentation or comments explaining the purpose and usage of this new class? This will help maintain clear understanding for future developers.

To verify the usage of this class, let's run the following script:

.vscode/settings.json (2)

3-3: ⚠️ Potential issue

Clarify the rationale for disabling Prettier

The addition of "prettier.enable": false raises some concerns:

  1. This change disables Prettier in VS Code, which could lead to inconsistent code formatting across the project.
  2. It doesn't seem to align with the PR's stated objective of fixing a screenshot DOM display bug.
  3. It might conflict with the project's coding standards or CI/CD pipeline.

Could you please clarify:

  1. Why is Prettier being disabled?
  2. How does this relate to the screenshot DOM display bug mentioned in the PR description?
  3. Is this change intended to be temporary or permanent?
  4. Have you confirmed that this won't cause issues with the project's coding standards or CI/CD pipeline?

To ensure this change doesn't conflict with project standards, let's check for Prettier configuration:


Line range hint 1-18: Consider reviewing ESLint configuration for potential improvements

While the ESLint configuration looks generally good, there are a few points to consider:

  1. With Prettier disabled and both ESLint and editor formatting enabled, there might be potential conflicts. Have you tested to ensure these settings work well together?

  2. The "eslint.useFlatConfig": false setting indicates that the project is not using the new ESLint flat config format. Is there a plan to migrate to the flat config in the future for improved performance and flexibility?

  3. The ESLint validation includes JavaScript, TypeScript, and Vue files. Is this comprehensive for your project, or are there any other file types that should be included?

Consider reviewing these settings to ensure they align with the project's long-term goals and best practices.

Let's check the ESLint configuration to ensure it aligns with these VS Code settings:

✅ Verification successful

ESLint Configuration Alignment Verified

The ESLint configuration in .eslintrc.js aligns with the .vscode/settings.json settings. With Prettier disabled and ESLint handling formatting, there should be no conflicts. The ESLint rules are comprehensive for JavaScript, TypeScript, and Vue files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check ESLint configuration
echo "ESLint configuration:"
fd -e js -e cjs -e json --exec grep -l 'eslintConfig' {}

Length of output: 111


Script:

#!/bin/bash
# Search for ESLint configuration files
echo "Searching for ESLint configuration files:"
fd -e js -e mjs -e cjs -e json -e yaml -e yml -e js -e ts '^\.eslintrc(\.js|\.json|\.yaml|\.yml)?$' .

Length of output: 404


Script:

#!/bin/bash
# Search for ESLint configuration files including hidden files
echo "Searching for ESLint configuration files (including hidden files):"
fd -H -e js -e mjs -e cjs -e json -e yaml -e yml -e ts '^\.eslintrc(\.js|\.json|\.yaml|\.yml)?$' .

Length of output: 258


Script:

#!/bin/bash
# Display the contents of the ESLint configuration file
echo "Contents of .eslintrc.js:"
cat ./.eslintrc.js

Length of output: 1914

packages/fluent-editor/package.json (3)

39-39: LGTM: Test script is correctly configured.

The test script is properly set up to use Jest for running tests, which is a standard and recommended practice.


Line range hint 1-62: LGTM: Overall package.json structure is well-maintained.

The package.json file maintains a consistent and standard structure, including all necessary fields such as name, version, description, scripts, and dependencies. The file appears to be well-organized and follows best practices for npm package configuration.


Line range hint 1-62: Verify removal of 'format' script and 'prettier' dependency.

The AI summary indicates that the 'format' script and 'prettier' dependency have been removed, but these changes are not visible in the provided code snippet. If this is correct, it could impact the project's code formatting workflow.

Please run the following script to verify these changes:

If these changes are confirmed:

  1. How will code formatting be handled going forward?
  2. Is there a project-wide decision to remove Prettier, or is this specific to the fluent-editor package?
  3. Have all team members been informed about this change in the development workflow?
✅ Verification successful

Confirmation of Removal of 'format' Script and 'prettier' Dependency

The removal of the 'format' script and 'prettier' dependency in packages/fluent-editor/package.json has been confirmed. This change will impact the project's code formatting workflow.

Please consider addressing the following:

  1. How will code formatting be handled going forward?
  2. Is there a project-wide decision to remove Prettier, or is this specific to the fluent-editor package?
  3. Have all team members been informed about this change in the development workflow?
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of 'format' script and 'prettier' dependency

# Test 1: Check for 'format' script
echo "Checking for 'format' script:"
jq '.scripts.format' packages/fluent-editor/package.json

# Test 2: Check for 'prettier' in devDependencies
echo "Checking for 'prettier' in devDependencies:"
jq '.devDependencies.prettier' packages/fluent-editor/package.json

# Expected results:
# If both commands return 'null', it confirms the removal of the 'format' script and 'prettier' dependency.

Length of output: 311

packages/fluent-editor/src/toolbar/index.ts (1)

143-143: Approve the focus method modification for screenshot functionality.

The change to prevent scrolling when focusing for the 'screenshot' format looks good. This should address the screenshot DOM display bug mentioned in the PR objectives.

To ensure the fix works as intended, please verify the following:

  1. The screenshot functionality works correctly without unexpected scrolling.
  2. Other toolbar actions are not affected by this change.
  3. The user experience for taking screenshots is improved.

Consider adding a test case to cover this scenario if not already present.

packages/fluent-editor/src/screenshot/index.ts (4)

5-6: LGTM: New imports for enhanced functionality.

The addition of imgToBase64 and lockScroll imports suggests improved image processing and scroll management, which aligns well with the screenshot feature enhancements.


55-59: Skipping comment on potential null reference error.

A previous review has already addressed the potential null reference error in the findParentFixed function. Please refer to the existing comment for the suggested fix.


144-144: LGTM: Improved scroll management during screenshot process.

The addition of lockScroll and its cleanup calls effectively prevents unwanted scrolling during the screenshot process, enhancing the user experience. The placement of cleanLock() calls ensures proper cleanup in various scenarios.

Also applies to: 149-149, 157-157


Line range hint 1-238: Summary of changes and suggestions

The changes in this file effectively address the screenshot DOM display bug by:

  1. Improving the handling of fixed and sticky positioned elements.
  2. Ensuring proper encoding of images in the screenshot.
  3. Implementing scroll locking during the screenshot process.

These enhancements should significantly improve the accuracy and user experience of the screenshot feature. Consider implementing the suggested use of getComputedStyle for even more reliable style detection.

Overall, the changes align well with the PR objectives and represent a solid improvement to the screenshot functionality.

🧰 Tools
🪛 Biome

[error] 66-67: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants