Skip to content

Commit

Permalink
Merge branch 'main' into feat-zhiya
Browse files Browse the repository at this point in the history
* main:
  chore: bump version 1.5.0 (AppFlowy-IO#551)
  feat: convert = and > to ⇒ (AppFlowy-IO#523)
  feat: support overriding i18n (AppFlowy-IO#550)
  feat: table html encoder and decoder added (AppFlowy-IO#449)
  • Loading branch information
q200892907 committed Oct 25, 2023
2 parents 812c62e + a573847 commit 016ab9f
Show file tree
Hide file tree
Showing 56 changed files with 789 additions and 165 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 1.5.0
* feat: enable toggling and canceling of formatting with shortcuts by @LucasXu0 in ([#528](https://github.com/AppFlowy-IO/appflowy-editor/pull/528))
* feat: disable the toolbar in the code block by @LucasXu0 in ([#534](https://github.com/AppFlowy-IO/appflowy-editor/pull/534))
* feat: refactor logic for converting color string to Color in background_color_mixin.dart by @LucasXu0 in ([#538](https://github.com/AppFlowy-IO/appflowy-editor/pull/538))
* feat: add an extra info parameter to the node by @LucasXu0 in ([#539](https://github.com/AppFlowy-IO/appflowy-editor/pull/539))
* feat: support parsing the nested list when exporting the document to markdown format by @LucasXu0 in ([#540](https://github.com/AppFlowy-IO/appflowy-editor/pull/540))
* feat: optimize editable features by @LucasXu0 in ([#541](https://github.com/AppFlowy-IO/appflowy-editor/pull/541))
* feat: table HTML encoder and decoder added by @alihassan143 in ([#449](https://github.com/AppFlowy-IO/appflowy-editor/pull/449))
* feat: support overriding i18n by @LucasXu0 in ([#550](https://github.com/AppFlowy-IO/appflowy-editor/pull/550))
* feat: convert = and > to ⇒ by @Gen1us1100 in ([#523](https://github.com/AppFlowy-IO/appflowy-editor/pull/523))
* fix: cursor blinks at the wrong location when inserting text by @LucasXu0 in ([#529](https://github.com/AppFlowy-IO/appflowy-editor/pull/529))
* fix: pinyin IME on Linux by @LucasXu0 in ([#531](https://github.com/AppFlowy-IO/appflowy-editor/pull/531))
* fix: unable to clear the style by toggling twice by @LucasXu0 in ([#532](https://github.com/AppFlowy-IO/appflowy-editor/pull/532))

## 1.4.4
* feat: support customizing error block by @LucasXu0 in ([#524](https://github.com/AppFlowy-IO/appflowy-editor/pull/524))
* feat: export JSON in mobile and update mobile_example.json by @hyj1204 in ([#515](https://github.com/AppFlowy-IO/appflowy-editor/pull/515))
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ and the Flutter guide for
* toolbar menu
* [Test Coverage](https://github.com/AppFlowy-IO/appflowy-editor/blob/main/documentation/testing.md) and ongoing maintenance by AppFlowy's core team and community of more than 1,000 builders

| Preview | Customize your own theme |
| ---------------------- | ------------------------ |
| ![Preview](documentation/images/preview.jpg) | ![Customize your own theme](documentation/images/theme.jpg) |

| Change the color of your text | Format your text |
| ---------------------- | ---------------------- |
| ![Color](documentation/images/color.jpg) | ![Format](documentation/images/format.jpg) |


## Getting Started

Add the AppFlowy editor [Flutter package](https://docs.flutter.dev/development/packages-and-plugins/using-packages) to your environment.
Expand Down
Binary file added documentation/images/color.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/format.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/preview.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/images/theme.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/appflowy_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export 'src/editor/block_component/rich_text/default_selectable_mixin.dart';
// editor part, including editor component, block component, etc.
export 'src/editor/editor.dart';
export 'src/editor/find_replace_menu/find_and_replace.dart';
export 'src/editor/l10n/appflowy_editor_l10n.dart';
export 'src/editor/selection_menu/selection_menu.dart';
// editor state
export 'src/editor_state.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';

SelectionMenuItem dividerMenuItem = SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.divider,
name: AppFlowyEditorL10n.current.divider,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
icon: Icons.horizontal_rule,
isSelected: isSelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
height: 36,
child: TabBar(
tabs: [
Tab(text: AppFlowyEditorLocalizations.current.uploadImage),
Tab(text: AppFlowyEditorLocalizations.current.urlImage),
Tab(text: AppFlowyEditorL10n.current.uploadImage),
Tab(text: AppFlowyEditorL10n.current.urlImage),
],
labelColor: widget.headerColor,
unselectedLabelColor: Colors.grey,
Expand Down Expand Up @@ -204,7 +204,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {

Widget _buildInvalidLinkText() {
return Text(
AppFlowyEditorLocalizations.current.incorrectLink,
AppFlowyEditorL10n.current.incorrectLink,
style: const TextStyle(color: Colors.red, fontSize: 12),
);
}
Expand Down Expand Up @@ -240,7 +240,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
}
},
child: Text(
AppFlowyEditorLocalizations.current.upload,
AppFlowyEditorL10n.current.upload,
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
fontSize: 14.0,
Expand Down Expand Up @@ -339,7 +339,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
),
const SizedBox(height: 8.0),
Text(
AppFlowyEditorLocalizations.current.chooseImage,
AppFlowyEditorL10n.current.chooseImage,
style: const TextStyle(
fontSize: 14.0,
color: Color(0xff00BCF0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class _ResizableImageState extends State<ResizableImage> {
SizedBox.fromSize(
size: const Size(10, 10),
),
Text(AppFlowyEditorLocalizations.current.loading),
Text(AppFlowyEditorL10n.current.loading),
],
),
);
Expand All @@ -163,7 +163,7 @@ class _ResizableImageState extends State<ResizableImage> {
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
border: Border.all(width: 1, color: Colors.black),
),
child: Text(AppFlowyEditorLocalizations.current.imageLoadFailed),
child: Text(AppFlowyEditorL10n.current.imageLoadFailed),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final Map<String, BlockComponentBuilder> standardBlockComponentBuilderMap = {
ParagraphBlockKeys.type: ParagraphBlockComponentBuilder(
configuration: standardBlockComponentConfiguration.copyWith(
placeholderText: (_) => PlatformExtension.isDesktopOrWeb
? AppFlowyEditorLocalizations.current.slashPlaceHolder
? AppFlowyEditorL10n.current.slashPlaceHolder
: ' ',
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/overlay_util.dart';
import 'package:appflowy_editor/src/editor/block_component/table_block_component/util.dart';
import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/overlay_util.dart';
import 'package:flutter/material.dart';

void showActionMenu(
BuildContext context,
Expand Down Expand Up @@ -41,8 +41,8 @@ void showActionMenu(
_menuItem(
context,
dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colAddAfter
: AppFlowyEditorLocalizations.current.rowAddAfter,
? AppFlowyEditorL10n.current.colAddAfter
: AppFlowyEditorL10n.current.rowAddAfter,
dir == TableDirection.col
? Icons.last_page
: Icons.vertical_align_bottom, () {
Expand All @@ -52,8 +52,8 @@ void showActionMenu(
_menuItem(
context,
dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colAddBefore
: AppFlowyEditorLocalizations.current.rowAddBefore,
? AppFlowyEditorL10n.current.colAddBefore
: AppFlowyEditorL10n.current.rowAddBefore,
dir == TableDirection.col
? Icons.first_page
: Icons.vertical_align_top, () {
Expand All @@ -63,24 +63,24 @@ void showActionMenu(
_menuItem(
context,
dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colRemove
: AppFlowyEditorLocalizations.current.rowRemove,
? AppFlowyEditorL10n.current.colRemove
: AppFlowyEditorL10n.current.rowRemove,
Icons.delete, () {
TableActions.delete(node, position, editorState, dir);
dismissOverlay();
}),
_menuItem(
context,
dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colDuplicate
: AppFlowyEditorLocalizations.current.rowDuplicate,
? AppFlowyEditorL10n.current.colDuplicate
: AppFlowyEditorL10n.current.rowDuplicate,
Icons.content_copy, () {
TableActions.duplicate(node, position, editorState, dir);
dismissOverlay();
}),
_menuItem(
context,
AppFlowyEditorLocalizations.current.backgroundColor,
AppFlowyEditorL10n.current.backgroundColor,
Icons.format_color_fill,
() {
final cell = dir == TableDirection.col
Expand Down Expand Up @@ -112,8 +112,8 @@ void showActionMenu(
_menuItem(
context,
dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colClear
: AppFlowyEditorLocalizations.current.rowClear,
? AppFlowyEditorL10n.current.colClear
: AppFlowyEditorL10n.current.rowClear,
Icons.clear, () {
TableActions.clear(node, position, editorState, dir);
dismissOverlay();
Expand Down Expand Up @@ -180,14 +180,14 @@ void _showColorMenu(
left: left,
builder: (context) {
return ColorPicker(
title: AppFlowyEditorLocalizations.current.highlightColor,
title: AppFlowyEditorL10n.current.highlightColor,
selectedColorHex: selectedColorHex,
colorOptions: generateHighlightColorOptions(),
onSubmittedColorHex: (color) {
action(color);
dismissOverlay();
},
resetText: AppFlowyEditorLocalizations.current.clearHighlightColor,
resetText: AppFlowyEditorL10n.current.clearHighlightColor,
resetIconName: 'clear_highlight_color',
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class _TableBlockComponentWidgetState extends State<TableBlockComponentWidget>
}

SelectionMenuItem tableMenuItem = SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.table,
name: AppFlowyEditorL10n.current.table,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
icon: Icons.table_view,
isSelected: isSelected,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
export 'insert_newline.dart';
export 'slash_command.dart';
export 'markdown_syntax_character_shortcut_events.dart';

export 'format_single_character/format_single_character.dart';
export 'format_single_character/format_italic.dart';
export 'format_single_character/format_code.dart';
export 'format_single_character/format_strikethrough.dart';

export 'format_double_characters/format_double_characters.dart';
export 'format_double_characters/format_bold.dart';
export 'format_double_characters/format_strikethrough.dart';
export 'format_double_characters/format_double_characters.dart';
export 'format_double_characters/format_double_hyphen.dart';
export 'format_double_characters/format_equal_greater_character.dart';
export 'format_double_characters/format_strikethrough.dart';
export 'format_single_character/format_code.dart';
export 'format_single_character/format_italic.dart';
export 'format_single_character/format_single_character.dart';
export 'format_single_character/format_strikethrough.dart';
export 'insert_newline.dart';
export 'markdown_syntax_character_shortcut_events.dart';
export 'slash_command.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:appflowy_editor/appflowy_editor.dart';

const _greater = '>';
const _equals = '=';
const _arrow = '⇒';

/// format '=' + '>' into an ⇒
///
/// - support
/// - desktop
/// - mobile
/// - web
///
final CharacterShortcutEvent formatGreaterEqual = CharacterShortcutEvent(
key: 'format = + > into ⇒',
character: _greater,
handler: (editorState) async => handleEqualGreaterReplacement(
editorState: editorState,
character: _greater,
replacement: _arrow,
),
);

// TODO(Xazin): Combine two character replacement methods into
// a helper function
Future<bool> handleEqualGreaterReplacement({
required EditorState editorState,
required String character,
required String replacement,
}) async {
assert(character.length == 1);

Selection? selection = editorState.selection;
if (selection == null) {
return false;
}

if (!selection.isCollapsed) {
await editorState.deleteSelection(selection);
}

selection = editorState.selection;
if (selection == null) {
return false;
}

final node = editorState.getNodeAtPath(selection.end.path);
final delta = node?.delta;
if (node == null || delta == null || delta.isEmpty) {
return false;
}

if (selection.end.offset > 0) {
final plain = delta.toPlainText();

final previousCharacter = plain[selection.end.offset - 1];
if (previousCharacter != _equals) {
return false;
}

final replace = editorState.transaction
..replaceText(
node,
selection.end.offset - 1,
1,
_arrow,
);

await editorState.apply(replace);

return true;
}

return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ final List<CharacterShortcutEvent> markdownSyntaxShortcutEvents = [

// format -- into em dash
formatDoubleHyphenEmDash,
// format = + > into ⇒
formatGreaterEqual,
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';

import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/gestures.dart';

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -52,7 +51,7 @@ TextSpan mobileTextSpanDecoratorForAttribute(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppFlowyEditorLocalizations.current.editLink),
title: Text(AppFlowyEditorL10n.current.editLink),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4),
),
Expand Down Expand Up @@ -122,12 +121,12 @@ class _LinkEditFormState extends State<LinkEditForm> {
keyboardType: TextInputType.text,
validator: (value) {
if (value == null || value.isEmpty) {
return AppFlowyEditorLocalizations.current.linkTextHint;
return AppFlowyEditorL10n.current.linkTextHint;
}
return null;
},
decoration: InputDecoration(
hintText: AppFlowyEditorLocalizations.current.linkText,
hintText: AppFlowyEditorL10n.current.linkText,
suffixIcon: IconButton(
icon: const Icon(
Icons.clear_rounded,
Expand All @@ -143,12 +142,12 @@ class _LinkEditFormState extends State<LinkEditForm> {
keyboardType: TextInputType.url,
validator: (value) {
if (value == null || value.isEmpty) {
return AppFlowyEditorLocalizations.current.linkAddressHint;
return AppFlowyEditorL10n.current.linkAddressHint;
}
return null;
},
decoration: InputDecoration(
hintText: AppFlowyEditorLocalizations.current.urlHint,
hintText: AppFlowyEditorL10n.current.urlHint,
suffixIcon: IconButton(
icon: const Icon(
Icons.clear_rounded,
Expand All @@ -164,7 +163,7 @@ class _LinkEditFormState extends State<LinkEditForm> {
children: [
TextButton(
child: Text(
AppFlowyEditorLocalizations.current.removeLink,
AppFlowyEditorL10n.current.removeLink,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onPressed: () async {
Expand All @@ -184,7 +183,7 @@ class _LinkEditFormState extends State<LinkEditForm> {
style: TextButton.styleFrom(
textStyle: Theme.of(context).textTheme.labelLarge,
),
child: Text(AppFlowyEditorLocalizations.current.done),
child: Text(AppFlowyEditorL10n.current.done),
onPressed: () async {
if (_formKey.currentState!.validate()) {
final bool textChanged =
Expand Down
Loading

0 comments on commit 016ab9f

Please sign in to comment.