@blocksuite/virgo
Advanced tools
Comparing version 0.0.0-20230817030423-20f3821a-nightly to 0.0.0-20230817172832-20c2b2a5-nightly
@@ -17,3 +17,3 @@ import type { VRange } from '../types.js'; | ||
*/ | ||
setVRange: (vRange: VRange, sync?: boolean) => void; | ||
setVRange: (vRange: VRange | null, sync?: boolean) => void; | ||
/** | ||
@@ -20,0 +20,0 @@ * sync the dom selection from vRange for **this Editor** |
@@ -23,2 +23,13 @@ import { VirgoLine } from '../components/index.js'; | ||
} | ||
if (this._vRange === null) { | ||
const selectionRoot = findDocumentOrShadowRoot(this._editor); | ||
const selection = selectionRoot.getSelection(); | ||
if (selection && selection.rangeCount > 0) { | ||
const range = selection.getRangeAt(0); | ||
if (range.intersectsNode(this._editor.rootElement)) { | ||
selection.removeAllRanges(); | ||
} | ||
} | ||
return; | ||
} | ||
const fn = () => { | ||
@@ -25,0 +36,0 @@ // There may be multiple range update events in one frame, |
@@ -58,3 +58,3 @@ import type { NullablePartial } from '@blocksuite/global/utils'; | ||
getVRange: () => VRange | null; | ||
setVRange: (vRange: VRange, sync?: boolean) => void; | ||
setVRange: (vRange: VRange | null, sync?: boolean) => void; | ||
syncVRange: () => void; | ||
@@ -61,0 +61,0 @@ getDeltasByVRange: (vRange: VRange) => import("./types.js").DeltaEntry<TextAttributes>[]; |
{ | ||
"name": "@blocksuite/virgo", | ||
"version": "0.0.0-20230817030423-20f3821a-nightly", | ||
"version": "0.0.0-20230817172832-20c2b2a5-nightly", | ||
"description": "A micro editor.", | ||
@@ -28,3 +28,3 @@ "main": "dist/index.js", | ||
"zod": "^3.21.4", | ||
"@blocksuite/global": "0.0.0-20230817030423-20f3821a-nightly" | ||
"@blocksuite/global": "0.0.0-20230817172832-20c2b2a5-nightly" | ||
}, | ||
@@ -31,0 +31,0 @@ "scripts": { |
@@ -42,2 +42,14 @@ import { VirgoLine } from '../components/index.js'; | ||
if (this._vRange === null) { | ||
const selectionRoot = findDocumentOrShadowRoot(this._editor); | ||
const selection = selectionRoot.getSelection(); | ||
if (selection && selection.rangeCount > 0) { | ||
const range = selection.getRangeAt(0); | ||
if (range.intersectsNode(this._editor.rootElement)) { | ||
selection.removeAllRanges(); | ||
} | ||
} | ||
return; | ||
} | ||
const fn = () => { | ||
@@ -64,3 +76,3 @@ // There may be multiple range update events in one frame, | ||
*/ | ||
setVRange = (vRange: VRange, sync = true): void => { | ||
setVRange = (vRange: VRange | null, sync = true): void => { | ||
this._editor.slots.vRangeUpdated.emit([vRange, sync ? 'other' : 'silent']); | ||
@@ -67,0 +79,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
504138
8358
+ Added@blocksuite/global@0.0.0-20230817172832-20c2b2a5-nightly(transitive)
- Removed@blocksuite/global@0.0.0-20230817030423-20f3821a-nightly(transitive)
Updated@blocksuite/global@0.0.0-20230817172832-20c2b2a5-nightly