2023-01-05 18:12:39 +08:00
# Importing data
2023-07-03 19:19:32 +08:00
Currently, we have supported three methods for importing data to initialize AppFlowy Editor.
2023-01-05 18:12:39 +08:00
1. From AppFlowy Document JSON
```dart
2023-07-03 19:19:32 +08:00
const document = r'''{
"document": {
"type": "page",
"children": [
{
"type": "heading",
"data": {
"delta": [{ "insert": "Hello AppFlowy!" }],
"level": 1
}
}
]
}
}''';
final json = Map<String, Object>.from(jsonDecode(document));
2023-01-05 18:12:39 +08:00
final editorState = EditorState(
2023-07-03 19:19:32 +08:00
document: Document.fromJson(json),
2023-01-05 18:12:39 +08:00
);
```
2. From Markdown
```dart
const markdown = r'''# Hello AppFlowy!''';
final editorState = EditorState(
2023-07-03 19:19:32 +08:00
document: markdownToDocument(markdown),
2023-01-05 18:12:39 +08:00
);
```
3. From Quill Delta
```dart
2023-07-03 19:19:32 +08:00
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);
2023-01-05 18:12:39 +08:00
```
2023-07-03 19:19:32 +08:00
> 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 ](https://github.com/AppFlowy-IO/appflowy-editor/blob/main/example/lib/home_page.dart#L298 ).