-
Notifications
You must be signed in to change notification settings - Fork 83
/
AggregateEditorViewDelegate.swift
112 lines (93 loc) · 5.67 KB
/
AggregateEditorViewDelegate.swift
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// AggregateEditorViewDelegate.swift
// Proton
//
// Created by Rajdeep Kwatra on 20/7/2023.
// Copyright © 2023 Rajdeep Kwatra. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import UIKit
class AggregateEditorViewDelegate: EditorViewDelegate {
private init(){ }
static func editor(_ editor: EditorView, shouldHandle key: EditorKey, modifierFlags: UIKeyModifierFlags, at range: NSRange, handled: inout Bool) {
editor.delegate?.editor(editor, shouldHandle: key, modifierFlags: modifierFlags, at: range, handled: &handled)
editor.editorContextDelegate?.editor(editor, shouldHandle: key, modifierFlags: modifierFlags, at: range, handled: &handled)
}
static func editor(_ editor: EditorView, didReceiveKey key: EditorKey, at range: NSRange) {
editor.delegate?.editor(editor, didReceiveKey: key, at: range)
editor.editorContextDelegate?.editor(editor, didReceiveKey: key, at: range)
}
static func editor(_ editor: EditorView, didReceiveFocusAt range: NSRange) {
editor.delegate?.editor(editor, didReceiveFocusAt: range)
editor.editorContextDelegate?.editor(editor, didReceiveFocusAt: range)
}
static func editor(_ editor: EditorView, didLoseFocusFrom range: NSRange) {
editor.delegate?.editor(editor, didLoseFocusFrom: range)
editor.editorContextDelegate?.editor(editor, didLoseFocusFrom: range)
}
static func editor(_ editor: EditorView, didChangeTextAt range: NSRange) {
editor.delegate?.editor(editor, didChangeTextAt: range)
editor.editorContextDelegate?.editor(editor, didChangeTextAt: range)
}
static func editor(_ editor: EditorView, didChangeSelectionAt range: NSRange, attributes: [NSAttributedString.Key: Any], contentType: EditorContent.Name) {
editor.delegate?.editor(editor, didChangeSelectionAt: range, attributes: attributes, contentType: contentType)
editor.editorContextDelegate?.editor(editor, didChangeSelectionAt: range, attributes: attributes, contentType: contentType)
}
static func editor(_ editor: EditorView, didExecuteProcessors processors: [TextProcessing], at range: NSRange) {
editor.delegate?.editor(editor, didExecuteProcessors: processors, at: range)
editor.editorContextDelegate?.editor(editor, didExecuteProcessors: processors, at: range)
}
static func editor(_ editor: EditorView, didChangeSize currentSize: CGSize, previousSize: CGSize) {
editor.delegate?.editor(editor, didChangeSize: currentSize, previousSize: previousSize)
editor.editorContextDelegate?.editor(editor, didChangeSize: currentSize, previousSize: previousSize)
}
static func editor(_ editor: EditorView, didTapAtLocation location: CGPoint, characterRange: NSRange?) {
editor.delegate?.editor(editor, didTapAtLocation: location, characterRange: characterRange)
editor.editorContextDelegate?.editor(editor, didTapAtLocation: location, characterRange: characterRange)
}
static func editor(_ editor: EditorView, didLayout content: NSAttributedString) {
editor.delegate?.editor(editor,didLayout: content)
editor.editorContextDelegate?.editor(editor,didLayout: content)
}
static func editor(_ editor: EditorView, willSetAttributedText attributedText: NSAttributedString, isDeferred: Bool) {
editor.delegate?.editor(editor, willSetAttributedText: attributedText, isDeferred: isDeferred)
editor.editorContextDelegate?.editor(editor, willSetAttributedText: attributedText, isDeferred: isDeferred)
}
static func editor(_ editor: EditorView, didSetAttributedText attributedText: NSAttributedString, isDeferred: Bool) {
editor.delegate?.editor(editor, didSetAttributedText: attributedText, isDeferred: isDeferred)
editor.editorContextDelegate?.editor(editor, didSetAttributedText: attributedText, isDeferred: isDeferred)
}
static func editor(_ editor: EditorView, isReady: Bool) {
editor.delegate?.editor(editor, isReady: isReady)
editor.editorContextDelegate?.editor(editor, isReady: isReady)
}
static func editor(_ editor: EditorView, didChangeEditable isEditable: Bool) {
editor.delegate?.editor(editor, didChangeEditable: isEditable)
editor.editorContextDelegate?.editor(editor, didChangeEditable: isEditable)
}
static func editor(_ editor: EditorView, willRenderAttachment attachment: Attachment) {
editor.delegate?.editor(editor, willRenderAttachment: attachment)
editor.editorContextDelegate?.editor(editor, willRenderAttachment: attachment)
}
static func editor(_ editor: EditorView, didRenderAttachment attachment: Attachment) {
editor.delegate?.editor(editor, didRenderAttachment: attachment)
editor.editorContextDelegate?.editor(editor, didRenderAttachment: attachment)
}
static func editor(_ editor: EditorView, shouldSelectAttachmentOnBackspace attachment: Attachment) -> Bool? {
return editor.delegate?.editor(editor, shouldSelectAttachmentOnBackspace: attachment) ??
editor.editorContextDelegate?.editor(editor, shouldSelectAttachmentOnBackspace: attachment) ??
attachment.selectBeforeDelete
}
}