Skip to content

Commit 5e8f6a5

Browse files
LucasXu0hyj1204
andauthored
relicense appflowy editor (#1938)
* revert:"fix: remove keyword when click selection menu item" This reverts commit 5782dec. * revert(appflowy_editor):revert "feat: double asterisks/underscores to bold text" This reverts commit c0964fa. * revert(appflowy_editor):revert "fix: workaround infinity formatting" This reverts commit 6a902a2. The Appflowy folder under the frontend had been removed before reverting. * chore(appflow_editor):update test variable after reverting * chore(appflowy_editor): comment out the test for reverting * chore(appflowy_editor): update variable type after reverting * chore(appflowy_editor): remove unused import after reverting * feat(appflowy_editor): double asterisk to bold text * test(appflowy_editor): test double asterisk to bold text * fix(appflowy_editor): delete slash after a selection menu item is selected * test(appflowy_editor): test selection menu widget after clicking * feat(appflowy_editor): double asterisk to bold text and remove slash after clicking selection menu item (#1935) * feat(appflowy_editor): double asterisk to bold text * test(appflowy_editor): test double asterisk to bold text * fix(appflowy_editor): delete slash after a selection menu item is selected * test(appflowy_editor): test selection menu widget after clicking * feat(appflowy_editor): double underscore to bold text * test(appflowy_editor): test double underscore to bold text * chore(appflowy_editor): put checkbox testing back * chore: format code --------- Co-authored-by: Yijing Huang <[email protected]>
1 parent 1d28bed commit 5e8f6a5

File tree

21 files changed

+368
-465
lines changed

21 files changed

+368
-465
lines changed

frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/board/board_menu_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flowy_infra/image.dart';
77
import 'package:flutter/material.dart';
88

99
SelectionMenuItem boardMenuItem = SelectionMenuItem(
10-
name: () => LocaleKeys.document_plugins_referencedBoard.tr(),
10+
name: LocaleKeys.document_plugins_referencedBoard.tr(),
1111
icon: (editorState, onSelected) {
1212
return svgWidget(
1313
'editor/board',

frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/grid/grid_menu_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flowy_infra/image.dart';
77
import 'package:flutter/material.dart';
88

99
SelectionMenuItem gridMenuItem = SelectionMenuItem(
10-
name: () => LocaleKeys.document_plugins_referencedGrid.tr(),
10+
name: LocaleKeys.document_plugins_referencedGrid.tr(),
1111
icon: (editorState, onSelected) {
1212
return svgWidget(
1313
'editor/grid',

frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/horizontal_rule_node_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ShortcutEventHandler _insertHorzaontalRule = (editorState, event) {
3737
};
3838

3939
SelectionMenuItem horizontalRuleMenuItem = SelectionMenuItem(
40-
name: () => 'Horizontal rule',
40+
name: 'Horizontal rule',
4141
icon: (editorState, onSelected) => Icon(
4242
Icons.horizontal_rule,
4343
color: onSelected

frontend/appflowy_flutter/packages/appflowy_editor/example/lib/plugin/AI/auto_completion.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart';
66

77
SelectionMenuItem autoCompletionMenuItem = SelectionMenuItem(
8-
name: () => 'Auto generate content',
8+
name: 'Auto generate content',
99
icon: (editorState, onSelected) => Icon(
1010
Icons.rocket,
1111
size: 18.0,

frontend/appflowy_flutter/packages/appflowy_editor/example/lib/plugin/AI/continue_to_write.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:example/plugin/AI/text_robot.dart';
44
import 'package:flutter/material.dart';
55

66
SelectionMenuItem continueToWriteMenuItem = SelectionMenuItem(
7-
name: () => 'Continue To Write',
7+
name: 'Continue To Write',
88
icon: (editorState, onSelected) => Icon(
99
Icons.print,
1010
size: 18.0,

frontend/appflowy_flutter/packages/appflowy_editor/lib/src/core/legacy/built_in_attribute_keys.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class BuiltInAttributeKey {
3737
static String checkbox = 'checkbox';
3838
static String code = 'code';
3939
static String number = 'number';
40-
static String defaultFormating = 'defaultFormating';
4140

4241
static List<String> partialStyleKeys = [
4342
BuiltInAttributeKey.bold,

frontend/appflowy_flutter/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_item_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class _SelectionMenuItemWidgetState extends State<SelectionMenuItemWidget> {
4747
: MaterialStateProperty.all(Colors.transparent),
4848
),
4949
label: Text(
50-
widget.item.name(),
50+
widget.item.name,
5151
textAlign: TextAlign.left,
5252
style: TextStyle(
5353
color: (widget.isSelected || _onHover)

frontend/appflowy_flutter/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ List<SelectionMenuItem> get defaultSelectionMenuItems =>
156156
_defaultSelectionMenuItems;
157157
final List<SelectionMenuItem> _defaultSelectionMenuItems = [
158158
SelectionMenuItem(
159-
name: () => AppFlowyEditorLocalizations.current.text,
159+
name: AppFlowyEditorLocalizations.current.text,
160160
icon: (editorState, onSelected) =>
161161
_selectionMenuIcon('text', editorState, onSelected),
162162
keywords: ['text'],
@@ -165,7 +165,7 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
165165
},
166166
),
167167
SelectionMenuItem(
168-
name: () => AppFlowyEditorLocalizations.current.heading1,
168+
name: AppFlowyEditorLocalizations.current.heading1,
169169
icon: (editorState, onSelected) =>
170170
_selectionMenuIcon('h1', editorState, onSelected),
171171
keywords: ['heading 1, h1'],
@@ -174,7 +174,7 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
174174
},
175175
),
176176
SelectionMenuItem(
177-
name: () => AppFlowyEditorLocalizations.current.heading2,
177+
name: AppFlowyEditorLocalizations.current.heading2,
178178
icon: (editorState, onSelected) =>
179179
_selectionMenuIcon('h2', editorState, onSelected),
180180
keywords: ['heading 2, h2'],
@@ -183,7 +183,7 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
183183
},
184184
),
185185
SelectionMenuItem(
186-
name: () => AppFlowyEditorLocalizations.current.heading3,
186+
name: AppFlowyEditorLocalizations.current.heading3,
187187
icon: (editorState, onSelected) =>
188188
_selectionMenuIcon('h3', editorState, onSelected),
189189
keywords: ['heading 3, h3'],
@@ -192,14 +192,14 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
192192
},
193193
),
194194
SelectionMenuItem(
195-
name: () => AppFlowyEditorLocalizations.current.image,
195+
name: AppFlowyEditorLocalizations.current.image,
196196
icon: (editorState, onSelected) =>
197197
_selectionMenuIcon('image', editorState, onSelected),
198198
keywords: ['image'],
199199
handler: showImageUploadMenu,
200200
),
201201
SelectionMenuItem(
202-
name: () => AppFlowyEditorLocalizations.current.bulletedList,
202+
name: AppFlowyEditorLocalizations.current.bulletedList,
203203
icon: (editorState, onSelected) =>
204204
_selectionMenuIcon('bulleted_list', editorState, onSelected),
205205
keywords: ['bulleted list', 'list', 'unordered list'],
@@ -208,7 +208,7 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
208208
},
209209
),
210210
SelectionMenuItem(
211-
name: () => AppFlowyEditorLocalizations.current.numberedList,
211+
name: AppFlowyEditorLocalizations.current.numberedList,
212212
icon: (editorState, onSelected) =>
213213
_selectionMenuIcon('number', editorState, onSelected),
214214
keywords: ['numbered list', 'list', 'ordered list'],
@@ -217,7 +217,7 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
217217
},
218218
),
219219
SelectionMenuItem(
220-
name: () => AppFlowyEditorLocalizations.current.checkbox,
220+
name: AppFlowyEditorLocalizations.current.checkbox,
221221
icon: (editorState, onSelected) =>
222222
_selectionMenuIcon('checkbox', editorState, onSelected),
223223
keywords: ['todo list', 'list', 'checkbox list'],
@@ -226,7 +226,7 @@ final List<SelectionMenuItem> _defaultSelectionMenuItems = [
226226
},
227227
),
228228
SelectionMenuItem(
229-
name: () => AppFlowyEditorLocalizations.current.quote,
229+
name: AppFlowyEditorLocalizations.current.quote,
230230
icon: (editorState, onSelected) =>
231231
_selectionMenuIcon('quote', editorState, onSelected),
232232
keywords: ['quote', 'refer'],

frontend/appflowy_flutter/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_widget.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class SelectionMenuItem {
2020
required SelectionMenuItemHandler handler,
2121
}) {
2222
this.handler = (editorState, menuService, context) {
23-
_deleteToSlash(editorState);
23+
_deleteSlash(editorState);
2424
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
2525
handler(editorState, menuService, context);
2626
});
2727
};
2828
}
2929

30-
final String Function() name;
30+
final String name;
3131
final Widget Function(EditorState editorState, bool onSelected) icon;
3232

3333
/// Customizes keywords for item.
@@ -36,20 +36,23 @@ class SelectionMenuItem {
3636
final List<String> keywords;
3737
late final SelectionMenuItemHandler handler;
3838

39-
void _deleteToSlash(EditorState editorState) {
39+
void _deleteSlash(EditorState editorState) {
4040
final selectionService = editorState.service.selectionService;
4141
final selection = selectionService.currentSelection.value;
4242
final nodes = selectionService.currentSelectedNodes;
4343
if (selection != null && nodes.length == 1) {
4444
final node = nodes.first as TextNode;
4545
final end = selection.start.offset;
46-
final start = node.toPlainText().substring(0, end).lastIndexOf('/');
46+
final lastSlashIndex =
47+
node.toPlainText().substring(0, end).lastIndexOf('/');
48+
// delete all the texts after '/' along with '/'
4749
final transaction = editorState.transaction
4850
..deleteText(
4951
node,
50-
start,
51-
selection.start.offset - start,
52+
lastSlashIndex,
53+
end - lastSlashIndex,
5254
);
55+
5356
editorState.apply(transaction);
5457
}
5558
}
@@ -81,7 +84,7 @@ class SelectionMenuItem {
8184
updateSelection,
8285
}) {
8386
return SelectionMenuItem(
84-
name: () => name,
87+
name: name,
8588
icon: (editorState, onSelected) => Icon(
8689
iconData,
8790
color: onSelected

0 commit comments

Comments
 (0)