usercss editor: show all section regexps in tester
This commit is contained in:
parent
963930ea1d
commit
61003b378c
|
@ -38,10 +38,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
$create('button.test-regexp', t('styleRegexpTestButton')));
|
$create('button.test-regexp', t('styleRegexpTestButton')));
|
||||||
|
|
||||||
CLICK_ROUTE = {
|
CLICK_ROUTE = {
|
||||||
'.test-regexp': (item, apply) => {
|
'.test-regexp': showRegExpTester,
|
||||||
regExpTester.toggle();
|
|
||||||
regExpTester.update([unescapeDoubleslash(apply.value.text)]);
|
|
||||||
},
|
|
||||||
|
|
||||||
'.remove-applies-to': (item, apply) => {
|
'.remove-applies-to': (item, apply) => {
|
||||||
const applies = item.closest('.applies-to').__applies;
|
const applies = item.closest('.applies-to').__applies;
|
||||||
|
@ -99,7 +96,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
if (typeElement) {
|
if (typeElement) {
|
||||||
const item = target.closest('.applies-to-item');
|
const item = target.closest('.applies-to-item');
|
||||||
const apply = item.__apply;
|
const apply = item.__apply;
|
||||||
changeItem(apply, 'type', typeElement.value);
|
changeItem(item, apply, 'type', typeElement.value);
|
||||||
item.dataset.type = apply.type.text;
|
item.dataset.type = apply.type.text;
|
||||||
} else {
|
} else {
|
||||||
return EVENTS.oninput.apply(this, arguments);
|
return EVENTS.oninput.apply(this, arguments);
|
||||||
|
@ -109,7 +106,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
if (target.matches('.applies-value')) {
|
if (target.matches('.applies-value')) {
|
||||||
const item = target.closest('.applies-to-item');
|
const item = target.closest('.applies-to-item');
|
||||||
const apply = item.__apply;
|
const apply = item.__apply;
|
||||||
changeItem(apply, 'value', target.value);
|
changeItem(item, apply, 'value', target.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onclick({target}) {
|
onclick({target}) {
|
||||||
|
@ -479,7 +476,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeItem(apply, part, newText) {
|
function changeItem(itemElement, apply, part, newText) {
|
||||||
if (!apply) {
|
if (!apply) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -505,9 +502,8 @@ function createAppliesToLineWidget(cm) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apply.type.text === 'regexp') {
|
if (apply.type.text === 'regexp' && apply.value.text.trim()) {
|
||||||
const rx = apply.value.text.trim();
|
showRegExpTester(itemElement);
|
||||||
regExpTester.update(rx ? [unescapeDoubleslash(rx)] : {});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,4 +574,12 @@ function createAppliesToLineWidget(cm) {
|
||||||
const hasSingleEscapes = /([^\\]|^)\\([^\\]|$)/.test(s);
|
const hasSingleEscapes = /([^\\]|^)\\([^\\]|$)/.test(s);
|
||||||
return hasSingleEscapes ? s : s.replace(/\\\\/g, '\\');
|
return hasSingleEscapes ? s : s.replace(/\\\\/g, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showRegExpTester(item) {
|
||||||
|
regExpTester.toggle(true);
|
||||||
|
regExpTester.update(
|
||||||
|
item.closest('.applies-to').__applies
|
||||||
|
.filter(a => a.type.text === 'regexp')
|
||||||
|
.map(a => unescapeDoubleslash(a.value.text)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user