diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/document/path.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/document/path.dart index 8f24947649..a8163f094d 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/document/path.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/document/path.dart @@ -1,5 +1,3 @@ -import 'dart:math'; - import 'package:flutter/foundation.dart'; typedef Path = List; diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/infra/html_converter.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/infra/html_converter.dart index 3457b1d5b0..fa49ee2e54 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/infra/html_converter.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/infra/html_converter.dart @@ -290,10 +290,10 @@ class HTMLToNodesConverter { List _handleUnorderedList(html.Element element) { final result = []; - element.children.forEach((child) { + for (var child in element.children) { result.addAll( _handleListElement(child, {"subtype": StyleKey.bulletedList})); - }); + } return result; } diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart index 974b702a46..fb4dbdc4a1 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart @@ -11,7 +11,6 @@ import 'package:appflowy_editor/src/document/text_delta.dart'; import 'package:appflowy_editor/src/editor_state.dart'; import 'package:appflowy_editor/src/render/rich_text/rich_text_style.dart'; import 'package:appflowy_editor/src/render/selection/selectable.dart'; -import 'package:appflowy_editor/src/service/render_plugin_service.dart'; typedef FlowyTextSpanDecorator = TextSpan Function(TextSpan textSpan); @@ -166,26 +165,26 @@ class _FlowyRichTextState extends State with Selectable { } // unused now. - Widget _buildRichTextWithChildren(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildSingleRichText(context), - ...widget.textNode.children - .map( - (child) => widget.editorState.service.renderPluginService - .buildPluginWidget( - NodeWidgetContext( - context: context, - node: child, - editorState: widget.editorState, - ), - ), - ) - .toList() - ], - ); - } + // Widget _buildRichTextWithChildren(BuildContext context) { + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // _buildSingleRichText(context), + // ...widget.textNode.children + // .map( + // (child) => widget.editorState.service.renderPluginService + // .buildPluginWidget( + // NodeWidgetContext( + // context: context, + // node: child, + // editorState: widget.editorState, + // ), + // ), + // ) + // .toList() + // ], + // ); + // } @override Offset localToGlobal(Offset offset) { diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection/toolbar_widget.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection/toolbar_widget.dart index 117bf316dc..dfc5c5c971 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection/toolbar_widget.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection/toolbar_widget.dart @@ -53,7 +53,7 @@ class ToolbarWidget extends StatefulWidget { } class _ToolbarWidgetState extends State with ToolbarMixin { - final GlobalKey _listToolbarKey = GlobalKey(); + // final GlobalKey _listToolbarKey = GlobalKey(); final toolbarHeight = 32.0; final topPadding = 5.0; @@ -117,14 +117,14 @@ class _ToolbarWidgetState extends State with ToolbarMixin { ); } - Widget _listToolbar(BuildContext context) { - return _centerToolbarIcon( - 'quote', - key: _listToolbarKey, - width: listToolbarWidth, - onTap: () => _onTapListToolbar(context), - ); - } + // Widget _listToolbar(BuildContext context) { + // return _centerToolbarIcon( + // 'quote', + // key: _listToolbarKey, + // width: listToolbarWidth, + // onTap: () => _onTapListToolbar(context), + // ); + // } Widget _centerToolbarIcon(String name, {Key? key, String? tooltipMessage, double? width, VoidCallback? onTap}) { @@ -150,62 +150,62 @@ class _ToolbarWidgetState extends State with ToolbarMixin { )); } - void _onTapListToolbar(BuildContext context) { - // TODO: implement more detailed UI. - final items = defaultListToolbarEventNames; - final renderBox = - _listToolbarKey.currentContext?.findRenderObject() as RenderBox; - final offset = renderBox - .localToGlobal(Offset.zero) - .translate(0, toolbarHeight - cornerRadius); - final rect = offset & Size(listToolbarWidth, listToolbarHeight); + // void _onTapListToolbar(BuildContext context) { + // // TODO: implement more detailed UI. + // final items = defaultListToolbarEventNames; + // final renderBox = + // _listToolbarKey.currentContext?.findRenderObject() as RenderBox; + // final offset = renderBox + // .localToGlobal(Offset.zero) + // .translate(0, toolbarHeight - cornerRadius); + // final rect = offset & Size(listToolbarWidth, listToolbarHeight); - _listToolbarOverlay?.remove(); - _listToolbarOverlay = OverlayEntry(builder: (context) { - return Positioned.fromRect( - rect: rect, - child: Material( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(cornerRadius), - bottomRight: Radius.circular(cornerRadius), - ), - color: const Color(0xFF333333), - child: SingleChildScrollView( - child: ListView.builder( - itemExtent: toolbarHeight, - padding: const EdgeInsets.only(bottom: 10.0), - shrinkWrap: true, - itemCount: items.length, - itemBuilder: ((context, index) { - return ListTile( - contentPadding: const EdgeInsets.only( - left: 3.0, - right: 3.0, - ), - minVerticalPadding: 0.0, - title: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - items[index], - textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.white, - ), - ), - ), - onTap: () { - _onTap(items[index]); - }, - ); - }), - ), - ), - ), - ); - }); - // TODO: disable scrolling. - Overlay.of(context)?.insert(_listToolbarOverlay!); - } + // _listToolbarOverlay?.remove(); + // _listToolbarOverlay = OverlayEntry(builder: (context) { + // return Positioned.fromRect( + // rect: rect, + // child: Material( + // borderRadius: BorderRadius.only( + // bottomLeft: Radius.circular(cornerRadius), + // bottomRight: Radius.circular(cornerRadius), + // ), + // color: const Color(0xFF333333), + // child: SingleChildScrollView( + // child: ListView.builder( + // itemExtent: toolbarHeight, + // padding: const EdgeInsets.only(bottom: 10.0), + // shrinkWrap: true, + // itemCount: items.length, + // itemBuilder: ((context, index) { + // return ListTile( + // contentPadding: const EdgeInsets.only( + // left: 3.0, + // right: 3.0, + // ), + // minVerticalPadding: 0.0, + // title: FittedBox( + // fit: BoxFit.scaleDown, + // child: Text( + // items[index], + // textAlign: TextAlign.center, + // style: const TextStyle( + // color: Colors.white, + // ), + // ), + // ), + // onTap: () { + // _onTap(items[index]); + // }, + // ); + // }), + // ), + // ), + // ), + // ); + // }); + // // TODO: disable scrolling. + // Overlay.of(context)?.insert(_listToolbarOverlay!); + // } void _onTap(String eventName) { if (defaultToolbarEventHandlers.containsKey(eventName)) { diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/selection_service.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/selection_service.dart index b55c5e8de1..7d2df57272 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/selection_service.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/selection_service.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:appflowy_editor/src/document/node.dart'; @@ -104,7 +103,7 @@ class _FlowySelectionState extends State final List _selectionAreas = []; final List _cursorAreas = []; - OverlayEntry? _debugOverlay; + // OverlayEntry? _debugOverlay; /// Pan Offset? _panStartOffset; @@ -517,38 +516,38 @@ class _FlowySelectionState extends State void _showDebugLayerIfNeeded({Offset? offset}) { // remove false to show debug overlay. - if (kDebugMode && false) { - _debugOverlay?.remove(); - if (offset != null) { - _debugOverlay = OverlayEntry( - builder: (context) => Positioned.fromRect( - rect: Rect.fromPoints(offset, offset.translate(20, 20)), - child: Container( - color: Colors.red.withOpacity(0.2), - ), - ), - ); - Overlay.of(context)?.insert(_debugOverlay!); - } else if (_panStartOffset != null) { - _debugOverlay = OverlayEntry( - builder: (context) => Positioned.fromRect( - rect: Rect.fromPoints( - _panStartOffset?.translate( - 0, - -(editorState.service.scrollService!.dy - - _panStartScrollDy!), - ) ?? - Offset.zero, - offset ?? Offset.zero), - child: Container( - color: Colors.red.withOpacity(0.2), - ), - ), - ); - Overlay.of(context)?.insert(_debugOverlay!); - } else { - _debugOverlay = null; - } - } + // if (kDebugMode && false) { + // _debugOverlay?.remove(); + // if (offset != null) { + // _debugOverlay = OverlayEntry( + // builder: (context) => Positioned.fromRect( + // rect: Rect.fromPoints(offset, offset.translate(20, 20)), + // child: Container( + // color: Colors.red.withOpacity(0.2), + // ), + // ), + // ); + // Overlay.of(context)?.insert(_debugOverlay!); + // } else if (_panStartOffset != null) { + // _debugOverlay = OverlayEntry( + // builder: (context) => Positioned.fromRect( + // rect: Rect.fromPoints( + // _panStartOffset?.translate( + // 0, + // -(editorState.service.scrollService!.dy - + // _panStartScrollDy!), + // ) ?? + // Offset.zero, + // offset ?? Offset.zero), + // child: Container( + // color: Colors.red.withOpacity(0.2), + // ), + // ), + // ); + // Overlay.of(context)?.insert(_debugOverlay!); + // } else { + // _debugOverlay = null; + // } + // } } }