@apollohg/react-native-prose-editor 0.5.16 → 0.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +1396 -143
- package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +403 -59
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +1666 -79
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +209 -87
- package/android/src/main/java/com/apollohg/editor/PositionBridge.kt +27 -0
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +58 -9
- package/dist/NativeEditorBridge.d.ts +34 -1
- package/dist/NativeEditorBridge.js +243 -83
- package/dist/NativeRichTextEditor.js +998 -137
- package/dist/addons.d.ts +7 -0
- package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
- package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
- package/ios/NativeEditorExpoView.swift +830 -17
- package/ios/NativeEditorModule.swift +304 -108
- package/ios/PositionBridge.swift +24 -1
- package/ios/RichTextEditorView.swift +715 -89
- package/package.json +2 -1
- package/rust/android/arm64-v8a/libeditor_core.so +0 -0
- package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
package/ios/PositionBridge.swift
CHANGED
|
@@ -82,14 +82,37 @@ final class PositionBridge {
|
|
|
82
82
|
|
|
83
83
|
static func utf16OffsetToScalar(_ utf16Offset: Int, in textView: UITextView) -> UInt32 {
|
|
84
84
|
let text = textView.text ?? ""
|
|
85
|
-
let clampedOffset = min(max(utf16Offset, 0), (text as NSString).length)
|
|
86
85
|
let conversionTable = textViewConversionTable(for: textView)
|
|
86
|
+
guard !conversionTable.adjustedUtf16ToScalar.isEmpty else { return 0 }
|
|
87
|
+
let clampedOffset = min(
|
|
88
|
+
max(utf16Offset, 0),
|
|
89
|
+
min((text as NSString).length, conversionTable.adjustedUtf16ToScalar.count - 1)
|
|
90
|
+
)
|
|
87
91
|
return conversionTable.adjustedUtf16ToScalar[clampedOffset]
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
static func utf16OffsetToScalar(_ utf16Offset: Int, in attributedString: NSAttributedString) -> UInt32 {
|
|
95
|
+
let conversionTable = adjustedConversionTable(for: attributedString)
|
|
96
|
+
guard !conversionTable.isEmpty else { return 0 }
|
|
97
|
+
let clampedOffset = min(max(utf16Offset, 0), conversionTable.count - 1)
|
|
98
|
+
return conversionTable[clampedOffset]
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
static func scalarToUtf16Offset(_ scalar: UInt32, in textView: UITextView) -> Int {
|
|
91
102
|
let conversionTable = textViewConversionTable(for: textView)
|
|
92
103
|
let utf16ToScalar = conversionTable.adjustedUtf16ToScalar
|
|
104
|
+
return scalarToUtf16Offset(scalar, inAdjustedUtf16ToScalarTable: utf16ToScalar)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static func scalarToUtf16Offset(_ scalar: UInt32, in attributedString: NSAttributedString) -> Int {
|
|
108
|
+
let utf16ToScalar = adjustedConversionTable(for: attributedString)
|
|
109
|
+
return scalarToUtf16Offset(scalar, inAdjustedUtf16ToScalarTable: utf16ToScalar)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private static func scalarToUtf16Offset(
|
|
113
|
+
_ scalar: UInt32,
|
|
114
|
+
inAdjustedUtf16ToScalarTable utf16ToScalar: [UInt32]
|
|
115
|
+
) -> Int {
|
|
93
116
|
guard scalar > 0, !utf16ToScalar.isEmpty else {
|
|
94
117
|
return 0
|
|
95
118
|
}
|