|
|
|
@ -128,7 +128,8 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> { |
|
|
|
onTap: _controller.meetingDetails.value.tasktype >= 3 |
|
|
|
? () { |
|
|
|
Get.back(); |
|
|
|
_copy(_controller.meetingDetails.value.summary); |
|
|
|
_copy(_markdownToPlainText( |
|
|
|
_controller.meetingDetails.value.summary)); |
|
|
|
} |
|
|
|
: null), |
|
|
|
]), |
|
|
|
@ -168,8 +169,9 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> { |
|
|
|
await getTemporaryDirectory(); |
|
|
|
final file = File( |
|
|
|
'${tempDir.path}/${_controller.meetingData.value.title}_summary.txt'); |
|
|
|
await file.writeAsString(_controller |
|
|
|
.meetingDetails.value.summary); |
|
|
|
await file.writeAsString( |
|
|
|
_markdownToPlainText(_controller |
|
|
|
.meetingDetails.value.summary)); |
|
|
|
_share(file.path, |
|
|
|
'exportSummary'.tr); // 对应中文:分享会议总结 |
|
|
|
} else { |
|
|
|
@ -320,6 +322,63 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 将Markdown格式转换为纯文本 |
|
|
|
String _markdownToPlainText(String markdown) { |
|
|
|
String text = markdown; |
|
|
|
|
|
|
|
// 移除粗体标记 **text** 或 __text__ |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'\*\*(.*?)\*\*'), (match) => match.group(1) ?? ''); |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'__(.*?)__'), (match) => match.group(1) ?? ''); |
|
|
|
|
|
|
|
// 移除斜体标记 *text* 或 _text_ |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'\*(.*?)\*'), (match) => match.group(1) ?? ''); |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'_(.*?)_'), (match) => match.group(1) ?? ''); |
|
|
|
|
|
|
|
// 移除删除线标记 ~~text~~ |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'~~(.*?)~~'), (match) => match.group(1) ?? ''); |
|
|
|
|
|
|
|
// 移除代码块标记 ```code``` |
|
|
|
text = text.replaceAll(RegExp(r'```[\s\S]*?```'), ''); |
|
|
|
|
|
|
|
// 移除行内代码标记 `code` |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'`(.*?)`'), (match) => match.group(1) ?? ''); |
|
|
|
|
|
|
|
// 移除链接标记 [text](url) |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'\[([^\]]+)\]\([^\)]+\)'), (match) => match.group(1) ?? ''); |
|
|
|
|
|
|
|
// 移除图片标记  |
|
|
|
text = text.replaceAllMapped( |
|
|
|
RegExp(r'!\[([^\]]*)\]\([^\)]+\)'), (match) => match.group(1) ?? ''); |
|
|
|
|
|
|
|
// 移除标题标记 # ## ### 等 |
|
|
|
text = text.replaceAll(RegExp(r'^#{1,6}\s+', multiLine: true), ''); |
|
|
|
|
|
|
|
// 移除引用标记 > |
|
|
|
text = text.replaceAll(RegExp(r'^>\s*', multiLine: true), ''); |
|
|
|
|
|
|
|
// 移除列表标记 - * + |
|
|
|
text = text.replaceAll(RegExp(r'^[\s]*[-\*\+]\s+', multiLine: true), ''); |
|
|
|
|
|
|
|
// 移除有序列表标记 1. 2. 等 |
|
|
|
text = text.replaceAll(RegExp(r'^[\s]*\d+\.\s+', multiLine: true), ''); |
|
|
|
|
|
|
|
// 移除水平分割线 |
|
|
|
text = |
|
|
|
text.replaceAll(RegExp(r'^[\s]*[-\*_]{3,}[\s]*$', multiLine: true), ''); |
|
|
|
|
|
|
|
// 清理多余的空行 |
|
|
|
text = text.replaceAll(RegExp(r'\n\s*\n\s*\n'), '\n\n'); |
|
|
|
|
|
|
|
return text.trim(); |
|
|
|
} |
|
|
|
|
|
|
|
String _getAllText() { |
|
|
|
String text = ''; |
|
|
|
for (var element in _controller.textList) { |
|
|
|
|