react-native-enriched-markdown-scaffold 1.2.0-scaffold.1 → 1.2.0-scaffold.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.
|
@@ -107,6 +107,10 @@ class EnrichedMarkdown(
|
|
|
107
107
|
private var linkLayoutEnabled = false
|
|
108
108
|
private var lastLinkLayout: List<LinkLayoutFragment>? = null
|
|
109
109
|
|
|
110
|
+
// False until the first background render has been applied. A freshly mounted view can be
|
|
111
|
+
// laid out before that, and its empty segment list would be reported as "no links".
|
|
112
|
+
private var hasRenderedContent = false
|
|
113
|
+
|
|
110
114
|
// At most one segment holds a selection; a new one clears the previous.
|
|
111
115
|
private var selectionOwner: EnrichedMarkdownInternalText? = null
|
|
112
116
|
|
|
@@ -621,6 +625,7 @@ class EnrichedMarkdown(
|
|
|
621
625
|
dirtyFlags.clear()
|
|
622
626
|
|
|
623
627
|
val topologyChanged = applySegments(renderedSegments, reset)
|
|
628
|
+
hasRenderedContent = true
|
|
624
629
|
|
|
625
630
|
if (selectionOwner?.let { owner -> segmentViews.none { it === owner } } == true) selectionOwner = null
|
|
626
631
|
if (activeBlock?.let { block -> segmentViews.none { it === block.view } } == true) activeBlock = null
|
|
@@ -860,9 +865,15 @@ class EnrichedMarkdown(
|
|
|
860
865
|
*
|
|
861
866
|
* P1 limitation: links inside a BlockquoteContainerView are neither reported nor counted,
|
|
862
867
|
* so linkIndex of later links is shifted. Fixed in P2 (A2) by walking containers recursively.
|
|
868
|
+
*
|
|
869
|
+
* Nothing is sent before the first render is applied. On mount, Fabric lays the view out
|
|
870
|
+
* before it attaches the event emitter, so an event sent from that first onLayout is queued
|
|
871
|
+
* through SurfaceMountingManager.enqueuePendingEvent (a main-thread post). If the render
|
|
872
|
+
* lands in between, its event is dispatched first and the queued empty one then replaces it
|
|
873
|
+
* in the coalescing EventQueue, leaving JS with no links (HWK-1674: concept brush missing).
|
|
863
874
|
*/
|
|
864
875
|
private fun emitLinkLayoutIfNeeded() {
|
|
865
|
-
if (!linkLayoutEnabled || width <= 0) return
|
|
876
|
+
if (!linkLayoutEnabled || !hasRenderedContent || width <= 0) return
|
|
866
877
|
val fragments = mutableListOf<LinkLayoutFragment>()
|
|
867
878
|
var linkCount = 0
|
|
868
879
|
segmentViews.forEach { view ->
|
|
@@ -146,6 +146,9 @@ class EnrichedMarkdownText
|
|
|
146
146
|
private var linkLayoutEnabled = false
|
|
147
147
|
private var lastLinkLayout: List<LinkLayoutFragment>? = null
|
|
148
148
|
|
|
149
|
+
// False until the first background render has been applied; see emitLinkLayoutIfNeeded.
|
|
150
|
+
private var hasRenderedContent = false
|
|
151
|
+
|
|
149
152
|
// Nullable and assigned in init: TextView calls onSelectionChanged from its
|
|
150
153
|
// own constructor, before this class's fields exist.
|
|
151
154
|
private var selectionReporter: SelectionChangeReporter? = null
|
|
@@ -346,6 +349,7 @@ class EnrichedMarkdownText
|
|
|
346
349
|
}
|
|
347
350
|
|
|
348
351
|
text = styledText
|
|
352
|
+
hasRenderedContent = true
|
|
349
353
|
|
|
350
354
|
applyInteractivity()
|
|
351
355
|
|
|
@@ -436,9 +440,16 @@ class EnrichedMarkdownText
|
|
|
436
440
|
/**
|
|
437
441
|
* Reports link rects to JS (for `renderLinkDecoration`) after every render and layout;
|
|
438
442
|
* deduplicated so an unchanged layout — the common case while streaming — sends nothing.
|
|
443
|
+
*
|
|
444
|
+
* Nothing is sent before the first render is applied: a TextView builds a layout for its
|
|
445
|
+
* empty initial text too, so `layout == null` alone does not catch it. On mount, Fabric lays
|
|
446
|
+
* the view out before it attaches the event emitter, so an event sent from that first
|
|
447
|
+
* onLayout is queued through a main-thread post. If the render lands in between, its event
|
|
448
|
+
* is dispatched first and the queued empty one then replaces it in the coalescing
|
|
449
|
+
* EventQueue, leaving JS with no links (HWK-1674).
|
|
439
450
|
*/
|
|
440
451
|
private fun emitLinkLayoutIfNeeded() {
|
|
441
|
-
if (!linkLayoutEnabled || layout == null || width <= 0) return
|
|
452
|
+
if (!linkLayoutEnabled || !hasRenderedContent || layout == null || width <= 0) return
|
|
442
453
|
val (fragments, _) = LinkLayoutCollector.collect(this)
|
|
443
454
|
if (fragments == lastLinkLayout) return
|
|
444
455
|
lastLinkLayout = fragments
|
package/package.json
CHANGED