-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
BREAKING fix(Text): styles onInput
#9096
Conversation
BERAKING: `get2DCursorLocation` => `getCursorPosition`, `getStyleCursorPosition`
Build Stats
|
BREAKING: rm `getCurrentCharFontSize`, `getCurrentCharColor`, `_getCurrentCharIndex`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
**BERAKING**: `get2DCursorLocation` => `getCursorPosition`, `getStyleCursorPosition` | ||
**BREAKING**: rm `getCurrentCharFontSize`, `getCurrentCharColor`, `_getCurrentCharIndex` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add to #8299
@@ -182,7 +185,7 @@ export abstract class StyledText< | |||
} | |||
|
|||
private _extendStyles(index: number, styles: TextStyleDeclaration): void { | |||
const { lineIndex, charIndex } = this.get2DCursorLocation(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUG!
commit 05da60d Author: ShaMan123 <shacharnen@gmail.com> Date: Sat Jul 15 12:40:06 2023 +0530 cleanup commit ac82663 Author: ShaMan123 <shacharnen@gmail.com> Date: Sat Jul 15 12:38:34 2023 +0530 Update Text.ts commit bfb99e9 Author: ShaMan123 <shacharnen@gmail.com> Date: Sat Jul 15 10:32:28 2023 +0530 progress commit 610bcb8 Author: ShaMan123 <shacharnen@gmail.com> Date: Sat Jul 15 09:26:27 2023 +0530 d
Progress
Parcel.Sandbox.-.Google.Chrome.2023-07-15.14-05-42_Trim.mp4 |
Almost all the calls to _getStyleDeclaration are wrong |
commit 8c7f09f29d5a095aa1a25299c9729b5a063537e9 Author: ShaMan123 <shacharnen@gmail.com> Date: Sat Jul 15 15:43:34 2023 +0530 artifacts commit 849cc479c781be1246521b40e413d5a8d9dafba0 Author: ShaMan123 <shacharnen@gmail.com> Date: Sat Jul 15 15:39:26 2023 +0530 cleanup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking stable
I want to add tests but I do not know how to generate playwright tests yet
blocked by #9078 to perform snapshots |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from adding snapshot for the playwright test this is DONE so feel free to review
*/ | ||
get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) { | ||
const lines = skipWrapping ? this._unwrappedTextLines : this._textLines; | ||
getCursorPosition(index: number, lines = this._textLines) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure 100% this method is not buggy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops I broke - jest has already proven its valuesetSelectionStyles
- should merge the style and not override
onInput
updated desc, playwright is the bomb |
import type { GLProbe } from '../filters/GLProbes/GLProbe'; | ||
import type { DOMWindow } from 'jsdom'; | ||
|
||
export type TCopyPasteData = { | ||
copiedText?: string; | ||
copiedStyle?: Record<string, string>; | ||
copiedTextStyle?: TextStyleDeclaration[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asturur this bug was not fixed in your PR, was it?
Motivation
closes #9028
Description
I had an Eureka about text styles and saw it to be true
There was a confusion in the code, styles correlates to the UNWRAPPED lines so I decided to make it strict.
This was found across a lot of logic
Changes
BERAKING:
get2DCursorLocation
=>getCursorPosition
,getStyleCursorPosition
to avoid confusionThe dev will be happy to find this breaking because it will uncover bugs.
BREAKING: rm
getCurrentCharFontSize
,getCurrentCharColor
,_getCurrentCharIndex
BREAKING: rm
cleanStyle
,removeStyle
,_extendStyles
,_setStyleDeclaration
,_deleteStyleDeclaration
,_getLineStyle
,_setLineStyle
,_deleteLineStyle
BREAKING: rm
_getStyleDeclaration
,getCompleteStyleDeclaration
=>getStyleDeclaration
Gist
In Action
https://github.com/fabricjs/fabric.js/assets/34343793/e31635bb-906c-432b-bf01-d7524b995d35
video.webm
Fresh from PLAYWRIGHT
FIXED
video.webm
MASTER
video.webm