Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

Merge branch 'feat/flowy_editor' into feat/text-delta-to-text-span

Vincent Chane92677d2ce78
diff --cc frontend/app_flowy/packages/flowy_editor/example/lib/plugin/text_node_widget.dart
index 7ce67fcdf6,a56327ead5..49dcfad8f4
--- a/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/text_node_widget.dart
+++ b/frontend/app_flowy/packages/flowy_editor/example/lib/plugin/text_node_widget.dart
@@@ -98,55 -46,49 +97,47 @@@ class _TextNodeWidget extends StatefulW
class __TextNodeWidgetState extends State<_TextNodeWidget>
implements TextInputClient {
-- Node get node => widget.node;
++ TextNode get node => widget.node as TextNode;
EditorState get editorState => widget.editorState;
- String get content => node.attributes['content'] as String;
- TextEditingValue get textEditingValue => TextEditingValue(text: content);
+ TextEditingValue get textEditingValue => const TextEditingValue();
TextInputConnection? _textInputConnection;
@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(
- text: content,
- style: node.attributes.toTextStyle(),
++ 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,
+ ),
+ ),
+ )
+ ],
);
}