Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.03 KB

importing.md

File metadata and controls

36 lines (28 loc) · 1.03 KB

Importing data

For now, we have supported three ways to import data to initialize AppFlowy Editor.

  1. From AppFlowy Document JSON
const document = r'''{"document":{"type":"editor","children":[{"type":"text","attributes":{"subtype":"heading","heading":"h1"},"delta":[{"insert":"Hello AppFlowy!"}]}]}}''';
final json = jsonDecode(document);
final editorState = EditorState(
    document: Document.fromJson(
        Map<String, Object>.from(json),
    ),
);
  1. From Markdown
const markdown = r'''# Hello AppFlowy!''';
final editorState = EditorState(
    document: markdownToDocument(markdown),
);
  1. From Quill Delta
const delta = r'''[{"insert":"Hello AppFlowy!"},{"attributes":{"header":1},"insert":"\n"}]''';
final json = jsonDecode(delta);
final editorState = EditorState(
    document: DeltaDocumentConvert().convertFromJSON(json),
);

For more details, please refer to the function _importFile through this link.