fixes and functions
This commit is contained in:
@@ -161,25 +161,6 @@ export function mapSelectionThroughEdit(previousText, nextText, start, end = sta
|
||||
end: Math.max(0, Math.min(nextText.length, map(end))),
|
||||
};
|
||||
}
|
||||
export function lineOwners(content, model) {
|
||||
const starts = [0];
|
||||
for (let i = 0; i < content.length; i++) if (content.charCodeAt(i) === 10) starts.push(i + 1);
|
||||
return starts.map((start, index) => {
|
||||
const end = index + 1 < starts.length ? starts[index + 1] : content.length;
|
||||
const totals = new Map();
|
||||
const representatives = new Map();
|
||||
for (const span of model?.spans || []) {
|
||||
const overlap = Math.max(0, Math.min(end, span.end) - Math.max(start, span.start));
|
||||
if (!overlap) continue;
|
||||
const identity = ownerIdentity(span.owner);
|
||||
totals.set(identity, (totals.get(identity) || 0) + overlap);
|
||||
representatives.set(identity, span.owner);
|
||||
}
|
||||
const identity = [...totals.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
||||
return identity ? representatives.get(identity) : "";
|
||||
});
|
||||
}
|
||||
|
||||
export function syncAuthorshipLayer(layer, editor) {
|
||||
if (!layer || !editor) return;
|
||||
const canvas = layer.querySelector(".authorship-canvas");
|
||||
|
||||
Reference in New Issue
Block a user