philomena/assets/js/pmwarning.js

29 lines
592 B
JavaScript
Raw Normal View History

2022-03-24 17:31:57 +01:00
/**
* PmWarning
*
* Warn users that their PM will be reviewed.
*/
import { $ } from './utils/dom';
function warnAboutPMs() {
const textarea = $('.js-toolbar-input');
const warning = $('.js-hidden-warning');
const imageEmbedRegex = /!+\[/g;
if (!warning || !textarea) return;
textarea.addEventListener('input', () => {
const value = textarea.value;
2022-03-24 19:07:51 +01:00
if (value.match(imageEmbedRegex)) {
2022-03-24 17:31:57 +01:00
warning.classList.remove('hidden');
2022-03-24 19:07:51 +01:00
}
else if (!warning.classList.contains('hidden')) {
2022-03-24 17:31:57 +01:00
warning.classList.add('hidden');
2022-03-24 19:07:51 +01:00
}
2022-03-24 17:31:57 +01:00
});
}
export { warnAboutPMs };