mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 20:37:59 +01:00
28 lines
629 B
TypeScript
28 lines
629 B
TypeScript
/**
|
|
* PmWarning
|
|
*
|
|
* Warn users that their PM will be reviewed.
|
|
*/
|
|
|
|
import { $ } from './utils/dom';
|
|
|
|
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)) {
|
|
warning.classList.remove('hidden');
|
|
}
|
|
else if (!warning.classList.contains('hidden')) {
|
|
warning.classList.add('hidden');
|
|
}
|
|
});
|
|
}
|
|
|
|
export { warnAboutPMs };
|