@blocksuite/block-std
Advanced tools
Comparing version 0.0.0-20230814000457-ce469d9b-nightly to 0.0.0-20230814155455-ceb5d5d8-nightly
@@ -6,2 +6,3 @@ export type BaseSelectionOptions = { | ||
static readonly type: string; | ||
static readonly group: string; | ||
readonly path: string[]; | ||
@@ -12,2 +13,3 @@ constructor({ path }: BaseSelectionOptions); | ||
get type(): BlockSuiteSelectionType; | ||
get group(): string; | ||
abstract equals(other: BaseSelection): boolean; | ||
@@ -14,0 +16,0 @@ abstract toJSON(): Record<string, unknown>; |
@@ -16,2 +16,5 @@ import { PathFinder } from '../utils/index.js'; | ||
} | ||
get group() { | ||
return this.constructor.group; | ||
} | ||
static fromJSON(_) { | ||
@@ -18,0 +21,0 @@ throw new Error('You must override this method'); |
@@ -25,2 +25,4 @@ import { DisposableGroup, Slot } from '@blocksuite/store'; | ||
set(selections: BaseSelection[]): void; | ||
setGroup(group: string, selections: BaseSelection[]): void; | ||
getGroup(group: string): BaseSelection[]; | ||
update(fn: (currentSelections: BaseSelection[]) => BaseSelection[]): void; | ||
@@ -27,0 +29,0 @@ clear(types?: string[]): void; |
@@ -58,2 +58,9 @@ import { DisposableGroup, Slot } from '@blocksuite/store'; | ||
} | ||
setGroup(group, selections) { | ||
const current = this.value.filter(s => s.group !== group); | ||
this.set([...current, ...selections]); | ||
} | ||
getGroup(group) { | ||
return this.value.filter(s => s.group === group); | ||
} | ||
update(fn) { | ||
@@ -60,0 +67,0 @@ const selections = fn(this.value); |
import { BaseSelection } from '../base.js'; | ||
export declare class BlockSelection extends BaseSelection { | ||
static type: string; | ||
static group: string; | ||
equals(other: BaseSelection): boolean; | ||
@@ -5,0 +6,0 @@ toJSON(): Record<string, unknown>; |
@@ -23,2 +23,3 @@ import { PathFinder } from '../../utils/index.js'; | ||
BlockSelection.type = 'block'; | ||
BlockSelection.group = 'note'; | ||
//# sourceMappingURL=block.js.map |
import { BaseSelection } from '../base.js'; | ||
export declare class SurfaceSelection extends BaseSelection { | ||
static type: string; | ||
static group: string; | ||
readonly elements: string[]; | ||
@@ -5,0 +6,0 @@ readonly editing: boolean; |
@@ -32,2 +32,3 @@ import { BaseSelection } from '../base.js'; | ||
SurfaceSelection.type = 'surface'; | ||
SurfaceSelection.group = 'edgeless'; | ||
//# sourceMappingURL=surface.js.map |
@@ -13,2 +13,3 @@ import { BaseSelection } from '../base.js'; | ||
static type: string; | ||
static group: string; | ||
from: TextRangePoint; | ||
@@ -15,0 +16,0 @@ to: TextRangePoint | null; |
@@ -51,2 +51,3 @@ import { PathFinder } from '../../utils/path-finder.js'; | ||
TextSelection.type = 'text'; | ||
TextSelection.group = 'note'; | ||
//# sourceMappingURL=text.js.map |
{ | ||
"name": "@blocksuite/block-std", | ||
"version": "0.0.0-20230814000457-ce469d9b-nightly", | ||
"version": "0.0.0-20230814155455-ceb5d5d8-nightly", | ||
"description": "Std for blocksuite blocks", | ||
@@ -12,10 +12,10 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"@blocksuite/store": "0.0.0-20230814000457-ce469d9b-nightly" | ||
"@blocksuite/store": "0.0.0-20230814155455-ceb5d5d8-nightly" | ||
}, | ||
"dependencies": { | ||
"w3c-keyname": "^2.2.8", | ||
"@blocksuite/global": "0.0.0-20230814000457-ce469d9b-nightly" | ||
"@blocksuite/global": "0.0.0-20230814155455-ceb5d5d8-nightly" | ||
}, | ||
"devDependencies": { | ||
"@blocksuite/store": "0.0.0-20230814000457-ce469d9b-nightly" | ||
"@blocksuite/store": "0.0.0-20230814155455-ceb5d5d8-nightly" | ||
}, | ||
@@ -22,0 +22,0 @@ "exports": { |
@@ -6,2 +6,3 @@ import { PathFinder } from '../utils/index.js'; | ||
type: string; | ||
group: string; | ||
}; | ||
@@ -15,2 +16,3 @@ | ||
static readonly type: string; | ||
static readonly group: string; | ||
readonly path: string[]; | ||
@@ -37,2 +39,6 @@ | ||
get group(): string { | ||
return (this.constructor as SelectionConstructor).group; | ||
} | ||
abstract equals(other: BaseSelection): boolean; | ||
@@ -39,0 +45,0 @@ |
@@ -78,2 +78,11 @@ import type { StackItem } from '@blocksuite/store'; | ||
setGroup(group: string, selections: BaseSelection[]) { | ||
const current = this.value.filter(s => s.group !== group); | ||
this.set([...current, ...selections]); | ||
} | ||
getGroup(group: string) { | ||
return this.value.filter(s => s.group === group); | ||
} | ||
update(fn: (currentSelections: BaseSelection[]) => BaseSelection[]) { | ||
@@ -80,0 +89,0 @@ const selections = fn(this.value); |
@@ -6,2 +6,3 @@ import { PathFinder } from '../../utils/index.js'; | ||
static override type = 'block'; | ||
static override group = 'note'; | ||
@@ -8,0 +9,0 @@ override equals(other: BaseSelection): boolean { |
@@ -5,2 +5,3 @@ import { BaseSelection } from '../base.js'; | ||
static override type = 'surface'; | ||
static override group = 'edgeless'; | ||
@@ -7,0 +8,0 @@ readonly elements: string[]; |
@@ -17,2 +17,3 @@ import { PathFinder } from '../../utils/path-finder.js'; | ||
static override type = 'text'; | ||
static override group = 'note'; | ||
@@ -19,0 +20,0 @@ from: TextRangePoint; |
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
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
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
436472
3481
+ Added@blocksuite/global@0.0.0-20230814155455-ceb5d5d8-nightly(transitive)
+ Added@blocksuite/store@0.0.0-20230814155455-ceb5d5d8-nightly(transitive)
+ Added@blocksuite/virgo@0.0.0-20230814155455-ceb5d5d8-nightly(transitive)
- Removed@blocksuite/global@0.0.0-20230814000457-ce469d9b-nightly(transitive)
- Removed@blocksuite/store@0.0.0-20230814000457-ce469d9b-nightly(transitive)
- Removed@blocksuite/virgo@0.0.0-20230814000457-ce469d9b-nightly(transitive)
Updated@blocksuite/global@0.0.0-20230814155455-ceb5d5d8-nightly