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

chore(TS): IText types #8610

Merged
merged 128 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
f750f9d
Update itext_behavior.mixin.ts
ShaMan123 Dec 20, 2022
617bc87
Update itext_behavior.mixin.ts
ShaMan123 Dec 22, 2022
db8739a
fix(): bad conflict resolution
ShaMan123 Dec 22, 2022
5555c5c
fix no dpr on drag image offset
ShaMan123 Dec 22, 2022
df95065
fix(): drag image + vpt
ShaMan123 Dec 22, 2022
9ec6440
test `isIdentityMatrix`
ShaMan123 Dec 22, 2022
c385df1
Update CHANGELOG.md
ShaMan123 Dec 22, 2022
057af08
cleanup
ShaMan123 Dec 22, 2022
7fb8378
fix(): acount for stroke style
ShaMan123 Dec 22, 2022
7899a25
drag image visual tests
ShaMan123 Dec 22, 2022
92cfc43
Update itext_behavior.mixin.ts
ShaMan123 Dec 22, 2022
328a016
better goldens
ShaMan123 Dec 22, 2022
2bdf139
Merge branch 'master' into fix-text-dnd
ShaMan123 Dec 29, 2022
9ca3c4f
Update CHANGELOG.md
ShaMan123 Jan 3, 2023
ecb8073
Merge branch 'master' into fix-text-dnd
ShaMan123 Jan 4, 2023
ee30fec
export isIdentityMatrix
ShaMan123 Jan 4, 2023
86242d6
Merge branch 'master' into fix-text-dnd
ShaMan123 Jan 6, 2023
e26c326
Merge branch 'master' into fix-text-dnd
asturur Jan 9, 2023
1ab5bff
fix(): offset is always 0
ShaMan123 Jan 9, 2023
3732bff
code styling
ShaMan123 Jan 9, 2023
74c34c9
fix(): transform event `isClick`
ShaMan123 Jan 9, 2023
f0e3d96
Merge branch 'master' into fix-text-dnd
ShaMan123 Jan 9, 2023
30c3924
fix(): click & drag interactions
ShaMan123 Jan 9, 2023
3af1301
fix(): false positive drag event
ShaMan123 Jan 9, 2023
7dc9815
fix(): render selection only if blurred and editing
ShaMan123 Jan 9, 2023
1f6d096
fix(): drag start flicker
ShaMan123 Jan 9, 2023
7205724
fix(): export itext while editing
ShaMan123 Jan 9, 2023
acc5b5e
fix(): clear cursor on stale drop target
ShaMan123 Jan 9, 2023
26aa014
fix(): _renderDragEffects when overlapping
ShaMan123 Jan 9, 2023
7e5de48
Merge branch 'master' into fix-text-dnd
asturur Jan 9, 2023
3a68c7c
fix(): find drag targets
ShaMan123 Jan 9, 2023
d713f76
Merge branch 'fix-text-dnd' of https://github.com/fabricjs/fabric.js …
ShaMan123 Jan 9, 2023
8b7971f
cleanup
ShaMan123 Jan 9, 2023
921b5f2
Update EventTypeDefs.ts
ShaMan123 Jan 9, 2023
b2b90ec
Merge branch 'master' into fix-text-dnd
asturur Jan 10, 2023
f5b628d
Merge branch 'master' into fix-text-dnd
ShaMan123 Jan 12, 2023
0c0e853
Update .gitignore
ShaMan123 Jan 12, 2023
37f7258
fix imports
ShaMan123 Jan 12, 2023
f4b03a9
fix merge
ShaMan123 Jan 12, 2023
ced0b67
revert
ShaMan123 Jan 12, 2023
9c41e18
types
ShaMan123 Jan 12, 2023
4d84e35
Update canvas_events.ts
ShaMan123 Jan 12, 2023
8a88bef
Update text.js
ShaMan123 Jan 12, 2023
542f8c6
Update itext_click_behaviour.js
ShaMan123 Jan 12, 2023
e6dd51a
init
ShaMan123 Jan 12, 2023
da6fc7d
init tests
ShaMan123 Jan 12, 2023
360ad4d
Update itext_behavior.mixin.ts
ShaMan123 Jan 12, 2023
915230f
Update draggable_text.js
ShaMan123 Jan 13, 2023
4fdbd68
Update draggable_text.js
ShaMan123 Jan 13, 2023
c4886b0
Update draggable_text.js
ShaMan123 Jan 13, 2023
cf24a6f
Merge branch 'master' into fix-text-dnd
ShaMan123 Jan 13, 2023
8eaae61
test(): Overlapping draggable text effects
ShaMan123 Jan 13, 2023
e6bd3c8
Update text.js
ShaMan123 Jan 13, 2023
68b036c
Update CHANGELOG.md
ShaMan123 Jan 13, 2023
fd48378
cleanup
ShaMan123 Jan 13, 2023
4fcb2ea
Update text.js
ShaMan123 Jan 13, 2023
565a9a8
renderEffects
ShaMan123 Jan 13, 2023
4a99d4e
init
ShaMan123 Jan 13, 2023
515593c
types
ShaMan123 Jan 13, 2023
8b426a9
progress
ShaMan123 Jan 13, 2023
a413d89
re expose
ShaMan123 Jan 14, 2023
7b44e2f
Update DraggableTextDelegate.ts
ShaMan123 Jan 14, 2023
c3b3cd3
tests
ShaMan123 Jan 14, 2023
d9f1dc0
fix
ShaMan123 Jan 14, 2023
fa0a91d
Update canvas_events.ts
ShaMan123 Jan 14, 2023
f4fee32
fix(): focus hiddentextarea in edge cases
ShaMan123 Jan 14, 2023
de198d4
correct comment
ShaMan123 Jan 14, 2023
9535054
Merge branch 'fix-text-dnd' into text-dnd-followup
ShaMan123 Jan 14, 2023
7a27cda
port fixes
ShaMan123 Jan 14, 2023
0afa3a9
minor ts
ShaMan123 Jan 14, 2023
a43f8ac
dispose
ShaMan123 Jan 14, 2023
c467707
imports
ShaMan123 Jan 14, 2023
a05de4d
fix(): refactor mouse up logic
ShaMan123 Jan 14, 2023
b4e1674
naming
ShaMan123 Jan 14, 2023
3ac2a17
move delegate to click handler
ShaMan123 Jan 14, 2023
e2dadc0
fix(): initial state on start + cursor on end
ShaMan123 Jan 14, 2023
51589e4
fix(): make test more accurate
ShaMan123 Jan 14, 2023
3aac84c
fix(): make state accurate after end
ShaMan123 Jan 14, 2023
778b80e
rename: `__isDragging` => `__mouseDownInPlace`
ShaMan123 Jan 14, 2023
ddb73b4
minors
ShaMan123 Jan 14, 2023
e04b5fb
cleanup clatter
ShaMan123 Jan 14, 2023
ef399a7
safegurad shitty clone
ShaMan123 Jan 14, 2023
de0a82d
readonly
ShaMan123 Jan 14, 2023
e3195b6
Update draggable_text.js
ShaMan123 Jan 14, 2023
4971527
organize to match lifecycle
ShaMan123 Jan 14, 2023
f9e50f8
Update DraggableTextDelegate.ts
ShaMan123 Jan 14, 2023
df12862
docs
ShaMan123 Jan 14, 2023
ec270ff
Update DraggableTextDelegate.ts
ShaMan123 Jan 14, 2023
67a419f
docs
ShaMan123 Jan 14, 2023
795248a
non readonly for overrides
ShaMan123 Jan 14, 2023
3d51363
docs
ShaMan123 Jan 14, 2023
26cedc0
docs
ShaMan123 Jan 14, 2023
ff62543
`__mouseDownInPlace` => `isActive`
ShaMan123 Jan 14, 2023
4e1d54b
disabling tests
ShaMan123 Jan 15, 2023
27dcd9e
docs
ShaMan123 Jan 15, 2023
c0fa8fb
Merge branch 'master' into fix-text-dnd
asturur Jan 15, 2023
3dd25c2
added coment and extract dropTarget variable
asturur Jan 15, 2023
fa4cdfb
Merge branch 'fix-text-dnd' into text-dnd-followup
ShaMan123 Jan 16, 2023
831ce55
port comment from 3dd25c2
ShaMan123 Jan 16, 2023
16dd40d
Update DraggableTextDelegate.ts
ShaMan123 Jan 16, 2023
7ecb5ea
prettier
asturur Jan 16, 2023
2aadf5d
start on mouse down + better drag interface
ShaMan123 Jan 16, 2023
cfde91f
Merge branch 'fix-text-dnd' into text-dnd-followup
ShaMan123 Jan 16, 2023
41aeeab
Merge branch 'master' into text-dnd-followup
ShaMan123 Jan 16, 2023
6145595
compact
ShaMan123 Jan 16, 2023
96b61e9
docs
ShaMan123 Jan 16, 2023
0df09b4
disable drop test
ShaMan123 Jan 16, 2023
8bcc8a6
fix(): repect overriding IText#canDrop
ShaMan123 Jan 16, 2023
6fcadb8
organize canDrop
ShaMan123 Jan 16, 2023
dbb834a
Update canvas_events.ts
ShaMan123 Jan 16, 2023
2f04172
Merge branch 'master' into text-dnd-followup
ShaMan123 Jan 16, 2023
85cecf0
Update CHANGELOG.md
ShaMan123 Jan 16, 2023
36b8383
major
ShaMan123 Jan 19, 2023
7a54354
Merge branch 'master' into more-text-types
ShaMan123 Jan 19, 2023
d23b216
Merge branch 'master' into text-dnd-followup
ShaMan123 Jan 19, 2023
5d93877
Merge branch 'text-dnd-followup' into more-text-types
ShaMan123 Jan 19, 2023
41d2f52
isRightClick
ShaMan123 Jan 19, 2023
2699f82
Merge branch 'master' into more-text-types
ShaMan123 Jan 22, 2023
b5562ce
itext: remove ts-nocheck
ShaMan123 Jan 22, 2023
aad5058
Update itext.class.ts
ShaMan123 Jan 22, 2023
e0447ea
fix
ShaMan123 Jan 22, 2023
cf0636a
Update CHANGELOG.md
ShaMan123 Jan 22, 2023
3f5feb2
Merge branch 'master' into more-text-types
asturur Jan 22, 2023
65c7ea4
execute todo
asturur Jan 22, 2023
4cc7ef9
Update itext_click_behavior.mixin.ts
asturur Jan 23, 2023
0e6a16d
Update itext_click_behavior.mixin.ts
asturur Jan 23, 2023
e1cd4c5
restore original code
asturur Jan 23, 2023
76a6005
added a comment
asturur Jan 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- chore(TS): type IText, IText behavior, IText click behavior [#8610](https://github.com/fabricjs/fabric.js/pull/8610)
- BREAKING: refactor `clone(obj, true)` with `cloneDeep(obj)` and remove all `extend`, `clone` calls in favor of object spreads. [#8600](https://github.com/fabricjs/fabric.js/pull/8600)
- chore(TS): Fix some error caused by ts-nocheck removals [#8615](https://github.com/fabricjs/fabric.js/pull/8615)
- refactor(IText): extract draggable text logic to a delegate [#8598](https://github.com/fabricjs/fabric.js/pull/8598)
Expand Down
15 changes: 7 additions & 8 deletions src/canvas/TextEditingManager.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { TPointerEvent } from '../EventTypeDefs';
import type { IText } from '../shapes/itext.class';
import type { Textbox } from '../shapes/textbox.class';
import type { ITextBehaviorMixin } from '../mixins/itext_behavior.mixin';
import { removeFromArray } from '../util/internals';

/**
* In charge of synchronizing all interactive text instances of a canvas
*/
export class TextEditingManager {
private targets: (IText | Textbox)[] = [];
private declare target?: IText | Textbox;
private targets: ITextBehaviorMixin[] = [];
private declare target?: ITextBehaviorMixin;

exitTextEditing() {
this.target = undefined;
Expand All @@ -19,20 +18,20 @@ export class TextEditingManager {
});
}

add(target: IText | Textbox) {
add(target: ITextBehaviorMixin) {
this.targets.push(target);
}

remove(target: IText | Textbox) {
remove(target: ITextBehaviorMixin) {
this.unregister(target);
removeFromArray(this.targets, target);
}

register(target: IText | Textbox) {
register(target: ITextBehaviorMixin) {
this.target = target;
}

unregister(target: IText | Textbox) {
unregister(target: ITextBehaviorMixin) {
if (target === this.target) {
this.target = undefined;
}
Expand Down
6 changes: 2 additions & 4 deletions src/canvas/canvas_events.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LEFT_CLICK, MIDDLE_CLICK, RIGHT_CLICK } from '../constants';
import { getEnv } from '../env';
import {
CanvasEvents,
Expand All @@ -24,10 +25,7 @@ import {
import { SelectableCanvas } from './canvas.class';
import { TextEditingManager } from './TextEditingManager';

const RIGHT_CLICK = 3,
MIDDLE_CLICK = 2,
LEFT_CLICK = 1,
addEventOptions = { passive: false } as EventListenerOptions;
const addEventOptions = { passive: false } as EventListenerOptions;

function checkClick(e: TPointerEvent, value: number) {
return !!(e as MouseEvent).button && (e as MouseEvent).button === value - 1;
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ export const ALIASING_LIMIT = 2;

/* "magic number" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */
export const kRect = 1 - 0.5522847498;

export const LEFT_CLICK = 1;
export const MIDDLE_CLICK = 2;
export const RIGHT_CLICK = 3;
Loading