@openeditor/react-native-prose-editor 0.0.13 → 0.0.15

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.
@@ -776,36 +776,31 @@ class NativeBlockEditorSurface(context: Context) : ScrollView(context) {
776
776
 
777
777
  private fun calloutView(node: JSONObject, depth: Int, path: List<Int>): View {
778
778
  val density = resources.displayMetrics.density
779
- val tone = node.optJSONObject("attrs")?.optString("tone", "info") ?: "info"
780
- val accent = when (tone) {
781
- "success" -> 0xFF16A34A.toInt()
782
- "warning" -> 0xFFD97706.toInt()
783
- "danger" -> 0xFFDC2626.toInt()
784
- else -> 0xFF2563EB.toInt()
785
- }
786
779
  val container = LinearLayout(context).apply {
787
- orientation = LinearLayout.VERTICAL
780
+ orientation = LinearLayout.HORIZONTAL
781
+ gravity = android.view.Gravity.TOP
788
782
  val padding = (12 * density).toInt()
789
783
  setPadding(padding, padding, padding, padding)
790
784
  background = roundedDrawable(
791
- Color.argb(24, Color.red(accent), Color.green(accent), Color.blue(accent)),
792
- Color.argb(140, Color.red(accent), Color.green(accent), Color.blue(accent)),
793
- 1f,
785
+ currentTheme?.codeBlock?.backgroundColor ?: 0xFFF5F5F5.toInt(),
786
+ Color.TRANSPARENT,
787
+ 0f,
794
788
  10f
795
789
  )
796
790
  }
797
791
  container.addView(TextView(context).apply {
798
- text = tone.replaceFirstChar { it.uppercase() }
799
- setTextColor(accent)
800
- setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
801
- setTypeface(typeface, Typeface.BOLD)
802
- isClickable = this@NativeBlockEditorSurface.isEditable
803
- setOnClickListener { cycleCalloutTone(node) }
792
+ text = node.optJSONObject("attrs")?.optString("emoji", "💡") ?: "💡"
793
+ setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f)
804
794
  })
795
+ val content = LinearLayout(context).apply {
796
+ orientation = LinearLayout.VERTICAL
797
+ setPadding((10 * density).toInt(), 0, 0, 0)
798
+ }
805
799
  val children = node.optJSONArray("children")
806
800
  for (index in 0 until (children?.length() ?: 0)) {
807
- children?.optJSONObject(index)?.let { container.addView(viewForNode(it, depth + 1, path + index)) }
801
+ children?.optJSONObject(index)?.let { content.addView(viewForNode(it, depth + 1, path + index)) }
808
802
  }
803
+ container.addView(content, LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f))
809
804
  return container
810
805
  }
811
806
 
@@ -833,14 +828,6 @@ class NativeBlockEditorSurface(context: Context) : ScrollView(context) {
833
828
  }
834
829
  }
835
830
 
836
- private fun cycleCalloutTone(node: JSONObject) {
837
- if (!isEditable) return
838
- val tones = listOf("info", "success", "warning", "danger")
839
- val current = node.optJSONObject("attrs")?.optString("tone", "info") ?: "info"
840
- val next = tones[(tones.indexOf(current).coerceAtLeast(0) + 1) % tones.size]
841
- updateNodeAttrs(node, JSONObject().put("tone", next))
842
- }
843
-
844
831
  private fun updateNodeAttrs(node: JSONObject, patch: JSONObject) {
845
832
  if (currentEditorId == 0L) return
846
833
  val attrs = JSONObject(node.optJSONObject("attrs")?.toString() ?: "{}")
@@ -864,37 +864,27 @@ final class NativeBlockEditorSurface: UIScrollView, UITextViewDelegate, UIGestur
864
864
  }
865
865
 
866
866
  private func calloutView(for node: [String: Any], depth: Int, path: [Int]) -> UIView {
867
- let tone = stringAttr(node, "tone") ?? "info"
868
- let accent: UIColor = switch tone {
869
- case "success": .systemGreen
870
- case "warning": .systemOrange
871
- case "danger": .systemRed
872
- default: .systemBlue
873
- }
874
867
  let container = UIStackView()
875
- container.axis = .vertical
876
- container.spacing = 8
868
+ container.axis = .horizontal
869
+ container.alignment = .top
870
+ container.spacing = 10
877
871
  container.layoutMargins = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
878
872
  container.isLayoutMarginsRelativeArrangement = true
879
- container.backgroundColor = accent.withAlphaComponent(0.1)
880
- container.layer.borderColor = accent.withAlphaComponent(0.55).cgColor
881
- container.layer.borderWidth = 1
873
+ container.backgroundColor = UIColor.secondarySystemBackground
882
874
  container.layer.cornerRadius = 10
883
875
 
884
- let toneButton = UIButton(type: .system)
885
- toneButton.setTitle(tone.capitalized, for: .normal)
886
- toneButton.setTitleColor(accent, for: .normal)
887
- toneButton.titleLabel?.font = .systemFont(ofSize: 12, weight: .semibold)
888
- toneButton.contentHorizontalAlignment = .leading
889
- toneButton.isEnabled = isEditable
890
- toneButton.addAction(UIAction { [weak self] _ in
891
- self?.cycleCalloutTone(node)
892
- }, for: .touchUpInside)
893
- container.addArrangedSubview(toneButton)
876
+ let emoji = UILabel()
877
+ emoji.text = stringAttr(node, "emoji") ?? "💡"
878
+ emoji.font = .systemFont(ofSize: 20)
879
+ container.addArrangedSubview(emoji)
894
880
 
881
+ let content = UIStackView()
882
+ content.axis = .vertical
883
+ content.spacing = 4
895
884
  for (index, child) in (node["children"] as? [[String: Any]] ?? []).enumerated() {
896
- container.addArrangedSubview(view(for: child, depth: depth + 1, path: path + [index]))
885
+ content.addArrangedSubview(view(for: child, depth: depth + 1, path: path + [index]))
897
886
  }
887
+ container.addArrangedSubview(content)
898
888
  return container
899
889
  }
900
890
 
@@ -932,14 +922,6 @@ final class NativeBlockEditorSurface: UIScrollView, UITextViewDelegate, UIGestur
932
922
  }
933
923
  }
934
924
 
935
- private func cycleCalloutTone(_ node: [String: Any]) {
936
- guard isEditable else { return }
937
- let tones = ["info", "success", "warning", "danger"]
938
- let current = stringAttr(node, "tone") ?? "info"
939
- let next = tones[((tones.firstIndex(of: current) ?? 0) + 1) % tones.count]
940
- updateNodeAttrs(node, patch: ["tone": next])
941
- }
942
-
943
925
  private func updateNodeAttrs(_ node: [String: Any], patch: [String: Any]) {
944
926
  guard currentEditorId != 0 else { return }
945
927
  var attrs = node["attrs"] as? [String: Any] ?? [:]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openeditor/react-native-prose-editor",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
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",