@@ -770,7 +770,6 @@ const komojini_widgets = {
770770 node . properties . dialogOpened = true ;
771771 node . dialog = new app . ui . dialog . constructor ( )
772772
773- node . dialog . element . id = "drag-image-canvas" ;
774773 // node.dialog.element.style.height = "90%";
775774 // node.dialog.element.style.width = "90%";
776775 // node.dialog.element.style.display = "block";
@@ -814,6 +813,18 @@ const komojini_widgets = {
814813 node . properties . newline = true
815814
816815 const container = document . createElement ( "div" )
816+
817+ container . id = "drag-image-container" ;
818+ // container.style = "display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-around;"
819+
820+ Object . assign ( container . style , {
821+ display : 'flex' ,
822+ gap : '10px' ,
823+ // flexWrap: 'wrap',
824+ flexDirection : 'row' ,
825+ // justifyContent: 'space-around',
826+ } )
827+
817828
818829 // Object.assign(container.style, {
819830 // display: 'flex',
@@ -834,9 +845,9 @@ const komojini_widgets = {
834845 canvasEl . id = "imageCanvas"
835846
836847 Object . assign ( canvasEl , {
837- height : node . properties . size [ 1 ] ,
838- width : node . properties . size [ 0 ] ,
839- style : "border: 1px dotted gray; --darkreader-inline-border-top: #545b5e; --darkreader-inline-border-right: #545b5e; --darkreader-inline-border-bottom: #545b5e; --darkreader-inline-border-left: #545b5e; " ,
848+ height : ` ${ node . properties . size [ 1 ] } px` ,
849+ width : ` ${ node . properties . size [ 0 ] } px` ,
850+ style : "border: 1px dotted gray;" ,
840851 } )
841852
842853 node . properties . canvas = canvasEl ;
@@ -894,8 +905,8 @@ const komojini_widgets = {
894905
895906 const draglineTextEl = document . createElement ( "textarea" )
896907 draglineTextEl . id = "draglinetext"
897- draglineTextEl . style . height = "auto" ;
898908 // draglineTextEl.style.height = draglineTextEl.scrollHeight + 'px'; // Set the height to the scrollHeight
909+ draglineTextEl . readOnly = true ;
899910
900911 function _undo ( ) {
901912 const newDraglines = [ ...node . properties . draglines ] ;
@@ -941,12 +952,6 @@ const komojini_widgets = {
941952 const rect = canvasEl . getBoundingClientRect ( ) ;
942953 const x = Math . round ( e . clientX - rect . left ) ;
943954 const y = Math . round ( e . clientY - rect . top ) ;
944- // var ctx
945-
946- // if (canvasEl.getContext) {
947- // ctx = canvasEl.getContext("2d")
948- // }
949- console . log ( "on mousemove" ) ;
950955
951956 var currentDraglines ;
952957
@@ -958,9 +963,6 @@ const komojini_widgets = {
958963 currentDraglines [ currentDraglines . length - 1 ] = [ ...prevDragline , [ x , y ] ]
959964 }
960965
961- // node.properties.draglines[node.properties.draglines.length -1].push([x, y])
962- // drawLine(prevxy[0], prevxy[1], x, y, ctx)
963- setTrackingPoints ( ) ;
964966 drawAllLines ( node , currentDraglines , imageNode , canvasEl ) ;
965967
966968 }
@@ -1008,13 +1010,11 @@ const komojini_widgets = {
10081010 }
10091011
10101012 const inputContainer = document . createElement ( "div" )
1011-
1012- Object . assign ( container . style , {
1013+ Object . assign ( inputContainer . style , {
10131014 display : 'flex' ,
10141015 gap : '10px' ,
10151016 flexDirection : 'column' ,
1016- } )
1017-
1017+ } )
10181018 const sizeSelectorEl = document . createElement ( "select" )
10191019 sizeSelectorEl . id = "sizeSelector"
10201020 let sizeOptions = "" ;
@@ -1104,26 +1104,41 @@ const komojini_widgets = {
11041104 newlineButton . onclick = setNewline ;
11051105 newlineButton . width = 100 ;
11061106
1107-
1108- inputContainer . append ( sizeSelectorEl )
1109- inputContainer . append ( imageInputEl )
1110-
11111107 const controlContainer = document . createElement ( "div" )
1112-
1108+ Object . assign ( controlContainer . style , {
1109+ display : "flex" ,
1110+ flexDirection : "column" ,
1111+ } )
1112+
1113+ const inputStyle = {
1114+ padding : '5px' ,
1115+ margin : '10px'
1116+ } ;
1117+
1118+ controlContainer . append ( sizeSelectorEl )
1119+ Object . assign ( sizeSelectorEl . style , inputStyle )
1120+
1121+ controlContainer . append ( imageInputEl )
1122+ Object . assign ( imageInputEl . style , inputStyle )
1123+
11131124 controlContainer . append ( refreshButton )
11141125 controlContainer . append ( undoButton )
11151126 controlContainer . append ( newlineButton )
11161127
11171128 container . append ( controlContainer )
1118- container . append ( inputContainer )
1129+ // container.append(inputContainer)
11191130
11201131 node . dialog . show ( '' )
11211132 node . dialog . textElement . append ( container )
1122-
1123- container . append ( draglineTextEl )
1133+
1134+ Object . assign ( draglineTextEl . style , {
1135+ flex : 1 ,
1136+ margin : "20px" ,
1137+ } )
1138+ controlContainer . append ( draglineTextEl )
11241139
11251140 _refreshCanvas ( )
1126- node . properties . draglines = JSON . parse ( dragTextWidget . value ) ;
1141+ node . properties . draglines = JSON . parse ( dragTextWidget . value ?? "[]" ) ?? [ ] ;
11271142 setTrackingPoints ( ) ;
11281143 }
11291144
0 commit comments