Browse Source

#WOA-2374|resolved|Clear HTML if text is empty

ihork 8 years ago
parent
commit
b639aed882
1 changed files with 13 additions and 0 deletions
  1. 13
    0
      src/editor.html

+ 13
- 0
src/editor.html View File

@@ -863,6 +863,16 @@
863 863
 				});
864 864
 			}
865 865
 
866
+			function clearHtmlIfTextIsEmpty(editorId) {
867
+				var $editor = $(`#${editorId}`);
868
+
869
+				$editor.on('input', function() {
870
+					if (!(this.textContent || this.querySelectorAll('img, li').length)) {
871
+						this.innerHTML = '';
872
+					}
873
+				});
874
+			}
875
+
866 876
 			zss_editor.init = function() {
867 877
 
868 878
 				disableLineBreakIfNecessary('zss_editor_title');
@@ -871,6 +881,9 @@
871 881
 				setupTouchEndEnableEditing('zss_editor_title');
872 882
 				setupTouchEndEnableEditing('zss_editor_content');
873 883
 
884
+				clearHtmlIfTextIsEmpty('zss_editor_title');
885
+				clearHtmlIfTextIsEmpty('zss_editor_content');
886
+
874 887
 				$(document).on('selectionchange',function(e){
875 888
 					console.log('selectionchange');
876 889
 					zss_editor.calculateEditorHeightWithCaretPosition();