From b06ccf2202966c5a8b3438f5867a58f6e22d7ce8 Mon Sep 17 00:00:00 2001
From: anisa kusumadewi <kusumadewi@itc.rwth-aachen.de>
Date: Wed, 26 Oct 2022 12:44:05 +0200
Subject: [PATCH] fix min0char

---
 locallib.php    | 2 +-
 shared/index.js | 6 +++---
 version.php     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/locallib.php b/locallib.php
index ebcbcc9..48ec13f 100644
--- a/locallib.php
+++ b/locallib.php
@@ -64,7 +64,7 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
     // Load and execute the javascript files.
     $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
     $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
-    $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00031"));
+    $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00032"));
     $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00005"));
 
     // Pass parameters from PHP to JavaScript.
diff --git a/shared/index.js b/shared/index.js
index 42e1753..9be76a8 100644
--- a/shared/index.js
+++ b/shared/index.js
@@ -831,7 +831,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                                         text = text.replace(/<br \/>/g, "\n");
                                         // Remove all other HTML-Tags.
                                         text = $("<div>").html(text).text();
-                                        
+
                                         var stringarray = doc.splitTextToSize(text, characters);
                                         var textbit;
                                         for (var j = 0; j < stringarray.length; j++) {
@@ -1777,7 +1777,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                             let defaultPTag = editAreaEditable.querySelector('p');
                             if(defaultPTag) {
                                 // No text and no images in default p tag of editor.
-                                if (defaultPTag.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0) {
+                                if (defaultPTag.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0 && editAreaEditable.childNodes.length === 0) {
                                     isEmptyContent = true;
                                 }
                             }
@@ -1956,7 +1956,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                                 var innerContent = commentContentElements.innerText.replace('/\n/g', '').trim();
                                 var temp = commentContentElements.querySelectorAll('p')[0];
                                 if(temp) {
-                                    if ((temp.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0) || innerContent === '') {
+                                    if ((temp.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0) && innerContent === '') {
                                         isEmptyContent = true;
                                     }
                                 }
diff --git a/version.php b/version.php
index 4f2ef28..981da97 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 $plugin->component = 'mod_pdfannotator';
-$plugin->version   = 2022102601;
+$plugin->version   = 2022102602;
 $plugin->release  = 'PDF Annotator v1.4 release 11';
 $plugin->requires  = 2021051700;
 $plugin->maturity  = MATURITY_STABLE;
-- 
GitLab