react-native-enriched-markdown-scaffold 0.7.4-scaffold.7 → 0.7.4-scaffold.8

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.
Files changed (72) hide show
  1. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +36 -0
  2. package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +3 -0
  3. package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +3 -1
  4. package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathFontWeight.kt +25 -0
  5. package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +12 -1
  6. package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +10 -0
  7. package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +1 -0
  8. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -1
  9. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +2 -2
  10. package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathTypeface.kt +30 -0
  11. package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +3 -1
  12. package/docs/INPUT.md +4 -0
  13. package/docs/LATEX_MATH.md +49 -0
  14. package/docs/STYLES.md +2 -0
  15. package/ios/attachments/ENRMMathInlineAttachment+macOS.m +5 -1
  16. package/ios/attachments/ENRMMathInlineAttachment.h +3 -0
  17. package/ios/attachments/ENRMMathInlineAttachment.m +2 -1
  18. package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +36 -0
  19. package/ios/input/ENRMInputFormatter.h +4 -0
  20. package/ios/input/ENRMInputFormatter.mm +2 -0
  21. package/ios/input/EnrichedMarkdownTextInput.mm +3 -0
  22. package/ios/input/InputStylePropsUtils.h +13 -0
  23. package/ios/math/ENRMRaTeXBridge.swift +52 -3
  24. package/ios/renderer/ENRMMathInlineRenderer.m +2 -0
  25. package/ios/styles/StyleConfig.h +4 -0
  26. package/ios/styles/StyleConfig.mm +24 -0
  27. package/ios/utils/ENRMMathFontWeight.h +18 -0
  28. package/ios/utils/StylePropsUtils.h +16 -0
  29. package/ios/views/ENRMMathContainerView.m +3 -1
  30. package/lib/module/EnrichedMarkdownNativeComponent.ts +2 -0
  31. package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
  32. package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +1 -0
  33. package/lib/module/EnrichedMarkdownTextNativeComponent.ts +2 -0
  34. package/lib/module/normalizeMarkdownStyle.js +4 -2
  35. package/lib/module/normalizeMarkdownStyle.js.map +1 -1
  36. package/lib/module/normalizeMarkdownStyle.web.js +4 -2
  37. package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
  38. package/lib/module/normalizeMarkdownTextInputStyle.js +7 -3
  39. package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
  40. package/lib/module/web/globalStyles.js +8 -1
  41. package/lib/module/web/globalStyles.js.map +1 -1
  42. package/lib/module/web/styles.js +3 -1
  43. package/lib/module/web/styles.js.map +1 -1
  44. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +2 -0
  45. package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
  46. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +1 -0
  47. package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
  48. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +1 -0
  49. package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
  50. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +2 -0
  51. package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
  52. package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
  53. package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
  54. package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +1 -0
  55. package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
  56. package/lib/typescript/src/types/MarkdownStyle.d.ts +24 -0
  57. package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
  58. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +2 -0
  59. package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
  60. package/lib/typescript/src/web/styles.d.ts.map +1 -1
  61. package/package.json +1 -1
  62. package/src/EnrichedMarkdownNativeComponent.ts +2 -0
  63. package/src/EnrichedMarkdownTextInput.tsx +1 -0
  64. package/src/EnrichedMarkdownTextInputNativeComponent.ts +1 -0
  65. package/src/EnrichedMarkdownTextNativeComponent.ts +2 -0
  66. package/src/normalizeMarkdownStyle.ts +6 -1
  67. package/src/normalizeMarkdownStyle.web.ts +6 -1
  68. package/src/normalizeMarkdownTextInputStyle.ts +5 -0
  69. package/src/types/MarkdownStyle.ts +24 -0
  70. package/src/types/MarkdownStyleInternal.ts +2 -0
  71. package/src/web/globalStyles.ts +7 -0
  72. package/src/web/styles.ts +5 -1
@@ -26,6 +26,7 @@ interface MathStyleInternal {
26
26
  paddingVertical: number;
27
27
  selectedBackgroundColor: ColorValue;
28
28
  selectedBorderColor: ColorValue;
29
+ fontWeight: string;
29
30
  }
30
31
 
