Bluesky app fork with some witchin' additions 💫

strip property measured in codepoints

12Me21 6567e1d6 1a6997af

+11 -6
+2 -2
src/components/RichText.tsx
··· 61 62 for (const feature of markupFeatures) { 63 if (feature.strip?.length === 2) { 64 - stripStart += toStripValue(feature.strip[0]) 65 - stripEnd += toStripValue(feature.strip[1]) 66 } 67 if (feature.style === 'italic') hasItalic = true 68 if (feature.style === 'bold') hasBold = true
··· 61 62 for (const feature of markupFeatures) { 63 if (feature.strip?.length === 2) { 64 + stripStart = Math.max(stripStart, toStripValue(feature.strip[0])) 65 + stripEnd = Math.max(stripEnd, toStripValue(feature.strip[1])) 66 } 67 if (feature.style === 'italic') hasItalic = true 68 if (feature.style === 'bold') hasBold = true
+9 -4
src/lib/twelve/facet.js
··· 11 function has_client_strip(feature) { 12 return feature.$type=="com.example.richtext.facet#markup" 13 } 14 15 // todo: exclusion like "dont allow anything overlapping this one" -> delete all reflections of a span if anything overlaps one of its reflections, or vice versa. 16 ··· 105 }, 106 features: win.spans.map(span=>{ 107 let feature = {...span.feature} 108 if (has_client_strip(feature)) { 109 - feature.strip = [ 110 - Math.max(0, span.strip[0]-lstrip), 111 - Math.max(0, span.strip[1]-rstrip), 112 - ] 113 } 114 return feature 115 }),
··· 11 function has_client_strip(feature) { 12 return feature.$type=="com.example.richtext.facet#markup" 13 } 14 + // ugh 15 + function calculate_unicode_strips(text, start, end, lstrip, rstrip) { 16 + let s1 = text.slice(start, start+lstrip) 17 + let s2 = text.slice(end-rstrip, end) 18 + return [[...s1].length, [...s2].length] 19 + } 20 21 // todo: exclusion like "dont allow anything overlapping this one" -> delete all reflections of a span if anything overlaps one of its reflections, or vice versa. 22 ··· 111 }, 112 features: win.spans.map(span=>{ 113 let feature = {...span.feature} 114 + let final_lstrip = Math.max(0, span.strip[0]-lstrip) 115 + let final_rstrip = Math.max(0, span.strip[1]-rstrip) 116 if (has_client_strip(feature)) { 117 + feature.strip = calculate_unicode_strips(text, start, end, final_lstrip, final_rstrip) 118 } 119 return feature 120 }),