Skip to main content

@lexical/file

Interfaces​

SerializedDocument​

Defined in: packages/lexical-file/src/fileImportExport.ts:18

Properties​

editorState​

editorState: SerializedEditorState

Defined in: packages/lexical-file/src/fileImportExport.ts:20

The serialized editorState produced by editorState.toJSON()

lastSaved​

lastSaved: number

Defined in: packages/lexical-file/src/fileImportExport.ts:22

The time this document was created in epoch milliseconds (Date.now())

source​

source: string

Defined in: packages/lexical-file/src/fileImportExport.ts:24

The source of the document, defaults to Lexical

version​

version: string

Defined in: packages/lexical-file/src/fileImportExport.ts:26

The version of Lexical that produced this document

Functions​

editorStateFromSerializedDocument()​

editorStateFromSerializedDocument(editor, maybeStringifiedDocument): EditorState

Defined in: packages/lexical-file/src/fileImportExport.ts:62

Parse an EditorState from the given editor and document

Parameters​

editor​

LexicalEditor

The lexical editor

maybeStringifiedDocument​

string | SerializedDocument

The contents of a .lexical file (as a JSON string, or already parsed)

Returns​

EditorState


exportFile()​

exportFile(editor, config?): void

Defined in: packages/lexical-file/src/fileImportExport.ts:114

Generates a .lexical file to be downloaded by the browser containing the current editor state.

Parameters​

editor​

LexicalEditor

The lexical editor.

config?​

Readonly<{ fileName?: string; source?: string; }> = ...

An object that optionally contains fileName and source. fileName defaults to the current date (as a string) and source defaults to Lexical.

Returns​

void


importFile()​

importFile(editor): void

Defined in: packages/lexical-file/src/fileImportExport.ts:77

Takes a file and inputs its content into the editor state as an input field.

Parameters​

editor​

LexicalEditor

The lexical editor.

Returns​

void


serializedDocumentFromEditorState()​

serializedDocumentFromEditorState(editorState, config?): SerializedDocument

Defined in: packages/lexical-file/src/fileImportExport.ts:38

Generates a SerializedDocument from the given EditorState

Parameters​

editorState​

EditorState

the EditorState to serialize

config?​

Readonly<{ editor?: LexicalEditor; lastSaved?: number; source?: string; }> = ...

An object that optionally contains source, lastSaved and editor. source defaults to Lexical and lastSaved defaults to the current time in epoch milliseconds. editor, the editor that editorState belongs to, is active while its nodes are exported, so their exportJSON can call $getEditor().

Returns​

SerializedDocument