From 0569c554c98b32251cddd8f0f65d47f2fd9ecbe7 Mon Sep 17 00:00:00 2001 From: Claudio-Emmolo <113107618+Claudio-Emmolo@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:44:38 +0200 Subject: [PATCH] previewAdv.js, add BLACKLIST --- src/previewAdv.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/previewAdv.js b/src/previewAdv.js index c756597..c6b5860 100644 --- a/src/previewAdv.js +++ b/src/previewAdv.js @@ -34,6 +34,7 @@ tinymce.PluginManager.add('previewAdv', (editor, url) => { editor.on('init', function () { const params = editor.getParam('previewAdv') const thresholds = params.thresholds + const blacklist = params.blacklist let pCount = 0 // Counter for

tags let advCount = 1 // Counter for adv divs @@ -69,10 +70,12 @@ tinymce.PluginManager.add('previewAdv', (editor, url) => { // === FUNCTIONS === function insertAdv () { + // REMOVE OLD ADV FOR LOAD NEW const advDivs = editor.getBody().querySelectorAll('.adv-preview') for (let i = 0; i < advDivs.length; i++) { advDivs[i].remove() } + const body = editor.getBody() const paragraphs = body.getElementsByTagName('p') @@ -82,6 +85,30 @@ tinymce.PluginManager.add('previewAdv', (editor, url) => { continue } + // === BLACKLIST === + const bfBlacklist = blacklist.before.slice(1, -1).split('|') + const afBlacklist = blacklist.after.slice(1, -1).split('|') + + bfBlacklist.push(' paragraphs[i].innerHTML.includes(item))) { + // continue + // } + if (bfBlacklist.some(item => new RegExp(item).test(paragraphs[i].innerHTML))) { + continue + } + + // AFTER BLACKLIST + // if (afBlacklist.some(item => paragraphs[i + 1].innerHTML.includes(item))) { + // continue + // } + if (afBlacklist.some(item => new RegExp(item).test(paragraphs[i + 1].innerHTML))) { + continue + } + // === END BLACKLIST === + const div = editor.dom.create('div', { class: 'adv-preview', contenteditable: 'false' }) div.style.backgroundColor = '#f3f3f3' div.style.color = '#666'