Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 1.2 KB

importing.md

File metadata and controls

48 lines (39 loc) · 1.2 KB

Importing data

Currently, we have supported three methods for importing data to initialize AppFlowy Editor.

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

Notes: Some styles, such as font-size, font-family and text-align, are not supported yet.

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