1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-03 17:49:39 +02:00

Fix minor details in new code viewer

- Automatically remove quotes around URLs pasted in input field
- Fix editor not getting the focus after interacting with input
  field
This commit is contained in:
Raymond Hill 2023-03-12 17:47:21 -04:00
parent b3821e6869
commit 4bf3fe7b5b
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -150,6 +150,10 @@ function updatePastURLs(url) {
/******************************************************************************/
async function setURL(resourceURL) {
// For convenience, remove potentially existing quotes around the URL
if ( /^(["']).+\1$/.test(resourceURL) ) {
resourceURL = resourceURL.slice(1, -1);
}
const input = qs$('#header input[type="url"]');
let to;
try {
@ -174,7 +178,8 @@ async function setURL(resourceURL) {
cmEditor.setOption('mode', r.mime || '');
cmEditor.setValue(r.text);
updatePastURLs(to.href);
cmEditor.focus();
// For unknown reasons, calling focus() synchronously does not work...
vAPI.setTimeout(( ) => { cmEditor.focus(); }, 1);
}
/******************************************************************************/