feat: migrate the delta encoder (#277)
This commit is contained in:
parent
cba0647f7f
commit
070ceb3e27
6 changed files with 371 additions and 396 deletions
|
|
@ -1,16 +1,27 @@
|
|||
# Importing data
|
||||
|
||||
For now, we have supported three ways to import data to initialize AppFlowy Editor.
|
||||
Currently, we have supported three methods for importing data to initialize AppFlowy Editor.
|
||||
|
||||
1. From AppFlowy Document JSON
|
||||
|
||||
```dart
|
||||
const document = r'''{"document":{"type":"editor","children":[{"type":"text","attributes":{"subtype":"heading","heading":"h1"},"delta":[{"insert":"Hello AppFlowy!"}]}]}}''';
|
||||
final json = jsonDecode(document);
|
||||
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(
|
||||
Map<String, Object>.from(json),
|
||||
),
|
||||
document: Document.fromJson(json),
|
||||
);
|
||||
```
|
||||
|
||||
|
|
@ -19,18 +30,19 @@ final editorState = EditorState(
|
|||
```dart
|
||||
const markdown = r'''# Hello AppFlowy!''';
|
||||
final editorState = EditorState(
|
||||
document: markdownToDocument(markdown),
|
||||
document: markdownToDocument(markdown),
|
||||
);
|
||||
```
|
||||
|
||||
3. From Quill Delta
|
||||
|
||||
```dart
|
||||
const delta = r'''[{"insert":"Hello AppFlowy!"},{"attributes":{"header":1},"insert":"\n"}]''';
|
||||
final json = jsonDecode(delta);
|
||||
final editorState = EditorState(
|
||||
document: DeltaDocumentConvert().convertFromJSON(json),
|
||||
);
|
||||
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);
|
||||
```
|
||||
|
||||
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).
|
||||
> 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).
|
||||
|
|
@ -11,7 +11,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
enum ExportFileType {
|
||||
json,
|
||||
documentJson,
|
||||
markdown,
|
||||
html,
|
||||
delta,
|
||||
|
|
@ -20,7 +20,7 @@ enum ExportFileType {
|
|||
extension on ExportFileType {
|
||||
String get extension {
|
||||
switch (this) {
|
||||
case ExportFileType.json:
|
||||
case ExportFileType.documentJson:
|
||||
case ExportFileType.delta:
|
||||
return 'json';
|
||||
case ExportFileType.markdown:
|
||||
|
|
@ -123,45 +123,19 @@ class _HomePageState extends State<HomePage> {
|
|||
_loadEditor(context, jsonString);
|
||||
}),
|
||||
|
||||
// Text Robot
|
||||
// _buildSeparator(context, 'Text Robot'),
|
||||
// _buildListTile(context, 'Type Text Automatically', () async {
|
||||
// final jsonString = Future<String>.value(
|
||||
// jsonEncode(
|
||||
// EditorState.blank(withInitialText: true).document.toJson(),
|
||||
// ).toString(),
|
||||
// );
|
||||
// await _loadEditor(context, jsonString);
|
||||
|
||||
// Future.delayed(const Duration(seconds: 2), () {
|
||||
// final textRobot = TextRobot(
|
||||
// editorState: _editorState,
|
||||
// );
|
||||
// textRobot.insertText(
|
||||
// '''
|
||||
// Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC
|
||||
// "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
|
||||
|
||||
// 1914 translation by H. Rackham
|
||||
// "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
|
||||
// ''',
|
||||
// );
|
||||
// });
|
||||
// }),
|
||||
|
||||
// Encoder Demo
|
||||
_buildSeparator(context, 'Encoder Demo'),
|
||||
_buildSeparator(context, 'Export To X Demo'),
|
||||
_buildListTile(context, 'Export To JSON', () {
|
||||
_exportFile(_editorState, ExportFileType.json);
|
||||
_exportFile(_editorState, ExportFileType.documentJson);
|
||||
}),
|
||||
_buildListTile(context, 'Export to Markdown', () {
|
||||
_exportFile(_editorState, ExportFileType.markdown);
|
||||
}),
|
||||
|
||||
// Decoder Demo
|
||||
_buildSeparator(context, 'Decoder Demo'),
|
||||
_buildListTile(context, 'Import From JSON', () {
|
||||
_importFile(ExportFileType.json);
|
||||
_buildSeparator(context, 'Import From X Demo'),
|
||||
_buildListTile(context, 'Import From Document JSON', () {
|
||||
_importFile(ExportFileType.documentJson);
|
||||
}),
|
||||
_buildListTile(context, 'Import From Markdown', () {
|
||||
_importFile(ExportFileType.markdown);
|
||||
|
|
@ -260,7 +234,7 @@ class _HomePageState extends State<HomePage> {
|
|||
var result = '';
|
||||
|
||||
switch (fileType) {
|
||||
case ExportFileType.json:
|
||||
case ExportFileType.documentJson:
|
||||
result = jsonEncode(editorState.document.toJson());
|
||||
break;
|
||||
case ExportFileType.markdown:
|
||||
|
|
@ -318,14 +292,16 @@ class _HomePageState extends State<HomePage> {
|
|||
|
||||
var jsonString = '';
|
||||
switch (fileType) {
|
||||
case ExportFileType.json:
|
||||
case ExportFileType.documentJson:
|
||||
jsonString = plainText;
|
||||
break;
|
||||
case ExportFileType.markdown:
|
||||
jsonString = jsonEncode(markdownToDocument(plainText).toJson());
|
||||
break;
|
||||
case ExportFileType.delta:
|
||||
jsonString = 'unsupported';
|
||||
final delta = Delta.fromJson(jsonDecode(plainText));
|
||||
final document = quillDeltaEncoder.convert(delta);
|
||||
jsonString = jsonEncode(document.toJson());
|
||||
break;
|
||||
case ExportFileType.html:
|
||||
throw UnimplementedError();
|
||||
|
|
|
|||
|
|
@ -1,71 +1,68 @@
|
|||
/// AppFlowyEditor library
|
||||
library appflowy_editor;
|
||||
|
||||
export 'src/infra/log.dart';
|
||||
export 'src/render/style/editor_style.dart';
|
||||
export 'src/core/document/attributes.dart';
|
||||
export 'src/core/document/deprecated/document.dart';
|
||||
export 'src/core/document/deprecated/node.dart';
|
||||
export 'src/core/document/document.dart';
|
||||
export 'src/core/document/node.dart';
|
||||
export 'src/core/document/node_iterator.dart';
|
||||
export 'src/core/document/path.dart';
|
||||
export 'src/core/document/text_delta.dart';
|
||||
export 'src/core/legacy/built_in_attribute_keys.dart';
|
||||
export 'src/core/location/position.dart';
|
||||
export 'src/core/location/selection.dart';
|
||||
export 'src/core/document/document.dart';
|
||||
export 'src/core/document/text_delta.dart';
|
||||
export 'src/core/document/attributes.dart';
|
||||
export 'src/core/legacy/built_in_attribute_keys.dart';
|
||||
export 'src/editor_state.dart';
|
||||
export 'src/core/transform/operation.dart';
|
||||
export 'src/core/transform/transaction.dart';
|
||||
export 'src/editor/block_component/block_component.dart';
|
||||
export 'src/editor/command/transform.dart';
|
||||
export 'src/editor/editor_component/editor_component.dart';
|
||||
export 'src/editor/toolbar/toolbar.dart';
|
||||
export 'src/editor/util/util.dart';
|
||||
export 'src/editor_state.dart';
|
||||
export 'src/extensions/extensions.dart';
|
||||
export 'src/extensions/node_extensions.dart';
|
||||
export 'src/infra/flowy_svg.dart';
|
||||
export 'src/infra/html_converter.dart';
|
||||
export 'src/infra/log.dart';
|
||||
export 'src/infra/mobile/mobile.dart';
|
||||
export 'src/l10n/l10n.dart';
|
||||
export 'src/plugins/html/html_document.dart';
|
||||
export 'src/plugins/html/html_document_decoder.dart';
|
||||
export 'src/plugins/html/html_document_encoder.dart';
|
||||
export 'src/plugins/markdown/decoder/delta_markdown_decoder.dart';
|
||||
export 'src/plugins/markdown/document_markdown.dart';
|
||||
export 'src/plugins/markdown/encoder/delta_markdown_encoder.dart';
|
||||
export 'src/plugins/markdown/encoder/document_markdown_encoder.dart';
|
||||
export 'src/plugins/markdown/encoder/parser/image_node_parser.dart';
|
||||
export 'src/plugins/markdown/encoder/parser/node_parser.dart';
|
||||
export 'src/plugins/markdown/encoder/parser/text_node_parser.dart';
|
||||
export 'src/plugins/quill_delta/quill_delta_encoder.dart';
|
||||
export 'src/render/action_menu/action_menu.dart';
|
||||
export 'src/render/action_menu/action_menu_item.dart';
|
||||
export 'src/render/rich_text/default_selectable.dart';
|
||||
export 'src/render/rich_text/flowy_rich_text.dart';
|
||||
export 'src/render/rich_text/flowy_rich_text_keys.dart';
|
||||
export 'src/render/selection/selectable.dart';
|
||||
export 'src/render/selection_menu/selection_menu_icon.dart';
|
||||
export 'src/render/selection_menu/selection_menu_item_widget.dart';
|
||||
export 'src/render/selection_menu/selection_menu_service.dart';
|
||||
export 'src/render/selection_menu/selection_menu_widget.dart';
|
||||
export 'src/render/style/editor_style.dart';
|
||||
export 'src/render/style/plugin_styles.dart';
|
||||
export 'src/render/toolbar/toolbar_item.dart';
|
||||
export 'src/service/default_text_operations/format_rich_text_style.dart';
|
||||
export 'src/service/editor_service.dart';
|
||||
export 'src/service/render_plugin_service.dart';
|
||||
export 'src/service/service.dart';
|
||||
export 'src/service/selection_service.dart';
|
||||
export 'src/service/scroll_service.dart';
|
||||
export 'src/service/toolbar_service.dart';
|
||||
export 'src/service/keyboard_service.dart';
|
||||
export 'src/service/input_service.dart';
|
||||
export 'src/service/internal_key_event_handlers/copy_paste_handler.dart';
|
||||
export 'src/service/keyboard_service.dart';
|
||||
export 'src/service/render_plugin_service.dart';
|
||||
export 'src/service/scroll_service.dart';
|
||||
export 'src/service/selection_service.dart';
|
||||
export 'src/service/service.dart';
|
||||
export 'src/service/shortcut_event/key_mapping.dart';
|
||||
export 'src/service/shortcut_event/keybinding.dart';
|
||||
export 'src/service/shortcut_event/shortcut_event.dart';
|
||||
export 'src/service/shortcut_event/shortcut_event_handler.dart';
|
||||
export 'src/render/rich_text/default_selectable.dart';
|
||||
export 'src/render/rich_text/flowy_rich_text.dart';
|
||||
export 'src/render/rich_text/flowy_rich_text_keys.dart';
|
||||
export 'src/render/selection_menu/selection_menu_widget.dart';
|
||||
export 'src/render/selection_menu/selection_menu_item_widget.dart';
|
||||
export 'src/render/selection_menu/selection_menu_icon.dart';
|
||||
export 'src/l10n/l10n.dart';
|
||||
export 'src/render/style/plugin_styles.dart';
|
||||
export 'src/plugins/markdown/encoder/delta_markdown_encoder.dart';
|
||||
export 'src/plugins/markdown/encoder/document_markdown_encoder.dart';
|
||||
export 'src/plugins/markdown/encoder/parser/node_parser.dart';
|
||||
export 'src/plugins/markdown/encoder/parser/text_node_parser.dart';
|
||||
export 'src/plugins/markdown/encoder/parser/image_node_parser.dart';
|
||||
export 'src/plugins/markdown/decoder/delta_markdown_decoder.dart';
|
||||
export 'src/plugins/markdown/document_markdown.dart';
|
||||
export 'src/plugins/quill_delta/delta_document_encoder.dart';
|
||||
export 'src/render/toolbar/toolbar_item.dart';
|
||||
export 'src/render/action_menu/action_menu.dart';
|
||||
export 'src/render/action_menu/action_menu_item.dart';
|
||||
export 'src/core/document/node_iterator.dart';
|
||||
export 'src/infra/flowy_svg.dart';
|
||||
export 'src/extensions/extensions.dart';
|
||||
export 'src/service/default_text_operations/format_rich_text_style.dart';
|
||||
export 'src/infra/html_converter.dart';
|
||||
export 'src/service/internal_key_event_handlers/copy_paste_handler.dart';
|
||||
|
||||
export 'src/editor/block_component/block_component.dart';
|
||||
export 'src/editor/editor_component/editor_component.dart';
|
||||
export 'src/editor/command/transform.dart';
|
||||
export 'src/editor/util/util.dart';
|
||||
export 'src/editor/toolbar/toolbar.dart';
|
||||
export 'src/extensions/node_extensions.dart';
|
||||
export 'src/service/standard_block_components.dart';
|
||||
|
||||
export 'src/core/document/deprecated/node.dart';
|
||||
export 'src/core/document/deprecated/document.dart';
|
||||
|
||||
export 'src/plugins/html/html_document_decoder.dart';
|
||||
export 'src/plugins/html/html_document_encoder.dart';
|
||||
export 'src/plugins/html/html_document.dart';
|
||||
export 'src/infra/mobile/mobile.dart';
|
||||
export 'src/service/toolbar_service.dart';
|
||||
|
|
|
|||
|
|
@ -1,233 +0,0 @@
|
|||
import 'package:appflowy_editor/src/core/document/attributes.dart';
|
||||
import 'package:appflowy_editor/src/core/document/document.dart';
|
||||
import 'package:appflowy_editor/src/core/document/node.dart';
|
||||
import 'package:appflowy_editor/src/core/document/text_delta.dart';
|
||||
import 'package:appflowy_editor/src/core/legacy/built_in_attribute_keys.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@Deprecated('This class is outdated and will be removed in the next release.')
|
||||
class DeltaDocumentConvert {
|
||||
DeltaDocumentConvert();
|
||||
|
||||
var _number = 1;
|
||||
final Map<int, List<TextNode>> _bulletedList = {};
|
||||
|
||||
Document convertFromJSON(List<dynamic> json) {
|
||||
final delta = Delta.fromJson(json);
|
||||
return convertFromDelta(delta);
|
||||
}
|
||||
|
||||
Document convertFromDelta(Delta delta) {
|
||||
final iter = delta.iterator;
|
||||
|
||||
final document = Document.blank();
|
||||
TextNode textNode = TextNode(delta: Delta());
|
||||
int path = 0;
|
||||
|
||||
while (iter.moveNext()) {
|
||||
final op = iter.current;
|
||||
if (op is TextInsert) {
|
||||
if (op.text != '\n') {
|
||||
// Attributes associated with a newline character describes formatting for that line.
|
||||
final texts = op.text.split('\n');
|
||||
if (texts.length > 1) {
|
||||
textNode.delta.insert(texts[0]);
|
||||
document.insert([path++], [textNode]);
|
||||
textNode = TextNode(delta: Delta()..insert(texts[1]));
|
||||
} else {
|
||||
_applyStyle(textNode, op.text, op.attributes);
|
||||
}
|
||||
} else {
|
||||
if (!_containNumberListStyle(op.attributes)) {
|
||||
_number = 1;
|
||||
}
|
||||
_applyListStyle(textNode, op.attributes);
|
||||
_applyHeaderStyle(textNode, op.attributes);
|
||||
_applyIndent(textNode, op.attributes);
|
||||
_applyBlockquote(textNode, op.attributes);
|
||||
// _applyCodeBlock(textNode, op.attributes);
|
||||
|
||||
if (_containIndentBulletedListStyle(op.attributes)) {
|
||||
final level = _indentLevel(op.attributes);
|
||||
final path = [
|
||||
..._bulletedList[level - 1]!.last.path,
|
||||
_bulletedList[level]!.length - 1,
|
||||
];
|
||||
document.insert(path, [textNode]);
|
||||
} else {
|
||||
document.insert([path++], [textNode]);
|
||||
}
|
||||
textNode = TextNode(delta: Delta());
|
||||
}
|
||||
} else {
|
||||
assert(false, 'op must be TextInsert');
|
||||
}
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
void _applyStyle(TextNode textNode, String text, Map? attributes) {
|
||||
Attributes attrs = {};
|
||||
|
||||
if (_containsStyle(attributes, 'strike')) {
|
||||
attrs[BuiltInAttributeKey.strikethrough] = true;
|
||||
}
|
||||
if (_containsStyle(attributes, 'underline')) {
|
||||
attrs[BuiltInAttributeKey.underline] = true;
|
||||
}
|
||||
if (_containsStyle(attributes, 'bold')) {
|
||||
attrs[BuiltInAttributeKey.bold] = true;
|
||||
}
|
||||
if (_containsStyle(attributes, 'italic')) {
|
||||
attrs[BuiltInAttributeKey.italic] = true;
|
||||
}
|
||||
final link = attributes?['link'] as String?;
|
||||
if (link != null) {
|
||||
attrs[BuiltInAttributeKey.href] = link;
|
||||
}
|
||||
final color = attributes?['color'] as String?;
|
||||
final colorHex = _convertColorToHexString(color);
|
||||
if (colorHex != null) {
|
||||
attrs[BuiltInAttributeKey.textColor] = colorHex;
|
||||
}
|
||||
final backgroundColor = attributes?['background'] as String?;
|
||||
final backgroundHex = _convertColorToHexString(backgroundColor);
|
||||
if (backgroundHex != null) {
|
||||
attrs[BuiltInAttributeKey.highlightColor] = backgroundHex;
|
||||
}
|
||||
|
||||
textNode.delta.insert(text, attributes: attrs);
|
||||
}
|
||||
|
||||
bool _containsStyle(Map? attributes, String key) {
|
||||
final value = attributes?[key] as bool?;
|
||||
return value == true;
|
||||
}
|
||||
|
||||
String? _convertColorToHexString(String? color) {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
if (color.startsWith('#')) {
|
||||
return '0xFF${color.substring(1)}';
|
||||
} else if (color.startsWith("rgba")) {
|
||||
List rgbaList = color.substring(5, color.length - 1).split(',');
|
||||
return Color.fromRGBO(
|
||||
int.parse(rgbaList[0]),
|
||||
int.parse(rgbaList[1]),
|
||||
int.parse(rgbaList[2]),
|
||||
double.parse(rgbaList[3]),
|
||||
).toHex();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// convert bullet-list, number-list, check-list to appflowy style list.
|
||||
void _applyListStyle(TextNode textNode, Map? attributes) {
|
||||
final indent = attributes?['indent'] as int?;
|
||||
final list = attributes?['list'] as String?;
|
||||
if (list != null) {
|
||||
switch (list) {
|
||||
case 'bullet':
|
||||
textNode.updateAttributes({
|
||||
BuiltInAttributeKey.subtype: BuiltInAttributeKey.bulletedList,
|
||||
});
|
||||
if (indent != null) {
|
||||
_bulletedList[indent] ??= [];
|
||||
_bulletedList[indent]?.add(textNode);
|
||||
} else {
|
||||
_bulletedList.clear();
|
||||
_bulletedList[0] ??= [];
|
||||
_bulletedList[0]?.add(textNode);
|
||||
}
|
||||
break;
|
||||
case 'ordered':
|
||||
textNode.updateAttributes({
|
||||
BuiltInAttributeKey.subtype: BuiltInAttributeKey.numberList,
|
||||
BuiltInAttributeKey.number: _number++,
|
||||
});
|
||||
break;
|
||||
case 'checked':
|
||||
textNode.updateAttributes({
|
||||
BuiltInAttributeKey.subtype: BuiltInAttributeKey.checkbox,
|
||||
BuiltInAttributeKey.checkbox: true,
|
||||
});
|
||||
break;
|
||||
case 'unchecked':
|
||||
textNode.updateAttributes({
|
||||
BuiltInAttributeKey.subtype: BuiltInAttributeKey.checkbox,
|
||||
BuiltInAttributeKey.checkbox: false,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _containNumberListStyle(Map? attributes) {
|
||||
final list = attributes?['list'] as String?;
|
||||
return list == 'ordered';
|
||||
}
|
||||
|
||||
bool _containIndentBulletedListStyle(Map? attributes) {
|
||||
final list = attributes?['list'] as String?;
|
||||
final indent = attributes?['indent'] as int?;
|
||||
return list == 'bullet' && indent != null;
|
||||
}
|
||||
|
||||
int _indentLevel(Map? attributes) {
|
||||
final indent = attributes?['indent'] as int?;
|
||||
return indent ?? 1;
|
||||
}
|
||||
|
||||
// convert header to appflowy style heading
|
||||
void _applyHeaderStyle(TextNode textNode, Map? attributes) {
|
||||
final header = attributes?['header'] as int?;
|
||||
if (header != null) {
|
||||
textNode.updateAttributes({
|
||||
BuiltInAttributeKey.subtype: BuiltInAttributeKey.heading,
|
||||
BuiltInAttributeKey.heading: 'h$header',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// convert indent to tab
|
||||
void _applyIndent(TextNode textNode, Map? attributes) {
|
||||
final indent = attributes?['indent'] as int?;
|
||||
final list = attributes?['list'] as String?;
|
||||
if (indent != null && list == null) {
|
||||
textNode.delta = textNode.delta.compose(
|
||||
Delta()
|
||||
..retain(0)
|
||||
..insert(' ' * indent),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// convert code_block to appflowy style code
|
||||
void _applyCodeBlock(TextNode textNode, Map? attributes) {
|
||||
final codeBlock = attributes?['code_block'] as bool?;
|
||||
if (codeBlock != null) {
|
||||
textNode.updateAttributes({
|
||||
BuiltInAttributeKey.subtype: 'code_block',
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void _applyBlockquote(TextNode textNode, Map? attributes) {
|
||||
final blockquote = attributes?['blockquote'] as bool?;
|
||||
if (blockquote != null) {
|
||||
textNode.updateAttributes({
|
||||
BuiltInAttributeKey.subtype: BuiltInAttributeKey.quote,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension on Color {
|
||||
String toHex() {
|
||||
return '0x${value.toRadixString(16)}';
|
||||
}
|
||||
}
|
||||
221
lib/src/plugins/quill_delta/quill_delta_encoder.dart
Normal file
221
lib/src/plugins/quill_delta/quill_delta_encoder.dart
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
final QuillDeltaEncoder quillDeltaEncoder = QuillDeltaEncoder();
|
||||
|
||||
const _newLineSymbol = '\n';
|
||||
const _header = 'header';
|
||||
const _list = 'list';
|
||||
const _orderedList = 'ordered';
|
||||
const _bulletedList = 'bullet';
|
||||
const _uncheckedList = 'unchecked';
|
||||
const _checkedList = 'checked';
|
||||
const _blockquote = 'blockquote';
|
||||
const _indent = 'indent';
|
||||
|
||||
class QuillDeltaEncoder extends Converter<Delta, Document> {
|
||||
final Map<int, List<Node>> nestedLists = {};
|
||||
|
||||
@override
|
||||
Document convert(Delta input) {
|
||||
final iterator = input.iterator;
|
||||
final document = Document.blank(withInitialText: false);
|
||||
|
||||
Node node = paragraphNode();
|
||||
int index = 0;
|
||||
|
||||
while (iterator.moveNext()) {
|
||||
final op = iterator.current;
|
||||
final attributes = op.attributes;
|
||||
if (op is TextInsert) {
|
||||
if (op.text == _newLineSymbol) {
|
||||
if (attributes != null) {
|
||||
node = _applyListStyleIfNeeded(node, attributes);
|
||||
node = _applyHeadingStyleIfNeeded(node, attributes);
|
||||
node = _applyBlockquoteIfNeeded(node, attributes);
|
||||
_applyIndentIfNeeded(node, attributes);
|
||||
}
|
||||
if (_isIndentBulletedList(attributes)) {
|
||||
final level = _indentLevel(attributes);
|
||||
final path = [
|
||||
...nestedLists[level - 1]!.last.path,
|
||||
nestedLists[level]!.length - 1,
|
||||
];
|
||||
document.insert(path, [node]);
|
||||
} else {
|
||||
document.insert([index++], [node]);
|
||||
}
|
||||
node = paragraphNode();
|
||||
} else {
|
||||
final texts = op.text.split('\n');
|
||||
if (texts.length > 1) {
|
||||
node.delta?.insert(texts[0]);
|
||||
document.insert([index++], [node]);
|
||||
node = paragraphNode(delta: Delta()..insert(texts[1]));
|
||||
} else {
|
||||
_applyStyle(node, op.text, attributes);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw UnsupportedError('only support text insert operation');
|
||||
}
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
void _applyStyle(Node node, String text, Map<String, dynamic>? attributes) {
|
||||
final Attributes attrs = {};
|
||||
if (_containsStyle(attributes, 'strike')) {
|
||||
attrs[FlowyRichTextKeys.strikethrough] = true;
|
||||
}
|
||||
if (_containsStyle(attributes, 'underline')) {
|
||||
attrs[FlowyRichTextKeys.underline] = true;
|
||||
}
|
||||
if (_containsStyle(attributes, 'bold')) {
|
||||
attrs[FlowyRichTextKeys.bold] = true;
|
||||
}
|
||||
if (_containsStyle(attributes, 'italic')) {
|
||||
attrs[FlowyRichTextKeys.italic] = true;
|
||||
}
|
||||
final link = attributes?['link'] as String?;
|
||||
if (link != null) {
|
||||
attrs[FlowyRichTextKeys.href] = link;
|
||||
}
|
||||
final color = attributes?['color'] as String?;
|
||||
final colorHex = _convertColorToHexString(color);
|
||||
if (colorHex != null) {
|
||||
attrs[FlowyRichTextKeys.textColor] = colorHex;
|
||||
}
|
||||
final backgroundColor = attributes?['background'] as String?;
|
||||
final backgroundHex = _convertColorToHexString(backgroundColor);
|
||||
if (backgroundHex != null) {
|
||||
attrs[FlowyRichTextKeys.highlightColor] = backgroundHex;
|
||||
}
|
||||
node.updateAttributes({
|
||||
'delta': (node.delta?..insert(text, attributes: attrs))?.toJson(),
|
||||
});
|
||||
}
|
||||
|
||||
void _applyIndentIfNeeded(Node node, Map<String, dynamic> attributes) {
|
||||
final indent = attributes[_indent] as int?;
|
||||
final list = attributes[_list] as String?;
|
||||
if (indent != null && list == null && node.delta != null) {
|
||||
node.updateAttributes({
|
||||
'delta': node.delta
|
||||
?.compose(
|
||||
Delta()
|
||||
..retain(0)
|
||||
..insert(' ' * indent),
|
||||
)
|
||||
.toJson(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Node _applyBlockquoteIfNeeded(Node node, Map<String, dynamic> attributes) {
|
||||
final blockquote = attributes[_blockquote] as bool?;
|
||||
if (blockquote == true) {
|
||||
return quoteNode(
|
||||
delta: node.delta,
|
||||
);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
Node _applyHeadingStyleIfNeeded(Node node, Map<String, dynamic> attributes) {
|
||||
final header = attributes[_header] as int?;
|
||||
if (header == null) {
|
||||
return node;
|
||||
}
|
||||
return headingNode(
|
||||
delta: node.delta,
|
||||
level: header,
|
||||
);
|
||||
}
|
||||
|
||||
// If the attributes contains the list style, then apply the list style to the node.
|
||||
Node _applyListStyleIfNeeded(Node node, Map<String, dynamic> attributes) {
|
||||
final list = attributes[_list] as String?;
|
||||
switch (list) {
|
||||
case _bulletedList:
|
||||
final bulletedList = bulletedListNode(
|
||||
delta: node.delta,
|
||||
);
|
||||
final indent = attributes[_indent] as int?;
|
||||
if (indent != null) {
|
||||
nestedLists[indent] ??= [];
|
||||
nestedLists[indent]?.add(bulletedList);
|
||||
} else {
|
||||
nestedLists.clear();
|
||||
nestedLists[0] ??= [];
|
||||
nestedLists[0]?.add(bulletedList);
|
||||
}
|
||||
return bulletedList;
|
||||
case _orderedList:
|
||||
final numberedList = numberedListNode(
|
||||
delta: node.delta,
|
||||
);
|
||||
final indent = attributes[_indent] as int?;
|
||||
if (indent != null) {
|
||||
nestedLists[indent] ??= [];
|
||||
nestedLists[indent]?.add(numberedList);
|
||||
} else {
|
||||
nestedLists.clear();
|
||||
nestedLists[0] ??= [];
|
||||
nestedLists[0]?.add(numberedList);
|
||||
}
|
||||
return numberedList;
|
||||
case _checkedList:
|
||||
final checkedList = todoListNode(
|
||||
delta: node.delta,
|
||||
checked: true,
|
||||
);
|
||||
return checkedList;
|
||||
case _uncheckedList:
|
||||
final uncheckedList = todoListNode(
|
||||
delta: node.delta,
|
||||
checked: false,
|
||||
);
|
||||
return uncheckedList;
|
||||
default:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
int _indentLevel(Map? attributes) {
|
||||
final indent = attributes?['indent'] as int?;
|
||||
return indent ?? 1;
|
||||
}
|
||||
|
||||
bool _isIndentBulletedList(Map<String, dynamic>? attributes) {
|
||||
final list = attributes?[_list] as String?;
|
||||
final indent = attributes?[_indent] as int?;
|
||||
return [_bulletedList, _orderedList].contains(list) && indent != null;
|
||||
}
|
||||
|
||||
bool _containsStyle(Map<String, dynamic>? attributes, String key) {
|
||||
final value = attributes?[key] as bool?;
|
||||
return value == true;
|
||||
}
|
||||
|
||||
String? _convertColorToHexString(String? color) {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
if (color.startsWith('#')) {
|
||||
return '0xFF${color.substring(1)}';
|
||||
} else if (color.startsWith("rgba")) {
|
||||
List rgbaList = color.substring(5, color.length - 1).split(',');
|
||||
return Color.fromRGBO(
|
||||
int.parse(rgbaList[0]),
|
||||
int.parse(rgbaList[1]),
|
||||
int.parse(rgbaList[2]),
|
||||
double.parse(rgbaList[3]),
|
||||
).toHex();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
551
test/plugins/quill_delta/quill_delta_encoder_test.dart
Normal file
551
test/plugins/quill_delta/quill_delta_encoder_test.dart
Normal file
|
|
@ -0,0 +1,551 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() async {
|
||||
group('delta_document_encoder.dart', () {
|
||||
test('', () {
|
||||
final json = jsonDecode(quillDeltaSample.replaceAll('\\\\\n', '\\n'));
|
||||
final document = quillDeltaEncoder.convert(Delta.fromJson(json));
|
||||
expect(jsonEncode(document.toJson()), documentSample);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const documentSample =
|
||||
'''{"document":{"type":"page","children":[{"type":"heading","data":{"level":1,"delta":[{"insert":"Flutter Quill"}]}},{"type":"paragraph","data":{"delta":[]}},{"type":"heading","data":{"level":2,"delta":[{"insert":"Rich text editor for Flutter"}]}},{"type":"heading","data":{"level":3,"delta":[{"insert":"Quill component for Flutter"}]}},{"type":"paragraph","data":{"delta":[{"insert":"This "},{"insert":"library","attributes":{"italic":true}},{"insert":" supports "},{"insert":"mobile","attributes":{"bold":true,"bg_color":"0xFFebd6ff"}},{"insert":" platform "},{"insert":"only","attributes":{"underline":true,"bold":true,"font_color":"0xFFe60000"}},{"insert":" and ","attributes":{"font_color":"d7000000"}},{"insert":"web","attributes":{"strikethrough":true}}]}},{"type":"paragraph","data":{"delta":[{"insert":"You are welcome to use "},{"insert":"Bullet Journal","attributes":{"href":"https://bulletjournal.us/home/index.html"}}]}},{"type":"numbered_list","data":{"delta":[{"insert":"Track personal and group journals (ToDo, Note, Ledger) from multiple views with timely reminders"}],"number":null}},{"type":"numbered_list","data":{"delta":[{"insert":"Share your tasks and notes with teammates, and see changes as they happen in real-time, across all devices"}],"number":null}},{"type":"numbered_list","data":{"delta":[{"insert":"Check out what you and your teammates are working on each day"}],"number":null}},{"type":"paragraph","data":{"delta":[]}},{"type":"bulleted_list","data":{"delta":[{"insert":"Splitting bills with friends can never be easier."}]}},{"type":"bulleted_list","data":{"delta":[{"insert":"Start creating a group and invite your friends to join."}]}},{"type":"bulleted_list","data":{"delta":[{"insert":"Create a BuJo of Ledger type to see expense or balance summary."}]}},{"type":"paragraph","data":{"delta":[]}},{"type":"quote","data":{"delta":[{"insert":"Attach one or multiple labels to tasks, notes or transactions. Later you can track them just using the label(s)."}]}},{"type":"paragraph","data":{"delta":[]}},{"type":"paragraph","data":{"delta":[{"insert":"var BuJo = 'Bullet' + 'Journal'"}]}},{"type":"paragraph","data":{"delta":[]}},{"type":"paragraph","data":{"delta":[{"insert":" Start tracking in your browser"}]}},{"type":"paragraph","data":{"delta":[{"insert":" Stop the timer on your phone"}]}},{"type":"paragraph","data":{"delta":[{"insert":" All your time entries are synced"}]}},{"type":"paragraph","data":{"delta":[{"insert":" between the phone apps"}]}},{"type":"paragraph","data":{"delta":[{"insert":" and the website."}]}},{"type":"paragraph","data":{"delta":[]}},{"type":"paragraph","data":{"delta":[]}},{"type":"paragraph","data":{"delta":[{"insert":"Center Align"}]}},{"type":"paragraph","data":{"delta":[{"insert":"Right Align"}]}},{"type":"paragraph","data":{"delta":[{"insert":"Justify Align"}]}},{"type":"numbered_list","children":[{"type":"numbered_list","children":[{"type":"numbered_list","data":{"delta":[{"insert":"and easily find contents"}],"number":null}},{"type":"numbered_list","data":{"delta":[{"insert":"across projects or folders."}],"number":null}}],"data":{"delta":[{"insert":"Just type in the search bar"}],"number":null}},{"type":"numbered_list","data":{"delta":[{"insert":"It matches text in your note or task."}],"number":null}}],"data":{"delta":[{"insert":"Have trouble finding things? "}],"number":null}},{"type":"numbered_list","children":[{"type":"numbered_list","data":{"delta":[{"insert":"email"}],"number":null}},{"type":"numbered_list","data":{"delta":[{"insert":"message on your phone"}],"number":null}},{"type":"numbered_list","data":{"delta":[{"insert":"popup on the web site"}],"number":null}}],"data":{"delta":[{"insert":"Enable reminders so that you will get notified by"}],"number":null}},{"type":"bulleted_list","children":[{"type":"bulleted_list","children":[{"type":"bulleted_list","data":{"delta":[{"insert":"tasks"}]}},{"type":"bulleted_list","data":{"delta":[{"insert":"notes"}]}},{"type":"bulleted_list","children":[{"type":"bulleted_list","data":{"delta":[{"insert":"under BuJo "}]}}],"data":{"delta":[{"insert":"transactions"}]}}],"data":{"delta":[{"insert":"Organize your"}]}}],"data":{"delta":[{"insert":"Create a BuJo serving as project or folder"}]}},{"type":"bulleted_list","children":[{"type":"bulleted_list","data":{"delta":[{"insert":"or hierarchical view"}]}}],"data":{"delta":[{"insert":"See them in Calendar"}]}},{"type":"todo_list","data":{"checked":true,"delta":[{"insert":"this is a check list"}]}},{"type":"todo_list","data":{"checked":false,"delta":[{"insert":"this is a uncheck list"}]}},{"type":"paragraph","data":{"delta":[{"insert":"Font Sans Serif Serif Monospace Size Small Large Hugefont size 15 font size 35 font size 20 diff-match-patch"}]}}]}}''';
|
||||
|
||||
const quillDeltaSample = r'''
|
||||
[
|
||||
{
|
||||
"insert": "Flutter Quill"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"header": 1
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": {
|
||||
"video": "https://www.youtube.com/watch?v=V4hgdKhIqtc&list=PLbhaS_83B97s78HsDTtplRTEhcFsqSqIK&index=1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"insert": {
|
||||
"video": "https://user-images.githubusercontent.com/122956/126238875-22e42501-ad41-4266-b1d6-3f89b5e3b79b.mp4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"insert": "\nRich text editor for Flutter"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"header": 2
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Quill component for Flutter"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"header": 3
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "This "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"italic": true,
|
||||
"background": "transparent"
|
||||
},
|
||||
"insert": "library"
|
||||
},
|
||||
{
|
||||
"insert": " supports "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"bold": true,
|
||||
"background": "#ebd6ff"
|
||||
},
|
||||
"insert": "mobile"
|
||||
},
|
||||
{
|
||||
"insert": " platform "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"underline": true,
|
||||
"bold": true,
|
||||
"color": "#e60000"
|
||||
},
|
||||
"insert": "only"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"color": "rgba(0, 0, 0, 0.847)"
|
||||
},
|
||||
"insert": " and "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"strike": true,
|
||||
"color": "black"
|
||||
},
|
||||
"insert": "web"
|
||||
},
|
||||
{
|
||||
"insert": " is not supported.\nYou are welcome to use "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"link": "https://bulletjournal.us/home/index.html"
|
||||
},
|
||||
"insert": "Bullet Journal"
|
||||
},
|
||||
{
|
||||
"insert": ":\nTrack personal and group journals (ToDo, Note, Ledger) from multiple views with timely reminders"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Share your tasks and notes with teammates, and see changes as they happen in real-time, across all devices"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Check out what you and your teammates are working on each day"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "\nSplitting bills with friends can never be easier."
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Start creating a group and invite your friends to join."
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Create a BuJo of Ledger type to see expense or balance summary."
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "\nAttach one or multiple labels to tasks, notes or transactions. Later you can track them just using the label(s)."
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"blockquote": true
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "\nvar BuJo = 'Bullet' + 'Journal'"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"code_block": true
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "\nStart tracking in your browser"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Stop the timer on your phone"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "All your time entries are synced"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 2
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "between the phone apps"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 2
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "and the website."
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 3
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "\nCenter Align"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"align": "center"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Right Align"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"align": "right"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Justify Align"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"align": "justify"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Have trouble finding things? "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Just type in the search bar"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1,
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "and easily find contents"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 2,
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "across projects or folders."
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 2,
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "It matches text in your note or task."
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1,
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Enable reminders so that you will get notified by"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "email"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1,
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "message on your phone"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1,
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "popup on the web site"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1,
|
||||
"list": "ordered"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Create a BuJo serving as project or folder"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Organize your"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1,
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "tasks"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 2,
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "notes"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 2,
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "transactions"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 2,
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "under BuJo "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 3,
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "See them in Calendar"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "or hierarchical view"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"indent": 1,
|
||||
"list": "bullet"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "this is a check list"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "checked"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "this is a uncheck list"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"list": "unchecked"
|
||||
},
|
||||
"insert": "\n"
|
||||
},
|
||||
{
|
||||
"insert": "Font "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"font": "sans-serif"
|
||||
},
|
||||
"insert": "Sans Serif"
|
||||
},
|
||||
{
|
||||
"insert": " "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"font": "serif"
|
||||
},
|
||||
"insert": "Serif"
|
||||
},
|
||||
{
|
||||
"insert": " "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"font": "monospace"
|
||||
},
|
||||
"insert": "Monospace"
|
||||
},
|
||||
{
|
||||
"insert": " Size "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"size": "small"
|
||||
},
|
||||
"insert": "Small"
|
||||
},
|
||||
{
|
||||
"insert": " "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"size": "large"
|
||||
},
|
||||
"insert": "Large"
|
||||
},
|
||||
{
|
||||
"insert": " "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"size": "huge"
|
||||
},
|
||||
"insert": "Huge"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"size": "15.0"
|
||||
},
|
||||
"insert": "font size 15"
|
||||
},
|
||||
{
|
||||
"insert": " "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"size": "35"
|
||||
},
|
||||
"insert": "font size 35"
|
||||
},
|
||||
{
|
||||
"insert": " "
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"size": "20"
|
||||
},
|
||||
"insert": "font size 20"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"token": "built_in"
|
||||
},
|
||||
"insert": " diff"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"token": "operator"
|
||||
},
|
||||
"insert": "-match"
|
||||
},
|
||||
{
|
||||
"attributes": {
|
||||
"token": "literal"
|
||||
},
|
||||
"insert": "-patch"
|
||||
},
|
||||
{
|
||||
"insert": {
|
||||
"image": "https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png"
|
||||
},
|
||||
"attributes": {
|
||||
"width": "230",
|
||||
"style": "display: block; margin: auto;"
|
||||
}
|
||||
},
|
||||
{
|
||||
"insert": "\n"
|
||||
}
|
||||
]
|
||||
''';
|
||||
Loading…
Reference in a new issue