Skip to content

Commit

Permalink
Merge branch 'main' into feat-zhiya
Browse files Browse the repository at this point in the history
* main:
  chore: refactor attribute comparison in Delta class diff loop (AppFlowy-IO#456)
  fix: duration cannot be zero in animate (AppFlowy-IO#452)
  chore: update Chinese l10n (AppFlowy-IO#445)
  fix: sometimes failed to paste content from google translation (AppFlowy-IO#451)
  feat: refactor color conversion method to handle RGB and hex formatsRefactor method to handle RGB and hex formats, improving color conversion (AppFlowy-IO#450)
  fix: unable to paste html contains section (AppFlowy-IO#448)
  fix: remove unused check in non_delta_input_service (AppFlowy-IO#447)
  feat: optimize the performance (AppFlowy-IO#442)
  refactor: migrate tests (AppFlowy-IO#438)
  feat: bulk open links shortcut (AppFlowy-IO#419)
  fix: request focus in find replace menu (AppFlowy-IO#440)
  feat: implement delta diff and provide external values (AppFlowy-IO#444)
  • Loading branch information
q200892907 committed Sep 13, 2023
2 parents 2709672 + 08f9bcd commit f82a8d0
Show file tree
Hide file tree
Showing 120 changed files with 5,886 additions and 1,583 deletions.
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "lib/src/flutter/"
23 changes: 23 additions & 0 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math';

import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:example/pages/customize_theme_for_editor.dart';
Expand Down Expand Up @@ -51,6 +52,7 @@ class _HomePageState extends State<HomePage> {
super.initState();

_jsonString = rootBundle.loadString('assets/example.json');

_widgetBuilder = (context) => Editor(
jsonString: _jsonString,
onEditorStateChange: (editorState) {
Expand Down Expand Up @@ -109,6 +111,20 @@ class _HomePageState extends State<HomePage> {
final jsonString = rootBundle.loadString('assets/example.json');
_loadEditor(context, jsonString);
}),
_buildListTile(context, 'With Large Document (10000+ lines)', () {
final nodes = List.generate(
10000,
(index) =>
paragraphNode(text: '$index ${generateRandomString(50)}'),
);
final editorState = EditorState(
document: Document(root: pageNode(children: nodes)),
);
final jsonString = Future.value(
jsonEncode(editorState.document.toJson()),
);
_loadEditor(context, jsonString);
}),
_buildListTile(context, 'With Example.html', () async {
final htmlString =
await rootBundle.loadString('assets/example.html');
Expand Down Expand Up @@ -315,3 +331,10 @@ class _HomePageState extends State<HomePage> {
}
}
}

String generateRandomString(int len) {
var r = Random();
return String.fromCharCodes(
List.generate(len, (index) => r.nextInt(33) + 89),
);
}
4 changes: 1 addition & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:example/home_page.dart';
import 'package:flutter/material.dart';

import 'package:flutter_localizations/flutter_localizations.dart';

import 'package:appflowy_editor/appflowy_editor.dart';

void main() {
runApp(const MyApp());
}
Expand Down
20 changes: 12 additions & 8 deletions example/lib/pages/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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) {
Expand All @@ -68,7 +71,7 @@ class Editor extends StatelessWidget {
child: _buildMobileEditor(
context,
editorState,
scrollController,
editorScrollController,
),
),
MobileToolbar(
Expand Down Expand Up @@ -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,
Expand All @@ -127,7 +130,8 @@ class Editor extends StatelessWidget {
};
return AppFlowyEditor(
editorState: editorState,
scrollController: scrollController,
shrinkWrap: true,
editorScrollController: editorScrollController,
blockComponentBuilders: customBlockComponentBuilders,
commandShortcutEvents: [
customToggleHighlightCommand(
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies:
universal_html: ^2.0.8
highlight: ^0.7.0
http: ^0.13.5
show_fps: ^1.0.6

dev_dependencies:
flutter_test:
Expand Down
119 changes: 102 additions & 17 deletions lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
@@ -1,35 +1,120 @@
{
"@@locale": "zh-CN",
"bold": "",
"bold": "粗体",
"@bold": {},
"bulletedList": "",
"bulletedList": "无序列表",
"@bulletedList": {},
"checkbox": "",
"checkbox": "选框",
"@checkbox": {},
"embedCode": "",
"embedCode": "代码块",
"@embedCode": {},
"heading1": "",
"heading1": "一级标题",
"@heading1": {},
"heading2": "",
"heading2": "二级标题",
"@heading2": {},
"heading3": "",
"heading3": "三级标题",
"@heading3": {},
"highlight": "",
"highlight": "高亮",
"@highlight": {},
"image": "",
"color": "颜色",
"@color": {},
"image": "图片",
"@image": {},
"italic": "",
"italic": "斜体",
"@italic": {},
"link": "",
"link": "链接",
"@link": {},
"numberedList": "",
"numberedList": "有序列表",
"@numberedList": {},
"quote": "",
"quote": "引文",
"@quote": {},
"strikethrough": "",
"strikethrough": "删除线",
"@strikethrough": {},
"text": "",
"text": "文本",
"@text": {},
"underline": "",
"@underline": {}
"underline": "下划线",
"@underline": {},
"fontColorDefault": "默认",
"@fontColorDefault": {},
"fontColorGray": "灰色",
"@fontColorGray": {},
"fontColorBrown": "棕色",
"@fontColorBrown": {},
"fontColorOrange": "橙色",
"@fontColorOrange": {},
"fontColorYellow": "黄色",
"@fontColorYellow": {},
"fontColorGreen": "绿色",
"@fontColorGreen": {},
"fontColorBlue": "蓝色",
"@fontColorBlue": {},
"fontColorPurple": "紫色",
"@fontColorPurple": {},
"fontColorPink": "粉红色",
"@fontColorPink": {},
"fontColorRed": "红色",
"@fontColorRed": {},
"backgroundColorDefault": "默认背景色",
"@backgroundColorDefault": {},
"backgroundColorGray": "灰色背景",
"@backgroundColorGray": {},
"backgroundColorBrown": "棕色背景",
"@backgroundColorBrown": {},
"backgroundColorOrange": "橙色背景",
"@backgroundColorOrange": {},
"backgroundColorYellow": "黄色背景",
"@backgroundColorYellow": {},
"backgroundColorGreen": "绿色背景",
"@backgroundColorGreen": {},
"backgroundColorBlue": "蓝色背景",
"@backgroundColorBlue": {},
"backgroundColorPurple": "紫色背景",
"@backgroundColorPurple": {},
"backgroundColorPink": "粉色背景",
"@backgroundColorPink": {},
"backgroundColorRed": "红色背景",
"@backgroundColorRed": {},
"done": "完成",
"cancel": "取消",
"tint1": "色调1",
"tint2": "色调2",
"tint3": "色调3",
"tint4": "色调4",
"tint5": "色调5",
"tint6": "色调6",
"tint7": "色调7",
"tint8": "色调8",
"tint9": "色调9",
"lightLightTint1": "紫色",
"lightLightTint2": "粉红色",
"lightLightTint3": "浅粉红色",
"lightLightTint4": "橙色",
"lightLightTint5": "黄色",
"lightLightTint6": "草绿色",
"lightLightTint7": "绿色",
"lightLightTint8": "水蓝色",
"lightLightTint9": "蓝色",
"urlHint": "URL",
"mobileHeading1": "一级标题",
"mobileHeading2": "二级标题",
"mobileHeading3": "三级标题",
"textColor": "文字颜色",
"backgroundColor": "背景颜色",
"addYourLink": "添加链接",
"openLink": "打开链接",
"copyLink": "复制链接",
"removeLink": "移除链接",
"editLink": "修改链接",
"linkText": "文字",
"linkTextHint": "请输入文字",
"linkAddressHint": "请输入URL",
"highlightColor": "高亮颜色",
"clearHighlightColor": "清除高亮颜色",
"customColor": "自定义颜色",
"hexValue": "十六进制值",
"opacity": "透明度",
"resetToDefaultColor": "重设为默认颜色",
"ltr": "自左至右",
"rtl": "自右至左",
"auto": "自动"
}
Loading

0 comments on commit f82a8d0

Please sign in to comment.