feat(editor): selection as store extension (#9605)

This commit is contained in:
Saul-Mirone
2025-01-09 11:49:23 +00:00
parent c2d8c23f13
commit 126ab18967
39 changed files with 176 additions and 204 deletions

View File

@@ -1,7 +1,7 @@
import { throttle } from '@blocksuite/global/utils';
import type { BlockModel } from '@blocksuite/store';
import type { BaseSelection, BlockModel } from '@blocksuite/store';
import { type BaseSelection, TextSelection } from '../selection/index.js';
import { TextSelection } from '../selection/index.js';
import type { BlockComponent } from '../view/element/block-component.js';
import { BLOCK_ID_ATTR } from '../view/index.js';
import { RANGE_SYNC_EXCLUDE_ATTR } from './consts.js';
@@ -247,6 +247,9 @@ export class RangeBinding {
};
private readonly _onStdSelectionChanged = (selections: BaseSelection[]) => {
const closestHost = document.activeElement?.closest('editor-host');
if (closestHost && closestHost !== this.host) return;
const text =
selections.find((selection): selection is TextSelection =>
selection.is(TextSelection)