mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
Fix markdown
This commit is contained in:
BIN
Binary file not shown.
@@ -384,51 +384,64 @@ struct FilterView: View {
|
||||
struct MarkdownContentView: View {
|
||||
let link: Link
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
@EnvironmentObject var linkViewModel: LinkViewModel
|
||||
@State private var showingEditLink = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
// Title
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
// Alias label
|
||||
HStack {
|
||||
Text(link.alias)
|
||||
.font(.largeTitle)
|
||||
.fontWeight(.bold)
|
||||
.padding(.horizontal)
|
||||
|
||||
// Description if available
|
||||
if let description = link.linkDescription, !description.isEmpty {
|
||||
Text(description)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
// Markdown content
|
||||
if let content = link.text, !content.isEmpty {
|
||||
// Use the existing markdown renderer
|
||||
Text(MarkdownRenderer.renderToAttributedString(content))
|
||||
.padding(.horizontal)
|
||||
.textSelection(.enabled)
|
||||
} else {
|
||||
Text("No content available")
|
||||
.font(.body)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
.font(.caption)
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 4)
|
||||
.background(Color.blue.opacity(0.2))
|
||||
.foregroundColor(.blue)
|
||||
.cornerRadius(6)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical)
|
||||
.padding(.horizontal)
|
||||
|
||||
// Markdown content
|
||||
ScrollView {
|
||||
if let content = link.text, !content.isEmpty {
|
||||
Text(MarkdownRenderer.renderToAttributedString(content))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal)
|
||||
.textSelection(.enabled)
|
||||
} else {
|
||||
VStack {
|
||||
Image(systemName: "doc.text")
|
||||
.font(.system(size: 50))
|
||||
.foregroundColor(.secondary)
|
||||
Text("No content available")
|
||||
.font(.title3)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Custom Content")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button("Edit") {
|
||||
showingEditLink = true
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("Done") {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showingEditLink) {
|
||||
LinkFormView(link: link)
|
||||
.environmentObject(linkViewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MarkdownContentView: View {
|
||||
let link: Link
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
// Title
|
||||
Text(link.alias)
|
||||
.font(.largeTitle)
|
||||
.fontWeight(.bold)
|
||||
.padding(.horizontal)
|
||||
|
||||
// Description if available
|
||||
if let description = link.linkDescription, !description.isEmpty {
|
||||
Text(description)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
// Markdown content
|
||||
if let content = link.text, !content.isEmpty {
|
||||
// Use the existing markdown renderer
|
||||
Text(MarkdownRenderer.renderToAttributedString(content))
|
||||
.padding(.horizontal)
|
||||
.textSelection(.enabled)
|
||||
} else {
|
||||
Text("No content available")
|
||||
.font(.body)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical)
|
||||
}
|
||||
.navigationTitle("Custom Content")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("Done") {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
// Create a sample link for preview
|
||||
let context = PersistenceController.preview.container.viewContext
|
||||
let sampleLink = Link(context: context)
|
||||
sampleLink.alias = "Sample Custom Content"
|
||||
sampleLink.text = "# This is a heading\n\nThis is some **bold** text and some *italic* text.\n\n- Item 1\n- Item 2\n- Item 3\n\nThis is a paragraph with some content."
|
||||
sampleLink.linkDescription = "A sample custom content link"
|
||||
sampleLink.linkType = LinkType.custom.rawValue
|
||||
|
||||
return MarkdownContentView(link: sampleLink)
|
||||
}
|
||||
Reference in New Issue
Block a user