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.
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +3 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathFontWeight.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +12 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +10 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +1 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +2 -2
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathTypeface.kt +30 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +3 -1
- package/docs/INPUT.md +4 -0
- package/docs/LATEX_MATH.md +49 -0
- package/docs/STYLES.md +2 -0
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +5 -1
- package/ios/attachments/ENRMMathInlineAttachment.h +3 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +2 -1
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +36 -0
- package/ios/input/ENRMInputFormatter.h +4 -0
- package/ios/input/ENRMInputFormatter.mm +2 -0
- package/ios/input/EnrichedMarkdownTextInput.mm +3 -0
- package/ios/input/InputStylePropsUtils.h +13 -0
- package/ios/math/ENRMRaTeXBridge.swift +52 -3
- package/ios/renderer/ENRMMathInlineRenderer.m +2 -0
- package/ios/styles/StyleConfig.h +4 -0
- package/ios/styles/StyleConfig.mm +24 -0
- package/ios/utils/ENRMMathFontWeight.h +18 -0
- package/ios/utils/StylePropsUtils.h +16 -0
- package/ios/views/ENRMMathContainerView.m +3 -1
- package/lib/module/EnrichedMarkdownNativeComponent.ts +2 -0
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +1 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +2 -0
- package/lib/module/normalizeMarkdownStyle.js +4 -2
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +4 -2
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/normalizeMarkdownTextInputStyle.js +7 -3
- package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
- package/lib/module/web/globalStyles.js +8 -1
- package/lib/module/web/globalStyles.js.map +1 -1
- package/lib/module/web/styles.js +3 -1
- package/lib/module/web/styles.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +2 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +1 -0
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +1 -0
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +2 -0
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts +1 -0
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +24 -0
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +2 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EnrichedMarkdownNativeComponent.ts +2 -0
- package/src/EnrichedMarkdownTextInput.tsx +1 -0
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +1 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +2 -0
- package/src/normalizeMarkdownStyle.ts +6 -1
- package/src/normalizeMarkdownStyle.web.ts +6 -1
- package/src/normalizeMarkdownTextInputStyle.ts +5 -0
- package/src/types/MarkdownStyle.ts +24 -0
- package/src/types/MarkdownStyleInternal.ts +2 -0
- package/src/web/globalStyles.ts +7 -0
- 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 {
|
package/src/web/globalStyles.ts
CHANGED
|
@@ -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 {
|
|
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,
|