Package apple.uikit.protocol
Interface NSTextElementProvider
-
- All Known Implementing Classes:
NSTextContentManager,NSTextContentStorage
public interface NSTextElementProviderNSTextElementProvider is a protocol conformed by NSTextContentManager and its concrete subclasses. It defines the base interface for interacting with a custom text document content type. API-Since: 15.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceNSTextElementProvider.Block_enumerateTextElementsFromLocationOptionsUsingBlockstatic interfaceNSTextElementProvider.Block_synchronizeToBackingStore
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default @Nullable NSTextRangeadjustedRangeFromRangeForEditingTextSelection(@NotNull NSTextRange textRange, boolean forEditingTextSelection)Should be implemented if the location backing store requires manual adjustment after editing.@NotNull NSTextRangedocumentRange()Declares the starting and ending locations for the document.@Nullable NSTextLocationenumerateTextElementsFromLocationOptionsUsingBlock(@Nullable NSTextLocation textLocation, long options, @NotNull NSTextElementProvider.Block_enumerateTextElementsFromLocationOptionsUsingBlock block)Enumerates the text elements starting at textLocation.default @Nullable NSTextLocationlocationFromLocationWithOffset(@NotNull NSTextLocation location, long offset)Returns a new location from location with offset.default longoffsetFromLocationToLocation(@NotNull NSTextLocation from, @NotNull NSTextLocation to)Returns the offset between from and to.voidreplaceContentsInRangeWithTextElements(@NotNull NSTextRange range, @Nullable NSArray<? extends NSTextElement> textElements)Replaces the characters specified by range with textElements.voidsynchronizeToBackingStore(@Nullable NSTextElementProvider.Block_synchronizeToBackingStore completionHandler)Synchronizes changes to the backing store.
-
-
-
Method Detail
-
adjustedRangeFromRangeForEditingTextSelection
@Nullable default @Nullable NSTextRange adjustedRangeFromRangeForEditingTextSelection(@NotNull @NotNull NSTextRange textRange, boolean forEditingTextSelection)
Should be implemented if the location backing store requires manual adjustment after editing. When textRange is intersecting or following the current edited range, the method returns the range adjusted for the modification in the editing session. Returns nil, when no adjustment necessary. forEditingTextSelection indicates if textRange is for the text selection associated with the edit session.
-
documentRange
@NotNull @NotNull NSTextRange documentRange()
Declares the starting and ending locations for the document. The subclass could use its own implementation of a location object conforming to NSTextRange.
-
enumerateTextElementsFromLocationOptionsUsingBlock
@Nullable @Nullable NSTextLocation enumerateTextElementsFromLocationOptionsUsingBlock(@Nullable @Nullable NSTextLocation textLocation, long options, @NotNull @NotNull NSTextElementProvider.Block_enumerateTextElementsFromLocationOptionsUsingBlock block)
Enumerates the text elements starting at textLocation. If textLocation=nil, it assumes self.documentRange.location for forward enumeration; uses self.documentRange.endLocation for reverse enumeration. When enumerating backward, it starts with the element preceding the one containing textLocation. If enumerated at least one element, it returns the edge of the enumerated range. Note that the enumerated range might not match the range of the last element returned. It enumerates the elements in the sequence, but it can skip a range (it can limit the maximum number of text elements enumerated for a single invocation or hide some elements from the layout). Returning NO from block breaks out of the enumeration.
-
locationFromLocationWithOffset
@Nullable default @Nullable NSTextLocation locationFromLocationWithOffset(@NotNull @NotNull NSTextLocation location, long offset)
Returns a new location from location with offset. The offset value could be positive or negative indicating the logical direction. Could return nil when the inputs don't produce any legal location (i.e. out of bounds index).
-
offsetFromLocationToLocation
default long offsetFromLocationToLocation(@NotNull @NotNull NSTextLocation from, @NotNull @NotNull NSTextLocation to)Returns the offset between from and to. The return value could be positive or negative. Could return NSNotFound when the offset cannot be represented in an integer value (i.e. locations are not in the same document).
-
replaceContentsInRangeWithTextElements
void replaceContentsInRangeWithTextElements(@NotNull @NotNull NSTextRange range, @Nullable @Nullable NSArray<? extends NSTextElement> textElements)Replaces the characters specified by range with textElements. If the edges of range is not at existing element range boundaries, it either split the element if it allows the operation (i.e. NSTextParagraph) or adjust the replacement range. This method is intended to be used only by NSTextLayoutManager.
-
synchronizeToBackingStore
void synchronizeToBackingStore(@Nullable @Nullable NSTextElementProvider.Block_synchronizeToBackingStore completionHandler)Synchronizes changes to the backing store. If completionHandler=nil, performs the operation synchronously. completionHandler gets passed error if failed. It should block (or fail if synchronous) when there is an active transaction.
-
-