Skip to content

BlockSuite API Documentation / @blocksuite/affine-widget-linked-doc

@blocksuite/affine-widget-linked-doc ​

Classes ​

AffineLinkedDocWidget ​

Extends ​

Constructors ​

Other ​

config ​
Get Signature ​

get config(): LinkedWidgetConfig

Returns ​

LinkedWidgetConfig

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

render() ​

render(): TemplateResult<1> | typeof nothing

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> | typeof nothing

Overrides ​

WidgetComponent.render

show() ​

show(props?): void

Parameters ​
props? ​
addTriggerKey? ​

boolean

inlineEditor? ​

InlineEditor<{ bold?: true | null; code?: true | null; italic?: true | null; link?: string | null; strike?: true | null; underline?: true | null; }>

mode? ​

"desktop" | "mobile"

primaryTriggerKey? ​

string

Returns ​

void

attributes ​

controllers ​

dev-mode ​

lifecycle ​

properties ​

rendering ​

styles ​

styles ​

static styles: CSSResult = linkedDocWidgetStyles

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 ​


Unzip ​

Constructors ​

Constructor ​

new Unzip(): Unzip

Returns ​

Unzip

Methods ​

[iterator]() ​

[iterator](): Generator<{ content: Blob; index: number; path: string; }, void, unknown>

Returns ​

Generator<{ content: Blob; index: number; path: string; }, void, unknown>

load() ​

load(blob): Promise<void>

Parameters ​
blob ​

Blob

Returns ​

Promise<void>

Type Aliases ​

ImportBatch ​

ImportBatch = object

Properties ​

blobs ​

blobs: ImportBlob[]

docs ​

docs: ImportDoc[]

done ​

done: boolean

entryId? ​

optional entryId?: string

folders? ​

optional folders?: ImportFolder[]

icons? ​

optional icons?: ImportIcon[]

isWorkspaceFile? ​

optional isWorkspaceFile?: boolean

progress? ​

optional progress?: object

completed ​

completed: number

total ​

total: number

tags? ​

optional tags?: ImportTag[]

warnings? ​

optional warnings?: ImportWarning[]


ImportBlob ​

ImportBlob = object

Properties ​

blobId ​

blobId: string

bytes ​

bytes: Uint8Array

fileName ​

fileName: string

mime ​

mime: string

sourcePath ​

sourcePath: string


ImportCommitResult ​

ImportCommitResult = object

Properties ​

docIds ​

docIds: string[]

entryId? ​

optional entryId?: string

isWorkspaceFile? ​

optional isWorkspaceFile?: boolean

rootFolderId? ​

optional rootFolderId?: string

warnings ​

warnings: ImportWarning[]


ImportDoc ​

ImportDoc = object

Properties ​

id ​

id: string

meta? ​

optional meta?: Partial<Pick<DocMeta, "title" | "createDate" | "updatedDate" | "tags" | "favorite" | "trash">>

snapshot ​

snapshot: DocSnapshot

sourcePath? ​

optional sourcePath?: string


ImportFolder ​

ImportFolder = object

Properties ​

icon? ​

optional icon?: ImportIconData

name ​

name: string

pageId? ​

optional pageId?: string

parentPath? ​

optional parentPath?: string

path ​

path: string


ImportIcon ​

ImportIcon = object

Properties ​

docId ​

docId: string

icon ​

icon: ImportIconData


ImportIconData ​

ImportIconData = { type: "emoji"; unicode: string; } | { content: string; type: "image"; }


ImportTag ​

ImportTag = object

Properties ​

docIds ​

docIds: string[]

name ​

name: string


ImportWarning ​

ImportWarning = object

Properties ​

code ​

code: string

message ​

message: string

sourcePath? ​

optional sourcePath?: string


LinkedDocContext ​

LinkedDocContext = object

Properties ​

close ​

close: () => void

Returns ​

void

config ​

config: LinkedWidgetConfig

inlineEditor ​

inlineEditor: AffineInlineEditor

startNativeRange ​

startNativeRange: Range

startRange ​

startRange: InlineRange

std ​

std: BlockStdScope

triggerKey ​

triggerKey: string


LinkedMenuAction ​

LinkedMenuAction = () => Promise<void> | void

Returns ​

Promise<void> | void


LinkedMenuGroup ​

LinkedMenuGroup = object

Properties ​

hidden? ​

optional hidden?: boolean | Signal<boolean>

items ​

items: LinkedMenuItem[] | Signal<LinkedMenuItem[]>

