krz/libre-edit

A free and private text editor for iOS. ios privacy swift text-editor

Commit 42f3aa0f6f

42f3aa0f6f9b72b06583715c812b0668801b5689

parent: 896d36505a

Verified · cmc

cmc <hello@cleberg.net> · 2024-01-14 18:01 UTC

feat: add option to view rendered markdown

Layout: unified · split

LibreEdit.xcodeproj/project.pbxproj +31
@@ -7,6 +7,8 @@
77 objects = {
88
99/* Begin PBXBuildFile section */
10 8B930F732B544EA200413A34 /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 8B930F722B544EA200413A34 /* MarkdownUI */; };
11 8B930F752B54504D00413A34 /* MarkdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B930F742B54504D00413A34 /* MarkdownView.swift */; };
1012 8BCA57062B537F9600DBA94B /* LibreEditApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BCA57052B537F9600DBA94B /* LibreEditApp.swift */; };
1113 8BCA57082B537F9600DBA94B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BCA57072B537F9600DBA94B /* ContentView.swift */; };
1214 8BCA570A2B537F9700DBA94B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8BCA57092B537F9700DBA94B /* Assets.xcassets */; };
@@ -14,6 +16,7 @@
1416/* End PBXBuildFile section */
1517
1618/* Begin PBXFileReference section */
19 8B930F742B54504D00413A34 /* MarkdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkdownView.swift; sourceTree = "<group>"; };
1720 8BCA57022B537F9600DBA94B /* LibreEdit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LibreEdit.app; sourceTree = BUILT_PRODUCTS_DIR; };
1821 8BCA57052B537F9600DBA94B /* LibreEditApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreEditApp.swift; sourceTree = "<group>"; };
1922 8BCA57072B537F9600DBA94B /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -26,6 +29,7 @@
2629 isa = PBXFrameworksBuildPhase;
2730 buildActionMask = 2147483647;
2831 files = (
32 8B930F732B544EA200413A34 /* MarkdownUI in Frameworks */,
2933 );
3034 runOnlyForDeploymentPostprocessing = 0;
3135 };
@@ -55,6 +59,7 @@
5559 8BCA57072B537F9600DBA94B /* ContentView.swift */,
5660 8BCA57092B537F9700DBA94B /* Assets.xcassets */,
5761 8BCA570B2B537F9700DBA94B /* Preview Content */,
62 8B930F742B54504D00413A34 /* MarkdownView.swift */,
5863 );
5964 path = LibreEdit;
6065 sourceTree = "<group>";
@@ -83,6 +88,9 @@
8388 dependencies = (
8489 );
8590 name = LibreEdit;
91 packageProductDependencies = (
92 8B930F722B544EA200413A34 /* MarkdownUI */,
93 );
8694 productName = LibreEdit;
8795 productReference = 8BCA57022B537F9600DBA94B /* LibreEdit.app */;
8896 productType = "com.apple.product-type.application";
@@ -111,6 +119,9 @@
111119 Base,
112120 );
113121 mainGroup = 8BCA56F92B537F9600DBA94B;
122 packageReferences = (
123 8B930F712B544EA200413A34 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */,
124 );
114125 productRefGroup = 8BCA57032B537F9600DBA94B /* Products */;
115126 projectDirPath = "";
116127 projectRoot = "";
@@ -137,6 +148,7 @@
137148 isa = PBXSourcesBuildPhase;
138149 buildActionMask = 2147483647;
139150 files = (
151 8B930F752B54504D00413A34 /* MarkdownView.swift in Sources */,
140152 8BCA57082B537F9600DBA94B /* ContentView.swift in Sources */,
141153 8BCA57062B537F9600DBA94B /* LibreEditApp.swift in Sources */,
142154 );
@@ -346,6 +358,25 @@
346358 defaultConfigurationName = Release;
347359 };
348360/* End XCConfigurationList section */
361
362/* Begin XCRemoteSwiftPackageReference section */
363 8B930F712B544EA200413A34 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = {
364 isa = XCRemoteSwiftPackageReference;
365 repositoryURL = "https://github.com/gonzalezreal/swift-markdown-ui";
366 requirement = {
367 kind = upToNextMajorVersion;
368 minimumVersion = 2.3.0;
369 };
370 };
371/* End XCRemoteSwiftPackageReference section */
372
373/* Begin XCSwiftPackageProductDependency section */
374 8B930F722B544EA200413A34 /* MarkdownUI */ = {
375 isa = XCSwiftPackageProductDependency;
376 package = 8B930F712B544EA200413A34 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */;
377 productName = MarkdownUI;
378 };
379/* End XCSwiftPackageProductDependency section */
349380 };
350381 rootObject = 8BCA56FA2B537F9600DBA94B /* Project object */;
351382}
LibreEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved added +23
@@ -0,0 +1,23 @@
1{
2 "pins" : [
3 {
4 "identity" : "networkimage",
5 "kind" : "remoteSourceControl",
6 "location" : "https://github.com/gonzalezreal/NetworkImage",
7 "state" : {
8 "revision" : "7aff8d1b31148d32c5933d75557d42f6323ee3d1",
9 "version" : "6.0.0"
10 }
11 },
12 {
13 "identity" : "swift-markdown-ui",
14 "kind" : "remoteSourceControl",
15 "location" : "https://github.com/gonzalezreal/swift-markdown-ui",
16 "state" : {
17 "revision" : "ae799d015a5374708f7b4c85f3294c05f2a564e2",
18 "version" : "2.3.0"
19 }
20 }
21 ],
22 "version" : 2
23}
LibreEdit/ContentView.swift +49 −42
@@ -43,51 +43,58 @@ struct ContentView: View {
4343 @Binding var document: TextFile
4444 @State private var showingPopover = false
4545 @State private var wordCount: Int = 0
46
46
4747 var body: some View {
48 Text("\(wordCount) words")
49 .foregroundColor(Color.white)
50 .font(.headline)
51 .padding(.trailing)
52 .frame(maxWidth: .infinity, maxHeight: 50)
53 .background(Color.gray.opacity(0.3))
54 .padding(.top, 20)
55 TextEditor(text: $document.text)
56 .onAppear {
57 self.wordCount = countWords(text: document.text)
58 }
59 .onChange(of: document.text) {
60 self.wordCount = countWords(text: document.text)
61 }
62 .toolbar {
63 ToolbarItemGroup(placement: .secondaryAction) {
64 Button {
65 showingPopover = true
66 } label: {
67 Text("More Info")
68 }.popover(isPresented: $showingPopover) {
69 VStack(alignment: .leading) {
70 Text("More Info")
71 .font(.largeTitle)
72 Text("")
73 Text("Instructions")
74 .font(.title)
75 Text("")
76 Text("LibreEdit provides a direct interface with the Apple Files app on your iPhone. Simply navigate to your preferred directory, edit existing files, or create new files!")
77 Text("")
78 Text("Developer")
79 .font(.title)
80 Text("")
81 Text("LibreEdit is a free and open source text editor for iOS built by [Christian Cleberg](https://cleberg.net).")
82 Text("")
83 Text("Visit the [GitHub Repository](https://github.com/ccleberg/ios-edit) to view the source code.")
84 Text("")
85 Text("This project was developed under the [GNU GPL v3 license](https://github.com/ccleberg/ios-edit/LICENSE).")
86 Spacer()
48 NavigationView {
49 VStack {
50 Text("\(wordCount) words")
51 .foregroundColor(Color.white)
52 .font(.headline)
53 .padding(.trailing)
54 .frame(maxWidth: .infinity, maxHeight: 50)
55 .background(Color.gray.opacity(0.3))
56 .padding(.top, 20)
57 TextEditor(text: $document.text)
58 .onAppear {
59 self.wordCount = countWords(text: document.text)
60 }
61 .onChange(of: document.text) {
62 self.wordCount = countWords(text: document.text)
63 }
64 .toolbar {
65 ToolbarItemGroup(placement: .secondaryAction) {
66 NavigationLink(destination: MarkdownView(document: $document)) {
67 Text("Show Rendered Markdown")
68 }
69 Button {
70 showingPopover = true
71 } label: {
72 Text("More Info")
73 }.popover(isPresented: $showingPopover) {
74 VStack(alignment: .leading) {
75 Text("More Info")
76 .font(.largeTitle)
77 Text("")
78 Text("Instructions")
79 .font(.title)
80 Text("")
81 Text("LibreEdit provides a direct interface with the Apple Files app on your iPhone. Simply navigate to your preferred directory, edit existing files, or create new files!")
82 Text("")
83 Text("Developer")
84 .font(.title)
85 Text("")
86 Text("LibreEdit is a free and open source text editor for iOS built by [Christian Cleberg](https://cleberg.net).")
87 Text("")
88 Text("Visit the [GitHub Repository](https://github.com/ccleberg/ios-edit) to view the source code.")
89 Text("")
90 Text("This project was developed under the [GNU GPL v3 license](https://github.com/ccleberg/ios-edit/LICENSE).")
91 Spacer()
92 }
93 .padding()
94 }
8795 }
88 .padding()
8996 }
90 }
9197 }
98 }
9299 }
93100}
LibreEdit/MarkdownView.swift added +24
@@ -0,0 +1,24 @@
1//
2// MarkdownView.swift
3// LibreEdit
4//
5// Created by Christian Cleberg on 2024-01-14.
6//
7
8import SwiftUI
9import MarkdownUI
10
11struct MarkdownView: View {
12 @Binding var document: TextFile
13
14 var body: some View {
15 ScrollView {
16 Markdown {
17 MarkdownContent(document.text)
18 }
19 .markdownTheme(.docC)
20 .padding()
21 }
22 .navigationTitle("Rendered Markdown")
23 }
24}
README.md +13 −5
@@ -3,12 +3,20 @@
33LibreEdit intended to be a simple open-source text editing app for iOS, written
44in Swift.
55
6## TODO
6LibreEdit integrates with the native iOS file manager, allowing users full
7control over the files themselves. The editor is simple and should display all
8file types.
79
8- [ ] Add functionality to `New` button.
9- [ ] Allow custom file names when saving.
10- [ ] Allow editing of existing files.
10There is an option to view rendered Markdown in the secondary actions menu in
11the naviation bar.
1112
1213## Screenshots
1314
14![Libre Edit](Screenshots/libre_edit.png)
15Native file manager:
16![Libre Edit](Screenshots/file_manager.png)
17
18Editor:
19![Libre Edit](Screenshots/editor.png)
20
21Rendered Markdown:
22![Libre Edit](Screenshots/rendered.png)
Screenshots/editor.png added

Binary file not shown.

Screenshots/file_manager.png added

Binary file not shown.

Screenshots/libre_edit.png deleted

Binary file not shown.

Screenshots/rendered.png added

Binary file not shown.