@apollohg/react-native-prose-editor 0.1.1 → 0.3.0

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 (53) hide show
  1. package/README.md +12 -7
  2. package/android/build.gradle +7 -2
  3. package/android/src/main/java/com/apollohg/editor/EditorEditText.kt +289 -2
  4. package/android/src/main/java/com/apollohg/editor/EditorTheme.kt +51 -1
  5. package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +199 -0
  6. package/android/src/main/java/com/apollohg/editor/NativeEditorExpoView.kt +16 -3
  7. package/android/src/main/java/com/apollohg/editor/NativeEditorModule.kt +82 -1
  8. package/android/src/main/java/com/apollohg/editor/NativeToolbar.kt +403 -45
  9. package/android/src/main/java/com/apollohg/editor/RemoteSelectionOverlayView.kt +246 -0
  10. package/android/src/main/java/com/apollohg/editor/RenderBridge.kt +841 -155
  11. package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +125 -8
  12. package/{src/EditorTheme.ts → dist/EditorTheme.d.ts} +12 -52
  13. package/dist/EditorTheme.js +29 -0
  14. package/dist/EditorToolbar.d.ts +129 -0
  15. package/dist/EditorToolbar.js +394 -0
  16. package/dist/NativeEditorBridge.d.ts +242 -0
  17. package/dist/NativeEditorBridge.js +647 -0
  18. package/dist/NativeRichTextEditor.d.ts +142 -0
  19. package/dist/NativeRichTextEditor.js +649 -0
  20. package/dist/YjsCollaboration.d.ts +83 -0
  21. package/dist/YjsCollaboration.js +585 -0
  22. package/dist/addons.d.ts +70 -0
  23. package/dist/addons.js +77 -0
  24. package/dist/index.d.ts +8 -0
  25. package/dist/index.js +26 -0
  26. package/dist/schemas.d.ts +35 -0
  27. package/{src/schemas.ts → dist/schemas.js} +62 -27
  28. package/dist/useNativeEditor.d.ts +40 -0
  29. package/dist/useNativeEditor.js +117 -0
  30. package/ios/EditorAddons.swift +26 -3
  31. package/ios/EditorCore.xcframework/Info.plist +5 -5
  32. package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
  33. package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
  34. package/ios/EditorLayoutManager.swift +236 -0
  35. package/ios/EditorTheme.swift +51 -1
  36. package/ios/Generated_editor_core.swift +270 -2
  37. package/ios/NativeEditorExpoView.swift +612 -45
  38. package/ios/NativeEditorModule.swift +81 -0
  39. package/ios/PositionBridge.swift +22 -0
  40. package/ios/RenderBridge.swift +427 -39
  41. package/ios/RichTextEditorView.swift +1342 -18
  42. package/ios/editor_coreFFI/editor_coreFFI.h +209 -0
  43. package/package.json +80 -64
  44. package/rust/android/arm64-v8a/libeditor_core.so +0 -0
  45. package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
  46. package/rust/android/x86_64/libeditor_core.so +0 -0
  47. package/rust/bindings/kotlin/uniffi/editor_core/editor_core.kt +404 -4
  48. package/src/EditorToolbar.tsx +0 -620
  49. package/src/NativeEditorBridge.ts +0 -607
  50. package/src/NativeRichTextEditor.tsx +0 -951
  51. package/src/addons.ts +0 -158
  52. package/src/index.ts +0 -63
  53. package/src/useNativeEditor.ts +0 -173
@@ -493,6 +493,130 @@ fileprivate struct FfiConverterString: FfiConverter {
493
493
  writeBytes(&buf, value.utf8)
494
494
  }
495
495
  }
