Add ⌘F find in transcripts and a TODO filter on the project page

This commit is contained in:
Ian Gulliver
2026-10-23 09:50:35 -07:00
parent fe86916ce6
commit fd0529b949
11 changed files with 434 additions and 34 deletions
+14 -7
View File
@@ -485,6 +485,7 @@ struct MarkdownView: View {
let blocks: [MDBlock]
var ctx = MDContext()
@Environment(Store.self) private var store
@Environment(\.findQuery) private var query
var body: some View {
VStack(alignment: .leading, spacing: 8) {
@@ -502,7 +503,9 @@ struct MarkdownView: View {
private func flow(_ blocks: [MDBlock]) -> NSAttributedString {
var builder = FlowBuilder(store: store, ctx: ctx)
return builder.build(blocks)
let out = builder.build(blocks)
highlight(out, query)
return out
}
private var runs: [MDRun] {
@@ -564,7 +567,7 @@ private struct FlowBuilder {
self.ctx = ctx
}
mutating func build(_ blocks: [MDBlock]) -> NSAttributedString {
mutating func build(_ blocks: [MDBlock]) -> NSMutableAttributedString {
self.blocks(blocks, 0)
if out.length > 0 {
out.deleteCharacters(in: NSRange(location: out.length - 1, length: 1))
@@ -918,13 +921,15 @@ struct InlineView: View {
@Environment(Store.self) private var store
@Environment(\.choiceTap) private var choiceTap
@Environment(\.centerImages) private var centerImages
@Environment(\.findQuery) private var query
var body: some View {
let segs = InlineRenderer(store: store, size: ctx.size, taskId: ctx.taskId, project: ctx.project, weight: ctx.weight, dir: ctx.dir).segments(inlines)
VStack(alignment: .leading, spacing: 4) {
ForEach(Array(segs.enumerated()), id: \.offset) { _, seg in
switch seg {
case .text(let a):
case .text(let plain):
let a = highlighted(plain, query)
if choiceTap != nil {
FlowText(text: flowString(a))
} else {
@@ -960,6 +965,7 @@ struct InlineView: View {
private struct BlockView: View {
let block: MDBlock
let ctx: MDContext
@Environment(\.findQuery) private var query
var body: some View {
switch block {
@@ -984,7 +990,7 @@ private struct BlockView: View {
case .code(let code):
Copyable(text: code) {
ScrollView(.horizontal) {
Text(verbatim: code)
Text(highlighted(code, query))
.font(Fonts.font(ctx.size, mono: true))
.foregroundStyle(Palette.text)
.textSelection(.enabled)
@@ -1000,7 +1006,7 @@ private struct BlockView: View {
case .diff(let lines):
DiffBlock(lines: lines, size: ctx.size)
case .details(let summary, let body):
DetailsBlock(summary: summary, blocks: body, ctx: ctx)
DetailsBlock(summary: summary, blocks: body, ctx: ctx, reveal: matches(mdText(body), query))
case .diagram(let source):
BoxDiagramView(source: source)
case .table(let head, let rows):
@@ -1115,6 +1121,7 @@ private struct DetailsBlock: View {
let summary: [MDInline]
let blocks: [MDBlock]
let ctx: MDContext
let reveal: Bool
@ViewState private var open = false
var body: some View {
@@ -1123,14 +1130,14 @@ private struct DetailsBlock: View {
open.toggle()
} label: {
HStack(alignment: .firstTextBaseline, spacing: 4) {
Text(open ? "▾" : "▸")
Text(open || reveal ? "▾" : "▸")
.foregroundStyle(Palette.accent)
InlineView(inlines: summary, ctx: MDContext(size: ctx.size, color: Palette.accent, taskId: ctx.taskId, project: ctx.project, dir: ctx.dir))
}
.contentShape(Rectangle())
}
.buttonStyle(.plain)
if open {
if open || reveal {
MarkdownView(blocks: blocks, ctx: ctx)
.padding(.leading, 11)
.overlay(alignment: .leading) {