Browse Source

fix links clickable offset

lucky1213 4 years ago
parent
commit
fa6787ff62

+ 1
- 1
packages/zefyr/example/lib/src/images.dart View File

@@ -126,7 +126,7 @@ class CustomLinkDelegate implements ZefyrLinkDelegate {
126 126
   @override
127 127
   void onLinkTap(ZefyrLinkEntity value) {
128 128
     // return
129
-    print('The word touched is 123123');
129
+    print(value.text);
130 130
   }
131 131
 }
132 132
 

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

@@ -267,9 +267,9 @@ class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
267 267
       if (_scope.controller.getStyleForSelection(selection).contains(NotusAttribute.link)) {
268 268
         // 当前点击的是link
269 269
         var position = paragraph.getRenderBoxPositionForOffset(localPoint);
270
-        // 此处加1是点击text尾,不算点中
270
+        // 第一个字符和最后一个字符将不触发onTap
271 271
         final TextSpan span = paragraph.text.getSpanForPosition(TextPosition(
272
-          offset: position.offset + 1,
272
+          offset: position.offset == 0 ? position.offset - 1 : position.offset + 1,
273 273
           affinity: position.affinity,
274 274
         ));
275 275
         final recognizer = (span?.recognizer as TapGestureRecognizer);