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