chore: sync the latest code from main repo (#25)

This commit is contained in:
Lucas.Xu 2023-03-22 16:36:32 +08:00 • committed by GitHub
commit c89ea36ce7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 185 additions and 81 deletions

View file

@ -1,8 +1,11 @@
## 0.1.3
* chore: update the dependencies to the latest release by @LucasXu0 ([#25](https://github.com/AppFlowy-IO/appflowy-editor/pull/25)).
## 0.1.2 ## 0.1.2
* fix: #7 bug on node iterator with nested nodes by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/11 * fix: bug on node iterator with nested nodes by @LucasXu0 ([#11](https://github.com/AppFlowy-IO/appflowy-editor/pull/11)).
* fix: #8 SVG display error in the latest version by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/12 * fix: SVG display error in the latest version by @LucasXu0 ([#12](https://github.com/AppFlowy-IO/appflowy-editor/pull/12)).
* fix: #9 Using the mouse to highlight text very easy to miss the first letter by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/13 * fix: Using the mouse to highlight text very easy to miss the first letter by @LucasXu0 ([#13](https://github.com/AppFlowy-IO/appflowy-editor/pull/13)).
* chore: fix some known issues by @LucasXu0 in https://github.com/AppFlowy-IO/appflowy-editor/pull/14 * chore: fix some known issues by @LucasXu0 in ([#14](https://github.com/AppFlowy-IO/appflowy-editor/pull/14)).
## 0.1.1 ## 0.1.1
* Relicense Appflowy Editor by @hyj1204. * Relicense Appflowy Editor by @hyj1204.

View file

@ -21,6 +21,6 @@
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>9.0</string> <string>11.0</string>
</dict> </dict>
</plist> </plist>

View file

@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project # Uncomment this line to define a global platform for your project
# platform :ios, '9.0' # platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true' ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View file

@ -3,10 +3,11 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 50; objectVersion = 54;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
04FEAAC38F2370365B8414DC /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1F5D64F559698A15DB17B36 /* Pods_Runner.framework */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
@ -35,6 +36,8 @@
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7B9564C525FDA21960DC1568 /* 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 = "<group>"; };
8ED982CC43DE110A1567B441 /* 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 = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -42,6 +45,8 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E1F5D64F559698A15DB17B36 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EA2F6824C2F8DF616F38D702 /* 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 = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -49,12 +54,24 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
04FEAAC38F2370365B8414DC /* Pods_Runner.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
2181B39B01004E1610D231F6 /* Pods */ = {
isa = PBXGroup;
children = (
7B9564C525FDA21960DC1568 /* Pods-Runner.debug.xcconfig */,
EA2F6824C2F8DF616F38D702 /* Pods-Runner.release.xcconfig */,
8ED982CC43DE110A1567B441 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = { 9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -72,6 +89,8 @@
9740EEB11CF90186004384FC /* Flutter */, 9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */, 97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */, 97C146EF1CF9000F007C117D /* Products */,
2181B39B01004E1610D231F6 /* Pods */,
DBB82516CCE88A0A80E570A6 /* Frameworks */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@ -98,6 +117,14 @@
path = Runner; path = Runner;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
DBB82516CCE88A0A80E570A6 /* Frameworks */ = {
isa = PBXGroup;
children = (
E1F5D64F559698A15DB17B36 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -105,12 +132,14 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = ( buildPhases = (
D1756A9F757523FB742DC39D /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */, 9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */, 97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */, 97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */, 97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */, 9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
6953CBC33F9B7A821F1D3D6F /* [CP] Embed Pods Frameworks */,
); );
buildRules = ( buildRules = (
); );
@ -171,6 +200,7 @@
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
); );
@ -183,8 +213,26 @@
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
}; };
6953CBC33F9B7A821F1D3D6F /* [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;
};
9740EEB61CF901F6004384FC /* Run Script */ = { 9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
); );
@ -197,6 +245,28 @@
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
}; };
D1756A9F757523FB742DC39D /* [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 */ /* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
@ -272,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;
@ -350,7 +420,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
@ -399,7 +469,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;

View file

@ -4,4 +4,7 @@
<FileRef <FileRef
location = "group:Runner.xcodeproj"> location = "group:Runner.xcodeproj">
</FileRef> </FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace> </Workspace>

View file

@ -45,5 +45,7 @@
<false/> <false/>
<key>CADisableMinimumFrameDurationOnPhone</key> <key>CADisableMinimumFrameDurationOnPhone</key>
<true/> <true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict> </dict>
</plist> </plist>

View file

@ -48,7 +48,7 @@ class _HomePageState extends State<HomePage> {
ThemeData _themeData = ThemeData.light().copyWith( ThemeData _themeData = ThemeData.light().copyWith(
extensions: [ extensions: [
...lightEditorStyleExtension, ...lightEditorStyleExtension,
...lightPlguinStyleExtension, ...lightPluginStyleExtension,
], ],
); );
@ -159,7 +159,7 @@ Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC
_themeData = ThemeData.dark().copyWith( _themeData = ThemeData.dark().copyWith(
extensions: [ extensions: [
...darkEditorStyleExtension, ...darkEditorStyleExtension,
...darkPlguinStyleExtension, ...darkPluginStyleExtension,
], ],
); );
}); });
@ -372,7 +372,7 @@ Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC
return Theme.of(context).copyWith(extensions: [ return Theme.of(context).copyWith(extensions: [
editorStyle, editorStyle,
...darkPlguinStyleExtension, ...darkPluginStyleExtension,
quote, quote,
]); ]);
} }

View file

@ -34,7 +34,7 @@ ThemeData customizeEditorTheme(BuildContext context) {
return Theme.of(context).copyWith(extensions: [ return Theme.of(context).copyWith(extensions: [
editorStyle, editorStyle,
...darkPlguinStyleExtension, ...darkPluginStyleExtension,
quote, quote,
]); ]);
} }

View file

@ -31,6 +31,7 @@ export 'src/extensions/attributes_extension.dart';
export 'src/render/rich_text/default_selectable.dart'; export 'src/render/rich_text/default_selectable.dart';
export 'src/render/rich_text/flowy_rich_text.dart'; export 'src/render/rich_text/flowy_rich_text.dart';
export 'src/render/selection_menu/selection_menu_widget.dart'; export 'src/render/selection_menu/selection_menu_widget.dart';
export 'src/render/selection_menu/selection_menu_item_widget.dart';
export 'src/l10n/l10n.dart'; export 'src/l10n/l10n.dart';
export 'src/render/style/plugin_styles.dart'; export 'src/render/style/plugin_styles.dart';
export 'src/plugins/markdown/encoder/delta_markdown_encoder.dart'; export 'src/plugins/markdown/encoder/delta_markdown_encoder.dart';

View file

@ -25,7 +25,6 @@ extension CommandExtension on EditorState {
} else if (path != null) { } else if (path != null) {
return document.nodeAtPath(path)!; return document.nodeAtPath(path)!;
} }
throw Exception('path and node cannot be null at the same time'); throw Exception('path and node cannot be null at the same time');
} }
@ -38,33 +37,26 @@ extension CommandExtension on EditorState {
} else if (path != null) { } else if (path != null) {
return document.nodeAtPath(path)! as TextNode; return document.nodeAtPath(path)! as TextNode;
} }
throw Exception('path and node cannot be null at the same time'); throw Exception('path and node cannot be null at the same time');
} }
Selection getSelection( Selection getSelection(
Selection? selection, Selection? selection,
) { ) {
final currentSelection = service.selectionService.currentSelection.value;
if (selection != null) { if (selection != null) {
return selection; return selection;
} } else if (currentSelection != null) {
final currentSelection = service.selectionService.currentSelection.value;
if (currentSelection != null) {
return currentSelection; return currentSelection;
} }
throw Exception('path and textNode cannot be null at the same time');
throw Exception(
'selection and selectionService.currentSelection cannot be null at the same time',
);
} }
String getTextInSelection( List<String> getTextInSelection(
List<TextNode> textNodes, List<TextNode> textNodes,
Selection selection, Selection selection,
) { ) {
List<String> res = []; List<String> res = [];
if (selection.isSingle) { if (selection.isSingle) {
final plainText = textNodes.first.toPlainText(); final plainText = textNodes.first.toPlainText();
res.add(plainText.substring(selection.startIndex, selection.endIndex)); res.add(plainText.substring(selection.startIndex, selection.endIndex));
@ -85,7 +77,6 @@ extension CommandExtension on EditorState {
} }
} }
} }
return res;
return res.join('\n');
} }
} }

View file

@ -235,20 +235,20 @@ class UpdateTextOperation extends Operation {
// TODO(Lucas.Xu): refactor this part // TODO(Lucas.Xu): refactor this part
Path transformPath(Path preInsertPath, Path b, [int delta = 1]) { Path transformPath(Path preInsertPath, Path b, [int delta = 1]) {
if (preInsertPath.length > b.length || preInsertPath.isEmpty || b.isEmpty) { if (preInsertPath.length > b.length) {
return b;
}
if (preInsertPath.isEmpty || b.isEmpty) {
return b; return b;
} }
// check the prefix // check the prefix
for (var i = 0; i < preInsertPath.length - 1; i++) { for (var i = 0; i < preInsertPath.length - 1; i++) {
if (preInsertPath[i] != b[i]) { if (preInsertPath[i] != b[i]) {
return b; return b;
} }
} }
final prefix = preInsertPath.sublist(0, preInsertPath.length - 1); final prefix = preInsertPath.sublist(0, preInsertPath.length - 1);
final suffix = b.sublist(preInsertPath.length); final suffix = b.sublist(preInsertPath.length);
final preInsertLast = preInsertPath.last; final preInsertLast = preInsertPath.last;
final bAtIndex = b[preInsertPath.length - 1]; final bAtIndex = b[preInsertPath.length - 1];
if (preInsertLast <= bAtIndex) { if (preInsertLast <= bAtIndex) {
@ -256,9 +256,7 @@ Path transformPath(Path preInsertPath, Path b, [int delta = 1]) {
} else { } else {
prefix.add(bAtIndex); prefix.add(bAtIndex);
} }
prefix.addAll(suffix); prefix.addAll(suffix);
return prefix; return prefix;
} }

View file

@ -347,24 +347,22 @@ extension TextTransaction on Transaction {
textNode.toPlainText().length, textNode.toPlainText().length,
texts.first, texts.first,
); );
} else if (i == length - 1) { } else if (i == length - 1 && texts.length >= 2) {
replaceText( replaceText(
textNode, textNode,
0, 0,
selection.endIndex, selection.endIndex,
texts.last, texts.last,
); );
} else if (i < texts.length - 1) {
replaceText(
textNode,
0,
textNode.toPlainText().length,
texts[i],
);
} else { } else {
if (i < texts.length - 1) { deleteNode(textNode);
replaceText(
textNode,
0,
textNode.toPlainText().length,
texts[i],
);
} else {
deleteNode(textNode);
}
} }
} }
afterSelection = null; afterSelection = null;

View file

@ -77,7 +77,7 @@ class EditorState {
// TODO: only for testing. // TODO: only for testing.
bool disableSealTimer = false; bool disableSealTimer = false;
bool disbaleRules = false; bool disableRules = false;
bool editable = true; bool editable = true;
@ -209,7 +209,7 @@ class EditorState {
void _applyRules(int ruleCount) { void _applyRules(int ruleCount) {
// Set a maximum count to prevent a dead loop. // Set a maximum count to prevent a dead loop.
if (ruleCount >= 5 || disbaleRules) { if (ruleCount >= 5 || disableRules) {
return; return;
} }

View file

@ -69,7 +69,7 @@ class SelectionMenu implements SelectionMenuService {
editorState.renderBox?.localToGlobal(Offset.zero) ?? Offset.zero; editorState.renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
final editorHeight = editorState.renderBox!.size.height; final editorHeight = editorState.renderBox!.size.height;
// show below defualt // show below default
var showBelow = true; var showBelow = true;
_alignment = Alignment.bottomLeft; _alignment = Alignment.bottomLeft;
final bottomRight = selectionRects.first.bottomRight; final bottomRight = selectionRects.first.bottomRight;
@ -91,20 +91,24 @@ class SelectionMenu implements SelectionMenuService {
top: showBelow ? _offset.dy : null, top: showBelow ? _offset.dy : null,
bottom: showBelow ? null : _offset.dy, bottom: showBelow ? null : _offset.dy,
left: offset.dx, left: offset.dx,
child: SelectionMenuWidget( right: 0,
items: [ child: SingleChildScrollView(
..._defaultSelectionMenuItems, scrollDirection: Axis.horizontal,
...editorState.selectionMenuItems, child: SelectionMenuWidget(
], items: [
maxItemInRow: 5, ..._defaultSelectionMenuItems,
editorState: editorState, ...editorState.selectionMenuItems,
menuService: this, ],
onExit: () { maxItemInRow: 5,
dismiss(); editorState: editorState,
}, menuService: this,
onSelectionUpdate: () { onExit: () {
_selectionUpdateByInner = true; dismiss();
}, },
onSelectionUpdate: () {
_selectionUpdateByInner = true;
},
),
), ),
); );
}); });

View file

@ -1,7 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/render/selection_menu/selection_menu_item_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -324,7 +323,8 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
_deleteLastCharacters(); _deleteLastCharacters();
return KeyEventResult.handled; return KeyEventResult.handled;
} else if (event.character != null && } else if (event.character != null &&
!arrowKeys.contains(event.logicalKey)) { !arrowKeys.contains(event.logicalKey) &&
event.logicalKey != LogicalKeyboardKey.tab) {
keyword += event.character!; keyword += event.character!;
_insertText(event.character!); _insertText(event.character!);
return KeyEventResult.handled; return KeyEventResult.handled;
@ -339,7 +339,14 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
newSelectedIndex -= 1; newSelectedIndex -= 1;
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) { } else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
newSelectedIndex += 1; newSelectedIndex += 1;
} else if (event.logicalKey == LogicalKeyboardKey.tab) {
newSelectedIndex += widget.maxItemInRow;
var currRow = (newSelectedIndex) % widget.maxItemInRow;
if (newSelectedIndex >= _showingItems.length) {
newSelectedIndex = (currRow + 1) % widget.maxItemInRow;
}
} }
if (newSelectedIndex != _selectedIndex) { if (newSelectedIndex != _selectedIndex) {
setState(() { setState(() {
_selectedIndex = newSelectedIndex.clamp(0, _showingItems.length - 1); _selectedIndex = newSelectedIndex.clamp(0, _showingItems.length - 1);

View file

@ -2,14 +2,14 @@ import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/infra/flowy_svg.dart'; import 'package:appflowy_editor/src/infra/flowy_svg.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Iterable<ThemeExtension<dynamic>> get lightPlguinStyleExtension => [ Iterable<ThemeExtension<dynamic>> get lightPluginStyleExtension => [
HeadingPluginStyle.light, HeadingPluginStyle.light,
CheckboxPluginStyle.light, CheckboxPluginStyle.light,
NumberListPluginStyle.light, NumberListPluginStyle.light,
QuotedTextPluginStyle.light, QuotedTextPluginStyle.light,
]; ];
Iterable<ThemeExtension<dynamic>> get darkPlguinStyleExtension => [ Iterable<ThemeExtension<dynamic>> get darkPluginStyleExtension => [
HeadingPluginStyle.dark, HeadingPluginStyle.dark,
CheckboxPluginStyle.dark, CheckboxPluginStyle.dark,
NumberListPluginStyle.dark, NumberListPluginStyle.dark,

View file

@ -16,14 +16,14 @@ class ToolbarWidget extends StatefulWidget {
required this.layerLink, required this.layerLink,
required this.offset, required this.offset,
required this.items, required this.items,
this.aligment = Alignment.topLeft, this.alignment = Alignment.topLeft,
}) : super(key: key); }) : super(key: key);
final EditorState editorState; final EditorState editorState;
final LayerLink layerLink; final LayerLink layerLink;
final Offset offset; final Offset offset;
final List<ToolbarItem> items; final List<ToolbarItem> items;
final Alignment aligment; final Alignment alignment;
@override @override
State<ToolbarWidget> createState() => _ToolbarWidgetState(); State<ToolbarWidget> createState() => _ToolbarWidgetState();
@ -41,7 +41,7 @@ class _ToolbarWidgetState extends State<ToolbarWidget> with ToolbarMixin {
link: widget.layerLink, link: widget.layerLink,
showWhenUnlinked: true, showWhenUnlinked: true,
offset: widget.offset, offset: widget.offset,
followerAnchor: widget.aligment, followerAnchor: widget.alignment,
child: _buildToolbar(context), child: _buildToolbar(context),
), ),
); );

View file

@ -40,7 +40,7 @@ class AppFlowyEditor extends StatefulWidget {
this.themeData = themeData ?? this.themeData = themeData ??
ThemeData.light().copyWith(extensions: [ ThemeData.light().copyWith(extensions: [
...lightEditorStyleExtension, ...lightEditorStyleExtension,
...lightPlguinStyleExtension, ...lightPluginStyleExtension,
]); ]);
} }

View file

@ -8,7 +8,9 @@ ShortcutEventHandler selectAllHandler = (editorState, event) {
if (editorState.document.root.children.isEmpty) { if (editorState.document.root.children.isEmpty) {
return KeyEventResult.handled; return KeyEventResult.handled;
} }
final firstNode = editorState.document.root.children.first; final firstNode = editorState.document.root.children.firstWhere(
(element) => element is TextNode,
);
final lastNode = editorState.document.root.children.last; final lastNode = editorState.document.root.children.last;
var offset = 0; var offset = 0;
if (lastNode is TextNode) { if (lastNode is TextNode) {

View file

@ -82,6 +82,13 @@ abstract class AppFlowySelectionService {
/// The current selection areas's rect in editor. /// The current selection areas's rect in editor.
List<Rect> get selectionRects; List<Rect> get selectionRects;
void register(SelectionInterceptor interceptor);
void unRegister(SelectionInterceptor interceptor);
}
class SelectionInterceptor {
bool Function(TapDownDetails details)? canTap;
} }
class AppFlowySelection extends StatefulWidget { class AppFlowySelection extends StatefulWidget {
@ -212,6 +219,7 @@ class _AppFlowySelectionState extends State<AppFlowySelection>
selectionRects.clear(); selectionRects.clear();
clearSelection(); clearSelection();
_clearToolbar();
if (selection != null) { if (selection != null) {
if (selection.isCollapsed) { if (selection.isCollapsed) {
@ -286,6 +294,10 @@ class _AppFlowySelectionState extends State<AppFlowySelection>
} }
void _onTapDown(TapDownDetails details) { void _onTapDown(TapDownDetails details) {
final canTap =
_interceptors.every((element) => element.canTap?.call(details) ?? true);
if (!canTap) return;
// clear old state. // clear old state.
_panStartOffset = null; _panStartOffset = null;
@ -337,7 +349,8 @@ class _AppFlowySelectionState extends State<AppFlowySelection>
// try to select the word. // try to select the word.
final selection = currentSelection.value; final selection = currentSelection.value;
if (selection == null || if (selection == null ||
(selection.isCollapsed && currentSelectedNodes.first is TextNode)) { (selection.isCollapsed == true &&
currentSelectedNodes.first is TextNode)) {
_onDoubleTapDown(details); _onDoubleTapDown(details);
} }
@ -700,4 +713,15 @@ class _AppFlowySelectionState extends State<AppFlowySelection>
// } // }
// } // }
} }
final List<SelectionInterceptor> _interceptors = [];
@override
void register(SelectionInterceptor interceptor) {
_interceptors.add(interceptor);
}
@override
void unRegister(SelectionInterceptor interceptor) {
_interceptors.removeWhere((element) => element == interceptor);
}
} }

Some files were not shown because too many files have changed in this diff Show more