Skip to content

Commit

Permalink
fixed JS error null.forEach; whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho committed Jan 9, 2024
1 parent 211e008 commit 038a672
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions Products/zms/plugins/rte/simplemde/manage_form.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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) {
Expand All @@ -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;
}

Expand Down

0 comments on commit 038a672

Please sign in to comment.