loading? ​

optional loading?: boolean | Signal<boolean>

maxDisplay? ​

optional maxDisplay?: number

name ​

name: string

overflowText? ​

optional overflowText?: string | Signal<string>

styles? ​

optional styles?: string


LinkedMenuItem ​

LinkedMenuItem = object

Properties ​

action ​

action: LinkedMenuAction

icon ​

icon: TemplateResult<1>

key ​

key: string

name ​

name: string | TemplateResult<1>

suffix? ​

optional suffix?: string | TemplateResult<1>


LinkedWidgetConfig ​

LinkedWidgetConfig = Required<Omit<LinkedDocViewExtensionOptions, "autoFocusedItemKey">> & Pick<LinkedDocViewExtensionOptions, "autoFocusedItemKey">

Variables ​

AFFINE_LINKED_DOC_WIDGET ​

const AFFINE_LINKED_DOC_WIDGET: "affine-linked-doc-widget" = 'affine-linked-doc-widget'


BearTransformer ​

const BearTransformer: object

Public API for importing Bear .bear2bk backup archives.

Type Declaration ​

planBearBackup ​

planBearBackup: (__namedParameters) => Promise<PlanBearBackupResult>

Import a Bear .bear2bk backup file. Uses JSZip for lazy/streaming decompression to handle large backups.

Parameters ​
__namedParameters ​

BearImportOptions

Returns ​

Promise<PlanBearBackupResult>


DocxTransformer ​

const DocxTransformer: object

Type Declaration ​

importDocx ​

importDocx: (options) => Promise<string | undefined>

Imports a .docx file into a doc.

Parameters ​
options ​

ImportDocxOptions

The import options.

Returns ​

Promise<string | undefined>

A Promise that resolves to the ID of the newly created doc, or undefined if import fails.


HtmlTransformer ​

const HtmlTransformer: object

Type Declaration ​

exportDoc ​

exportDoc: (doc) => Promise<void>

Exports a doc to HTML format.

Parameters ​
doc ​

Store

The doc to be exported.

Returns ​

Promise<void>

A Promise that resolves when the export is complete.

importHTMLToDoc ​

importHTMLToDoc: (options) => Promise<string | undefined>

Imports HTML content into a new doc within a collection.

Parameters ​
options ​

ImportHTMLToDocOptions

The import options.

Returns ​

Promise<string | undefined>

A Promise that resolves to the ID of the newly created doc, or undefined if import fails.

importHTMLZip ​

importHTMLZip: (options) => Promise<string[]>

Imports a zip file containing HTML files and assets into a collection.

Parameters ​
options ​

ImportHTMLZipOptions

The import options.

Returns ​

Promise<string[]>

A Promise that resolves to an array of IDs of the newly created docs.


linkedDocWidget ​

const linkedDocWidget: ExtensionType


LinkedWidgetConfigExtension ​

const LinkedWidgetConfigExtension: ConfigFactory<Partial<LinkedWidgetConfig>>


LinkedWidgetUtils ​

const LinkedWidgetUtils: object

Type Declaration ​

createNewDocMenuGroup ​

createNewDocMenuGroup: (query, abort, editorHost, inlineEditor) => LinkedMenuGroup

Parameters ​
query ​

string

abort ​

() => void

editorHost ​

EditorHost

inlineEditor ​

AffineInlineEditor

Returns ​

LinkedMenuGroup

insertLinkedNode ​

insertLinkedNode: (__namedParameters) => void

Parameters ​
__namedParameters ​
docId ​

string

inlineEditor ​

AffineInlineEditor

Returns ​

void


MarkdownTransformer ​

const MarkdownTransformer: object

Type Declaration ​

exportDoc ​

exportDoc: (doc) => Promise<void>

Exports a doc to a Markdown file or a zip archive containing Markdown and assets.

Parameters ​
doc ​

Store

The doc to export

Returns ​

Promise<void>

A Promise that resolves when the export is complete

importMarkdownToBlock ​

importMarkdownToBlock: (options) => Promise<void>

Imports Markdown content into a specific block within a doc.

Parameters ​
options ​

ImportMarkdownToBlockOptions

Object containing import options

Returns ​

Promise<void>

A Promise that resolves when the import is complete

importMarkdownToDoc ​

importMarkdownToDoc: (options) => Promise<string | undefined>

Imports Markdown content into a new doc within a collection.

Parameters ​
options ​

ImportMarkdownToDocOptions

Object containing import options

Returns ​

Promise<string | undefined>