31
32
  interface MathBlockStyleInternal extends MathStyleInternal {
@@ -76,6 +77,7 @@ const defaultMathInternal: MathStyleInternal = Object.freeze({
76
77
  paddingVertical: 0,
77
78
  selectedBackgroundColor: TRANSPARENT,
78
79
  selectedBorderColor: TRANSPARENT,
80
+ fontWeight: 'normal',
79
81
  });
80
82
 
81
83
  const defaultMathBlockInternal: MathBlockStyleInternal = Object.freeze({
@@ -89,6 +91,7 @@ const defaultMathBlockInternal: MathBlockStyleInternal = Object.freeze({
89
91
  paddingVertical: 8,
90
92
  selectedBackgroundColor: TRANSPARENT,
91
93
  selectedBorderColor: TRANSPARENT,
94
+ fontWeight: 'normal',
92
95
  marginTop: 8,
93
96
  marginBottom: 8,
94
97
  alignment: 'center',
@@ -152,6 +155,7 @@ function normalizeMathStyle(
152
155
  normalizeColor(style?.selectedBackgroundColor) ?? backgroundColor,
153
156
  selectedBorderColor:
154
157
  normalizeColor(style?.selectedBorderColor) ?? borderColor,
158
+ fontWeight: style?.fontWeight ?? fallback.fontWeight,
155
159
  };
156
160
  }
157
161
 
@@ -171,6 +175,7 @@ function normalizeMathBlockStyle(
171
175
  paddingVertical: fallback.paddingVertical,
172
176
  selectedBackgroundColor: baseInline.selectedBackgroundColor,
173
177
  selectedBorderColor: baseInline.selectedBorderColor,
178
+ fontWeight: baseInline.fontWeight,
174
179
  };
175
180
  const inheritedInline = normalizeMathStyle(style, merged);
176
181
  let alignment: 'left' | 'center' | 'right' = fallback.alignment;
@@ -155,6 +155,18 @@ interface MathStyle {
155
155
  marginTop?: number;
156
156
  marginBottom?: number;
157
157
  textAlign?: 'left' | 'center' | 'right';
158
+ /**
159
+ * Typeset the formula at bold weight.
160
+ *
161
+ * The native engine has no weight parameter and its glyph positions are
162
+ * already laid out when this applies, so `'bold'` is a SYNTHETIC embolden
163
+ * (a stroke on iOS, the platform's fake-bold on Android) rather than a
164
+ * switch to the bundled bold faces. That is deliberate: KaTeX's bold faces
165
+ * are up to 15% wider than the regular advances the layout reserved, so
166
+ * swapping them in would make glyphs collide.
167
+ * @default 'normal'
168
+ */
169
+ fontWeight?: 'bold' | 'normal';
158
170
  }
159
171
 
160
172
  interface InlineMathStyle {
@@ -167,6 +179,18 @@ interface InlineMathStyle {
167
179
  * @default 4
168
180
  */
169
181
  paddingVertical?: number;
182
+ /**
183
+ * Typeset the formula at bold weight.
184
+ *
185
+ * The native engine has no weight parameter and its glyph positions are
186
+ * already laid out when this applies, so `'bold'` is a SYNTHETIC embolden
187
+ * (a stroke on iOS, the platform's fake-bold on Android) rather than a
188
+ * switch to the bundled bold faces. That is deliberate: KaTeX's bold faces
189
+ * are up to 15% wider than the regular advances the layout reserved, so
190
+ * swapping them in would make glyphs collide.
191
+ * @default 'normal'
192
+ */
193
+ fontWeight?: 'bold' | 'normal';
170
194
  }
171
195
 
172
196
  interface SpoilerParticlesStyle {
@@ -140,11 +140,13 @@ interface MathStyleInternal {
140
140
  marginTop: number;
141
141
  marginBottom: number;
142
142
  textAlign: BlockTextAlign;
143
+ fontWeight: string;
143
144
  }
144
145
 
145
146
  interface InlineMathStyleInternal {
146
147
  color: string;
147
148
  paddingVertical: number;
149
+ fontWeight: string;
148
150
  }
149
151
 
150
152
  interface SpoilerParticlesStyleInternal {
@@ -8,6 +8,13 @@ const RULES: ReadonlyArray<readonly [id: string, css: string]> = [
8
8
  'enrm-selection-style',
9
9
  `.${ENRM_TEXT_CLASS} ::selection { background-color: var(${ENRM_SELECTION_BG_VAR}); }`,
10
10
  ],
11
+ // `fontWeight` for math is set on the span wrapping KaTeX's output, so the
12
+ // formula only picks it up by inheritance. `katex.css` opens `.katex` with
13
+ // the `font` shorthand, which resets `font-weight` — and a rule matching the
14
+ // element itself always beats a value inherited from an ancestor, inline
15
+ // style included. We do not load `katex.css` (MathML output needs no CSS),
16
+ // but a consumer may, so opt `.katex` back into inheriting.
17
+ ['enrm-katex-font-weight', '.katex { font-weight: inherit; }'],
11
18
  ];
12
19
 
13
20
  for (const [id, css] of RULES) {
package/src/web/styles.ts CHANGED
@@ -333,7 +333,10 @@ function highlightStyle(style: MarkdownStyleInternal): CSSProperties {
333
333
  }
334
334
 
335
335
  function mathInlineStyle(style: MarkdownStyleInternal): CSSProperties {
336
- return { color: style.inlineMath.color };
336
+ return {
337
+ color: style.inlineMath.color,
338
+ fontWeight: normalizeFontWeight(style.inlineMath.fontWeight),
339
+ };
337
340
  }
338
341
 
339
342
  function mathDisplayStyle(style: MarkdownStyleInternal): CSSProperties {
@@ -341,6 +344,7 @@ function mathDisplayStyle(style: MarkdownStyleInternal): CSSProperties {
341
344
  return {
342
345
  fontSize: math.fontSize,
343
346
  color: math.color,
347
+ fontWeight: normalizeFontWeight(math.fontWeight),
344
348
  backgroundColor: math.backgroundColor,
345
349
  padding: math.padding,
346
350
  marginTop: math.marginTop,