Repository navigation
Expand file tree
/
Copy pathCoreNote.swift
More file actions
71 lines (62 loc) · 2.24 KB
/
Copy pathCoreNote.swift
File metadata and controls
71 lines (62 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// Note.swift
// FSNotes iOS
//
// Created by Oleksandr Glushchenko on 7/25/18.
// Copyright © 2018 Oleksandr Glushchenko. All rights reserved.
//
import UIKit
import Foundation
public class CoreNote: UIDocument {
var note: Note
init(note: Note) {
self.note = note
super.init(fileURL: note.url)
}
public override func contents(forType typeName: String) throws -> Any {
return note.getFileWrapper()
}
public override func load(fromContents contents: Any, ofType typeName: String?) throws {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "es.fsnot.external.file.changed"), object: nil)
//
// DispatchQueue.main.async {
// UIApplication.getVC().cloudDriveManager?.resolveConflict(url: self.fileURL)
// }
//
// if typeName == "public.rtf" {
// /**
// TODO: Implement RTF reloading
// **/
// return
// }
//
// if typeName == "org.textbundle.package", let wrapper = contents as? FileWrapper {
// if let infoWrapper = wrapper.fileWrappers?["info.json"], let jsonData = infoWrapper.regularFileContents,
// let info = try? JSONDecoder().decode(TextBundleInfo.self, from: jsonData) {
// let container: NoteContainer = info.version == 0x02 ? .textBundleV2 : .textBundle
//
// let ext = NoteType.withUTI(rawValue: info.type).getExtension(for: container)
// let fileName = "text.\(ext)"
//
// if let markdownWrapper = wrapper.fileWrappers?[fileName] {
// if let data = markdownWrapper.regularFileContents, let content = String(data: data as Data, encoding: .utf8) {
// self.content = content
// updateView()
// }
// }
//
// return
// }
// }
//
// if let data = contents as? Data, let content = String(data: data, encoding: .utf8) {
// self.content = content
// updateView()
// }
}
public func updateView() {
// DispatchQueue.main.async {
// UIApplication.getVC().updateTableOrEditor(url: self.fileURL, content: self.content)
// }
}
}