0.2.88
This commit is contained in:
1 parent
df403c0aa7
commit
9e133628e5
17 files changed
+270
-34
No files matched your search
@@ -1247,6 +1247,21 @@ export function startNoteEditor(adapter) {
|
||||
});
|
||||
}
|
||||
const render = createRenderQueue(renderNow);
|
||||
// Collaborative edits can arrive many times per second. Keep typing and
|
||||
// WebSocket processing responsive by batching expensive Markdown/DOM work.
|
||||
let deferredRenderTimer = null;
|
||||
let firstDeferredRenderAt = 0;
|
||||
function scheduleDocumentRender() {
|
||||
const now = performance.now();
|
||||
if (deferredRenderTimer === null) firstDeferredRenderAt = now;
|
||||
else clearTimeout(deferredRenderTimer);
|
||||
const delay = Math.min(180, Math.max(0, 750 - (now - firstDeferredRenderAt)));
|
||||
deferredRenderTimer = setTimeout(() => {
|
||||
deferredRenderTimer = null;
|
||||
firstDeferredRenderAt = 0;
|
||||
render();
|
||||
}, delay);
|
||||
}
|
||||
function queueCollaborativeOperation(operation, ownerReplacements = []) {
|
||||
if (!collaboration.ready || !canEditDocument()) return false;
|
||||
try {
|
||||
@@ -1407,7 +1422,7 @@ export function startNoteEditor(adapter) {
|
||||
if (ownerMap != null) authorship = adoptCurrentOwnerAliases(parseAuthorship(content, ownerMap), content.length);
|
||||
previousContent = content;
|
||||
editHistory.syncCurrent();
|
||||
renderGutter();
|
||||
scheduleDocumentRender();
|
||||
requestAnimationFrame(revealLinkedLine);
|
||||
return;
|
||||
}
|
||||
@@ -1427,7 +1442,7 @@ export function startNoteEditor(adapter) {
|
||||
applyingRemote = false;
|
||||
if (resetHistory) editHistory.reset();
|
||||
else editHistory.syncCurrent();
|
||||
render();
|
||||
scheduleDocumentRender();
|
||||
editor.scrollTop = initialLoad ? 0 : scrollTop;
|
||||
editor.scrollLeft = scrollLeft;
|
||||
syncEditorLayers();
|
||||
@@ -2238,7 +2253,7 @@ export function startNoteEditor(adapter) {
|
||||
});
|
||||
preview.addEventListener("change", event => {
|
||||
const checkbox = event.target.closest(".task-checkbox");
|
||||
if (!checkbox) return;
|
||||
if (!checkbox || checkbox.disabled) return;
|
||||
if (!canEditDocument()) {
|
||||
checkbox.checked = !checkbox.checked;
|
||||
saveState.textContent = "Read only";
|
||||
@@ -2488,7 +2503,7 @@ export function startNoteEditor(adapter) {
|
||||
authorship = replaceAuthorshipOwner(authorship, owner => ownerName(owner) === nickname, currentOwner(), previous.length);
|
||||
authorship = applyAuthorshipEdit(authorship, previous, nextContent, currentOwner());
|
||||
previousContent = nextContent;
|
||||
render();
|
||||
scheduleDocumentRender();
|
||||
if (applyingRemote || applyingHistory) return;
|
||||
queueCollaborativeOperation(operationFromEdit(previous, nextContent, authorship));
|
||||
editHistory.record(event.inputType || "");
|
||||
|
||||
Reference in new issue
Block a user