@blocksuite/shared
Advanced tools
Comparing version 0.2.1 to 0.2.2
import type { Quill } from 'quill'; | ||
import { BaseBlockModel, Store } from '@blocksuite/store'; | ||
import { BlockHost, Detail, SelectionPosition } from './types'; | ||
import { BlockHost, Detail, SelectionPosition, SelectOptions } from './types'; | ||
declare type ExtendedModel = BaseBlockModel & Record<string, any>; | ||
@@ -22,3 +22,4 @@ export declare function createEvent<T extends keyof WindowEventMap>(type: T, detail: Detail<T>): CustomEvent<Detail<T>>; | ||
export declare function commonTextActiveHandler(position: SelectionPosition, editableContainer: Element): void; | ||
export declare function commonPassCursorHandler(id: string, selection: BlockHost['selection'], selectOptions?: SelectOptions): void; | ||
export {}; | ||
//# sourceMappingURL=operations.d.ts.map |
@@ -318,2 +318,13 @@ import { TextEntity } from '@blocksuite/store'; | ||
} | ||
export function commonPassCursorHandler(id, selection, selectOptions) { | ||
if (selectOptions?.needFocus) { | ||
const lastSelectionPosition = selection.lastSelectionPosition; | ||
if (selectOptions?.from === 'next') { | ||
selection.activatePreviousBlock(id, lastSelectionPosition); | ||
} | ||
else { | ||
selection.activateNextBlock(id, lastSelectionPosition); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=operations.js.map |
import type { BaseBlockModel, Store } from '@blocksuite/store'; | ||
import { Point } from './rect'; | ||
export declare type SelectionPosition = 'start' | 'end' | Point; | ||
export declare type SelectOptions = { | ||
needFocus?: boolean; | ||
from?: 'previous' | 'next'; | ||
}; | ||
/** Common context interface definition for block models. */ | ||
@@ -8,9 +12,9 @@ export interface BlockHost { | ||
selection: { | ||
addBlockSelectedListener: (blockId: string, handler: (selected: boolean) => void) => void; | ||
addBlockSelectedListener: (blockId: string, handler: (selectionInfo?: SelectOptions) => void) => void; | ||
removeBlockSelectedListener: (blockId: string) => void; | ||
addBlockActiveListener: (blockId: string, handler: (position: SelectionPosition) => void) => void; | ||
removeBlockActiveListener: (blockId: string) => void; | ||
activatePreviousBlock: (blockId: string, position?: SelectionPosition) => void; | ||
activateNextBlock: (blockId: string, position?: SelectionPosition) => void; | ||
selectAllBlocks: () => void; | ||
selectionInfo: SelectionInfo; | ||
lastSelectionPosition: SelectionPosition; | ||
}; | ||
@@ -17,0 +21,0 @@ } |
{ | ||
"name": "@blocksuite/shared", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"type": "module", | ||
@@ -11,3 +11,3 @@ "description": "", | ||
"dependencies": { | ||
"@blocksuite/store": "0.2.1", | ||
"@blocksuite/store": "0.2.2", | ||
"hotkeys-js": "^3.10.0" | ||
@@ -14,0 +14,0 @@ }, |
import type { Quill } from 'quill'; | ||
import { BaseBlockModel, Store, TextEntity } from '@blocksuite/store'; | ||
import { BlockHost, Detail, SelectionPosition } from './types'; | ||
import { BlockHost, Detail, SelectionPosition, SelectOptions } from './types'; | ||
import { ALLOW_DEFAULT, PREVENT_DEFAULT } from './consts'; | ||
@@ -416,1 +416,16 @@ import { Point, Rect } from './rect'; | ||
} | ||
export function commonPassCursorHandler( | ||
id: string, | ||
selection: BlockHost['selection'], | ||
selectOptions?: SelectOptions | ||
) { | ||
if (selectOptions?.needFocus) { | ||
const lastSelectionPosition = selection.lastSelectionPosition; | ||
if (selectOptions?.from === 'next') { | ||
selection.activatePreviousBlock(id, lastSelectionPosition); | ||
} else { | ||
selection.activateNextBlock(id, lastSelectionPosition); | ||
} | ||
} | ||
} |
@@ -6,2 +6,7 @@ import type { BaseBlockModel, Store } from '@blocksuite/store'; | ||
export type SelectOptions = { | ||
needFocus?: boolean; | ||
from?: 'previous' | 'next'; | ||
}; | ||
/** Common context interface definition for block models. */ | ||
@@ -14,12 +19,5 @@ export interface BlockHost { | ||
blockId: string, | ||
handler: (selected: boolean) => void | ||
handler: (selectionInfo?: SelectOptions) => void | ||
) => void; | ||
removeBlockSelectedListener: (blockId: string) => void; | ||
addBlockActiveListener: ( | ||
blockId: string, | ||
handler: (position: SelectionPosition) => void | ||
) => void; | ||
removeBlockActiveListener: (blockId: string) => void; | ||
activatePreviousBlock: ( | ||
@@ -31,2 +29,4 @@ blockId: string, | ||
selectAllBlocks: () => void; | ||
selectionInfo: SelectionInfo; | ||
lastSelectionPosition: SelectionPosition; | ||
}; | ||
@@ -33,0 +33,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
84104
1363
0
+ Added@blocksuite/store@0.2.2(transitive)
- Removed@blocksuite/store@0.2.1(transitive)
Updated@blocksuite/store@0.2.2