Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

perf(editor): avoid redundant dom query when editing single block (#11732)

Yifeng Wang16f7be7f0b50
diff --git a/blocksuite/framework/std/src/inline/range/inline-range-provider.ts b/blocksuite/framework/std/src/inline/range/inline-range-provider.ts
index f53afedc27..eb4b85a34a 100644
--- a/blocksuite/framework/std/src/inline/range/inline-range-provider.ts
+++ b/blocksuite/framework/std/src/inline/range/inline-range-provider.ts
@@ -40,6 +40,13 @@ export const getInlineRangeProvider: (
return null;
}
+ if (
+ textSelection.isInSameBlock() &&
+ textSelection.from.blockId !== element.blockId
+ ) {
+ return null;
+ }
+
const elementRange = rangeManager.textSelectionToRange(
selectionManager.create(TextSelection, {
from: {
@@ -98,6 +105,7 @@ export const getInlineRangeProvider: (
inlineRange$.value = null;
return;
}
+
const inlineRange = calculateInlineRange(range, textSelection);
inlineRange$.value = inlineRange;
})