mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: update example project and example.json
This commit is contained in:
parent
b7c21df3b2
commit
2b2bae80ef
@ -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"
|
||||
}
|
||||
],
|
||||
"insert": "AppFlowy Editor",
|
||||
"attributes": {
|
||||
"subtype": "heading",
|
||||
"heading": "h1"
|
||||
"href": "appflowy.io",
|
||||
"italic": true,
|
||||
"bold": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "type": "text", "delta": [] },
|
||||
{
|
||||
"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",
|
||||
"attributes": {
|
||||
"href": "https://github.com/AppFlowy-IO/AppFlowy"
|
||||
}
|
||||
},
|
||||
{
|
||||
"insert": " helps you. 😊😊😊"
|
||||
}
|
||||
{ "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",
|
||||
"attributes": { "checkbox": true, "subtype": "checkbox" },
|
||||
"delta": [{ "insert": "Customizable" }]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"attributes": { "checkbox": true, "subtype": "checkbox" },
|
||||
"delta": [{ "insert": "Test-covered" }]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"attributes": { "checkbox": false, "subtype": "checkbox" },
|
||||
"delta": [{ "insert": "more to come!" }]
|
||||
},
|
||||
{ "type": "text", "delta": [] },
|
||||
{
|
||||
"type": "text",
|
||||
"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": "AppFlowy Editor",
|
||||
"attributes": {
|
||||
"italic": true,
|
||||
"bold": true,
|
||||
"backgroundColor": "0x6000BCF0"
|
||||
}
|
||||
},
|
||||
{ "insert": " as a component to build your own app." }
|
||||
]
|
||||
},
|
||||
{ "type": "text", "delta": [] },
|
||||
{
|
||||
"type": "text",
|
||||
"attributes": { "subtype": "bulleted-list" },
|
||||
"delta": [{ "insert": "Use / to insert blocks" }]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"attributes": { "subtype": "bulleted-list" },
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Since the FlowyEditor are a community-driven open source editor, we very welcome and appreciate every pull request submissions from everyone.😄😄😄"
|
||||
"insert": "Select text to trigger to the toolbar to format your notes."
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "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." }
|
||||
]
|
||||
},
|
||||
{
|
||||
"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."
|
||||
"insert": "If you have questions or feedback, please submit an issue on Github or join the community along with 1000+ builders!"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Hello world"
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"subtype": "checkbox",
|
||||
"checkbox": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Hello world"
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"subtype": "bulleted-list"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Hello world"
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"subtype": "bulleted-list"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Hello "
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Hello world"
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"subtype": "number-list",
|
||||
"number": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Hello world"
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"subtype": "number-list",
|
||||
"number": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"delta": [
|
||||
{
|
||||
"insert": "Hello world"
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"subtype": "number-list",
|
||||
"number": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget 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,
|
||||
@ -131,8 +125,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
ActionButton(
|
||||
icon: const Icon(Icons.print),
|
||||
onPressed: () => _exportDocument(_editorState),
|
||||
),
|
||||
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 {
|
||||
|
@ -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);
|
||||
|
@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_saver
|
||||
rich_clipboard_linux
|
||||
url_launcher_linux
|
||||
)
|
||||
|
@ -5,14 +5,12 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import file_saver
|
||||
import path_provider_macos
|
||||
import rich_clipboard_macos
|
||||
import url_launcher_macos
|
||||
import wakelock_macos
|
||||
|
||||
func 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"))
|
||||
|
@ -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:
|
||||
- FlutterMacOS
|
||||
|
||||
DEPENDENCIES:
|
||||
- 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/macos
|
||||
FlutterMacOS:
|
||||
:path: Flutter/ephemeral
|
||||
path_provider_macos:
|
||||
@ -34,7 +29,6 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/wakelock_macos/macos
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
file_saver: 44e6fbf666677faf097302460e214e977fdd977b
|
||||
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
|
||||
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
|
||||
rich_clipboard_macos: 43364b66b9dc69d203eb8dd6d758e2d12e02723c
|
||||
|
@ -40,7 +40,6 @@ dependencies:
|
||||
video_player: ^2.4.5
|
||||
pod_player: 0.0.8
|
||||
flutter_inappwebview: ^5.4.3+7
|
||||
file_saver: ^0.1.1
|
||||
path_provider: ^2.0.11
|
||||
|
||||
dev_dependencies:
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_saver
|
||||
url_launcher_windows
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user