BlockSuite API Documentation / @blocksuite/std / index
index
Enumerations
EventScopeSourceType
Enumeration Members
Selection
Selection:
"selection"
Target
Target:
"target"
Classes
BlockComponent<Model, Service, WidgetName>
Extends
ShadowlessElement<this> &DisposableClass<this>
Extended by
GfxBlockComponentNoteBlockComponentEdgelessRootBlockComponentEdgelessRootPreviewBlockComponentPageRootBlockComponentPreviewRootBlockComponentSurfaceBlockComponentEdgelessSurfaceRefBlockComponentSurfaceRefBlockComponent
Type Parameters
Model
Model extends BlockModel = BlockModel
Service
Service extends BlockService = BlockService
WidgetName
WidgetName extends string = string
Constructors
Other
[blockComponentSymbol]
[blockComponentSymbol]:
boolean=true
selected$
selected$:
ReadonlySignal<boolean>
_renderers
blockId
Get Signature
get blockId():
string
Returns
string
childBlocks
Get Signature
get childBlocks():
BlockComponent<BlockModel<object>,BlockService,string>[]
Returns
BlockComponent<BlockModel<object>, BlockService, string>[]
flavour
Get Signature
get flavour():
string
Returns
string
host
Get Signature
get host():
EditorHost
Returns
isVersionMismatch
Get Signature
get isVersionMismatch():
boolean
Returns
boolean
model
Get Signature
get model():
Model
Returns
Model
parentComponent
Get Signature
get parentComponent():
BlockComponent<BlockModel<object>,BlockService,string> |null
Returns
BlockComponent<BlockModel<object>, BlockService, string> | null
renderChildren
Get Signature
get renderChildren(): (
model,filter?) =>TemplateResult
Returns
(
model,filter?):TemplateResult
Parameters
model
filter?
(model) => boolean
Returns
TemplateResult
rootComponent
Get Signature
get rootComponent():
BlockComponent<BlockModel<object>,BlockService,string> |null
Returns
BlockComponent<BlockModel<object>, BlockService, string> | null
selection
Get Signature
get selection():
StoreSelectionExtension
Returns
service
Get Signature
get service():
Service
Returns
Service
std
store
topContenteditableElement
Get Signature
get topContenteditableElement():
BlockComponent<BlockModel<object>,BlockService,string> |null
Returns
BlockComponent<BlockModel<object>, BlockService, string> | null
viewType
widgetComponents
Get Signature
get widgetComponents():
Partial<Record<WidgetName,WidgetComponent>>
Returns
Partial<Record<WidgetName, WidgetComponent>>
widgets
addRenderer()
addRenderer(
renderer):void
Parameters
renderer
(content) => unknown
Returns
void
bindHotKey()
bindHotKey(
keymap,options?): () =>void
Parameters
keymap
Record<string, UIEventHandler>
options?
flavour?
boolean
global?
boolean
Returns
():
void
Returns
void
connectedCallback()
connectedCallback():
void
Returns
void
Overrides
SignalWatcher(WithDisposable(ShadowlessElement)).connectedCallback
handleEvent()
handleEvent(
name,handler,options?):void
Parameters
name
"copy" | "blur" | "click" | "cut" | "focus" | "paste" | "wheel" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "keyPress" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "nativeDragStart" | "nativeDragMove" | "nativeDragEnd" | "nativeDrop" | "nativeDragOver" | "nativeDragLeave" | "beforeInput" | "contextMenu"
handler
options?
flavour?
boolean
global?
boolean
Returns
void
renderBlock()
renderBlock():
unknown
Returns
unknown
renderVersionMismatch()
renderVersionMismatch(
expectedVersion,actualVersion):TemplateResult
Render a warning message when the block version is mismatched.
Parameters
expectedVersion
number
If the schema is not found, the expected version is -1. Which means the block is not supported in the current editor.
actualVersion
number
The version of the block's crdt data.
Returns
TemplateResult
attributes
controllers
dev-mode
lifecycle
properties
rendering
render()
render():
unknown
Invoked on each update to perform rendering tasks. This method may return any value renderable by lit-html's ChildPart - typically a TemplateResult. Setting properties inside this method will not trigger the element to update.
Returns
unknown
Overrides
SignalWatcher(WithDisposable(ShadowlessElement)).render
styles
updates
getUpdateComplete()
protectedgetUpdateComplete():Promise<boolean>
Override point for the updateComplete promise.
It is not safe to override the updateComplete getter directly due to a limitation in TypeScript which means it is not possible to call a superclass getter (e.g. super.updateComplete.then(...)) when the target language is ES5 (https://github.com/microsoft/TypeScript/issues/338). This method should be overridden instead. For example:
class MyElement extends LitElement {
override async getUpdateComplete() {
const result = await super.getUpdateComplete();
await this._myChild.updateComplete;
return result;
}
}Returns
Promise<boolean>
A promise of a boolean that resolves to true if the update completed without triggering another update.
Overrides
SignalWatcher(WithDisposable(ShadowlessElement)).getUpdateComplete
BlockSelection
Extends
Constructors
Properties
group
staticgroup:string='note'
Overrides
type
statictype:string='block'
Overrides
Accessors
Methods
equals()
equals(
other):boolean
Parameters
other
Returns
boolean
Overrides
toJSON()
toJSON():
Record<string,unknown>
Returns
Record<string, unknown>
Overrides
fromJSON()
staticfromJSON(json):BlockSelection
Parameters
json
Record<string, unknown>
Returns
Overrides
abstract BlockService
abstract BlockServiceDeprecated
BlockService is deprecated. You should reconsider where to put your feature.
BlockService is a legacy extension that is used to provide services to the block. In the previous version of BlockSuite, block service provides a way to extend the block. However, in the new version, we recommend using the new extension system.
Extends
Extended by
Constructors
Constructor
new BlockService(
std,flavourProvider):BlockService
Parameters
std
flavourProvider
flavour
string
Returns
Overrides
Properties
disposables
readonlydisposables:DisposableGroup
flavour
readonlyflavour:string
flavourProvider
readonlyflavourProvider:object
flavour
flavour:
string
std
readonlystd:BlockStdScope
flavour
staticflavour:string
Accessors
collection
Get Signature
get collection():
Workspace
Returns
doc
Get Signature
get doc():
Store
Returns
host
Get Signature
get host():
EditorHost
Returns
selectionManager
Get Signature
get selectionManager():
StoreSelectionExtension
Returns
uiEventDispatcher
Get Signature
get uiEventDispatcher():
UIEventDispatcher
Returns
Methods
bindHotKey()
bindHotKey(
keymap,options?):void
Parameters
keymap
Record<string, UIEventHandler>
options?
global
boolean
Returns
void
dispose()
dispose():
void
Returns
void
handleEvent()
handleEvent(
name,fn,options?):void
Parameters
name
"copy" | "blur" | "click" | "cut" | "focus" | "paste" | "wheel" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "keyPress" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "nativeDragStart" | "nativeDragMove" | "nativeDragEnd" | "nativeDrop" | "nativeDragOver" | "nativeDragLeave" | "beforeInput" | "contextMenu"
fn
options?
global
boolean
Returns
void
mounted()
mounted():
void
Returns
void
unmounted()
unmounted():
void
Returns
void
setup()
staticsetup(di):void
Parameters
di
Container
Returns
void
Overrides
BlockStdScope
Constructors
Constructor
new BlockStdScope(
options):BlockStdScope
Parameters
options
Returns
Properties
container
readonlycontainer:Container
provider
readonlyprovider:ServiceProvider
store
readonlystore:Store
userExtensions
readonlyuserExtensions:ExtensionType[]
internalExtensions
staticinternalExtensions: (typeofServiceManager| typeofRangeManager| typeofViewStore| typeofUIEventDispatcher| typeofCommandManager| typeofLayerManager| typeofGridManager| typeofGfxSelectionManager| typeofSurfaceMiddlewareExtension| typeofViewManager)[]
Accessors
clipboard
Get Signature
get clipboard():
Clipboard
Returns
command
Get Signature
get command():
CommandManager
Returns
dnd
Get Signature
get dnd():
DndController
Returns
event
Get Signature
get event():
UIEventDispatcher
Returns
get
Get Signature
get get(): <
T>(identifier,options?) =>T
Returns
<
T>(identifier,options?):T
Type Parameters
T
T
Parameters
identifier
GeneralServiceIdentifier<T>
options?
ResolveOptions
Returns
T
getOptional
Get Signature
get getOptional(): <
T>(identifier,options?) =>T|null
Returns
<
T>(identifier,options?):T|null
Type Parameters
T
T
Parameters
identifier
GeneralServiceIdentifier<T>
options?
ResolveOptions
Returns
T | null
host
Get Signature
get host():
EditorHost
Returns
range
Get Signature
get range():
RangeManager
Returns
RangeManager
selection
Get Signature
get selection():
StoreSelectionExtension
Returns
view
Get Signature
get view():
ViewStore
Returns
workspace
Get Signature
get workspace():
Workspace
Returns
Methods
getView()
getView(
flavour):BlockViewType|null
Parameters
flavour
string
Returns
BlockViewType | null
mount()
mount():
void
Returns
void
render()
render():
EditorHost
Returns
unmount()
unmount():
void
Returns
void
Clipboard
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends
Extended by
Constructors
Properties
key
statickey:string='clipboard'
Overrides
Accessors
_adapters
Get Signature
get
protected_adapters():ClipboardAdapterConfig[]
Returns
configs
Get Signature
get configs():
Map<string,string>
Returns
Map<string, string>
Methods
copy()
copy(
slice):Promise<void>
Parameters
slice
Returns
Promise<void>
copySlice()
copySlice(
slice):Promise<void>
Parameters
slice
Returns
Promise<void>
duplicateSlice()
duplicateSlice(
slice,doc,parent?,index?,type?):Promise<void>
Parameters
slice
doc
parent?
string
index?
number
type?
string = 'BLOCKSUITE/SNAPSHOT'
Returns
Promise<void>
paste()
paste(
event,doc,parent?,index?):Promise<Slice|null|undefined>
Parameters
event
ClipboardEvent
doc
parent?
string
index?
number
Returns
Promise<Slice | null | undefined>
pasteBlockSnapshot()
pasteBlockSnapshot(
snapshot,doc,parent?,index?):Promise<BlockModel<object> |undefined>
Parameters
snapshot
doc
parent?
string
index?
number
Returns
Promise<BlockModel<object> | undefined>
readFromClipboard()
readFromClipboard(
clipboardData):any
Parameters
clipboardData
DataTransfer
Returns
any
sliceToSnapshot()
sliceToSnapshot(
slice):SliceSnapshot|undefined
Parameters
slice
Returns
SliceSnapshot | undefined
unuse()
unuse(
middleware):void
Parameters
middleware
Returns
void
use()
use(
middleware):void
Parameters
middleware
Returns
void
writeToClipboard()
writeToClipboard(
updateItems):Promise<void>
Parameters
updateItems
<T>(items) => T | Promise<T>
Returns
Promise<void>
ClipboardEventState
Extends
Constructors
Constructor
new ClipboardEventState(
__namedParameters):ClipboardEventState
Parameters
__namedParameters
ClipboardEventStateOptions
Returns
Overrides
Properties
raw
raw:
ClipboardEvent
type
type:
string='clipboardState'
when extends, override it with pattern xxxState
Overrides
CommandManager
Command manager to manage all commands
Commands are functions that take a context and a next function as arguments
const myCommand: Command<input, output> = (ctx, next) => {
const count = ctx.count || 0;
const success = someOperation();
if (success) {
return next({ count: count + 1 });
}
// if the command is not successful, you can return without calling next
return;Command input and output data can be defined in the Command type
// input: ctx.firstName, ctx.lastName
// output: ctx.fullName
const myCommand: Command<{ firstName: string; lastName: string }, { fullName: string }> = (ctx, next) => {
const { firstName, lastName } = ctx;
const fullName = `${firstName} ${lastName}`;
return next({ fullName });
}Commands can be run in two ways:
- Using
execmethodexecis used to run a single command
const [result, data] = commandManager.exec(myCommand, payload);- Using
chainmethodchainis used to run a series of commands
const chain = commandManager.chain();
const [result, data] = chain
.pipe(myCommand1)
.pipe(myCommand2, payload)
.run();Command chains will stop running if a command is not successful
const chain = commandManager.chain();
const [result, data] = chain
.chain(myCommand1) <-- if this fail
.chain(myCommand2, payload) <- this won't run
.run();
result <- result will be `false`You can use try to run a series of commands and if one of them is successful, it will continue to the next command
const chain = commandManager.chain();
const [result, data] = chain
.try(chain => [
chain.pipe(myCommand1), <- if this fail
chain.pipe(myCommand2, payload), <- this will run, if this success
chain.pipe(myCommand3), <- this won't run
])
.run();The tryAll method is similar to try, but it will run all commands even if one of them is successful
const chain = commandManager.chain();
const [result, data] = chain
.try(chain => [
chain.pipe(myCommand1), <- if this success
chain.pipe(myCommand2), <- this will also run
chain.pipe(myCommand3), <- so will this
])
.run();Extends
Constructors
Properties
key
readonlystatickey:"commandManager"='commandManager'
Overrides
Methods
chain()
chain():
Chain<InitCommandCtx>
Create a chain to run a series of commands
const chain = commandManager.chain();
const [result, data] = chain
.myCommand1()
.myCommand2(payload)
.run();Returns
[success, data] - success is a boolean to indicate if the chain is successful, data is the final context after running the chain
exec()
exec<
Output,Input>(command,input?): [false,Partial<InitCommandCtx&Input&Output> &InitCommandCtx] | [true,InitCommandCtx&Input&Output]
Type Parameters
Output
Output extends object
Input
Input extends object
Parameters
command
Command<Input, Output>
input?
Input
Returns
[false, Partial<InitCommandCtx & Input & Output> & InitCommandCtx] | [true, InitCommandCtx & Input & Output]
CursorSelection
Extends
Constructors
Constructor
new CursorSelection(
x,y):CursorSelection
Parameters
x
number
y
number
Returns
Overrides
Properties
x
readonlyx:number
y
readonlyy:number
group
staticgroup:string='gfx'
Overrides
type
statictype:string='cursor'
Overrides
Accessors
Methods
equals()
equals(
other):boolean
Parameters
other
Returns
boolean
Overrides
toJSON()
toJSON():
Record<string,unknown>
Returns
Record<string, unknown>
Overrides
fromJSON()
staticfromJSON(json):CursorSelection
Parameters
json
Record<string, unknown>
Returns
Overrides
DndController
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends
Constructors
Properties
key
statickey:string='DndController'
Overrides
Methods
autoScroll()
autoScroll<
PayloadEntity,PayloadFrom>(options):CleanupFn
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity = DragEntity
PayloadFrom
PayloadFrom extends DragFrom = DragFromBlockSuite
Parameters
options
AutoScroll<PayloadEntity, PayloadFrom>
Returns
CleanupFn
draggable()
draggable<
PayloadEntity,DropData>(args):CleanupFn
Make an element draggable.
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity = DragEntity
DropData
DropData extends object = { }
Parameters
args
DraggableOption<PayloadEntity, DragFromBlockSuite, DropPayload<DropData>>
Returns
CleanupFn
dropTarget()
dropTarget<
PayloadEntity,DropData,PayloadFrom>(args):CleanupFn
Make an element a drop target.
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity = DragEntity
DropData
DropData extends object = { }
PayloadFrom
PayloadFrom extends DragFrom = DragFromBlockSuite
Parameters
args
DropTargetOption<PayloadEntity, PayloadFrom, DropPayload<DropData>>
Returns
CleanupFn
monitor()
monitor<
PayloadEntity,DropData,PayloadFrom>(args):CleanupFn
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity = DragEntity
DropData
DropData extends object = { }
PayloadFrom
PayloadFrom extends DragFrom = DragFromBlockSuite
Parameters
args
MonitorOption<PayloadEntity, PayloadFrom, DropPayload<DropData>>
Returns
CleanupFn
DndEventState
Extends
Constructors
Constructor
new DndEventState(
__namedParameters):DndEventState
Parameters
__namedParameters
DndEventStateOptions
Returns
Overrides
Properties
raw
raw:
DragEvent
type
type:
string='dndState'
when extends, override it with pattern xxxState
Overrides
EditorHost
Extends
ShadowlessElement<this> &DisposableClass<this>
Constructors
Other
styles
staticstyles:CSSResult
Overrides
SignalWatcher( WithDisposable(ShadowlessElement) ).styles
command
Get Signature
get command():
CommandManager
Returns
event
Get Signature
get event():
UIEventDispatcher
Returns
range
Get Signature
get range():
RangeManager
Returns
RangeManager
selection
Get Signature
get selection():
StoreSelectionExtension
Returns
std
store
view
Get Signature
get view():
ViewStore
Returns
connectedCallback()
connectedCallback():
void
Returns
void
Overrides
SignalWatcher( WithDisposable(ShadowlessElement) ).connectedCallback
disconnectedCallback()
disconnectedCallback():
void
Returns
void
Overrides
SignalWatcher( WithDisposable(ShadowlessElement) ).disconnectedCallback
renderChildren()
renderChildren(
model,filter?):TemplateResult
Parameters
model
filter?
(model) => boolean
Returns
TemplateResult
attributes
controllers
dev-mode
properties
rendering
render()
render():
TemplateResult| typeofnothing
Invoked on each update to perform rendering tasks. This method may return any value renderable by lit-html's ChildPart - typically a TemplateResult. Setting properties inside this method will not trigger the element to update.
Returns
TemplateResult | typeof nothing
Overrides
SignalWatcher( WithDisposable(ShadowlessElement) ).render
styles
updates
getUpdateComplete()
getUpdateComplete():
Promise<boolean>
Override point for the updateComplete promise.
It is not safe to override the updateComplete getter directly due to a limitation in TypeScript which means it is not possible to call a superclass getter (e.g. super.updateComplete.then(...)) when the target language is ES5 (https://github.com/microsoft/TypeScript/issues/338). This method should be overridden instead. For example:
class MyElement extends LitElement {
override async getUpdateComplete() {
const result = await super.getUpdateComplete();
await this._myChild.updateComplete;
return result;
}
}Returns
Promise<boolean>
A promise of a boolean that resolves to true if the update completed without triggering another update.
Overrides
SignalWatcher( WithDisposable(ShadowlessElement) ).getUpdateComplete
EditorLifeCycleExtension
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends
Constructors
Constructor
new EditorLifeCycleExtension(
std):EditorLifeCycleExtension
Parameters
std
Returns
Overrides
Properties
disposables
disposables:
DisposableGroup
slots
readonlyslots:object
created
created:
Subject<void>
mounted
mounted:
Subject<void>
rendered
rendered:
Subject<void>
unmounted
unmounted:
Subject<void>
key
statickey:string='editor-life-cycle'
Overrides
Methods
created()
created():
void
Called when std is created.
Returns
void
Overrides
mounted()
mounted():
void
Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.
Returns
void
Overrides
rendered()
rendered():
void
Called when std.render is called.
Returns
void
Overrides
unmounted()
unmounted():
void
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.
Returns
void
Overrides
EventSourceState
Extends
Constructors
Constructor
new EventSourceState(
__namedParameters):EventSourceState
Parameters
__namedParameters
Returns
Overrides
Properties
sourceType
readonlysourceType:EventScopeSourceType
type
type:
string='sourceState'
when extends, override it with pattern xxxState
Overrides
abstract GfxBlockComponent<Model, Service, WidgetName>
Extends
BlockComponent<Model,Service,WidgetName>
Extended by
Type Parameters
Model
Model extends GfxBlockElementModel = GfxBlockElementModel
Service
Service extends BlockService = BlockService
WidgetName
WidgetName extends string = string
Implements
GfxViewTransformInterface
Constructors
Other
[GfxElementSymbol]
[GfxElementSymbol]:
boolean=true
transformState$
readonlytransformState$:Signal<"idle"|"active">
gfx
Get Signature
get gfx():
GfxController
Returns
connectedCallback()
connectedCallback():
void
Returns
void
Overrides
BlockComponent.connectedCallback
getCSSScaleVal()
getCSSScaleVal():
number
Returns
number
getCSSTransform()
getCSSTransform():
string
Returns
string
getRenderingRect()
getRenderingRect():
object
Returns
object
h
h:
any
w
w:
any
x
x:
any
y
y:
any
zIndex
zIndex:
string
onBoxSelected()
onBoxSelected(
_):void
When the element is selected by box selection, return false to prevent the default selection behavior.
Parameters
_
Returns
void
Implementation of
GfxViewTransformInterface.onBoxSelected
onDragEnd()
onDragEnd():
void
Returns
void
Implementation of
GfxViewTransformInterface.onDragEnd
onDragMove()
onDragMove(
__namedParameters):void
Parameters
__namedParameters
Returns
void
Implementation of
GfxViewTransformInterface.onDragMove
onDragStart()
onDragStart():
void
Returns
void
Implementation of
GfxViewTransformInterface.onDragStart
renderBlock()
renderBlock():
unknown
Returns
unknown
Overrides
renderGfxBlock()
renderGfxBlock():
unknown
Returns
unknown
renderPageContent()
renderPageContent():
unknown
Returns
unknown
toZIndex()
toZIndex():
string
Returns
string
updateZIndex()
updateZIndex():
void
Returns
void
attributes
controllers
dev-mode
lifecycle
properties
rendering
styles
updates
scheduleUpdate()
scheduleUpdate():
Promise<unknown>
Schedules an element update. You can override this method to change the timing of updates by returning a Promise. The update will await the returned Promise, and you should resolve the Promise to allow the update to proceed. If this method is overridden, super.scheduleUpdate() must be called.
For instance, to schedule updates to occur just before the next frame:
override protected async scheduleUpdate(): Promise<unknown> {
await new Promise((resolve) => requestAnimationFrame(() => resolve()));
super.scheduleUpdate();
}Returns
Promise<unknown>
Overrides
BlockComponent.scheduleUpdate
KeyboardEventState
Extends
Constructors
Constructor
new KeyboardEventState(
__namedParameters):KeyboardEventState
Parameters
__namedParameters
KeyboardEventStateOptions
Returns
Overrides
Properties
composing
composing:
boolean
raw
raw:
KeyboardEvent
type
type:
string='keyboardState'
when extends, override it with pattern xxxState
Overrides
abstract LifeCycleWatcher
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends
Extended by
ClipboardCommandManagerUIEventDispatcherDndControllerEditorLifeCycleExtensionServiceManagerViewStoreGfxControllerSurfaceMiddlewareExtensionCodeBlockClipboardControllerCodeBlockHighlighterEdgelessLockerReadOnlyClipboardInlineCommentManager
Constructors
Constructor
new LifeCycleWatcher(
std):LifeCycleWatcher
Parameters
std
Returns
Overrides
Properties
std
readonlystd:BlockStdScope
key
statickey:string
Methods
created()
created():
void
Called when std is created.
Returns
void
mounted()
mounted():
void
Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.
Returns
void
rendered()
rendered():
void
Called when std.render is called.
Returns
void
unmounted()
unmounted():
void
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.
Returns
void
setup()
staticsetup(di):void
Parameters
di
Container
Returns
void
Overrides
MultiPointerEventState
Extends
Constructors
Constructor
new MultiPointerEventState(
event,pointers):MultiPointerEventState
Parameters
event
PointerEvent
pointers
Returns
Overrides
Properties
pointers
pointers:
PointerEventState[]
type
type:
string='multiPointerState'
when extends, override it with pattern xxxState
Overrides
PointerEventState
Extends
Constructors
Constructor
new PointerEventState(
__namedParameters):PointerEventState
Parameters
__namedParameters
PointerEventStateOptions
Returns
Overrides
Properties
button
button:
number
containerOffset
containerOffset:
Point
delta
delta:
Point
keys
keys:
object
alt
alt:
boolean
cmd
cmd:
boolean
shift
shift:
boolean
point
point:
Point
pressure
pressure:
number
raw
raw:
PointerEvent
start
start:
Point
type
type:
string='pointerState'
when extends, override it with pattern xxxState
Overrides
Accessors
x
Get Signature
get x():
number
Returns
number
y
Get Signature
get y():
number
Returns
number
ServiceManager
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends
Constructors
Properties
key
readonlystatickey:"serviceManager"='serviceManager'
Overrides
Methods
mounted()
mounted():
void
Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.
Returns
void
Overrides
unmounted()
unmounted():
void
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.
Returns
void
Overrides
ShadowlessElement
Extends
LitElement
Extended by
Constructors
Other
connectedCount
staticconnectedCount:WeakMap<Constructor,WeakMap<Node,number>>
onDisconnectedMap
staticonDisconnectedMap:WeakMap<Constructor,WeakMap<Node, () =>void|null>>
attributes
controllers
dev-mode
lifecycle
connectedCallback()
connectedCallback():
void
Invoked when the component is added to the document's DOM.
In connectedCallback() you should setup tasks that should only occur when the element is connected to the document. The most common of these is adding event listeners to nodes external to the element, like a keydown event handler added to the window.
connectedCallback() {
super.connectedCallback();
addEventListener('keydown', this._handleKeydown);
}Typically, anything done in connectedCallback() should be undone when the element is disconnected, in disconnectedCallback().
Returns
void
Overrides
LitElement.connectedCallback
disconnectedCallback()
disconnectedCallback():
void
Invoked when the component is removed from the document's DOM.
This callback is the main signal to the element that it may no longer be used. disconnectedCallback() should ensure that nothing is holding a reference to the element (such as event listeners added to nodes external to the element), so that it is free to be garbage collected.
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener('keydown', this._handleKeydown);
}An element may be re-connected after being disconnected.
Returns
void
Overrides
LitElement.disconnectedCallback
properties
rendering
createRenderRoot()
createRenderRoot():
ShadowlessElement
Returns
Overrides
LitElement.createRenderRoot
styles
finalizeStyles()
protectedstaticfinalizeStyles(styles?):CSSResultOrNative[]
Takes the styles the user supplied via the static styles property and returns the array of styles to apply to the element. Override this method to integrate into a style management system.
Styles are deduplicated preserving the last instance in the list. This is a performance optimization to avoid duplicated styles that can occur especially when composing via subclassing. The last item is kept to try to preserve the cascade order with the assumption that it's most important that last added styles override previous styles.
Parameters
styles?
CSSResultGroup
Returns
CSSResultOrNative[]
Nocollapse
Overrides
LitElement.finalizeStyles
updates
SurfaceSelection
Extends
Constructors
Constructor
new SurfaceSelection(
blockId,elements,editing,inoperable):SurfaceSelection
Parameters
blockId
string
elements
string[]
editing
boolean
inoperable
boolean = false
Returns
Overrides
Properties
editing
readonlyediting:boolean
elements
readonlyelements:string[]
inoperable
readonlyinoperable:boolean
group
staticgroup:string='gfx'
Overrides
recoverable
staticrecoverable:boolean=true
Overrides
type
statictype:string='surface'
Overrides
Accessors
Methods
equals()
equals(
other):boolean
Parameters
other
Returns
boolean
Overrides
isEmpty()
isEmpty():
boolean
Returns
boolean
toJSON()
toJSON():
Record<string,unknown>
Returns
Record<string, unknown>
Overrides
fromJSON()
staticfromJSON(json):SurfaceSelection
Parameters
json
Record<string, unknown>
Returns
Overrides
TextSelection
Extends
Constructors
Constructor
new TextSelection(
__namedParameters):TextSelection
Parameters
__namedParameters
Returns
Overrides
Properties
from
from:
TextRangePoint
reverse
reverse:
boolean
to
to:
TextRangePoint|null
group
staticgroup:string='note'
Overrides
recoverable
staticrecoverable:boolean=true
Overrides
type
statictype:string='text'
Overrides
Accessors
end
Get Signature
get end():
TextRangePoint
Returns
start
Get Signature
get start():
TextRangePoint
Returns
Methods
empty()
empty():
boolean
Returns
boolean
equals()
equals(
other):boolean
Parameters
other
Returns
boolean
Overrides
isCollapsed()
isCollapsed():
boolean
Returns
boolean
isInSameBlock()
isInSameBlock():
boolean
Returns
boolean
toJSON()
toJSON():
Record<string,unknown>
Returns
Record<string, unknown>
Overrides
fromJSON()
staticfromJSON(json):TextSelection
Parameters
json
Record<string, unknown>
Returns
Overrides
UIEventDispatcher
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends
Constructors
Constructor
new UIEventDispatcher(
std):UIEventDispatcher
Parameters
std
Returns
Overrides
Properties
disposables
disposables:
DisposableGroup
key
readonlystatickey:"UIEventDispatcher"='UIEventDispatcher'
Overrides
Accessors
active
Get Signature
get active():
boolean
Returns
boolean
Set Signature
set active(
active):void
Parameters
active
boolean
Returns
void
active$
Get Signature
get active$():
Signal<boolean>
Returns
Signal<boolean>
host
Get Signature
get host():
EditorHost
Returns
Methods
add()
add(
name,handler,options?): () =>void
Parameters
name
"copy" | "blur" | "click" | "cut" | "focus" | "paste" | "wheel" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "keyPress" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "nativeDragStart" | "nativeDragMove" | "nativeDragEnd" | "nativeDrop" | "nativeDragOver" | "nativeDragLeave" | "beforeInput" | "contextMenu"
handler
options?
Returns
():
void
Returns
void
bindHotkey()
bindHotkey(...
args): () =>void
Parameters
args
...[Record<string, UIEventHandler>, EventOptions]
Returns
():
void
Returns
void
buildEventScope()
buildEventScope(
name,blocks):EventHandlerRunner[] |undefined
Parameters
name
"copy" | "blur" | "click" | "cut" | "focus" | "paste" | "wheel" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "keyPress" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "nativeDragStart" | "nativeDragMove" | "nativeDragEnd" | "nativeDrop" | "nativeDragOver" | "nativeDragLeave" | "beforeInput" | "contextMenu"
blocks
string[]
Returns
EventHandlerRunner[] | undefined
mounted()
mounted():
void
Called when editor host is mounted. Which means the editor host emit the connectedCallback lifecycle event.
Returns
void
Overrides
run()
run(
name,context,runners?):void
Parameters
name
"copy" | "blur" | "click" | "cut" | "focus" | "paste" | "wheel" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "keyPress" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "nativeDragStart" | "nativeDragMove" | "nativeDragEnd" | "nativeDrop" | "nativeDragOver" | "nativeDragLeave" | "beforeInput" | "contextMenu"
context
runners?
Returns
void
unmounted()
unmounted():
void
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.
Returns
void
Overrides
UIEventState
Extended by
ClipboardEventStateDndEventStateKeyboardEventStatePointerEventStateMultiPointerEventStateEventSourceState
Constructors
Constructor
new UIEventState(
event):UIEventState
Parameters
event
Event
Returns
Properties
event
event:
Event
type
type:
string='defaultState'
when extends, override it with pattern xxxState
UIEventStateContext
Constructors
Constructor
new UIEventStateContext():
UIEventStateContext
Returns
Methods
add()
add<
State>(state):void
Type Parameters
State
State extends UIEventState = UIEventState
Parameters
state
State
Returns
void
get()
get<
Type>(type):MatchEvent<Type>
Type Parameters
Type
Type extends keyof BlockSuiteUIEventState = keyof BlockSuiteUIEventState
Parameters
type
Type
Returns
MatchEvent<Type>
has()
has(
type):boolean
Parameters
type
keyof BlockSuiteUIEventState
Returns
boolean
from()
staticfrom(...states):UIEventStateContext
Parameters
states
...UIEventState[]
Returns
ViewStore
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';In the life cycle watcher, the methods will be called in the following order:
created: Called when the std is created.rendered: Called whenstd.renderis called.mounted: Called when the editor host is mounted.unmounted: Called when the editor host is unmounted.
Extends
Constructors
Properties
viewUpdated
viewUpdated:
Subject<ViewUpdatePayload>
key
readonlystatickey:"viewStore"='viewStore'
Overrides
Accessors
views
Get Signature
get views():
BlockComponent<BlockModel<object>,BlockService,string>[]
Returns
BlockComponent<BlockModel<object>, BlockService, string>[]
Methods
deleteBlock()
deleteBlock(
node):void
Parameters
node
Returns
void
deleteWidget()
deleteWidget(
node):void
Parameters
node
Returns
void
getBlock()
getBlock(
id):BlockComponent<BlockModel<object>,BlockService,string> |null
Parameters
id
string
Returns
BlockComponent<BlockModel<object>, BlockService, string> | null
getWidget()
getWidget(
widgetName,hostBlockId):WidgetComponent<BlockModel<object>,BlockComponent<BlockModel<object>,BlockService,string>,BlockService> |null
Parameters
widgetName
string
hostBlockId
string
Returns
WidgetComponent<BlockModel<object>, BlockComponent<BlockModel<object>, BlockService, string>, BlockService> | null
setBlock()
setBlock(
node):void
Parameters
node
Returns
void
setWidget()
setWidget(
node):void
Parameters
node
Returns
void
unmounted()
unmounted():
void
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback lifecycle event.
Returns
void
Overrides
walkThrough()
walkThrough(
fn,blockId?):void
Parameters
fn
(nodeView, index, parent) => true | null | undefined
blockId?
string | null
Returns
void
WidgetComponent<Model, B, S>
Extends
LitElement<this> &DisposableClass<this>
Extended by
AffineCodeToolbarWidgetAffineDragHandleWidgetEdgelessAutoConnectWidgetEdgelessDraggingAreaRectWidgetEdgelessSelectedRectWidgetEdgelessToolbarWidgetAffineEdgelessZoomToolbarWidgetAffineFrameTitleWidgetAffineKeyboardToolbarWidgetAffineLinkedDocWidgetNoteSlicerAffinePageDraggingAreaWidgetAffineDocRemoteSelectionWidgetEdgelessRemoteSelectionWidgetAffineScrollAnchoringWidgetAffineToolbarWidgetAffineViewportOverlayWidget
Type Parameters
Model
Model extends BlockModel = BlockModel
B
B extends BlockComponent = BlockComponent
S
S extends BlockService = BlockService
Constructors
Other
block
Get Signature
get block():
B|null
Returns
B | null
flavour
Get Signature
get flavour():
string
Returns
string
host
Get Signature
get host():
EditorHost
Returns
model
Get Signature
get model():
Model
Returns
Model
service
Get Signature
get service():
S
Returns
S
std
Get Signature
get std():
BlockStdScope
Returns
store
Get Signature
get store():
Store
Returns
widgetId
Get Signature
get widgetId():
string
Returns
string
bindHotKey()
bindHotKey(
keymap,options?):void
Parameters
keymap
Record<string, UIEventHandler>
options?
global
boolean
Returns
void
handleEvent()
handleEvent(
name,handler,options?):void
Parameters
name
"copy" | "blur" | "click" | "cut" | "focus" | "paste" | "wheel" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "keyPress" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "nativeDragStart" | "nativeDragMove" | "nativeDragEnd" | "nativeDrop" | "nativeDragOver" | "nativeDragLeave" | "beforeInput" | "contextMenu"
handler
options?
global?
boolean
Returns
void
attributes
controllers
dev-mode
lifecycle
connectedCallback()
connectedCallback():
void
Invoked when the component is added to the document's DOM.
In connectedCallback() you should setup tasks that should only occur when the element is connected to the document. The most common of these is adding event listeners to nodes external to the element, like a keydown event handler added to the window.
connectedCallback() {
super.connectedCallback();
addEventListener('keydown', this._handleKeydown);
}Typically, anything done in connectedCallback() should be undone when the element is disconnected, in disconnectedCallback().
Returns
void
Overrides
SignalWatcher(WithDisposable(LitElement)).connectedCallback
disconnectedCallback()
disconnectedCallback():
void
Invoked when the component is removed from the document's DOM.
This callback is the main signal to the element that it may no longer be used. disconnectedCallback() should ensure that nothing is holding a reference to the element (such as event listeners added to nodes external to the element), so that it is free to be garbage collected.
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener('keydown', this._handleKeydown);
}An element may be re-connected after being disconnected.
Returns
void
Overrides
SignalWatcher(WithDisposable(LitElement)).disconnectedCallback
properties
rendering
render()
render():
unknown
Invoked on each update to perform rendering tasks. This method may return any value renderable by lit-html's ChildPart - typically a TemplateResult. Setting properties inside this method will not trigger the element to update.
Returns
unknown
Overrides
SignalWatcher(WithDisposable(LitElement)).render
styles
updates
Interfaces
BlockStdOptions
Properties
extensions
extensions:
ExtensionType[]
store
store:
Store
ClipboardAdapterConfig
Properties
adapter
adapter:
AdapterConstructor
mimeType
mimeType:
string
priority
priority:
number
ConfigFactory()<Config>
Type Parameters
Config
Config extends Record<string, any>
ConfigFactory(
config):ExtensionType
Parameters
config
Config
Returns
Properties
identifier
identifier:
ServiceIdentifier<Config>
DNDEntity
Properties
basic
basic:
DragEntity
InitCommandCtx
Properties
std
std:
BlockStdScope
Type Aliases
AutoScroll<PayloadEntity, PayloadFrom>
AutoScroll<
PayloadEntity,PayloadFrom> =object
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity
PayloadFrom
PayloadFrom extends DragFrom
Properties
canScroll()?
optionalcanScroll: (args) =>void
Parameters
args
ElementDragEventBaseArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
void
element
element:
HTMLElement
getAllowedAxis()?
optionalgetAllowedAxis: (args) =>ReturnType<Required<OriginalAutoScrollOption>["getAllowedAxis"]>
Parameters
args
ElementDragEventBaseArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
ReturnType<Required<OriginalAutoScrollOption>["getAllowedAxis"]>
getConfiguration()?
optionalgetConfiguration: (args) =>ReturnType<Required<OriginalAutoScrollOption>["getConfiguration"]>
Parameters
args
ElementDragEventBaseArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
ReturnType<Required<OriginalAutoScrollOption>["getConfiguration"]>
BlockViewType
BlockViewType =
StaticValue| (model) =>StaticValue
Chain<CommandCtx>
Chain<
CommandCtx> =object
Type Parameters
CommandCtx
CommandCtx extends object = InitCommandCtx
Properties
[cmdSymbol]
[cmdSymbol]:
Command[]
pipe()
pipe: {<
Out>(command):Chain<CommandCtx&Out>; <Out,In>(command,input?):Chain<CommandCtx&In&Out>; }
Call Signature
<
Out>(command):Chain<CommandCtx&Out>
Type Parameters
Out
Out extends object
Parameters
command
Command<CommandCtx, Out>
Returns
Chain<CommandCtx & Out>
Call Signature
<
Out,In>(command,input?):Chain<CommandCtx&In&Out>
Type Parameters
Out
Out extends object
In
In extends object
Parameters
command
Command<In, Out>
input?
In
Returns
Chain<CommandCtx & In & Out>
run()
run: () => [
false,Partial<CommandCtx> &InitCommandCtx] | [true,CommandCtx]
Returns
[false, Partial<CommandCtx> & InitCommandCtx] | [true, CommandCtx]
try()
try: <
Out>(commands) =>Chain<CommandCtx&Out>
Type Parameters
Out
Out extends object
Parameters
commands
(chain) => Chain<CommandCtx & Out>[]
Returns
Chain<CommandCtx & Out>
tryAll()
tryAll: <
Out>(commands) =>Chain<CommandCtx&Out>
Type Parameters
Out
Out extends object
Parameters
commands
(chain) => Chain<CommandCtx & Out>[]
Returns
Chain<CommandCtx & Out>
with()
with: <
Out>(input) =>Chain<CommandCtx&Out>
Type Parameters
Out
Out extends object
Parameters
input
Out
Returns
Chain<CommandCtx & Out>
Cmds
Cmds =
object
Properties
[cmdSymbol]
[cmdSymbol]:
Command[]
Command()<Input, Output>
Command<
Input,Output> = (input,next) =>void
Type Parameters
Input
Input = InitCommandCtx
Output
Output = { }
Parameters
input
Input & InitCommandCtx
next
(output?) => void
Returns
void
DragEntity
DragEntity =
object
Properties
type
type:
string
DragFrom
DragFrom =
object
Properties
at
at:
string
DragFromBlockSuite
DragFromBlockSuite =
object
Properties
at
at:
"blocksuite-editor"
docId
docId:
string
DraggableOption<PayloadEntity, PayloadFrom, DropPayload>
DraggableOption<
PayloadEntity,PayloadFrom,DropPayload> =Pick<OriginalDraggableOption,"element"|"dragHandle"|"canDrag"> &object&ElementDragEventMap<DragPayload<PayloadEntity,PayloadFrom>,DropPayload>
Type Declaration
setDragData()?
optionalsetDragData: (args) =>PayloadEntity
Set drag data for the draggable element.
Parameters
args
ElementGetFeedbackArgs
Returns
PayloadEntity
See
ElementGetFeedbackArgs for callback arguments
setDragPreview?
optionalsetDragPreview:false| (options) =>void| () =>void
Set custom drag preview for the draggable element.
setDragPreview is a function that will be called with a container element and other drag data as parameter when the drag preview is generating. Append the custom element to the container which will be used to generate the preview. Once the drag preview is generated, the container element and its children will be removed automatically.
If you want to completely disable the drag preview, just set setDragPreview to false.
Example
dnd.draggable({
// ...
setDragPreview: ({ container }) => {
const preview = document.createElement('div');
preview.style.width = '100px';
preview.style.height = '100px';
preview.style.backgroundColor = 'red';
preview.innerText = 'Custom Drag Preview';
container.appendChild(preview);
return () => {
// do some cleanup
}
}
})Param
callback to set custom drag preview
Returns
setExternalDragData()?
optionalsetExternalDragData: (args) =>ReturnType<Required<OriginalDraggableOption>["getInitialDataForExternal"]>
Set external drag data for the draggable element.
Parameters
args
ElementGetFeedbackArgs
Returns
ReturnType<Required<OriginalDraggableOption>["getInitialDataForExternal"]>
See
ElementGetFeedbackArgs for callback arguments
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity
PayloadFrom
PayloadFrom extends DragFrom
DropPayload
DropPayload extends object
DragPayload<E, F>
DragPayload<
E,F> =object
Type Parameters
E
E extends DragEntity = DragEntity
F
F extends DragFrom = DragFromBlockSuite
Properties
bsEntity?
optionalbsEntity:E
from?
optionalfrom:F
DropEdge
DropEdge =
Edge
DropPayload<T>
DropPayload<
T> =object&T
Type Declaration
edge?
optionaledge:Edge
Type Parameters
T
T extends object = { }
DropTargetOption<PayloadEntity, PayloadFrom, DropPayload>
DropTargetOption<
PayloadEntity,PayloadFrom,DropPayload> =object&ElementDropEventMap<DragPayload<PayloadEntity,PayloadFrom>,DropPayload>
Type Declaration
allowDropPosition?
optionalallowDropPosition:Edge[]
Allow drop position for the drop target.
canDrop()?
optionalcanDrop: (args) =>boolean
OriginalDropTargetOption.canDrop
Parameters
args
ElementDropTargetFeedbackArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
boolean
element
element:
HTMLElement
OriginalDropTargetOption.element
getDropEffect()?
optionalgetDropEffect: (args) =>DropTargetRecord["dropEffect"]
OriginalDropTargetOption.getDropEffect
Parameters
args
ElementDropTargetFeedbackArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
DropTargetRecord["dropEffect"]
getIsSticky()?
optionalgetIsSticky: (args) =>boolean
OriginalDropTargetOption.getIsSticky
Parameters
args
ElementDropTargetFeedbackArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
boolean
setDropData()?
optionalsetDropData: (args) =>DropPayload
OriginalDropTargetOption.getData
Parameters
args
ElementDropTargetFeedbackArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
DropPayload
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity
PayloadFrom
PayloadFrom extends DragFrom
DropPayload
DropPayload extends object
EventHandlerRunner
EventHandlerRunner =
object
Properties
blockId?
optionalblockId:string
flavour?
optionalflavour:string
fn
fn:
UIEventHandler
EventName
EventName = typeof
eventNames[number]
EventOptions
EventOptions =
object
Properties
blockId?
optionalblockId:string
flavour?
optionalflavour:string
EventSourceStateOptions
EventSourceStateOptions =
object
Properties
event
event:
Event
sourceType
sourceType:
EventScopeSourceType
MonitorOption<PayloadEntity, PayloadFrom, DropPayload>
MonitorOption<
PayloadEntity,PayloadFrom,DropPayload> =object&ElementDragEventMap<DragPayload<PayloadEntity,PayloadFrom>,DropPayload>
Type Declaration
canMonitor()?
optionalcanMonitor: (args) =>boolean
OriginalMonitorOption.canMonitor
Parameters
args
ElementMonitorFeedbackArgs<DragPayload<PayloadEntity, PayloadFrom>>
Returns
boolean
Type Parameters
PayloadEntity
PayloadEntity extends DragEntity
PayloadFrom
PayloadFrom extends DragFrom
DropPayload
DropPayload extends object
TextRangePoint
TextRangePoint =
object
Properties
blockId
blockId:
string
index
index:
number
length
length:
number
TextSelectionProps
TextSelectionProps =
object
Properties
from
from:
TextRangePoint
reverse?
optionalreverse:boolean
to
to:
TextRangePoint|null
UIEventHandler()
UIEventHandler = (
context) =>boolean|null|undefined|void
Parameters
context
Returns
boolean | null | undefined | void
ViewUpdatePayload
ViewUpdatePayload = {
id:string;method:ViewUpdateMethod;type:"block";view:BlockComponent; } | {id:string;method:ViewUpdateMethod;type:"widget";view:WidgetComponent; }
WidgetViewType
WidgetViewType =
StaticValue
Variables
BLOCK_ID_ATTR
constBLOCK_ID_ATTR:"data-block-id"='data-block-id'
blockComponentSymbol
constblockComponentSymbol: typeofblockComponentSymbol
BlockFlavourIdentifier
constBlockFlavourIdentifier:ServiceIdentifier<{flavour:string; }> & <U>(variant) =>ServiceIdentifier<U>
BlockSelectionExtension
constBlockSelectionExtension:ExtensionType
BlockServiceIdentifier
constBlockServiceIdentifier:ServiceIdentifier<BlockService> & <U>(variant) =>ServiceIdentifier<U>
BlockViewIdentifier
constBlockViewIdentifier:ServiceIdentifier<BlockViewType> & <U>(variant) =>ServiceIdentifier<U>
ClipboardAdapterConfigIdentifier
constClipboardAdapterConfigIdentifier:ServiceIdentifier<ClipboardAdapterConfig> & <U>(variant) =>ServiceIdentifier<U>
cmdSymbol
constcmdSymbol: typeofcmdSymbol
CommandIdentifier
constCommandIdentifier:ServiceIdentifier<Command> & <U>(variant) =>ServiceIdentifier<U>
ConfigIdentifier
constConfigIdentifier:ServiceIdentifier<Record<string,unknown>> & <U>(variant) =>ServiceIdentifier<U>
CursorSelectionExtension
constCursorSelectionExtension:ExtensionType
DndExtensionIdentifier
constDndExtensionIdentifier:ServiceIdentifier<DndController>
GfxElementSymbol
constGfxElementSymbol: typeofGfxElementSymbol
internalExtensions
constinternalExtensions: (typeofServiceManager| typeofRangeManager| typeofViewStore| typeofUIEventDispatcher| typeofCommandManager| typeofLayerManager| typeofGridManager| typeofGfxSelectionManager| typeofSurfaceMiddlewareExtension| typeofViewManager)[]
KeymapIdentifier
constKeymapIdentifier:ServiceIdentifier<{getter: (std) =>Record<string,UIEventHandler>;options?:EventOptions; }> & <U>(variant) =>ServiceIdentifier<U>
LifeCycleWatcherIdentifier
constLifeCycleWatcherIdentifier:ServiceIdentifier<LifeCycleWatcher> & <U>(variant) =>ServiceIdentifier<U>
modelContext
constmodelContext:object
Type Declaration
__context__
__context__:
BlockModel
PropTypes
constPropTypes:object
Type Declaration
array()
array: (
value) =>value is any[]
Parameters
value
unknown
Returns
value is any[]
arrayOf()
arrayOf: (
validator) => (value) =>boolean
Parameters
validator
ValidatorFunction
Returns
(
value):boolean
Parameters
value
unknown
Returns
boolean
boolean()
boolean: (
value) =>value is boolean
Parameters
value
unknown
Returns
value is boolean
instanceOf()
instanceOf: (
expectedClass) => (value) =>boolean
Parameters
expectedClass
Constructor
Returns
(
value):boolean
Parameters
value
unknown
Returns
boolean
number()
number: (
value) =>value is number
Parameters
value
unknown
Returns
value is number
object()
object: (
value) => value is object | null
Parameters
value
unknown
Returns
value is object | null
of()
of: (
validator) => (value) =>boolean
Parameters
validator
ValidatorFunction
Returns
(
value):boolean
Parameters
value
unknown
Returns
boolean
recordOf()
recordOf: (
validator) => (value) =>boolean
Parameters
validator
ValidatorFunction
Returns
(
value):boolean
Parameters
value
unknown
Returns
boolean
string()
string: (
value) =>value is string
Parameters
value
unknown
Returns
value is string
serviceContext
constserviceContext:object
Type Declaration
__context__
__context__:
BlockService
stdContext
conststdContext:object
Type Declaration
__context__
__context__:
BlockStdScope
StdIdentifier
constStdIdentifier:ServiceIdentifier<BlockStdScope> & <U>(variant) =>ServiceIdentifier<U>
storeContext
conststoreContext:object
Type Declaration
__context__
__context__:
Store
SurfaceSelectionExtension
constSurfaceSelectionExtension:ExtensionType
TextSelectionExtension
constTextSelectionExtension:ExtensionType
WIDGET_ID_ATTR
constWIDGET_ID_ATTR:"data-widget-id"='data-widget-id'
WidgetViewIdentifier
constWidgetViewIdentifier:ServiceIdentifier<StaticValue> & <U>(variant) =>ServiceIdentifier<U>
Functions
androidBindKeymapPatch()
androidBindKeymapPatch(
bindings):UIEventHandler
Parameters
bindings
Record<string, UIEventHandler>
Returns
bindKeymap()
bindKeymap(
bindings):UIEventHandler
Parameters
bindings
Record<string, UIEventHandler>
Returns
BlockViewExtension()
BlockViewExtension(
flavour,view):ExtensionType
Create a block view extension.
Parameters
flavour
string
The flavour of the block that the view is for.
view
Lit literal template for the view. Example: my-list-block
The view is a lit template that is used to render the block.
Returns
Example
import { BlockViewExtension } from '@blocksuite/std';
const MyListBlockViewExtension = BlockViewExtension(
'affine:list',
literal`my-list-block`
);ClipboardAdapterConfigExtension()
ClipboardAdapterConfigExtension(
config):ExtensionType
Parameters
config
Returns
ConfigExtensionFactory()
ConfigExtensionFactory<
Config>(configId):ConfigFactory<Config>
Create a config extension. A config extension provides a configuration object for a block flavour. The configuration object can be used like:
const config = std.provider.getOptional(ConfigIdentifier('my-flavour'));Type Parameters
Config
Config extends Record<string, any>
Parameters
configId
string
The id of the config. Should be unique for each config.
Returns
ConfigFactory<Config>
Example
import { ConfigExtensionFactory } from '@blocksuite/std';
const MyConfigExtensionFactory = ConfigExtensionFactory<ConfigType>('my-flavour');
const MyConfigExtension = MyConfigExtensionFactory({
option1: 'value1',
option2: 'value2',
});FlavourExtension()
FlavourExtension(
flavour):ExtensionType
Create a flavour extension.
Parameters
flavour
string
The flavour of the block that the extension is for.
Returns
Example
import { FlavourExtension } from '@blocksuite/std';
const MyFlavourExtension = FlavourExtension('my-flavour');isGfxBlockComponent()
isGfxBlockComponent(
element):element is GfxBlockComponent<GfxBlockElementModel<GfxCompatibleProps>, BlockService, string>
Parameters
element
unknown
Returns
element is GfxBlockComponent<GfxBlockElementModel<GfxCompatibleProps>, BlockService, string>
KeymapExtension()
KeymapExtension(
keymapFactory,options?):ExtensionType
Create a keymap extension.
Parameters
keymapFactory
(std) => Record<string, UIEventHandler>
Create keymap of the extension. It should return an object with keymap and options.
keymap is a record of keymap.
options?
options is an optional object that restricts the event to be handled.
Returns
Example
import { KeymapExtension } from '@blocksuite/std';
const MyKeymapExtension = KeymapExtension(std => {
return {
keymap: {
'mod-a': SelectAll
}
options: {
flavour: 'affine:paragraph'
}
}
});requiredProperties()
requiredProperties(
propTypes): (constructor) =>void
Parameters
propTypes
Record<string, ValidatorFunction>
Returns
(
constructor):void
Parameters
constructor
Constructor<LitElement>
Returns
void
toGfxBlockComponent()
toGfxBlockComponent<
Model,Service,WidgetName,B>(CustomBlock):B& (...args) =>GfxBlockComponent
Type Parameters
Model
Model extends GfxBlockElementModel<GfxCompatibleProps>
Service
Service extends BlockService
WidgetName
WidgetName extends string
B
B extends typeof BlockComponent
Parameters
CustomBlock
B
Returns
B & (...args) => GfxBlockComponent
WidgetViewExtension()
WidgetViewExtension(
flavour,id,view):ExtensionType
Create a widget view extension.
Parameters
flavour
string
The flavour of the block that the widget view is for.
id
string
The id of the widget view.
view
StaticValue
The widget view lit literal.
A widget view is to provide a widget view for a block. For every target block, it's view will be rendered with the widget view.
Returns
Example
import { WidgetViewExtension } from '@blocksuite/std';
const MyWidgetViewExtension = WidgetViewExtension('my-flavour', 'my-widget', literal`my-widget-view`);