Skip to content

Commit f1b24e9

Browse files
committed
Prevent some doubled actions, fix runtime error
1 parent 4774dfe commit f1b24e9

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/editor.html

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -827,14 +827,6 @@
827827
});
828828
}
829829

830-
function setupSelectionChange(editorId) {
831-
$(document).on('selectionchange',function(e){
832-
zss_editor.calculateEditorHeightWithCaretPosition(editorId);
833-
zss_editor.setScrollPosition();
834-
zss_editor.enabledEditingItems(e);
835-
});
836-
}
837-
838830
function setupTouchEndFocus(editorId) {
839831
$(window).on('touchend', function(e) {
840832
if (!zss_editor.isDragging && (e.target.id == "zss_editor_footer"||e.target.nodeName.toLowerCase() == "html")) {
@@ -879,8 +871,12 @@
879871
setupTouchEndEnableEditing('zss_editor_title');
880872
setupTouchEndEnableEditing('zss_editor_content');
881873

882-
setupSelectionChange('zss_editor_title');
883-
setupSelectionChange('zss_editor_content');
874+
$(document).on('selectionchange',function(e){
875+
console.log('selectionchange');
876+
zss_editor.calculateEditorHeightWithCaretPosition();
877+
zss_editor.setScrollPosition();
878+
zss_editor.enabledEditingItems(e);
879+
});
884880

885881
$(window).on('scroll', function(e) {
886882
zss_editor.updateOffset();
@@ -1014,13 +1010,10 @@
10141010
return topPosition;
10151011
}
10161012

1017-
zss_editor.calculateEditorHeightWithCaretPosition = function(editorId) {
1013+
zss_editor.calculateEditorHeightWithCaretPosition = function() {
10181014

10191015
var padding = 50;
10201016
var c = zss_editor.getCaretYPosition();
1021-
var e = document.getElementById(editorId);
1022-
1023-
var editor = $(`#${editorId}`);
10241017

10251018
var offsetY = window.document.body.scrollTop;
10261019
var height = zss_editor.contentHeight;
@@ -1682,5 +1675,6 @@
16821675
<div id="zss_editor_title" class="zss_editor_title" contenteditable="true" placeholder="" disableLineBreaks="true"></div>
16831676
<div id="separatorContainer"><hr></div>
16841677
<div id="zss_editor_content" class="zs_editor_content" contenteditable="true" placeholder=""></div>
1678+
<div id="zss_editor_footer"></div>
16851679
</body>
16861680
</html>

0 commit comments

Comments
 (0)