2022-03-24 17:31:57 +01:00
|
|
|
/**
|
|
|
|
* PmWarning
|
|
|
|
*
|
|
|
|
* Warn users that their PM will be reviewed.
|
|
|
|
*/
|
|
|
|
|
2024-06-08 17:53:44 +02:00
|
|
|
import { $, hideEl, showEl } from './utils/dom';
|
2022-03-24 17:31:57 +01:00
|
|
|
|
2024-06-08 17:53:44 +02: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)) {
|
2024-06-08 17:53:44 +02:00
|
|
|
showEl(warning);
|
2024-07-04 02:27:59 +02:00
|
|
|
} else {
|
2024-06-08 17:53:44 +02:00
|
|
|
hideEl(warning);
|
2022-03-24 19:07:51 +01:00
|
|
|
}
|
2022-03-24 17:31:57 +01:00
|
|
|
});
|
|
|
|
}
|