auto-open import dialog when pasted text has @-moz-document

This commit is contained in:
tophf 2017-08-30 02:26:47 +03:00
parent f308d0be6c
commit edc2ab0ead

View File

@ -396,7 +396,18 @@ function setupCodeMirror(textarea, index) {
hotkeyRerouter.setState(false); hotkeyRerouter.setState(false);
wrapper.classList.add('CodeMirror-active'); wrapper.classList.add('CodeMirror-active');
}); });
cm.on('paste', () => { cm.on('paste', (cm, event) => {
const text = event.clipboardData.getData('text') || '';
if (
text.includes('@-moz-document') &&
text.replace(/\/\*[\s\S]*?\*\//g, '')
.match(/@-moz-document[\s\r\n]+(url|url-prefix|domain|regexp)\(/)
) {
event.preventDefault();
fromMozillaFormat();
$('#help-popup').codebox.setValue(text);
$('#help-popup').codebox.markClean();
}
if (editors.length === 1) { if (editors.length === 1) {
setTimeout(() => { setTimeout(() => {
if (cm.display.sizer.clientHeight > cm.display.wrapper.clientHeight) { if (cm.display.sizer.clientHeight > cm.display.wrapper.clientHeight) {