Skip to content

Commit

Permalink
feat(editor): Add experimental info hint for bbcode editor
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Feb 28, 2024
1 parent c6860fb commit 65457af
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- 编辑:提供实验性的bbcode编辑器,支持所见即所得。
- WIP: 显示文本样式包括粗体、斜体、下划线、删除线、颜色、背景色。
- WIP: 支持使用markdown语法书写bbcode(默认关闭)。
- WIP: 支持引用、表情、图片、网页链接、多级标题、有序/无序列表、代码块、折叠/展开、表格、分隔符。

### Fixed

- 帖子: 依旧是修复了很多多余或缺少的空行。
Expand Down
29 changes: 28 additions & 1 deletion lib/features/post/view/post_edit_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:tsdm_client/generated/i18n/strings.g.dart';
import 'package:tsdm_client/shared/models/models.dart';
import 'package:tsdm_client/utils/retry_button.dart';
import 'package:tsdm_client/utils/show_bottom_sheet.dart';
import 'package:tsdm_client/utils/show_dialog.dart';

/// Default thread title text length (bytes size in utf-8 encoding).
///
Expand Down Expand Up @@ -292,7 +293,11 @@ class _PostEditPageState extends State<PostEditPage> {
return Row(
children: [
IconButton(
icon: const Icon(Icons.science_outlined),
icon: Icon(
Icons.science_outlined,
color:
useExperimentalEditor ? Theme.of(context).primaryColor : null,
),
onPressed: () {
setState(() {
useExperimentalEditor = !useExperimentalEditor;
Expand Down Expand Up @@ -355,6 +360,26 @@ class _PostEditPageState extends State<PostEditPage> {
);
}

Widget _buildUsingExperimentalEditorHintRow(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextButton.icon(
icon: const Icon(Icons.info_outline),
label: Text(context.t.bbcodeEditor.experimentalInfo),
onPressed: () async {
await showMessageSingleButtonDialog(
context: context,
title: context.t.bbcodeEditor.experimentalInfoTitle,
message: context.t.bbcodeEditor.experimentalInfoDetail,
);
},
),
const Spacer(),
],
);
}

Widget _buildBody(BuildContext context) {
return MultiBlocProvider(
providers: [
Expand Down Expand Up @@ -468,6 +493,8 @@ class _PostEditPageState extends State<PostEditPage> {
},
),
),
if (useExperimentalEditor)
_buildUsingExperimentalEditorHintRow(context),
_buildControlRow(context, state),
].insertBetween(sizedBoxW15H15),
);
Expand Down
5 changes: 5 additions & 0 deletions lib/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,10 @@
},
"bountyAnswerCard": {
"title": "Best Answer"
},
"bbcodeEditor": {
"experimentalInfo": "Experimental BBCode Editor",
"experimentalInfoTitle": "Experimental BBCode Editor",
"experimentalInfoDetail": "This bbcode editor supports WYSIWYG and provides convenient ways to add text styles and other rich text components.\nIt is still in experimental state which means: Already tested but may not behave as expected."
}
}
5 changes: 5 additions & 0 deletions lib/i18n/strings_zh-CN.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,10 @@
},
"bountyAnswerCard": {
"title": "最佳答案"
},
"bbcodeEditor": {
"experimentalInfo": "实验性bbcode编辑器",
"experimentalInfoTitle": "实验性bbcode编辑器",
"experimentalInfoDetail": "此bbcode编辑器支持所见即所得,可以方便地添加文本样式和其他bbcode组件。\n但处于实验阶段:已经经过测试,但可能有bug。"
}
}
5 changes: 5 additions & 0 deletions lib/i18n/strings_zh-TW.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,10 @@
},
"bountyAnswerCard": {
"title": "最佳答案"
},
"bbcodeEditor": {
"experimentalInfo": "實驗性bbcode編輯器",
"experimentalInfoTitle": "實驗性bbcode編輯器",
"experimentalInfoDetail": "此bbcode編輯器支援所見即所得,可以方便地添加文字樣式和其他bbcode元件。\n但處於實驗階段:已經經過測試,但可能有bug。"
}
}

0 comments on commit 65457af

Please sign in to comment.