496
+ /**
497
+ * Apply a durable Yjs encoded state/update represented as a JSON byte array.
498
+ */
499
+ public func collaborationSessionApplyEncodedState(id: UInt64, encodedStateJson: String) -> String {
500
+ return try! FfiConverterString.lift(try! rustCall() {
501
+ uniffi_editor_core_fn_func_collaboration_session_apply_encoded_state(
502
+ FfiConverterUInt64.lower(id),
503
+ FfiConverterString.lower(encodedStateJson),$0
504
+ )
505
+ })
506
+ }
507
+ /**
508
+ * Apply a local ProseMirror JSON snapshot to the collaboration session.
509
+ */
510
+ public func collaborationSessionApplyLocalDocumentJson(id: UInt64, json: String) -> String {
511
+ return try! FfiConverterString.lift(try! rustCall() {
512
+ uniffi_editor_core_fn_func_collaboration_session_apply_local_document_json(
513
+ FfiConverterUInt64.lower(id),
514
+ FfiConverterString.lower(json),$0
515
+ )
516
+ })
517
+ }
518
+ /**
519
+ * Clear the local awareness payload for a collaboration session.
520
+ */
521
+ public func collaborationSessionClearLocalAwareness(id: UInt64) -> String {
522
+ return try! FfiConverterString.lift(try! rustCall() {
523
+ uniffi_editor_core_fn_func_collaboration_session_clear_local_awareness(
524
+ FfiConverterUInt64.lower(id),$0
525
+ )
526
+ })
527
+ }
528
+ /**
529
+ * Create a Yjs collaboration session backed by yrs.
530
+ */
531
+ public func collaborationSessionCreate(configJson: String) -> UInt64 {
532
+ return try! FfiConverterUInt64.lift(try! rustCall() {
533
+ uniffi_editor_core_fn_func_collaboration_session_create(
534
+ FfiConverterString.lower(configJson),$0
535
+ )
536
+ })
537
+ }
538
+ /**
539
+ * Destroy a collaboration session and free its resources.
540
+ */
541
+ public func collaborationSessionDestroy(id: UInt64) {try! rustCall() {
542
+ uniffi_editor_core_fn_func_collaboration_session_destroy(
543
+ FfiConverterUInt64.lower(id),$0
544
+ )
545
+ }
546
+ }
547
+ /**
548
+ * Return the current shared ProseMirror JSON document for a collaboration session.
549
+ */
550
+ public func collaborationSessionGetDocumentJson(id: UInt64) -> String {
551
+ return try! FfiConverterString.lift(try! rustCall() {
552
+ uniffi_editor_core_fn_func_collaboration_session_get_document_json(
553
+ FfiConverterUInt64.lower(id),$0
554
+ )
555
+ })
556
+ }
557
+ /**
558
+ * Return the current shared Yjs document state as a JSON byte array.
559
+ */
560
+ public func collaborationSessionGetEncodedState(id: UInt64) -> String {
561
+ return try! FfiConverterString.lift(try! rustCall() {
562
+ uniffi_editor_core_fn_func_collaboration_session_get_encoded_state(
563
+ FfiConverterUInt64.lower(id),$0
564
+ )
565
+ })
566
+ }
567
+ /**
568
+ * Return the current awareness peers for a collaboration session.
569
+ */
570
+ public func collaborationSessionGetPeersJson(id: UInt64) -> String {
571
+ return try! FfiConverterString.lift(try! rustCall() {
572
+ uniffi_editor_core_fn_func_collaboration_session_get_peers_json(
573
+ FfiConverterUInt64.lower(id),$0
574
+ )
575
+ })
576
+ }
577
+ /**
578
+ * Apply an incoming y-sync binary message encoded as a JSON byte array.
579
+ */
580
+ public func collaborationSessionHandleMessage(id: UInt64, messageJson: String) -> String {
581
+ return try! FfiConverterString.lift(try! rustCall() {
582
+ uniffi_editor_core_fn_func_collaboration_session_handle_message(
583
+ FfiConverterUInt64.lower(id),
584
+ FfiConverterString.lower(messageJson),$0
585
+ )
586
+ })
587
+ }
588
+ /**
589
+ * Replace the collaboration document with a durable Yjs encoded state/update.
590
+ */
591
+ public func collaborationSessionReplaceEncodedState(id: UInt64, encodedStateJson: String) -> String {
592
+ return try! FfiConverterString.lift(try! rustCall() {
593
+ uniffi_editor_core_fn_func_collaboration_session_replace_encoded_state(
594
+ FfiConverterUInt64.lower(id),
595
+ FfiConverterString.lower(encodedStateJson),$0
596
+ )
597
+ })
598
+ }
599
+ /**
600
+ * Update the local awareness payload for a collaboration session.
601
+ */
602
+ public func collaborationSessionSetLocalAwareness(id: UInt64, awarenessJson: String) -> String {
603
+ return try! FfiConverterString.lift(try! rustCall() {
604
+ uniffi_editor_core_fn_func_collaboration_session_set_local_awareness(
605
+ FfiConverterUInt64.lower(id),
606
+ FfiConverterString.lower(awarenessJson),$0
607
+ )
608
+ })
609
+ }
610
+ /**
611
+ * Start the sync handshake for a collaboration session.
612
+ */
613
+ public func collaborationSessionStart(id: UInt64) -> String {
614
+ return try! FfiConverterString.lift(try! rustCall() {
615
+ uniffi_editor_core_fn_func_collaboration_session_start(
616
+ FfiConverterUInt64.lower(id),$0
617
+ )
618
+ })
619
+ }
496
620
  /**
497
621
  * Check if redo is available.
498
622
  */
