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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: update example project and example.json
Lucas.Xu2b2bae80ef0d
diff --git a/frontend/app_flowy/packages/appflowy_editor/example/assets/example.json b/frontend/app_flowy/packages/appflowy_editor/example/assets/example.jsonindex b522a68594..48184a6511 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/assets/example.json+++ b/frontend/app_flowy/packages/appflowy_editor/example/assets/example.json@@ -1,276 +1,102 @@{"document": {"type": "editor",- "attributes": {},"children": [{"type": "image","attributes": {- "image_src": "https://images.squarespace-cdn.com/content/v1/617f6f16b877c06711e87373/c3f23723-37f4-44d7-9c5d-6e2a53064ae7/Asset+10.png",+ "image_src": "https://s1.ax1x.com/2022/08/26/v2sSbR.jpg","align": "center"}},{"type": "text",+ "attributes": { "subtype": "heading", "heading": "h1" },"delta": [+ { "insert": "π " },+ { "insert": "Welcome to ", "attributes": { "bold": true } },{- "insert": "πΆ Read Me"- }- ],- "attributes": {- "subtype": "heading",- "heading": "h1"- }- },- {- "type": "text",- "delta": [- {- "insert": "π Welcome to FlowyEditor"- }- ],- "attributes": {- "subtype": "heading",- "heading": "h2"- }- },- {- "type": "text",- "delta": [- {- "insert": "To be honest, we are still in the alpha stage. There are still many functions that need to be completed. And we are developing more features. Please give us a star if the "- },- {- "insert": "FlowyEditor",+ "insert": "AppFlowy Editor","attributes": {- "href": "https://github.com/AppFlowy-IO/AppFlowy"+ "href": "appflowy.io",+ "italic": true,+ "bold": true}- },- {- "insert": " helps you. πππ"- }- ]- },- {- "type": "text",- "delta": [- {- "insert": "Since the FlowyEditor are a community-driven open source editor, we very welcome and appreciate every pull request submissions from everyone.πππ"}]},+ { "type": "text", "delta": [] },{"type": "text","delta": [- {- "insert": "Here are the basics:"- }- ],- "attributes": {- "subtype": "heading",- "heading": "h3"- }- },- {- "type": "text",- "delta": [- { "insert": "Click " },- { "insert": "anywhere", "attributes": { "underline": true } },- { "insert": " and just typing." }+ { "insert": "AppFlowy Editor is a " },+ { "insert": "highly customizable", "attributes": { "bold": true } },+ { "insert": " " },+ { "insert": "rich-text editor", "attributes": { "italic": true } },+ { "insert": " for " },+ { "insert": "Flutter", "attributes": { "underline": true } }]},{"type": "text",- "delta": [- {- "insert": "Hit"- },- {- "insert": " / ",- "attributes": { "backgroundColor": "0xFFFFFF00" }- },- {- "insert": "to see all the types of content you can add - headers, bulleted lists, checkboxes, etc."- }- ]- },- {- "type": "text",- "delta": [- {- "insert": "Highlight",- "attributes": { "backgroundColor": "0xFF00BCFB" }- },- {- "insert": " any text, and use the menu that pops up to "- },- { "insert": "style", "attributes": { "bold": true } },- { "insert": " your ", "attributes": { "italic": true } },- { "insert": "writing", "attributes": { "strikethrough": true } },- { "insert": "." }- ]- },- {- "type": "text",- "delta": [- {- "insert": "Here are the plugins:"- }- ],- "attributes": {- "subtype": "heading",- "heading": "h3"- }- },- {- "type": "image",- "attributes": {- "image_src": "https://s1.ax1x.com/2022/08/24/vgAJED.png",- "align": "left",- "width": 300- }- },- {- "type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "checkbox",- "checkbox": false- }- },- {- "type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "checkbox",- "checkbox": false- }+ "attributes": { "checkbox": true, "subtype": "checkbox" },+ "delta": [{ "insert": "Customizable" }]},{"type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "checkbox",- "checkbox": false- }+ "attributes": { "checkbox": true, "subtype": "checkbox" },+ "delta": [{ "insert": "Test-covered" }]},{"type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "bulleted-list"- }+ "attributes": { "checkbox": false, "subtype": "checkbox" },+ "delta": [{ "insert": "more to come!" }]},+ { "type": "text", "delta": [] },{"type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "bulleted-list"- }+ "attributes": { "subtype": "quote" },+ "delta": [{ "insert": "Here is an exmaple you can give it a try" }]},+ { "type": "text", "delta": [] },{"type": "text","delta": [+ { "insert": "You can also use " },{- "insert": "Hello "+ "insert": "AppFlowy Editor",+ "attributes": {+ "italic": true,+ "bold": true,+ "backgroundColor": "0x6000BCF0"+ }},- {- "insert": "world",- "attributes": { "bold": true }- }- ],- "attributes": {- "subtype": "bulleted-list"- }- },- {- "type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "quote"- }- },- {- "type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "quote"- }- },- {- "type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "quote"- }+ { "insert": " as a component to build your own app." }+ ]},+ { "type": "text", "delta": [] },{"type": "text",- "delta": [- {- "insert": "Hello world"- }- ],- "attributes": {- "subtype": "number-list",- "number": 1- }+ "attributes": { "subtype": "bulleted-list" },+ "delta": [{ "insert": "Use / to insert blocks" }]},{"type": "text",+ "attributes": { "subtype": "bulleted-list" },"delta": [{- "insert": "Hello world"+ "insert": "Select text to trigger to the toolbar to format your notes."}- ],- "attributes": {- "subtype": "number-list",- "number": 2- }+ ]},+ { "type": "text", "delta": [] },{"type": "text","delta": [{- "insert": "Hello world"+ "insert": "If you have questions or feedback, please submit an issue on Github or join the community along with 1000+ builders!"}- ],- "attributes": {- "subtype": "number-list",- "number": 3- }+ ]}]}diff --git a/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart b/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dartindex 35dd8161db..e72739e246 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart+++ b/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart@@ -20,6 +20,7 @@ class MyApp extends StatelessWidget {@overrideWidget build(BuildContext context) {return MaterialApp(+ debugShowCheckedModeBanner: false,theme: ThemeData(primarySwatch: Colors.blue,),@@ -54,21 +55,27 @@ class _MyHomePageState extends State<MyHomePage> {Widget _buildEditor(BuildContext context) {if (_jsonString != null) {- return _buildEditorWithJsonPath(_jsonString!);+ return _buildEditorWithJsonString(_jsonString!);}if (_pageIndex == 0) {- return _buildEditorWithJsonPath(- rootBundle.loadString('assets/example.json'));+ return _buildEditorWithJsonString(+ rootBundle.loadString('assets/example.json'),+ );} else if (_pageIndex == 1) {- return _buildEditorWithJsonPath(- rootBundle.loadString('assets/big_document.json'));+ return _buildEditorWithJsonString(+ rootBundle.loadString('assets/big_document.json'),+ );} else if (_pageIndex == 2) {- return _buildEditorWithEmptyDocument();+ return _buildEditorWithJsonString(+ Future.value(+ jsonEncode(EditorState.empty().document.toJson()),+ ),+ );}throw UnimplementedError();}- Widget _buildEditorWithJsonPath(Future<String> jsonString) {+ Widget _buildEditorWithJsonString(Future<String> jsonString) {return FutureBuilder<String>(future: jsonString,builder: (_, snapshot) {@@ -86,7 +93,7 @@ class _MyHomePageState extends State<MyHomePage> {debugPrint(message);};return Container(- padding: const EdgeInsets.only(left: 20, right: 20),+ padding: const EdgeInsets.all(20),child: AppFlowyEditor(editorState: _editorState,),@@ -100,19 +107,6 @@ class _MyHomePageState extends State<MyHomePage> {);}- Widget _buildEditorWithEmptyDocument() {- _editorState = EditorState.empty();- _editorState.logConfiguration- ..level = LogLevel.all- ..handler = (message) {- debugPrint(message);- };- final editor = AppFlowyEditor(- editorState: _editorState,- );- return editor;- }-Widget _buildExpandableFab() {return ExpandableFab(distance: 112.0,@@ -130,9 +124,8 @@ class _MyHomePageState extends State<MyHomePage> {onPressed: () => _switchToPage(2),),ActionButton(- icon: const Icon(Icons.print),- onPressed: () => _exportDocument(_editorState),- ),+ icon: const Icon(Icons.print),+ onPressed: () => {_exportDocument(_editorState)}),ActionButton(icon: const Icon(Icons.import_export),onPressed: () => _importDocument(),@@ -148,6 +141,14 @@ class _MyHomePageState extends State<MyHomePage> {final path = directory.path;final file = File('$path/editor.json');await file.writeAsString(json);++ if (mounted) {+ ScaffoldMessenger.of(context).showSnackBar(+ SnackBar(+ content: Text('The document is saved to the ${file.path}'),+ ),+ );+ }}void _importDocument() async {diff --git a/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugin_registrant.ccindex 45a19e066d..00fd3bc03f 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugin_registrant.cc+++ b/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugin_registrant.cc@@ -6,14 +6,10 @@#include "generated_plugin_registrant.h"-#include <file_saver/file_saver_plugin.h>#include <rich_clipboard_linux/rich_clipboard_plugin.h>#include <url_launcher_linux/url_launcher_plugin.h>void fl_register_plugins(FlPluginRegistry* registry) {- g_autoptr(FlPluginRegistrar) file_saver_registrar =- fl_plugin_registry_get_registrar_for_plugin(registry, "FileSaverPlugin");- file_saver_plugin_register_with_registrar(file_saver_registrar);g_autoptr(FlPluginRegistrar) rich_clipboard_linux_registrar =fl_plugin_registry_get_registrar_for_plugin(registry, "RichClipboardPlugin");rich_clipboard_plugin_register_with_registrar(rich_clipboard_linux_registrar);diff --git a/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugins.cmakeindex 10140a75b4..0342e3868a 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugins.cmake+++ b/frontend/app_flowy/packages/appflowy_editor/example/linux/flutter/generated_plugins.cmake@@ -3,7 +3,6 @@#list(APPEND FLUTTER_PLUGIN_LIST- file_saverrich_clipboard_linuxurl_launcher_linux)diff --git a/frontend/app_flowy/packages/appflowy_editor/example/macos/Flutter/GeneratedPluginRegistrant.swift b/frontend/app_flowy/packages/appflowy_editor/example/macos/Flutter/GeneratedPluginRegistrant.swiftindex ac60ac6ec9..08b7c3b866 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/macos/Flutter/GeneratedPluginRegistrant.swift+++ b/frontend/app_flowy/packages/appflowy_editor/example/macos/Flutter/GeneratedPluginRegistrant.swift@@ -5,14 +5,12 @@import FlutterMacOSimport Foundation-import file_saverimport path_provider_macosimport rich_clipboard_macosimport url_launcher_macosimport wakelock_macosfunc RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {- FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))RichClipboardPlugin.register(with: registry.registrar(forPlugin: "RichClipboardPlugin"))UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))diff --git a/frontend/app_flowy/packages/appflowy_editor/example/macos/Podfile.lock b/frontend/app_flowy/packages/appflowy_editor/example/macos/Podfile.lockindex c56e297a68..1fcb47735c 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/macos/Podfile.lock+++ b/frontend/app_flowy/packages/appflowy_editor/example/macos/Podfile.lock@@ -1,6 +1,4 @@PODS:- - file_saver (0.0.1):- - FlutterMacOS- FlutterMacOS (1.0.0)- path_provider_macos (0.0.1):- FlutterMacOS@@ -12,7 +10,6 @@ PODS:- FlutterMacOSDEPENDENCIES:- - file_saver (from `Flutter/ephemeral/.symlinks/plugins/file_saver/macos`)- FlutterMacOS (from `Flutter/ephemeral`)- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)- rich_clipboard_macos (from `Flutter/ephemeral/.symlinks/plugins/rich_clipboard_macos/macos`)@@ -20,8 +17,6 @@ DEPENDENCIES:- wakelock_macos (from `Flutter/ephemeral/.symlinks/plugins/wakelock_macos/macos`)EXTERNAL SOURCES:- file_saver:- :path: Flutter/ephemeral/.symlinks/plugins/file_saver/macosFlutterMacOS::path: Flutter/ephemeralpath_provider_macos:@@ -34,7 +29,6 @@ EXTERNAL SOURCES::path: Flutter/ephemeral/.symlinks/plugins/wakelock_macos/macosSPEC CHECKSUMS:- file_saver: 44e6fbf666677faf097302460e214e977fdd977bFlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19rich_clipboard_macos: 43364b66b9dc69d203eb8dd6d758e2d12e02723cdiff --git a/frontend/app_flowy/packages/appflowy_editor/example/pubspec.yaml b/frontend/app_flowy/packages/appflowy_editor/example/pubspec.yamlindex 9f2fae24bd..5ba51433d6 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/pubspec.yaml+++ b/frontend/app_flowy/packages/appflowy_editor/example/pubspec.yaml@@ -40,7 +40,6 @@ dependencies:video_player: ^2.4.5pod_player: 0.0.8flutter_inappwebview: ^5.4.3+7- file_saver: ^0.1.1path_provider: ^2.0.11dev_dependencies:diff --git a/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugin_registrant.ccindex 391ef56268..4f7884874d 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugin_registrant.cc+++ b/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugin_registrant.cc@@ -6,12 +6,9 @@#include "generated_plugin_registrant.h"-#include <file_saver/file_saver_plugin.h>#include <url_launcher_windows/url_launcher_windows.h>void RegisterPlugins(flutter::PluginRegistry* registry) {- FileSaverPluginRegisterWithRegistrar(- registry->GetRegistrarForPlugin("FileSaverPlugin"));UrlLauncherWindowsRegisterWithRegistrar(registry->GetRegistrarForPlugin("UrlLauncherWindows"));}diff --git a/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugins.cmake b/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugins.cmakeindex 047111654d..88b22e5c77 100644--- a/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugins.cmake+++ b/frontend/app_flowy/packages/appflowy_editor/example/windows/flutter/generated_plugins.cmake@@ -3,7 +3,6 @@#list(APPEND FLUTTER_PLUGIN_LIST- file_saverurl_launcher_windows)