diff --git a/Proton/Sources/Swift/Editor/EditorView.swift b/Proton/Sources/Swift/Editor/EditorView.swift index 39531276..9e6b9f84 100644 --- a/Proton/Sources/Swift/Editor/EditorView.swift +++ b/Proton/Sources/Swift/Editor/EditorView.swift @@ -1468,6 +1468,7 @@ extension EditorView { } } } else { + self.delegate?.editor(self, willRenderAttachment: attachment) attachment.render(in: self) if !self.isSettingAttributedText, let focusable = attachment.contentView as? Focusable { focusable.setFocus() diff --git a/Proton/Sources/Swift/Editor/EditorViewDelegate.swift b/Proton/Sources/Swift/Editor/EditorViewDelegate.swift index f5f334cb..5f84024e 100644 --- a/Proton/Sources/Swift/Editor/EditorViewDelegate.swift +++ b/Proton/Sources/Swift/Editor/EditorViewDelegate.swift @@ -118,6 +118,15 @@ public protocol EditorViewDelegate: AnyObject { /// - isEditable: `true` if editor is editable, else `false` func editor(_ editor: EditorView, didChangeEditable isEditable: Bool) + /// Notifies when an `Attachment` is going to rendered for the first time in `EditorView` + /// - Parameters: + /// - editor: Editor view receiving the event. + /// - attachment: `Attachment` getting rendered + /// - Note: + /// This invocation only applies in default mode of rendering attachment. If `EditorView` has `AsyncAttachmentRenderingDelegate` provided, + /// that delegate will receive the event instead. + func editor(_ editor: EditorView, willRenderAttachment attachment: Attachment) + /// Notifies when an `Attachment` is rendered for the first time in `EditorView` /// - Parameters: /// - editor: Editor view receiving the event. @@ -153,6 +162,7 @@ public extension EditorViewDelegate { func editor(_ editor: EditorView, didSetAttributedText attributedText: NSAttributedString, isDeferred: Bool) { } func editor(_ editor: EditorView, isReady: Bool) { } func editor(_ editor: EditorView, didChangeEditable isEditable: Bool) { } + func editor(_ editor: EditorView, willRenderAttachment attachment: Attachment) { } func editor(_ editor: EditorView, didRenderAttachment attachment: Attachment) { } func editor(_ editor: EditorView, shouldSelectAttachmentOnBackspace attachment: Attachment) -> Bool? { return nil