Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
46805695
Commit
46805695
authored
May 22, 2023
by
missionfloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reorder hotkeys
Shifts selected items with ctrl+left/right
parent
89f9faa6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
javascript/edit-order.js
javascript/edit-order.js
+36
-0
No files found.
javascript/edit-order.js
0 → 100644
View file @
46805695
function
keyupEditOrder
(
event
){
let
target
=
event
.
originalTarget
||
event
.
composedPath
()[
0
];
if
(
!
target
.
matches
(
"
*:is([id*='_toprow'] [id*='_prompt'], .prompt) textarea
"
))
return
;
if
(
!
event
.
metaKey
&&
!
event
.
ctrlKey
)
return
;
let
isLeft
=
event
.
key
==
"
ArrowLeft
"
let
isRight
=
event
.
key
==
"
ArrowRight
"
if
(
!
isLeft
&&
!
isRight
)
return
;
let
selectionStart
=
target
.
selectionStart
;
let
selectionEnd
=
target
.
selectionEnd
;
let
text
=
target
.
value
;
let
items
=
text
.
split
(
"
,
"
)
let
indexStart
=
(
text
.
slice
(
0
,
selectionStart
).
match
(
/,/g
)
||
[]).
length
let
indexEnd
=
(
text
.
slice
(
0
,
selectionEnd
).
match
(
/,/g
)
||
[]).
length
let
range
=
indexEnd
-
indexStart
+
1
if
(
isLeft
&&
indexStart
>
0
)
{
items
.
splice
(
indexStart
-
1
,
0
,
...
items
.
splice
(
indexStart
,
range
))
target
.
value
=
items
.
join
()
target
.
selectionStart
=
items
.
slice
(
0
,
indexStart
-
1
).
join
().
length
+
(
indexStart
==
1
?
0
:
1
)
target
.
selectionEnd
=
items
.
slice
(
0
,
indexEnd
).
join
().
length
}
else
if
(
isRight
&&
indexEnd
<
items
.
length
-
1
)
{
items
.
splice
(
indexStart
+
1
,
0
,
...
items
.
splice
(
indexStart
,
range
))
target
.
value
=
items
.
join
()
target
.
selectionStart
=
items
.
slice
(
0
,
indexStart
+
1
).
join
().
length
+
1
target
.
selectionEnd
=
items
.
slice
(
0
,
indexEnd
+
2
).
join
().
length
}
event
.
preventDefault
()
updateInput
(
target
)
}
addEventListener
(
'
keydown
'
,
(
event
)
=>
{
keyupEditOrder
(
event
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment