Skip to content
Snippets Groups Projects
Unverified Commit 12a641be authored by Tim Schroeder's avatar Tim Schroeder
Browse files

fix editing comments with mathjax formulas

parent 08346352
No related branches found
No related tags found
No related merge requests found
...@@ -416,7 +416,8 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -416,7 +416,8 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
if (data.status === "success") { if (data.status === "success") {
$("#comment_" + commentId).addClass('dimmed_text'); // render chat box in grey. $("#comment_" + commentId).addClass('dimmed_text'); // render chat box in grey.
$('#chatmessage' + commentId).append("<br><span id='taghidden" + commentId + "' class='tag tag-info'>" + M.util.get_string('hiddenforparticipants', 'pdfannotator') + "</span>"); $('#chatmessage' + commentId).append("<br><span id='taghidden" + commentId + "' class='tag tag-info'>" + M.util.get_string('hiddenforparticipants', 'pdfannotator') + "</span>");
renderMathJax(); let comment = document.getElementById("comment_" + commentId);
renderMathJax(comment);
notification.addNotification({ notification.addNotification({
message: M.util.get_string('successfullyHidden', 'pdfannotator'), message: M.util.get_string('successfullyHidden', 'pdfannotator'),
type: "success" type: "success"
...@@ -452,7 +453,8 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -452,7 +453,8 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
if (data.status === "success") { if (data.status === "success") {
$("#comment_" + commentId).removeClass('dimmed_text'); // render chat box in grey. $("#comment_" + commentId).removeClass('dimmed_text'); // render chat box in grey.
$('#taghidden' + commentId).remove(); $('#taghidden' + commentId).remove();
renderMathJax(); let comment = document.getElementById("comment_" + commentId);
renderMathJax(comment);
notification.addNotification({ notification.addNotification({
message: M.util.get_string('successfullyRedisplayed', 'pdfannotator'), message: M.util.get_string('successfullyRedisplayed', 'pdfannotator'),
type: "success" type: "success"
...@@ -1576,10 +1578,10 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -1576,10 +1578,10 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
let selector = '#comment_' + comment.uuid + ' .chat-message-text p'; let selector = '#comment_' + comment.uuid + ' .chat-message-text p';
let element = document.querySelector(selector);
renderMathJax(element);
}); });
// fixCommentForm(); // fixCommentForm();
renderMathJax();
//$("#comment_"+comment.uuid+" chat-message-p:contains('"+pattern+"')").addClass('mark'); //$("#comment_"+comment.uuid+" chat-message-p:contains('"+pattern+"')").addClass('mark');
//$("chat-message+:contains('text')").addClass('mark'); //$("chat-message+:contains('text')").addClass('mark');
...@@ -1764,7 +1766,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -1764,7 +1766,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
} else if(newContent === comment.content) { // No changes. } else if(newContent === comment.content) { // No changes.
editForm.style.display = "none"; editForm.style.display = "none";
text.innerHTML = comment.content; text.innerHTML = comment.content;
renderMathJax(); renderMathJax(text);
} else { // Save changes. } else { // Save changes.
_2.default.getStoreAdapter().editComment(documentId, comment.uuid, newContent) _2.default.getStoreAdapter().editComment(documentId, comment.uuid, newContent)
.then(function(data){ .then(function(data){
...@@ -1778,7 +1780,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -1778,7 +1780,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
newContent = data.newContent; newContent = data.newContent;
text.innerHTML = newContent; text.innerHTML = newContent;
comment.content = newContent; comment.content = newContent;
renderMathJax(); renderMathJax(text);
notification.addNotification({ notification.addNotification({
message: M.util.get_string('successfullyEdited', 'pdfannotator'), message: M.util.get_string('successfullyEdited', 'pdfannotator'),
type: "success" type: "success"
...@@ -1804,12 +1806,12 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -1804,12 +1806,12 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
$('#comment_' + comment.uuid + ' #commentCancel').click(function(e){ $('#comment_' + comment.uuid + ' #commentCancel').click(function(e){
editForm.style.display = "none"; editForm.style.display = "none";
text.innerHTML = comment.content; text.innerHTML = comment.content;
renderMathJax(); renderMathJax(text);
}); });
} else { } else {
editForm.style.display = "none"; editForm.style.display = "none";
text.innerHTML = comment.content; text.innerHTML = comment.content;
renderMathJax(); renderMathJax(text);
} }
} }
// Create an element for click. // Create an element for click.
......
...@@ -83,18 +83,18 @@ function addDropdownNavigation(Y, __capabilities, __cmid) { ...@@ -83,18 +83,18 @@ function addDropdownNavigation(Y, __capabilities, __cmid) {
} }
function renderMathJax() { function renderMathJax(node) {
var counter = 0; var counter = 0;
let mathjax = function () { let mathjax = function (node) {
if (typeof (MathJax) !== "undefined") { if (typeof (MathJax) !== "undefined") {
MathJax.Hub.Queue(['Typeset', MathJax.Hub]); MathJax.Hub.Queue(['Typeset', MathJax.Hub, node]);
} else if (counter < 30) { } else if (counter < 30) {
counter++; counter++;
setTimeout(mathjax, 100); setTimeout(mathjax, 100);
} else { } else {
} }
}; };
mathjax(); mathjax(node);
} }
function fixCommentForm() { function fixCommentForm() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment