-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Chat-ng]: Appflowy Editor editor integration #2332
Open
gtalha07
wants to merge
21
commits into
acterglobal:main
Choose a base branch
from
gtalha07:chat-ng-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
69f7e3d
set up code for appflowy editor mentions plugin
gtalha07 191a8f8
implement mentions fetching logic based on query
gtalha07 7868d77
start from the basic UI setup
gtalha07 01f7315
add send message functionality back
gtalha07 a16dd7f
fix editor focus when sending message
gtalha07 6fe1e5a
implement emoji picker logic
gtalha07 7bc47fa
fix ordering state
gtalha07 f0ab803
restore attachment button functionality
gtalha07 9fcf9d8
fix merge conflicts
gtalha07 71fcd4f
fix lint errors
gtalha07 16c9256
Merge branch 'main' into chat-ng-input
gtalha07 5679cab
add changelogs
gtalha07 0ef9aa3
make editor size more responsive on desktop
gtalha07 0be9f23
fix and update compose draft state with editorState
gtalha07 3c5a6af
Feedback review: clean up and organise chat editor
gtalha07 def4f25
Feedback review: clean up and organise mention block
gtalha07 29f4ab3
fix and organise mentions structure
gtalha07 224e62b
fix mention selection logic
gtalha07 01d17e4
add L10n strings
gtalha07 4e172c0
make inline mentions prettier
gtalha07 cd28e67
keep keyboard events only listenable for desktop version
gtalha07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Chat-NG now supports Appflowy editor with proper markdown support. Some/Other features might be disabled or limited for now. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
app/lib/common/widgets/html_editor/components/mention_block.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import 'package:acter/common/widgets/html_editor/components/mention_content.dart'; | ||
import 'package:acter/common/widgets/html_editor/models/mention_block_keys.dart'; | ||
import 'package:acter/common/widgets/html_editor/models/mention_type.dart'; | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class MentionBlock extends StatelessWidget { | ||
const MentionBlock({ | ||
super.key, | ||
required this.editorState, | ||
required this.mention, | ||
required this.node, | ||
required this.index, | ||
required this.textStyle, | ||
}); | ||
|
||
final EditorState editorState; | ||
final Map<String, dynamic> mention; | ||
final Node node; | ||
final int index; | ||
final TextStyle? textStyle; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final type = MentionType.fromStr(mention[MentionBlockKeys.type]); | ||
|
||
switch (type) { | ||
case MentionType.user: | ||
final String? userId = mention[MentionBlockKeys.userId] as String?; | ||
final String? blockId = mention[MentionBlockKeys.blockId] as String?; | ||
final String? displayName = | ||
mention[MentionBlockKeys.displayName] as String?; | ||
|
||
if (userId == null) { | ||
return const SizedBox.shrink(); | ||
} | ||
|
||
return _mentionContent( | ||
context: context, | ||
mentionId: userId, | ||
blockId: blockId, | ||
editorState: editorState, | ||
displayName: displayName, | ||
node: node, | ||
index: index, | ||
); | ||
case MentionType.room: | ||
final String? roomId = mention[MentionBlockKeys.roomId] as String?; | ||
final String? blockId = mention[MentionBlockKeys.blockId] as String?; | ||
final String? displayName = | ||
mention[MentionBlockKeys.displayName] as String?; | ||
|
||
if (roomId == null) { | ||
return const SizedBox.shrink(); | ||
} | ||
|
||
return _mentionContent( | ||
context: context, | ||
mentionId: roomId, | ||
blockId: blockId, | ||
editorState: editorState, | ||
displayName: displayName, | ||
node: node, | ||
index: index, | ||
); | ||
default: | ||
return const SizedBox.shrink(); | ||
} | ||
} | ||
|
||
Widget _mentionContent({ | ||
required BuildContext context, | ||
required EditorState editorState, | ||
required String mentionId, | ||
String? blockId, | ||
required String? displayName, | ||
gtalha07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
TextStyle? textStyle, | ||
gtalha07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required Node node, | ||
required int index, | ||
}) { | ||
final desktopPlatforms = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mouse can also be plugged/connected to phones. don't do a check like that. |
||
TargetPlatform.linux, | ||
TargetPlatform.macOS, | ||
TargetPlatform.windows, | ||
]; | ||
final mentionContentWidget = MentionContentWidget( | ||
mentionId: mentionId, | ||
displayName: displayName, | ||
textStyle: textStyle, | ||
editorState: editorState, | ||
node: node, | ||
index: index, | ||
); | ||
|
||
final Widget content = GestureDetector( | ||
onTap: _handleUserTap, | ||
behavior: HitTestBehavior.opaque, | ||
child: desktopPlatforms.contains(Theme.of(context).platform) | ||
? MouseRegion( | ||
cursor: SystemMouseCursors.click, | ||
child: mentionContentWidget, | ||
) | ||
: mentionContentWidget, | ||
); | ||
|
||
return content; | ||
} | ||
|
||
void _handleUserTap() { | ||
// Implement user tap action (e.g., show profile, start chat) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
app/lib/common/widgets/html_editor/components/mention_content.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class MentionContentWidget extends StatelessWidget { | ||
gtalha07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const MentionContentWidget({ | ||
super.key, | ||
required this.mentionId, | ||
this.displayName, | ||
required this.textStyle, | ||
required this.editorState, | ||
required this.node, | ||
required this.index, | ||
}); | ||
|
||
final String mentionId; | ||
final String? displayName; | ||
final TextStyle? textStyle; | ||
final EditorState editorState; | ||
final Node node; | ||
final int index; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final baseTextStyle = textStyle?.copyWith( | ||
color: Theme.of(context).colorScheme.primary, | ||
leadingDistribution: TextLeadingDistribution.even, | ||
); | ||
gtalha07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
if (displayName != null) | ||
Text( | ||
displayName!, | ||
style: baseTextStyle?.copyWith( | ||
fontWeight: FontWeight.w500, | ||
), | ||
gtalha07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
const SizedBox(width: 4), | ||
Text( | ||
mentionId, | ||
style: baseTextStyle?.copyWith( | ||
fontSize: (baseTextStyle.fontSize ?? 14.0) * 0.9, | ||
color: Theme.of(context).hintColor, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.