-
-
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
refactor(): canvas text editing manager #8543
Conversation
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.
Progress
src/shapes/text.class.ts
Outdated
@@ -94,7 +94,7 @@ export class Text< | |||
* @type Array | |||
* @private | |||
*/ | |||
_dimensionAffectingProps: (keyof this)[]; | |||
_dimensionAffectingProps: string[]; |
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.
TS went mad because of this line
|
||
add(target: IText | Textbox) { | ||
if (!this.disposer) { | ||
const disposer = this.canvas.on('mouse:up', () => { |
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.
I will try to remove the need for the subscription
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
Build Stats
|
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.
seems ready
tested live as well
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.
updated from master
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.
extensive test
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.
I am not sure why the mouse move handler (now renamed to so moving outside the textbox will still update selection.updateSelection
) is not called from the object's mousemove event.
- It seems
selected
is handled by mouse up so no need to false it from the manager - rm
__isMousedown
:- used for updating selection only when mouse move after mouse down (now handled by the manager)
- used to render the cursor with global alpha = 1, fixed to not run cursor animation in such a case
This PR is becoming less scoped and is about to clash with #8583 #8534
A few fixes so tests pass and I am done hopefully
@@ -521,7 +434,6 @@ export abstract class ITextBehaviorMixin< | |||
this.selectionStart !== currentStart || | |||
this.selectionEnd !== currentEnd | |||
) { | |||
this.restartCursorIfNeeded(); |
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.
important fix
no reason to do this here, in case of a cursor the animation will be started from mouse up
// avoid running this logic when there is an active object | ||
// this because is possible with shift click and fast clicks, | ||
// to rapidly deselect and reselect this object and trigger an enterEdit | ||
return; | ||
} | ||
|
||
if (this.__lastSelected && !this.__corner) { |
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.
this bit is really harsh, hard to understand logic
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.
READY
I think this all in all is better than what we had before, is also a change that will open up to regressions for sure. |
Oh also please tell me more about those nexted Itexts |
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.
applied changes from review
This is good work imho, just not convinced about that _set usage. |
Very good point |
Motivation
Another step making text classes readable, simpler, Scoped which they are absolutely not
Description
extracted the logic that handles canvas itext instances from itext_behavior to a dedicated manager
Changes
_set
. This will handle cases such as nested itexts.Gist
In Action