Updated updateView, now will updateHistory in editor changes event, support preventSyncScroll and workaround editor might scroll to no where on changes in the doc bottom
This commit is contained in:
parent
11c4a0404e
commit
fa957db272
2 changed files with 12 additions and 1 deletions
|
@ -1596,6 +1596,12 @@ editor.on('beforeChange', function (cm, change) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
editor.on('changes', function (cm, changes) {
|
||||||
|
updateHistory();
|
||||||
|
preventSyncScroll = true;
|
||||||
|
var scrollInfo = editor.getScrollInfo();
|
||||||
|
editor.scrollTo(null, scrollInfo.top - 1);
|
||||||
|
editor.scrollTo(null, scrollInfo.top);
|
||||||
});
|
});
|
||||||
editor.on('focus', function (cm) {
|
editor.on('focus', function (cm) {
|
||||||
for (var i = 0; i < onlineUsers.length; i++) {
|
for (var i = 0; i < onlineUsers.length; i++) {
|
||||||
|
@ -1731,7 +1737,6 @@ function updateViewInner() {
|
||||||
generateToc('toc-affix');
|
generateToc('toc-affix');
|
||||||
generateScrollspy();
|
generateScrollspy();
|
||||||
smoothHashScroll();
|
smoothHashScroll();
|
||||||
writeHistory(ui.area.markdown);
|
|
||||||
isDirty = false;
|
isDirty = false;
|
||||||
clearMap();
|
clearMap();
|
||||||
buildMap();
|
buildMap();
|
||||||
|
|
|
@ -139,6 +139,8 @@ md.renderer.rules.code = function (tokens, idx /*, options, env */ ) {
|
||||||
return '<code>' + Remarkable.utils.escapeHtml(tokens[idx].content) + '</code>';
|
return '<code>' + Remarkable.utils.escapeHtml(tokens[idx].content) + '</code>';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var preventSyncScroll = false;
|
||||||
|
|
||||||
//var editorScrollThrottle = 100;
|
//var editorScrollThrottle = 100;
|
||||||
var buildMapThrottle = 100;
|
var buildMapThrottle = 100;
|
||||||
|
|
||||||
|
@ -299,6 +301,10 @@ function getEditorLineNoByTop(top) {
|
||||||
|
|
||||||
function syncScrollToView(event, _lineNo) {
|
function syncScrollToView(event, _lineNo) {
|
||||||
if (currentMode != modeType.both) return;
|
if (currentMode != modeType.both) return;
|
||||||
|
if (preventSyncScroll) {
|
||||||
|
preventSyncScroll = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var lineNo, posTo;
|
var lineNo, posTo;
|
||||||
var scrollInfo = editor.getScrollInfo();
|
var scrollInfo = editor.getScrollInfo();
|
||||||
if (!scrollMap || !lineHeightMap) {
|
if (!scrollMap || !lineHeightMap) {
|
||||||
|
|
Loading…
Reference in a new issue