@@ -525,12 +649,14 @@ public func editorCoreVersion() -> String {
525
649
  /**
526
650
  * Create a new editor from a JSON config object.
527
651
  *
528
- * Config fields (all optional — empty object `{}` creates a default editor):
652
+ * Config fields (all optional):
529
653
  * - `"schema"`: custom schema definition (see `Schema::from_json`)
530
654
  * - `"maxLength"`: maximum document length in characters
531
655
  * - `"readOnly"`: if `true`, rejects non-API mutations
532
656
  * - `"inputFilter"`: regex pattern; only matching characters are inserted
657
+ * - `"allowBase64Images"`: if `true`, parses `<img src="data:image/...">` as image nodes
533
658
  *
659
+ * An empty object creates a default editor.
534
660
  * Falls back to the default Tiptap schema when `"schema"` is absent or invalid.
535
661
  */
536
662
  public func editorCreate(configJson: String) -> UInt64 {
@@ -821,6 +947,19 @@ public func editorReplaceTextScalar(id: UInt64, scalarFrom: UInt32, scalarTo: UI
821
947
  )
822
948
  })
823
949
  }
950
+ /**
951
+ * Resize an image node at a document position. Returns an update JSON string.
952
+ */
953
+ public func editorResizeImageAtDocPos(id: UInt64, docPos: UInt32, width: UInt32, height: UInt32) -> String {
954
+ return try! FfiConverterString.lift(try! rustCall() {
955
+ uniffi_editor_core_fn_func_editor_resize_image_at_doc_pos(
956
+ FfiConverterUInt64.lower(id),
957
+ FfiConverterUInt32.lower(docPos),
958
+ FfiConverterUInt32.lower(width),
959
+ FfiConverterUInt32.lower(height),$0
960
+ )
961
+ })
962
+ }
824
963
  /**
825
964
  * Convert a rendered-text scalar offset to a document position.
826
965
  */
@@ -854,6 +993,32 @@ public func editorSetJson(id: UInt64, json: String) -> String {
854
993
  )
855
994
  })
856
995
  }
996
+ /**
997
+ * Set a mark with attrs on the current selection. Returns an update JSON string.
998
+ */
999
+ public func editorSetMark(id: UInt64, markName: String, attrsJson: String) -> String {
1000
+ return try! FfiConverterString.lift(try! rustCall() {
1001
+ uniffi_editor_core_fn_func_editor_set_mark(
1002
+ FfiConverterUInt64.lower(id),
1003
+ FfiConverterString.lower(markName),
1004
+ FfiConverterString.lower(attrsJson),$0
1005
+ )
1006
+ })
1007
+ }
1008
+ /**
1009
+ * Set a mark with attrs at an explicit scalar selection. Returns an update JSON string.
1010
+ */
1011
+ public func editorSetMarkAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, markName: String, attrsJson: String) -> String {
1012
+ return try! FfiConverterString.lift(try! rustCall() {
1013
+ uniffi_editor_core_fn_func_editor_set_mark_at_selection_scalar(
1014
+ FfiConverterUInt64.lower(id),
1015
+ FfiConverterUInt32.lower(scalarAnchor),
1016
+ FfiConverterUInt32.lower(scalarHead),
1017
+ FfiConverterString.lower(markName),
1018
+ FfiConverterString.lower(attrsJson),$0
1019
+ )
1020
+ })
1021
+ }
857
1022
  /**
858
1023
  * Set the selection. Anchor and head are document positions.
859
1024
  */
@@ -898,6 +1063,28 @@ public func editorSplitBlockScalar(id: UInt64, scalarPos: UInt32) -> String {
898
1063
  )
899
1064
  })
900
1065
  }
