mirror of https://github.com/gorhill/uBlock.git
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:
parent
b3821e6869
commit
4bf3fe7b5b
|
@ -150,6 +150,10 @@ function updatePastURLs(url) {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
async function setURL(resourceURL) {
|
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"]');
|
const input = qs$('#header input[type="url"]');
|
||||||
let to;
|
let to;
|
||||||
try {
|
try {
|
||||||
|
@ -174,7 +178,8 @@ async function setURL(resourceURL) {
|
||||||
cmEditor.setOption('mode', r.mime || '');
|
cmEditor.setOption('mode', r.mime || '');
|
||||||
cmEditor.setValue(r.text);
|
cmEditor.setValue(r.text);
|
||||||
updatePastURLs(to.href);
|
updatePastURLs(to.href);
|
||||||
cmEditor.focus();
|
// For unknown reasons, calling focus() synchronously does not work...
|
||||||
|
vAPI.setTimeout(( ) => { cmEditor.focus(); }, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue