Browse Source

Fixed caret affinity on tap

Anatoly Pulyaevskiy 6 years ago
parent
commit
c3b37152c5

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

102
   @override
102
   @override
103
   TextRange getWordBoundary(TextPosition position) {
103
   TextRange getWordBoundary(TextPosition position) {
104
     final localPosition = new TextPosition(
104
     final localPosition = new TextPosition(
105
-      offset: position.offset - _node.offset,
105
+      offset: position.offset - _node.documentOffset,
106
       affinity: position.affinity,
106
       affinity: position.affinity,
107
     );
107
     );
108
     final localRange = super.getWordBoundary(localPosition);
108
     final localRange = super.getWordBoundary(localPosition);

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

218
 
218
 
219
     final localPoint = box.globalToLocal(globalPoint);
219
     final localPoint = box.globalToLocal(globalPoint);
220
     final position = box.getPositionForOffset(localPoint);
220
     final position = box.getPositionForOffset(localPoint);
221
-    final selection = new TextSelection.collapsed(offset: position.offset);
221
+    final selection = new TextSelection.collapsed(
222
+      offset: position.offset,
223
+      affinity: position.affinity,
224
+    );
222
     if (_didCaretTap && _selection == selection) {
225
     if (_didCaretTap && _selection == selection) {
223
       _didCaretTap = false;
226
       _didCaretTap = false;
224
       hideToolbar();
227
       hideToolbar();

+ 3
- 3
packages/zefyr/lib/src/widgets/theme.dart View File

73
       fontWeight: FontWeight.normal,
73
       fontWeight: FontWeight.normal,
74
       color: Colors.grey.shade800,
74
       color: Colors.grey.shade800,
75
     );
75
     );
76
-    final padding = const EdgeInsets.only(bottom: 8.0);
76
+    final padding = const EdgeInsets.only(bottom: 16.0);
77
     final boldStyle = new TextStyle(fontWeight: FontWeight.bold);
77
     final boldStyle = new TextStyle(fontWeight: FontWeight.bold);
78
     final italicStyle = new TextStyle(fontStyle: FontStyle.italic);
78
     final italicStyle = new TextStyle(fontStyle: FontStyle.italic);
79
     final linkStyle =
79
     final linkStyle =
181
           height: 1.25,
181
           height: 1.25,
182
           fontWeight: FontWeight.w600,
182
           fontWeight: FontWeight.w600,
183
         ),
183
         ),
184
-        padding: EdgeInsets.only(bottom: 8.0, top: 16.0),
184
+        padding: EdgeInsets.only(bottom: 8.0, top: 8.0),
185
       ),
185
       ),
186
       level3: StyleTheme(
186
       level3: StyleTheme(
187
         textStyle: TextStyle(
187
         textStyle: TextStyle(
190
           height: 1.25,
190
           height: 1.25,
191
           fontWeight: FontWeight.w600,
191
           fontWeight: FontWeight.w600,
192
         ),
192
         ),
193
-        padding: EdgeInsets.only(bottom: 8.0, top: 16.0),
193
+        padding: EdgeInsets.only(bottom: 8.0, top: 8.0),
194
       ),
194
       ),
195
     );
195
     );
196
   }
196
   }