mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-21 16:26:58 +08:00
feat(editor): selection as store extension (#9605)
This commit is contained in:
@@ -84,18 +84,21 @@ export const getInlineRangeProvider: (
|
||||
}
|
||||
};
|
||||
const inlineRange$: InlineRangeProvider['inlineRange$'] = signal(null);
|
||||
selectionManager.slots.changed.on(selections => {
|
||||
const textSelection = selections.find(s => s.type === 'text') as
|
||||
| TextSelection
|
||||
| undefined;
|
||||
const range = rangeManager.value;
|
||||
if (!range || !textSelection) {
|
||||
inlineRange$.value = null;
|
||||
return;
|
||||
}
|
||||
const inlineRange = calculateInlineRange(range, textSelection);
|
||||
inlineRange$.value = inlineRange;
|
||||
});
|
||||
|
||||
editorHost.disposables.add(
|
||||
selectionManager.slots.changed.on(selections => {
|
||||
const textSelection = selections.find(s => s.type === 'text') as
|
||||
| TextSelection
|
||||
| undefined;
|
||||
const range = rangeManager.value;
|
||||
if (!range || !textSelection) {
|
||||
inlineRange$.value = null;
|
||||
return;
|
||||
}
|
||||
const inlineRange = calculateInlineRange(range, textSelection);
|
||||
inlineRange$.value = inlineRange;
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
setInlineRange,
|
||||
|
||||
Reference in New Issue
Block a user