Quellcode durchsuchen

fix hidetoolbar

lucky1213 vor 4 Jahren
Ursprung
Commit
3d579800b2

+ 16
- 0
packages/zefyr/example/lib/generated_plugin_registrant.dart Datei anzeigen

@@ -0,0 +1,16 @@
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 Datei anzeigen

@@ -273,6 +273,8 @@ class BlockTheme {
273 273
         break;
274 274
       case TargetPlatform.android:
275 275
       case TargetPlatform.fuchsia:
276
+      case TargetPlatform.linux:
277
+      case TargetPlatform.windows:
276 278
         fontFamily = 'Roboto Mono';
277 279
         break;
278 280
     }

+ 0
- 1
packages/zefyr/lib/src/widgets/buttons.dart Datei anzeigen

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

+ 38
- 27
packages/zefyr/lib/src/widgets/selection.dart Datei anzeigen

@@ -16,6 +16,7 @@ import 'editable_box.dart';
16 16
 import 'image.dart' show RenderEditableImage;
17 17
 import 'rich_text.dart' show RenderZefyrParagraph;
18 18
 import 'scope.dart';
19
+
19 20
 /// Selection overlay controls selection handles and other gestures.
20 21
 class ZefyrSelectionOverlay extends StatefulWidget {
21 22
   const ZefyrSelectionOverlay({Key key, @required this.controls})
@@ -253,7 +254,7 @@ class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
253 254
     WidgetsBinding.instance.hitTest(result, globalPoint);
254 255
 
255 256
     RenderEditableProxyBox box = _getEditableBox(result);
256
-    
257
+
257 258
     box ??= _scope.renderContext.closestBoxForGlobalPoint(globalPoint);
258 259
     if (box == null) return null;
259 260
 
@@ -266,7 +267,9 @@ class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
266 267
     // 如果是link或者image
267 268
     if (box?.child is RenderZefyrParagraph) {
268 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 273
         // 当前点击的是link
271 274
         var spanPosition = paragraph.getRenderBoxPositionForOffset(localPoint);
272 275
         // // 第一个字符和最后一个字符将不触发onTap
@@ -275,14 +278,16 @@ class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
275 278
           affinity: spanPosition.affinity,
276 279
         ));
277 280
         if (span != null) {
278
-          if (paragraph.getPositionHasRenderBox(spanPosition, span.text.length)) {
281
+          if (paragraph.getPositionHasRenderBox(
282
+              spanPosition, span.text.length)) {
279 283
             final recognizer = (span?.recognizer as TapGestureRecognizer);
280 284
             if (recognizer != null) {
281 285
               print('当前点击的是link');
282 286
               // 关闭键盘 触发tap,改变光标,但不弹出键盘
283 287
               _scope.closeKeyboard();
284 288
               recognizer.onTap();
285
-              _scope.controller.updateSelection(selection, source: ChangeSource.remote);
289
+              _scope.controller
290
+                  .updateSelection(selection, source: ChangeSource.remote);
286 291
               return;
287 292
             }
288 293
           }
@@ -290,11 +295,14 @@ class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
290 295
       }
291 296
     } else if (box?.child is RenderEditableImage) {
292 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 302
         _scope.closeKeyboard();
296 303
         gestureBox.onTap();
297
-        _scope.controller.updateSelection(selection, source: ChangeSource.remote);
304
+        _scope.controller
305
+            .updateSelection(selection, source: ChangeSource.remote);
298 306
         return;
299 307
       }
300 308
     }
@@ -323,7 +331,7 @@ class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
323 331
     final localPoint = box.globalToLocal(globalPoint);
324 332
     final position = box.getPositionForOffset(localPoint);
325 333
     var word = box.getWordBoundary(position);
326
-    
334
+
327 335
     // if (box?.child is RenderZefyrParagraph) {
328 336
     //   RenderZefyrParagraph paragraph = box.child;
329 337
     //   if (_scope.controller.getStyleForSelection(TextSelection.collapsed(
@@ -522,18 +530,18 @@ class _SelectionHandleDriverState extends State<SelectionHandleDriver>
522 530
         alignment: Alignment.topLeft,
523 531
         width: interactiveRect.width,
524 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 545
           behavior: HitTestBehavior.translucent,
538 546
           dragStartBehavior: DragStartBehavior.start,
539 547
           onPanStart: _handleDragStart,
@@ -630,6 +638,7 @@ class _SelectionToolbar extends StatefulWidget {
630 638
 }
631 639
 
632 640
 class _SelectionToolbarState extends State<_SelectionToolbar> {
641
+  final ClipboardStatusNotifier _clipboardStatus = kIsWeb ? null : ClipboardStatusNotifier();
633 642
   TextSelectionControls get controls => widget.selectionOverlay.controls;
634 643
   ZefyrScope get scope => widget.selectionOverlay.scope;
635 644
   TextSelection get selection =>
@@ -681,12 +690,14 @@ class _SelectionToolbarState extends State<_SelectionToolbar> {
681 690
     );
682 691
 
683 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 701
     return CompositedTransformFollower(
691 702
       link: block.layerLink,
692 703
       showWhenUnlinked: false,
@@ -730,4 +741,4 @@ class CustomPanGestureRecognizer extends OneSequenceGestureRecognizer {
730 741
 
731 742
   @override
732 743
   void didStopTrackingLastPointer(int pointer) {}
733
-} 
744
+}

+ 1
- 1
packages/zefyr/pubspec.yaml Datei anzeigen

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