Skip to content

Commit

Permalink
fix: set custom UTType
Browse files Browse the repository at this point in the history
update the type of data  to 'org.bsc.plantuml-text'
  • Loading branch information
Build Pipeline committed Nov 3, 2022
1 parent 059f9ab commit 66b1bbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions PlantUML/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<key>CFBundleTypeName</key>
<string>plantuml</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>org.bsc.plantuml</string>
<string>org.bsc.plantuml-text</string>
</array>
<key>NSUbiquitousDocumentUserActivityType</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).plantuml-document</string>
Expand All @@ -28,11 +28,13 @@
</array>
<key>UTTypeDescription</key>
<string>plantuml diagram</string>
<key>UTTypeIdentifier</key>
<string>org.bsc.plantuml-text</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.puml</key>
<key>public.filename-extension</key>
<array>
<string>puml</string>
</array>
Expand Down
9 changes: 5 additions & 4 deletions PlantUML/PlantUMLDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ import SwiftUI
import UniformTypeIdentifiers

extension UTType {
static var exampleText: UTType {
UTType(importedAs: "com.example.plain-text")
static var umldiagram: UTType {
// UTType(importedAs: "com.example.plain-text")
UTType(importedAs: "org.bsc.plantuml-text")
}
}

struct PlantUMLDocument: FileDocument {
var text: String

init(text: String = "Title untitled") {
self.text = text
}

static var readableContentTypes: [UTType] { [.exampleText] }
static var readableContentTypes: [UTType] { [.umldiagram] }

init(configuration: ReadConfiguration) throws {
guard let data = configuration.file.regularFileContents,
Expand Down

0 comments on commit 66b1bbf

Please sign in to comment.