Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

feat: click a finished meeting's summary, a conclusion or a to-do to fix it in place

wquguruc8b09526c1ad
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings
index 07d40c9..e32d256 100644
--- a/Resources/en.lproj/Localizable.strings
+++ b/Resources/en.lproj/Localizable.strings
@@ -479,6 +479,11 @@
"议题" = "Topics";
"结论" = "Conclusions";
"结论和待办" = "Conclusions and to-dos";
+"负责人" = "Owner";
+"删除这条" = "Delete";
+"点一下修改" = "Click to edit";
+"⏎ 保存 · esc 取消" = "⏎ Save · esc Cancel";
+"⌘⏎ 保存 · esc 取消" = "⌘⏎ Save · esc Cancel";
"人名和术语" = "Names and terms";
"依据较少" = "Little evidence";
"依据 %lld 句" = "Evidence: %lld";
@@ -1530,19 +1535,6 @@
"这个人是谁?" = "Who is this?";
"写上名字后,这场记录会按这个名字显示。要下次自动认出,再点“记住这个声音”。" = "This meeting will show this name. To recognize them next time, also choose “Remember this voice”.";
"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在人员库里删除。" = "Make sure they know first. The voiceprint stays only on this Mac, is used to recognize this person in later meetings, and can be deleted from People anytime.";
-"编辑纪要" = "Edit Notes";
-"纪要标题" = "Notes title";
-"改完保存在这场会议里;人名和术语也会用于以后整理。" = "Saved with this meeting; names and terms are also used for later notes.";
-"名字写对后,纪要里所有人名会按这里显示;识别错的写法放在“听成”里。" = "Names in the notes follow the spelling here; put misheard spellings under “Heard as”.";
-"例如:季度产品评审" = "e.g. Quarterly product review";
-"议题标题" = "Topic title";
-"要点" = "Point";
-"听成(逗号分隔)" = "Heard as (comma-separated)";
-"正确名字/术语" = "Correct name or term";
-"说明(公司、职位…)" = "Note (company, role…)";
-"%@内容" = "%@ text";
-"负责人(可空)" = "Owner (optional)";
-"手动改纪要、人名和术语" = "Edit the notes, names and terms by hand";
"人员库" = "People";
"%lld 个人 · 声纹和备注" = "%lld saved · voiceprints and notes";
"声纹只保存在这台 Mac;可以写备注,也可以删除。" = "Voiceprints stay only on this Mac. Add notes or delete them here.";
diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.strings
index 1820477..0adcda3 100644
--- a/Resources/ja.lproj/Localizable.strings
+++ b/Resources/ja.lproj/Localizable.strings
@@ -479,6 +479,11 @@
"议题" = "議題";
"结论" = "結論";
"结论和待办" = "結論とToDo";
+"负责人" = "担当者";
+"删除这条" = "この項目を削除";
+"点一下修改" = "クリックして編集";
+"⏎ 保存 · esc 取消" = "⏎ 保存 · esc キャンセル";
+"⌘⏎ 保存 · esc 取消" = "⌘⏎ 保存 · esc キャンセル";
"人名和术语" = "人名と用語";
"依据较少" = "根拠が少ない";
"依据 %lld 句" = "根拠 %lld文";
@@ -1530,19 +1535,6 @@
"这个人是谁?" = "この人は誰ですか?";
"写上名字后,这场记录会按这个名字显示。要下次自动认出,再点“记住这个声音”。" = "この会議ではこの名前で表示されます。次回も自動で認識するには「この声を覚える」も選んでください。";
"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在人员库里删除。" = "まず相手に知らせてください。声紋はこのMacだけに保存され、今後の会議でこの人を認識するために使います。「人物」からいつでも削除できます。";
-"编辑纪要" = "メモを編集";
-"纪要标题" = "メモのタイトル";
-"改完保存在这场会议里;人名和术语也会用于以后整理。" = "この会議に保存されます。名前と用語は今後のメモにも使われます。";
-"名字写对后,纪要里所有人名会按这里显示;识别错的写法放在“听成”里。" = "メモ内の名前はここの表記に揃います。聞き間違えた表記は「聞き取り」に入れてください。";
-"例如:季度产品评审" = "例:四半期プロダクトレビュー";
-"议题标题" = "トピック名";
-"要点" = "要点";
-"听成(逗号分隔)" = "聞き取り(カンマ区切り)";
-"正确名字/术语" = "正しい名前・用語";
-"说明(公司、职位…)" = "メモ(会社、役職…)";
-"%@内容" = "%@の内容";
-"负责人(可空)" = "担当者(任意)";
-"手动改纪要、人名和术语" = "メモ・名前・用語を手で直す";
"人员库" = "人物";
"%lld 个人 · 声纹和备注" = "%lld人 · 声紋とメモ";
"声纹只保存在这台 Mac;可以写备注,也可以删除。" = "声紋はこのMacだけに保存されます。メモの追加や削除ができます。";
diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.strings
index 7bac3a4..3e8c3c1 100644
--- a/Resources/ko.lproj/Localizable.strings
+++ b/Resources/ko.lproj/Localizable.strings
@@ -479,6 +479,11 @@
"议题" = "안건";
"结论" = "결론";
"结论和待办" = "결론 및 할 일";
+"负责人" = "담당자";
+"删除这条" = "이 항목 삭제";
+"点一下修改" = "클릭해서 수정";
+"⏎ 保存 · esc 取消" = "⏎ 저장 · esc 취소";
+"⌘⏎ 保存 · esc 取消" = "⌘⏎ 저장 · esc 취소";
"人名和术语" = "인명 및 용어";
"依据较少" = "근거 적음";
"依据 %lld 句" = "근거 %lld문장";
@@ -1530,19 +1535,6 @@
"这个人是谁?" = "이 사람은 누구인가요?";
"写上名字后,这场记录会按这个名字显示。要下次自动认出,再点“记住这个声音”。" = "이 회의에서는 이 이름으로 표시됩니다. 다음에도 자동으로 알아보려면 ‘이 목소리 기억하기’도 선택하세요.";
"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在人员库里删除。" = "먼저 상대방에게 알려 주세요. 음성 지문은 이 Mac에만 저장되며 앞으로 이 사람을 인식하는 데 사용됩니다. ‘사람’에서 언제든지 삭제할 수 있습니다.";
-"编辑纪要" = "메모 편집";
-"纪要标题" = "메모 제목";
-"改完保存在这场会议里;人名和术语也会用于以后整理。" = "이 회의에 저장됩니다. 이름과 용어는 이후 메모에도 쓰입니다.";
-"名字写对后,纪要里所有人名会按这里显示;识别错的写法放在“听成”里。" = "메모 속 이름은 여기 표기를 따릅니다. 잘못 들린 표기는 ‘들린 말’에 넣으세요.";
-"例如:季度产品评审" = "예: 분기 제품 리뷰";
-"议题标题" = "주제 제목";
-"要点" = "요점";
-"听成(逗号分隔)" = "들린 말(쉼표로 구분)";
-"正确名字/术语" = "올바른 이름·용어";
-"说明(公司、职位…)" = "설명(회사, 직책…)";
-"%@内容" = "%@ 내용";
-"负责人(可空)" = "담당자(선택)";
-"手动改纪要、人名和术语" = "메모, 이름, 용어를 직접 수정";
"人员库" = "사람";
"%lld 个人 · 声纹和备注" = "%lld명 · 음성 지문과 메모";
"声纹只保存在这台 Mac;可以写备注,也可以删除。" = "음성 지문은 이 Mac에만 저장됩니다. 메모를 쓰거나 삭제할 수 있습니다.";
diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.strings
index 5878075..236e2ad 100644
--- a/Resources/zh-Hans.lproj/Localizable.strings
+++ b/Resources/zh-Hans.lproj/Localizable.strings
@@ -464,6 +464,11 @@
"议题" = "议题";
"结论" = "结论";
"结论和待办" = "结论和待办";
+"负责人" = "负责人";
+"删除这条" = "删除这条";
+"点一下修改" = "点一下修改";
+"⏎ 保存 · esc 取消" = "⏎ 保存 · esc 取消";
+"⌘⏎ 保存 · esc 取消" = "⌘⏎ 保存 · esc 取消";
"人名和术语" = "人名和术语";
"依据较少" = "依据较少";
"依据 %lld 句" = "依据 %lld 句";
@@ -1435,19 +1440,6 @@
"这个人是谁?" = "这个人是谁?";
"写上名字后,这场记录会按这个名字显示。要下次自动认出,再点“记住这个声音”。" = "写上名字后,这场记录会按这个名字显示。要下次自动认出,再点“记住这个声音”。";
"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在人员库里删除。" = "请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在人员库里删除。";
-"编辑纪要" = "编辑纪要";
-"纪要标题" = "纪要标题";
-"改完保存在这场会议里;人名和术语也会用于以后整理。" = "改完保存在这场会议里;人名和术语也会用于以后整理。";
-"名字写对后,纪要里所有人名会按这里显示;识别错的写法放在“听成”里。" = "名字写对后,纪要里所有人名会按这里显示;识别错的写法放在“听成”里。";
-"例如:季度产品评审" = "例如:季度产品评审";
-"议题标题" = "议题标题";
-"要点" = "要点";
-"听成(逗号分隔)" = "听成(逗号分隔)";
-"正确名字/术语" = "正确名字/术语";
-"说明(公司、职位…)" = "说明(公司、职位…)";
-"%@内容" = "%@内容";
-"负责人(可空)" = "负责人(可空)";
-"手动改纪要、人名和术语" = "手动改纪要、人名和术语";
"人员库" = "人员库";
"%lld 个人 · 声纹和备注" = "%lld 个人 · 声纹和备注";
"声纹只保存在这台 Mac;可以写备注,也可以删除。" = "声纹只保存在这台 Mac;可以写备注,也可以删除。";
diff --git a/Sources/Cicada/AppModel.swift b/Sources/Cicada/AppModel.swift
index 063e970..58b9656 100644
--- a/Sources/Cicada/AppModel.swift
+++ b/Sources/Cicada/AppModel.swift
@@ -47,6 +47,8 @@ final class AppModel: ObservableObject {
}
/// The 试一句 sheet in settings.
@Published var speakTestShown = false
+ /// The piece of a finished meeting's notes open for editing on the main window's page.
+ @Published var noteEdit: NoteEdit?
/// The panel is asking, the first time, what turning 同声传译 on changes.
@Published var speakAsking = false
/// Meeting apps and the microphone each reads; refreshed every second once the virtual mic exists.
@@ -2393,17 +2395,27 @@ final class AppModel: ObservableObject {
if let img = r.nsImage, let tiff = img.tiffRepresentation, let rep = NSBitmapImageRep(data: tiff) {
try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: p[1]))
}
- case "peopleShow", "notesEditShow":
- // peopleShow (设置 › 通用 › 人员库) and notesEditShow:<会议 id> (编辑纪要) in a window of
- // their own, for `screencapture -l` (winall): sheets a synthetic click can't reach.
- let view: AnyView = parts.first == "peopleShow"
- ? AnyView(SpeakerLibraryView(model: self))
- : AnyView(NotesEditorView(model: self, sessionID: arg))
- let w = NSWindow(contentViewController: NSHostingController(rootView: view))
- w.title = parts.first ?? ""
+ case "peopleShow":
+ // 设置 › 通用 › 人员库 in a window of its own, for `screencapture -l` (winall): a sheet a
+ // synthetic click can't reach.
+ let w = NSWindow(contentViewController: NSHostingController(rootView: SpeakerLibraryView(model: self)))
+ w.title = "peopleShow"
w.isReleasedWhenClosed = false
w.center()
w.makeKeyAndOrderFront(nil)
+ case "noteEdit", "noteSave":
+ // noteEdit:<会议 id>=<summary|N> opens that piece on the page like a click (N counts the
+ // conclusions then the to-dos from 1); noteEdit: closes it.
+ // noteSave:<会议 id>=<summary|N>|<text>[|<owner>] saves like ⏎; an empty text deletes the row.
+ let p = arg.split(separator: "=", maxSplits: 1).map(String.init)
+ guard p.count == 2 else { noteEdit = nil; break }
+ let rest = p[1].components(separatedBy: "|")
+ let target: NoteEdit.Target = rest[0] == "summary" ? .summary : .item((Int(rest[0]) ?? 1) - 1)
+ if parts.first == "noteEdit" {
+ noteEdit = NoteEdit(session: p[0], target: target)
+ } else {
+ saveNote(p[0], target, text: rest.count > 1 ? rest[1] : "", owner: rest.count > 2 ? .some(rest[2]) : nil)
+ }
case "windowsRender":
// Every visible window as drawn (<dir>/<n>-<class>.png), without Screen Recording permission.
for (i, w) in NSApp.windows.enumerated() where w.isVisible {
diff --git a/Sources/Cicada/NotesEditing.swift b/Sources/Cicada/NotesEditing.swift
new file mode 100644
index 0000000..b9a2cc4
--- /dev/null
+++ b/Sources/Cicada/NotesEditing.swift
@@ -0,0 +1,70 @@
+import Foundation
+
+/// A finished meeting's notes changed in place on the main window's page: the summary, or one
+/// conclusion or to-do. Only what people take away is editable here; the title has its own field,
+/// names and terms go through 改这句… and 词表, and topics are the AI's to rewrite (重新整理).
+struct NoteEdit: Equatable {
+ enum Target: Equatable {
+ case summary
+ /// A row as the page lists them: conclusions first, then to-dos.
+ case item(Int)
+ }
+ let session: String
+ let target: Target
+}
+
+/// What the page needs to edit in place: which piece is open, and how to open, save or close one.
+struct NotesEditHooks {
+ let current: NoteEdit.Target?
+ let open: (NoteEdit.Target?) -> Void
+ /// `owner`: nil keeps the stored owner; .some("") clears it.
+ let save: (NoteEdit.Target, String, String??) -> Void
+}
+
+extension MeetingNotes {
+ /// The notes with one piece replaced. An empty conclusion or to-do is deleted; an empty summary
+ /// stays empty. Everything else (topics, terms, coverage, evidence counts) is kept as it was.
+ func editing(_ target: NoteEdit.Target, text: String, owner: String?? = nil) -> MeetingNotes {
+ var n = self
+ let text = text.trimmingCharacters(in: .whitespacesAndNewlines)
+ func apply(_ item: inout NoteItem) {
+ item.text = text
+ if let owner { item.owner = owner.flatMap { $0.trimmingCharacters(in: .whitespaces).isEmpty ? nil : $0 } }
+ }
+ switch target {
+ case .summary:
+ n.summary = text
+ case .item(let i):
+ let c = n.conclusions.count
+ if i >= 0, i < c {
+ if text.isEmpty { n.conclusions.remove(at: i) } else { apply(&n.conclusions[i]) }
+ } else if i >= c, i - c < n.todos.count {
+ if text.isEmpty { n.todos.remove(at: i - c) } else { apply(&n.todos[i - c]) }
+ }
+ }
+ return n
+ }
+}
+
+extension AppModel {
+ /// Not while the meeting is being written (the next pass would redo the notes), nor while an
+ /// import is still transcribing.
+ func canEditNotes(_ s: Session) -> Bool {
+ s.id != store.liveID && importer.status(of: s) == nil && !(s.notes?.isEmpty ?? true)
+ }
+
+ func editHooks(_ s: Session) -> NotesEditHooks? {
+ guard canEditNotes(s) else { return nil }
+ return NotesEditHooks(
+ current: noteEdit?.session == s.id ? noteEdit?.target : nil,
+ open: { [weak self] t in self?.noteEdit = t.map { NoteEdit(session: s.id, target: $0) } },
+ save: { [weak self] t, text, owner in self?.saveNote(s.id, t, text: text, owner: owner) })
+ }
+
+ func saveNote(_ id: String, _ target: NoteEdit.Target, text: String, owner: String?? = nil) {
+ guard let notes = store.session(id)?.notes else { return }
+ saveEditedNotes(notes.editing(target, text: text, owner: owner), session: id)
+ noteEdit = nil
+ debugLog("notes edit: saved \(target) in \(id)")
+ }
+}
diff --git a/Sources/Cicada/NotesEditorView.swift b/Sources/Cicada/NotesEditorView.swift
deleted file mode 100644
index 2e6a2c0..0000000
--- a/Sources/Cicada/NotesEditorView.swift
+++ /dev/null
@@ -1,170 +0,0 @@
-import SwiftUI
-
-/// Edit the notes by hand. Names and terms are what speech recognition gets wrong most, so they
-/// are fields of their own; the AI's text stays a draft until the user saves it.
-struct NotesEditorView: View {
- @ObservedObject var model: AppModel
- let sessionID: String
- @State private var draft: MeetingNotes
- @Environment(\.dismiss) private var dismiss
-
- init(model: AppModel, sessionID: String) {
- self.model = model
- self.sessionID = sessionID
- _draft = State(initialValue: model.store.session(sessionID)?.notes ?? MeetingNotes())
- }
-
- var body: some View {
- VStack(alignment: .leading, spacing: 0) {
- HStack {
- VStack(alignment: .leading, spacing: 3) {
- Text("编辑纪要").font(.system(size: 18, weight: .bold))
- Text("改完保存在这场会议里;人名和术语也会用于以后整理。")
- .font(.system(size: 11)).foregroundStyle(Palette.tertiary)
- }
- Spacer()
- Button("取消") { dismiss() }.buttonStyle(.plain)
- .font(.system(size: 13)).foregroundStyle(Palette.secondary)
- SoftButton(L("保存"), dark: true) { save() }
- }
- .padding(.horizontal, 20).padding(.top, 18).padding(.bottom, 14)
-
- Divider()
-
- ScrollView {
- VStack(alignment: .leading, spacing: 18) {
- field(L("纪要标题")) {
- TextField("例如:季度产品评审", text: optional(\.title))
- .textFieldStyle(.roundedBorder)
- }
-
- field(L("总结")) {
- editor($draft.summary, height: 110)
- }
-
- if !draft.topics.isEmpty {
- section(L("议题"))
- ForEach(draft.topics.indices, id: \.self) { i in
- VStack(alignment: .leading, spacing: 6) {
- TextField("议题标题", text: $draft.topics[i].title)
- .textFieldStyle(.roundedBorder)
- editor($draft.topics[i].summary, height: 64)
- ForEach(draft.topics[i].points.indices, id: \.self) { j in
- HStack(spacing: 6) {
- Text("·").foregroundStyle(Palette.tertiary)
- TextField("要点", text: $draft.topics[i].points[j])
- .textFieldStyle(.roundedBorder)
- }
- }
- }
- .padding(10)
- .background(RoundedRectangle(cornerRadius: 10).fill(Palette.raised))
- }
- }
-
- if !draft.conclusions.isEmpty {
- section(L("结论"))
- ForEach(draft.conclusions.indices, id: \.self) { i in
- item($draft.conclusions[i], prefix: L("结论"))
- }
- }
- if !draft.todos.isEmpty {
- section(L("待办"))
- ForEach(draft.todos.indices, id: \.self) { i in
- item($draft.todos[i], prefix: L("待办"))
- }
- }
-
- if !draft.terms.isEmpty {
- section(L("人名和术语"))
- Text("名字写对后,纪要里所有人名会按这里显示;识别错的写法放在“听成”里。")
- .font(.system(size: 11)).foregroundStyle(Palette.tertiary)
- ForEach(draft.terms.indices, id: \.self) { i in
- VStack(alignment: .leading, spacing: 6) {
- HStack(spacing: 8) {
- TextField("正确名字/术语", text: $draft.terms[i].name)
- .textFieldStyle(.roundedBorder)
- TextField("说明(公司、职位…)", text: $draft.terms[i].note)
- .textFieldStyle(.roundedBorder)
- }
- TextField("听成(逗号分隔)", text: Binding(
- get: { draft.terms[i].heard.joined(separator: ",") },
- set: { draft.terms[i].heard = $0.split(whereSeparator: { $0 == "," || $0 == "," })
- .map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty } }
- ))
- .textFieldStyle(.roundedBorder)
- .font(.system(size: 11))
- }
- .padding(10)
- .background(RoundedRectangle(cornerRadius: 10).fill(Palette.raised))
- }
- }
- }
- .padding(20)
- }
- }
- .frame(width: 720, height: 680)
- .background(Color.white)
- }
-
- private func save() {
- draft.updatedAt = Date()
- model.saveEditedNotes(draft, session: sessionID)
- dismiss()
- }
-
- private func optional(_ key: WritableKeyPath<MeetingNotes, String?>) -> Binding<String> {
- Binding(get: { draft[keyPath: key] ?? "" },
- set: { draft[keyPath: key] = $0.isEmpty ? nil : $0 })
- }
-
- private func field<Content: View>(_ title: String, @ViewBuilder content: () -> Content) -> some View {
- VStack(alignment: .leading, spacing: 6) {
- Text(title).font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.secondary)
- content()
- }
- }
-
- private func section(_ title: String) -> some View {
- Text(title).font(.system(size: 13, weight: .bold)).foregroundStyle(Palette.ink)
- .padding(.top, 4)
- }
-
- private func editor(_ text: Binding<String>, height: CGFloat) -> some View {
- TextEditor(text: text)
- .font(.system(size: 13))
- .scrollContentBackground(.hidden)
- .padding(7)
- .frame(minHeight: height)
- .background(RoundedRectangle(cornerRadius: 8).fill(Palette.raised))
- .overlay(RoundedRectangle(cornerRadius: 8).stroke(Palette.line, lineWidth: 1))
- }
-
- private func item(_ item: Binding<NoteItem>, prefix: String) -> some View {
- VStack(alignment: .leading, spacing: 6) {
- TextField("\(prefix)内容", text: item.text).textFieldStyle(.roundedBorder)
- TextField("负责人(可空)", text: Binding(
- get: { item.wrappedValue.owner ?? "" },
- set: { item.wrappedValue.owner = $0.isEmpty ? nil : $0 }
- )).textFieldStyle(.roundedBorder).font(.system(size: 11))
- }
- .padding(10)
- .background(RoundedRectangle(cornerRadius: 10).fill(Palette.raised))
- }
-}
-
-/// The small 编辑 control that opens `NotesEditorView`; no state outside the button.
-struct NotesEditButton: View {
- @ObservedObject var model: AppModel
- let session: Session
- @State private var shown = false
-
- var body: some View {
- Button("编辑") { shown = true }
- .buttonStyle(.plain)
- .font(.system(size: 13))
- .foregroundStyle(Palette.secondary)
- .help("手动改纪要、人名和术语")
- .sheet(isPresented: $shown) { NotesEditorView(model: model, sessionID: session.id) }
- }
-}
diff --git a/Sources/Cicada/NotesViews.swift b/Sources/Cicada/NotesViews.swift
index 285ac55..2ffad00 100644
--- a/Sources/Cicada/NotesViews.swift
+++ b/Sources/Cicada/NotesViews.swift
@@ -26,10 +26,13 @@ struct NotesContentView: View {
var onJump: (Double) -> Void = { _ in }
/// 改正听错的词's part of 人名和术语 (the words fixed, the ones waiting), from the notes window.
var fixTerms: AnyView? = nil
+ /// A finished meeting on the main window's page: the summary, conclusions and to-dos change in place.
+ var editing: NotesEditHooks? = nil
var body: some View {
if document {
- DocumentNotesView(notes: notes, fresh: fresh, live: live, updating: updating, endedAt: endedAt, onJump: onJump)
+ DocumentNotesView(notes: notes, fresh: fresh, live: live, updating: updating, endedAt: endedAt, onJump: onJump,
+ editing: editing)
} else {
cards
}
@@ -148,6 +151,13 @@ private struct DocumentNotesView: View {
let updating: Bool
let endedAt: Double?
let onJump: (Double) -> Void
+ let editing: NotesEditHooks?
+ @State private var hovered: NoteEdit.Target?
+ @State private var draft = ""
+ @State private var draftOwner = ""
+ /// The owner as the row showed it when opened: unchanged means keep the stored one ("说话人2").
+ @State private var shownOwner = ""
+ @FocusState private var focused: Bool
var body: some View {
VStack(alignment: .leading, spacing: 40) {
@@ -158,7 +168,12 @@ private struct DocumentNotesView: View {
.font(.system(size: 12, weight: .medium)).foregroundStyle(Palette.secondary)
.padding(.bottom, 2)
ForEach(Array(items.enumerated()), id: \.offset) { i, item in
- conclusion(item, index: i + 1, todo: i >= notes.conclusions.count)
+ let todo = i >= notes.conclusions.count
+ if editing?.current == .item(i) {
+ itemEditor(index: i + 1, todo: todo)
+ } else {
+ editable(.item(i), inset: 8) { conclusion(item, index: i + 1, todo: todo) }
+ }
}
}
.padding(.horizontal, 24).padding(.vertical, 22)
@@ -166,9 +181,14 @@ private struct DocumentNotesView: View {
.background(RoundedRectangle(cornerRadius: 14).fill(Palette.raised))
}
- if !notes.summary.isEmpty {
- Text(notes.summary).font(.system(size: 15)).lineSpacing(9).foregroundStyle(Palette.body)
- .textSelection(.enabled).fixedSize(horizontal: false, vertical: true)
+ if editing?.current == .summary {
+ summaryEditor
+ } else if !notes.summary.isEmpty {
+ if editing == nil {
+ summaryText.textSelection(.enabled)
+ } else {
+ editable(.summary, inset: 10, hoverFill: Palette.raised) { summaryText }
+ }
}
if !notes.topics.isEmpty {
@@ -195,6 +215,132 @@ private struct DocumentNotesView: View {
}
}
+ private var summaryText: some View {
+ Text(notes.summary).font(.system(size: 15)).lineSpacing(9).foregroundStyle(Palette.body)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+
+ // MARK: Editing in place
+
+ /// A row that opens for editing when clicked: on hover it lifts onto white (or grey on the white
+ /// page) and shows a pencil. Buttons inside it (the time link) keep their own clicks.
+ @ViewBuilder
+ private func editable<Content: View>(_ target: NoteEdit.Target, inset: CGFloat, hoverFill: Color = .white,
+ @ViewBuilder content: () -> Content) -> some View {
+ if let editing {
+ HStack(alignment: .firstTextBaseline, spacing: 8) {
+ content()
+ Image(systemName: "pencil").font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ .opacity(hovered == target ? 1 : 0).accessibilityHidden(true)
+ }
+ .padding(.horizontal, inset).padding(.vertical, 4)
+ .background(RoundedRectangle(cornerRadius: 9).fill(hovered == target ? hoverFill : .clear))
+ .padding(.horizontal, -inset)
+ .contentShape(Rectangle())
+ .onHover { hovered = $0 ? target : (hovered == target ? nil : hovered) }
+ .onTapGesture { editing.open(target) }
+ .help(L("点一下修改"))
+ .accessibilityAddTraits(.isButton)
+ .accessibilityAction { editing.open(target) }
+ } else {
+ content()
+ }
+ }
+
+ /// The app's own field: white, radius 9, a hairline, the accent when focused; never the system's
+ /// blue ring.
+ private func fieldFrame<V: View>(_ field: V, radius: CGFloat = 9) -> some View {
+ field
+ .textFieldStyle(.plain)
+ .focusEffectDisabled()
+ .background(RoundedRectangle(cornerRadius: radius).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: radius).stroke(focused ? Palette.accent : Palette.line,
+ lineWidth: focused ? 1.5 : 1))
+ }
+
+ private func itemEditor(index: Int, todo: Bool) -> some View {
+ VStack(alignment: .leading, spacing: 6) {
+ HStack(alignment: .center, spacing: 8) {
+ Group {
+ if todo { Image(systemName: "circle").font(.system(size: 11)) } else { Text("\(index)").font(.system(size: 12).monospacedDigit()) }
+ }
+ .fontWeight(.semibold).foregroundStyle(Palette.link).frame(width: 16, alignment: .leading)
+ fieldFrame(TextField(todo ? L("待办") : L("结论"), text: $draft, axis: .vertical)
+ .font(.system(size: 15)).lineLimit(1...4)
+ .focused($focused)
+ .padding(.horizontal, 10).padding(.vertical, 8)
+ .onSubmit(commit))
+ if todo {
+ TextField(L("负责人"), text: $draftOwner)
+ .textFieldStyle(.plain).focusEffectDisabled()
+ .font(.system(size: 12))
+ .padding(.horizontal, 8).frame(width: 110, height: 28)
+ .background(RoundedRectangle(cornerRadius: 7).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 7).stroke(Palette.line, lineWidth: 1))
+ .onSubmit(commit)
+ }
+ }
+ HStack(spacing: 14) {
+ Text("⏎ 保存 · esc 取消").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ Spacer()
+ Button(L("删除这条")) { draft = ""; commit() }
+ .buttonStyle(.plain).font(.system(size: 12)).foregroundStyle(Palette.accentInk)
+ }
+ .padding(.leading, 24)
+ }
+ .padding(.vertical, 2)
+ .onAppear { load() }
+ .onExitCommand { editing?.open(nil) }
+ }
+
+ private var summaryEditor: some View {
+ VStack(alignment: .leading, spacing: 8) {
+ fieldFrame(TextEditor(text: $draft)
+ .font(.system(size: 15)).lineSpacing(9)
+ .scrollContentBackground(.hidden)
+ .focused($focused)
+ .frame(minHeight: 72)
+ .padding(.horizontal, 6).padding(.vertical, 8))
+ HStack(spacing: 14) {
+ Text("⌘⏎ 保存 · esc 取消").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ Spacer()
+ Button(L("取消")) { editing?.open(nil) }
+ .buttonStyle(.plain).font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ Button(L("保存")) { commit() }
+ .buttonStyle(.plain).font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.accentInk)
+ .keyboardShortcut(.return, modifiers: .command)
+ }
+ }
+ .padding(.horizontal, -10)
+ .onAppear { load() }
+ .onExitCommand { editing?.open(nil) }
+ }
+
+ /// Fill the field from the piece being opened and put the caret in it.
+ private func load() {
+ guard let target = editing?.current else { return }
+ switch target {
+ case .summary:
+ draft = notes.summary
+ shownOwner = ""
+ case .item(let i):
+ let items = notes.conclusions + notes.todos
+ guard items.indices.contains(i) else { return }
+ draft = items[i].text
+ shownOwner = items[i].ownerShown ?? ""
+ }
+ draftOwner = shownOwner
+ hovered = nil
+ DispatchQueue.main.async { focused = true }
+ }
+
+ private func commit() {
+ guard let editing, let target = editing.current else { return }
+ let owner: String?? = draftOwner == shownOwner ? nil : .some(draftOwner)
+ editing.save(target, draft, owner)
+ }
+
/// A conclusion reads as a plain sentence, numbered, with its numbers and dates marked; clicking it
/// jumps to the lines behind it. One with little support stays grey.
private func conclusion(_ item: NoteItem, index: Int, todo: Bool) -> some View {
diff --git a/Sources/Cicada/Views.swift b/Sources/Cicada/Views.swift
index 57f584d..dd1d1de 100644
--- a/Sources/Cicada/Views.swift
+++ b/Sources/Cicada/Views.swift
@@ -1201,11 +1201,6 @@ struct MainWindowView: View {
.buttonStyle(.plain)
.help(showQuotes ? L("收起原话") : L("在纪要旁显示原话"))
}
- // Edit the notes, names and terms by hand: here only, not in the notes panel (it never
- // takes focus), and not while the meeting is being written (the next pass would redo it).
- if active == "notes", s.id != store.liveID, importer.status(of: s) == nil, let notes = s.notes, !notes.isEmpty {
- NotesEditButton(model: model, session: s)
- }
// Not while the meeting is still going, nor before an import has its text.
Button { sharing = s } label: {
Text("分享…").font(.system(size: 13)).foregroundStyle(Palette.secondary)
@@ -1634,7 +1629,7 @@ struct SessionNotesView: View {
header.id(PinnedHeader.top).pinnedHeader($pinned)
if let notes, !notes.isEmpty {
NotesContentView(notes: SpeakerLabels.named(notes, SpeakerLabels.names(session)), fresh: live ? engine.fresh : [], live: live, document: true,
- endedAt: session.lines.last?.t, onJump: onJump)
+ endedAt: session.lines.last?.t, onJump: onJump, editing: model.editHooks(session))
} else if generating || (live && ling.hasKey && !session.lines.isEmpty && engine.state == .updating) {
NotesGeneratingView(heard: session.lines.count)
} else if live && ling.hasKey {
diff --git a/Tests/CicadaTests/NotesEditingTests.swift b/Tests/CicadaTests/NotesEditingTests.swift
new file mode 100644
index 0000000..88b0cee
--- /dev/null
+++ b/Tests/CicadaTests/NotesEditingTests.swift
@@ -0,0 +1,46 @@
+import Foundation
+import Testing
+@testable import Cicada
+
+@Suite struct NotesEditingTests {
+ private var notes: MeetingNotes {
+ var n = MeetingNotes()
+ n.summary = "原来的总结"
+ n.topics = [NoteTopic(start: 8, title: "发布", summary: "议题", points: ["要点"])]
+ n.conclusions = [NoteItem(text: "锁定 3月3日", owner: nil, support: 2, t: 11),
+ NoteItem(text: "第二条", owner: nil, support: 1, t: 20)]
+ n.todos = [NoteItem(text: "周五前签署", owner: "说话人2", support: 1, t: 11)]
+ n.covered = 4
+ n.final = true
+ return n
+ }
+
+ @Test func replacesASummaryAndKeepsTheRest() {
+ let n = notes.editing(.summary, text: " 新总结\n")
+ #expect(n.summary == "新总结")
+ #expect(n.topics == notes.topics && n.conclusions == notes.conclusions && n.todos == notes.todos)
+ #expect(n.covered == 4 && n.final)
+ }
+
+ @Test func rowsCountConclusionsThenTodos() {
+ let n = notes.editing(.item(1), text: "改过的第二条")
+ #expect(n.conclusions[1].text == "改过的第二条")
+ #expect(n.conclusions[1].support == 1 && n.conclusions[1].t == 20, "evidence and time stay")
+ let m = notes.editing(.item(2), text: "下周一前签署")
+ #expect(m.todos[0].text == "下周一前签署")
+ #expect(m.todos[0].owner == "说话人2", "an unchanged owner keeps the stored one")
+ }
+
+ @Test func ownerChangesOrClears() {
+ #expect(notes.editing(.item(2), text: "周五前签署", owner: .some("Emma")).todos[0].owner == "Emma")
+ #expect(notes.editing(.item(2), text: "周五前签署", owner: .some(" ")).todos[0].owner == nil)
+ }
+
+ @Test func anEmptyRowIsDeleted() {
+ let n = notes.editing(.item(0), text: "")
+ #expect(n.conclusions.map(\.text) == ["第二条"])
+ let m = notes.editing(.item(2), text: " ")
+ #expect(m.todos.isEmpty)
+ #expect(notes.editing(.item(9), text: "") == notes, "a row that isn't there changes nothing")
+ }
+}