From 038a672f10f782205443f9e55d6c21be30a43959 Mon Sep 17 00:00:00 2001 From: drfho Date: Wed, 3 Jan 2024 14:53:58 +0100 Subject: [PATCH] fixed JS error null.forEach; whitespace --- .../zms/plugins/rte/simplemde/manage_form.zpt | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/Products/zms/plugins/rte/simplemde/manage_form.zpt b/Products/zms/plugins/rte/simplemde/manage_form.zpt index ecf49516e..fd776d125 100644 --- a/Products/zms/plugins/rte/simplemde/manage_form.zpt +++ b/Products/zms/plugins/rte/simplemde/manage_form.zpt @@ -48,7 +48,7 @@ var simplemde = new SimpleMDE({ }); $('#attr_url_markdown').on("change", function() { - var data = simplemde.value(); + var data = simplemde.value(); var link_href = $('#attr_url_markdown').val(); $.ajax({ url: 'zmi_breadcrumbs_obj_path', @@ -68,16 +68,16 @@ $('#attr_url_markdown').on("change", function() { }); function zmiStandardOnSubmitEventHandler(fm) { - var data = simplemde.value(); - $('#' + elName).val(data); + var data = simplemde.value(); + $('#' + elName).val(data); } function zmiRichtextOnSubmitEventHandler(fm) { var el = document.getElementById('zmiRichtextEditor'+elName); - if ( el != null && el.style.display != 'none' && el.style.visibility != 'hidden') { - var data = simplemde.value(); - $('#' + elName).val(data); - } + if ( el != null && el.style.display != 'none' && el.style.visibility != 'hidden') { + var data = simplemde.value(); + $('#' + elName).val(data); + } } function zmiRichtextInit(id) { @@ -88,23 +88,24 @@ function customMarkdownParser(plainText) { text = marked.parse(plainText); // https://stackoverflow.com/questions/136505/searching-for-uuids-in-text-with-regex - const pattern = /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/ig - uuids = text.match(pattern); - - uuids.forEach(function(uuid) { - $.ajax({ - url: '++rest_api/zmsindex', - async: false, // to set text in success below - data: { - get_uid: 'uid:' + uuid, - }, - datatype: 'json', - success: function(response) { - text = text.replace('%7B$uid:' + uuid + '%7D', response[0].getPath); // incorrect path for img src - } + const pattern = /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/ig; + + var uuids = text.match(pattern); + if (uuids != null) { + uuids.forEach(function(uuid) { + $.ajax({ + url: '++rest_api/zmsindex', + async: false, // to set text in success below + data: { + get_uid: 'uid:' + uuid, + }, + datatype: 'json', + success: function(response) { + text = text.replace('%7B$uid:' + uuid + '%7D', response[0].getPath); // incorrect path for img src + } + }); }); - }); - + } return text; }