@@ -124,7 +124,7 @@ export default class XPgInputPixelEditorBasic extends HTMLElement {
124124 suggestedName : 'Canvas' ,
125125 types : [ {
126126 description : 'SVG Document' ,
127- accept : { 'image/svg+xml' : [ '.svg' ] } ,
127+ accept : { 'image/svg+xml' : [ '.svg' ] } ,
128128 } ] ,
129129 } ) ;
130130 const writable = await handle . createWritable ( ) ;
@@ -143,7 +143,7 @@ export default class XPgInputPixelEditorBasic extends HTMLElement {
143143 suggestedName : 'CanvasName' ,
144144 types : [ {
145145 description : 'SVG Document' ,
146- accept : { 'image/svg+xml' : [ '.svg' ] } ,
146+ accept : { 'image/svg+xml' : [ '.svg' ] } ,
147147 } ] ,
148148 } ) ;
149149 const writable = await handle . createWritable ( ) ;
@@ -184,7 +184,7 @@ export default class XPgInputPixelEditorBasic extends HTMLElement {
184184 ] ;
185185 this . $layers . addEventListener ( 'action' , ( e : any ) => {
186186 const { getColumn, getRows, key } = e . detail ;
187- switch ( key ) {
187+ switch ( key ) {
188188 case 'select' :
189189 getRows ( ) . forEach ( ( { getColumn } ) => {
190190 getColumn ( 'selected' ) . value = false ;
@@ -259,15 +259,28 @@ export default class XPgInputPixelEditorBasic extends HTMLElement {
259259 } ) ;
260260 } ) ) ;
261261 this . $colors . addEventListener ( 'action' , ( e : any ) => {
262- const { getColumn, getRows, key } = e . detail ;
263- switch ( key ) {
262+ const { getColumn, getRows, key, value, index } = e . detail ;
263+ const [ r , g , b , a ] = this . $input . getColor ( index ) ;
264+ switch ( key ) {
264265 case 'select' :
265266 getRows ( ) . forEach ( ( { getColumn } ) => {
266267 getColumn ( 'selected' ) . value = false ;
267268 } ) ;
268269 getColumn ( 'selected' ) . value = true ;
269270 this . $input . selectColor ( getColumn ( 'select' ) . value ) ;
270271 break ;
272+ case 'r' :
273+ this . $input . setColor ( index , value , g , b , a ) ;
274+ break ;
275+ case 'g' :
276+ this . $input . setColor ( index , r , value , b , a ) ;
277+ break ;
278+ case 'b' :
279+ this . $input . setColor ( index , r , g , value , a ) ;
280+ break ;
281+ case 'a' :
282+ this . $input . setColor ( index , r , g , b , value ) ;
283+ break ;
271284 }
272285 } ) ;
273286 this . $addColor . addEventListener ( 'click' , ( ) => {
@@ -295,7 +308,7 @@ export default class XPgInputPixelEditorBasic extends HTMLElement {
295308 if ( files . length !== 1 ) {
296309 throw new Error ( 'select only 1 file' ) ;
297310 }
298- switch ( files [ 0 ] . type ) {
311+ switch ( files [ 0 ] . type ) {
299312 case 'image/svg+xml' :
300313 // Read the file
301314 const reader = new FileReader ( ) ;
0 commit comments