Skip to content

BlockSuite API Documentation / @blocksuite/affine-widget-drag-handle

@blocksuite/affine-widget-drag-handle

Classes

AffineDragHandleWidget

Extends

Constructors

Other

anchorBlockComponent

anchorBlockComponent: ReadonlySignal<BlockComponent<BlockModel<object>, BlockService, string> | null>

anchorBlockId

anchorBlockId: Signal<string | null>

anchorEdgelessElement

anchorEdgelessElement: ReadonlySignal<GfxModel | null>

center

center: IVec

dragging

dragging: boolean = false

draggingAreaRect

draggingAreaRect: ReadonlySignal<Rect | null>

edgelessWatcher

edgelessWatcher: EdgelessWatcher

isDragHandleHovered

isDragHandleHovered: boolean = false

lastDragPoint

lastDragPoint: Point | null = null

noteScale

noteScale: Signal<number>

pointerEventWatcher

pointerEventWatcher: PointerEventWatcher

rectHelper

rectHelper: RectHelper

scale

scale: Signal<number>

scaleInNote

scaleInNote: ReadonlySignal<number>

selectionHelper

selectionHelper: SelectionHelper

activeDragHandle
dragHandleContainer
dragHandleContainerOffsetParent
Get Signature

get dragHandleContainerOffsetParent(): HTMLElement

Returns

HTMLElement

dragHandleGrabber
dragHoverRect
isBlockDragHandleVisible
Get Signature

get isBlockDragHandleVisible(): boolean

Returns

boolean

isGfxDragHandleVisible
Get Signature

get isGfxDragHandleVisible(): boolean

Returns

boolean

mode
Get Signature

get mode(): DocMode | null

Returns

DocMode | null

rootComponent
Get Signature

get rootComponent(): BlockComponent<BlockModel<object>, BlockService, string> | null

Returns

BlockComponent<BlockModel<object>, BlockService, string> | null

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.

ts
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

WidgetComponent.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.

ts
disconnectedCallback() {
  super.disconnectedCallback();
  window.removeEventListener('keydown', this._handleKeydown);
}

An element may be re-connected after being disconnected.

Returns

void

Overrides

WidgetComponent.disconnectedCallback

handleAnchorModelDisposables()

handleAnchorModelDisposables(): void

Returns

void

hide()

hide(force): void

Parameters
force

boolean = false

Reset the dragging state

Returns

void

render()

render(): TemplateResult<1>

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<1>

Overrides

WidgetComponent.render

attributes

controllers

dev-mode

properties

rendering

styles

styles

static styles: CSSResult

Array of styles to apply to the element. The styles should be defined using the css tag function, via constructible stylesheets, or imported from native CSS module scripts.

Note on Content Security Policy:

Element styles are implemented with <style> tags when the browser doesn't support adopted StyleSheets. To use such <style> tags with the style-src CSP directive, the style-src value must either include 'unsafe-inline' or nonce-<base64-value> with <base64-value> replaced be a server-generated nonce.

To provide a nonce to use on generated <style> elements, set window.litNonce to a server-generated nonce in your page's HTML, before loading application code:

html
<script>
  // Generated and unique per request:
  window.litNonce = 'a1b2c3d4';
</script>
Nocollapse
Overrides

WidgetComponent.styles

updates

firstUpdated()

firstUpdated(): void

Invoked when the element is first updated. Implement to perform one time work on the element after update.

ts
firstUpdated() {
  this.renderRoot.getElementById('my-text-area').focus();
}

Setting properties inside this method will trigger the element to update again after this update cycle completes.

Returns

void

Overrides

WidgetComponent.firstUpdated

Type Aliases

DragBlockPayload

DragBlockPayload = DragPayload<DragBlockEntity, DragFromBlockSuite>

Variables

AFFINE_DRAG_HANDLE_WIDGET

const AFFINE_DRAG_HANDLE_WIDGET: "affine-drag-handle-widget" = 'affine-drag-handle-widget'


dragHandleWidget

const dragHandleWidget: ExtensionType

Functions

containBlock()

containBlock(blockIDs, targetID): boolean

Parameters

blockIDs

string[]

targetID

string

Returns

boolean


containChildBlock()

containChildBlock(blocks, childModel): boolean

Parameters

blocks

BlockComponent<BlockModel<object>, BlockService, string>[]

childModel

BlockModel

Returns

boolean


extractIdsFromSnapshot()

extractIdsFromSnapshot(snapshot): string[]

Parameters

snapshot

SliceSnapshot

Returns

string[]


getClosestBlockByPoint()

getClosestBlockByPoint(editorHost, rootComponent, point): BlockComponent<BlockModel<object>, BlockService, string> | null

Parameters

editorHost

EditorHost

rootComponent

BlockComponent

point

Point

Returns

BlockComponent<BlockModel<object>, BlockService, string> | null


getClosestNoteBlock()

getClosestNoteBlock(editorHost, rootComponent, point): BlockComponent<BlockModel<object>, BlockService, string> | null

Parameters

editorHost

EditorHost

rootComponent

BlockComponent

point

Point

Returns

BlockComponent<BlockModel<object>, BlockService, string> | null


getDragHandleContainerHeight()

getDragHandleContainerHeight(model): number

Parameters

model

BlockModel

Returns

number


getDragHandleLeftPadding()

getDragHandleLeftPadding(blocks): 2 | 18

Parameters

blocks

BlockComponent<BlockModel<object>, BlockService, string>[]

Returns

2 | 18


getDropResult()

getDropResult(event, scale): DropTarget | null

Parameters

event

MouseEvent

scale

number = 1

Returns

DropTarget | null


getDuplicateBlocks()

getDuplicateBlocks(blocks): object[]

Parameters

blocks

BlockModel<object>[]

Returns

object[]


getParentNoteBlock()

getParentNoteBlock(blockComponent): Element | null

Parameters

blockComponent

BlockComponent

Returns

Element | null


getSnapshotRect()

getSnapshotRect(snapshot): Bound | null

Parameters

snapshot

SliceSnapshot

Returns

Bound | null


includeTextSelection()

includeTextSelection(selections): boolean

Parameters

selections

BaseSelection[]

Returns

boolean


insideDatabaseTable()

insideDatabaseTable(element): boolean

Parameters

element

Element

Returns

boolean


isBlockIdEqual()

isBlockIdEqual(id1, id2): boolean

Check if the path of two blocks are equal

Parameters

id1

string | null | undefined

id2

string | null | undefined

Returns

boolean


isOutOfNoteBlock()

isOutOfNoteBlock(editorHost, noteBlock, point, scale): boolean

Parameters

editorHost

EditorHost

noteBlock

Element

point

Point

scale

number

Returns

boolean


updateDragHandleClassName()

updateDragHandleClassName(blocks): void

Parameters

blocks

BlockComponent<BlockModel<object>, BlockService, string>[] = []

Returns

void