Skip to content

Commit b639aed

Browse files
committed
#WOA-2374|resolved|Clear HTML if text is empty
1 parent 207867b commit b639aed

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/editor.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,16 @@
863863
});
864864
}
865865

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+
866876
zss_editor.init = function() {
867877

868878
disableLineBreakIfNecessary('zss_editor_title');
@@ -871,6 +881,9 @@
871881
setupTouchEndEnableEditing('zss_editor_title');
872882
setupTouchEndEnableEditing('zss_editor_content');
873883

884+
clearHtmlIfTextIsEmpty('zss_editor_title');
885+
clearHtmlIfTextIsEmpty('zss_editor_content');
886+
874887
$(document).on('selectionchange',function(e){
875888
console.log('selectionchange');
876889
zss_editor.calculateEditorHeightWithCaretPosition();

0 commit comments

Comments
 (0)