feat: load the readme file when first time launch (#2676)

* chore: bump version 0.2.0

* test: add migration test

* feat: support exporting document data to afdoc format (#2610)

* feat: support exporting document data to afdoc format

* feat: export database

* fix: resolve comment issues

* fix: add error tips when exporting files failed

---------

Co-authored-by: nathan <nathan@appflowy.io>

* feat: rename delta

* feat: add built-in readme

* fix: use independent children id

* fix: comment typo

* chore: add icons

* fix: floating toolbar style

* fix: markdown export test

* chore: disbale moveup/movedown action

* fix: unit test

---------

Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
Lucas.Xu
2023-06-01 20:18:40 +08:00
committed by GitHub
parent 012b6c0066
commit 2ef72f3203
41 changed files with 1043 additions and 298 deletions

View File

@ -91,7 +91,6 @@ extension DocumentDataPBFromTo on DocumentDataPB {
class _BackendKeys {
const _BackendKeys._();
static const String page = 'page';
static const String text = 'text';
}
@ -109,7 +108,6 @@ extension BlockToNode on BlockPB {
String _typeAdapter(String ty) {
final adapter = {
_BackendKeys.page: 'document',
_BackendKeys.text: ParagraphBlockKeys.type,
};
return adapter[ty] ?? ty;
@ -149,7 +147,6 @@ extension NodeToBlock on Node {
String _typeAdapter(String type) {
final adapter = {
'document': 'page',
'paragraph': 'text',
};
return adapter[type] ?? type;

View File

@ -114,6 +114,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
maxWidth: double.infinity,
),
child: FloatingToolbar(
style: styleCustomizer.floatingToolbarStyleBuilder(),
items: toolbarItems,
editorState: widget.editorState,
scrollController: scrollController,
@ -127,16 +128,16 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
final standardActions = [
OptionAction.delete,
OptionAction.duplicate,
OptionAction.divider,
OptionAction.moveUp,
OptionAction.moveDown,
// OptionAction.divider,
// OptionAction.moveUp,
// OptionAction.moveDown,
];
final configuration = BlockComponentConfiguration(
padding: (_) => const EdgeInsets.symmetric(vertical: 4.0),
);
final customBlockComponentBuilderMap = {
'document': DocumentComponentBuilder(),
PageBlockKeys.type: PageBlockComponentBuilder(),
ParagraphBlockKeys.type: TextBlockComponentBuilder(
configuration: configuration,
),
@ -207,7 +208,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
// customize the action builder. actually, we can customize them in their own builder. Put them here just for convenience.
for (final entry in builders.entries) {
if (entry.key == 'document') {
if (entry.key == PageBlockKeys.type) {
continue;
}
final builder = entry.value;
@ -224,7 +225,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
];
final colorAction = [
OptionAction.divider,
// OptionAction.divider,
OptionAction.color,
];

View File

@ -29,7 +29,7 @@ class BlockActionButton extends StatelessWidget {
behavior: HitTestBehavior.deferToChild,
child: svgWidget(
svgName,
size: const Size.square(14.0),
size: const Size.square(18.0),
color: Theme.of(context).iconTheme.color,
),
),

View File

@ -120,9 +120,6 @@ class BlockOptionButton extends StatelessWidget {
transaction.moveNode(node.path.next.next, node);
break;
case OptionAction.color:
// show the color picker
break;
case OptionAction.divider:
throw UnimplementedError();
}

View File

@ -2,10 +2,11 @@ import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/
import 'package:appflowy/plugins/database_view/widgets/row/cells/select_option_cell/extension.dart';
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/appflowy_editor.dart' hide FlowySvg;
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:flowy_infra/image.dart';
import 'package:flutter/material.dart';
import 'package:styled_widget/styled_widget.dart';
enum OptionAction {
delete,
@ -36,10 +37,10 @@ class ColorOptionAction extends PopoverActionCell {
@override
Widget? leftIcon(Color iconColor) {
return svgWidget(
'editor/color_formatter',
color: iconColor,
);
return const FlowySvg(
name: 'editor/color_formatter',
size: Size.square(12),
).padding(all: 2.0);
}
@override
@ -125,18 +126,13 @@ class OptionActionWrapper extends ActionCell {
case OptionAction.moveDown:
name = 'editor/move_down';
break;
case OptionAction.color:
throw UnimplementedError();
case OptionAction.divider:
default:
throw UnimplementedError();
}
if (name.isEmpty) {
return null;
}
return svgWidget(
name,
color: iconColor,
);
return FlowySvg(name: name);
}
@override

View File

@ -103,9 +103,6 @@ class OptionActionList extends StatelessWidget {
transaction.moveNode(node.path.next.next, node);
break;
case OptionAction.color:
// show the color picker
break;
case OptionAction.divider:
throw UnimplementedError();
}

View File

@ -37,12 +37,12 @@ class EditorMigration {
(element) => element.id == 'cover',
);
if (coverNode != null) {
node = documentNode(
node = pageNode(
children: children,
attributes: coverNode.attributes,
);
} else {
node = documentNode(children: children);
node = pageNode(children: children);
}
} else if (id == 'callout') {
final emoji = nodeV0.attributes['emoji'] ?? '📌';
@ -141,12 +141,13 @@ class EditorMigration {
}
const backgroundColor = 'backgroundColor';
if (attributes.containsKey(backgroundColor)) {
attributes['highlightColor'] = attributes[backgroundColor];
attributes[FlowyRichTextKeys.highlightColor] =
attributes[backgroundColor];
attributes.remove(backgroundColor);
}
const color = 'color';
if (attributes.containsKey(color)) {
attributes['textColor'] = attributes[color];
attributes[FlowyRichTextKeys.textColor] = attributes[color];
attributes.remove(color);
}
return attributes;

View File

@ -375,7 +375,7 @@ class _AutoCompletionBlockComponentState
final previous = widget.node.previous;
final Selection selection;
if (previous == null ||
previous.type != 'paragraph' ||
previous.type != ParagraphBlockKeys.type ||
(previous.delta?.toPlainText().isNotEmpty ?? false)) {
selection = Selection.single(
path: widget.node.path,

View File

@ -136,4 +136,11 @@ class EditorStyleCustomizer {
selectionMenuItemSelectedColor: theme.hoverColor,
);
}
FloatingToolbarStyle floatingToolbarStyleBuilder() {
final theme = Theme.of(context);
return FloatingToolbarStyle(
backgroundColor: theme.cardColor,
);
}
}