mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: improve performance of document page (#3357)
This commit is contained in:
parent
608255fa0f
commit
71071b60b2
@ -2,10 +2,10 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/cell/checklist_cell_service.dart';
|
import 'package:appflowy/plugins/database_view/application/cell/checklist_cell_service.dart';
|
||||||
|
import 'package:appflowy_backend/log.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database2/checklist_entities.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database2/checklist_entities.pb.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-database2/select_option.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-database2/select_option.pb.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:appflowy_backend/log.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
@ -150,11 +150,16 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
|
|||||||
final (bool autoFocus, Selection? selection) =
|
final (bool autoFocus, Selection? selection) =
|
||||||
_computeAutoFocusParameters();
|
_computeAutoFocusParameters();
|
||||||
|
|
||||||
|
final editorScrollController = EditorScrollController(
|
||||||
|
editorState: widget.editorState,
|
||||||
|
shrinkWrap: widget.shrinkWrap,
|
||||||
|
scrollController: effectiveScrollController,
|
||||||
|
);
|
||||||
|
|
||||||
final editor = AppFlowyEditor(
|
final editor = AppFlowyEditor(
|
||||||
editorState: widget.editorState,
|
editorState: widget.editorState,
|
||||||
editable: true,
|
editable: true,
|
||||||
shrinkWrap: widget.shrinkWrap,
|
editorScrollController: editorScrollController,
|
||||||
scrollController: effectiveScrollController,
|
|
||||||
// setup the auto focus parameters
|
// setup the auto focus parameters
|
||||||
autoFocus: widget.autoFocus ?? autoFocus,
|
autoFocus: widget.autoFocus ?? autoFocus,
|
||||||
focusedSelection: selection,
|
focusedSelection: selection,
|
||||||
@ -171,18 +176,12 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: ConstrainedBox(
|
child: FloatingToolbar(
|
||||||
constraints: const BoxConstraints(
|
style: styleCustomizer.floatingToolbarStyleBuilder(),
|
||||||
maxWidth: double.infinity,
|
items: toolbarItems,
|
||||||
maxHeight: double.infinity,
|
editorState: widget.editorState,
|
||||||
),
|
editorScrollController: editorScrollController,
|
||||||
child: FloatingToolbar(
|
child: editor,
|
||||||
style: styleCustomizer.floatingToolbarStyleBuilder(),
|
|
||||||
items: toolbarItems,
|
|
||||||
editorState: widget.editorState,
|
|
||||||
scrollController: effectiveScrollController,
|
|
||||||
child: editor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
||||||
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/block_action_button.dart';
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/block_action_button.dart';
|
||||||
import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/option_action.dart';
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/option_action.dart';
|
||||||
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
|
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class BlockOptionButton extends StatelessWidget {
|
class BlockOptionButton extends StatelessWidget {
|
||||||
const BlockOptionButton({
|
const BlockOptionButton({
|
||||||
@ -42,9 +42,11 @@ class BlockOptionButton extends StatelessWidget {
|
|||||||
actions: popoverActions,
|
actions: popoverActions,
|
||||||
onPopupBuilder: () => blockComponentState.alwaysShowActions = true,
|
onPopupBuilder: () => blockComponentState.alwaysShowActions = true,
|
||||||
onClosed: () {
|
onClosed: () {
|
||||||
editorState.selectionType = null;
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
editorState.selection = null;
|
editorState.selectionType = null;
|
||||||
blockComponentState.alwaysShowActions = false;
|
editorState.selection = null;
|
||||||
|
blockComponentState.alwaysShowActions = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onSelected: (action, controller) {
|
onSelected: (action, controller) {
|
||||||
if (action is OptionActionWrapper) {
|
if (action is OptionActionWrapper) {
|
||||||
|
@ -195,6 +195,17 @@ class _CalloutBlockComponentWidgetState
|
|||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
child = BlockSelectionContainer(
|
||||||
|
node: node,
|
||||||
|
delegate: this,
|
||||||
|
listenable: editorState.selectionNotifier,
|
||||||
|
blockColor: editorState.editorStyle.selectionColor,
|
||||||
|
supportTypes: const [
|
||||||
|
BlockSelectionType.block,
|
||||||
|
],
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
|
||||||
if (widget.showActions && widget.actionBuilder != null) {
|
if (widget.showActions && widget.actionBuilder != null) {
|
||||||
child = BlockComponentActionWrapper(
|
child = BlockComponentActionWrapper(
|
||||||
node: widget.node,
|
node: widget.node,
|
||||||
@ -212,6 +223,7 @@ class _CalloutBlockComponentWidgetState
|
|||||||
padding: padding,
|
padding: padding,
|
||||||
child: AppFlowyRichText(
|
child: AppFlowyRichText(
|
||||||
key: forwardKey,
|
key: forwardKey,
|
||||||
|
delegate: this,
|
||||||
node: widget.node,
|
node: widget.node,
|
||||||
editorState: editorState,
|
editorState: editorState,
|
||||||
placeholderText: placeholderText,
|
placeholderText: placeholderText,
|
||||||
@ -221,6 +233,8 @@ class _CalloutBlockComponentWidgetState
|
|||||||
placeholderTextSpanDecorator: (textSpan) => textSpan.updateTextStyle(
|
placeholderTextSpanDecorator: (textSpan) => textSpan.updateTextStyle(
|
||||||
placeholderTextStyle,
|
placeholderTextStyle,
|
||||||
),
|
),
|
||||||
|
cursorColor: editorState.editorStyle.cursorColor,
|
||||||
|
selectionColor: editorState.editorStyle.selectionColor,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -204,6 +204,17 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
child = BlockSelectionContainer(
|
||||||
|
node: node,
|
||||||
|
delegate: this,
|
||||||
|
listenable: editorState.selectionNotifier,
|
||||||
|
blockColor: editorState.editorStyle.selectionColor,
|
||||||
|
supportTypes: const [
|
||||||
|
BlockSelectionType.block,
|
||||||
|
],
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
|
||||||
if (widget.showActions && widget.actionBuilder != null) {
|
if (widget.showActions && widget.actionBuilder != null) {
|
||||||
child = BlockComponentActionWrapper(
|
child = BlockComponentActionWrapper(
|
||||||
node: widget.node,
|
node: widget.node,
|
||||||
@ -235,6 +246,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|||||||
padding: widget.padding,
|
padding: widget.padding,
|
||||||
child: AppFlowyRichText(
|
child: AppFlowyRichText(
|
||||||
key: forwardKey,
|
key: forwardKey,
|
||||||
|
delegate: this,
|
||||||
node: widget.node,
|
node: widget.node,
|
||||||
editorState: editorState,
|
editorState: editorState,
|
||||||
placeholderText: placeholderText,
|
placeholderText: placeholderText,
|
||||||
@ -246,6 +258,8 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|||||||
placeholderTextSpanDecorator: (textSpan) => TextSpan(
|
placeholderTextSpanDecorator: (textSpan) => TextSpan(
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
|
cursorColor: editorState.editorStyle.cursorColor,
|
||||||
|
selectionColor: editorState.editorStyle.selectionColor,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ CommandShortcutEventHandler _copyCommandHandler = (editorState) {
|
|||||||
// plain text.
|
// plain text.
|
||||||
final text = editorState.getTextInSelection(selection).join('\n');
|
final text = editorState.getTextInSelection(selection).join('\n');
|
||||||
|
|
||||||
final nodes = editorState.getSelectedNodes(selection);
|
final nodes = editorState.getSelectedNodes(selection: selection);
|
||||||
final document = Document.blank()..insert([0], nodes);
|
final document = Document.blank()..insert([0], nodes);
|
||||||
|
|
||||||
// in app json
|
// in app json
|
||||||
|
@ -6,7 +6,6 @@ import 'package:appflowy/workspace/presentation/widgets/emoji_picker/emoji_picke
|
|||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -202,7 +201,7 @@ class _DocumentHeaderToolbarState extends State<DocumentHeaderToolbar> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 80),
|
padding: const EdgeInsets.symmetric(horizontal: 40),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 28,
|
height: 28,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
@ -171,6 +171,7 @@ class _ToggleListBlockComponentWidgetState
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: AppFlowyRichText(
|
child: AppFlowyRichText(
|
||||||
key: forwardKey,
|
key: forwardKey,
|
||||||
|
delegate: this,
|
||||||
node: widget.node,
|
node: widget.node,
|
||||||
editorState: editorState,
|
editorState: editorState,
|
||||||
placeholderText: placeholderText,
|
placeholderText: placeholderText,
|
||||||
@ -183,6 +184,8 @@ class _ToggleListBlockComponentWidgetState
|
|||||||
placeholderTextStyle,
|
placeholderTextStyle,
|
||||||
),
|
),
|
||||||
textDirection: textDirection,
|
textDirection: textDirection,
|
||||||
|
cursorColor: editorState.editorStyle.cursorColor,
|
||||||
|
selectionColor: editorState.editorStyle.selectionColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -195,6 +198,17 @@ class _ToggleListBlockComponentWidgetState
|
|||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
child = BlockSelectionContainer(
|
||||||
|
node: node,
|
||||||
|
delegate: this,
|
||||||
|
listenable: editorState.selectionNotifier,
|
||||||
|
blockColor: editorState.editorStyle.selectionColor,
|
||||||
|
supportTypes: const [
|
||||||
|
BlockSelectionType.block,
|
||||||
|
],
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
|
||||||
if (widget.showActions && widget.actionBuilder != null) {
|
if (widget.showActions && widget.actionBuilder != null) {
|
||||||
child = BlockComponentActionWrapper(
|
child = BlockComponentActionWrapper(
|
||||||
node: node,
|
node: node,
|
||||||
|
@ -54,8 +54,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "3f2db9b"
|
ref: "4a92c88"
|
||||||
resolved-ref: "3f2db9b416f7c7512acba397e0cbb342fabaf7a2"
|
resolved-ref: "4a92c88b6611af95909e4618be3970cc20f6d930"
|
||||||
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
|
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
|
@ -48,7 +48,7 @@ dependencies:
|
|||||||
appflowy_editor:
|
appflowy_editor:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/AppFlowy-IO/appflowy-editor.git
|
url: https://github.com/AppFlowy-IO/appflowy-editor.git
|
||||||
ref: 3f2db9b
|
ref: 4a92c88
|
||||||
appflowy_popover:
|
appflowy_popover:
|
||||||
path: packages/appflowy_popover
|
path: packages/appflowy_popover
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user