-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(markdown): support markdown editing and embed rendering
- Implement markdown editing feature with toolbar. - Add rendering for image, audio, and video embeds in markdown content. - Add markdown content preview. - Refactor and improve drawing and photo picking features. - Implement rendering of markdown syntax highlighting. - Add markdown to text plain text conversion. - Add markdown type for diary.
- Loading branch information
Showing
17 changed files
with
469 additions
and
103 deletions.
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
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
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,23 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:moodiary/utils/file_util.dart'; | ||
|
||
import '../audio_player/audio_player_view.dart'; | ||
|
||
class MarkdownAudioEmbed extends StatelessWidget { | ||
final String audioName; | ||
final bool isEdit; | ||
|
||
const MarkdownAudioEmbed( | ||
{super.key, required this.audioName, required this.isEdit}); | ||
|
||
@override | ||
Widget build( | ||
BuildContext context, | ||
) { | ||
final path = isEdit | ||
? FileUtil.getCachePath(audioName) | ||
: FileUtil.getRealPath('audio', audioName); | ||
|
||
return AudioPlayerComponent(path: path); // 使用音频播放器组件渲染 | ||
} | ||
} |
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,43 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:moodiary/router/app_routes.dart'; | ||
import 'package:moodiary/utils/file_util.dart'; | ||
import 'package:refreshed/refreshed.dart'; | ||
|
||
class MarkdownImageEmbed extends StatelessWidget { | ||
final bool isEdit; | ||
final String imageName; | ||
|
||
const MarkdownImageEmbed( | ||
{super.key, required this.isEdit, required this.imageName}); | ||
|
||
@override | ||
Widget build( | ||
BuildContext context, | ||
) { | ||
final imagePath = | ||
isEdit ? imageName : FileUtil.getRealPath('image', imageName); | ||
|
||
return Center( | ||
child: GestureDetector( | ||
onTap: () { | ||
if (!isEdit) { | ||
Get.toNamed(AppRoutes.photoPage, arguments: [ | ||
[imagePath], | ||
0, | ||
]); | ||
} | ||
}, | ||
child: ConstrainedBox( | ||
constraints: const BoxConstraints(maxHeight: 300), | ||
child: Card.outlined( | ||
clipBehavior: Clip.hardEdge, | ||
color: Colors.transparent, | ||
child: Image.file(File(imagePath)), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:moodiary/components/video_player/video_player_view.dart'; | ||
import 'package:moodiary/utils/file_util.dart'; | ||
|
||
class MarkdownVideoEmbed extends StatelessWidget { | ||
final bool isEdit; | ||
final String videoName; | ||
|
||
const MarkdownVideoEmbed( | ||
{super.key, required this.isEdit, required this.videoName}); | ||
|
||
@override | ||
Widget build( | ||
BuildContext context, | ||
) { | ||
final videoPath = | ||
isEdit ? videoName : FileUtil.getRealPath('video', videoName); | ||
final colorScheme = Theme.of(context).colorScheme; | ||
return Center( | ||
child: ConstrainedBox( | ||
constraints: const BoxConstraints(maxHeight: 300), | ||
child: Card.outlined( | ||
clipBehavior: Clip.hardEdge, | ||
color: colorScheme.surfaceContainerLowest, | ||
child: VideoPlayerComponent( | ||
videoPath: videoPath, | ||
), | ||
), | ||
), | ||
); // 使用音频播放器组件渲染 | ||
} | ||
} |
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
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
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
Oops, something went wrong.