A Promise that resolves to the ID of the newly created doc, or undefined if import fails

planMarkdownZip ​

planMarkdownZip: (__namedParameters) => Promise<PlanMarkdownZipResult>

Parameters ​
__namedParameters ​

ImportMarkdownZipOptions

Returns ​

Promise<PlanMarkdownZipResult>

planNotionMarkdownZip ​

planNotionMarkdownZip: (__namedParameters) => Promise<PlanMarkdownZipResult>

Parameters ​
__namedParameters ​

ImportMarkdownZipOptions

Returns ​

Promise<PlanMarkdownZipResult>


NotionHtmlTransformer ​

const NotionHtmlTransformer: object

Type Declaration ​

planNotionHtmlZip ​

planNotionHtmlZip: (__namedParameters) => Promise<PlanNotionHtmlZipResult>

Parameters ​
__namedParameters ​

ImportNotionZipOptions

Returns ​

Promise<PlanNotionHtmlZipResult>


ObsidianTransformer ​

const ObsidianTransformer: object

Type Declaration ​

planObsidianVault ​

planObsidianVault: (__namedParameters) => Promise<PlanObsidianVaultResult>

Parameters ​
__namedParameters ​

ImportObsidianVaultOptions

Returns ​

Promise<PlanObsidianVaultResult>


PdfTransformer ​

const PdfTransformer: object

Type Declaration ​

exportDoc ​

exportDoc: (doc) => Promise<void>

Parameters ​
doc ​

Store

Returns ​

Promise<void>


ZipTransformer ​

const ZipTransformer: object

Type Declaration ​

exportDocs ​

exportDocs: (collection, schema, docs) => Promise<void>

Parameters ​
collection ​

Workspace

schema ​

Schema

docs ​

Store[]

Returns ​

Promise<void>

importDocs ​

importDocs: (collection, schema, imported) => Promise<(Store | undefined)[]>

Parameters ​
collection ​

Workspace

schema ​

Schema

imported ​

Blob

Returns ​

Promise<(Store | undefined)[]>

Functions ​

blobsFromAssets() ​

blobsFromAssets(assets, pathBlobIdMap?): Promise<ImportBlob[]>

Parameters ​

assets ​

ReadonlyMap<string, File>

pathBlobIdMap? ​

ReadonlyMap<string, string> = ...

Returns ​

Promise<ImportBlob[]>


commitImportBatchToWorkspace() ​

commitImportBatchToWorkspace(collection, schema, batch): Promise<ImportCommitResult>

Parameters ​

collection ​

Workspace

schema ​

Schema

batch ​

ImportBatch

Returns ​

Promise<ImportCommitResult>


createAssetsArchive() ​

createAssetsArchive(assetsMap, assetsIds): Promise<Zip>

Parameters ​

assetsMap ​

Map<string, Blob>

assetsIds ​

string[]

Returns ​

Promise<Zip>


createLinkedDocMenuGroup() ​

createLinkedDocMenuGroup(query, abort, editorHost, inlineEditor): object

Parameters ​

query ​

string

abort ​

() => void

editorHost ​

EditorHost

inlineEditor ​

AffineInlineEditor

Returns ​

object

items ​

items: object[]

maxDisplay ​

maxDisplay: number = MAX_DOCS

name ​

name: string = 'Link to Doc'

overflowText ​

overflowText: string


createNewDocMenuGroup() ​

createNewDocMenuGroup(query, abort, editorHost, inlineEditor): LinkedMenuGroup

Parameters ​

query ​

string

abort ​

() => void

editorHost ​

EditorHost

inlineEditor ​

AffineInlineEditor

Returns ​

LinkedMenuGroup


download() ​

download(blob, name): void

Parameters ​

blob ​

Blob

name ​

string

Returns ​

void


getMenus() ​

getMenus(query, abort, editorHost, inlineEditor): Promise<LinkedMenuGroup[]>

Parameters ​

query ​

string

abort ​

() => void

editorHost ​

EditorHost

inlineEditor ​

AffineInlineEditor

Returns ​

Promise<LinkedMenuGroup[]>


showImportModal() ​

showImportModal(__namedParameters): ImportDoc

Parameters ​

__namedParameters ​
abortController? ​

AbortController = ...

collection ​

Workspace

container? ​

HTMLElement = document.body

extensions ​

ExtensionType[]

multiple? ​

boolean

onFail? ​

OnFailHandler

onSuccess? ​

OnSuccessHandler

schema ​

Schema

Returns ​

ImportDoc