Browse Source

fix hidetoolbar

lucky1213 4 years ago
parent
commit
3d579800b2

+ 16
- 0
packages/zefyr/example/lib/generated_plugin_registrant.dart View File

1
+//
2
+// Generated file. Do not edit.
3
+//
4
+
5
+// ignore: unused_import
6
+import 'dart:ui';
7
+
8
+import 'package:url_launcher_web/url_launcher_web.dart';
9
+
10
+import 'package:flutter_web_plugins/flutter_web_plugins.dart';
11
+
12
+// ignore: public_member_api_docs
13
+void registerPlugins(PluginRegistry registry) {
14
+  UrlLauncherPlugin.registerWith(registry.registrarFor(UrlLauncherPlugin));
15
+  registry.registerMessageHandler();
16
+}

+ 2
- 0
packages/zefyr/lib/src/widgets/__theme.dart View File

273
         break;
273
         break;
274
       case TargetPlatform.android:
274
       case TargetPlatform.android:
275
       case TargetPlatform.fuchsia:
275
       case TargetPlatform.fuchsia:
276
+      case TargetPlatform.linux:
277
+      case TargetPlatform.windows:
276
         fontFamily = 'Roboto Mono';
278
         fontFamily = 'Roboto Mono';
277
         break;
279
         break;
278
     }
280
     }

+ 0
- 1
packages/zefyr/lib/src/widgets/buttons.dart View File

6
 
6
 
7
 import 'package:flutter/material.dart';
7
 import 'package:flutter/material.dart';
8
 import 'package:flutter/services.dart';
8
 import 'package:flutter/services.dart';
9
-import 'package:image_picker/image_picker.dart';
10
 import 'package:notus/notus.dart';
9
 import 'package:notus/notus.dart';
11
 import 'package:photo/photo.dart';
10
 import 'package:photo/photo.dart';
12
 import 'package:photo_manager/photo_manager.dart';
11
 import 'package:photo_manager/photo_manager.dart';

+ 38
- 27
packages/zefyr/lib/src/widgets/selection.dart View File

16
 import 'image.dart' show RenderEditableImage;
16
 import 'image.dart' show RenderEditableImage;
17
 import 'rich_text.dart' show RenderZefyrParagraph;
17
 import 'rich_text.dart' show RenderZefyrParagraph;
18
 import 'scope.dart';
18
 import 'scope.dart';
19
+
19
 /// Selection overlay controls selection handles and other gestures.
20
 /// Selection overlay controls selection handles and other gestures.
20
 class ZefyrSelectionOverlay extends StatefulWidget {
21
 class ZefyrSelectionOverlay extends StatefulWidget {
21
   const ZefyrSelectionOverlay({Key key, @required this.controls})
22
   const ZefyrSelectionOverlay({Key key, @required this.controls})
253
     WidgetsBinding.instance.hitTest(result, globalPoint);
254
     WidgetsBinding.instance.hitTest(result, globalPoint);
254
 
255
 
255
     RenderEditableProxyBox box = _getEditableBox(result);
256
     RenderEditableProxyBox box = _getEditableBox(result);
256
-    
257
+
257
     box ??= _scope.renderContext.closestBoxForGlobalPoint(globalPoint);
258
     box ??= _scope.renderContext.closestBoxForGlobalPoint(globalPoint);
258
     if (box == null) return null;
259
     if (box == null) return null;
259
 
260
 
266
     // 如果是link或者image
267
     // 如果是link或者image
267
     if (box?.child is RenderZefyrParagraph) {
268
     if (box?.child is RenderZefyrParagraph) {
268
       RenderZefyrParagraph paragraph = box.child;
269
       RenderZefyrParagraph paragraph = box.child;
269
-      if (_scope.controller.getStyleForSelection(selection).contains(NotusAttribute.link)) {
270
+      if (_scope.controller
271
+          .getStyleForSelection(selection)
272
+          .contains(NotusAttribute.link)) {
270
         // 当前点击的是link
273
         // 当前点击的是link
271
         var spanPosition = paragraph.getRenderBoxPositionForOffset(localPoint);
274
         var spanPosition = paragraph.getRenderBoxPositionForOffset(localPoint);
272
         // // 第一个字符和最后一个字符将不触发onTap
275
         // // 第一个字符和最后一个字符将不触发onTap
275
           affinity: spanPosition.affinity,
278
           affinity: spanPosition.affinity,
276
         ));
279
         ));
277
         if (span != null) {
280
         if (span != null) {
278
-          if (paragraph.getPositionHasRenderBox(spanPosition, span.text.length)) {
281
+          if (paragraph.getPositionHasRenderBox(
282
+              spanPosition, span.text.length)) {
279
             final recognizer = (span?.recognizer as TapGestureRecognizer);
283
             final recognizer = (span?.recognizer as TapGestureRecognizer);
280
             if (recognizer != null) {
284
             if (recognizer != null) {
281
               print('当前点击的是link');
285
               print('当前点击的是link');
282
               // 关闭键盘 触发tap,改变光标,但不弹出键盘
286
               // 关闭键盘 触发tap,改变光标,但不弹出键盘
283
               _scope.closeKeyboard();
287
               _scope.closeKeyboard();
284
               recognizer.onTap();
288
               recognizer.onTap();
285
-              _scope.controller.updateSelection(selection, source: ChangeSource.remote);
289
+              _scope.controller
290
+                  .updateSelection(selection, source: ChangeSource.remote);
286
               return;
291
               return;
287
             }
292
             }
288
           }
293
           }
290
       }
295
       }
291
     } else if (box?.child is RenderEditableImage) {
296
     } else if (box?.child is RenderEditableImage) {
292
       RenderEditableImage image = box.child;
297
       RenderEditableImage image = box.child;
293
-      if ((image.child as RenderPadding).child is RenderSemanticsGestureHandler) {
294
-        RenderSemanticsGestureHandler gestureBox = (image.child as RenderPadding).child;
298
+      if ((image.child as RenderPadding).child
299
+          is RenderSemanticsGestureHandler) {
300
+        RenderSemanticsGestureHandler gestureBox =
301
+            (image.child as RenderPadding).child;
295
         _scope.closeKeyboard();
302
         _scope.closeKeyboard();
296
         gestureBox.onTap();
303
         gestureBox.onTap();
297
-        _scope.controller.updateSelection(selection, source: ChangeSource.remote);
304
+        _scope.controller
305
+            .updateSelection(selection, source: ChangeSource.remote);
298
         return;
306
         return;
299
       }
307
       }
300
     }
308
     }
