tangled
alpha
login
or
join now
ansxor.ca
/
witchsky.app
forked from
jollywhoppers.com/witchsky.app
1
fork
atom
Bluesky app fork with some witchin' additions 💫
1
fork
atom
overview
issues
pulls
pipelines
strip property measured in codepoints
12Me21
2 weeks ago
6567e1d6
1a6997af
+11
-6
2 changed files
expand all
collapse all
unified
split
src
components
RichText.tsx
lib
twelve
facet.js
+2
-2
src/components/RichText.tsx
···
61
61
62
62
for (const feature of markupFeatures) {
63
63
if (feature.strip?.length === 2) {
64
64
-
stripStart += toStripValue(feature.strip[0])
65
65
-
stripEnd += toStripValue(feature.strip[1])
64
64
+
stripStart = Math.max(stripStart, toStripValue(feature.strip[0]))
65
65
+
stripEnd = Math.max(stripEnd, toStripValue(feature.strip[1]))
66
66
}
67
67
if (feature.style === 'italic') hasItalic = true
68
68
if (feature.style === 'bold') hasBold = true
+9
-4
src/lib/twelve/facet.js
···
11
11
function has_client_strip(feature) {
12
12
return feature.$type=="com.example.richtext.facet#markup"
13
13
}
14
14
+
// ugh
15
15
+
function calculate_unicode_strips(text, start, end, lstrip, rstrip) {
16
16
+
let s1 = text.slice(start, start+lstrip)
17
17
+
let s2 = text.slice(end-rstrip, end)
18
18
+
return [[...s1].length, [...s2].length]
19
19
+
}
14
20
15
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.
16
22
···
105
111
},
106
112
features: win.spans.map(span=>{
107
113
let feature = {...span.feature}
114
114
+
let final_lstrip = Math.max(0, span.strip[0]-lstrip)
115
115
+
let final_rstrip = Math.max(0, span.strip[1]-rstrip)
108
116
if (has_client_strip(feature)) {
109
109
-
feature.strip = [
110
110
-
Math.max(0, span.strip[0]-lstrip),
111
111
-
Math.max(0, span.strip[1]-rstrip),
112
112
-
]
117
117
+
feature.strip = calculate_unicode_strips(text, start, end, final_lstrip, final_rstrip)
113
118
}
114
119
return feature
115
120
}),