fixes
This commit is contained in:
+12
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user