323
     final localPoint = box.globalToLocal(globalPoint);
331
     final localPoint = box.globalToLocal(globalPoint);
324
     final position = box.getPositionForOffset(localPoint);
332
     final position = box.getPositionForOffset(localPoint);
325
     var word = box.getWordBoundary(position);
333
     var word = box.getWordBoundary(position);
326
-    
334
+
327
     // if (box?.child is RenderZefyrParagraph) {
335
     // if (box?.child is RenderZefyrParagraph) {
328
     //   RenderZefyrParagraph paragraph = box.child;
336
     //   RenderZefyrParagraph paragraph = box.child;
329
     //   if (_scope.controller.getStyleForSelection(TextSelection.collapsed(
337
     //   if (_scope.controller.getStyleForSelection(TextSelection.collapsed(
522
         alignment: Alignment.topLeft,
530
         alignment: Alignment.topLeft,
523
         width: interactiveRect.width,
531
         width: interactiveRect.width,
524
         height: interactiveRect.height,
532
         height: interactiveRect.height,
525
-        child: 
526
-        //  RawGestureDetector(
527
-        //   behavior: HitTestBehavior.translucent,
528
-        //   gestures: <Type, GestureRecognizerFactory>{
529
-        //     CustomPanGestureRecognizer: GestureRecognizerFactoryWithHandlers<
530
-        //         CustomPanGestureRecognizer>(
531
-        //       () => CustomPanGestureRecognizer(
532
-        //           onPanDown: _handleDragStart, onPanUpdate: _handleDragUpdate),
533
-        //       (CustomPanGestureRecognizer instance) {},
534
-        //     ),
535
-        //   },
536
-        GestureDetector(
533
+        child:
534
+            //  RawGestureDetector(
535
+            //   behavior: HitTestBehavior.translucent,
536
+            //   gestures: <Type, GestureRecognizerFactory>{
537
+            //     CustomPanGestureRecognizer: GestureRecognizerFactoryWithHandlers<
538
+            //         CustomPanGestureRecognizer>(
539
+            //       () => CustomPanGestureRecognizer(
540
+            //           onPanDown: _handleDragStart, onPanUpdate: _handleDragUpdate),
541
+            //       (CustomPanGestureRecognizer instance) {},
542
+            //     ),
543
+            //   },
544
+            GestureDetector(
537
           behavior: HitTestBehavior.translucent,
545
           behavior: HitTestBehavior.translucent,
538
           dragStartBehavior: DragStartBehavior.start,
546
           dragStartBehavior: DragStartBehavior.start,
539
           onPanStart: _handleDragStart,
547
           onPanStart: _handleDragStart,
630
 }
638
 }
631
 
639
 
632
 class _SelectionToolbarState extends State<_SelectionToolbar> {
640
 class _SelectionToolbarState extends State<_SelectionToolbar> {
641
+  final ClipboardStatusNotifier _clipboardStatus = kIsWeb ? null : ClipboardStatusNotifier();
633
   TextSelectionControls get controls => widget.selectionOverlay.controls;
642
   TextSelectionControls get controls => widget.selectionOverlay.controls;
634
   ZefyrScope get scope => widget.selectionOverlay.scope;
643
   ZefyrScope get scope => widget.selectionOverlay.scope;
635
   TextSelection get selection =>
644
   TextSelection get selection =>
681
     );
690
     );
682
 
691
 
683
     final toolbar = controls.buildToolbar(
692
     final toolbar = controls.buildToolbar(
684
-        context,
685
-        editingRegion,
686
-        block.preferredLineHeight,
687
-        midpoint,
688
-        endpoints,
689
-        widget.selectionOverlay);
693
+      context,
694
+      editingRegion,
695
+      block.preferredLineHeight,
696
+      midpoint,
697
+      endpoints,
698
+      widget.selectionOverlay,
699
+      _clipboardStatus,
700
+    );
690
     return CompositedTransformFollower(
701
     return CompositedTransformFollower(
691
       link: block.layerLink,
702
       link: block.layerLink,
692
       showWhenUnlinked: false,
703
       showWhenUnlinked: false,
730
 
741
 
731
   @override
742
   @override
732
   void didStopTrackingLastPointer(int pointer) {}
743
   void didStopTrackingLastPointer(int pointer) {}
733
-} 
744
+}

+ 1
- 1
packages/zefyr/pubspec.yaml View File

1
 name: zefyr
1
 name: zefyr
2
 description: Clean, minimalistic and collaboration-ready rich text editor for Flutter.
2
 description: Clean, minimalistic and collaboration-ready rich text editor for Flutter.
3
-version: 0.10.1
3
+version: 0.10.2
4
 author: Anatoly Pulyaevskiy <anatoly.pulyaevskiy@gmail.com>
4
 author: Anatoly Pulyaevskiy <anatoly.pulyaevskiy@gmail.com>
5
 homepage: https://github.com/memspace/zefyr
5
 homepage: https://github.com/memspace/zefyr
6
 
6