KMNBotaAnnotationModel.swift 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // KMNBotaAnnotationModel.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/12/6.
  6. //
  7. import Cocoa
  8. class KMNBotaAnnotationSectionModel: NSObject {
  9. var isExpand = false
  10. var items: [KMNBotaAnnotationModel] = []
  11. var titleText: String = "" //头部显示文字,目前是时间或者页面
  12. var viewH: CGFloat = 44 //头部高度
  13. }
  14. class KMNBotaAnnotationModel: NSObject {
  15. weak var annotation: CPDFAnnotation? {
  16. didSet {
  17. if annotation?.isMarkup() == true {
  18. if let markAnnotation = annotation as? CPDFMarkupAnnotation {
  19. privateContentText = markAnnotation.markupText()
  20. }
  21. } else {
  22. privateContentText = annotation?.contents ?? ""
  23. }
  24. privateAuthorText = annotation?.userName() ?? ""
  25. let ans = annotation?.replyAnnotations
  26. let tReplys:[KMNReplysAnnotationModel] = []
  27. for i in 0 ..< (ans?.count ?? 0) {
  28. let annotationModel = KMNReplysAnnotationModel()
  29. annotationModel.annotation = ans?[i]
  30. }
  31. replys = tReplys
  32. modificationDate = annotation?.modificationDate() as NSDate?
  33. }
  34. }
  35. var isExpand = false
  36. private var privateContentText:String = ""
  37. var contentText: String {
  38. return privateContentText
  39. }
  40. private var privateAuthorText:String = ""
  41. var authorText: String {
  42. return privateAuthorText
  43. }
  44. private var replys: [KMNReplysAnnotationModel] = []
  45. var replyAnnotations: [KMNReplysAnnotationModel] {
  46. return replys
  47. }
  48. private var modificationDate: NSDate?
  49. var annotationDate: NSDate {
  50. return modificationDate ?? NSDate()
  51. }
  52. }
  53. class KMNReplysAnnotationModel: NSObject {
  54. weak var annotation: CPDFAnnotation? {
  55. didSet {
  56. privateContentText = annotation?.contents ?? ""
  57. privateAuthorText = annotation?.userName() ?? ""
  58. modificationDate = annotation?.modificationDate() as NSDate?
  59. }
  60. }
  61. var isEnterEdit = false
  62. private var privateContentText:String = ""
  63. var contentText: String {
  64. return privateContentText
  65. }
  66. private var privateAuthorText:String = ""
  67. var authorText: String {
  68. return privateAuthorText
  69. }
  70. private var replys: [KMNReplysAnnotationModel] = []
  71. var replyAnnotations: [KMNReplysAnnotationModel] {
  72. return replys
  73. }
  74. private var modificationDate: NSDate?
  75. var annotationDate: NSDate {
  76. return modificationDate ?? NSDate()
  77. }
  78. }