You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When inserting an image into the RichTextEdit contained within a ScrollView, the image is being scaled down to the height of the view. This happens because the smallest height is being used for scaling.
#221
Open
alonematch86 opened this issue
Dec 14, 2024
· 1 comment
When inserting an image into the RichTextEdit contained within a ScrollView, the image is being scaled down to the height of the view. This happens because the smallest height is being used for scaling.
To resolve this, I modified the RichTextImageAttachmentManager.swift file by commenting out the logic responsible for height scaling in the attachmentSize method.
public extension RichTextImageAttachmentManager {
/// Get the attachment bounds of an image, given a max size.
func attachmentBounds(
for image: ImageRepresentable,
maxSize: CGSize
) -> CGRect {
let size = attachmentSize(for: image, maxSize: maxSize)
return CGRect(origin: .zero, size: size)
}
/// Get the attachment size of an image, given a max size.
func attachmentSize(
for image: ImageRepresentable,
maxSize: CGSize
) -> CGSize {
let size = image.size
let validWidth = size.width < maxSize.width
let validHeight = size.height < maxSize.height
let validSize = validWidth && validHeight
if validSize {
return image.size
}
let aspectWidth = maxSize.width / size.width
// Removed height scaling logic to avoid shrinking the image unnecessarily
// let aspectHeight = maxSize.height / size.height
let aspectRatio = aspectWidth // min(aspectWidth, aspectHeight)
let newSize = CGSize(
width: size.width * aspectRatio,
height: size.height * aspectRatio
)
return newSize
}
}
The text was updated successfully, but these errors were encountered:
When inserting an image into the RichTextEdit contained within a ScrollView, the image is being scaled down to the height of the view. This happens because the smallest height is being used for scaling.
To resolve this, I modified the RichTextImageAttachmentManager.swift file by commenting out the logic responsible for height scaling in the attachmentSize method.
public extension RichTextImageAttachmentManager {
}
The text was updated successfully, but these errors were encountered: