diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30714493d..e1f7d1385 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: "stable" - flutter-version: "3.22.0" + flutter-version: "3.27.0" cache: true - name: Run tests diff --git a/CHANGELOG.md b/CHANGELOG.md index abafdc9e5..6087df210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,62 @@ +## 5.0.0 + +- fix: export pdf set font not work by @Linij in https://github.com/AppFlowy-IO/appflowy-editor/pull/923 +- fix: \_deleteBackward deleteRange start must > 0 by @Linij in https://github.com/AppFlowy-IO/appflowy-editor/pull/928 +- chore: update device_info_plus to 11.0.0 by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/931 +- fix: html decoder ignores h4-h6 tags by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/932 +- fix: markdown parser doesn't recognize softline breaks by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/933 +- feat: select multiple lines with block selection style by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/936 +- feat: custom slice function by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/935 +- fix: use retain instead of insert/delete for same attr by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/937 +- fix: update migration guide by @emmanuel-ferdman in https://github.com/AppFlowy-IO/appflowy-editor/pull/929 +- fix: replace texts assertion by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/938 +- fix: links starting with 0 index lose href attribute after formating by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/947 +- fix: replace texts may result in incorrect afterSelection by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/952 +- fix: cancel block selection when tapping the editor on mobile by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/956 +- fix: highlight search match not scrolling document to reveal said match by @richardshiue in https://github.com/AppFlowy-IO/appflowy-editor/pull/954 +- fix: cursor height is inconsistent when the font size is smaller than the default text size by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/958 +- feat: exclude padding when highlight heading block by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/960 +- fix: move cursor up / down error by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/961 +- fix: table resizing when rect not rendered by @Xazin in https://github.com/AppFlowy-IO/appflowy-editor/pull/967 +- fix: Searching command with / using in18 by @Ahad-patel in https://github.com/AppFlowy-IO/appflowy-editor/pull/966 +- fix: cut collapsed table cell won't crash the editor by @saif-ellafi in https://github.com/AppFlowy-IO/appflowy-editor/pull/963 +- fix: deleting the last table being the last node of the document, places an empty node to avoid the editor to crash by @saif-ellafi in https://github.com/AppFlowy-IO/appflowy-editor/pull/951 +- fix: cross blocks format not reflected on the float toolbar by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/971 +- feat: support in memory transaction update by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/972 +- fix: editor now detects phone number and launches it by @ARYPROGRAMMER in https://github.com/AppFlowy-IO/appflowy-editor/pull/970 +- fix: ignore backspace on empty table cells to avoid editor crash by @saif-ellafi in https://github.com/AppFlowy-IO/appflowy-editor/pull/964 +- fix: hide the floating toolbar if no content is visible by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/976 +- fix: skip repeated key events when the slash menu is opening by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/978 +- fix: creating document from slash menu leaves text behind by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/980 +- fix: closing a ')' braket to create a link will erase a text following it to the end of a paragraph by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/983 +- fix: underscore works should not be interpreted in inline-code by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/984 +- feat: support customize supported node types for slash menu by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/982 +- chore: refactor html test by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/987 +- fix: issue #6808 of appflowy by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/986 +- fix: cross column deletion in the table by @Linij in https://github.com/AppFlowy-IO/appflowy-editor/pull/934 +- feat: add command shortcut keys to convert text to title by @Ahad-patel in https://github.com/AppFlowy-IO/appflowy-editor/pull/921 +- Fixed menu closing on some devices by @g-apparence in https://github.com/AppFlowy-IO/appflowy-editor/pull/941 +- feat: reset to the default inline code format logic by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/988 +- feat: add `partialSliced` to support partial sliced attributes by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/989 +- fix: shift+enter should wrap the line in list by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/990 +- fix: assertion error in auto_expand_editor example by @mikefaust-jm in https://github.com/AppFlowy-IO/appflowy-editor/pull/991 +- fix: all the text pasted from google doc will be applied inline link by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/993 +- fix: sougou IME issue on Windows by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/1000 +- feat: deep copy the node by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/995 +- fix: checking is mounted before updating the value of PropertyValueNotifier(#977) by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/997 +- feat: support text align in text-based blocks by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1002 +- feat: enable debug paint size for mobile drag handle by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1007 +- fix: out of text range while composing error by @kyungilcho in https://github.com/AppFlowy-IO/appflowy-editor/pull/979 +- fix: error format of TextEditingDeltaInsertion by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/1004 +- feat: clear selection extra info before inserting a new line by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1009 +- fix: enter after emoji will create a softbreak on mobile by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1010 +- feat: expose text span for text style builder by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1011 +- fix: using space bar to move the cursor not working on Android by @asjqkkkk in https://github.com/AppFlowy-IO/appflowy-editor/pull/1013 +- fix: unable to parse image if the image is inside the paragraph by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1012 +- fix: use jump to when cursor not rendered by @richardshiue in https://github.com/AppFlowy-IO/appflowy-editor/pull/1015 +- fix: check if scroll service is disposed before scrolling by @richardshiue in https://github.com/AppFlowy-IO/appflowy-editor/pull/1016 +- feat: support copy with indentPadding by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/1018 + ## 4.0.0 - feat: support dragging to reorder block by @LucasXu0 in [#887](https://github.com/AppFlowy-IO/appflowy-editor/pull/887) diff --git a/example/.gitignore b/example/.gitignore index a8e938c08..221b42254 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related diff --git a/example/lib/pages/customize_theme_for_editor.dart b/example/lib/pages/customize_theme_for_editor.dart index db21237de..6c22f2806 100644 --- a/example/lib/pages/customize_theme_for_editor.dart +++ b/example/lib/pages/customize_theme_for_editor.dart @@ -158,7 +158,7 @@ class _CustomizeThemeForEditorState extends State { : const EdgeInsets.symmetric(horizontal: 20), cursorColor: Colors.green, dragHandleColor: Colors.green, - selectionColor: Colors.green.withOpacity(0.5), + selectionColor: Colors.green.withValues(alpha: 0.5), textStyleConfiguration: TextStyleConfiguration( text: GoogleFonts.poppins( fontSize: 14.0, diff --git a/example/lib/pages/editor.dart b/example/lib/pages/editor.dart index 928c625bb..33e0a466b 100644 --- a/example/lib/pages/editor.dart +++ b/example/lib/pages/editor.dart @@ -130,7 +130,7 @@ class _EditorState extends State { child: Container( padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 12), decoration: BoxDecoration( - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), borderRadius: BorderRadius.only( topLeft: const Radius.circular(8), bottomLeft: UniversalPlatform.isMobile diff --git a/example/lib/pages/markdown_editor.dart b/example/lib/pages/markdown_editor.dart index e546654d5..e5370f767 100644 --- a/example/lib/pages/markdown_editor.dart +++ b/example/lib/pages/markdown_editor.dart @@ -18,7 +18,7 @@ class _MarkdownEditorState extends State { padding: const EdgeInsets.symmetric(horizontal: 16), cursorColor: Colors.transparent, cursorWidth: 0, - selectionColor: Colors.grey.withOpacity(0.3), + selectionColor: Colors.grey.withValues(alpha: 0.3), textStyleConfiguration: TextStyleConfiguration( lineHeight: 1.2, applyHeightToFirstAscent: true, diff --git a/example/macos/Runner/AppDelegate.swift b/example/macos/Runner/AppDelegate.swift index d53ef6437..b3c176141 100644 --- a/example/macos/Runner/AppDelegate.swift +++ b/example/macos/Runner/AppDelegate.swift @@ -1,9 +1,13 @@ import Cocoa import FlutterMacOS -@NSApplicationMain +@main class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } } diff --git a/lib/appflowy_editor.dart b/lib/appflowy_editor.dart index c7efc8910..88932f68a 100644 --- a/lib/appflowy_editor.dart +++ b/lib/appflowy_editor.dart @@ -1,5 +1,5 @@ /// AppFlowyEditor library -library appflowy_editor; +library; // core part, including document, node, selection, etc. export 'src/core/core.dart'; diff --git a/lib/src/editor/block_component/image_block_component/image_upload_widget.dart b/lib/src/editor/block_component/image_block_component/image_upload_widget.dart index f3415497d..3df97b1c7 100644 --- a/lib/src/editor/block_component/image_block_component/image_upload_widget.dart +++ b/lib/src/editor/block_component/image_block_component/image_upload_widget.dart @@ -117,7 +117,7 @@ class _UploadImageMenuState extends State { BoxShadow( blurRadius: 5, spreadRadius: 1, - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), ), ], // borderRadius: BorderRadius.circular(6.0), diff --git a/lib/src/editor/block_component/image_block_component/resizable_image.dart b/lib/src/editor/block_component/image_block_component/resizable_image.dart index db6989cb8..5d8e19dab 100644 --- a/lib/src/editor/block_component/image_block_component/resizable_image.dart +++ b/lib/src/editor/block_component/image_block_component/resizable_image.dart @@ -210,7 +210,7 @@ class _ResizableImageState extends State { child: Container( height: 40, decoration: BoxDecoration( - color: Colors.black.withOpacity(0.5), + color: Colors.black.withValues(alpha: 0.5), borderRadius: const BorderRadius.all( Radius.circular(5.0), ), diff --git a/lib/src/editor/editor_component/service/shortcuts/character/format_double_character/format_double_characters.dart b/lib/src/editor/editor_component/service/shortcuts/character/format_double_character/format_double_characters.dart index 20ac3633f..09ff371fd 100644 --- a/lib/src/editor/editor_component/service/shortcuts/character/format_double_character/format_double_characters.dart +++ b/lib/src/editor/editor_component/service/shortcuts/character/format_double_character/format_double_characters.dart @@ -92,9 +92,6 @@ bool handleFormatByWrappingWithDoubleCharacter({ case DoubleCharacterFormatStyle.strikethrough: style = 'strikethrough'; break; - default: - style = ''; - assert(false, 'Invalid format style'); } // if the text is already formatted, we should remove the format. diff --git a/lib/src/editor/editor_component/service/shortcuts/character/format_single_character/format_single_character.dart b/lib/src/editor/editor_component/service/shortcuts/character/format_single_character/format_single_character.dart index cdf484d35..97fefc5e3 100644 --- a/lib/src/editor/editor_component/service/shortcuts/character/format_single_character/format_single_character.dart +++ b/lib/src/editor/editor_component/service/shortcuts/character/format_single_character/format_single_character.dart @@ -185,9 +185,6 @@ bool handleFormatByWrappingWithSingleCharacter({ case FormatStyleByWrappingWithSingleChar.strikethrough: style = 'strikethrough'; break; - default: - style = ''; - assert(false, 'Invalid format style'); } // if the text is already formatted, we should remove the format. diff --git a/lib/src/editor/editor_component/service/shortcuts/command/open_links_command.dart b/lib/src/editor/editor_component/service/shortcuts/command/open_links_command.dart index d032a5502..c59800eb5 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command/open_links_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command/open_links_command.dart @@ -1,5 +1,4 @@ import 'package:appflowy_editor/appflowy_editor.dart'; -import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; /// Option/Alt + Shift + Enter: to open links @@ -27,13 +26,13 @@ KeyEventResult _openLinksHandler( // A set to store the links which should be opened final links = nodes .map((node) => node.delta) - .whereNotNull() + .nonNulls .expand( (node) => node.map( (op) => op.attributes?[AppFlowyRichTextKeys.href], ), ) - .whereNotNull() + .nonNulls .toSet(); for (final link in links) { diff --git a/lib/src/editor/editor_component/style/mobile_text_span_decorator_for_attribute.dart b/lib/src/editor/editor_component/style/mobile_text_span_decorator_for_attribute.dart index 804f1d4dc..1321f2c13 100644 --- a/lib/src/editor/editor_component/style/mobile_text_span_decorator_for_attribute.dart +++ b/lib/src/editor/editor_component/style/mobile_text_span_decorator_for_attribute.dart @@ -175,9 +175,11 @@ class _LinkEditFormState extends State { widget.hrefText.length, {BuiltInAttributeKey.href: null}, ); - await widget.editorState - .apply(transaction) - .whenComplete(() => Navigator.of(context).pop()); + await widget.editorState.apply(transaction).whenComplete(() { + if (context.mounted) { + Navigator.of(context).pop(); + } + }); }, ), TextButton( @@ -206,8 +208,12 @@ class _LinkEditFormState extends State { }, ); await widget.editorState.apply(transaction).whenComplete( - () => Navigator.of(context).pop(), - ); + () { + if (context.mounted) { + Navigator.of(context).pop(); + } + }, + ); } else if (textChanged && !addressChanged) { final transaction = widget.editorState.transaction ..replaceText( @@ -217,13 +223,21 @@ class _LinkEditFormState extends State { hrefTextTextEditingController.text, ); await widget.editorState.apply(transaction).whenComplete( - () => Navigator.of(context).pop(), - ); + () { + if (context.mounted) { + Navigator.of(context).pop(); + } + }, + ); } else if (!textChanged && addressChanged) { await widget.editorState.formatDelta(widget.selection, { AppFlowyRichTextKeys.href: hrefAddressTextEditingController.value.text, - }).whenComplete(() => Navigator.of(context).pop()); + }).whenComplete(() { + if (context.mounted) { + Navigator.of(context).pop(); + } + }); } else { Navigator.of(context).pop(); } diff --git a/lib/src/editor/find_replace_menu/find_menu_service.dart b/lib/src/editor/find_replace_menu/find_menu_service.dart index ffed696d5..25ad3449a 100644 --- a/lib/src/editor/find_replace_menu/find_menu_service.dart +++ b/lib/src/editor/find_replace_menu/find_menu_service.dart @@ -89,7 +89,7 @@ class FindReplaceMenu implements FindReplaceService { BoxShadow( blurRadius: 5, spreadRadius: 1, - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), ), ], borderRadius: BorderRadius.circular(6.0), diff --git a/lib/src/editor/find_replace_menu/find_replace_widget.dart b/lib/src/editor/find_replace_menu/find_replace_widget.dart index f6760fb61..4740af173 100644 --- a/lib/src/editor/find_replace_menu/find_replace_widget.dart +++ b/lib/src/editor/find_replace_menu/find_replace_widget.dart @@ -230,9 +230,11 @@ class _FindMenuState extends State { // will request focus, here's a workaround to request the // focus back to the findTextField Future.delayed(const Duration(milliseconds: 50), () { - FocusScope.of(context).requestFocus( - findTextFieldFocusNode, - ); + if (context.mounted) { + FocusScope.of(context).requestFocus( + findTextFieldFocusNode, + ); + } }); }, decoration: _buildInputDecoration( @@ -255,9 +257,11 @@ class _FindMenuState extends State { onPressed: () { // work around to request focus back to the input field Future.delayed(const Duration(milliseconds: 10), () { - FocusScope.of(context).requestFocus( - findTextFieldFocusNode, - ); + if (context.mounted) { + FocusScope.of(context).requestFocus( + findTextFieldFocusNode, + ); + } }); widget.searchService.navigateToMatch(moveUp: true); }, @@ -270,9 +274,11 @@ class _FindMenuState extends State { iconButtonKey: const Key('nextMatchButton'), onPressed: () { Future.delayed(const Duration(milliseconds: 10), () { - FocusScope.of(context).requestFocus( - findTextFieldFocusNode, - ); + if (context.mounted) { + FocusScope.of(context).requestFocus( + findTextFieldFocusNode, + ); + } }); widget.searchService.navigateToMatch(); }, @@ -400,9 +406,11 @@ class _ReplaceMenuState extends State { _replaceSelectedWord(); Future.delayed(const Duration(milliseconds: 50), () { - FocusScope.of(context).requestFocus( - replaceTextFieldFocusNode, - ); + if (context.mounted) { + FocusScope.of(context).requestFocus( + replaceTextFieldFocusNode, + ); + } }); }, decoration: _buildInputDecoration( diff --git a/lib/src/editor/selection_menu/selection_menu_widget.dart b/lib/src/editor/selection_menu/selection_menu_widget.dart index 16b7b3280..9816aeb32 100644 --- a/lib/src/editor/selection_menu/selection_menu_widget.dart +++ b/lib/src/editor/selection_menu/selection_menu_widget.dart @@ -343,7 +343,7 @@ class _SelectionMenuWidgetState extends State { BoxShadow( blurRadius: 5, spreadRadius: 1, - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), ), ], borderRadius: BorderRadius.circular(6.0), diff --git a/lib/src/editor/toolbar/desktop/items/utils/overlay_util.dart b/lib/src/editor/toolbar/desktop/items/utils/overlay_util.dart index 5e8822167..4890bc8d2 100644 --- a/lib/src/editor/toolbar/desktop/items/utils/overlay_util.dart +++ b/lib/src/editor/toolbar/desktop/items/utils/overlay_util.dart @@ -20,7 +20,7 @@ BoxDecoration buildOverlayDecoration(BuildContext context) { borderRadius: BorderRadius.circular(6), boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.2), + color: Colors.black.withValues(alpha: 0.2), blurRadius: 10, offset: const Offset(0, 2), ), diff --git a/lib/src/editor/toolbar/utils/color_generators.dart b/lib/src/editor/toolbar/utils/color_generators.dart index 338fbbb97..618ad8ae2 100644 --- a/lib/src/editor/toolbar/utils/color_generators.dart +++ b/lib/src/editor/toolbar/utils/color_generators.dart @@ -53,35 +53,35 @@ List generateTextColorOptions() { List generateHighlightColorOptions() { return [ ColorOption( - colorHex: Colors.grey.withOpacity(0.3).toHex(), + colorHex: Colors.grey.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorGray, ), ColorOption( - colorHex: Colors.brown.withOpacity(0.3).toHex(), + colorHex: Colors.brown.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorBrown, ), ColorOption( - colorHex: Colors.yellow.withOpacity(0.3).toHex(), + colorHex: Colors.yellow.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorYellow, ), ColorOption( - colorHex: Colors.green.withOpacity(0.3).toHex(), + colorHex: Colors.green.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorGreen, ), ColorOption( - colorHex: Colors.blue.withOpacity(0.3).toHex(), + colorHex: Colors.blue.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorBlue, ), ColorOption( - colorHex: Colors.purple.withOpacity(0.3).toHex(), + colorHex: Colors.purple.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorPurple, ), ColorOption( - colorHex: Colors.pink.withOpacity(0.3).toHex(), + colorHex: Colors.pink.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorPink, ), ColorOption( - colorHex: Colors.red.withOpacity(0.3).toHex(), + colorHex: Colors.red.withValues(alpha: 0.3).toHex(), name: AppFlowyEditorL10n.current.backgroundColorRed, ), ]; diff --git a/lib/src/editor/util/color_util.dart b/lib/src/editor/util/color_util.dart index 81bd65c96..2847e6448 100644 --- a/lib/src/editor/util/color_util.dart +++ b/lib/src/editor/util/color_util.dart @@ -49,6 +49,11 @@ extension ColorExtension on String { extension HexExtension on Color { String toHex() { - return '0x${value.toRadixString(16)}'; + final alpha = (a * 255).toInt().toRadixString(16).padLeft(2, '0'); + final red = (r * 255).toInt().toRadixString(16).padLeft(2, '0'); + final green = (g * 255).toInt().toRadixString(16).padLeft(2, '0'); + final blue = (b * 255).toInt().toRadixString(16).padLeft(2, '0'); + + return '0x$alpha$red$green$blue'.toLowerCase(); } } diff --git a/lib/src/extensions/color_extension.dart b/lib/src/extensions/color_extension.dart index b7b0578c0..41ebf0838 100644 --- a/lib/src/extensions/color_extension.dart +++ b/lib/src/extensions/color_extension.dart @@ -31,6 +31,11 @@ extension ColorExtension2 on Color { } String toRgbaString() { + final alpha = (a * 255).toInt(); + final red = (r * 255).toInt(); + final green = (g * 255).toInt(); + final blue = (b * 255).toInt(); + return 'rgba($red, $green, $blue, $alpha)'; } } diff --git a/lib/src/flutter/scrollable_helpers.dart b/lib/src/flutter/scrollable_helpers.dart index e6714fc70..9695a0302 100644 --- a/lib/src/flutter/scrollable_helpers.dart +++ b/lib/src/flutter/scrollable_helpers.dart @@ -141,7 +141,7 @@ class ScrollableDetails { /// /// The scroll velocity is controlled by the [velocityScalar]: /// -/// velocity = * [velocityScalar]. +/// velocity = <distance of overscroll> * [velocityScalar]. class EdgeDraggingAutoScroller { /// Creates a auto scroller that scrolls the [scrollable]. EdgeDraggingAutoScroller( @@ -166,7 +166,7 @@ class EdgeDraggingAutoScroller { /// The velocity scalar per pixel over scroll. /// /// It represents how the velocity scale with the over scroll distance. The - /// auto-scroll velocity = * velocityScalar. + /// auto-scroll velocity = <distance of overscroll> * velocityScalar. final double velocityScalar; late Rect _dragTargetRelatedToScrollOrigin; diff --git a/lib/src/plugins/html/html_document.dart b/lib/src/plugins/html/html_document.dart index 6c7c7995e..35ee5b32f 100644 --- a/lib/src/plugins/html/html_document.dart +++ b/lib/src/plugins/html/html_document.dart @@ -1,4 +1,4 @@ -library delta_markdown; +library; import 'dart:convert'; diff --git a/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart b/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart index 7bfc05d37..eb7291332 100644 --- a/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart +++ b/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart @@ -29,7 +29,7 @@ class DocumentMarkdownDecoder extends Converter { final document = Document.blank(); final nodes = mdNodes .map((e) => _parseNode(e)) - .whereNotNull() + .nonNulls .flattened .toList(growable: false); // avoid lazy evaluation if (nodes.isNotEmpty) { diff --git a/lib/src/plugins/markdown/document_markdown.dart b/lib/src/plugins/markdown/document_markdown.dart index f06e01efc..ab6d054b6 100644 --- a/lib/src/plugins/markdown/document_markdown.dart +++ b/lib/src/plugins/markdown/document_markdown.dart @@ -1,4 +1,4 @@ -library delta_markdown; +library; import 'dart:convert'; diff --git a/lib/src/render/color_menu/color_picker.dart b/lib/src/render/color_menu/color_picker.dart index 8fbed681b..268e94cd3 100644 --- a/lib/src/render/color_menu/color_picker.dart +++ b/lib/src/render/color_menu/color_picker.dart @@ -71,7 +71,7 @@ class _ColorPickerState extends State { BoxShadow( blurRadius: 5, spreadRadius: 1, - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), ), ], borderRadius: BorderRadius.circular(6.0), @@ -294,6 +294,11 @@ class _ColorPickerState extends State { extension ConvertToHex on Color { String toHex() { - return '0x${value.toRadixString(16)}'; + final alpha = (a * 255).toInt().toRadixString(16).padLeft(2, '0'); + final red = (r * 255).toInt().toRadixString(16).padLeft(2, '0'); + final green = (g * 255).toInt().toRadixString(16).padLeft(2, '0'); + final blue = (b * 255).toInt().toRadixString(16).padLeft(2, '0'); + + return '0x$alpha$red$green$blue'.toUpperCase(); } } diff --git a/lib/src/render/selection/cursor.dart b/lib/src/render/selection/cursor.dart index b7b0573ff..e4c6c4dc4 100644 --- a/lib/src/render/selection/cursor.dart +++ b/lib/src/render/selection/cursor.dart @@ -87,7 +87,7 @@ class CursorState extends State { return Container( width: size.width, height: size.height, - color: color.withOpacity(0.2), + color: color.withValues(alpha: 0.2), ); } } diff --git a/lib/src/render/selection/mobile_basic_handle.dart b/lib/src/render/selection/mobile_basic_handle.dart index b19d67189..f4cd724a6 100644 --- a/lib/src/render/selection/mobile_basic_handle.dart +++ b/lib/src/render/selection/mobile_basic_handle.dart @@ -121,7 +121,7 @@ class DragHandle extends _IDragHandle { if (debugPaintSizeEnabled) { child = ColoredBox( - color: Colors.red.withOpacity(0.5), + color: Colors.red.withValues(alpha: 0.5), child: child, ); } diff --git a/lib/src/service/context_menu/context_menu.dart b/lib/src/service/context_menu/context_menu.dart index 9af2070ab..5c31058a4 100644 --- a/lib/src/service/context_menu/context_menu.dart +++ b/lib/src/service/context_menu/context_menu.dart @@ -87,7 +87,7 @@ class ContextMenu extends StatelessWidget { BoxShadow( blurRadius: 5, spreadRadius: 1, - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), ), ], borderRadius: BorderRadius.circular(6.0), diff --git a/pubspec.yaml b/pubspec.yaml index ab67f966c..967510858 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,12 @@ name: "appflowy_editor" -version: 4.0.0 +version: 5.0.0 homepage: "https://github.com/AppFlowy-IO/appflowy-editor" environment: sdk: ">=3.4.0 <4.0.0" - flutter: ">=3.22.0" + flutter: ">=3.27.0" description: A highly customizable rich-text editor for Flutter. The AppFlowy Editor project for AppFlowy and beyond. @@ -19,7 +19,7 @@ dependencies: flutter: sdk: flutter flutter_svg: "^2.0.6" - html: "^0.15.0" + html: ^0.15.5 http: "^1.2.0" intl: "^0.19.0" keyboard_height_plugin: "^0.1.5" @@ -36,7 +36,7 @@ dependencies: url_launcher: "^6.1.11" dev_dependencies: - flutter_lints: "^4.0.0" + flutter_lints: ^5.0.0 flutter_localizations: sdk: flutter flutter_test: @@ -56,7 +56,6 @@ platforms: web: topics: - - ui - widgets - editor - appflowy diff --git a/test/mobile/toolbar/mobile/toolbar_items/color/text_and_background_color_tool_bar_item_test.dart b/test/mobile/toolbar/mobile/toolbar_items/color/text_and_background_color_tool_bar_item_test.dart index ff1a9518d..e852b7af2 100644 --- a/test/mobile/toolbar/mobile/toolbar_items/color/text_and_background_color_tool_bar_item_test.dart +++ b/test/mobile/toolbar/mobile/toolbar_items/color/text_and_background_color_tool_bar_item_test.dart @@ -94,7 +94,7 @@ void main() { return delta.whereType().every( (element) => element.attributes?[AppFlowyRichTextKeys.backgroundColor] == - Colors.red.withOpacity(0.3).toHex(), + Colors.red.withValues(alpha: 0.3).toHex(), ); }), true,