diff --git a/example/android/build.gradle b/example/android/build.gradle index 3cdaac958..e06c40a41 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.8.0' repositories { google() mavenCentral() diff --git a/example/assets/images/icon.jpeg b/example/assets/images/icon.jpeg new file mode 100644 index 000000000..a5ca96872 Binary files /dev/null and b/example/assets/images/icon.jpeg differ diff --git a/example/assets/images/icon.png b/example/assets/images/icon.png deleted file mode 100644 index 95e504908..000000000 Binary files a/example/assets/images/icon.png and /dev/null differ diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index cc4822906..eb78dcb5a 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -68,7 +68,6 @@ EA2F6824C2F8DF616F38D702 /* Pods-Runner.release.xcconfig */, 8ED982CC43DE110A1567B441 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -359,14 +358,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 446D3AAR7E; + DEVELOPMENT_TEAM = KD48NC6JW7; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = io.appflowy.editor; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -488,14 +487,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 446D3AAR7E; + DEVELOPMENT_TEAM = KD48NC6JW7; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = io.appflowy.editor; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -511,14 +510,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 446D3AAR7E; + DEVELOPMENT_TEAM = KD48NC6JW7; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = io.appflowy.editor; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index f3ef8da90..60a561945 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -1,55 +1,55 @@ - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Example - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - example - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - - LSApplicationQueriesSchemes - - https - - - \ No newline at end of file + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Example + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSApplicationQueriesSchemes + + https + + LSRequiresIPhoneOS + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 70130e80f..d25bb04a0 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -83,7 +83,8 @@ class _HomePageState extends State { extendBodyBehindAppBar: PlatformExtension.isDesktopOrWeb, drawer: _buildDrawer(context), appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, + backgroundColor: const Color.fromARGB(255, 134, 46, 247), + foregroundColor: Colors.white, surfaceTintColor: Colors.transparent, title: const Text('AppFlowy Editor'), ), @@ -100,7 +101,7 @@ class _HomePageState extends State { padding: EdgeInsets.zero, margin: EdgeInsets.zero, child: Image.asset( - 'assets/images/icon.png', + 'assets/images/icon.jpeg', fit: BoxFit.fill, ), ), diff --git a/example/lib/pages/editor.dart b/example/lib/pages/editor.dart index 06b41bdd6..2d9df82bf 100644 --- a/example/lib/pages/editor.dart +++ b/example/lib/pages/editor.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:appflowy_editor/appflowy_editor.dart'; +import 'package:example/pages/mobile_editor.dart'; import 'package:flutter/material.dart'; class Editor extends StatelessWidget { @@ -65,30 +66,9 @@ class Editor extends StatelessWidget { ), ); } else if (PlatformExtension.isMobile) { - return Column( - children: [ - Expanded( - child: _buildMobileEditor( - context, - editorState, - editorScrollController, - ), - ), - MobileToolbar( - editorState: editorState, - toolbarItems: [ - textDecorationMobileToolbarItem, - buildTextAndBackgroundColorMobileToolbarItem(), - headingMobileToolbarItem, - todoListMobileToolbarItem, - listMobileToolbarItem, - linkMobileToolbarItem, - quoteMobileToolbarItem, - dividerMobileToolbarItem, - codeMobileToolbarItem, - ], - ), - ], + return MobileEditor( + editorState: editorState, + onEditorStateChange: onEditorStateChange, ); } } @@ -99,18 +79,6 @@ class Editor extends StatelessWidget { ); } - Widget _buildMobileEditor( - BuildContext context, - EditorState editorState, - EditorScrollController? editorScrollController, - ) { - return AppFlowyEditor( - editorStyle: const EditorStyle.mobile(), - editorState: editorState, - editorScrollController: editorScrollController, - ); - } - Widget _buildDesktopEditor( BuildContext context, EditorState editorState, diff --git a/example/lib/pages/mobile_editor.dart b/example/lib/pages/mobile_editor.dart new file mode 100644 index 000000000..61a9e8128 --- /dev/null +++ b/example/lib/pages/mobile_editor.dart @@ -0,0 +1,141 @@ +import 'package:appflowy_editor/appflowy_editor.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class MobileEditor extends StatefulWidget { + const MobileEditor({ + super.key, + required this.editorState, + required this.onEditorStateChange, + this.editorStyle, + }); + + final EditorState editorState; + final EditorStyle? editorStyle; + final void Function(EditorState editorState) onEditorStateChange; + + @override + State createState() => _MobileEditorState(); +} + +class _MobileEditorState extends State { + EditorState get editorState => widget.editorState; + + late final EditorScrollController editorScrollController; + + late EditorStyle editorStyle; + late Map blockComponentBuilders; + + @override + void initState() { + super.initState(); + + // customize the log configuration + editorState.logConfiguration + ..handler = debugPrint + ..level = LogLevel.off; + + // listen to editor state change + editorState.transactionStream.listen((event) { + if (event.$1 == TransactionTime.after) { + widget.onEditorStateChange(editorState); + } + }); + + editorScrollController = EditorScrollController( + editorState: editorState, + shrinkWrap: false, + ); + + editorStyle = _buildMobileEditorStyle(); + blockComponentBuilders = _buildBlockComponentBuilders(); + } + + @override + void reassemble() { + super.reassemble(); + + editorStyle = _buildMobileEditorStyle(); + blockComponentBuilders = _buildBlockComponentBuilders(); + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + // build appflowy editor + Expanded( + child: AppFlowyEditor( + editorStyle: editorStyle, + editorState: editorState, + editorScrollController: editorScrollController, + blockComponentBuilders: blockComponentBuilders, + // showcase 3: customize the header and footer. + header: Image.asset( + 'assets/images/icon.jpeg', + fit: BoxFit.fitWidth, + height: 100, + ), + footer: const SizedBox( + height: 100, + ), + ), + ), + // build mobile toolbar + MobileToolbar( + editorState: editorState, + toolbarItems: [ + textDecorationMobileToolbarItem, + buildTextAndBackgroundColorMobileToolbarItem(), + headingMobileToolbarItem, + todoListMobileToolbarItem, + listMobileToolbarItem, + linkMobileToolbarItem, + quoteMobileToolbarItem, + dividerMobileToolbarItem, + codeMobileToolbarItem, + ], + ), + ], + ); + } + + // showcase 1: customize the editor style. + EditorStyle _buildMobileEditorStyle() { + return EditorStyle.mobile( + cursorColor: Colors.blue, + selectionColor: Colors.blue.shade200, + textStyleConfiguration: TextStyleConfiguration( + text: GoogleFonts.poppins( + fontSize: 14, + color: Colors.black, + ), + code: GoogleFonts.badScript(), + ), + padding: const EdgeInsets.symmetric(horizontal: 14.0), + ); + } + + // showcase 2: customize the block style + Map _buildBlockComponentBuilders() { + final map = { + ...standardBlockComponentBuilderMap, + }; + // customize the heading block component + final levelToFontSize = [ + 24.0, + 22.0, + 20.0, + 18.0, + 16.0, + 14.0, + ]; + map[HeadingBlockKeys.type] = HeadingBlockComponentBuilder( + textStyleBuilder: (level) => GoogleFonts.poppins( + fontSize: levelToFontSize.elementAtOrNull(level - 1) ?? 14.0, + fontWeight: FontWeight.w600, + ), + ); + return map; + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0fa366257..7de9b8023 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -69,7 +69,7 @@ flutter: assets: - assets/example.json - assets/example.html - - assets/images/icon.png + - assets/images/icon.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware diff --git a/lib/src/editor/block_component/heading_block_component/heading_block_component.dart b/lib/src/editor/block_component/heading_block_component/heading_block_component.dart index 38a78226c..86fafc3a8 100644 --- a/lib/src/editor/block_component/heading_block_component/heading_block_component.dart +++ b/lib/src/editor/block_component/heading_block_component/heading_block_component.dart @@ -144,11 +144,14 @@ class _HeadingBlockComponentWidgetState node: widget.node, editorState: editorState, textAlign: alignment?.toTextAlign, - textSpanDecorator: (textSpan) => - textSpan.updateTextStyle(textStyle).updateTextStyle( - widget.textStyleBuilder?.call(level) ?? - defaultTextStyle(level), - ), + textSpanDecorator: (textSpan) { + var result = textSpan.updateTextStyle(textStyle); + result = result.updateTextStyle( + widget.textStyleBuilder?.call(level) ?? + defaultTextStyle(level), + ); + return result; + }, placeholderText: placeholderText, placeholderTextSpanDecorator: (textSpan) => textSpan .updateTextStyle( diff --git a/lib/src/editor/block_component/standard_block_components.dart b/lib/src/editor/block_component/standard_block_components.dart index c74b81c35..b3165e2c5 100644 --- a/lib/src/editor/block_component/standard_block_components.dart +++ b/lib/src/editor/block_component/standard_block_components.dart @@ -7,8 +7,9 @@ final Map standardBlockComponentBuilderMap = { PageBlockKeys.type: PageBlockComponentBuilder(), ParagraphBlockKeys.type: TextBlockComponentBuilder( configuration: standardBlockComponentConfiguration.copyWith( - placeholderText: (_) => - AppFlowyEditorLocalizations.current.slashPlaceHolder, + placeholderText: (_) => PlatformExtension.isDesktopOrWeb + ? AppFlowyEditorLocalizations.current.slashPlaceHolder + : ' ', ), ), TodoListBlockKeys.type: TodoListBlockComponentBuilder( diff --git a/lib/src/editor/editor_component/entry/page_block_component.dart b/lib/src/editor/editor_component/entry/page_block_component.dart index 303300220..fd0e0443f 100644 --- a/lib/src/editor/editor_component/entry/page_block_component.dart +++ b/lib/src/editor/editor_component/entry/page_block_component.dart @@ -54,17 +54,19 @@ class PageBlockComponent extends BlockComponentStatelessWidget { return Builder( builder: (context) { editorState.updateAutoScroller(Scrollable.of(context)); - return Padding( - padding: editorState.editorStyle.padding, - child: Column( - children: [ - if (header != null) header!, - ...items - .map((e) => editorState.renderer.build(context, e)) - .toList(), - if (footer != null) footer!, - ], - ), + return Column( + children: [ + if (header != null) header!, + ...items + .map( + (e) => Padding( + padding: editorState.editorStyle.padding, + child: editorState.renderer.build(context, e), + ), + ) + .toList(), + if (footer != null) footer!, + ], ); }, ); @@ -75,16 +77,19 @@ class PageBlockComponent extends BlockComponentStatelessWidget { return ScrollablePositionedList.builder( shrinkWrap: scrollController.shrinkWrap, - padding: editorState.editorStyle.padding, + // padding: editorState.editorStyle.padding, scrollDirection: Axis.vertical, itemCount: items.length + extentCount, itemBuilder: (context, index) { editorState.updateAutoScroller(Scrollable.of(context)); if (header != null && index == 0) return header!; if (footer != null && index == items.length + 1) return footer!; - return editorState.renderer.build( - context, - items[index - (header != null ? 1 : 0)], + return Padding( + padding: editorState.editorStyle.padding, + child: editorState.renderer.build( + context, + items[index - (header != null ? 1 : 0)], + ), ); }, itemScrollController: scrollController.itemScrollController, diff --git a/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart b/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart index fddf1d277..246e98015 100644 --- a/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart +++ b/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart @@ -416,6 +416,7 @@ class _MobileSelectionServiceWidgetState rect: rect, showLeftHandler: showLeftHandler, showRightHandler: showRightHandler, + handlerColor: editorState.editorStyle.cursorColor, ), ); _selectionAreas.add(overlay); diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_down_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_down_command.dart index 067bffd80..acf3ebe06 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_down_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_down_command.dart @@ -24,11 +24,6 @@ final CommandShortcutEvent moveCursorDownCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _moveCursorDownCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'arrow down key is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - final selection = editorState.selection; if (selection == null) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_left_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_left_command.dart index de27d0589..21d8383a7 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_left_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_left_command.dart @@ -26,10 +26,6 @@ final CommandShortcutEvent moveCursorLeftCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _arrowLeftCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'arrow left key is not supported on mobile platform.'); - return KeyEventResult.ignored; - } if (isRTL(editorState)) { editorState.moveCursorBackward(SelectionMoveRange.character); } else { @@ -48,10 +44,6 @@ final CommandShortcutEvent moveCursorToBeginCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _moveCursorToBeginCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'arrow left key is not supported on mobile platform.'); - return KeyEventResult.ignored; - } if (isRTL(editorState)) { editorState.moveCursorBackward(SelectionMoveRange.line); } else { diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_right_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_right_command.dart index 2af20116b..4aea0f98d 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_right_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_right_command.dart @@ -26,10 +26,6 @@ final CommandShortcutEvent moveCursorRightCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _arrowRightCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'arrow right key is not supported on mobile platform.'); - return KeyEventResult.ignored; - } if (isRTL(editorState)) { editorState.moveCursorForward(SelectionMoveRange.character); } else { @@ -48,10 +44,6 @@ final CommandShortcutEvent moveCursorToEndCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _moveCursorToEndCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'arrow right key is not supported on mobile platform.'); - return KeyEventResult.ignored; - } if (isRTL(editorState)) { editorState.moveCursorForward(SelectionMoveRange.line); } else { diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_up_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_up_command.dart index 88c053d91..6035e39a9 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_up_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/arrow_up_command.dart @@ -24,11 +24,6 @@ final CommandShortcutEvent moveCursorUpCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _moveCursorUpCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'arrow up key is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - final selection = editorState.selection; if (selection == null) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/copy_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/copy_command.dart index 55a67f541..c89ff0285 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/copy_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/copy_command.dart @@ -15,12 +15,7 @@ final CommandShortcutEvent copyCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _copyCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'copyCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - - var selection = editorState.selection?.normalized; + final selection = editorState.selection?.normalized; if (selection == null || selection.isCollapsed) { return KeyEventResult.ignored; } diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/cut_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/cut_command.dart index 46a9f4cfe..c82df5bf0 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/cut_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/cut_command.dart @@ -15,11 +15,6 @@ final CommandShortcutEvent cutCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _cutCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'cutCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - // plain text. handleCut(editorState); return KeyEventResult.handled; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/end_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/end_command.dart index 6ce6660fe..4e174369c 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/end_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/end_command.dart @@ -15,10 +15,6 @@ final CommandShortcutEvent endCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _endCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'endCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } final scrollService = editorState.service.scrollService; if (scrollService == null) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/escape_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/escape_command.dart index b872d867b..0c95486c5 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/escape_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/escape_command.dart @@ -14,10 +14,7 @@ final CommandShortcutEvent exitEditingCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _exitEditingCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'exitEditingCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } editorState.selection = null; + editorState.service.keyboardService?.closeKeyboard(); return KeyEventResult.handled; }; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/home_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/home_command.dart index 77f00168d..d40ccaf0d 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/home_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/home_command.dart @@ -15,10 +15,6 @@ final CommandShortcutEvent homeCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _homeCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'homeCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } final scrollService = editorState.service.scrollService; if (scrollService == null) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/markdown_commands.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/markdown_commands.dart index bb4b2e0e9..1e39c2655 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/markdown_commands.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/markdown_commands.dart @@ -59,11 +59,6 @@ KeyEventResult _toggleAttribute( EditorState editorState, String key, ) { - if (PlatformExtension.isMobile) { - assert(false, 'toggle attribute is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - final selection = editorState.selection; if (selection == null) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_link_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_link_command.dart index 4f4a5229e..dd72aa298 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_link_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_link_command.dart @@ -15,11 +15,6 @@ final CommandShortcutEvent openInlineLinkCommand = CommandShortcutEvent( KeyEventResult _openInlineLink( EditorState editorState, ) { - if (PlatformExtension.isMobile) { - assert(false, 'open inline link is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - //TODO:If selection is collapsed, isHref is false. final selection = editorState.selection; if (selection == null || selection.isCollapsed) { diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_links_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_links_command.dart index e45662e96..d5ef4bd25 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_links_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/open_links_command.dart @@ -16,11 +16,6 @@ final CommandShortcutEvent openLinksCommand = CommandShortcutEvent( KeyEventResult _openLinksHandler( EditorState editorState, ) { - if (PlatformExtension.isMobile) { - assert(false, 'open links is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - final selection = editorState.selection; if (selection == null || selection.isCollapsed) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/page_down_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/page_down_command.dart index 86f26465f..9dd09e1be 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/page_down_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/page_down_command.dart @@ -16,10 +16,6 @@ final CommandShortcutEvent pageDownCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _pageUpCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'pageDownCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } final scrollService = editorState.service.scrollService; if (scrollService == null) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/paste_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/paste_command.dart index a81b21e76..5ca02b256 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/paste_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/paste_command.dart @@ -30,14 +30,6 @@ final CommandShortcutEvent pasteTextWithoutFormattingCommand = CommandShortcutEventHandler _pasteTextWithoutFormattingCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert( - false, - 'pasteTextWithoutFormattingCommand is not supported on mobile platform.', - ); - return KeyEventResult.ignored; - } - final selection = editorState.selection; if (selection == null) { return KeyEventResult.ignored; @@ -56,11 +48,6 @@ CommandShortcutEventHandler _pasteTextWithoutFormattingCommandHandler = }; CommandShortcutEventHandler _pasteCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'pasteCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } - final selection = editorState.selection; if (selection == null) { return KeyEventResult.ignored; diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/select_all_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/select_all_command.dart index 31e52ffb3..c4cbd183d 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/select_all_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/select_all_command.dart @@ -15,10 +15,6 @@ final CommandShortcutEvent selectAllCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _selectAllCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'selectAllCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } if (editorState.document.root.children.isEmpty) { return KeyEventResult.handled; } diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/undo_redo_command.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/undo_redo_command.dart index efeaae033..3357440b3 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/undo_redo_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_events/undo_redo_command.dart @@ -15,10 +15,6 @@ final CommandShortcutEvent undoCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _undoCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'undoCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } editorState.undoManager.undo(); return KeyEventResult.handled; }; @@ -37,10 +33,6 @@ final CommandShortcutEvent redoCommand = CommandShortcutEvent( ); CommandShortcutEventHandler _redoCommandHandler = (editorState) { - if (PlatformExtension.isMobile) { - assert(false, 'redoCommand is not supported on mobile platform.'); - return KeyEventResult.ignored; - } editorState.undoManager.redo(); return KeyEventResult.handled; }; diff --git a/lib/src/render/selection/mobile_selection_widget.dart b/lib/src/render/selection/mobile_selection_widget.dart index 354bd8130..f3b1eb0ab 100644 --- a/lib/src/render/selection/mobile_selection_widget.dart +++ b/lib/src/render/selection/mobile_selection_widget.dart @@ -9,6 +9,7 @@ class MobileSelectionWidget extends StatelessWidget { this.decoration, this.showLeftHandler = false, this.showRightHandler = false, + this.handlerColor = Colors.black, }) : super(key: key); final Color color; @@ -17,6 +18,7 @@ class MobileSelectionWidget extends StatelessWidget { final BoxDecoration? decoration; final bool showLeftHandler; final bool showRightHandler; + final Color handlerColor; @override Widget build(BuildContext context) { @@ -34,6 +36,7 @@ class MobileSelectionWidget extends StatelessWidget { decoration: decoration, showLeftHandler: showLeftHandler, showRightHandler: showRightHandler, + handlerColor: handlerColor, ), ), ),