1066
+ /**
1067
+ * Toggle a blockquote around the current block selection. Returns an update JSON string.
1068
+ */
1069
+ public func editorToggleBlockquote(id: UInt64) -> String {
1070
+ return try! FfiConverterString.lift(try! rustCall() {
1071
+ uniffi_editor_core_fn_func_editor_toggle_blockquote(
1072
+ FfiConverterUInt64.lower(id),$0
1073
+ )
1074
+ })
1075
+ }
1076
+ /**
1077
+ * Toggle a blockquote at an explicit scalar selection. Returns an update JSON string.
1078
+ */
1079
+ public func editorToggleBlockquoteAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32) -> String {
1080
+ return try! FfiConverterString.lift(try! rustCall() {
1081
+ uniffi_editor_core_fn_func_editor_toggle_blockquote_at_selection_scalar(
1082
+ FfiConverterUInt64.lower(id),
1083
+ FfiConverterUInt32.lower(scalarAnchor),
1084
+ FfiConverterUInt32.lower(scalarHead),$0
1085
+ )
1086
+ })
1087
+ }
901
1088
  /**
902
1089
  * Toggle a mark on the current selection. Returns an update JSON string.
903
1090
  */
@@ -932,6 +1119,30 @@ public func editorUndo(id: UInt64) -> String {
932
1119
  )
933
1120
  })
934
1121
  }
1122
+ /**
1123
+ * Remove a mark from the current selection. Returns an update JSON string.
1124
+ */
1125
+ public func editorUnsetMark(id: UInt64, markName: String) -> String {
1126
+ return try! FfiConverterString.lift(try! rustCall() {
1127
+ uniffi_editor_core_fn_func_editor_unset_mark(
1128
+ FfiConverterUInt64.lower(id),
1129
+ FfiConverterString.lower(markName),$0
1130
+ )
1131
+ })
1132
+ }
1133
+ /**
1134
+ * Remove a mark at an explicit scalar selection. Returns an update JSON string.
1135
+ */
1136
+ public func editorUnsetMarkAtSelectionScalar(id: UInt64, scalarAnchor: UInt32, scalarHead: UInt32, markName: String) -> String {
1137
+ return try! FfiConverterString.lift(try! rustCall() {
1138
+ uniffi_editor_core_fn_func_editor_unset_mark_at_selection_scalar(
1139
+ FfiConverterUInt64.lower(id),
1140
+ FfiConverterUInt32.lower(scalarAnchor),
1141
+ FfiConverterUInt32.lower(scalarHead),
1142
+ FfiConverterString.lower(markName),$0
1143
+ )
1144
+ })
1145
+ }
935
1146
  /**
936
1147
  * Unwrap the current list item back to a paragraph. Returns an update JSON string.
937
1148
  */
