diff --git a/app_flowy/ios/Podfile.lock b/app_flowy/ios/Podfile.lock new file mode 100644 index 0000000000..65ef402667 --- /dev/null +++ b/app_flowy/ios/Podfile.lock @@ -0,0 +1,52 @@ +PODS: + - flowy_editor (0.0.1): + - Flutter + - flowy_infra_ui (0.0.1): + - Flutter + - flowy_sdk (0.0.1): + - Flutter + - Flutter (1.0.0) + - flutter_keyboard_visibility (0.0.1): + - Flutter + - path_provider (0.0.1): + - Flutter + - url_launcher (0.0.1): + - Flutter + +DEPENDENCIES: + - flowy_editor (from `.symlinks/plugins/flowy_editor/ios`) + - flowy_infra_ui (from `.symlinks/plugins/flowy_infra_ui/ios`) + - flowy_sdk (from `.symlinks/plugins/flowy_sdk/ios`) + - Flutter (from `Flutter`) + - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) + - path_provider (from `.symlinks/plugins/path_provider/ios`) + - url_launcher (from `.symlinks/plugins/url_launcher/ios`) + +EXTERNAL SOURCES: + flowy_editor: + :path: ".symlinks/plugins/flowy_editor/ios" + flowy_infra_ui: + :path: ".symlinks/plugins/flowy_infra_ui/ios" + flowy_sdk: + :path: ".symlinks/plugins/flowy_sdk/ios" + Flutter: + :path: Flutter + flutter_keyboard_visibility: + :path: ".symlinks/plugins/flutter_keyboard_visibility/ios" + path_provider: + :path: ".symlinks/plugins/path_provider/ios" + url_launcher: + :path: ".symlinks/plugins/url_launcher/ios" + +SPEC CHECKSUMS: + flowy_editor: bf8d58894ddb03453bd4d8521c57267ad638b837 + flowy_infra_ui: 146c88346fd55d2ee6a41ae35059a5bf095cfbb3 + flowy_sdk: c416222c639e678828776789bf0c1a1d0d59df3c + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 + path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c + url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef + +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c + +COCOAPODS: 1.10.1 diff --git a/app_flowy/ios/Runner.xcodeproj/project.pbxproj b/app_flowy/ios/Runner.xcodeproj/project.pbxproj index 2b1d21fd89..48c4dd313d 100644 --- a/app_flowy/ios/Runner.xcodeproj/project.pbxproj +++ b/app_flowy/ios/Runner.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 9D1D47ADD7F5DE8237063BCA /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 197F72694BED43249F1523E8 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -31,7 +32,11 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 197F72694BED43249F1523E8 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 35DA03217F6DD4F7AC9356F9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 4C2CB38DA64605A62D45B098 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 580A1ED8E012CA1552E5EFD3 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -49,12 +54,21 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 9D1D47ADD7F5DE8237063BCA /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 78844014EF958DCBB6F9B4EA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 197F72694BED43249F1523E8 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +86,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 9EC83BEE9154F1BD11D24F8F /* Pods */, + 78844014EF958DCBB6F9B4EA /* Frameworks */, ); sourceTree = ""; }; @@ -98,6 +114,17 @@ path = Runner; sourceTree = ""; }; + 9EC83BEE9154F1BD11D24F8F /* Pods */ = { + isa = PBXGroup; + children = ( + 35DA03217F6DD4F7AC9356F9 /* Pods-Runner.debug.xcconfig */, + 580A1ED8E012CA1552E5EFD3 /* Pods-Runner.release.xcconfig */, + 4C2CB38DA64605A62D45B098 /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -105,12 +132,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + E790B8FE5609053209ED85CB /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 08FAA63113168DEC7FB74204 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -169,6 +198,23 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 08FAA63113168DEC7FB74204 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -197,6 +243,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + E790B8FE5609053209ED85CB /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/app_flowy/ios/Runner.xcworkspace/contents.xcworkspacedata b/app_flowy/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a16ed..21a3cc14c7 100644 --- a/app_flowy/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/app_flowy/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/app_flowy/lib/workspace/domain/i_doc.dart b/app_flowy/lib/workspace/domain/i_doc.dart index 3fdc3323c1..92843e29bb 100644 --- a/app_flowy/lib/workspace/domain/i_doc.dart +++ b/app_flowy/lib/workspace/domain/i_doc.dart @@ -1,9 +1,9 @@ import 'dart:convert'; import 'dart:async'; -import 'package:flowy_editor/flowy_editor.dart'; import 'package:dartz/dartz.dart'; // ignore: implementation_imports -import 'package:flowy_editor/src/model/quill_delta.dart'; +import 'package:editor/flutter_quill.dart'; +// import 'package:flowy_editor/flowy_editor.dart'; import 'package:flowy_log/flowy_log.dart'; import 'package:flowy_sdk/protobuf/flowy-document/doc.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart'; diff --git a/app_flowy/lib/workspace/presentation/doc/doc_page.dart b/app_flowy/lib/workspace/presentation/doc/doc_page.dart index 1dfb6c8ce4..54da272466 100644 --- a/app_flowy/lib/workspace/presentation/doc/doc_page.dart +++ b/app_flowy/lib/workspace/presentation/doc/doc_page.dart @@ -3,19 +3,19 @@ import 'dart:io'; import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/application/doc/doc_edit_bloc.dart'; import 'package:app_flowy/workspace/domain/i_doc.dart'; -import 'package:flowy_editor/flowy_editor.dart'; +// import 'package:flowy_editor/flowy_editor.dart'; +import 'package:editor/flutter_quill.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -// ignore: must_be_immutable class DocPage extends StatefulWidget { - late EditorController controller; + late QuillController controller; late DocEditBloc editBloc; final FlowyDoc doc; DocPage({Key? key, required this.doc}) : super(key: key) { editBloc = getIt(param1: doc.id); - controller = EditorController( + controller = QuillController( document: doc.document, selection: const TextSelection.collapsed(offset: 0), ); @@ -54,8 +54,8 @@ class _DocPageState extends State { await widget.doc.close(); } - Widget _renderEditor(EditorController controller) { - final editor = FlowyEditor( + Widget _renderEditor(QuillController controller) { + final editor = QuillEditor( controller: controller, focusNode: _focusNode, scrollable: true, @@ -71,10 +71,9 @@ class _DocPageState extends State { ); } - Widget _renderToolbar(EditorController controller) { - return FlowyToolbar.basic( + Widget _renderToolbar(QuillController controller) { + return QuillToolbar.basic( controller: controller, - onImageSelectCallback: _onImageSelection, ); } @@ -82,3 +81,81 @@ class _DocPageState extends State { throw UnimplementedError(); } } + +// import 'package:flowy_editor/flowy_editor.dart'; + +// ignore: must_be_immutable +// class DocPage extends StatefulWidget { +// late EditorController controller; +// late DocEditBloc editBloc; +// final FlowyDoc doc; + +// DocPage({Key? key, required this.doc}) : super(key: key) { +// editBloc = getIt(param1: doc.id); +// controller = EditorController( +// document: doc.document, +// selection: const TextSelection.collapsed(offset: 0), +// ); +// } + +// @override +// State createState() => _DocPageState(); +// } + +// class _DocPageState extends State { +// final FocusNode _focusNode = FocusNode(); + +// @override +// Widget build(BuildContext context) { +// return BlocProvider.value( +// value: widget.editBloc, +// child: BlocBuilder( +// builder: (ctx, state) { +// return Column( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// _renderEditor(widget.controller), +// _renderToolbar(widget.controller), +// ], +// ); +// }, +// ), +// ); +// } + +// @override +// Future dispose() async { +// widget.editBloc.add(const DocEditEvent.close()); +// widget.editBloc.close(); +// super.dispose(); +// await widget.doc.close(); +// } + +// Widget _renderEditor(EditorController controller) { +// final editor = FlowyEditor( +// controller: controller, +// focusNode: _focusNode, +// scrollable: true, +// autoFocus: false, +// expands: false, +// padding: const EdgeInsets.symmetric(horizontal: 8.0), +// readOnly: false, +// scrollBottomInset: 0, +// scrollController: ScrollController(), +// ); +// return Expanded( +// child: Padding(padding: const EdgeInsets.all(10), child: editor), +// ); +// } + +// Widget _renderToolbar(EditorController controller) { +// return FlowyToolbar.basic( +// controller: controller, +// onImageSelectCallback: _onImageSelection, +// ); +// } + +// Future _onImageSelection(File file) { +// throw UnimplementedError(); +// } +// } diff --git a/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift b/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift index f0757e328c..b23c6473e2 100644 --- a/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/app_flowy/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,7 @@ import FlutterMacOS import Foundation +import editor import flowy_editor import flowy_infra_ui import flowy_sdk @@ -13,6 +14,7 @@ import url_launcher_macos import window_size func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + EditorPlugin.register(with: registry.registrar(forPlugin: "EditorPlugin")) FlowyEditorPlugin.register(with: registry.registrar(forPlugin: "FlowyEditorPlugin")) FlowyInfraUIPlugin.register(with: registry.registrar(forPlugin: "FlowyInfraUIPlugin")) FlowySdkPlugin.register(with: registry.registrar(forPlugin: "FlowySdkPlugin")) diff --git a/app_flowy/macos/Podfile.lock b/app_flowy/macos/Podfile.lock index e1cf0b5146..e6ace5b16e 100644 --- a/app_flowy/macos/Podfile.lock +++ b/app_flowy/macos/Podfile.lock @@ -1,4 +1,6 @@ PODS: + - editor (0.0.1): + - FlutterMacOS - flowy_editor (0.0.1): - FlutterMacOS - flowy_infra_ui (0.0.1): @@ -14,6 +16,7 @@ PODS: - FlutterMacOS DEPENDENCIES: + - editor (from `Flutter/ephemeral/.symlinks/plugins/editor/macos`) - flowy_editor (from `Flutter/ephemeral/.symlinks/plugins/flowy_editor/macos`) - flowy_infra_ui (from `Flutter/ephemeral/.symlinks/plugins/flowy_infra_ui/macos`) - flowy_sdk (from `Flutter/ephemeral/.symlinks/plugins/flowy_sdk/macos`) @@ -23,6 +26,8 @@ DEPENDENCIES: - window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`) EXTERNAL SOURCES: + editor: + :path: Flutter/ephemeral/.symlinks/plugins/editor/macos flowy_editor: :path: Flutter/ephemeral/.symlinks/plugins/flowy_editor/macos flowy_infra_ui: @@ -39,6 +44,7 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/window_size/macos SPEC CHECKSUMS: + editor: 380351c0334fbeb0e431e4e49629c9e2d925b66d flowy_editor: 26060a984848e6afac1f6a4455511f4114119d8d flowy_infra_ui: 9d5021b1610fe0476eb1191bf7cd41c4a4138d8f flowy_sdk: c302ac0a22dea596db0df8073b9637b2bf2ff6fd diff --git a/app_flowy/packages/editor/.gitignore b/app_flowy/packages/editor/.gitignore new file mode 100644 index 0000000000..9be145fde9 --- /dev/null +++ b/app_flowy/packages/editor/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/app_flowy/packages/editor/.metadata b/app_flowy/packages/editor/.metadata new file mode 100644 index 0000000000..e625d09562 --- /dev/null +++ b/app_flowy/packages/editor/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 4b330ddbedab445481cc73d50a4695b9154b4e4f + channel: dev + +project_type: plugin diff --git a/app_flowy/packages/editor/CHANGELOG.md b/app_flowy/packages/editor/CHANGELOG.md new file mode 100644 index 0000000000..41cc7d8192 --- /dev/null +++ b/app_flowy/packages/editor/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/app_flowy/packages/editor/LICENSE b/app_flowy/packages/editor/LICENSE new file mode 100644 index 0000000000..ba75c69f7f --- /dev/null +++ b/app_flowy/packages/editor/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/app_flowy/packages/editor/README.md b/app_flowy/packages/editor/README.md new file mode 100644 index 0000000000..d40ce861c4 --- /dev/null +++ b/app_flowy/packages/editor/README.md @@ -0,0 +1,15 @@ +# editor + +A new flutter plugin project. + +## Getting Started + +This project is a starting point for a Flutter +[plug-in package](https://flutter.dev/developing-packages/), +a specialized package that includes platform-specific implementation code for +Android and/or iOS. + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. + diff --git a/app_flowy/packages/editor/analysis_options.yaml b/app_flowy/packages/editor/analysis_options.yaml new file mode 100644 index 0000000000..a5744c1cfb --- /dev/null +++ b/app_flowy/packages/editor/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/app_flowy/packages/editor/example/.gitignore b/app_flowy/packages/editor/example/.gitignore new file mode 100644 index 0000000000..0fa6b675c0 --- /dev/null +++ b/app_flowy/packages/editor/example/.gitignore @@ -0,0 +1,46 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/app_flowy/packages/editor/example/.metadata b/app_flowy/packages/editor/example/.metadata new file mode 100644 index 0000000000..f941867ca7 --- /dev/null +++ b/app_flowy/packages/editor/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 4b330ddbedab445481cc73d50a4695b9154b4e4f + channel: dev + +project_type: app diff --git a/app_flowy/packages/editor/example/README.md b/app_flowy/packages/editor/example/README.md new file mode 100644 index 0000000000..e97c9163b6 --- /dev/null +++ b/app_flowy/packages/editor/example/README.md @@ -0,0 +1,16 @@ +# editor_example + +Demonstrates how to use the editor plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/app_flowy/packages/editor/example/analysis_options.yaml b/app_flowy/packages/editor/example/analysis_options.yaml new file mode 100644 index 0000000000..61b6c4de17 --- /dev/null +++ b/app_flowy/packages/editor/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/app_flowy/packages/editor/example/lib/main.dart b/app_flowy/packages/editor/example/lib/main.dart new file mode 100644 index 0000000000..69e1dba469 --- /dev/null +++ b/app_flowy/packages/editor/example/lib/main.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:flutter/services.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + String _platformVersion = 'Unknown'; + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Running on: $_platformVersion\n'), + ), + ), + ); + } +} diff --git a/app_flowy/packages/editor/example/macos/.gitignore b/app_flowy/packages/editor/example/macos/.gitignore new file mode 100644 index 0000000000..746adbb6b9 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/app_flowy/packages/editor/example/macos/Flutter/Flutter-Debug.xcconfig b/app_flowy/packages/editor/example/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000000..4b81f9b2d2 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/app_flowy/packages/editor/example/macos/Flutter/Flutter-Release.xcconfig b/app_flowy/packages/editor/example/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000000..5caa9d1579 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/app_flowy/packages/editor/example/macos/Flutter/GeneratedPluginRegistrant.swift b/app_flowy/packages/editor/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000000..8ad27b61c9 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import editor +import url_launcher_macos + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + EditorPlugin.register(with: registry.registrar(forPlugin: "EditorPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) +} diff --git a/app_flowy/packages/editor/example/macos/Podfile b/app_flowy/packages/editor/example/macos/Podfile new file mode 100644 index 0000000000..dade8dfad0 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Podfile @@ -0,0 +1,40 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/app_flowy/packages/editor/example/macos/Runner.xcodeproj/project.pbxproj b/app_flowy/packages/editor/example/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..67d4a67167 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,572 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* editor_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "editor_example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* editor_example.app */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* editor_example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/app_flowy/packages/editor/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/app_flowy/packages/editor/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/app_flowy/packages/editor/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/app_flowy/packages/editor/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000000..5b8298c9f7 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app_flowy/packages/editor/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/app_flowy/packages/editor/example/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..1d526a16ed --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/app_flowy/packages/editor/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/app_flowy/packages/editor/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/app_flowy/packages/editor/example/macos/Runner/AppDelegate.swift b/app_flowy/packages/editor/example/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000000..d53ef64377 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..a2ec33f19f --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000000..3c4935a7ca Binary files /dev/null and b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000000..ed4cc16421 Binary files /dev/null and b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000000..483be61389 Binary files /dev/null and b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000000..bcbf36df2f Binary files /dev/null and b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000000..9c0a652864 Binary files /dev/null and b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000000..e71a726136 Binary files /dev/null and b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000000..8a31fe2dd3 Binary files /dev/null and b/app_flowy/packages/editor/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/app_flowy/packages/editor/example/macos/Runner/Base.lproj/MainMenu.xib b/app_flowy/packages/editor/example/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000..537341abf9 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app_flowy/packages/editor/example/macos/Runner/Configs/AppInfo.xcconfig b/app_flowy/packages/editor/example/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000000..42ef1adbb6 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = editor_example + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.editorExample + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved. diff --git a/app_flowy/packages/editor/example/macos/Runner/Configs/Debug.xcconfig b/app_flowy/packages/editor/example/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000000..36b0fd9464 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/app_flowy/packages/editor/example/macos/Runner/Configs/Release.xcconfig b/app_flowy/packages/editor/example/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000000..dff4f49561 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/app_flowy/packages/editor/example/macos/Runner/Configs/Warnings.xcconfig b/app_flowy/packages/editor/example/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000000..42bcbf4780 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/app_flowy/packages/editor/example/macos/Runner/DebugProfile.entitlements b/app_flowy/packages/editor/example/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000000..dddb8a30c8 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/app_flowy/packages/editor/example/macos/Runner/Info.plist b/app_flowy/packages/editor/example/macos/Runner/Info.plist new file mode 100644 index 0000000000..4789daa6a4 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/app_flowy/packages/editor/example/macos/Runner/MainFlutterWindow.swift b/app_flowy/packages/editor/example/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000000..2722837ec9 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController.init() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/app_flowy/packages/editor/example/macos/Runner/Release.entitlements b/app_flowy/packages/editor/example/macos/Runner/Release.entitlements new file mode 100644 index 0000000000..852fa1a472 --- /dev/null +++ b/app_flowy/packages/editor/example/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/app_flowy/packages/editor/example/pubspec.lock b/app_flowy/packages/editor/example/pubspec.lock new file mode 100644 index 0000000000..80209b263b --- /dev/null +++ b/app_flowy/packages/editor/example/pubspec.lock @@ -0,0 +1,404 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + cross_file: + dependency: transitive + description: + name: cross_file + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.1+5" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.1" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + diff_match_patch: + dependency: transitive + description: + name: diff_match_patch + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.1" + editor: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_colorpicker: + dependency: transitive + description: + name: flutter_colorpicker + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + flutter_inappwebview: + dependency: transitive + description: + name: flutter_inappwebview + url: "https://pub.dartlang.org" + source: hosted + version: "5.3.2" + flutter_keyboard_visibility: + dependency: transitive + description: + name: flutter_keyboard_visibility + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.3" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + html: + dependency: transitive + description: + name: html + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.4" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + image_picker: + dependency: transitive + description: + name: image_picker + url: "https://pub.dartlang.org" + source: hosted + version: "0.8.4+2" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.1" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" + photo_view: + dependency: transitive + description: + name: photo_view + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + string_validator: + dependency: transitive + description: + name: string_validator + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.3" + tuple: + dependency: transitive + description: + name: tuple + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + url_launcher: + dependency: transitive + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.12" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + video_player: + dependency: transitive + description: + name: video_player + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.5" + video_player_platform_interface: + dependency: transitive + description: + name: video_player_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.0" + video_player_web: + dependency: transitive + description: + name: video_player_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + youtube_player_flutter: + dependency: transitive + description: + name: youtube_player_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.0" +sdks: + dart: ">=2.15.0-116.0.dev <3.0.0" + flutter: ">=2.5.0" diff --git a/app_flowy/packages/editor/example/pubspec.yaml b/app_flowy/packages/editor/example/pubspec.yaml new file mode 100644 index 0000000000..803fcf2d18 --- /dev/null +++ b/app_flowy/packages/editor/example/pubspec.yaml @@ -0,0 +1,84 @@ +name: editor_example +description: Demonstrates how to use the editor plugin. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: ">=2.15.0-116.0.dev <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + editor: + # When depending on this package from a real application you should use: + # editor: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^1.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/app_flowy/packages/editor/example/test/widget_test.dart b/app_flowy/packages/editor/example/test/widget_test.dart new file mode 100644 index 0000000000..490370c0db --- /dev/null +++ b/app_flowy/packages/editor/example/test/widget_test.dart @@ -0,0 +1,11 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +// import 'package:flutter/material.dart'; +// import 'package:flutter_test/flutter_test.dart'; + +void main() {} diff --git a/app_flowy/packages/editor/lib/flutter_quill.dart b/app_flowy/packages/editor/lib/flutter_quill.dart new file mode 100644 index 0000000000..6b6754ceb4 --- /dev/null +++ b/app_flowy/packages/editor/lib/flutter_quill.dart @@ -0,0 +1,11 @@ +library flutter_quill; + +export 'src/models/documents/attribute.dart'; +export 'src/models/documents/document.dart'; +export 'src/models/documents/nodes/embed.dart'; +export 'src/models/documents/nodes/leaf.dart'; +export 'src/models/quill_delta.dart'; +export 'src/widgets/controller.dart'; +export 'src/widgets/default_styles.dart'; +export 'src/widgets/editor.dart'; +export 'src/widgets/toolbar.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/attribute.dart b/app_flowy/packages/editor/lib/models/documents/attribute.dart new file mode 100644 index 0000000000..e106383eb9 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/attribute.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/documents/attribute.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/document.dart b/app_flowy/packages/editor/lib/models/documents/document.dart new file mode 100644 index 0000000000..a187d19d81 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/document.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/documents/document.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/history.dart b/app_flowy/packages/editor/lib/models/documents/history.dart new file mode 100644 index 0000000000..b07c8e3315 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/history.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/documents/history.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/nodes/block.dart b/app_flowy/packages/editor/lib/models/documents/nodes/block.dart new file mode 100644 index 0000000000..6de6f7437e --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/nodes/block.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../../src/models/documents/nodes/block.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/nodes/container.dart b/app_flowy/packages/editor/lib/models/documents/nodes/container.dart new file mode 100644 index 0000000000..d9a54451fd --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/nodes/container.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../../src/models/documents/nodes/container.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/nodes/embed.dart b/app_flowy/packages/editor/lib/models/documents/nodes/embed.dart new file mode 100644 index 0000000000..01dc357bcb --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/nodes/embed.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../../src/models/documents/nodes/embed.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/nodes/leaf.dart b/app_flowy/packages/editor/lib/models/documents/nodes/leaf.dart new file mode 100644 index 0000000000..cc2808f216 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/nodes/leaf.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../../src/models/documents/nodes/leaf.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/nodes/line.dart b/app_flowy/packages/editor/lib/models/documents/nodes/line.dart new file mode 100644 index 0000000000..7ca2016efe --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/nodes/line.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../../src/models/documents/nodes/line.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/nodes/node.dart b/app_flowy/packages/editor/lib/models/documents/nodes/node.dart new file mode 100644 index 0000000000..210c167220 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/nodes/node.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../../src/models/documents/nodes/node.dart'; diff --git a/app_flowy/packages/editor/lib/models/documents/style.dart b/app_flowy/packages/editor/lib/models/documents/style.dart new file mode 100644 index 0000000000..6df9412b50 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/documents/style.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/documents/style.dart'; diff --git a/app_flowy/packages/editor/lib/models/quill_delta.dart b/app_flowy/packages/editor/lib/models/quill_delta.dart new file mode 100644 index 0000000000..796d68ca8c --- /dev/null +++ b/app_flowy/packages/editor/lib/models/quill_delta.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../src/models/quill_delta.dart'; diff --git a/app_flowy/packages/editor/lib/models/rules/delete.dart b/app_flowy/packages/editor/lib/models/rules/delete.dart new file mode 100644 index 0000000000..0430686b1a --- /dev/null +++ b/app_flowy/packages/editor/lib/models/rules/delete.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/rules/delete.dart'; diff --git a/app_flowy/packages/editor/lib/models/rules/format.dart b/app_flowy/packages/editor/lib/models/rules/format.dart new file mode 100644 index 0000000000..7d642af37b --- /dev/null +++ b/app_flowy/packages/editor/lib/models/rules/format.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/rules/format.dart'; diff --git a/app_flowy/packages/editor/lib/models/rules/insert.dart b/app_flowy/packages/editor/lib/models/rules/insert.dart new file mode 100644 index 0000000000..04e7a4fac1 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/rules/insert.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/rules/insert.dart'; diff --git a/app_flowy/packages/editor/lib/models/rules/rule.dart b/app_flowy/packages/editor/lib/models/rules/rule.dart new file mode 100644 index 0000000000..ccea0dda86 --- /dev/null +++ b/app_flowy/packages/editor/lib/models/rules/rule.dart @@ -0,0 +1,3 @@ +/// TODO: Remove this file in the next breaking release, because implementation +/// files should be located in the src folder, https://bit.ly/3fA23Yz. +export '../../src/models/rules/rule.dart'; diff --git a/app_flowy/packages/editor/lib/src/models/documents/attribute.dart b/app_flowy/packages/editor/lib/src/models/documents/attribute.dart new file mode 100644 index 0000000000..db667ce107 --- /dev/null +++ b/app_flowy/packages/editor/lib/src/models/documents/attribute.dart @@ -0,0 +1,314 @@ +import 'dart:collection'; + +import 'package:quiver/core.dart'; + +enum AttributeScope { + INLINE, // refer to https://quilljs.com/docs/formats/#inline + BLOCK, // refer to https://quilljs.com/docs/formats/#block + EMBEDS, // refer to https://quilljs.com/docs/formats/#embeds + IGNORE, // attributes that can be ignored +} + +class Attribute { + Attribute(this.key, this.scope, this.value); + + final String key; + final AttributeScope scope; + final T value; + + static final Map _registry = LinkedHashMap.of({ + Attribute.bold.key: Attribute.bold, + Attribute.italic.key: Attribute.italic, + Attribute.small.key: Attribute.small, + Attribute.underline.key: Attribute.underline, + Attribute.strikeThrough.key: Attribute.strikeThrough, + Attribute.inlineCode.key: Attribute.inlineCode, + Attribute.font.key: Attribute.font, + Attribute.size.key: Attribute.size, + Attribute.link.key: Attribute.link, + Attribute.color.key: Attribute.color, + Attribute.background.key: Attribute.background, + Attribute.placeholder.key: Attribute.placeholder, + Attribute.header.key: Attribute.header, + Attribute.align.key: Attribute.align, + Attribute.list.key: Attribute.list, + Attribute.codeBlock.key: Attribute.codeBlock, + Attribute.blockQuote.key: Attribute.blockQuote, + Attribute.indent.key: Attribute.indent, + Attribute.width.key: Attribute.width, + Attribute.height.key: Attribute.height, + Attribute.style.key: Attribute.style, + Attribute.token.key: Attribute.token, + }); + + static final BoldAttribute bold = BoldAttribute(); + + static final ItalicAttribute italic = ItalicAttribute(); + + static final SmallAttribute small = SmallAttribute(); + + static final UnderlineAttribute underline = UnderlineAttribute(); + + static final StrikeThroughAttribute strikeThrough = StrikeThroughAttribute(); + + static final InlineCodeAttribute inlineCode = InlineCodeAttribute(); + + static final FontAttribute font = FontAttribute(null); + + static final SizeAttribute size = SizeAttribute(null); + + static final LinkAttribute link = LinkAttribute(null); + + static final ColorAttribute color = ColorAttribute(null); + + static final BackgroundAttribute background = BackgroundAttribute(null); + + static final PlaceholderAttribute placeholder = PlaceholderAttribute(); + + static final HeaderAttribute header = HeaderAttribute(); + + static final IndentAttribute indent = IndentAttribute(); + + static final AlignAttribute align = AlignAttribute(null); + + static final ListAttribute list = ListAttribute(null); + + static final CodeBlockAttribute codeBlock = CodeBlockAttribute(); + + static final BlockQuoteAttribute blockQuote = BlockQuoteAttribute(); + + static final WidthAttribute width = WidthAttribute(null); + + static final HeightAttribute height = HeightAttribute(null); + + static final StyleAttribute style = StyleAttribute(null); + + static final TokenAttribute token = TokenAttribute(''); + + static final Set inlineKeys = { + Attribute.bold.key, + Attribute.italic.key, + Attribute.small.key, + Attribute.underline.key, + Attribute.strikeThrough.key, + Attribute.link.key, + Attribute.color.key, + Attribute.background.key, + Attribute.placeholder.key, + }; + + static final Set blockKeys = LinkedHashSet.of({ + Attribute.header.key, + Attribute.align.key, + Attribute.list.key, + Attribute.codeBlock.key, + Attribute.blockQuote.key, + Attribute.indent.key, + }); + + static final Set blockKeysExceptHeader = LinkedHashSet.of({ + Attribute.list.key, + Attribute.align.key, + Attribute.codeBlock.key, + Attribute.blockQuote.key, + Attribute.indent.key, + }); + + static final Set exclusiveBlockKeys = LinkedHashSet.of({ + Attribute.header.key, + Attribute.list.key, + Attribute.codeBlock.key, + Attribute.blockQuote.key, + }); + + static Attribute get h1 => HeaderAttribute(level: 1); + + static Attribute get h2 => HeaderAttribute(level: 2); + + static Attribute get h3 => HeaderAttribute(level: 3); + + // "attributes":{"align":"left"} + static Attribute get leftAlignment => AlignAttribute('left'); + + // "attributes":{"align":"center"} + static Attribute get centerAlignment => AlignAttribute('center'); + + // "attributes":{"align":"right"} + static Attribute get rightAlignment => AlignAttribute('right'); + + // "attributes":{"align":"justify"} + static Attribute get justifyAlignment => AlignAttribute('justify'); + + // "attributes":{"list":"bullet"} + static Attribute get ul => ListAttribute('bullet'); + + // "attributes":{"list":"ordered"} + static Attribute get ol => ListAttribute('ordered'); + + // "attributes":{"list":"checked"} + static Attribute get checked => ListAttribute('checked'); + + // "attributes":{"list":"unchecked"} + static Attribute get unchecked => ListAttribute('unchecked'); + + // "attributes":{"indent":1"} + static Attribute get indentL1 => IndentAttribute(level: 1); + + // "attributes":{"indent":2"} + static Attribute get indentL2 => IndentAttribute(level: 2); + + // "attributes":{"indent":3"} + static Attribute get indentL3 => IndentAttribute(level: 3); + + static Attribute getIndentLevel(int? level) { + if (level == 1) { + return indentL1; + } + if (level == 2) { + return indentL2; + } + if (level == 3) { + return indentL3; + } + return IndentAttribute(level: level); + } + + bool get isInline => scope == AttributeScope.INLINE; + + bool get isBlockExceptHeader => blockKeysExceptHeader.contains(key); + + Map toJson() => {key: value}; + + static Attribute? fromKeyValue(String key, dynamic value) { + final origin = _registry[key]; + if (origin == null) { + return null; + } + final attribute = clone(origin, value); + return attribute; + } + + static int getRegistryOrder(Attribute attribute) { + var order = 0; + for (final attr in _registry.values) { + if (attr.key == attribute.key) { + break; + } + order++; + } + + return order; + } + + static Attribute clone(Attribute origin, dynamic value) { + return Attribute(origin.key, origin.scope, value); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! Attribute) return false; + final typedOther = other; + return key == typedOther.key && + scope == typedOther.scope && + value == typedOther.value; + } + + @override + int get hashCode => hash3(key, scope, value); + + @override + String toString() { + return 'Attribute{key: $key, scope: $scope, value: $value}'; + } +} + +class BoldAttribute extends Attribute { + BoldAttribute() : super('bold', AttributeScope.INLINE, true); +} + +class ItalicAttribute extends Attribute { + ItalicAttribute() : super('italic', AttributeScope.INLINE, true); +} + +class SmallAttribute extends Attribute { + SmallAttribute() : super('small', AttributeScope.INLINE, true); +} + +class UnderlineAttribute extends Attribute { + UnderlineAttribute() : super('underline', AttributeScope.INLINE, true); +} + +class StrikeThroughAttribute extends Attribute { + StrikeThroughAttribute() : super('strike', AttributeScope.INLINE, true); +} + +class InlineCodeAttribute extends Attribute { + InlineCodeAttribute() : super('code', AttributeScope.INLINE, true); +} + +class FontAttribute extends Attribute { + FontAttribute(String? val) : super('font', AttributeScope.INLINE, val); +} + +class SizeAttribute extends Attribute { + SizeAttribute(String? val) : super('size', AttributeScope.INLINE, val); +} + +class LinkAttribute extends Attribute { + LinkAttribute(String? val) : super('link', AttributeScope.INLINE, val); +} + +class ColorAttribute extends Attribute { + ColorAttribute(String? val) : super('color', AttributeScope.INLINE, val); +} + +class BackgroundAttribute extends Attribute { + BackgroundAttribute(String? val) + : super('background', AttributeScope.INLINE, val); +} + +/// This is custom attribute for hint +class PlaceholderAttribute extends Attribute { + PlaceholderAttribute() : super('placeholder', AttributeScope.INLINE, true); +} + +class HeaderAttribute extends Attribute { + HeaderAttribute({int? level}) : super('header', AttributeScope.BLOCK, level); +} + +class IndentAttribute extends Attribute { + IndentAttribute({int? level}) : super('indent', AttributeScope.BLOCK, level); +} + +class AlignAttribute extends Attribute { + AlignAttribute(String? val) : super('align', AttributeScope.BLOCK, val); +} + +class ListAttribute extends Attribute { + ListAttribute(String? val) : super('list', AttributeScope.BLOCK, val); +} + +class CodeBlockAttribute extends Attribute { + CodeBlockAttribute() : super('code-block', AttributeScope.BLOCK, true); +} + +class BlockQuoteAttribute extends Attribute { + BlockQuoteAttribute() : super('blockquote', AttributeScope.BLOCK, true); +} + +class WidthAttribute extends Attribute { + WidthAttribute(String? val) : super('width', AttributeScope.IGNORE, val); +} + +class HeightAttribute extends Attribute { + HeightAttribute(String? val) : super('height', AttributeScope.IGNORE, val); +} + +class StyleAttribute extends Attribute { + StyleAttribute(String? val) : super('style', AttributeScope.IGNORE, val); +} + +class TokenAttribute extends Attribute { + TokenAttribute(String val) : super('token', AttributeScope.IGNORE, val); +} diff --git a/app_flowy/packages/editor/lib/src/models/documents/document.dart b/app_flowy/packages/editor/lib/src/models/documents/document.dart new file mode 100644 index 0000000000..9e6ce6b79b --- /dev/null +++ b/app_flowy/packages/editor/lib/src/models/documents/document.dart @@ -0,0 +1,291 @@ +import 'dart:async'; + +import 'package:tuple/tuple.dart'; + +import '../quill_delta.dart'; +import '../rules/rule.dart'; +import 'attribute.dart'; +import 'history.dart'; +import 'nodes/block.dart'; +import 'nodes/container.dart'; +import 'nodes/embed.dart'; +import 'nodes/line.dart'; +import 'nodes/node.dart'; +import 'style.dart'; + +/// The rich text document +class Document { + Document() : _delta = Delta()..insert('\n') { + _loadDocument(_delta); + } + + Document.fromJson(List data) : _delta = _transform(Delta.fromJson(data)) { + _loadDocument(_delta); + } + + Document.fromDelta(Delta delta) : _delta = delta { + _loadDocument(delta); + } + + /// The root node of the document tree + final Root _root = Root(); + + Root get root => _root; + + int get length => _root.length; + + Delta _delta; + + Delta toDelta() => Delta.from(_delta); + + final Rules _rules = Rules.getInstance(); + + void setCustomRules(List customRules) { + _rules.setCustomRules(customRules); + } + + final StreamController> _observer = + StreamController.broadcast(); + + final History _history = History(); + + Stream> get changes => _observer.stream; + + Delta insert(int index, Object? data, {int replaceLength = 0}) { + assert(index >= 0); + assert(data is String || data is Embeddable); + if (data is Embeddable) { + data = data.toJson(); + } else if ((data as String).isEmpty) { + return Delta(); + } + + final delta = _rules.apply(RuleType.INSERT, this, index, + data: data, len: replaceLength); + compose(delta, ChangeSource.LOCAL); + return delta; + } + + Delta delete(int index, int len) { + assert(index >= 0 && len > 0); + final delta = _rules.apply(RuleType.DELETE, this, index, len: len); + if (delta.isNotEmpty) { + compose(delta, ChangeSource.LOCAL); + } + return delta; + } + + Delta replace(int index, int len, Object? data) { + assert(index >= 0); + assert(data is String || data is Embeddable); + + final dataIsNotEmpty = (data is String) ? data.isNotEmpty : true; + + assert(dataIsNotEmpty || len > 0); + + var delta = Delta(); + + // We have to insert before applying delete rules + // Otherwise delete would be operating on stale document snapshot. + if (dataIsNotEmpty) { + delta = insert(index, data, replaceLength: len); + } + + if (len > 0) { + final deleteDelta = delete(index, len); + delta = delta.compose(deleteDelta); + } + + return delta; + } + + Delta format(int index, int len, Attribute? attribute) { + assert(index >= 0 && len >= 0 && attribute != null); + + var delta = Delta(); + + final formatDelta = _rules.apply(RuleType.FORMAT, this, index, + len: len, attribute: attribute); + if (formatDelta.isNotEmpty) { + compose(formatDelta, ChangeSource.LOCAL); + delta = delta.compose(formatDelta); + } + + return delta; + } + + /// Only attributes applied to all characters within this range are + /// included in the result. + Style collectStyle(int index, int len) { + final res = queryChild(index); + return (res.node as Line).collectStyle(res.offset, len); + } + + /// Returns all styles for any character within the specified text range. + List