You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: frontend/app_flowy/packages/appflowy_editor/README.md
+37-24Lines changed: 37 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,21 +26,27 @@ and the Flutter guide for
26
26
27
27
## Key Features
28
28
29
-
* Allow you to build rich, intuitive editors
30
-
* Design and modify it your way by customizing components, shortcut events, and many more coming soon including menu options and themes
31
-
*[Test-covered](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/documentation/testing.md) and maintained by AppFlowy's core team along with a community of more than 1,000 builders
29
+
* Build rich, intuitive editors
30
+
* Design and modify an ever expanding list of customizable features including
31
+
* components (such as form input controls, numbered lists, and rich text widgets)
32
+
* shortcut events
33
+
* menu options (**coming soon!**)
34
+
* themes (**coming soon!**)
35
+
*[Test-coverage](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/documentation/testing.md) and on-going maintenance by AppFlowy's core team and community of more than 1,000 builders
32
36
37
+
## Getting Started
33
38
34
-
## Getting started
39
+
Add the AppFlowy editor [Flutter package](https://docs.flutter.dev/development/packages-and-plugins/using-packages) to your environment.
35
40
36
41
```shell
37
42
flutter pub add appflowy_editor
38
43
flutter pub get
39
44
```
40
45
41
-
## How to use
46
+
## Creating Your First Editor
47
+
48
+
Start by creating a new empty AppFlowyEditor object.
42
49
43
-
Let's create a new AppFlowyEditor object
44
50
```dart
45
51
final editorState = EditorState.empty(); // an empty state
46
52
final editor = AppFlowyEditor(
@@ -50,7 +56,8 @@ final editor = AppFlowyEditor(
50
56
);
51
57
```
52
58
53
-
You can also create an editor from a JSON file
59
+
You can also create an editor from a JSON object in order to configure your initial state.
60
+
54
61
```dart
55
62
final json = ...;
56
63
final editorState = EditorState(StateTree.fromJson(data));
@@ -61,37 +68,43 @@ final editor = AppFlowyEditor(
61
68
);
62
69
```
63
70
64
-
To get a sense for how you might use it, run this example:
71
+
To get a sense for how the AppFlowy Editor works, run our example:
cd frontend/app_flowy/packages/appflowy_editor/example
68
76
flutter run
69
77
```
70
78
79
+
## Customizing Your Editor
80
+
81
+
### Customizing Components
71
82
72
-
## How to customize
73
-
### Customize a component
74
-
Please refer to [customizing a component](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/documentation/customizing.md#customize-a-component) for more details.
83
+
Please refer to our documentation on customizing AppFlowy for a detailed discussion about [customizing components](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/documentation/customizing.md#customize-a-component).
75
84
85
+
Below are some examples of component customizations:
76
86
77
-
### Customize a shortcut event
78
-
Please refer to [customizing a shortcut event](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/documentation/customizing.md#customize-a-shortcut-event) for more details.
87
+
*[Checkbox Text](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart) demonstrates how to extend new styles based on existing rich text components
88
+
*[Image](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/example/lib/plugin/network_image_node_widget.dart) demonstrates how to extend a new node and render it
89
+
* See further examples of [rich-text plugins](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text)
90
+
91
+
### Customizing Shortcut Events
79
92
80
-
## More Examples
81
-
* Customize a component
82
-
*[Checkbox Text](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart) shows you how to extend new styles based on existing rich text components
83
-
*[Image](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/example/lib/plugin/network_image_node_widget.dart) teaches you how to extend a new node and render it
84
-
* And more examples on [rich-text plugins](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text)
85
-
* Customize a shortcut event
86
-
*[BIUS](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/update_text_style_by_command_x_handler.dart) shows you how to make text bold/italic/underline/strikethrough through shortcut keys
87
-
*[Paste HTML](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/copy_paste_handler.dart) gives you an idea on how to handle pasted styles through shortcut keys
88
-
* Need more examples? Check out [Internal key event handlers](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers)
93
+
Please refer to our documentation on customizing AppFlowy for a detailed discussion about [customizing shortcut events](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/documentation/customizing.md#customize-a-shortcut-event).
94
+
95
+
Below are some examples of shortcut event customizations:
96
+
97
+
*[BIUS](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/update_text_style_by_command_x_handler.dart) demonstrates how to make text bold/italic/underline/strikethrough through shortcut keys
98
+
*[Paste HTML](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/copy_paste_handler.dart) gives you an idea on how to handle pasted styles through shortcut keys
99
+
* Need more examples? Check out [Internal key event handlers](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers)
89
100
90
101
## Glossary
91
102
Please refer to the API documentation.
92
103
93
104
## Contributing
94
-
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Please look at [CONTRIBUTING.md](https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/contributing-to-appflowy) for details.
105
+
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
106
+
107
+
Please look at [CONTRIBUTING.md](https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/contributing-to-appflowy) for details.
95
108
96
109
## License
97
-
Distributed under the AGPLv3 License. See LICENSE for more information.
110
+
Distributed under the AGPLv3 License. See [LICENSE](https://github.com/AppFlowy-IO/AppFlowy-Docs/blob/main/LICENSE) for more information.
Copy file name to clipboardExpand all lines: frontend/app_flowy/packages/appflowy_editor/documentation/customizing.md
+35-32Lines changed: 35 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# How to customize ...
1
+
# Customizing Editor Features
2
2
3
-
## Customize a shortcut event
3
+
## Customizing a Shortcut Event
4
4
5
5
We will use a simple example to illustrate how to quickly add a shortcut event.
6
6
7
-
For example, typing `_xxx_` will be converted into _xxx_.
7
+
In this example, text that starts and ends with an underscore ( \_ ) character will be rendered in italics for emphasis. So typing `_xxx_` will automatically be converted into _xxx_.
8
8
9
-
Let's start with a blank document.
9
+
Let's start with a blank document:
10
10
11
11
```dart
12
12
@override
@@ -27,31 +27,33 @@ At this point, nothing magic will happen after typing `_xxx_`.
Check out the [complete code](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/example/lib/plugin/underscore_to_italic_key_event_handler.dart) file of this example.
126
+
124
127
125
-
## Customize a component
126
-
We will use a simple example to showcase how to quickly add a custom component.
128
+
## Customizing a Component
129
+
We will use a simple example to show how to quickly add a custom component.
127
130
128
-
For example, we want to render an image from the network.
131
+
In this example we will render an image from the network.
129
132
130
-
To start with, let's create an empty document by running commands as follows:
Next, we choose a unique string for your custom node's type. We use `network_image` in this case. And we add `network_image_src` to the `attributes` to describe the link of the image.
150
+
Next, we will choose a unique string for your custom node's type.
148
151
149
-
> For the definition of the [Node](), please refer to this [link]().
152
+
We'll use `network_image` in this case. And we add `network_image_src`to the `attributes` to describe the link of the image.
150
153
151
154
```JSON
152
155
{
@@ -157,9 +160,9 @@ Next, we choose a unique string for your custom node's type. We use `network_ima
157
160
}
158
161
```
159
162
160
-
Then, we create a class that inherits [NodeWidgetBuilder](). As shown in the autoprompt, we need to implement two functions:
163
+
Then, we create a class that inherits [NodeWidgetBuilder](../lib/src/service/render_plugin_service.dart). As shown in the autoprompt, we need to implement two functions:
161
164
1. one returns a widget
162
-
2. the other verifies the correctness of the [Node]().
165
+
2. the other verifies the correctness of the [Node](../lib/src/document/node.dart).
163
166
164
167
165
168
```dart
@@ -179,9 +182,7 @@ class NetworkImageNodeWidgetBuilder extends NodeWidgetBuilder {
179
182
180
183
Now, let's implement a simple image widget based on `Image`.
181
184
182
-
**It is important to note that the `State` of the returned `Widget` must be with [Selectable]().**
183
-
184
-
> For the definition of the [Selectable](), please refer to this [link]().
185
+
Note that the `State` object that is returned by the `Widget` must implement [Selectable](../lib/src/render/selection/selectable.dart) using the `with` keyword.
185
186
186
187
```dart
187
188
class _NetworkImageNodeWidget extends StatefulWidget {
@@ -236,7 +237,7 @@ class __NetworkImageNodeWidgetState extends State<_NetworkImageNodeWidget>
236
237
}
237
238
```
238
239
239
-
Finally, we return `_NetworkImageNodeWidget` in the `build` function of `NetworkImageNodeWidgetBuilder` and register `NetworkImageNodeWidgetBuilder` into `AppFlowyEditor`.
240
+
Finally, we return `_NetworkImageNodeWidget` in the `build` function of `NetworkImageNodeWidgetBuilder`...
240
241
241
242
```dart
242
243
class NetworkImageNodeWidgetBuilder extends NodeWidgetBuilder {
@@ -256,6 +257,8 @@ class NetworkImageNodeWidgetBuilder extends NodeWidgetBuilder {
256
257
}
257
258
```
258
259
260
+
... and register `NetworkImageNodeWidgetBuilder` in the `AppFlowyEditor`.
261
+
259
262
```dart
260
263
final editorState = EditorState(
261
264
document: StateTree.empty()
@@ -281,6 +284,6 @@ return AppFlowyEditor(
281
284
);
282
285
```
283
286
284
-

287
+

285
288
286
-
[Here you can check out the complete code file of this example]()
289
+
Check out the [complete code](https://github.com/AppFlowy-IO/AppFlowy/blob/main/frontend/app_flowy/packages/appflowy_editor/example/lib/plugin/network_image_node_widget.dart) file of this example.
0 commit comments