Fix id of Items, saving

This commit is contained in:
Christoph Hagen
2025-06-11 08:19:44 +02:00
parent 5970ce2e9f
commit 1d0eba9d78
64 changed files with 233 additions and 217 deletions

View File

@ -20,7 +20,7 @@ final class InsertableFileButton: ObservableObject {
"""
icon: \(label.icon.rawValue)
text: \(label.value)
file: \(file.id)
file: \(file.identifier)
"""
guard let downloadedFileName else {
return result
@ -86,7 +86,7 @@ struct InsertableButtons: View, InsertableCommandView {
var id: String {
switch self {
case .file(let file):
return "file-\(file.file?.id ?? "none")"
return "file-\(file.file?.identifier ?? "none")"
case .url(let url):
return "url-\(url.url)"
case .event(let event):
@ -161,7 +161,7 @@ private struct FileButtonView: View {
var body: some View {
HStack {
LabelEditingView(label: $content.label)
Button("\(content.file?.id ?? "Select file")", action: { showFileSelectionSheet = true })
Button("\(content.file?.identifier ?? "Select file")", action: { showFileSelectionSheet = true })
OptionalTextField("", text: $content.downloadedFileName, prompt: "Downloaded file name")
.textFieldStyle(.roundedBorder)
}

View File

@ -28,7 +28,7 @@ struct InsertableGallery: View, InsertableCommandView {
}
return (
["```\(GalleryBlock.blockId)"] +
images.map { $0.id } +
images.map { $0.identifier } +
["```"]
).joined(separator: "\n")
}

View File

@ -24,9 +24,9 @@ struct InsertableImage: View, InsertableCommandView {
return nil
}
guard let caption else {
return "![image](\(selectedImage.id))"
return "![image](\(selectedImage.identifier))"
}
return "![image](\(selectedImage.id);\(caption))"
return "![image](\(selectedImage.identifier);\(caption))"
}
}

View File

@ -45,11 +45,11 @@ struct InsertableLink: View, InsertableCommandView {
case .post, .tagOverview:
return nil
case .page:
return selectedPage?.id
return selectedPage?.identifier
case .tag:
return selectedTag?.id
return selectedTag?.identifier
case .file:
return selectedFile?.id
return selectedFile?.identifier
}
}

View File

@ -40,8 +40,8 @@ struct InsertableRoute: View, InsertableCommandView {
return nil
}
var result = ["```route"]
result.append("\(RouteBlock.Key.image.rawValue): \(selectedImage.id)")
result.append("\(RouteBlock.Key.file.rawValue): \(dataFile.id)")
result.append("\(RouteBlock.Key.image.rawValue): \(selectedImage.identifier)")
result.append("\(RouteBlock.Key.file.rawValue): \(dataFile.identifier)")
if components != Set(RouteStatisticType.allCases) {
let list = components
.map { $0.rawValue }

View File

@ -50,16 +50,16 @@ struct InsertableVideo: View, InsertableCommandView {
var lines: [String] = []
lines.append("```video")
if let posterImage {
lines.append("\(VideoBlock.Key.poster): \(posterImage.id)")
lines.append("\(VideoBlock.Key.poster): \(posterImage.identifier)")
}
if let videoH265 {
lines.append("\(VideoBlock.Key.h265): \(videoH265.id)")
lines.append("\(VideoBlock.Key.h265): \(videoH265.identifier)")
}
if let videoH264 {
lines.append("\(VideoBlock.Key.h264): \(videoH264.id)")
lines.append("\(VideoBlock.Key.h264): \(videoH264.identifier)")
}
if let videoWebm {
lines.append("\(VideoBlock.Key.webm): \(videoWebm.id)")
lines.append("\(VideoBlock.Key.webm): \(videoWebm.identifier)")
}
if controls { lines.append(VideoBlock.Key.controls.rawValue) }
if autoplay { lines.append(VideoBlock.Key.autoplay.rawValue) }