feat: optimize the performance (#442)
This commit is contained in:
parent
ad55171c5b
commit
19f999f422
1 changed files with 4639 additions and 828 deletions
|
|
@ -37,7 +37,10 @@ class Editor extends StatelessWidget {
|
|||
onEditorStateChange(editorState);
|
||||
}
|
||||
});
|
||||
final scrollController = ScrollController();
|
||||
final editorScrollController = EditorScrollController(
|
||||
editorState: editorState,
|
||||
shrinkWrap: false,
|
||||
);
|
||||
if (PlatformExtension.isDesktopOrWeb) {
|
||||
return FloatingToolbar(
|
||||
items: [
|
||||
|
|
@ -54,11 +57,11 @@ class Editor extends StatelessWidget {
|
|||
...alignmentItems,
|
||||
],
|
||||
editorState: editorState,
|
||||
scrollController: scrollController,
|
||||
editorScrollController: editorScrollController,
|
||||
child: _buildDesktopEditor(
|
||||
context,
|
||||
editorState,
|
||||
scrollController,
|
||||
editorScrollController,
|
||||
),
|
||||
);
|
||||
} else if (PlatformExtension.isMobile) {
|
||||
|
|
@ -68,7 +71,7 @@ class Editor extends StatelessWidget {
|
|||
child: _buildMobileEditor(
|
||||
context,
|
||||
editorState,
|
||||
scrollController,
|
||||
editorScrollController,
|
||||
),
|
||||
),
|
||||
MobileToolbar(
|
||||
|
|
@ -99,19 +102,19 @@ class Editor extends StatelessWidget {
|
|||
Widget _buildMobileEditor(
|
||||
BuildContext context,
|
||||
EditorState editorState,
|
||||
ScrollController? scrollController,
|
||||
EditorScrollController? editorScrollController,
|
||||
) {
|
||||
return AppFlowyEditor(
|
||||
editorStyle: const EditorStyle.mobile(),
|
||||
editorState: editorState,
|
||||
scrollController: scrollController,
|
||||
editorScrollController: editorScrollController,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDesktopEditor(
|
||||
BuildContext context,
|
||||
EditorState editorState,
|
||||
ScrollController? scrollController,
|
||||
EditorScrollController? editorScrollController,
|
||||
) {
|
||||
final customBlockComponentBuilders = {
|
||||
...standardBlockComponentBuilderMap,
|
||||
|
|
@ -127,7 +130,8 @@ class Editor extends StatelessWidget {
|
|||
};
|
||||
return AppFlowyEditor(
|
||||
editorState: editorState,
|
||||
scrollController: scrollController,
|
||||
shrinkWrap: true,
|
||||
editorScrollController: editorScrollController,
|
||||
blockComponentBuilders: customBlockComponentBuilders,
|
||||
commandShortcutEvents: [
|
||||
customToggleHighlightCommand(
|
||||
|
|
|
|||
Loading…
Reference in a new issue