Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
b9b1df30
Commit
b9b1df30
authored
Apr 17, 2023
by
comfyanonymous
Browse files
Merge branch 'edit-attention-fix' of
https://github.com/EllangoK/ComfyUI
parents
c8afa7e9
a9622229
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
web/extensions/core/editAttention.js
web/extensions/core/editAttention.js
+21
-3
No files found.
web/extensions/core/editAttention.js
View file @
b9b1df30
...
@@ -70,7 +70,7 @@ name:id,
...
@@ -70,7 +70,7 @@ name:id,
let
end
=
inputField
.
selectionEnd
;
let
end
=
inputField
.
selectionEnd
;
let
selectedText
=
inputField
.
value
.
substring
(
start
,
end
);
let
selectedText
=
inputField
.
value
.
substring
(
start
,
end
);
// If there is no selection, attempt to find the nearest enclosure
// If there is no selection, attempt to find the nearest enclosure
, or select the current word
if
(
!
selectedText
)
{
if
(
!
selectedText
)
{
const
nearestEnclosure
=
findNearestEnclosure
(
inputField
.
value
,
start
);
const
nearestEnclosure
=
findNearestEnclosure
(
inputField
.
value
,
start
);
if
(
nearestEnclosure
)
{
if
(
nearestEnclosure
)
{
...
@@ -78,7 +78,26 @@ name:id,
...
@@ -78,7 +78,26 @@ name:id,
end
=
nearestEnclosure
.
end
;
end
=
nearestEnclosure
.
end
;
selectedText
=
inputField
.
value
.
substring
(
start
,
end
);
selectedText
=
inputField
.
value
.
substring
(
start
,
end
);
}
else
{
}
else
{
return
;
// Select the current word, find the start and end of the word (first space before and after)
const
wordStart
=
inputField
.
value
.
substring
(
0
,
start
).
lastIndexOf
(
"
"
)
+
1
;
const
wordEnd
=
inputField
.
value
.
substring
(
end
).
indexOf
(
"
"
);
// If there is no space after the word, select to the end of the string
if
(
wordEnd
===
-
1
)
{
end
=
inputField
.
value
.
length
;
}
else
{
end
+=
wordEnd
;
}
start
=
wordStart
;
// Remove all punctuation at the end and beginning of the word
while
(
inputField
.
value
[
start
].
match
(
/
[
.,
\/
#!$%
\^
&
\*
;:{}=
\-
_`~()
]
/
))
{
start
++
;
}
while
(
inputField
.
value
[
end
-
1
].
match
(
/
[
.,
\/
#!$%
\^
&
\*
;:{}=
\-
_`~()
]
/
))
{
end
--
;
}
selectedText
=
inputField
.
value
.
substring
(
start
,
end
);
if
(
!
selectedText
)
return
;
}
}
}
}
...
@@ -97,7 +116,6 @@ name:id,
...
@@ -97,7 +116,6 @@ name:id,
// If the selection is not enclosed in parentheses, add them
// If the selection is not enclosed in parentheses, add them
if
(
selectedText
[
0
]
!==
"
(
"
||
selectedText
[
selectedText
.
length
-
1
]
!==
"
)
"
)
{
if
(
selectedText
[
0
]
!==
"
(
"
||
selectedText
[
selectedText
.
length
-
1
]
!==
"
)
"
)
{
console
.
log
(
"
adding parentheses
"
,
inputField
.
value
[
start
],
inputField
.
value
[
end
],
selectedText
);
selectedText
=
`(
${
selectedText
}
)`
;
selectedText
=
`(
${
selectedText
}
)`
;
}
}
...
...
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