Skip to content

Commit

Permalink
Deprecate some context functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Feb 14, 2024
1 parent fb1f6f9 commit ca04d4a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 56 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ This release adds a lot of new `RichTextAction` cases and adjusts the context an

* The library once again builds on visionOS.

* `RichTextAlignment` now behaves better.
* `RichTextCoordinator` now handles indentation changes.


### 🗑️ Deprecations

* `RichTextCoordinator` functions that just trigger `handle(_:)` have been deprecated.



## 0.9.8
Expand Down
54 changes: 0 additions & 54 deletions Sources/RichTextKit/Context/RichTextContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,60 +154,6 @@ public extension RichTextContext {
highlightedRange = range
}

/// Paste an image into the editor, at a certain index.
func pasteImage(
_ image: ImageRepresentable,
at index: Int? = nil,
moveCursorToPastedContent: Bool = false
) {
let index = index ?? selectedRange.location
userActionPublisher.send(
.pasteImage(
RichTextInsertion(
content: image,
at: index,
moveCursor: moveCursorToPastedContent
)
)
)
}

/// Paste images into the editor, at a certain index.
func pasteImages(
_ images: [ImageRepresentable],
at index: Int? = nil,
moveCursorToPastedContent: Bool = false
) {
let index = index ?? selectedRange.location
userActionPublisher.send(
.pasteImages(
RichTextInsertion(
content: images,
at: index,
moveCursor: moveCursorToPastedContent
)
)
)
}

/// Paste text into the editor, at a certain index.
func pasteText(
_ text: String,
at index: Int? = nil,
moveCursorToPastedContent: Bool = false
) {
let index = index ?? selectedRange.location
userActionPublisher.send(
.pasteText(
RichTextInsertion(
content: text,
at: index,
moveCursor: moveCursorToPastedContent
)
)
)
}

/// Reset the attributed string.
func resetAttributedString() {
setAttributedString(to: "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ public extension RichTextAttributeWriter {
let increase = indent == .increase
let change: CGFloat = 30.0
let points = increase ? change : -change
stepRichTextIndent(points: points, at: range)
return richTextAttributes(at: range)
return stepRichTextIndent(points: points, at: range)
}

@available(*, deprecated, renamed: "stepRichTextFontSize(points:at:)")
Expand Down
54 changes: 54 additions & 0 deletions Sources/RichTextKit/_Deprecated/RichTextContext+Deprecated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,58 @@ public extension RichTextContext {
func decreaseIndent(points: UInt = 1) {
handle(.decreaseIndent(points: points))
}

@available(*, deprecated, message: "Use handle(_:) with the .pasteImage action")
func pasteImage(
_ image: ImageRepresentable,
at index: Int? = nil,
moveCursorToPastedContent: Bool = false
) {
let index = index ?? selectedRange.location
userActionPublisher.send(
.pasteImage(
RichTextInsertion(
content: image,
at: index,
moveCursor: moveCursorToPastedContent
)
)
)
}

@available(*, deprecated, message: "Use handle(_:) with the .pasteImages action")
func pasteImages(
_ images: [ImageRepresentable],
at index: Int? = nil,
moveCursorToPastedContent: Bool = false
) {
let index = index ?? selectedRange.location
userActionPublisher.send(
.pasteImages(
RichTextInsertion(
content: images,
at: index,
moveCursor: moveCursorToPastedContent
)
)
)
}

@available(*, deprecated, message: "Use handle(_:) with the .pasteText action")
func pasteText(
_ text: String,
at index: Int? = nil,
moveCursorToPastedContent: Bool = false
) {
let index = index ?? selectedRange.location
userActionPublisher.send(
.pasteText(
RichTextInsertion(
content: text,
at: index,
moveCursor: moveCursorToPastedContent
)
)
)
}
}

0 comments on commit ca04d4a

Please sign in to comment.