@openeditor/react-native-prose-editor 0.0.9 → 0.0.10
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/README.md +5 -9
- package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +23 -0
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +2 -2
- package/android/src/main/java/com/apollohg/editor/NativeBlockEditorSurface.kt +381 -49
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +110 -169
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +1 -1
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +124 -337
- package/dist/EditorTheme.d.ts +8 -0
- package/ios/NativeBlockEditorSurface.swift +268 -58
- package/ios/NativeEditorExpoView.swift +114 -117
- package/ios/NativeInputSupport.swift +0 -302
- package/ios/PositionBridge.swift +22 -548
- package/ios/RichTextEditorView.swift +217 -4671
- package/package.json +1 -1
- package/android/src/main/java/com/apollohg/editor/CaretGeometry.kt +0 -50
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +0 -4068
- package/android/src/main/java/com/apollohg/editor/EditorInputConnection.kt +0 -1009
- package/android/src/main/java/com/apollohg/editor/InputSnapshotSupport.kt +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openeditor/react-native-prose-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "OpenEditor-owned native rich text editor engine for React Native",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/EasyLink-HQ/openeditor",
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
package com.openeditor.editor
|
|
2
|
-
|
|
3
|
-
import android.graphics.Paint
|
|
4
|
-
import android.text.Layout
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Vertical geometry for the text caret, clipped to the rendered glyph height.
|
|
8
|
-
*
|
|
9
|
-
* Android's [android.widget.Editor] draws the native caret from
|
|
10
|
-
* `Layout.getLineTop(line)` to `Layout.getLineBottom(line)`. When a
|
|
11
|
-
* line-height span inflates a line's descent, `getLineBottom` includes that
|
|
12
|
-
* extra space and the caret stretches into it.
|
|
13
|
-
* `getLineBottomWithoutSpacing` cannot help: the inflation lives in the line's
|
|
14
|
-
* DESCENT column, not the line-spacing EXTRA column it subtracts.
|
|
15
|
-
*
|
|
16
|
-
* The baseline is provably independent of descent inflation
|
|
17
|
-
* (`getLineBaseline(line) == getLineTop(line) - ascent`), so anchoring the
|
|
18
|
-
* caret bottom at `baseline + raw font descent` clips it to the glyph height.
|
|
19
|
-
* This mirrors the trim already used for blockquote stripes
|
|
20
|
-
* ([BlockquoteSpan.resolvedStripeBottom]).
|
|
21
|
-
*/
|
|
22
|
-
object CaretGeometry {
|
|
23
|
-
data class VerticalBounds(val top: Float, val bottom: Float)
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Whether the manually-drawn caret should be visible. The native caret is
|
|
27
|
-
* suppressed, so this gates our replacement: only when the field is focused,
|
|
28
|
-
* its window is focused, and the selection is a collapsed insertion point
|
|
29
|
-
* (a range selection shows the selection highlight instead).
|
|
30
|
-
*/
|
|
31
|
-
fun shouldRender(
|
|
32
|
-
focused: Boolean,
|
|
33
|
-
windowFocused: Boolean,
|
|
34
|
-
selectionStart: Int,
|
|
35
|
-
selectionEnd: Int
|
|
36
|
-
): Boolean = focused &&
|
|
37
|
-
windowFocused &&
|
|
38
|
-
selectionStart >= 0 &&
|
|
39
|
-
selectionStart == selectionEnd
|
|
40
|
-
|
|
41
|
-
fun verticalBounds(layout: Layout, offset: Int, paint: Paint): VerticalBounds {
|
|
42
|
-
val line = layout.getLineForOffset(offset.coerceIn(0, layout.text.length))
|
|
43
|
-
val top = layout.getLineTop(line).toFloat()
|
|
44
|
-
// Anchor the bottom at the glyph descent below the baseline. The baseline
|
|
45
|
-
// is independent of any ReplacementSpan descent inflation, so this clips
|
|
46
|
-
// the caret to the rendered text height instead of the inflated line bottom.
|
|
47
|
-
val bottom = layout.getLineBaseline(line) + paint.fontMetrics.descent
|
|
48
|
-
return VerticalBounds(top, bottom)
|
|
49
|
-
}
|
|
50
|
-
}
|