@apollohg/react-native-rich-text-editor 2.0.1 → 2.0.2

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 (31) hide show
  1. package/README.md +8 -116
  2. package/android/src/main/java/com/apollohg/editor/EditorEditTextImages.kt +25 -0
  3. package/android/src/main/java/com/apollohg/editor/EditorV2RenderValidation.kt +1 -0
  4. package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +101 -33
  5. package/android/src/main/java/com/apollohg/editor/RenderMediaSpans.kt +15 -3
  6. package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +14 -0
  7. package/android/src/main/java/com/apollohg/editor/viewer/AndroidProseLayoutEngine.kt +1 -1
  8. package/dist/EditorStyleSheetNormalization.js +1 -1
  9. package/dist/EditorStyleSheetTypes.d.ts +1 -1
  10. package/ios/EditorCore.xcframework/Info.plist +5 -5
  11. package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
  12. package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
  13. package/ios/EditorInteractionOverlays.swift +114 -122
  14. package/ios/EditorLayoutManager.swift +13 -3
  15. package/ios/EditorStyleSheet.swift +12 -1
  16. package/ios/EditorTextView+Images.swift +32 -10
  17. package/ios/EditorTextView.swift +1 -1
  18. package/ios/EditorV2Adapter+RenderValidation.swift +2 -2
  19. package/ios/NativeToolbar+ButtonStyle.swift +17 -5
  20. package/ios/NativeToolbar+Diagnostics.swift +15 -0
  21. package/ios/RenderBridge+Atoms.swift +0 -1
  22. package/ios/RenderBridge+Attachments.swift +0 -29
  23. package/ios/RichTextEditorView.swift +4 -12
  24. package/ios/Viewer/CoreTextProseLayoutEngine+AttributedText.swift +3 -2
  25. package/package.json +1 -1
  26. package/rust/android/arm64-v8a/libeditor_core.so +0 -0
  27. package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
  28. package/rust/android/x86/libeditor_core.so +0 -0
  29. package/rust/android/x86_64/libeditor_core.so +0 -0
  30. package/src/EditorStyleSheetNormalization.ts +1 -1
  31. package/src/EditorStyleSheetTypes.ts +1 -1
@@ -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, labelWidth + appearance.padding.left + appearance.padding.right),
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: UIEdgeInsets(top: 4, left: 6, bottom: 4, right: 6).adding(box.inset))
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollohg/react-native-rich-text-editor",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
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
@@ -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;