Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 committed Oct 30, 2024
1 parent 8b0b3e0 commit 11051bc
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -536,20 +536,14 @@ function updateCustomDecorations(
}

if (coverType === UpdateDocsAttributeType.REPLACE) {
const removeIndex: number[] = [];
for (let index = 0; index < customDecorations.length; index++) {
const customDecoration = customDecorations[index];
const { startIndex, endIndex } = customDecoration;
if (startIndex >= currentIndex && endIndex <= currentIndex + textLength - 1) {
removeCustomDecorations.push(customDecoration);
removeIndex.push(index);
}
}

for (let index = removeIndex.length - 1; index >= 0; index--) {
customDecorations.splice(removeIndex[index], 1);
}

updateDataCustomDecorations?.forEach((customDecoration) => {
const { startIndex, endIndex } = customDecoration;
customDecorations.push({
Expand All @@ -576,13 +570,13 @@ function updateCustomDecorations(
});
}
}
}

for (const removeCustomDecoration of removeCustomDecorations) {
const { id } = removeCustomDecoration;
const index = customDecorations.findIndex((d) => d.id === id);
if (index !== -1) {
customDecorations.splice(index, 1);
}
for (const removeCustomDecoration of removeCustomDecorations) {
const { id } = removeCustomDecoration;
const index = customDecorations.findIndex((d) => d.id === id);
if (index !== -1) {
customDecorations.splice(index, 1);
}
}

Expand Down

0 comments on commit 11051bc

Please sign in to comment.