[Feature request] Attribute-based conditional mention styling (mentionStyleRules)
Los mantenedores suelen responder en 3 días
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- objective-c, react-native, typescript
- Área
- mobile
Línea de trabajo
Revisa PR #493 y los cambios propuestos en JavaScript relacionados con HtmlStyle y normalizeHtmlStyle; después, inspecciona la implementación de iOS InputConfig y MentionStyle.mm descrita en la issue. Extiende el enfoque para Android y web, conservando el fallback basado en indicadores y el comportamiento de las reglas de first-match; el trabajo estará terminado cuando los atributos coincidentes seleccionen el estilo configurado en todas las implementaciones.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
Currently, mention styling is determined entirely by the indicator character — all mentions with the same indicator share one style. There's no way to style individual mentions differently based on their state or metadata.
Use case: In our app, we use mentions for template variables (%custom_var% and {{mapping_var}}). Some variables are "pending" (not yet configured by the user) and need to be visually distinct — e.g., orange instead of blue — so users can see at a glance which variables need attention. Since both valid and pending variables share the same indicator, we can't differentiate them with the current API.
Proposed API
A new mentionStyleRules property on htmlStyle that allows declarative, attribute-based style overrides:
<EnrichedTextInput
htmlStyle={{
mention: {
"@": { color: "blue", backgroundColor: "lightblue", textDecorationLine: "none" },
},
mentionStyleRules: [
{
match: { pending: "true" },
style: { color: "orange", backgroundColor: "lightyellow", textDecorationLine: "none" },
},
{
match: { type: "urgent", priority: "high" },
style: { color: "red", backgroundColor: "pink", textDecorationLine: "underline" },
},
],
}}
mentionIndicators={["@"]}
/>
When committing a mention with matching attributes:
ref.current?.setMention("@", "John", { pending: "true" });
// → renders with orange style instead of the default blue
How it works
- Each rule has
match(key-value pairs) andstyle(MentionStyleProperties) matchis checked against the mention's attributes (the third arg tosetMention, which are already stored on both iOS and Android)- First matching rule wins; unmatched mentions fall back to indicator-based style
- Fully declarative — no lambdas, serializable over the bridge
Why this design
- No indicator hacking: We tried using separate indicator characters for different states, but indicators are tightly coupled to detection triggers and the native editor displays them as visible prefixes.
- Composable: Multiple rules for different conditions, each with independent match criteria.
- Backwards compatible: No rules = existing behavior. The
attributesparameter ofsetMentionis already supported but unused for styling. - No codegen changes: Rules are embedded in the existing
mentiondict (which isUnsafeMixed) and extracted on the native side.
Implementation
I have a working iOS implementation in PR #493. Happy to adjust the approach based on feedback. The Android and web implementations would follow the same pattern.
Summary of changes
JS: mentionStyleRules on HtmlStyle, processed in normalizeHtmlStyle (color conversion), embedded as __rules__ in the mention dict for native transport.
iOS native: InputConfig stores rules and exposes mentionStylePropsForIndicator:attributes: which deserializes the mention's JSON attributes and matches against rules. MentionStyle.mm uses the attribute-aware lookup.
- Lenguaje dominante
- C
- Estrellas
- 1.4k
- Forks
- 73
- Merge medio
- 3 d 4 h
- PR fusionados (30 d)
- 18
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de software-mansion/react-native-enriched-html
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
software-mansion/react-native-enriched-html#848 ·
Los mantenedores suelen responder en 3 días
-
[Feature request] Vertical spacing (margins) for headings and lists in htmlStylePosiblemente ocupada @henrikra la tomó hace 6 días. Abiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
software-mansion/react-native-enriched-html#832 ·
Los mantenedores suelen responder en 3 días
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
software-mansion/react-native-enriched-html#818 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
[iOS] Tags not parsed on iOS below a certain string lengthPosiblemente ocupada @hejsztynx la tomó hace 14 días. Abiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
software-mansion/react-native-enriched-html#811 · 3 comentarios ·
Los mantenedores suelen responder en 3 días
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
software-mansion/react-native-enriched-html#810 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Todos los issues de software-mansion/react-native-enriched-html
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
zephyrproject-rtos/zephyr#123881 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
ly05010419/MacNativeGames#1252 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 2 días
-
Component - Build
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Description of the bugAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
HarbourMasters/Lighthouse#655 ·
Los mantenedores suelen responder en 1 día