From 657aa83a5ca24dc35572c040df64a0abb85e8612 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Mon, 15 Jun 2026 14:35:36 +0200 Subject: Initial extraction from Norganize --- Sources/NorgUI/Views/Blocks/BlockView.swift | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Sources/NorgUI/Views/Blocks/BlockView.swift (limited to 'Sources/NorgUI/Views/Blocks/BlockView.swift') diff --git a/Sources/NorgUI/Views/Blocks/BlockView.swift b/Sources/NorgUI/Views/Blocks/BlockView.swift new file mode 100644 index 0000000..59fcb78 --- /dev/null +++ b/Sources/NorgUI/Views/Blocks/BlockView.swift @@ -0,0 +1,49 @@ +import NorgKit +import SwiftUI + +// General block renderer. +struct BlockView: View { + let block: NorgBlock + let ordinal: Int? + let onSetStatus: (Int, TaskStatus) -> Void + + var body: some View { + switch block { + case .heading(let level, let status, let content, let line): + HeadingView( + level: level, status: status, content: content, line: line, onSetStatus: onSetStatus) + + case .paragraph(let content, _): + ParagraphView(content: content) + + case .unorderedListItem(_, let status, let content, let line): + ListItemView( + marker: "•", status: status, content: content, line: line, onSetStatus: onSetStatus) + + case .orderedListItem(_, let status, let content, let line): + ListItemView( + marker: "\(ordinal ?? 1).", status: status, content: content, + line: line, onSetStatus: onSetStatus) + + case .quote(_, let status, let content, let line): + QuoteView(status: status, content: content, line: line, onSetStatus: onSetStatus) + + case .codeBlock(let language, let code, _): + CodeBlockView(language: language, code: code) + + case .definition(let title, let status, _, let line), + .footnote(let title, let status, _, let line), + .tableCell(let title, let status, _, let line): + RangeableBlockView(title: title, status: status, line: line, onSetStatus: onSetStatus) + + case .rangedTag(let name, _, let content, _): + RangedTagView(name: name, content: content) + + case .horizontalRule: + Divider() + + case .weakDelimiter, .strongDelimiter: + EmptyView() + } + } +} -- cgit