Skip to content

Commit

Permalink
fix(blocks): latex selected state in edgeless mode (#8344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flrande authored Sep 13, 2024
1 parent 9f1edb4 commit 57cfefb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/framework/block-std/src/range/inline-range-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ export const getInlineRangeProvider: (
let lastInlineRange: InlineRange | null = null;
selectionManager.slots.changed.on(() => {
const textSelection = selectionManager.find('text');
if (!textSelection) return;
if (!textSelection) {
inlineRangeUpdatedSlot.emit([null, false]);
return;
}

const range = rangeManager.value;
if (!range || !isElementSelected(range)) return;
if (!range || !isElementSelected(range)) {
inlineRangeUpdatedSlot.emit([null, false]);
return;
}

// wait for lit updated
requestAnimationFrame(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/inline/src/services/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class RangeService<TextAttributes extends BaseTextAttributes> {
return;
}

if (this._inlineRange === null) {
if (this._inlineRange === null && this.editor.mounted) {
const selection = document.getSelection();
if (selection && selection.rangeCount > 0) {
const range = selection.getRangeAt(0);
Expand Down

0 comments on commit 57cfefb

Please sign in to comment.