@@ -994,6 +1205,42 @@ private let initializationResult: InitializationResult = {
994
1205
  if bindings_contract_version != scaffolding_contract_version {
995
1206
  return InitializationResult.contractVersionMismatch
996
1207
  }
1208
+ if (uniffi_editor_core_checksum_func_collaboration_session_apply_encoded_state() != 4684) {
1209
+ return InitializationResult.apiChecksumMismatch
1210
+ }
1211
+ if (uniffi_editor_core_checksum_func_collaboration_session_apply_local_document_json() != 396) {
1212
+ return InitializationResult.apiChecksumMismatch
1213
+ }
1214
+ if (uniffi_editor_core_checksum_func_collaboration_session_clear_local_awareness() != 48044) {
1215
+ return InitializationResult.apiChecksumMismatch
1216
+ }
1217
+ if (uniffi_editor_core_checksum_func_collaboration_session_create() != 60237) {
1218
+ return InitializationResult.apiChecksumMismatch
1219
+ }
1220
+ if (uniffi_editor_core_checksum_func_collaboration_session_destroy() != 56261) {
1221
+ return InitializationResult.apiChecksumMismatch
1222
+ }
1223
+ if (uniffi_editor_core_checksum_func_collaboration_session_get_document_json() != 44139) {
1224
+ return InitializationResult.apiChecksumMismatch
1225
+ }
1226
+ if (uniffi_editor_core_checksum_func_collaboration_session_get_encoded_state() != 16895) {
1227
+ return InitializationResult.apiChecksumMismatch
1228
+ }
1229
+ if (uniffi_editor_core_checksum_func_collaboration_session_get_peers_json() != 46461) {
1230
+ return InitializationResult.apiChecksumMismatch
1231
+ }
1232
+ if (uniffi_editor_core_checksum_func_collaboration_session_handle_message() != 25528) {
1233
+ return InitializationResult.apiChecksumMismatch
1234
+ }
1235
+ if (uniffi_editor_core_checksum_func_collaboration_session_replace_encoded_state() != 53994) {
1236
+ return InitializationResult.apiChecksumMismatch
1237
+ }
1238
+ if (uniffi_editor_core_checksum_func_collaboration_session_set_local_awareness() != 63617) {
1239
+ return InitializationResult.apiChecksumMismatch
1240
+ }
1241
+ if (uniffi_editor_core_checksum_func_collaboration_session_start() != 54751) {
1242
+ return InitializationResult.apiChecksumMismatch
1243
+ }
997
1244
  if (uniffi_editor_core_checksum_func_editor_can_redo() != 15854) {
998
1245
  return InitializationResult.apiChecksumMismatch
999
1246
  }
@@ -1003,7 +1250,7 @@ private let initializationResult: InitializationResult = {
1003
1250
  if (uniffi_editor_core_checksum_func_editor_core_version() != 41638) {
1004
1251
  return InitializationResult.apiChecksumMismatch
1005
1252
  }
1006
- if (uniffi_editor_core_checksum_func_editor_create() != 23908) {
1253
+ if (uniffi_editor_core_checksum_func_editor_create() != 19812) {
1007
1254
  return InitializationResult.apiChecksumMismatch
1008
1255
  }
1009
1256
  if (uniffi_editor_core_checksum_func_editor_delete_and_split_scalar() != 13764) {
@@ -1081,6 +1328,9 @@ private let initializationResult: InitializationResult = {
1081
1328
  if (uniffi_editor_core_checksum_func_editor_replace_text_scalar() != 45475) {
1082
1329
  return InitializationResult.apiChecksumMismatch
1083
1330
  }
1331
+ if (uniffi_editor_core_checksum_func_editor_resize_image_at_doc_pos() != 36353) {
1332
+ return InitializationResult.apiChecksumMismatch
1333
+ }
1084
1334
  if (uniffi_editor_core_checksum_func_editor_scalar_to_doc() != 40126) {
1085
1335
  return InitializationResult.apiChecksumMismatch
1086
1336
  }
@@ -1090,6 +1340,12 @@ private let initializationResult: InitializationResult = {
1090
1340
  if (uniffi_editor_core_checksum_func_editor_set_json() != 18497) {
1091
1341
  return InitializationResult.apiChecksumMismatch
1092
1342
  }
1343
+ if (uniffi_editor_core_checksum_func_editor_set_mark() != 29349) {
1344
+ return InitializationResult.apiChecksumMismatch
1345
+ }
1346
+ if (uniffi_editor_core_checksum_func_editor_set_mark_at_selection_scalar() != 43994) {
1347
+ return InitializationResult.apiChecksumMismatch
1348
+ }
1093
1349
  if (uniffi_editor_core_checksum_func_editor_set_selection() != 28236) {
1094
1350
  return InitializationResult.apiChecksumMismatch
1095
1351
  }
@@ -1102,6 +1358,12 @@ private let initializationResult: InitializationResult = {
1102
1358
  if (uniffi_editor_core_checksum_func_editor_split_block_scalar() != 47554) {
1103
1359
  return InitializationResult.apiChecksumMismatch
1104
1360
  }
1361
+ if (uniffi_editor_core_checksum_func_editor_toggle_blockquote() != 25804) {
1362
+ return InitializationResult.apiChecksumMismatch
1363
+ }
1364
+ if (uniffi_editor_core_checksum_func_editor_toggle_blockquote_at_selection_scalar() != 58523) {
1365
+ return InitializationResult.apiChecksumMismatch
1366
+ }
1105
1367
  if (uniffi_editor_core_checksum_func_editor_toggle_mark() != 30661) {
1106
1368
  return InitializationResult.apiChecksumMismatch
1107
1369
  }
@@ -1111,6 +1373,12 @@ private let initializationResult: InitializationResult = {
1111
1373
  if (uniffi_editor_core_checksum_func_editor_undo() != 28689) {
1112
1374
  return InitializationResult.apiChecksumMismatch
1113
1375
  }
1376
+ if (uniffi_editor_core_checksum_func_editor_unset_mark() != 47985) {
1377
+ return InitializationResult.apiChecksumMismatch
1378
+ }
1379
+ if (uniffi_editor_core_checksum_func_editor_unset_mark_at_selection_scalar() != 54992) {
1380
+ return InitializationResult.apiChecksumMismatch
1381
+ }
1114
1382
  if (uniffi_editor_core_checksum_func_editor_unwrap_from_list() != 41875) {
1115
1383
  return InitializationResult.apiChecksumMismatch
1116
1384
  }