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(IText): Draggable text #7802

Merged
merged 103 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
4a00d88
feat(IText): native like text dragging
ShaMan123 Mar 11, 2022
d6d1eae
fire event on object
ShaMan123 Mar 11, 2022
672f945
Update itext_click_behavior.mixin.js
ShaMan123 Mar 11, 2022
0298b3b
lint
ShaMan123 Mar 11, 2022
c7a39a0
dragend
ShaMan123 Mar 12, 2022
f5957c8
Update itext_click_behavior.mixin.js
ShaMan123 Mar 12, 2022
d4bdf7f
Update itext_click_behavior.mixin.js
ShaMan123 Mar 12, 2022
a77f365
dragover + drop
ShaMan123 Mar 12, 2022
51c06ae
Update itext_behavior.mixin.js
ShaMan123 Mar 12, 2022
a04e57d
Update itext_behavior.mixin.js
ShaMan123 Mar 12, 2022
04ee04f
Update itext_click_behavior.mixin.js
ShaMan123 Mar 12, 2022
afedfc2
fix(): drag end
ShaMan123 Mar 12, 2022
fc00090
Update itext_behavior.mixin.js
ShaMan123 Mar 12, 2022
7dfa629
support `editable`/`canDrop`
ShaMan123 Mar 12, 2022
934dd3c
Update itext_behavior.mixin.js
ShaMan123 Mar 12, 2022
f70651c
lint
ShaMan123 Mar 12, 2022
3d32720
Update itext_behavior.mixin.js
ShaMan123 Mar 12, 2022
34bc7b5
fix bug
ShaMan123 Mar 12, 2022
7ce1e7d
point
ShaMan123 Mar 13, 2022
8d500b3
drag image
ShaMan123 Mar 13, 2022
de9ca36
fix: drag over controls
ShaMan123 Mar 13, 2022
aa8c371
Update itext_behavior.mixin.js
ShaMan123 Mar 13, 2022
0efa15a
JSDOC
ShaMan123 Mar 13, 2022
4f457b9
Update canvas_events.js
ShaMan123 Mar 13, 2022
4d516ea
Update itext_behavior.mixin.js
ShaMan123 Mar 13, 2022
76d2a4d
Update itext_behavior.mixin.js
ShaMan123 Mar 14, 2022
cbe456c
cleanup
ShaMan123 Mar 14, 2022
6047c29
Update itext.class.js
ShaMan123 Mar 14, 2022
3df67f2
Update itext.class.js
ShaMan123 Mar 14, 2022
784a27a
setDragImage
ShaMan123 Mar 14, 2022
17b3f9a
revert `getRelativeCursorPosition`
ShaMan123 Mar 14, 2022
1ae3043
Update itext_behavior.mixin.js
ShaMan123 Mar 14, 2022
8fdf77b
retina scaling
ShaMan123 Mar 14, 2022
d112f3b
fix(): drag image offset
ShaMan123 Mar 14, 2022
57e81a1
Update itext_behavior.mixin.js
ShaMan123 Mar 14, 2022
63bbdfe
better drag image
ShaMan123 Mar 14, 2022
1b640f5
Update itext_behavior.mixin.js
ShaMan123 Mar 14, 2022
a2d2225
support styles
ShaMan123 Mar 14, 2022
48e2dde
dragstart + trailing spcae
ShaMan123 Mar 14, 2022
eef6895
drop + trailing space
ShaMan123 Mar 14, 2022
34b5686
fix: edit after drop + selection
ShaMan123 Mar 14, 2022
f6f701a
Update itext_behavior.mixin.js
ShaMan123 Mar 14, 2022
10a43d9
Update itext_behavior.mixin.js
ShaMan123 Mar 14, 2022
4642784
Update itext_behavior.mixin.js
ShaMan123 Mar 14, 2022
8e69763
refactor clipboard events
ShaMan123 Mar 14, 2022
4d441f3
finalize clipboard data
ShaMan123 Mar 14, 2022
e78310a
JSDOC
ShaMan123 Mar 14, 2022
f6d1311
lint
ShaMan123 Mar 14, 2022
04f379a
rtl support prep
ShaMan123 Mar 14, 2022
f9ed862
Update itext_key_behaviour.js
ShaMan123 Mar 14, 2022
c257c91
Update itext_key_behaviour.js
ShaMan123 Mar 14, 2022
72b9a77
Update itext_key_behavior.mixin.js
ShaMan123 Mar 14, 2022
df3f7f2
Update itext_behavior.mixin.js
ShaMan123 Mar 21, 2022
efdd61e
typo
ShaMan123 Mar 22, 2022
97cebb1
remove `disableStyleCopyPaste`
ShaMan123 Mar 22, 2022
ab637ac
Merge branch 'master' into draggable-text
ShaMan123 Mar 29, 2022
fe7cc4d
Merge branch 'master' into draggable-text
ShaMan123 Apr 2, 2022
8b06dfe
fix(): can't drop over selection
ShaMan123 Apr 2, 2022
1b12168
render drag selection
ShaMan123 Apr 2, 2022
6b8a1d9
renderDragStartSelection
ShaMan123 Apr 2, 2022
49aa851
better drag selection start rendering
ShaMan123 Apr 2, 2022
cfa7445
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
6033478
Update itext.class.js
ShaMan123 Apr 2, 2022
33d1cd6
Update itext.class.js
ShaMan123 Apr 2, 2022
f7ed62c
fix drag start selection
ShaMan123 Apr 2, 2022
46206b1
remove `trailingSpace` logic
ShaMan123 Apr 2, 2022
cdf9abd
fix(): clear context
ShaMan123 Apr 2, 2022
a9ca01e
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
de44140
lint
ShaMan123 Apr 2, 2022
c8b413b
fix: dragleave on canvas
ShaMan123 Apr 2, 2022
2069128
Update canvas_events.js
ShaMan123 Apr 2, 2022
c8c10f0
fix dragenter
ShaMan123 Apr 2, 2022
513199f
Update canvas_events.js
ShaMan123 Apr 2, 2022
d610383
Update canvas_events.js
ShaMan123 Apr 2, 2022
9ebdc62
fire always
ShaMan123 Apr 2, 2022
0d89e2b
Update canvas_events.mixin.js
ShaMan123 Apr 2, 2022
9734207
dragend
ShaMan123 Apr 2, 2022
c181512
Update itext_key_behavior.mixin.js
ShaMan123 Apr 2, 2022
29456b1
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
4058520
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
61c96fa
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
ea9c099
fix(): dragsource dragend edit mode state
ShaMan123 Apr 2, 2022
829bc67
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
43afb2e
Update canvas_events.mixin.js
ShaMan123 Apr 2, 2022
fd8515c
lint
ShaMan123 Apr 2, 2022
ecbf266
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
bd2b6c3
Update canvas_events.mixin.js
ShaMan123 Apr 2, 2022
a875dfe
Revert "Update itext_behavior.mixin.js"
ShaMan123 Apr 2, 2022
bc4e4c1
Update itext_behavior.mixin.js
ShaMan123 Apr 2, 2022
186d26d
fix(): always fire events
ShaMan123 Apr 3, 2022
d4fa70c
dragSource attr on drop event
ShaMan123 Apr 3, 2022
23f450f
fix(): firing `drag` event on drag source
ShaMan123 Apr 3, 2022
c60716d
lint
ShaMan123 Apr 3, 2022
0ebb4bb
fire dragstart on canvas
ShaMan123 Apr 3, 2022
61a48f7
Merge branch 'master' into draggable-text
ShaMan123 Apr 3, 2022
a6b5aa1
revert clipboard event changes
ShaMan123 Apr 25, 2022
51e15fe
revert: remove `disableStyleCopyPaste`
ShaMan123 Apr 25, 2022
d07d6d3
Merge branch 'master' into draggable-text
ShaMan123 May 1, 2022
be4cf22
Merge branch 'master' into draggable-text
ShaMan123 Jun 10, 2022
d6f9c8f
Merge branch 'master' into draggable-text
ShaMan123 Jul 5, 2022
b38b34c
add additional tweaks
ShaMan123 Jul 9, 2022
2db76ec
lint
ShaMan123 Jul 10, 2022
f00e547
Changes for text dragging (#8065)
asturur Jul 28, 2022
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual",
"coverage:report": "nyc report --reporter=lcov --reporter=text",
"lint": "eslint --config .eslintrc.json src",
"lint:fix": "eslint --fix --config .eslintrc.json src",
"lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests",
"all": "npm run build && npm run test -- --all && npm run lint && npm run lint_tests && npm run export",
"testem": "testem .",
Expand Down
37 changes: 36 additions & 1 deletion src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,42 @@
* @fires dragover
* @fires dragenter
* @fires dragleave
* @fires drop:before before drop event. same native event. This is added to handle edge cases
* @fires drag:enter object drag enter
* @fires drag:leave object drag leave
* @fires drop:before before drop event. Prepare for the drop event (same native event).
* @fires drop
* @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).
* @example
* let a: fabric.Object, b: fabric.Object;
* let flag = false;
* canvas.add(a, b);
* a.on('drop:before', opt => {
* // we want a to accept the drop even though it's below b in the stack
* flag = this.canDrop(opt.e);
* });
* b.canDrop = function(e) {
* !flag && this.callSuper('canDrop', e);
* }
* b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));
* a.on('drop', opt => {
* opt.e.defaultPrevented // drop occured
* opt.didDrop // drop occured on canvas
* opt.target // drop target
* opt.target !== a && a.set('text', 'I lost');
* });
* canvas.on('drop:after', opt => {
* // inform user who won
* if(!opt.e.defaultPrevented) {
* // no winners
* }
* else if(!opt.didDrop) {
* // my objects didn't win, some other lucky object
* }
* else {
* // we have a winner it's opt.target!!
* }
* })
*
* @fires after:render at the end of the render process, receives the context in the callback
* @fires before:render at start the render process, receives the context in the callback
*
Expand Down Expand Up @@ -1024,6 +1058,7 @@

this._copyCanvasStyle(lowerCanvasEl, upperCanvasEl);
this._applyCanvasStyle(upperCanvasEl);
upperCanvasEl.setAttribute('draggable', 'true');
this.contextTop = upperCanvasEl.getContext('2d');
},

Expand Down
Loading