feat: add parentScale #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/parent-scale"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
When the editor or its parent container has the
transform.scalestyle and the value is not equal to 1, the drop cursor position will be misaligned when the text is selected and dragged in the editor.Changelog
parentScaleto address the cursor misaligned problem caused by setting a non-1 scale on the parent component. The default value is 1.updateOverlaymethod about calculating the width, height, and positioning of the cursor element, the new code will correct the calculation according to theparentScalevalue, and keep the same logic with the original code when theparentScaleis 1 by default.Details
parentScaleis an optional parameter, it should be set only when the scale style is set by the editor or parent component and the value is not equal to 1.parentScaleparameter can benumberor(()=>number).Screenshots
I set the dropcursor property to {width: 10, color: "orange"} to make the cursor stand out more in the screenshot.
Before:


After:
Code Samples
Here's a code sample that can be used to reproduce the cursor misalignment problem and to validate the modified code. Replacing the following code with the contents of the corresponding directory file in the demo should work fine.
demo/index.html
example-setup/src/index.ts
This can be reproduced or verified by toggling the code in the dropCursor comments section of the plugins.
dropcursor/src/dropcursor.ts
Thank you for reviewing my PR!
Does patch
af2c980, which attempts to make this work without action from the user, work for you?Yes, but the width or height of drop cursor doesn't look correct when scale is not 1. I tried to fix this issue in #19. please check, thanks.
Pull request closed