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:57

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:109

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:72

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:36

Generates a SerializedDocument from the given EditorState

Parameters​

editorState​

EditorState

the EditorState to serialize

config?​

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

An object that optionally contains source and lastSaved. source defaults to Lexical and lastSaved defaults to the current time in epoch milliseconds.

Returns​

SerializedDocument