「记一条」面板里正文是个 textarea,排版、表格、贴图都没有——创建时反而比 详情页更寒酸。现在新建面板直接用详情同款 Vditor 编辑器,创建与修改一个模样。 - `RichTextEditor` 的 `itemId` 改为可选:新建时还没有条目 id,正文照写, 只是上传按钮不摆出来;真去贴图会提示「先保存这条内容,再回来贴图」。 - `KnowledgeComposer` 的正文换用 `RichTextEditor`(minHeight 320),页脚提示 按有没有条目 id 给不同文案。 - 安卓:新建对话框不再放纯文本正文框,保存后直接进 `RichTextEditorScreen` 写正文(排版、表格、贴图都在那儿),写完回到列表并展开详情。 - e2e 增加一条断言:新建面板里的正文就是富文本编辑器(aria-label=正文 的 contenteditable),正文按真实键盘输入后 Markdown 正常落库。 验证:`tsc --noEmit` 通过、`vite build` 通过、`knowledge-notebook.mjs` 11 项 全绿(新增「新建面板的正文是富文本编辑器」)。安卓端本机仍是 JDK 25 + Gradle 8.7/AGP 8.7.3 不兼容,本次未编译验证。
This commit is contained in:
@@ -272,7 +272,16 @@ fun KnowledgeScreen(
|
||||
scope.launch {
|
||||
loadCategories()
|
||||
reload()
|
||||
open = created
|
||||
// 正文交给富文本编辑器写:先落一条草稿,再直接进去写,不让用户对着纯文本框凑排版
|
||||
onEdit(
|
||||
EditRequest(
|
||||
itemId = created.id,
|
||||
title = created.title,
|
||||
body = created.bodyMd,
|
||||
version = created.version,
|
||||
knowledge = true,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
onFail = { fail(it) },
|
||||
@@ -307,7 +316,6 @@ private fun KnowledgeComposerDialog(
|
||||
var docType by remember { mutableStateOf("note") }
|
||||
var categoryId by remember { mutableStateOf<String?>(null) }
|
||||
var tags by remember { mutableStateOf("") }
|
||||
var body by remember { mutableStateOf("") }
|
||||
var saving by remember { mutableStateOf(false) }
|
||||
|
||||
Dialog(
|
||||
@@ -339,7 +347,7 @@ private fun KnowledgeComposerDialog(
|
||||
api.createKnowledge(
|
||||
workspace.id,
|
||||
title.trim(),
|
||||
body,
|
||||
"",
|
||||
docType,
|
||||
parseTags(tags),
|
||||
categoryId,
|
||||
@@ -426,19 +434,11 @@ private fun KnowledgeComposerDialog(
|
||||
),
|
||||
)
|
||||
Spacer(Modifier.height(10.dp))
|
||||
SectionLabel("正文 · Markdown")
|
||||
OutlinedTextField(
|
||||
value = body,
|
||||
onValueChange = { body = it },
|
||||
modifier = Modifier.fillMaxWidth().heightIn(min = 240.dp),
|
||||
placeholder = { Text("背景、做法、结论……写清楚以后自己还能看懂", color = InkMuted) },
|
||||
shape = RoundedCornerShape(10.dp),
|
||||
colors = TextFieldDefaults.colors(
|
||||
focusedContainerColor = Color.White,
|
||||
unfocusedContainerColor = Color.White,
|
||||
focusedIndicatorColor = Primary,
|
||||
unfocusedIndicatorColor = Line,
|
||||
),
|
||||
SectionLabel("正文")
|
||||
Text(
|
||||
"点右上「保存」先把这张备忘存成草稿,随后会直接打开编辑器写正文——排版、表格、贴图都在编辑器里。",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = InkMuted,
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user