File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 55 < meta charset ="UTF-8 " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
77 < title > Quill Resize Image</ title >
8- < link href ="https://cdn.bootcdn.net/ajax/libs/quill/1.3.7/quill.snow.min.css " rel ="stylesheet " />
9- < script defer src ="https://cdn.bootcdn.net/ajax/libs/quill/1.3.7/quill.min.js "> </ script >
8+ < link href ="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css " rel ="stylesheet " />
9+ < link href ="https://cdn.jsdelivr.net/npm/quill-table-better@1/dist/quill-table-better.css " rel ="stylesheet " />
10+ < script defer src ="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js "> </ script >
1011 < script defer src ="https://unpkg.com/quill-resize-image@1.0.5/dist/quill-resize-image.min.js "> </ script >
1112</ head >
1213
2021</ body >
2122< script defer >
2223 document . addEventListener ( 'DOMContentLoaded' , function ( ) {
23- if ( ! window . QuillResizeImage ) return ;
24+ if ( ! window . QuillResizeImage ) return ;
25+
2426 Quill . register ( "modules/resize" , window . QuillResizeImage ) ;
2527
2628 var toolbarOptions = [
2931 "underline" ,
3032 "strike" ,
3133 "image" ,
32- "video" ,
34+ "video"
3335 ] ;
3436 var quill = new Quill ( "#editor" , {
3537 theme : "snow" ,
3638 modules : {
3739 toolbar : toolbarOptions ,
3840 resize : {
3941 locale : { } ,
40- } ,
42+ }
4143 } ,
4244 } ) ;
4345
Original file line number Diff line number Diff line change @@ -104,12 +104,18 @@ class ResizePlugin {
104104 this . resizer = resizer ;
105105 }
106106 positionResizerToTarget ( el : HTMLElement ) {
107- if ( this . resizer !== null ) {
108- this . resizer . style . setProperty ( "left" , el . offsetLeft + "px" ) ;
109- this . resizer . style . setProperty ( "top" , ( el . offsetTop - this . editor . scrollTop ) + "px" ) ;
110- this . resizer . style . setProperty ( "width" , el . clientWidth + "px" ) ;
111- this . resizer . style . setProperty ( "height" , el . clientHeight + "px" ) ;
112- }
107+ if ( ! this . resizer || ! this . editor ) return ;
108+
109+ const elRect = el . getBoundingClientRect ( ) ;
110+ const editorRect = this . editor . getBoundingClientRect ( ) ;
111+
112+ const left = elRect . left - editorRect . left + this . editor . scrollLeft ;
113+ const top = elRect . top - editorRect . top + this . editor . scrollTop ;
114+
115+ this . resizer . style . setProperty ( "left" , `${ left } px` ) ;
116+ this . resizer . style . setProperty ( "top" , `${ top } px` ) ;
117+ this . resizer . style . setProperty ( "width" , `${ el . clientWidth } px` ) ;
118+ this . resizer . style . setProperty ( "height" , `${ el . clientHeight } px` ) ;
113119 }
114120 bindEvents ( ) {
115121 if ( this . resizer !== null ) {
You can’t perform that action at this time.
0 commit comments