@apollohg/react-native-rich-text-editor 2.0.2 → 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.
Files changed (43) hide show
  1. package/README.md +21 -7
  2. package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +20 -6
  3. package/android/src/main/java/com/apollohg/editor/EditorEditTextClipboard.kt +181 -36
  4. package/android/src/main/java/com/apollohg/editor/EditorEditTextSelection.kt +7 -0
  5. package/android/src/main/java/com/apollohg/editor/EditorTextSurfaceInteraction.kt +31 -11
  6. package/android/src/main/java/com/apollohg/editor/EditorV2Adapter.kt +36 -0
  7. package/android/src/main/java/com/apollohg/editor/EditorV2Backend.kt +1 -0
  8. package/android/src/main/java/com/apollohg/editor/EditorV2Driver.kt +10 -0
  9. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +2 -0
  10. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoViewProperties.kt +4 -0
  11. package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +3 -0
  12. package/android/src/main/java/com/apollohg/editor/UniffiEditorV2Backend.kt +4 -0
  13. package/dist/NativeRichTextEditor.d.ts +1 -1
  14. package/dist/RichTextEditorNativeTypes.d.ts +2 -1
  15. package/dist/RichTextEditorTypes.d.ts +4 -0
  16. package/dist/index.d.ts +1 -1
  17. package/dist/useRichTextEditorPresentation.d.ts +1 -1
  18. package/dist/useRichTextEditorPresentation.js +2 -2
  19. package/dist/useRichTextEditorState.d.ts +5 -3
  20. package/dist/useRichTextEditorState.js +4 -3
  21. package/ios/EditorCore.xcframework/Info.plist +5 -5
  22. package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
  23. package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
  24. package/ios/EditorTextView+KeyboardInput.swift +299 -0
  25. package/ios/EditorTextView.swift +63 -43
  26. package/ios/EditorV2Adapter+Commands.swift +22 -0
  27. package/ios/EditorV2Shadow.swift +12 -0
  28. package/ios/Generated_editor_core.swift +10 -0
  29. package/ios/NativeEditorExpoView+Properties.swift +4 -0
  30. package/ios/NativeEditorModule.swift +3 -0
  31. package/ios/editor_coreFFI/editor_coreFFI.h +11 -0
  32. package/package.json +1 -1
  33. package/rust/android/arm64-v8a/libeditor_core.so +0 -0
  34. package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
  35. package/rust/android/x86/libeditor_core.so +0 -0
  36. package/rust/android/x86_64/libeditor_core.so +0 -0
  37. package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +18 -0
  38. package/src/NativeRichTextEditor.tsx +1 -0
  39. package/src/RichTextEditorNativeTypes.tsx +2 -0
  40. package/src/RichTextEditorTypes.tsx +5 -0
  41. package/src/index.ts +1 -0
  42. package/src/useRichTextEditorPresentation.tsx +3 -0
  43. package/src/useRichTextEditorState.tsx +5 -2
@@ -2077,6 +2077,13 @@ public func editorV2DocToScalar(editorId: String, docPos: UInt32) -> FfiJsonResu
2077
2077
  )
2078
2078
  })
2079
2079
  }
2080
+ public func editorV2GetClipboard(editorId: String) -> FfiJsonResult {
2081
+ return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2082
+ uniffi_editor_core_fn_func_editor_v2_get_clipboard(
2083
+ FfiConverterString.lower(editorId),$0
2084
+ )
2085
+ })
2086
+ }
2080
2087
  public func editorV2GetContentSnapshot(editorId: String) -> FfiJsonResult {
2081
2088
  return try! FfiConverterTypeFfiJsonResult_lift(try! rustCall() {
2082
2089
  uniffi_editor_core_fn_func_editor_v2_get_content_snapshot(
@@ -2289,6 +2296,9 @@ private let initializationResult: InitializationResult = {
2289
2296
  if (uniffi_editor_core_checksum_func_editor_v2_doc_to_scalar() != 62503) {
2290
2297
  return InitializationResult.apiChecksumMismatch
2291
2298
  }
2299
+ if (uniffi_editor_core_checksum_func_editor_v2_get_clipboard() != 3214) {
2300
+ return InitializationResult.apiChecksumMismatch
2301
+ }
2292
2302
  if (uniffi_editor_core_checksum_func_editor_v2_get_content_snapshot() != 21323) {
2293
2303
  return InitializationResult.apiChecksumMismatch
2294
2304
  }
@@ -104,6 +104,10 @@ extension NativeEditorExpoView {
104
104
  updateAccessoryToolbarVisibility()
105
105
  }
106
106
 
107
+ func setPasteMode(_ pasteMode: String) {
108
+ richTextView.textView.pasteMode = EditorPasteMode(rawValue: pasteMode) ?? .rich
109
+ }
110
+
107
111
  func setAccessibilityLabel(_ label: String?) {
108
112
  richTextView.textView.accessibilityLabel = label
109
113
  }
@@ -753,6 +753,9 @@ public class NativeEditorModule: BaseModule, @preconcurrency AnyModule {
753
753
  Prop("editable") { (view: NativeEditorExpoView, editable: Bool) in
754
754
  view.setEditable(editable)
755
755
  }
756
+ Prop("pasteMode") { (view: NativeEditorExpoView, pasteMode: String) in
757
+ view.setPasteMode(pasteMode)
758
+ }
756
759
  Prop("accessibilityLabel") { (view: NativeEditorExpoView, label: String?) in
757
760
  view.setAccessibilityLabel(label)
758
761
  }
@@ -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.2",
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
@@ -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 ->
@@ -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,