Currently, we have supported three methods for importing data to initialize AppFlowy Editor.
- 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),
);
- From Markdown
const markdown = r'''# Hello AppFlowy!''';
final editorState = EditorState(
document: markdownToDocument(markdown),
);
- 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.