From c356fb9be5abfc1cb3f51ad86f96fec1698aaf36 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 27 Mar 2017 00:37:45 +0300 Subject: [PATCH] Add regexp tester to the editor --- _locales/en/messages.json | 24 ++++++++ edit.html | 66 ++++++++++++++++++++- edit.js | 118 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 207 insertions(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d624661b..bade24a8 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -362,6 +362,30 @@ "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" }, + "styleRegexpTestButton": { + "message": "RegExp test", + "description": "RegExp test button label in the editor shown when applies-to list has a regexp value" + }, + "styleRegexpTestTitle": { + "message": "List of matching opened tabs (click on URL to focus its tab)", + "description": "RegExp test report: title of the report" + }, + "styleRegexpTestFull": { + "message": "Matching tabs", + "description": "RegExp test report: label for the fully matching expressions" + }, + "styleRegexpTestPartial": { + "message": "Not matching fully, hence skipped", + "description": "RegExp test report: label for the partially matching expressions" + }, + "styleRegexpTestNone": { + "message": "No matching tabs", + "description": "RegExp test report: label for expressions that didn't match any tabs" + }, + "styleRegexpTestInvalid": { + "message": "Invalid regexps skipped", + "description": "RegExp test report: label for the invalid expressions" + }, "styleBeautify": { "message": "Beautify", "description": "Label for the CSS-beautifier button on the edit style page" diff --git a/edit.html b/edit.html index 0d3ca30c..244469fa 100644 --- a/edit.html +++ b/edit.html @@ -207,6 +207,14 @@ background-color: none; } } + @keyframes fadein { + from { + opacity: 0; + } + to { + opacity: 1; + } + } .resize-grip { position: absolute; display: block; @@ -261,6 +269,61 @@ .applies-to img { vertical-align: bottom; } + .test-regexp { + display: none; + } + .has-regexp .test-regexp { + display: inline-block; + } + .regexp-report summary, .regexp-report div { + cursor: pointer; + } + .regexp-report mark { + background-color: rgba(255, 255, 0, .5); + } + .regexp-report details { + margin-left: 1rem; + } + .regexp-report details:not(:last-child) { + margin-bottom: 1rem; + } + .regexp-report summary { + font-weight: bold; + margin-left: -1rem; + margin-bottom: .5rem; + outline: none; + cursor: default; + } + .regexp-report details[data-type="full"] { + color: darkgreen; + } + .regexp-report details[data-type="partial"] { + color: darkgray; + } + .regexp-report details[data-type="invalid"] { + color: maroon; + } + .regexp-report details details { + margin-left: 2rem; + margin-top: .5rem; + } + .regexp-report .svg-icon { + position: absolute; + margin-top: -1px; + } + .regexp-report details div:hover { + text-decoration: underline; + text-decoration-skip: ink; + } + .regexp-report details div img { + width: 16px; + max-height: 16px; + position: absolute; + margin-left: -20px; + margin-top: -1px; + animation: fadein 1s cubic-bezier(.03, .67, .08, .94); + animation-fill-mode: both; + } /************ help popup ************/ #help-popup { top: 3rem; @@ -285,7 +348,7 @@ font-weight: bold; background-color: rgba(0,0,0,0.05); margin: -0.5rem -0.5rem 0.5rem; - padding: 0.5rem; + padding: .5rem 32px .5rem .5rem; } #help-popup .contents { max-height: calc(100vh - 8rem); @@ -537,6 +600,7 @@ +