react-native-enriched-markdown-scaffold 0.6.0-scaffold.6 → 0.7.4-scaffold.1
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/ReactNativeEnrichedMarkdown.podspec +62 -11
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +1 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +9 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +1 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +20 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +744 -36
- package/android/src/main/baseline-prof.txt +75 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +62 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +10 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +9 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +0 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibilityLabels.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +44 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +52 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +55 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/FormattingStore.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputParser.kt +22 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputRemend.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputMeasurementStore.kt +7 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/input/model/MathChipStyle.kt +0 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/input/toolbar/InputContextMenu.kt +54 -13
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +17 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +4 -4
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/MathModels.kt +0 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +1 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +1 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +30 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/MarkdownStyleParser.kt +0 -14
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkEvents.kt +22 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +36 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +73 -3
- package/android/src/main/jni/CMakeLists.txt +15 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +0 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathChipSpan.kt +1 -2
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +1 -3
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathMeasureHelper.kt +1 -2
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +25 -10
- package/app.plugin.js +2 -1
- package/cpp/parser/MD4CParser.cpp +1 -1
- package/cpp/wasm/build.sh +9 -9
- package/docs/ACCESSIBILITY.md +172 -0
- package/docs/API_REFERENCE.md +948 -0
- package/docs/COPY_OPTIONS.md +127 -0
- package/docs/ELEMENTS_STRUCTURE.md +112 -0
- package/docs/IMAGE_CACHING.md +25 -0
- package/docs/INPUT.md +233 -0
- package/docs/LATEX_MATH.md +136 -0
- package/docs/MACOS.md +19 -0
- package/docs/MARKDOWN_STREAMING.md +36 -0
- package/docs/MENTIONS.md +97 -0
- package/docs/RTL.md +82 -0
- package/docs/STYLES.md +519 -0
- package/docs/TEXT.md +110 -0
- package/docs/WEB.md +49 -0
- package/ios/EnrichedMarkdown.mm +82 -25
- package/ios/EnrichedMarkdownText.mm +37 -5
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +1 -5
- package/ios/attachments/ENRMMathInlineAttachment.h +0 -3
- package/ios/attachments/ENRMMathInlineAttachment.m +1 -2
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +20 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +744 -36
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +15 -0
- package/ios/input/ENRMFormattingStore.h +5 -0
- package/ios/input/ENRMFormattingStore.mm +34 -0
- package/ios/input/ENRMInputFormatter.h +0 -6
- package/ios/input/ENRMInputFormatter.mm +0 -2
- package/ios/input/ENRMInputTextView.h +2 -0
- package/ios/input/ENRMInputTextView.mm +8 -17
- package/ios/input/ENRMMarkdownSerializer.mm +1 -1
- package/ios/input/EnrichedMarkdownTextInput+ContextMenu.mm +71 -53
- package/ios/input/EnrichedMarkdownTextInput+Internal.h +26 -0
- package/ios/input/EnrichedMarkdownTextInput.h +1 -0
- package/ios/input/EnrichedMarkdownTextInput.mm +207 -12
- package/ios/input/InputStylePropsUtils.h +0 -8
- package/ios/input/styles/ENRMBoldStyleHandler.mm +3 -2
- package/ios/input/styles/ENRMItalicStyleHandler.mm +3 -2
- package/ios/math/ENRMRaTeXBridge.swift +2 -16
- package/ios/renderer/AttributedRenderer.m +51 -6
- package/ios/renderer/ENRMMathInlineRenderer.m +5 -2
- package/ios/styles/ENRMFontSlot.h +1 -1
- package/ios/styles/StyleConfig.h +0 -4
- package/ios/styles/StyleConfig.mm +0 -24
- package/ios/utils/ENRMAccessibilityLabels.h +36 -0
- package/ios/utils/ENRMAccessibilityLabels.m +5 -0
- package/ios/utils/EditMenuUtils+macOS.m +4 -5
- package/ios/utils/EditMenuUtils.h +70 -0
- package/ios/utils/EditMenuUtils.m +14 -11
- package/ios/utils/LastElementUtils.h +39 -2
- package/ios/utils/MarkdownAccessibilityElementBuilder.h +18 -16
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +64 -32
- package/ios/utils/ParagraphStyleUtils.m +21 -2
- package/ios/utils/StylePropsUtils.h +0 -10
- package/ios/views/ENRMMathContainerView.h +8 -0
- package/ios/views/ENRMMathContainerView.m +8 -7
- package/ios/views/ENRMTableIOSGridView.h +40 -0
- package/ios/views/ENRMTableIOSGridView.m +216 -0
- package/ios/views/EnrichedMarkdownInternalText.h +2 -0
- package/ios/views/EnrichedMarkdownInternalText.m +2 -0
- package/ios/views/TableContainerView.h +8 -0
- package/ios/views/TableContainerView.m +72 -128
- package/lib/module/EnrichedMarkdownNativeComponent.ts +37 -2
- package/lib/module/EnrichedMarkdownTextInput.js +48 -1
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +35 -1
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +37 -2
- package/lib/module/accessibilityLabelDefaults.js +64 -0
- package/lib/module/accessibilityLabelDefaults.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +72 -4
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +2 -4
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +2 -4
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/normalizeMarkdownTextInputStyle.js +3 -10
- package/lib/module/normalizeMarkdownTextInputStyle.js.map +1 -1
- package/lib/module/normalizeMenuItem.js +38 -0
- package/lib/module/normalizeMenuItem.js.map +1 -0
- package/lib/module/types/AccessibilityLabels.js +2 -0
- package/lib/module/types/AccessibilityLabels.js.map +1 -0
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +34 -2
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +55 -13
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +30 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +34 -2
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/accessibilityLabelDefaults.d.ts +16 -0
- package/lib/typescript/src/accessibilityLabelDefaults.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
- package/lib/typescript/src/native/EnrichedMarkdownText.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 +0 -2
- package/lib/typescript/src/normalizeMarkdownTextInputStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMenuItem.d.ts +7 -0
- package/lib/typescript/src/normalizeMenuItem.d.ts.map +1 -0
- package/lib/typescript/src/types/AccessibilityLabels.d.ts +114 -0
- package/lib/typescript/src/types/AccessibilityLabels.d.ts.map +1 -0
- package/lib/typescript/src/types/MarkdownStyle.d.ts +0 -14
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +0 -3
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +78 -9
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/package.json +4 -2
- package/plugin/build/withAndroidMath.js +19 -0
- package/plugin/build/withIosMath.js +28 -0
- package/plugin/build/withReactNativeEnrichedMarkdown.js +11 -0
- package/plugin/tsconfig.build.json +16 -0
- package/src/EnrichedMarkdownNativeComponent.ts +37 -2
- package/src/EnrichedMarkdownTextInput.tsx +117 -13
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +35 -1
- package/src/EnrichedMarkdownTextNativeComponent.ts +37 -2
- package/src/accessibilityLabelDefaults.ts +83 -0
- package/src/index.tsx +11 -0
- package/src/native/EnrichedMarkdownText.tsx +120 -6
- package/src/normalizeMarkdownStyle.ts +1 -6
- package/src/normalizeMarkdownStyle.web.ts +1 -6
- package/src/normalizeMarkdownTextInputStyle.ts +0 -14
- package/src/normalizeMenuItem.ts +52 -0
- package/src/types/AccessibilityLabels.ts +118 -0
- package/src/types/MarkdownStyle.ts +0 -14
- package/src/types/MarkdownStyleInternal.ts +0 -4
- package/src/types/MarkdownTextProps.ts +74 -9
- package/android/src/math/java/com/swmansion/enriched/markdown/utils/math/LatexWeightWrapper.kt +0 -23
- package/lib/module/plugin/withAndroidMath.js +0 -20
- package/lib/module/plugin/withAndroidMath.js.map +0 -1
- package/lib/module/plugin/withIosMath.js +0 -23
- package/lib/module/plugin/withIosMath.js.map +0 -1
- package/lib/module/plugin/withReactNativeEnrichedMarkdown.js +0 -16
- package/lib/module/plugin/withReactNativeEnrichedMarkdown.js.map +0 -1
- package/lib/typescript/src/plugin/withAndroidMath.d.ts +0 -5
- package/lib/typescript/src/plugin/withAndroidMath.d.ts.map +0 -1
- package/lib/typescript/src/plugin/withIosMath.d.ts +0 -5
- package/lib/typescript/src/plugin/withIosMath.d.ts.map +0 -1
- package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts +0 -6
- package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts.map +0 -1
- /package/{src/plugin → plugin/src}/withAndroidMath.ts +0 -0
- /package/{src/plugin → plugin/src}/withIosMath.ts +0 -0
- /package/{src/plugin → plugin/src}/withReactNativeEnrichedMarkdown.ts +0 -0
|
@@ -3,6 +3,11 @@ import EnrichedMarkdownTextNativeComponent from '../EnrichedMarkdownTextNativeCo
|
|
|
3
3
|
import type { MarkdownStyleInternal } from '../EnrichedMarkdownTextNativeComponent';
|
|
4
4
|
import EnrichedMarkdownNativeComponent from '../EnrichedMarkdownNativeComponent';
|
|
5
5
|
import { normalizeMarkdownStyle } from '../normalizeMarkdownStyle';
|
|
6
|
+
import { resolveAccessibilityLabels } from '../accessibilityLabelDefaults';
|
|
7
|
+
import {
|
|
8
|
+
normalizeMenuItem,
|
|
9
|
+
normalizeLegacyBooleanMenuItem,
|
|
10
|
+
} from '../normalizeMenuItem';
|
|
6
11
|
import type { NativeSyntheticEvent } from 'react-native';
|
|
7
12
|
import type { MarkdownStyle, Md4cFlags } from '../types/MarkdownStyle';
|
|
8
13
|
import type {
|
|
@@ -10,6 +15,7 @@ import type {
|
|
|
10
15
|
StreamingConfig,
|
|
11
16
|
ContextMenuItem,
|
|
12
17
|
SelectionMenuConfig,
|
|
18
|
+
SelectionMenuPluralLabels,
|
|
13
19
|
} from '../types/MarkdownTextProps';
|
|
14
20
|
import type {
|
|
15
21
|
LinkPressEvent,
|
|
@@ -24,9 +30,71 @@ export type {
|
|
|
24
30
|
StreamingConfig,
|
|
25
31
|
ContextMenuItem,
|
|
26
32
|
SelectionMenuConfig,
|
|
33
|
+
SelectionMenuPluralLabels,
|
|
27
34
|
};
|
|
28
35
|
export type { LinkPressEvent, LinkLongPressEvent, TaskListItemPressEvent };
|
|
29
36
|
|
|
37
|
+
// Default English labels for the built-in selection menu actions. Defaults are
|
|
38
|
+
// resolved here (JS-side) so the native code always receives a concrete string.
|
|
39
|
+
const DEFAULT_COPY_LABEL = 'Copy';
|
|
40
|
+
const DEFAULT_COPY_AS_MARKDOWN_LABEL = 'Copy as Markdown';
|
|
41
|
+
const DEFAULT_COPY_IMAGE_URL_LABEL = 'Copy Image URL';
|
|
42
|
+
const DEFAULT_COPY_IMAGE_URLS_LABEL = 'Copy {count} Image URLs';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Resolves `pluralLabels` into a per-count template table (index = image count,
|
|
46
|
+
* 0..100) the native side can index without any locale logic. `Intl.PluralRules`
|
|
47
|
+
* selects the CLDR category for each count; missing categories fall back to the
|
|
48
|
+
* required `other`. Index 1 uses the singular `label` (the single-image case).
|
|
49
|
+
* Native uses `other` (copyImageUrlsLabel) for counts > 100, and falls back to
|
|
50
|
+
* the singular/`{count}` templates entirely when this returns an empty array
|
|
51
|
+
* (no plural labels set, or `Intl.PluralRules` unavailable).
|
|
52
|
+
*/
|
|
53
|
+
const buildPluralTemplates = (
|
|
54
|
+
pluralLabels: SelectionMenuPluralLabels | undefined,
|
|
55
|
+
singularLabel: string
|
|
56
|
+
): string[] => {
|
|
57
|
+
if (!pluralLabels) return [];
|
|
58
|
+
|
|
59
|
+
const IntlRef = Intl as unknown as {
|
|
60
|
+
PluralRules?: new (locales?: string | string[]) => {
|
|
61
|
+
select(n: number): string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
if (typeof IntlRef.PluralRules !== 'function') return [];
|
|
65
|
+
|
|
66
|
+
let pluralRules: { select(n: number): string };
|
|
67
|
+
try {
|
|
68
|
+
// TODO: expose `copyImageUrl.pluralLocale?: string` so i18n apps can force
|
|
69
|
+
// a locale independent of the device. Today this resolves to the JS
|
|
70
|
+
// runtime's default locale, so on an English device only `one` and `other`
|
|
71
|
+
// ever fire even when richer plural labels are configured.
|
|
72
|
+
pluralRules = new IntlRef.PluralRules();
|
|
73
|
+
} catch {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const { other } = pluralLabels;
|
|
78
|
+
const byCategory: Record<string, string> = {
|
|
79
|
+
zero: pluralLabels.zero ?? other,
|
|
80
|
+
one: pluralLabels.one ?? other,
|
|
81
|
+
two: pluralLabels.two ?? other,
|
|
82
|
+
few: pluralLabels.few ?? other,
|
|
83
|
+
many: pluralLabels.many ?? other,
|
|
84
|
+
other,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const templates: string[] = [];
|
|
88
|
+
for (let n = 0; n <= 100; n++) {
|
|
89
|
+
// The literal single-image case uses the (non-plural) singular label; every
|
|
90
|
+
// other count uses its CLDR category form.
|
|
91
|
+
templates.push(
|
|
92
|
+
n === 1 ? singularLabel : (byCategory[pluralRules.select(n)] ?? other)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return templates;
|
|
96
|
+
};
|
|
97
|
+
|
|
30
98
|
const defaultMd4cFlags: Md4cFlags = {
|
|
31
99
|
underline: false,
|
|
32
100
|
superscript: false,
|
|
@@ -54,6 +122,7 @@ export const EnrichedMarkdownText = ({
|
|
|
54
122
|
spoilerOverlay = 'particles',
|
|
55
123
|
contextMenuItems,
|
|
56
124
|
selectionMenuConfig,
|
|
125
|
+
accessibilityLabels,
|
|
57
126
|
selectionColor,
|
|
58
127
|
selectionHandleColor,
|
|
59
128
|
textBreakStrategy,
|
|
@@ -142,12 +211,56 @@ export const EnrichedMarkdownText = ({
|
|
|
142
211
|
|
|
143
212
|
const tableMode = streamingConfig?.tableMode ?? 'progressive';
|
|
144
213
|
const normalizedStreamingConfig = useMemo(() => ({ tableMode }), [tableMode]);
|
|
145
|
-
const normalizedSelectionMenuConfig = useMemo(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
214
|
+
const normalizedSelectionMenuConfig = useMemo(() => {
|
|
215
|
+
// The boolean acceptance is confined to this wrapper boundary via a single
|
|
216
|
+
// `as unknown` cast; the public type only exposes the object shape.
|
|
217
|
+
const config = selectionMenuConfig as
|
|
218
|
+
| {
|
|
219
|
+
copy?: unknown;
|
|
220
|
+
copyAsMarkdown?: unknown;
|
|
221
|
+
copyImageUrl?: unknown;
|
|
222
|
+
}
|
|
223
|
+
| undefined;
|
|
224
|
+
|
|
225
|
+
const copy = normalizeMenuItem(config?.copy, true, DEFAULT_COPY_LABEL);
|
|
226
|
+
const copyAsMarkdown = normalizeLegacyBooleanMenuItem(
|
|
227
|
+
config?.copyAsMarkdown,
|
|
228
|
+
'selectionMenuConfig',
|
|
229
|
+
'copyAsMarkdown',
|
|
230
|
+
true,
|
|
231
|
+
DEFAULT_COPY_AS_MARKDOWN_LABEL
|
|
232
|
+
);
|
|
233
|
+
const copyImageUrl = normalizeLegacyBooleanMenuItem(
|
|
234
|
+
config?.copyImageUrl,
|
|
235
|
+
'selectionMenuConfig',
|
|
236
|
+
'copyImageUrl',
|
|
237
|
+
true,
|
|
238
|
+
DEFAULT_COPY_IMAGE_URL_LABEL
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const pluralLabels = (
|
|
242
|
+
config?.copyImageUrl as
|
|
243
|
+
| { pluralLabels?: SelectionMenuPluralLabels }
|
|
244
|
+
| undefined
|
|
245
|
+
)?.pluralLabels;
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
copyAsMarkdown: copyAsMarkdown.enabled,
|
|
249
|
+
copyImageUrl: copyImageUrl.enabled,
|
|
250
|
+
copyLabel: copy.label,
|
|
251
|
+
copyAsMarkdownLabel: copyAsMarkdown.label,
|
|
252
|
+
copyImageUrlLabel: copyImageUrl.label,
|
|
253
|
+
copyImageUrlsLabel: pluralLabels?.other ?? DEFAULT_COPY_IMAGE_URLS_LABEL,
|
|
254
|
+
copyImageUrlPluralTemplates: buildPluralTemplates(
|
|
255
|
+
pluralLabels,
|
|
256
|
+
copyImageUrl.label
|
|
257
|
+
),
|
|
258
|
+
};
|
|
259
|
+
}, [selectionMenuConfig]);
|
|
260
|
+
|
|
261
|
+
const resolvedAccessibilityLabels = useMemo(
|
|
262
|
+
() => resolveAccessibilityLabels(accessibilityLabels),
|
|
263
|
+
[accessibilityLabels]
|
|
151
264
|
);
|
|
152
265
|
|
|
153
266
|
const sharedProps = {
|
|
@@ -168,6 +281,7 @@ export const EnrichedMarkdownText = ({
|
|
|
168
281
|
style: containerStyle,
|
|
169
282
|
contextMenuItems: nativeContextMenuItems,
|
|
170
283
|
selectionMenuConfig: normalizedSelectionMenuConfig,
|
|
284
|
+
accessibilityLabels: resolvedAccessibilityLabels,
|
|
171
285
|
onContextMenuItemPress: handleContextMenuItemPress,
|
|
172
286
|
selectionColor,
|
|
173
287
|
selectionHandleColor,
|
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
EmphasisFontStyle,
|
|
6
6
|
LinkVariantEntryInternal,
|
|
7
7
|
MarkdownStyleInternal,
|
|
8
|
-
MathFontWeight,
|
|
9
8
|
} from './types/MarkdownStyleInternal';
|
|
10
9
|
import { isStyleEqual, normalizeColor, mergeSubStyle } from './styleUtils';
|
|
11
10
|
import { normalizeLinkVariantEntries } from './linkVariantUtils';
|
|
@@ -194,12 +193,8 @@ const DEFAULT_NORMALIZED_STYLE = Object.freeze({
|
|
|
194
193
|
marginTop: 0,
|
|
195
194
|
marginBottom: 16,
|
|
196
195
|
textAlign: 'center' as BlockTextAlign,
|
|
197
|
-
fontWeight: 'normal' as MathFontWeight,
|
|
198
|
-
},
|
|
199
|
-
inlineMath: {
|
|
200
|
-
color: defaultTextColor,
|
|
201
|
-
fontWeight: 'normal' as MathFontWeight,
|
|
202
196
|
},
|
|
197
|
+
inlineMath: { color: defaultTextColor },
|
|
203
198
|
taskList: {
|
|
204
199
|
checkedColor: Platform.select({
|
|
205
200
|
ios: normalizeColor('#007AFF')!,
|
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
EmphasisFontStyle,
|
|
5
5
|
LinkVariantEntryInternal,
|
|
6
6
|
MarkdownStyleInternal,
|
|
7
|
-
MathFontWeight,
|
|
8
7
|
} from './types/MarkdownStyleInternal';
|
|
9
8
|
import { isStyleEqual, mergeSubStyle } from './styleUtils';
|
|
10
9
|
import { normalizeLinkVariantEntries } from './linkVariantUtils';
|
|
@@ -178,12 +177,8 @@ const DEFAULT_NORMALIZED_STYLE: MarkdownStyleInternal = Object.freeze({
|
|
|
178
177
|
marginTop: 0,
|
|
179
178
|
marginBottom: 16,
|
|
180
179
|
textAlign: 'center' as BlockTextAlign,
|
|
181
|
-
fontWeight: 'normal' as MathFontWeight,
|
|
182
|
-
},
|
|
183
|
-
inlineMath: {
|
|
184
|
-
color: defaultTextColor,
|
|
185
|
-
fontWeight: 'normal' as MathFontWeight,
|
|
186
180
|
},
|
|
181
|
+
inlineMath: { color: defaultTextColor },
|
|
187
182
|
taskList: {
|
|
188
183
|
checkedColor: '#007AFF',
|
|
189
184
|
borderColor: '#9E9E9E',
|
|
@@ -15,8 +15,6 @@ interface LinkVariantEntryInternal {
|
|
|
15
15
|
backgroundColor: ColorValue;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
type MathFontWeight = 'normal' | 'bold';
|
|
19
|
-
|
|
20
18
|
interface MathStyleInternal {
|
|
21
19
|
color: ColorValue;
|
|
22
20
|
fontSize: number;
|
|
@@ -28,7 +26,6 @@ interface MathStyleInternal {
|
|
|
28
26
|
paddingVertical: number;
|
|
29
27
|
selectedBackgroundColor: ColorValue;
|
|
30
28
|
selectedBorderColor: ColorValue;
|
|
31
|
-
fontWeight: MathFontWeight;
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
interface MathBlockStyleInternal extends MathStyleInternal {
|
|
@@ -79,7 +76,6 @@ const defaultMathInternal: MathStyleInternal = Object.freeze({
|
|
|
79
76
|
paddingVertical: 0,
|
|
80
77
|
selectedBackgroundColor: TRANSPARENT,
|
|
81
78
|
selectedBorderColor: TRANSPARENT,
|
|
82
|
-
fontWeight: 'normal',
|
|
83
79
|
});
|
|
84
80
|
|
|
85
81
|
const defaultMathBlockInternal: MathBlockStyleInternal = Object.freeze({
|
|
@@ -93,7 +89,6 @@ const defaultMathBlockInternal: MathBlockStyleInternal = Object.freeze({
|
|
|
93
89
|
paddingVertical: 8,
|
|
94
90
|
selectedBackgroundColor: TRANSPARENT,
|
|
95
91
|
selectedBorderColor: TRANSPARENT,
|
|
96
|
-
fontWeight: 'normal',
|
|
97
92
|
marginTop: 8,
|
|
98
93
|
marginBottom: 8,
|
|
99
94
|
alignment: 'center',
|
|
@@ -135,13 +130,6 @@ function normalizeInputLinkStyle(
|
|
|
135
130
|
};
|
|
136
131
|
}
|
|
137
132
|
|
|
138
|
-
function normalizeMathFontWeight(
|
|
139
|
-
value: 'normal' | 'bold' | undefined,
|
|
140
|
-
fallback: MathFontWeight
|
|
141
|
-
): MathFontWeight {
|
|
142
|
-
return value === 'bold' ? 'bold' : value === 'normal' ? 'normal' : fallback;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
133
|
function normalizeMathStyle(
|
|
146
134
|
style: MathStyle | undefined,
|
|
147
135
|
fallback: MathStyleInternal
|
|
@@ -164,7 +152,6 @@ function normalizeMathStyle(
|
|
|
164
152
|
normalizeColor(style?.selectedBackgroundColor) ?? backgroundColor,
|
|
165
153
|
selectedBorderColor:
|
|
166
154
|
normalizeColor(style?.selectedBorderColor) ?? borderColor,
|
|
167
|
-
fontWeight: normalizeMathFontWeight(style?.fontWeight, fallback.fontWeight),
|
|
168
155
|
};
|
|
169
156
|
}
|
|
170
157
|
|
|
@@ -184,7 +171,6 @@ function normalizeMathBlockStyle(
|
|
|
184
171
|
paddingVertical: fallback.paddingVertical,
|
|
185
172
|
selectedBackgroundColor: baseInline.selectedBackgroundColor,
|
|
186
173
|
selectedBorderColor: baseInline.selectedBorderColor,
|
|
187
|
-
fontWeight: baseInline.fontWeight,
|
|
188
174
|
};
|
|
189
175
|
const inheritedInline = normalizeMathStyle(style, merged);
|
|
190
176
|
let alignment: 'left' | 'center' | 'right' = fallback.alignment;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Not __DEV__-gated on purpose: deprecation warnings need to surface in
|
|
2
|
+
// staging/TestFlight/CI prod builds too.
|
|
3
|
+
const warned = new Set<string>();
|
|
4
|
+
|
|
5
|
+
const warnOnce = (key: string, msg: string) => {
|
|
6
|
+
if (warned.has(key)) return;
|
|
7
|
+
warned.add(key);
|
|
8
|
+
console.warn(msg);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type NormalizedMenuItem = { enabled: boolean; label: string };
|
|
12
|
+
|
|
13
|
+
// TODO: revisit grouping cross-cutting utilities (this, styleUtils, linkVariantUtils,
|
|
14
|
+
// normalizeMarkdownStyle, etc.) into a shared module once the set grows further.
|
|
15
|
+
export const normalizeMenuItem = (
|
|
16
|
+
raw: unknown,
|
|
17
|
+
defaultEnabled: boolean,
|
|
18
|
+
defaultLabel: string
|
|
19
|
+
): NormalizedMenuItem => {
|
|
20
|
+
if (raw === undefined)
|
|
21
|
+
return { enabled: defaultEnabled, label: defaultLabel };
|
|
22
|
+
// Validate per leaf so an empty string stays an empty string (an emoji-only
|
|
23
|
+
// item is a legitimate use case), while null / non-object / wrong-typed
|
|
24
|
+
// fields fall back to defaults — `getBoolean` on the Android side throws on
|
|
25
|
+
// non-booleans, and a null root would crash JS on property access.
|
|
26
|
+
const obj =
|
|
27
|
+
typeof raw === 'object' && raw !== null
|
|
28
|
+
? (raw as { enabled?: unknown; label?: unknown })
|
|
29
|
+
: {};
|
|
30
|
+
return {
|
|
31
|
+
enabled: typeof obj.enabled === 'boolean' ? obj.enabled : defaultEnabled,
|
|
32
|
+
label: typeof obj.label === 'string' ? obj.label : defaultLabel,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const normalizeLegacyBooleanMenuItem = (
|
|
37
|
+
raw: unknown,
|
|
38
|
+
parentProp: string,
|
|
39
|
+
field: string,
|
|
40
|
+
defaultEnabled: boolean,
|
|
41
|
+
defaultLabel: string
|
|
42
|
+
): NormalizedMenuItem => {
|
|
43
|
+
if (typeof raw === 'boolean') {
|
|
44
|
+
warnOnce(
|
|
45
|
+
`${parentProp}.${field}`,
|
|
46
|
+
`[react-native-enriched-markdown] ${parentProp}.${field} as a boolean is ` +
|
|
47
|
+
`deprecated; use { enabled: ${raw} }. The boolean form will be removed in 0.8.`
|
|
48
|
+
);
|
|
49
|
+
return { enabled: raw, label: defaultLabel };
|
|
50
|
+
}
|
|
51
|
+
return normalizeMenuItem(raw, defaultEnabled, defaultLabel);
|
|
52
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strings spoken by VoiceOver (iOS) / TalkBack (Android) when navigating
|
|
3
|
+
* the rendered markdown.
|
|
4
|
+
*
|
|
5
|
+
* Every key is optional — when omitted, defaults from
|
|
6
|
+
* `accessibilityLabelDefaults.ts` are applied on the JS side before being
|
|
7
|
+
* forwarded to native. Native code can rely on every field being a concrete
|
|
8
|
+
* string at the point it is consumed.
|
|
9
|
+
*
|
|
10
|
+
* **Placeholder syntax.** Where a label has dynamic content, the default uses
|
|
11
|
+
* `{n}` (count / index, 1-based), `{content}` (resolved cell text or similar),
|
|
12
|
+
* or `{latex}` (math source). Translations must preserve the placeholder names
|
|
13
|
+
* exactly — native code substitutes them at speak time.
|
|
14
|
+
*
|
|
15
|
+
* **No plurals.** Defaults intentionally use the cardinal form (`"Row 2"`,
|
|
16
|
+
* `"List item 2"`) instead of ordinals or count-aware variants. Screen readers
|
|
17
|
+
* already announce numbers locale-appropriately, and a single template avoids
|
|
18
|
+
* the per-language plural rules (en `1/2+`, pl `1/2-4/5+`, ar `0/1/2/3-10/11-99/100+`, …).
|
|
19
|
+
*
|
|
20
|
+
* The shape is split into logical sub-groups so that consumers can override
|
|
21
|
+
* just the announcements that matter to them without re-declaring the rest.
|
|
22
|
+
*/
|
|
23
|
+
export interface AccessibilityLabels {
|
|
24
|
+
/** Labels spoken for list items. iOS + Android. */
|
|
25
|
+
list?: {
|
|
26
|
+
/** @default 'Bullet point' */
|
|
27
|
+
bulletPoint?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Spoken when the bullet is inside another list.
|
|
30
|
+
* @default 'Nested bullet point'
|
|
31
|
+
*/
|
|
32
|
+
nestedBulletPoint?: string;
|
|
33
|
+
/**
|
|
34
|
+
* `{n}` → 1-based item number.
|
|
35
|
+
* @default 'List item {n}'
|
|
36
|
+
*/
|
|
37
|
+
orderedItem?: string;
|
|
38
|
+
/**
|
|
39
|
+
* `{n}` → 1-based item number.
|
|
40
|
+
* @default 'Nested list item {n}'
|
|
41
|
+
*/
|
|
42
|
+
nestedOrderedItem?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Labels appended for content inside a blockquote. iOS + Android. */
|
|
46
|
+
blockquote?: {
|
|
47
|
+
/**
|
|
48
|
+
* Spoken for top-level blockquote content.
|
|
49
|
+
* @default 'Blockquote'
|
|
50
|
+
*/
|
|
51
|
+
quote?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Spoken for content nested inside another blockquote.
|
|
54
|
+
* @default 'Nested blockquote'
|
|
55
|
+
*/
|
|
56
|
+
nestedQuote?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Labels spoken for tables. iOS + Android. */
|
|
60
|
+
table?: {
|
|
61
|
+
/**
|
|
62
|
+
* `{n}` → 1-based row index, `{content}` → comma-joined cell texts.
|
|
63
|
+
* @default 'Row {n}: {content}'
|
|
64
|
+
*/
|
|
65
|
+
row?: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** Labels spoken for math equations. iOS + Android. */
|
|
69
|
+
math?: {
|
|
70
|
+
/**
|
|
71
|
+
* `{latex}` → equation source.
|
|
72
|
+
* @default 'Math: {latex}'
|
|
73
|
+
*/
|
|
74
|
+
equation?: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Labels for the VoiceOver rotor (the secondary jump-by-type navigator on iOS).
|
|
79
|
+
* iOS only — Android has no rotor concept.
|
|
80
|
+
*/
|
|
81
|
+
rotor?: {
|
|
82
|
+
/** @default 'Headings' */
|
|
83
|
+
headings?: string;
|
|
84
|
+
/** @default 'Links' */
|
|
85
|
+
links?: string;
|
|
86
|
+
/** @default 'Images' */
|
|
87
|
+
images?: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Fully-populated counterpart of `AccessibilityLabels` — every leaf field is a
|
|
93
|
+
* concrete string. Produced by `resolveAccessibilityLabels()` and what native
|
|
94
|
+
* code should be wired to consume.
|
|
95
|
+
*/
|
|
96
|
+
export interface ResolvedAccessibilityLabels {
|
|
97
|
+
list: {
|
|
98
|
+
bulletPoint: string;
|
|
99
|
+
nestedBulletPoint: string;
|
|
100
|
+
orderedItem: string;
|
|
101
|
+
nestedOrderedItem: string;
|
|
102
|
+
};
|
|
103
|
+
blockquote: {
|
|
104
|
+
quote: string;
|
|
105
|
+
nestedQuote: string;
|
|
106
|
+
};
|
|
107
|
+
table: {
|
|
108
|
+
row: string;
|
|
109
|
+
};
|
|
110
|
+
math: {
|
|
111
|
+
equation: string;
|
|
112
|
+
};
|
|
113
|
+
rotor: {
|
|
114
|
+
headings: string;
|
|
115
|
+
links: string;
|
|
116
|
+
images: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -155,24 +155,10 @@ interface MathStyle {
|
|
|
155
155
|
marginTop?: number;
|
|
156
156
|
marginBottom?: number;
|
|
157
157
|
textAlign?: 'left' | 'center' | 'right';
|
|
158
|
-
/**
|
|
159
|
-
* Renders math glyphs with KaTeX's bold variant (KaTeX_Main-Bold /
|
|
160
|
-
* KaTeX_Math-BoldItalic). Wraps the LaTeX in `\mathbf{…}` at render time
|
|
161
|
-
* only — raw markdown text is unaffected.
|
|
162
|
-
*
|
|
163
|
-
* Caveat: large operators (`\sum`, `\int`, `\prod`), AMS symbols, Script
|
|
164
|
-
* and Typewriter glyphs have no bold variant in KaTeX and stay at regular
|
|
165
|
-
* weight even when `fontWeight: 'bold'`.
|
|
166
|
-
*
|
|
167
|
-
* @default 'normal'
|
|
168
|
-
*/
|
|
169
|
-
fontWeight?: 'normal' | 'bold';
|
|
170
158
|
}
|
|
171
159
|
|
|
172
160
|
interface InlineMathStyle {
|
|
173
161
|
color?: string;
|
|
174
|
-
/** See {@link MathStyle.fontWeight}. @default 'normal' */
|
|
175
|
-
fontWeight?: 'normal' | 'bold';
|
|
176
162
|
}
|
|
177
163
|
|
|
178
164
|
interface SpoilerParticlesStyle {
|
|
@@ -132,8 +132,6 @@ interface TaskListStyleInternal {
|
|
|
132
132
|
checkedStrikethrough: boolean;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
export type MathFontWeight = 'normal' | 'bold';
|
|
136
|
-
|
|
137
135
|
interface MathStyleInternal {
|
|
138
136
|
fontSize: number;
|
|
139
137
|
color: string;
|
|
@@ -142,12 +140,10 @@ interface MathStyleInternal {
|
|
|
142
140
|
marginTop: number;
|
|
143
141
|
marginBottom: number;
|
|
144
142
|
textAlign: BlockTextAlign;
|
|
145
|
-
fontWeight: MathFontWeight;
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
interface InlineMathStyleInternal {
|
|
149
146
|
color: string;
|
|
150
|
-
fontWeight: MathFontWeight;
|
|
151
147
|
}
|
|
152
148
|
|
|
153
149
|
interface SpoilerParticlesStyleInternal {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ColorValue, ViewProps, ViewStyle, TextStyle } from 'react-native';
|
|
2
2
|
import type { MarkdownStyle, Md4cFlags } from './MarkdownStyle';
|
|
3
|
+
import type { AccessibilityLabels } from './AccessibilityLabels';
|
|
3
4
|
import type {
|
|
4
5
|
LinkPressEvent,
|
|
5
6
|
LinkLongPressEvent,
|
|
@@ -20,17 +21,71 @@ export interface ContextMenuItem {
|
|
|
20
21
|
visible?: boolean;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Plural forms for the "Copy Image URL(s)" action, keyed by CLDR plural
|
|
26
|
+
* category. The right form is chosen at runtime from the number of selected
|
|
27
|
+
* images using `Intl.PluralRules` (resolved against the app's default locale).
|
|
28
|
+
*
|
|
29
|
+
* Each value is a template where the `{count}` token is replaced with the
|
|
30
|
+
* number of selected images. Only `other` is required by CLDR; any category
|
|
31
|
+
* left `undefined` falls back to `other`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Polish: one / few / many / other
|
|
35
|
+
* pluralLabels: {
|
|
36
|
+
* one: 'Kopiuj adres URL obrazu',
|
|
37
|
+
* few: 'Kopiuj adresy URL {count} obrazów',
|
|
38
|
+
* many: 'Kopiuj adresy URL {count} obrazów',
|
|
39
|
+
* other: 'Kopiuj adresy URL {count} obrazu',
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
42
|
+
export interface SelectionMenuPluralLabels {
|
|
43
|
+
/**
|
|
44
|
+
* Required base form. Any category left `undefined` falls back to `other`,
|
|
45
|
+
* so the menu never shows the English default once `pluralLabels` is set.
|
|
46
|
+
*/
|
|
47
|
+
other: string;
|
|
48
|
+
zero?: string;
|
|
49
|
+
one?: string;
|
|
50
|
+
two?: string;
|
|
51
|
+
few?: string;
|
|
52
|
+
many?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Controls the built-in items added to the native text selection menu and
|
|
57
|
+
* lets you localize their labels.
|
|
58
|
+
*
|
|
59
|
+
* Each item accepts an object: `{ enabled }` toggles visibility (the system
|
|
60
|
+
* `copy` item can't be hidden — only relabeled) and `label` overrides the
|
|
61
|
+
* English default. Wire `label` to your i18n library to match the rest of your
|
|
62
|
+
* app's UI. Labels apply to the main text selection menu as well as the table
|
|
63
|
+
* and math block copy menus.
|
|
64
|
+
*
|
|
65
|
+
* @platform ios, android, macos
|
|
66
|
+
*/
|
|
23
67
|
export interface SelectionMenuConfig {
|
|
24
68
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @default
|
|
69
|
+
* The system "Copy" item. It can't be hidden — only its label is configurable.
|
|
70
|
+
* @default { label: "Copy" }
|
|
27
71
|
*/
|
|
28
|
-
|
|
72
|
+
copy?: { label?: string };
|
|
29
73
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @default true
|
|
74
|
+
* The built-in "Copy as Markdown" action for text selections.
|
|
75
|
+
* @default { enabled: true, label: "Copy as Markdown" }
|
|
76
|
+
*/
|
|
77
|
+
copyAsMarkdown?: { enabled?: boolean; label?: string };
|
|
78
|
+
/**
|
|
79
|
+
* The built-in "Copy Image URL" action, shown when the selection contains
|
|
80
|
+
* images. `label` is used for a single image; `pluralLabels` provides the
|
|
81
|
+
* forms for multiple images.
|
|
82
|
+
* @default { enabled: true, label: "Copy Image URL" }
|
|
32
83
|
*/
|
|
33
|
-
copyImageUrl?:
|
|
84
|
+
copyImageUrl?: {
|
|
85
|
+
enabled?: boolean;
|
|
86
|
+
label?: string;
|
|
87
|
+
pluralLabels?: SelectionMenuPluralLabels;
|
|
88
|
+
};
|
|
34
89
|
}
|
|
35
90
|
|
|
36
91
|
export interface StreamingConfig {
|
|
@@ -200,12 +255,22 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
|
|
|
200
255
|
*/
|
|
201
256
|
contextMenuItems?: ContextMenuItem[];
|
|
202
257
|
/**
|
|
203
|
-
* Controls built-in items added to the native text selection menu
|
|
204
|
-
* Custom app-provided actions are controlled
|
|
205
|
-
*
|
|
258
|
+
* Controls the built-in items added to the native text selection menu and
|
|
259
|
+
* lets you localize their labels. Custom app-provided actions are controlled
|
|
260
|
+
* separately with `contextMenuItems`.
|
|
261
|
+
* @default { copyAsMarkdown: { enabled: true }, copyImageUrl: { enabled: true } }
|
|
206
262
|
* @platform ios, android, macos
|
|
207
263
|
*/
|
|
208
264
|
selectionMenuConfig?: SelectionMenuConfig;
|
|
265
|
+
/**
|
|
266
|
+
* Translations for VoiceOver / TalkBack announcements (list items, table
|
|
267
|
+
* rows, math, and the iOS rotor). All keys are optional and fall back to
|
|
268
|
+
* the English defaults from `accessibilityLabelDefaults.ts` — see
|
|
269
|
+
* `AccessibilityLabels` for the placeholder syntax and the no-plural
|
|
270
|
+
* rationale.
|
|
271
|
+
* @platform ios, android
|
|
272
|
+
*/
|
|
273
|
+
accessibilityLabels?: AccessibilityLabels;
|
|
209
274
|
/**
|
|
210
275
|
* Sets the text direction on the root container.
|
|
211
276
|
* Useful for RTL languages — CSS logical properties in the renderers
|
package/android/src/math/java/com/swmansion/enriched/markdown/utils/math/LatexWeightWrapper.kt
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
package com.swmansion.enriched.markdown.utils.math
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Wraps a raw LaTeX expression with the appropriate KaTeX bold command so RaTeX
|
|
5
|
-
* picks up the bold glyph variant (KaTeX_Main-Bold / KaTeX_Math-BoldItalic).
|
|
6
|
-
*
|
|
7
|
-
* Wrap is render-time only — callers must keep the original `latex` string
|
|
8
|
-
* stored on chips/attachments so serialized markdown round-trips cleanly.
|
|
9
|
-
*
|
|
10
|
-
* Caveat: large operators (`\sum`, `\int`, `\prod`), AMS symbols, Script and
|
|
11
|
-
* Typewriter glyphs have no bold variant in the bundled KaTeX fonts and stay
|
|
12
|
-
* at regular weight even when wrapped.
|
|
13
|
-
*/
|
|
14
|
-
object LatexWeightWrapper {
|
|
15
|
-
fun wrap(
|
|
16
|
-
latex: String,
|
|
17
|
-
fontWeight: String,
|
|
18
|
-
): String =
|
|
19
|
-
when (fontWeight) {
|
|
20
|
-
"bold" -> "\\mathbf{$latex}"
|
|
21
|
-
else -> latex
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { withGradleProperties } from '@expo/config-plugins';
|
|
4
|
-
export const withAndroidMath = (config, {
|
|
5
|
-
enableMath = true
|
|
6
|
-
}) => {
|
|
7
|
-
if (enableMath) {
|
|
8
|
-
return config;
|
|
9
|
-
}
|
|
10
|
-
return withGradleProperties(config, gradleConfig => {
|
|
11
|
-
gradleConfig.modResults = gradleConfig.modResults.filter(prop => prop.type !== 'property' || prop.key !== 'enrichedMarkdown.enableMath');
|
|
12
|
-
gradleConfig.modResults.push({
|
|
13
|
-
type: 'property',
|
|
14
|
-
key: 'enrichedMarkdown.enableMath',
|
|
15
|
-
value: 'false'
|
|
16
|
-
});
|
|
17
|
-
return gradleConfig;
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=withAndroidMath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["withGradleProperties","withAndroidMath","config","enableMath","gradleConfig","modResults","filter","prop","type","key","push","value"],"sourceRoot":"../../../src","sources":["plugin/withAndroidMath.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAA2B,sBAAsB;AAE9E,OAAO,MAAMC,eAAuD,GAAGA,CACrEC,MAAM,EACN;EAAEC,UAAU,GAAG;AAAK,CAAC,KAClB;EACH,IAAIA,UAAU,EAAE;IACd,OAAOD,MAAM;EACf;EACA,OAAOF,oBAAoB,CAACE,MAAM,EAAGE,YAAY,IAAK;IACpDA,YAAY,CAACC,UAAU,GAAGD,YAAY,CAACC,UAAU,CAACC,MAAM,CACrDC,IAAI,IACHA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAK,6BAC7C,CAAC;IAEDL,YAAY,CAACC,UAAU,CAACK,IAAI,CAAC;MAC3BF,IAAI,EAAE,UAAU;MAChBC,GAAG,EAAE,6BAA6B;MAClCE,KAAK,EAAE;IACT,CAAC,CAAC;IAEF,OAAOP,YAAY;EACrB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { withDangerousMod } from '@expo/config-plugins';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
const IOS_MATH_OPTION = "ENV['ENRICHED_MARKDOWN_ENABLE_MATH'] = '0'";
|
|
7
|
-
export const withIosMath = (config, {
|
|
8
|
-
enableMath = true
|
|
9
|
-
}) => {
|
|
10
|
-
if (enableMath) {
|
|
11
|
-
return config;
|
|
12
|
-
}
|
|
13
|
-
return withDangerousMod(config, ['ios', async modConfig => {
|
|
14
|
-
const file = path.join(modConfig.modRequest.platformProjectRoot, 'Podfile');
|
|
15
|
-
const contents = fs.readFileSync(file, 'utf8');
|
|
16
|
-
const lines = contents.split('\n');
|
|
17
|
-
const filteredLines = lines.filter(line => !line.includes('ENRICHED_MARKDOWN_ENABLE_MATH'));
|
|
18
|
-
filteredLines.unshift(IOS_MATH_OPTION);
|
|
19
|
-
fs.writeFileSync(file, filteredLines.join('\n'));
|
|
20
|
-
return modConfig;
|
|
21
|
-
}]);
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=withIosMath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["withDangerousMod","fs","path","IOS_MATH_OPTION","withIosMath","config","enableMath","modConfig","file","join","modRequest","platformProjectRoot","contents","readFileSync","lines","split","filteredLines","filter","line","includes","unshift","writeFileSync"],"sourceRoot":"../../../src","sources":["plugin/withIosMath.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAA2B,sBAAsB;AAC1E,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,MAAMC,eAAe,GAAG,4CAA4C;AAEpE,OAAO,MAAMC,WAAmD,GAAGA,CACjEC,MAAM,EACN;EAAEC,UAAU,GAAG;AAAK,CAAC,KAClB;EACH,IAAIA,UAAU,EAAE;IACd,OAAOD,MAAM;EACf;EACA,OAAOL,gBAAgB,CAACK,MAAM,EAAE,CAC9B,KAAK,EACL,MAAOE,SAAS,IAAK;IACnB,MAAMC,IAAI,GAAGN,IAAI,CAACO,IAAI,CACpBF,SAAS,CAACG,UAAU,CAACC,mBAAmB,EACxC,SACF,CAAC;IACD,MAAMC,QAAQ,GAAGX,EAAE,CAACY,YAAY,CAACL,IAAI,EAAE,MAAM,CAAC;IAE9C,MAAMM,KAAK,GAAGF,QAAQ,CAACG,KAAK,CAAC,IAAI,CAAC;IAClC,MAAMC,aAAa,GAAGF,KAAK,CAACG,MAAM,CAC/BC,IAAY,IAAK,CAACA,IAAI,CAACC,QAAQ,CAAC,+BAA+B,CAClE,CAAC;IAEDH,aAAa,CAACI,OAAO,CAACjB,eAAe,CAAC;IAEtCF,EAAE,CAACoB,aAAa,CAACb,IAAI,EAAEQ,aAAa,CAACP,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhD,OAAOF,SAAS;EAClB,CAAC,CACF,CAAC;AACJ,CAAC","ignoreList":[]}
|