This commit is contained in:
Mateusz Gruszczyński
2026-07-29 11:48:44 +02:00
parent 904f59146b
commit 0655cfe48c
12 changed files with 938 additions and 191 deletions
+12 -1
View File
@@ -171,6 +171,17 @@ export function lineOwners(content, model) {
});
}
export function syncAuthorshipLayer(layer, editor) {
if (!layer || !editor) return;
const canvas = layer.querySelector(".authorship-canvas");
if (!canvas) return;
canvas.style.transform = `translate3d(${-editor.scrollLeft}px, ${-editor.scrollTop}px, 0)`;
// The canvas already mirrors the textarea scroll through its transform.
// Keeping the overlay element itself at zero prevents a double offset.
layer.scrollTop = 0;
layer.scrollLeft = 0;
}
export function renderAuthorshipLayer(layer, editor, model, colorFor) {
if (!layer) return;
const style = getComputedStyle(editor);
@@ -202,6 +213,6 @@ export function renderAuthorshipLayer(layer, editor, model, colorFor) {
}
if (cursor < text.length) canvas.append(document.createTextNode(text.slice(cursor)));
if (!text.endsWith("\n")) canvas.append(document.createTextNode("\n"));
canvas.style.transform = `translate3d(${-editor.scrollLeft}px, ${-editor.scrollTop}px, 0)`;
layer.replaceChildren(canvas);
syncAuthorshipLayer(layer, editor);
}