philomena/assets/js/pmwarning.ts

26 lines
544 B
TypeScript
Raw Normal View History

2022-03-24 17:31:57 +01:00
/**
* PmWarning
*
* Warn users that their PM will be reviewed.
*/
import { $, hideEl, showEl } from './utils/dom';
2022-03-24 17:31:57 +01:00
export function warnAboutPMs() {
const textarea = $<HTMLTextAreaElement>('.js-toolbar-input');
const warning = $<HTMLDivElement>('.js-hidden-warning');
2022-03-24 17:31:57 +01:00
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)) {
showEl(warning);
2024-07-04 02:27:59 +02:00
} else {
hideEl(warning);
2022-03-24 19:07:51 +01:00
}
2022-03-24 17:31:57 +01:00
});
}