fix: cannot paste text into the title of the doc (#6821)

* fix: cannot paste text into the title of the doc

* test: add paste in title test
This commit is contained in:
Lucas 2024-11-18 14:44:02 +08:00 committed by GitHub
parent 7e528cf260
commit 8a7cedd5b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 0 deletions

View File

@ -347,5 +347,27 @@ void main() {
await tester.pumpAndSettle();
});
testWidgets('paste text in title, check if the text is updated',
(tester) async {
await tester.initializeAppFlowy();
await tester.tapAnonymousSignInButton();
await tester.createNewPageWithNameUnderParent();
await Clipboard.setData(const ClipboardData(text: _testDocumentName));
final title = tester.editor.findDocumentTitle('');
await tester.tapButton(title);
await tester.simulateKeyEvent(
LogicalKeyboardKey.keyV,
isMetaPressed: UniversalPlatform.isMacOS,
isControlPressed: !UniversalPlatform.isMacOS,
);
await tester.pumpAndSettle();
final newTitle = tester.editor.findDocumentTitle(_testDocumentName);
expect(newTitle, findsOneWidget);
});
});
}

View File

@ -30,6 +30,11 @@ final CommandShortcutEvent customPasteCommand = CommandShortcutEvent(
);
CommandShortcutEventHandler _pasteCommandHandler = (editorState) {
final selection = editorState.selection;
if (selection == null) {
return KeyEventResult.ignored;
}
doPaste(editorState).then((_) {
final context = editorState.document.root.context;
if (context != null && context.mounted) {