feat: support customizing cursor width (#654)
This commit is contained in:
parent
49575bc58f
commit
ba9bcee094
8 changed files with 15 additions and 0 deletions
|
|
@ -103,6 +103,7 @@ class _DesktopEditorState extends State<DesktopEditor> {
|
|||
// showcase 1: customize the editor style.
|
||||
EditorStyle _buildDesktopEditorStyle() {
|
||||
return EditorStyle.desktop(
|
||||
cursorWidth: 2.0,
|
||||
cursorColor: Colors.blue,
|
||||
selectionColor: Colors.grey.shade300,
|
||||
textStyleConfiguration: TextStyleConfiguration(
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ class _BulletedListBlockComponentWidgetState
|
|||
textDirection: textDirection,
|
||||
cursorColor: editorState.editorStyle.cursorColor,
|
||||
selectionColor: editorState.editorStyle.selectionColor,
|
||||
cursorWidth: editorState.editorStyle.cursorWidth,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ class _HeadingBlockComponentWidgetState
|
|||
textDirection: textDirection,
|
||||
cursorColor: editorState.editorStyle.cursorColor,
|
||||
selectionColor: editorState.editorStyle.selectionColor,
|
||||
cursorWidth: editorState.editorStyle.cursorWidth,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ class _NumberedListBlockComponentWidgetState
|
|||
textDirection: textDirection,
|
||||
cursorColor: editorState.editorStyle.cursorColor,
|
||||
selectionColor: editorState.editorStyle.selectionColor,
|
||||
cursorWidth: editorState.editorStyle.cursorWidth,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ class _ParagraphBlockComponentWidgetState
|
|||
textDirection: textDirection,
|
||||
cursorColor: editorState.editorStyle.cursorColor,
|
||||
selectionColor: editorState.editorStyle.selectionColor,
|
||||
cursorWidth: editorState.editorStyle.cursorWidth,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ class _QuoteBlockComponentWidgetState extends State<QuoteBlockComponentWidget>
|
|||
textDirection: textDirection,
|
||||
cursorColor: editorState.editorStyle.cursorColor,
|
||||
selectionColor: editorState.editorStyle.selectionColor,
|
||||
cursorWidth: editorState.editorStyle.cursorWidth,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ class _TodoListBlockComponentWidgetState
|
|||
),
|
||||
cursorColor: editorState.editorStyle.cursorColor,
|
||||
selectionColor: editorState.editorStyle.selectionColor,
|
||||
cursorWidth: editorState.editorStyle.cursorWidth,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class EditorStyle {
|
|||
this.magnifierSize = const Size(72, 48),
|
||||
this.mobileDragHandleBallSize = const Size(8, 8),
|
||||
this.mobileDragHandleWidth = 2.0,
|
||||
this.cursorWidth = 2.0,
|
||||
this.defaultTextDirection,
|
||||
this.enableHapticFeedbackOnAndroid = true,
|
||||
});
|
||||
|
|
@ -27,6 +28,9 @@ class EditorStyle {
|
|||
// The cursor color
|
||||
final Color cursorColor;
|
||||
|
||||
// The cursor width
|
||||
final double cursorWidth;
|
||||
|
||||
// The drag handle color
|
||||
// only works on mobile
|
||||
// the drag handle color will be ignored on Android.
|
||||
|
|
@ -73,6 +77,7 @@ class EditorStyle {
|
|||
TextStyleConfiguration? textStyleConfiguration,
|
||||
TextSpanDecoratorForAttribute? textSpanDecorator,
|
||||
this.defaultTextDirection,
|
||||
this.cursorWidth = 2.0,
|
||||
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 100),
|
||||
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
||||
selectionColor =
|
||||
|
|
@ -100,6 +105,7 @@ class EditorStyle {
|
|||
this.magnifierSize = const Size(72, 48),
|
||||
this.mobileDragHandleBallSize = const Size(8, 8),
|
||||
this.mobileDragHandleWidth = 2.0,
|
||||
this.cursorWidth = 2.0,
|
||||
this.enableHapticFeedbackOnAndroid = true,
|
||||
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 20),
|
||||
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
||||
|
|
@ -125,6 +131,7 @@ class EditorStyle {
|
|||
Size? mobileDragHandleBallSize,
|
||||
double? mobileDragHandleWidth,
|
||||
bool? enableHapticFeedbackOnAndroid,
|
||||
double? cursorWidth,
|
||||
}) {
|
||||
return EditorStyle(
|
||||
padding: padding ?? this.padding,
|
||||
|
|
@ -142,6 +149,7 @@ class EditorStyle {
|
|||
mobileDragHandleWidth ?? this.mobileDragHandleWidth,
|
||||
enableHapticFeedbackOnAndroid:
|
||||
enableHapticFeedbackOnAndroid ?? this.enableHapticFeedbackOnAndroid,
|
||||
cursorWidth: cursorWidth ?? this.cursorWidth,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue