Skip to main content

Module: @lexical/file

Interfaces

Functions

editorStateFromSerializedDocument

editorStateFromSerializedDocument(editor, maybeStringifiedDocument): EditorState

Parse an EditorState from the given editor and document

Parameters

NameTypeDescription
editorLexicalEditorThe lexical editor
maybeStringifiedDocumentstring | SerializedDocumentThe contents of a .lexical file (as a JSON string, or already parsed)

Returns

EditorState

Defined in

packages/lexical-file/src/fileImportExport.ts:54


exportFile

exportFile(editor, config?): void

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

Parameters

NameTypeDescription
editorLexicalEditorThe lexical editor.
configReadonly<{ 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

Defined in

packages/lexical-file/src/fileImportExport.ts:105


importFile

importFile(editor): void

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

Parameters

NameTypeDescription
editorLexicalEditorThe lexical editor.

Returns

void

Defined in

packages/lexical-file/src/fileImportExport.ts:69


serializedDocumentFromEditorState

serializedDocumentFromEditorState(editorState, config?): SerializedDocument

Generates a SerializedDocument from the given EditorState

Parameters

NameTypeDescription
editorStateEditorStatethe EditorState to serialize
configReadonly<{ 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

Defined in

packages/lexical-file/src/fileImportExport.ts:33