Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,8 @@ private extension AttributedStringParser {
if attachment.alignment != .center {
style += attachment.alignment.htmlString()
}

if attachment.size != .full {
if attachment.size != .none {
style += style.isEmpty ? String() : String(.space)
style += attachment.size.htmlString()
}
Expand Down
11 changes: 8 additions & 3 deletions Aztec/Classes/TextKit/ImageAttachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open class ImageAttachment: MediaAttachment {

/// Attachment Size
///
open var size: Size = .full {
open var size: Size = .none {
willSet {
if newValue != size {
glyphImage = nil
Expand Down Expand Up @@ -117,7 +117,7 @@ open class ImageAttachment: MediaAttachment {
override func onScreenWidth(_ containerWidth: CGFloat) -> CGFloat {
if let image = image {
switch (size) {
case .full:
case .full, .none:
return floor(min(image.size.width, containerWidth))
default:
return floor(min(min(image.size.width,size.width), containerWidth))
Expand Down Expand Up @@ -191,6 +191,7 @@ extension ImageAttachment {
case medium
case large
case full
case none

func htmlString() -> String {
switch self {
Expand All @@ -202,14 +203,17 @@ extension ImageAttachment {
return "size-large"
case .full:
return "size-full"
case .none:
return ""
}
}

static let mappedValues:[String:Size] = [
Size.thumbnail.htmlString():.thumbnail,
Size.medium.htmlString():.medium,
Size.large.htmlString():.large,
Size.full.htmlString():.full
Size.full.htmlString():.full,
Size.none.htmlString():.none
]

static func fromHTML(string value:String) -> Size? {
Expand All @@ -222,6 +226,7 @@ extension ImageAttachment {
case .medium: return Settings.medium
case .large: return Settings.large
case .full: return Settings.maximum
case .none: return Settings.maximum
}
}

Expand Down
15 changes: 8 additions & 7 deletions Example/Example/AttachmentDetailsViewController.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -29,12 +29,13 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="qWp-hq-exU">
<rect key="frame" x="16" y="8" width="349" height="29"/>
<rect key="frame" x="24" y="8" width="341" height="29"/>
<segments>
<segment title="Thumbnail"/>
<segment title="Medium"/>
<segment title="Large"/>
<segment title="Full"/>
<segment title="None"/>
</segments>
</segmentedControl>
</subviews>
Expand All @@ -57,7 +58,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="hM7-SO-P7P">
<rect key="frame" x="16" y="8" width="349" height="29"/>
<rect key="frame" x="24" y="8" width="341" height="29"/>
<segments>
<segment title="None"/>
<segment title="Left"/>
Expand Down Expand Up @@ -85,7 +86,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="6H9-eI-Wgd">
<rect key="frame" x="16" y="7" width="336" height="30"/>
<rect key="frame" x="24" y="7" width="320" height="30"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" keyboardType="URL"/>
Expand All @@ -110,7 +111,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="fsr-eq-4v0">
<rect key="frame" x="16" y="7" width="336" height="30"/>
<rect key="frame" x="24" y="7" width="320" height="30"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" keyboardType="URL"/>
Expand All @@ -135,7 +136,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="fBd-rD-kOx">
<rect key="frame" x="16" y="7" width="336" height="30"/>
<rect key="frame" x="24" y="7" width="320" height="30"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" keyboardType="URL"/>
Expand Down
3 changes: 3 additions & 0 deletions Example/Example/AttachmentDetailsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ private extension AttachmentDetailsViewController
case medium
case large
case maximum
case none

init(attachmentSize: AttachmentSize) {
switch attachmentSize {
case .thumbnail: self = .thumbnail
case .medium: self = .medium
case .large: self = .large
case .full: self = .maximum
case .none: self = .none
}
}

Expand All @@ -146,6 +148,7 @@ private extension AttachmentDetailsViewController
case .medium: return .medium
case .large: return .large
case .maximum: return .full
case .none: return .none
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Example/Example/EditorDemoController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ private extension EditorDemoController
let fileURL = saveToDisk(image: image)

let attachment = richTextView.replaceWithImage(at: richTextView.selectedRange, sourceURL: fileURL, placeHolderImage: image)
attachment.size = .full
attachment.linkURL = fileURL
let imageID = attachment.identifier
let progress = Progress(parent: nil, userInfo: [MediaProgressKey.mediaID: imageID])
Expand Down