-
public class EditorIndexMapperThe indexes in the Editable text and ComposerModel may differ if we take into account ExtraCharacterSpan that are added for lists.
These spans are used to mark extra characters that are not present in the original HTML output, mainly extra line breaks between list items.
-
-
Field Summary
Fields Modifier and Type Field Description public final static EditorIndexMapperINSTANCE
-
Method Summary
Modifier and Type Method Description final Pair<Integer, Integer>fromComposerToEditor(Integer start, Integer end, Spanned editableText)Translates the start, end indexes that come from the ComposerModel into indexes that can be safely used in the editableText. final Pair<UInt, UInt>fromEditorToComposer(Integer start, Integer end, Spanned editableText)Translates the start, end indexes that come from the editableText into indexes that can be safely used in the ComposerModel. final IntegereditorIndexFromComposer(Integer composerIndex, Spanned editableText)Translates the composerIndex coming from the ComposerModel into one that can be safely used in the editableText. -
-
Method Detail
-
fromComposerToEditor
final Pair<Integer, Integer> fromComposerToEditor(Integer start, Integer end, Spanned editableText)
Translates the start, end indexes that come from the ComposerModel into indexes that can be safely used in the editableText.
For this, ExtraCharacterSpan spans are used: we look for them in the editableText, then sum their lengths and add this extra length to the start and end original indexes.
-
fromEditorToComposer
final Pair<UInt, UInt> fromEditorToComposer(Integer start, Integer end, Spanned editableText)
Translates the start, end indexes that come from the editableText into indexes that can be safely used in the ComposerModel.
For this, ExtraCharacterSpan spans are used: we look for them in the editableText, then sum their lengths and subtract these lengths to the start and end original indexes.
-
editorIndexFromComposer
final Integer editorIndexFromComposer(Integer composerIndex, Spanned editableText)
Translates the composerIndex coming from the ComposerModel into one that can be safely used in the editableText.
-
-
-
-