File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed
Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ export function apply() {
3535 console . log ( `${ name } ` , settings ) ;
3636
3737 return {
38+ keys : { name } ,
3839 image : ( ( ) => {
3940 return also ( new Image ( ) , img => {
4041 img . loading = 'lazy' ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export function apply() {
1111 } ) ;
1212 signal . throwIfAborted ( ) ;
1313 return {
14+ keys : { name : String ( number ) } ,
1415 image : ( ( ) => {
1516 return also ( new Image ( ) , img => {
1617 img . loading = "lazy" ;
Original file line number Diff line number Diff line change 410410
411411 document . getElementById ( "cards" ) . innerHTML = "" ;
412412 for ( const cardPromise of window . KanbanBro . cardProviders . flatMap ( provider => provider ( abortController . signal ) ) ) {
413- document . getElementById ( "cards" ) . append (
414- also ( document . createElement ( "div" ) , cardDiv => {
415- cardDiv . className = "card" ;
413+ cardPromise . then ( card => {
414+ abortController . signal . throwIfAborted ( ) ;
415+
416+ const cardContainer = document . getElementById ( "cards" ) ;
417+
418+ let refNode = null ;
419+ const newName = card . keys ?. name ?? "" ;
420+ for ( const child of Array . from ( cardContainer . children ) ) {
421+ const existingName = child . card . keys ?. name ?? "" ;
422+ if ( existingName . localeCompare ( newName ) > 0 ) {
423+ refNode = child ;
424+ break ;
425+ }
426+ }
427+
428+ cardContainer . insertBefore (
429+ also ( document . createElement ( "div" ) , cardDiv => {
430+ cardDiv . className = "card" ;
431+ cardDiv . card = card ;
416432
417- cardPromise . then ( card => {
418- abortController . signal . throwIfAborted ( ) ;
419433 cardDiv . append (
420434 also ( document . createElement ( "div" ) , screenshotDiv => {
421435 screenshotDiv . className = "screenshot" ;
454468 ) ;
455469 } ) ,
456470 ) ;
457- } ) ;
458- } ) ,
459- ) ;
471+ } ) ,
472+ refNode ,
473+ ) ;
474+ } ) ;
460475 }
461476 }
462477
You can’t perform that action at this time.
0 commit comments