-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3ed533
commit 27e2f3b
Showing
42 changed files
with
438 additions
and
1,239 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file was deleted.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo (iOS).xcscheme
This file was deleted.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo (macOS).xcscheme
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
Demo/Demo.xcodeproj/xcshareddata/xcschemes/RichTextKitTests.xcscheme
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// DemoApp.swift | ||
// Demo | ||
// | ||
// Created by Daniel Saidi on 2024-03-04. | ||
// Copyright © 2024 Kankoda Sweden AB. All rights reserved. | ||
// | ||
|
||
import RichTextKit | ||
import SwiftUI | ||
|
||
@main | ||
struct DemoApp: App { | ||
|
||
var body: some Scene { | ||
|
||
DocumentGroup(newDocument: DemoDocument()) { file in | ||
DemoEditor( | ||
document: file.$document | ||
) | ||
} | ||
.commands { | ||
SidebarCommands() | ||
#if os(macOS) | ||
AboutCommand() | ||
#endif | ||
RichTextCommand.FormatMenu() | ||
|
||
CommandMenu("RichTextKit") { | ||
DemoUrl.github.link | ||
DemoUrl.documentation.link | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// DemoDocument.swift | ||
// Demo | ||
// | ||
// Created by Daniel Saidi on 2024-03-04. | ||
// Copyright © 2024 Kankoda Sweden AB. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import RichTextKit | ||
import UniformTypeIdentifiers | ||
|
||
struct DemoDocument: FileDocument { | ||
|
||
init(text: NSAttributedString = .empty) { | ||
self.text = text | ||
} | ||
|
||
var text: NSAttributedString | ||
|
||
static var readableContentTypes: [UTType] { [.archivedData] } | ||
|
||
init( | ||
configuration: ReadConfiguration | ||
) throws { | ||
guard | ||
let data = configuration.file.regularFileContents | ||
else { | ||
throw CocoaError(.fileReadCorruptFile) | ||
} | ||
let text = try NSAttributedString(data: data, format: .archivedData) | ||
self.text = text | ||
} | ||
|
||
func fileWrapper( | ||
configuration: WriteConfiguration | ||
) throws -> FileWrapper { | ||
let data = try text.richTextData(for: .archivedData) | ||
return .init(regularFileWithContents: data) | ||
} | ||
} |
Oops, something went wrong.