File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class Scroll extends ScrollBlot {
1515 this . batch = false ;
1616 this . optimize ( ) ;
1717 this . enable ( ) ;
18+ this . domNode . addEventListener ( 'dragstart' , e => this . handleDragStart ( e ) ) ;
1819 }
1920
2021 batchStart ( ) {
@@ -63,6 +64,10 @@ class Scroll extends ScrollBlot {
6364 this . optimize ( ) ;
6465 }
6566
67+ handleDragStart ( event ) {
68+ event . preventDefault ( ) ;
69+ }
70+
6671 insertAt ( index , value , def ) {
6772 if ( index >= this . length ( ) ) {
6873 if ( def == null || this . scroll . query ( value , Scope . BLOCK ) == null ) {
Original file line number Diff line number Diff line change @@ -75,9 +75,6 @@ class Quill {
7575 this . container . innerHTML = '' ;
7676 instances . set ( this . container , this ) ;
7777 this . root = this . addContainer ( 'ql-editor' ) ;
78- this . root . addEventListener ( 'dragstart' , e => {
79- e . preventDefault ( ) ;
80- } ) ;
8178 this . root . classList . add ( 'ql-blank' ) ;
8279 this . root . setAttribute ( 'data-gramm' , false ) ;
8380 this . scrollingContainer = this . options . scrollingContainer || this . root ;
Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ describe('Scroll', function() {
3939 } , 1 ) ;
4040 } ) ;
4141
42+ it ( 'prevent dragstart' , function ( ) {
43+ const scroll = this . initialize ( Scroll , '<p>Hello World!</p>' ) ;
44+ const dragstart = new Event ( 'dragstart' ) ;
45+ spyOn ( dragstart , 'preventDefault' ) ;
46+ scroll . domNode . dispatchEvent ( dragstart ) ;
47+ expect ( dragstart . preventDefault ) . toHaveBeenCalled ( ) ;
48+ } ) ;
49+
4250 describe ( 'leaf()' , function ( ) {
4351 it ( 'text' , function ( ) {
4452 const scroll = this . initialize ( Scroll , '<p>Tests</p>' ) ;
You can’t perform that action at this time.
0 commit comments