Always use text cursor for editor on desktop (#1264)

pull/1267/head
Benjamin Quinn 2 years ago committed by GitHub
parent 9d877478ad
commit 0906f71b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 128
      example/lib/pages/home_page.dart
  2. 76
      lib/src/widgets/raw_editor.dart

@ -158,76 +158,70 @@ class _HomePageState extends State<HomePage> {
} }
Widget _buildWelcomeEditor(BuildContext context) { Widget _buildWelcomeEditor(BuildContext context) {
Widget quillEditor = MouseRegion( Widget quillEditor = QuillEditor(
cursor: SystemMouseCursors.text, controller: _controller!,
child: QuillEditor( scrollController: ScrollController(),
controller: _controller!, scrollable: true,
scrollController: ScrollController(), focusNode: _focusNode,
scrollable: true, autoFocus: false,
focusNode: _focusNode, readOnly: false,
autoFocus: false, placeholder: 'Add content',
readOnly: false, enableSelectionToolbar: isMobile(),
placeholder: 'Add content', expands: false,
enableSelectionToolbar: isMobile(), padding: EdgeInsets.zero,
expands: false, onImagePaste: _onImagePaste,
padding: EdgeInsets.zero, onTapUp: (details, p1) {
onImagePaste: _onImagePaste, return _onTripleClickSelection();
onTapUp: (details, p1) { },
return _onTripleClickSelection(); customStyles: DefaultStyles(
}, h1: DefaultTextBlockStyle(
customStyles: DefaultStyles( const TextStyle(
h1: DefaultTextBlockStyle( fontSize: 32,
const TextStyle( color: Colors.black,
fontSize: 32, height: 1.15,
color: Colors.black, fontWeight: FontWeight.w300,
height: 1.15, ),
fontWeight: FontWeight.w300, const VerticalSpacing(16, 0),
), const VerticalSpacing(0, 0),
const VerticalSpacing(16, 0), null),
const VerticalSpacing(0, 0), sizeSmall: const TextStyle(fontSize: 9),
null),
sizeSmall: const TextStyle(fontSize: 9),
),
embedBuilders: [
...FlutterQuillEmbeds.builders(),
NotesEmbedBuilder(addEditNote: _addEditNote)
],
), ),
embedBuilders: [
...FlutterQuillEmbeds.builders(),
NotesEmbedBuilder(addEditNote: _addEditNote)
],
); );
if (kIsWeb) { if (kIsWeb) {
quillEditor = MouseRegion( quillEditor = QuillEditor(
cursor: SystemMouseCursors.text, controller: _controller!,
child: QuillEditor( scrollController: ScrollController(),
controller: _controller!, scrollable: true,
scrollController: ScrollController(), focusNode: _focusNode,
scrollable: true, autoFocus: false,
focusNode: _focusNode, readOnly: false,
autoFocus: false, placeholder: 'Add content',
readOnly: false, expands: false,
placeholder: 'Add content', padding: EdgeInsets.zero,
expands: false, onTapUp: (details, p1) {
padding: EdgeInsets.zero, return _onTripleClickSelection();
onTapUp: (details, p1) { },
return _onTripleClickSelection(); customStyles: DefaultStyles(
}, h1: DefaultTextBlockStyle(
customStyles: DefaultStyles( const TextStyle(
h1: DefaultTextBlockStyle( fontSize: 32,
const TextStyle( color: Colors.black,
fontSize: 32, height: 1.15,
color: Colors.black, fontWeight: FontWeight.w300,
height: 1.15, ),
fontWeight: FontWeight.w300, const VerticalSpacing(16, 0),
), const VerticalSpacing(0, 0),
const VerticalSpacing(16, 0), null),
const VerticalSpacing(0, 0), sizeSmall: const TextStyle(fontSize: 9),
null), ),
sizeSmall: const TextStyle(fontSize: 9), embedBuilders: [
), ...defaultEmbedBuildersWeb,
embedBuilders: [ NotesEmbedBuilder(addEditNote: _addEditNote),
...defaultEmbedBuildersWeb, ]);
NotesEmbedBuilder(addEditNote: _addEditNote),
]),
);
} }
var toolbar = QuillToolbar.basic( var toolbar = QuillToolbar.basic(
controller: _controller!, controller: _controller!,

@ -461,23 +461,26 @@ class RawEditorState extends EditorState
Widget child = CompositedTransformTarget( Widget child = CompositedTransformTarget(
link: _toolbarLayerLink, link: _toolbarLayerLink,
child: Semantics( child: Semantics(
child: _Editor( child: MouseRegion(
key: _editorKey, cursor: SystemMouseCursors.text,
document: _doc, child: _Editor(
selection: controller.selection, key: _editorKey,
hasFocus: _hasFocus, document: _doc,
scrollable: widget.scrollable, selection: controller.selection,
cursorController: _cursorCont, hasFocus: _hasFocus,
textDirection: _textDirection, scrollable: widget.scrollable,
startHandleLayerLink: _startHandleLayerLink, cursorController: _cursorCont,
endHandleLayerLink: _endHandleLayerLink, textDirection: _textDirection,
onSelectionChanged: _handleSelectionChanged, startHandleLayerLink: _startHandleLayerLink,
onSelectionCompleted: _handleSelectionCompleted, endHandleLayerLink: _endHandleLayerLink,
scrollBottomInset: widget.scrollBottomInset, onSelectionChanged: _handleSelectionChanged,
padding: widget.padding, onSelectionCompleted: _handleSelectionCompleted,
maxContentWidth: widget.maxContentWidth, scrollBottomInset: widget.scrollBottomInset,
floatingCursorDisabled: widget.floatingCursorDisabled, padding: widget.padding,
children: _buildChildren(_doc, context), maxContentWidth: widget.maxContentWidth,
floatingCursorDisabled: widget.floatingCursorDisabled,
children: _buildChildren(_doc, context),
),
), ),
), ),
); );
@ -499,24 +502,27 @@ class RawEditorState extends EditorState
physics: widget.scrollPhysics, physics: widget.scrollPhysics,
viewportBuilder: (_, offset) => CompositedTransformTarget( viewportBuilder: (_, offset) => CompositedTransformTarget(
link: _toolbarLayerLink, link: _toolbarLayerLink,
child: _Editor( child: MouseRegion(
key: _editorKey, cursor: SystemMouseCursors.text,
offset: offset, child: _Editor(
document: _doc, key: _editorKey,
selection: controller.selection, offset: offset,
hasFocus: _hasFocus, document: _doc,
scrollable: widget.scrollable, selection: controller.selection,
textDirection: _textDirection, hasFocus: _hasFocus,
startHandleLayerLink: _startHandleLayerLink, scrollable: widget.scrollable,
endHandleLayerLink: _endHandleLayerLink, textDirection: _textDirection,
onSelectionChanged: _handleSelectionChanged, startHandleLayerLink: _startHandleLayerLink,
onSelectionCompleted: _handleSelectionCompleted, endHandleLayerLink: _endHandleLayerLink,
scrollBottomInset: widget.scrollBottomInset, onSelectionChanged: _handleSelectionChanged,
padding: widget.padding, onSelectionCompleted: _handleSelectionCompleted,
maxContentWidth: widget.maxContentWidth, scrollBottomInset: widget.scrollBottomInset,
cursorController: _cursorCont, padding: widget.padding,
floatingCursorDisabled: widget.floatingCursorDisabled, maxContentWidth: widget.maxContentWidth,
children: _buildChildren(_doc, context), cursorController: _cursorCont,
floatingCursorDisabled: widget.floatingCursorDisabled,
children: _buildChildren(_doc, context),
),
), ),
), ),
), ),

Loading…
Cancel
Save