mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
26 lines
591 B
TypeScript
26 lines
591 B
TypeScript
/**
|
|
* PmWarning
|
|
*
|
|
* Warn users that their PM will be reviewed.
|
|
*/
|
|
|
|
import { $, hideEl, showEl } from './utils/dom';
|
|
|
|
export function warnAboutPMs() {
|
|
const textarea = $<HTMLTextAreaElement>('.js-toolbar-input');
|
|
const warning = $<HTMLDivElement>('.js-hidden-warning');
|
|
const imageEmbedRegex = /!+\[/g;
|
|
|
|
if (!warning || !textarea) return;
|
|
|
|
textarea.addEventListener('input', () => {
|
|
const value = textarea.value;
|
|
|
|
if (value.match(imageEmbedRegex)) {
|
|
showEl(warning);
|
|
}
|
|
else if (!warning.classList.contains('hidden')) {
|
|
hideEl(warning);
|
|
}
|
|
});
|
|
}
|