|
@@ -3,7 +3,6 @@ import 'package:flutter/gestures.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flowy_editor/flowy_editor.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
-import 'package:provider/provider.dart';
|
|
|
import 'package:flowy_editor/document/attributes.dart';
|
|
|
|
|
|
class TextNodeBuilder extends NodeWidgetBuilder {
|
|
@@ -98,7 +97,7 @@ class _TextNodeWidget extends StatefulWidget {
|
|
|
|
|
|
class __TextNodeWidgetState extends State<_TextNodeWidget>
|
|
|
implements TextInputClient {
|
|
|
- Node get node => widget.node;
|
|
|
+ TextNode get node => widget.node as TextNode;
|
|
|
EditorState get editorState => widget.editorState;
|
|
|
TextEditingValue get textEditingValue => const TextEditingValue();
|
|
|
|
|
@@ -106,47 +105,39 @@ class __TextNodeWidgetState extends State<_TextNodeWidget>
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return ChangeNotifierProvider.value(
|
|
|
- value: node,
|
|
|
- builder: (_, __) => Consumer<Node>(
|
|
|
- builder: ((context, value, child) {
|
|
|
- final textNode = value as TextNode;
|
|
|
- return Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- SelectableText.rich(
|
|
|
- TextSpan(
|
|
|
- children: textNode.toTextSpans(),
|
|
|
- ),
|
|
|
- onTap: () {
|
|
|
- _textInputConnection?.close();
|
|
|
- _textInputConnection = TextInput.attach(
|
|
|
- this,
|
|
|
- const TextInputConfiguration(
|
|
|
- enableDeltaModel: false,
|
|
|
- inputType: TextInputType.multiline,
|
|
|
- textCapitalization: TextCapitalization.sentences,
|
|
|
- ),
|
|
|
- );
|
|
|
- _textInputConnection
|
|
|
- ?..show()
|
|
|
- ..setEditingState(textEditingValue);
|
|
|
- },
|
|
|
+ return Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ SelectableText.rich(
|
|
|
+ TextSpan(
|
|
|
+ children: node.toTextSpans(),
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ _textInputConnection?.close();
|
|
|
+ _textInputConnection = TextInput.attach(
|
|
|
+ this,
|
|
|
+ const TextInputConfiguration(
|
|
|
+ enableDeltaModel: false,
|
|
|
+ inputType: TextInputType.multiline,
|
|
|
+ textCapitalization: TextCapitalization.sentences,
|
|
|
),
|
|
|
- if (node.children.isNotEmpty)
|
|
|
- ...node.children.map(
|
|
|
- (e) => editorState.renderPlugins.buildWidget(
|
|
|
- context: NodeWidgetContext(
|
|
|
- buildContext: context,
|
|
|
- node: e,
|
|
|
- editorState: editorState,
|
|
|
- ),
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
- );
|
|
|
- }),
|
|
|
- ),
|
|
|
+ );
|
|
|
+ _textInputConnection
|
|
|
+ ?..show()
|
|
|
+ ..setEditingState(textEditingValue);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ if (node.children.isNotEmpty)
|
|
|
+ ...node.children.map(
|
|
|
+ (e) => editorState.renderPlugins.buildWidget(
|
|
|
+ context: NodeWidgetContext(
|
|
|
+ buildContext: context,
|
|
|
+ node: e,
|
|
|
+ editorState: editorState,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
);
|
|
|
}
|
|
|
|