@apollohg/react-native-rich-text-editor 2.0.1 → 2.0.3
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 +29 -123
- package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +20 -6
- package/android/src/main/java/com/apollohg/editor/EditorEditTextClipboard.kt +181 -36
- package/android/src/main/java/com/apollohg/editor/EditorEditTextImages.kt +25 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextSelection.kt +7 -0
- package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceInteraction.kt +31 -11
- package/android/src/main/java/com/apollohg/editor/EditorV2Adapter.kt +36 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Backend.kt +1 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2Driver.kt +10 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2RenderValidation.kt +1 -0
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +101 -33
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +2 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewProperties.kt +4 -0
- package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +3 -0
- package/android/src/main/java/com/apollohg/editor/RenderMediaSpans.kt +15 -3
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +14 -0
- package/android/src/main/java/com/apollohg/editor/UniffiEditorV2Backend.kt +4 -0
- package/android/src/main/java/com/apollohg/editor/viewer/AndroidProseLayoutEngine.kt +1 -1
- package/dist/EditorStyleSheetNormalization.js +1 -1
- package/dist/EditorStyleSheetTypes.d.ts +1 -1
- package/dist/NativeRichTextEditor.d.ts +1 -1
- package/dist/RichTextEditorNativeTypes.d.ts +2 -1
- package/dist/RichTextEditorTypes.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/useRichTextEditorPresentation.d.ts +1 -1
- package/dist/useRichTextEditorPresentation.js +2 -2
- package/dist/useRichTextEditorState.d.ts +5 -3
- package/dist/useRichTextEditorState.js +4 -3
- 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/EditorInteractionOverlays.swift +114 -122
- package/ios/EditorLayoutManager.swift +13 -3
- package/ios/EditorStyleSheet.swift +12 -1
- package/ios/EditorTextView+Images.swift +32 -10
- package/ios/EditorTextView+KeyboardInput.swift +299 -0
- package/ios/EditorTextView.swift +64 -44
- package/ios/EditorV2Adapter+Commands.swift +22 -0
- package/ios/EditorV2Adapter+RenderValidation.swift +2 -2
- package/ios/EditorV2Shadow.swift +12 -0
- package/ios/Generated_editor_core.swift +10 -0
- package/ios/NativeEditorExpoView+Properties.swift +4 -0
- package/ios/NativeEditorModule.swift +3 -0
- package/ios/NativeToolbar+ButtonStyle.swift +17 -5
- package/ios/NativeToolbar+Diagnostics.swift +15 -0
- package/ios/RenderBridge+Atoms.swift +0 -1
- package/ios/RenderBridge+Attachments.swift +0 -29
- package/ios/RichTextEditorView.swift +4 -12
- package/ios/Viewer/CoreTextProseLayoutEngine+AttributedText.swift +3 -2
- package/ios/editor_coreFFI/editor_coreFFI.h +11 -0
- package/package.json +1 -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/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
- package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +18 -0
- package/src/EditorStyleSheetNormalization.ts +1 -1
- package/src/EditorStyleSheetTypes.ts +1 -1
- package/src/NativeRichTextEditor.tsx +1 -0
- package/src/RichTextEditorNativeTypes.tsx +2 -0
- package/src/RichTextEditorTypes.tsx +5 -0
- package/src/index.ts +1 -0
- package/src/useRichTextEditorPresentation.tsx +3 -0
- package/src/useRichTextEditorState.tsx +5 -2
|
@@ -101,7 +101,6 @@ final class AtomBlockAttachment: NSTextAttachment {
|
|
|
101
101
|
final class BlockImageAttachment: NSTextAttachment {
|
|
102
102
|
var styleBox: EditorStyleBox?
|
|
103
103
|
let source: String
|
|
104
|
-
let placeholderTint: UIColor
|
|
105
104
|
private weak var loadOwner: RenderImageLoadOwner?
|
|
106
105
|
private var loadReceipt: RenderImageLoadOwner.ImageLoadReceipt?
|
|
107
106
|
var preferredWidth: CGFloat?
|
|
@@ -110,12 +109,10 @@ final class BlockImageAttachment: NSTextAttachment {
|
|
|
110
109
|
|
|
111
110
|
init(
|
|
112
111
|
source: String,
|
|
113
|
-
placeholderTint: UIColor,
|
|
114
112
|
preferredWidth: CGFloat?,
|
|
115
113
|
preferredHeight: CGFloat?
|
|
116
114
|
) {
|
|
117
115
|
self.source = source
|
|
118
|
-
self.placeholderTint = placeholderTint
|
|
119
116
|
self.preferredWidth = preferredWidth
|
|
120
117
|
self.preferredHeight = preferredHeight
|
|
121
118
|
self.loadOwner = RenderImageLoadOwner.current
|
|
@@ -131,15 +128,6 @@ final class BlockImageAttachment: NSTextAttachment {
|
|
|
131
128
|
loadReceipt?.cancel()
|
|
132
129
|
}
|
|
133
130
|
|
|
134
|
-
func setPreferredSize(width: CGFloat, height: CGFloat) {
|
|
135
|
-
preferredWidth = width
|
|
136
|
-
preferredHeight = height
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
func previewImage() -> UIImage? {
|
|
140
|
-
loadedImage ?? image
|
|
141
|
-
}
|
|
142
|
-
|
|
143
131
|
override func attachmentBounds(
|
|
144
132
|
for textContainer: NSTextContainer?,
|
|
145
133
|
proposedLineFragment lineFrag: CGRect,
|
|
@@ -193,9 +181,6 @@ final class BlockImageAttachment: NSTextAttachment {
|
|
|
193
181
|
renderer.cgContext.clip(to: imageBounds.inset(by: styleBox.inset))
|
|
194
182
|
if let loadedImage {
|
|
195
183
|
loadedImage.draw(in: styleBox.imageRect(loadedImage.size, in: imageBounds))
|
|
196
|
-
} else {
|
|
197
|
-
let iconBounds = imageBounds.insetBy(dx: imageBounds.width * 0.35, dy: imageBounds.height * 0.35)
|
|
198
|
-
UIImage(systemName: "photo")?.withTintColor(placeholderTint, renderingMode: .alwaysOriginal).draw(in: iconBounds)
|
|
199
184
|
}
|
|
200
185
|
}
|
|
201
186
|
}
|
|
@@ -206,20 +191,6 @@ final class BlockImageAttachment: NSTextAttachment {
|
|
|
206
191
|
let path = UIBezierPath(roundedRect: imageBounds, cornerRadius: 12)
|
|
207
192
|
UIColor.secondarySystemFill.setFill()
|
|
208
193
|
path.fill()
|
|
209
|
-
|
|
210
|
-
let iconSize = min(imageBounds.width, imageBounds.height) * 0.28
|
|
211
|
-
let iconOrigin = CGPoint(
|
|
212
|
-
x: imageBounds.midX - (iconSize / 2),
|
|
213
|
-
y: imageBounds.midY - (iconSize / 2)
|
|
214
|
-
)
|
|
215
|
-
let iconRect = CGRect(origin: iconOrigin, size: CGSize(width: iconSize, height: iconSize))
|
|
216
|
-
|
|
217
|
-
if #available(iOS 13.0, *) {
|
|
218
|
-
let config = UIImage.SymbolConfiguration(pointSize: iconSize, weight: .medium)
|
|
219
|
-
let icon = UIImage(systemName: "photo", withConfiguration: config)?
|
|
220
|
-
.withTintColor(placeholderTint.withAlphaComponent(0.7), renderingMode: .alwaysOriginal)
|
|
221
|
-
icon?.draw(in: iconRect)
|
|
222
|
-
}
|
|
223
194
|
}
|
|
224
195
|
}
|
|
225
196
|
|
|
@@ -684,10 +684,6 @@ final class RichTextEditorView: UIView {
|
|
|
684
684
|
imageTapOverlayView.handleTapForTesting(convert(point, to: imageTapOverlayView))
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
-
func imageResizePreviewHasImageForTesting() -> Bool {
|
|
688
|
-
imageResizeOverlayView.previewHasImageForTesting
|
|
689
|
-
}
|
|
690
|
-
|
|
691
687
|
func refreshSelectionVisualStateForTesting() {
|
|
692
688
|
textView.refreshSelectionVisualState()
|
|
693
689
|
}
|
|
@@ -708,6 +704,10 @@ final class RichTextEditorView: UIView {
|
|
|
708
704
|
imageResizeOverlayView.simulatePreviewResizeForTesting(width: width, height: height)
|
|
709
705
|
}
|
|
710
706
|
|
|
707
|
+
func previewImageResizeDragForTesting(corner: ImageResizeOverlayView.Corner, translation: CGPoint) {
|
|
708
|
+
imageResizeOverlayView.simulatePreviewDragForTesting(corner: corner, translation: translation)
|
|
709
|
+
}
|
|
710
|
+
|
|
711
711
|
func commitPreviewResizeForTesting() {
|
|
712
712
|
imageResizeOverlayView.commitPreviewResizeForTesting()
|
|
713
713
|
}
|
|
@@ -803,14 +803,6 @@ final class RichTextEditorView: UIView {
|
|
|
803
803
|
textView.setImageResizePreviewActive(active)
|
|
804
804
|
}
|
|
805
805
|
|
|
806
|
-
func imagePreviewForResize(docPos: UInt32) -> UIImage? {
|
|
807
|
-
textView.imagePreviewForDocPos(docPos)
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
func imageResizePreviewBackgroundColor() -> UIColor {
|
|
811
|
-
textView.backgroundColor ?? .systemBackground
|
|
812
|
-
}
|
|
813
|
-
|
|
814
806
|
func maximumImageWidthForResizeGesture() -> CGFloat {
|
|
815
807
|
textView.maximumRenderableImageWidth()
|
|
816
808
|
}
|
|
@@ -79,8 +79,9 @@ extension CoreTextProseLayoutEngine {
|
|
|
79
79
|
let labelWidth = CGFloat(CTLineGetTypographicBounds(labelLine, &labelAscent, &labelDescent, &labelLeading))
|
|
80
80
|
let requestedHeight = EditorTheme.cgFloat(appearance.attributes[editorInlineLineHeightAttribute]) ?? 0
|
|
81
81
|
let extra = max(0, requestedHeight - labelAscent - max(labelDescent, 2)) / 2
|
|
82
|
+
let paddedWidth = labelWidth + appearance.padding.left + appearance.padding.right
|
|
82
83
|
let metrics = PreparedAtomMetrics(
|
|
83
|
-
width: max(paint.font.lineHeight,
|
|
84
|
+
width: nodeType == "mention" ? paddedWidth : max(paint.font.lineHeight, paddedWidth),
|
|
84
85
|
ascent: labelAscent + extra + appearance.padding.top,
|
|
85
86
|
descent: max(labelDescent, 2) + extra + appearance.padding.bottom
|
|
86
87
|
)
|
|
@@ -388,7 +389,7 @@ extension CoreTextProseLayoutEngine {
|
|
|
388
389
|
var boxValues = values
|
|
389
390
|
boxValues["backgroundColor"] = values["backgroundColor"] ?? "#007aff1f"
|
|
390
391
|
let box = EditorStyleBox(boxValues)
|
|
391
|
-
return PreparedAtomAppearance(styleBox: box, attributes: coreTextAttributes(styled), background: box.color("backgroundColor") ?? .clear, borderColor: nil, borderWidth: 0, radius: 0, padding:
|
|
392
|
+
return PreparedAtomAppearance(styleBox: box, attributes: coreTextAttributes(styled), background: box.color("backgroundColor") ?? .clear, borderColor: nil, borderWidth: 0, radius: 0, padding: box.mentionInsets)
|
|
392
393
|
}
|
|
393
394
|
return PreparedAtomAppearance(
|
|
394
395
|
attributes: attributes,
|
|
@@ -392,6 +392,11 @@ RustBuffer uniffi_editor_core_fn_func_editor_v2_destroy(RustBuffer editor_id, Ru
|
|
|
392
392
|
RustBuffer uniffi_editor_core_fn_func_editor_v2_doc_to_scalar(RustBuffer editor_id, uint32_t doc_pos, RustCallStatus *_Nonnull out_status
|
|
393
393
|
);
|
|
394
394
|
#endif
|
|
395
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_FN_FUNC_EDITOR_V2_GET_CLIPBOARD
|
|
396
|
+
#define UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_FN_FUNC_EDITOR_V2_GET_CLIPBOARD
|
|
397
|
+
RustBuffer uniffi_editor_core_fn_func_editor_v2_get_clipboard(RustBuffer editor_id, RustCallStatus *_Nonnull out_status
|
|
398
|
+
);
|
|
399
|
+
#endif
|
|
395
400
|
#ifndef UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_FN_FUNC_EDITOR_V2_GET_CONTENT_SNAPSHOT
|
|
396
401
|
#define UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_FN_FUNC_EDITOR_V2_GET_CONTENT_SNAPSHOT
|
|
397
402
|
RustBuffer uniffi_editor_core_fn_func_editor_v2_get_content_snapshot(RustBuffer editor_id, RustCallStatus *_Nonnull out_status
|
|
@@ -875,6 +880,12 @@ uint16_t uniffi_editor_core_checksum_func_editor_v2_destroy(void
|
|
|
875
880
|
#define UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_CHECKSUM_FUNC_EDITOR_V2_DOC_TO_SCALAR
|
|
876
881
|
uint16_t uniffi_editor_core_checksum_func_editor_v2_doc_to_scalar(void
|
|
877
882
|
|
|
883
|
+
);
|
|
884
|
+
#endif
|
|
885
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_CHECKSUM_FUNC_EDITOR_V2_GET_CLIPBOARD
|
|
886
|
+
#define UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_CHECKSUM_FUNC_EDITOR_V2_GET_CLIPBOARD
|
|
887
|
+
uint16_t uniffi_editor_core_checksum_func_editor_v2_get_clipboard(void
|
|
888
|
+
|
|
878
889
|
);
|
|
879
890
|
#endif
|
|
880
891
|
#ifndef UNIFFI_FFIDEF_UNIFFI_EDITOR_CORE_CHECKSUM_FUNC_EDITOR_V2_GET_CONTENT_SNAPSHOT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollohg/react-native-rich-text-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Native rich text editor with Rust core for React Native",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/apollohg/react-native-rich-text-editor",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -797,6 +797,8 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {
|
|
|
797
797
|
|
|
798
798
|
|
|
799
799
|
|
|
800
|
+
|
|
801
|
+
|
|
800
802
|
|
|
801
803
|
|
|
802
804
|
|
|
@@ -855,6 +857,8 @@ fun uniffi_editor_core_checksum_func_editor_v2_destroy(
|
|
|
855
857
|
): Short
|
|
856
858
|
fun uniffi_editor_core_checksum_func_editor_v2_doc_to_scalar(
|
|
857
859
|
): Short
|
|
860
|
+
fun uniffi_editor_core_checksum_func_editor_v2_get_clipboard(
|
|
861
|
+
): Short
|
|
858
862
|
fun uniffi_editor_core_checksum_func_editor_v2_get_content_snapshot(
|
|
859
863
|
): Short
|
|
860
864
|
fun uniffi_editor_core_checksum_func_editor_v2_get_document_html(
|
|
@@ -1006,6 +1010,8 @@ fun uniffi_editor_core_fn_func_editor_v2_destroy(`editorId`: RustBuffer.ByValue,
|
|
|
1006
1010
|
): RustBuffer.ByValue
|
|
1007
1011
|
fun uniffi_editor_core_fn_func_editor_v2_doc_to_scalar(`editorId`: RustBuffer.ByValue,`docPos`: Int,uniffi_out_err: UniffiRustCallStatus,
|
|
1008
1012
|
): RustBuffer.ByValue
|
|
1013
|
+
fun uniffi_editor_core_fn_func_editor_v2_get_clipboard(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
1014
|
+
): RustBuffer.ByValue
|
|
1009
1015
|
fun uniffi_editor_core_fn_func_editor_v2_get_content_snapshot(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
1010
1016
|
): RustBuffer.ByValue
|
|
1011
1017
|
fun uniffi_editor_core_fn_func_editor_v2_get_document_html(`editorId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
|
|
@@ -1226,6 +1232,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
|
|
|
1226
1232
|
if (lib.uniffi_editor_core_checksum_func_editor_v2_doc_to_scalar() != 62503.toShort()) {
|
|
1227
1233
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1228
1234
|
}
|
|
1235
|
+
if (lib.uniffi_editor_core_checksum_func_editor_v2_get_clipboard() != 3214.toShort()) {
|
|
1236
|
+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1237
|
+
}
|
|
1229
1238
|
if (lib.uniffi_editor_core_checksum_func_editor_v2_get_content_snapshot() != 21323.toShort()) {
|
|
1230
1239
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
1231
1240
|
}
|
|
@@ -2992,6 +3001,15 @@ public object FfiConverterSequenceTypeFfiViewerElement: FfiConverterRustBuffer<L
|
|
|
2992
3001
|
)
|
|
2993
3002
|
}
|
|
2994
3003
|
|
|
3004
|
+
fun `editorV2GetClipboard`(`editorId`: kotlin.String): FfiJsonResult {
|
|
3005
|
+
return FfiConverterTypeFfiJsonResult.lift(
|
|
3006
|
+
uniffiRustCall() { _status ->
|
|
3007
|
+
UniffiLib.INSTANCE.uniffi_editor_core_fn_func_editor_v2_get_clipboard(
|
|
3008
|
+
FfiConverterString.lower(`editorId`),_status)
|
|
3009
|
+
}
|
|
3010
|
+
)
|
|
3011
|
+
}
|
|
3012
|
+
|
|
2995
3013
|
fun `editorV2GetContentSnapshot`(`editorId`: kotlin.String): FfiJsonResult {
|
|
2996
3014
|
return FfiConverterTypeFfiJsonResult.lift(
|
|
2997
3015
|
uniffiRustCall() { _status ->
|
|
@@ -70,7 +70,7 @@ const fields: Record<keyof EditorStyleMap, readonly string[]> = {
|
|
|
70
70
|
italic: inline,
|
|
71
71
|
underline: inline,
|
|
72
72
|
strike: inline,
|
|
73
|
-
mention: [ ...inline, ...border ],
|
|
73
|
+
mention: [ ...inline, ...border, ...spacing('padding') ],
|
|
74
74
|
placeholder: typography,
|
|
75
75
|
};
|
|
76
76
|
|
|
@@ -113,7 +113,7 @@ export interface EditorHorizontalRuleStyle extends EditorBorderStyle, EditorMarg
|
|
|
113
113
|
height?: number;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export interface EditorMentionStyle extends EditorInlineStyle, EditorBorderStyle {}
|
|
116
|
+
export interface EditorMentionStyle extends EditorInlineStyle, EditorBorderStyle, EditorPaddingStyle {}
|
|
117
117
|
|
|
118
118
|
export interface EditorStyleMap {
|
|
119
119
|
content: EditorSurfaceStyle;
|
|
@@ -2,6 +2,7 @@ export {
|
|
|
2
2
|
type RichTextEditorHeightBehavior,
|
|
3
3
|
type RichTextEditorToolbarPlacement,
|
|
4
4
|
type RichTextEditorValueJSONUpdateMode,
|
|
5
|
+
type RichTextEditorPasteMode,
|
|
5
6
|
type RichTextEditorAutoCapitalize,
|
|
6
7
|
type RichTextEditorKeyboardType,
|
|
7
8
|
type RichTextEditorAndroidInputOptions,
|
|
@@ -6,6 +6,7 @@ import { type ReactNode } from 'react';
|
|
|
6
6
|
import { type NativeSyntheticEvent, type StyleProp, type ViewStyle } from 'react-native';
|
|
7
7
|
import { type DocumentJSON, type NativeEditorDocumentHandle } from './NativeEditorBridge';
|
|
8
8
|
import {
|
|
9
|
+
type RichTextEditorPasteMode,
|
|
9
10
|
type RichTextEditorAutoCapitalize,
|
|
10
11
|
type RichTextEditorKeyboardType,
|
|
11
12
|
type RichTextEditorToolbarPlacement,
|
|
@@ -32,6 +33,7 @@ export interface NativeEditorViewProps {
|
|
|
32
33
|
editorId: string;
|
|
33
34
|
placeholder?: string;
|
|
34
35
|
editable: boolean;
|
|
36
|
+
pasteMode: RichTextEditorPasteMode;
|
|
35
37
|
autoFocus: boolean;
|
|
36
38
|
autoCapitalize?: RichTextEditorAutoCapitalize;
|
|
37
39
|
autoCorrect?: boolean;
|
|
@@ -37,6 +37,9 @@ export type RichTextEditorToolbarPlacement = 'keyboard' | 'inline';
|
|
|
37
37
|
*/
|
|
38
38
|
export type RichTextEditorValueJSONUpdateMode = 'replace' | 'reset';
|
|
39
39
|
|
|
40
|
+
/** Controls native clipboard paste. Plain text keeps destination typing marks. */
|
|
41
|
+
export type RichTextEditorPasteMode = 'rich' | 'plainText' | 'disabled';
|
|
42
|
+
|
|
40
43
|
/** Native keyboard auto-capitalization behavior. */
|
|
41
44
|
export type RichTextEditorAutoCapitalize = 'none' | 'sentences' | 'words' | 'characters';
|
|
42
45
|
|
|
@@ -137,6 +140,8 @@ export interface RichTextEditorProps {
|
|
|
137
140
|
placeholder?: string;
|
|
138
141
|
/** Whether the editor is editable. Defaults to true. When false, every mutation ref method rejects with MUTATION_REJECTED; selection and controlled content still flow. */
|
|
139
142
|
editable?: boolean;
|
|
143
|
+
/** Clipboard paste policy. Defaults to rich; updates apply immediately. */
|
|
144
|
+
pasteMode?: RichTextEditorPasteMode;
|
|
140
145
|
/** Whether to auto-focus on mount. */
|
|
141
146
|
autoFocus?: boolean;
|
|
142
147
|
/** Controls native keyboard auto-capitalization. Defaults to sentences. */
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
type RichTextEditorHeightBehavior,
|
|
7
7
|
type RichTextEditorToolbarPlacement,
|
|
8
8
|
type RichTextEditorValueJSONUpdateMode,
|
|
9
|
+
type RichTextEditorPasteMode,
|
|
9
10
|
type RichTextEditorAutoCapitalize,
|
|
10
11
|
type RichTextEditorKeyboardType,
|
|
11
12
|
type RichTextEditorAndroidInputOptions,
|
|
@@ -73,6 +73,7 @@ export function useRichTextEditorPresentation(
|
|
|
73
73
|
| 'accessibilityHint'
|
|
74
74
|
| 'placeholder'
|
|
75
75
|
| 'autoFocus'
|
|
76
|
+
| 'pasteMode'
|
|
76
77
|
| 'autoCapitalize'
|
|
77
78
|
| 'autoCorrect'
|
|
78
79
|
| 'keyboardType'
|
|
@@ -157,6 +158,7 @@ export function useRichTextEditorPresentation(
|
|
|
157
158
|
accessibilityHint,
|
|
158
159
|
placeholder,
|
|
159
160
|
autoFocus,
|
|
161
|
+
pasteMode,
|
|
160
162
|
autoCapitalize,
|
|
161
163
|
autoCorrect,
|
|
162
164
|
keyboardType,
|
|
@@ -492,6 +494,7 @@ export function useRichTextEditorPresentation(
|
|
|
492
494
|
placeholder={placeholder}
|
|
493
495
|
editable={editable}
|
|
494
496
|
autoFocus={autoFocus}
|
|
497
|
+
pasteMode={pasteMode}
|
|
495
498
|
autoCapitalize={autoCapitalize}
|
|
496
499
|
autoCorrect={autoCorrect}
|
|
497
500
|
keyboardType={keyboardType}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
1
2
|
import {
|
|
2
3
|
DEFAULT_EDITOR_TOOLBAR_ITEMS,
|
|
3
4
|
setActiveEditorToolbarFrameOwnerForEditor,
|
|
@@ -48,6 +49,7 @@ export function useRichTextEditorState(
|
|
|
48
49
|
valueJSONUpdateMode = 'replace',
|
|
49
50
|
placeholder,
|
|
50
51
|
editable = true,
|
|
52
|
+
pasteMode = 'rich',
|
|
51
53
|
autoFocus = false,
|
|
52
54
|
autoCapitalize,
|
|
53
55
|
autoCorrect,
|
|
@@ -636,8 +638,8 @@ export function useRichTextEditorState(
|
|
|
636
638
|
toolbarItems,
|
|
637
639
|
toolbarPlacement,
|
|
638
640
|
showToolbar,
|
|
639
|
-
containerStyle
|
|
640
|
-
style
|
|
641
|
+
containerStyle: containerStyle as StyleProp<ViewStyle>,
|
|
642
|
+
style: style as StyleProp<ViewStyle>,
|
|
641
643
|
autoGrowHeight,
|
|
642
644
|
pushedUpdate,
|
|
643
645
|
registeredToolbarFrames,
|
|
@@ -647,6 +649,7 @@ export function useRichTextEditorState(
|
|
|
647
649
|
accessibilityHint,
|
|
648
650
|
placeholder,
|
|
649
651
|
autoFocus,
|
|
652
|
+
pasteMode,
|
|
650
653
|
autoCapitalize,
|
|
651
654
|
autoCorrect,
|
|
652
655
|
keyboardType,
|