react-native-nitro-markdown 0.3.2 → 0.4.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/README.md +84 -82
- package/cpp/core/MD4CParser.cpp +60 -25
- package/cpp/core/MD4CParser.hpp +13 -1
- package/cpp/md4c/md4c.c +1 -1
- package/lib/commonjs/index.js +0 -22
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/markdown-stream.js +53 -4
- package/lib/commonjs/markdown-stream.js.map +1 -1
- package/lib/commonjs/markdown.js +20 -5
- package/lib/commonjs/markdown.js.map +1 -1
- package/lib/commonjs/renderers/code.js +9 -2
- package/lib/commonjs/renderers/code.js.map +1 -1
- package/lib/commonjs/renderers/heading.js +14 -5
- package/lib/commonjs/renderers/heading.js.map +1 -1
- package/lib/commonjs/renderers/image.js +12 -3
- package/lib/commonjs/renderers/image.js.map +1 -1
- package/lib/commonjs/renderers/link.js +6 -1
- package/lib/commonjs/renderers/link.js.map +1 -1
- package/lib/commonjs/renderers/list.js +32 -8
- package/lib/commonjs/renderers/list.js.map +1 -1
- package/lib/commonjs/renderers/math.js +8 -2
- package/lib/commonjs/renderers/math.js.map +1 -1
- package/lib/commonjs/renderers/table.js +8 -2
- package/lib/commonjs/renderers/table.js.map +1 -1
- package/lib/commonjs/theme.js +47 -84
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/markdown-stream.js +54 -5
- package/lib/module/markdown-stream.js.map +1 -1
- package/lib/module/markdown.js +21 -6
- package/lib/module/markdown.js.map +1 -1
- package/lib/module/renderers/code.js +9 -2
- package/lib/module/renderers/code.js.map +1 -1
- package/lib/module/renderers/heading.js +15 -6
- package/lib/module/renderers/heading.js.map +1 -1
- package/lib/module/renderers/image.js +13 -4
- package/lib/module/renderers/image.js.map +1 -1
- package/lib/module/renderers/link.js +7 -2
- package/lib/module/renderers/link.js.map +1 -1
- package/lib/module/renderers/list.js +33 -9
- package/lib/module/renderers/list.js.map +1 -1
- package/lib/module/renderers/math.js +8 -2
- package/lib/module/renderers/math.js.map +1 -1
- package/lib/module/renderers/table.js +9 -3
- package/lib/module/renderers/table.js.map +1 -1
- package/lib/module/theme.js +46 -83
- package/lib/module/theme.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown-stream.d.ts +16 -0
- package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown.d.ts +2 -2
- package/lib/typescript/commonjs/markdown.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -1
- package/lib/typescript/commonjs/renderers/table.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme.d.ts +3 -4
- package/lib/typescript/commonjs/theme.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/markdown-stream.d.ts +16 -0
- package/lib/typescript/module/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/module/markdown.d.ts +2 -2
- package/lib/typescript/module/markdown.d.ts.map +1 -1
- package/lib/typescript/module/renderers/code.d.ts.map +1 -1
- package/lib/typescript/module/renderers/heading.d.ts.map +1 -1
- package/lib/typescript/module/renderers/image.d.ts.map +1 -1
- package/lib/typescript/module/renderers/link.d.ts.map +1 -1
- package/lib/typescript/module/renderers/list.d.ts.map +1 -1
- package/lib/typescript/module/renderers/math.d.ts.map +1 -1
- package/lib/typescript/module/renderers/table.d.ts.map +1 -1
- package/lib/typescript/module/theme.d.ts +3 -4
- package/lib/typescript/module/theme.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +0 -3
- package/src/markdown-stream.tsx +82 -5
- package/src/markdown.tsx +8 -2
- package/src/renderers/code.tsx +3 -0
- package/src/renderers/heading.tsx +24 -2
- package/src/renderers/image.tsx +4 -0
- package/src/renderers/link.tsx +10 -1
- package/src/renderers/list.tsx +30 -6
- package/src/renderers/math.tsx +2 -0
- package/src/renderers/table.tsx +3 -0
- package/src/theme.ts +51 -88
- package/lib/commonjs/default-markdown-renderer.js +0 -217
- package/lib/commonjs/default-markdown-renderer.js.map +0 -1
- package/lib/module/default-markdown-renderer.js +0 -212
- package/lib/module/default-markdown-renderer.js.map +0 -1
- package/lib/typescript/commonjs/default-markdown-renderer.d.ts +0 -10
- package/lib/typescript/commonjs/default-markdown-renderer.d.ts.map +0 -1
- package/lib/typescript/module/default-markdown-renderer.d.ts +0 -10
- package/lib/typescript/module/default-markdown-renderer.d.ts.map +0 -1
- package/src/default-markdown-renderer.tsx +0 -261
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/renderers/link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/renderers/link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAyB9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhF,UAAU,SAAS;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAoB9B,CAAC;AAEF,UAAU,aAAa;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAwCtC,CAAC;AAEF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAwD9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAoBtB,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAoBtB,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAyDD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAC;AAEF,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA0BxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAwChF,UAAU,kBAAkB;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAYD,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAmLhD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TextStyle, type ViewStyle } from "react-native";
|
|
2
2
|
import type { MarkdownNode } from "./headless";
|
|
3
3
|
export interface MarkdownTheme {
|
|
4
4
|
colors: {
|
|
@@ -45,6 +45,7 @@ export interface MarkdownTheme {
|
|
|
45
45
|
heading: string | undefined;
|
|
46
46
|
mono: string | undefined;
|
|
47
47
|
};
|
|
48
|
+
headingWeight?: TextStyle["fontWeight"];
|
|
48
49
|
borderRadius: {
|
|
49
50
|
s: number;
|
|
50
51
|
m: number;
|
|
@@ -54,12 +55,10 @@ export interface MarkdownTheme {
|
|
|
54
55
|
}
|
|
55
56
|
export declare const defaultMarkdownTheme: MarkdownTheme;
|
|
56
57
|
export type PartialMarkdownTheme = {
|
|
57
|
-
[K in keyof MarkdownTheme]?: K extends "showCodeLanguage" ? MarkdownTheme[K] : Partial<MarkdownTheme[K]
|
|
58
|
+
[K in keyof MarkdownTheme]?: K extends "showCodeLanguage" | "headingWeight" ? MarkdownTheme[K] : MarkdownTheme[K] extends object ? Partial<MarkdownTheme[K]> : MarkdownTheme[K];
|
|
58
59
|
};
|
|
59
60
|
export type NodeStyleOverrides = Partial<Record<MarkdownNode["type"], ViewStyle | TextStyle>>;
|
|
60
61
|
export type StylingStrategy = "opinionated" | "minimal";
|
|
61
62
|
export declare const minimalMarkdownTheme: MarkdownTheme;
|
|
62
|
-
export declare const lightMarkdownTheme: MarkdownTheme;
|
|
63
|
-
export declare const darkMarkdownTheme: MarkdownTheme;
|
|
64
63
|
export declare const mergeThemes: (base: MarkdownTheme, partial?: PartialMarkdownTheme) => MarkdownTheme;
|
|
65
64
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export * from "./headless";
|
|
2
|
-
export { DefaultMarkdownRenderer } from "./default-markdown-renderer";
|
|
3
2
|
export { Markdown } from "./markdown";
|
|
4
3
|
export { MarkdownStream } from "./markdown-stream";
|
|
5
4
|
export { useMarkdownContext, MarkdownContext } from "./MarkdownContext";
|
|
6
5
|
export type { CustomRenderer, CustomRenderers, CustomRendererProps, NodeRendererProps, BaseCustomRendererProps, EnhancedRendererProps, HeadingRendererProps, LinkRendererProps, ImageRendererProps, CodeBlockRendererProps, InlineCodeRendererProps, ListRendererProps, TaskListItemRendererProps, MarkdownContextValue, } from "./MarkdownContext";
|
|
7
|
-
export { defaultMarkdownTheme,
|
|
6
|
+
export { defaultMarkdownTheme, minimalMarkdownTheme, mergeThemes, } from "./theme";
|
|
8
7
|
export type { MarkdownTheme, PartialMarkdownTheme, NodeStyleOverrides, StylingStrategy, } from "./theme";
|
|
9
8
|
export { Heading } from "./renderers/heading";
|
|
10
9
|
export { Paragraph } from "./renderers/paragraph";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxE,YAAY,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -6,6 +6,22 @@ export interface MarkdownStreamProps extends Omit<MarkdownProps, "children"> {
|
|
|
6
6
|
* The active MarkdownSession to stream content from.
|
|
7
7
|
*/
|
|
8
8
|
session: MarkdownSession;
|
|
9
|
+
/**
|
|
10
|
+
* Throttle UI updates to avoid re-rendering on every token.
|
|
11
|
+
* Defaults to 50ms, which keeps UI responsive while streaming.
|
|
12
|
+
*/
|
|
13
|
+
updateIntervalMs?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Update strategy for streaming renders.
|
|
16
|
+
* - "interval": throttle to a fixed interval (default)
|
|
17
|
+
* - "raf": update at most once per animation frame
|
|
18
|
+
*/
|
|
19
|
+
updateStrategy?: "interval" | "raf";
|
|
20
|
+
/**
|
|
21
|
+
* Use React transitions for streaming updates.
|
|
22
|
+
* Useful when you want to prioritize user interactions over stream renders.
|
|
23
|
+
*/
|
|
24
|
+
useTransitionUpdates?: boolean;
|
|
9
25
|
}
|
|
10
26
|
/**
|
|
11
27
|
* A component that renders streaming Markdown from a MarkdownSession.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-stream.d.ts","sourceRoot":"","sources":["../../../src/markdown-stream.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"markdown-stream.d.ts","sourceRoot":"","sources":["../../../src/markdown-stream.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AACf,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC;IAC1E;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;IACpC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAuElD,CAAC"}
|
|
@@ -31,7 +31,7 @@ export interface MarkdownProps {
|
|
|
31
31
|
*/
|
|
32
32
|
renderers?: CustomRenderers;
|
|
33
33
|
/**
|
|
34
|
-
* Custom theme to override default styles.
|
|
34
|
+
* Custom theme tokens to override default styles.
|
|
35
35
|
*/
|
|
36
36
|
theme?: PartialMarkdownTheme;
|
|
37
37
|
/**
|
|
@@ -47,7 +47,7 @@ export interface MarkdownProps {
|
|
|
47
47
|
styles?: NodeStyleOverrides;
|
|
48
48
|
/**
|
|
49
49
|
* Styling strategy for the component.
|
|
50
|
-
* - "opinionated":
|
|
50
|
+
* - "opinionated": Balanced defaults with spacing and neutral colors (default)
|
|
51
51
|
* - "minimal": Bare minimum styling for a clean slate
|
|
52
52
|
*/
|
|
53
53
|
stylingStrategy?: StylingStrategy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAA2B,KAAK,EAAE,EAAY,MAAM,OAAO,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAA2B,KAAK,EAAE,EAAY,MAAM,OAAO,CAAC;AACnE,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAa3B,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE;QACzB,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,YAAY,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,IAAI,CAAC;IACX;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAkEtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/renderers/code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/renderers/code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAsDxC,CAAC;AAEF,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA8B1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../../../src/renderers/heading.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../../../src/renderers/heading.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG1E,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAYD,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAmEpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/renderers/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/renderers/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAmB5D,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAiKhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/renderers/link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/renderers/link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAyB9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/renderers/list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhF,UAAU,SAAS;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAoB9B,CAAC;AAEF,UAAU,aAAa;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAwCtC,CAAC;AAEF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAwD9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAoBtB,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/renderers/math.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAML,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAoBtB,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAyDD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAC;AAEF,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA0BxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAwChF,UAAU,kBAAkB;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAYD,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAmLhD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type TextStyle, type ViewStyle } from "react-native";
|
|
2
2
|
import type { MarkdownNode } from "./headless";
|
|
3
3
|
export interface MarkdownTheme {
|
|
4
4
|
colors: {
|
|
@@ -45,6 +45,7 @@ export interface MarkdownTheme {
|
|
|
45
45
|
heading: string | undefined;
|
|
46
46
|
mono: string | undefined;
|
|
47
47
|
};
|
|
48
|
+
headingWeight?: TextStyle["fontWeight"];
|
|
48
49
|
borderRadius: {
|
|
49
50
|
s: number;
|
|
50
51
|
m: number;
|
|
@@ -54,12 +55,10 @@ export interface MarkdownTheme {
|
|
|
54
55
|
}
|
|
55
56
|
export declare const defaultMarkdownTheme: MarkdownTheme;
|
|
56
57
|
export type PartialMarkdownTheme = {
|
|
57
|
-
[K in keyof MarkdownTheme]?: K extends "showCodeLanguage" ? MarkdownTheme[K] : Partial<MarkdownTheme[K]
|
|
58
|
+
[K in keyof MarkdownTheme]?: K extends "showCodeLanguage" | "headingWeight" ? MarkdownTheme[K] : MarkdownTheme[K] extends object ? Partial<MarkdownTheme[K]> : MarkdownTheme[K];
|
|
58
59
|
};
|
|
59
60
|
export type NodeStyleOverrides = Partial<Record<MarkdownNode["type"], ViewStyle | TextStyle>>;
|
|
60
61
|
export type StylingStrategy = "opinionated" | "minimal";
|
|
61
62
|
export declare const minimalMarkdownTheme: MarkdownTheme;
|
|
62
|
-
export declare const lightMarkdownTheme: MarkdownTheme;
|
|
63
|
-
export declare const darkMarkdownTheme: MarkdownTheme;
|
|
64
63
|
export declare const mergeThemes: (base: MarkdownTheme, partial?: PartialMarkdownTheme) => MarkdownTheme;
|
|
65
64
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "High-performance Markdown parser for React Native using Nitro Modules and md4c",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"registry": "https://registry.npmjs.org/"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@types/react": "^19.2.
|
|
89
|
+
"@types/react": "^19.2.11",
|
|
90
90
|
"@types/react-native": "^0.73.0",
|
|
91
91
|
"react-native-builder-bob": "^0.40.17",
|
|
92
92
|
"react-native-nitro-modules": "*",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./headless";
|
|
2
2
|
|
|
3
|
-
export { DefaultMarkdownRenderer } from "./default-markdown-renderer";
|
|
4
3
|
export { Markdown } from "./markdown";
|
|
5
4
|
export { MarkdownStream } from "./markdown-stream";
|
|
6
5
|
|
|
@@ -24,8 +23,6 @@ export type {
|
|
|
24
23
|
|
|
25
24
|
export {
|
|
26
25
|
defaultMarkdownTheme,
|
|
27
|
-
lightMarkdownTheme,
|
|
28
|
-
darkMarkdownTheme,
|
|
29
26
|
minimalMarkdownTheme,
|
|
30
27
|
mergeThemes,
|
|
31
28
|
} from "./theme";
|
package/src/markdown-stream.tsx
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useState,
|
|
3
|
+
useEffect,
|
|
4
|
+
useRef,
|
|
5
|
+
startTransition,
|
|
6
|
+
type FC,
|
|
7
|
+
} from "react";
|
|
2
8
|
import { Markdown, type MarkdownProps } from "./markdown";
|
|
3
9
|
import type { MarkdownSession } from "./specs/MarkdownSession.nitro";
|
|
4
10
|
|
|
@@ -7,6 +13,22 @@ export interface MarkdownStreamProps extends Omit<MarkdownProps, "children"> {
|
|
|
7
13
|
* The active MarkdownSession to stream content from.
|
|
8
14
|
*/
|
|
9
15
|
session: MarkdownSession;
|
|
16
|
+
/**
|
|
17
|
+
* Throttle UI updates to avoid re-rendering on every token.
|
|
18
|
+
* Defaults to 50ms, which keeps UI responsive while streaming.
|
|
19
|
+
*/
|
|
20
|
+
updateIntervalMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Update strategy for streaming renders.
|
|
23
|
+
* - "interval": throttle to a fixed interval (default)
|
|
24
|
+
* - "raf": update at most once per animation frame
|
|
25
|
+
*/
|
|
26
|
+
updateStrategy?: "interval" | "raf";
|
|
27
|
+
/**
|
|
28
|
+
* Use React transitions for streaming updates.
|
|
29
|
+
* Useful when you want to prioritize user interactions over stream renders.
|
|
30
|
+
*/
|
|
31
|
+
useTransitionUpdates?: boolean;
|
|
10
32
|
}
|
|
11
33
|
|
|
12
34
|
/**
|
|
@@ -15,18 +37,73 @@ export interface MarkdownStreamProps extends Omit<MarkdownProps, "children"> {
|
|
|
15
37
|
*/
|
|
16
38
|
export const MarkdownStream: FC<MarkdownStreamProps> = ({
|
|
17
39
|
session,
|
|
40
|
+
updateIntervalMs = 50,
|
|
41
|
+
updateStrategy = "interval",
|
|
42
|
+
useTransitionUpdates = false,
|
|
18
43
|
...props
|
|
19
44
|
}) => {
|
|
20
45
|
const [text, setText] = useState(() => session.getAllText());
|
|
46
|
+
const pendingUpdateRef = useRef(false);
|
|
47
|
+
const updateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
48
|
+
const rafRef = useRef<number | null>(null);
|
|
49
|
+
const lastEmittedRef = useRef(text);
|
|
21
50
|
|
|
22
51
|
useEffect(() => {
|
|
23
52
|
// Ensure initial state is synced
|
|
24
|
-
|
|
53
|
+
const initialText = session.getAllText();
|
|
54
|
+
setText(initialText);
|
|
55
|
+
lastEmittedRef.current = initialText;
|
|
25
56
|
|
|
26
|
-
|
|
27
|
-
|
|
57
|
+
const flushUpdate = () => {
|
|
58
|
+
updateTimerRef.current = null;
|
|
59
|
+
if (rafRef.current !== null) {
|
|
60
|
+
cancelAnimationFrame(rafRef.current);
|
|
61
|
+
rafRef.current = null;
|
|
62
|
+
}
|
|
63
|
+
if (!pendingUpdateRef.current) return;
|
|
64
|
+
pendingUpdateRef.current = false;
|
|
65
|
+
|
|
66
|
+
const latest = session.getAllText();
|
|
67
|
+
if (latest === lastEmittedRef.current) return;
|
|
68
|
+
lastEmittedRef.current = latest;
|
|
69
|
+
|
|
70
|
+
if (useTransitionUpdates) {
|
|
71
|
+
startTransition(() => setText(latest));
|
|
72
|
+
} else {
|
|
73
|
+
setText(latest);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const scheduleFlush = () => {
|
|
78
|
+
if (updateStrategy === "raf") {
|
|
79
|
+
if (rafRef.current === null) {
|
|
80
|
+
rafRef.current = requestAnimationFrame(flushUpdate);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!updateTimerRef.current) {
|
|
86
|
+
updateTimerRef.current = setTimeout(flushUpdate, updateIntervalMs);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const unsubscribe = session.addListener(() => {
|
|
91
|
+
pendingUpdateRef.current = true;
|
|
92
|
+
scheduleFlush();
|
|
28
93
|
});
|
|
29
|
-
|
|
94
|
+
|
|
95
|
+
return () => {
|
|
96
|
+
unsubscribe();
|
|
97
|
+
if (updateTimerRef.current) {
|
|
98
|
+
clearTimeout(updateTimerRef.current);
|
|
99
|
+
updateTimerRef.current = null;
|
|
100
|
+
}
|
|
101
|
+
if (rafRef.current !== null) {
|
|
102
|
+
cancelAnimationFrame(rafRef.current);
|
|
103
|
+
rafRef.current = null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}, [session, updateIntervalMs, updateStrategy, useTransitionUpdates]);
|
|
30
107
|
|
|
31
108
|
return <Markdown {...props}>{text}</Markdown>;
|
|
32
109
|
};
|
package/src/markdown.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
StyleSheet,
|
|
13
13
|
View,
|
|
14
14
|
Text,
|
|
15
|
+
Platform,
|
|
15
16
|
type StyleProp,
|
|
16
17
|
type ViewStyle,
|
|
17
18
|
} from "react-native";
|
|
@@ -68,7 +69,7 @@ export interface MarkdownProps {
|
|
|
68
69
|
*/
|
|
69
70
|
renderers?: CustomRenderers;
|
|
70
71
|
/**
|
|
71
|
-
* Custom theme to override default styles.
|
|
72
|
+
* Custom theme tokens to override default styles.
|
|
72
73
|
*/
|
|
73
74
|
theme?: PartialMarkdownTheme;
|
|
74
75
|
/**
|
|
@@ -84,7 +85,7 @@ export interface MarkdownProps {
|
|
|
84
85
|
styles?: NodeStyleOverrides;
|
|
85
86
|
/**
|
|
86
87
|
* Styling strategy for the component.
|
|
87
|
-
* - "opinionated":
|
|
88
|
+
* - "opinionated": Balanced defaults with spacing and neutral colors (default)
|
|
88
89
|
* - "minimal": Bare minimum styling for a clean slate
|
|
89
90
|
*/
|
|
90
91
|
stylingStrategy?: StylingStrategy;
|
|
@@ -502,20 +503,25 @@ const createBaseStyles = (theme: MarkdownTheme) =>
|
|
|
502
503
|
color: "#f87171",
|
|
503
504
|
fontSize: 14,
|
|
504
505
|
fontFamily: theme.fontFamilies.mono ?? "monospace",
|
|
506
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
505
507
|
},
|
|
506
508
|
text: {
|
|
507
509
|
color: theme.colors.text,
|
|
508
510
|
fontSize: theme.fontSizes.m,
|
|
509
511
|
lineHeight: theme.fontSizes.m * 1.6,
|
|
510
512
|
fontFamily: theme.fontFamilies.regular,
|
|
513
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
511
514
|
},
|
|
512
515
|
bold: {
|
|
513
516
|
fontWeight: "700",
|
|
517
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
514
518
|
},
|
|
515
519
|
italic: {
|
|
516
520
|
fontStyle: "italic",
|
|
521
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
517
522
|
},
|
|
518
523
|
strikethrough: {
|
|
519
524
|
textDecorationLine: "line-through",
|
|
525
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
520
526
|
},
|
|
521
527
|
});
|
package/src/renderers/code.tsx
CHANGED
|
@@ -47,6 +47,8 @@ export const CodeBlock: FC<CodeBlockProps> = ({
|
|
|
47
47
|
marginBottom: theme.spacing.s,
|
|
48
48
|
textTransform: "uppercase",
|
|
49
49
|
letterSpacing: 0.5,
|
|
50
|
+
fontFamily: theme.fontFamilies.mono,
|
|
51
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
50
52
|
},
|
|
51
53
|
codeBlockText: {
|
|
52
54
|
fontFamily:
|
|
@@ -55,6 +57,7 @@ export const CodeBlock: FC<CodeBlockProps> = ({
|
|
|
55
57
|
fontSize: theme.fontSizes.s,
|
|
56
58
|
color: theme.colors.text,
|
|
57
59
|
lineHeight: theme.fontSizes.s * 1.5,
|
|
60
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
58
61
|
},
|
|
59
62
|
}),
|
|
60
63
|
[theme]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, useMemo, type FC } from "react";
|
|
2
|
-
import { Text, StyleSheet, type TextStyle } from "react-native";
|
|
2
|
+
import { Text, StyleSheet, Platform, type TextStyle } from "react-native";
|
|
3
3
|
import { useMarkdownContext } from "../MarkdownContext";
|
|
4
4
|
|
|
5
5
|
interface HeadingProps {
|
|
@@ -8,17 +8,36 @@ interface HeadingProps {
|
|
|
8
8
|
style?: TextStyle;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
const ANDROID_SYSTEM_FONTS = new Set([
|
|
12
|
+
"sans-serif",
|
|
13
|
+
"sans-serif-medium",
|
|
14
|
+
"sans-serif-light",
|
|
15
|
+
"sans-serif-condensed",
|
|
16
|
+
"sans-serif-thin",
|
|
17
|
+
"serif",
|
|
18
|
+
"monospace",
|
|
19
|
+
]);
|
|
20
|
+
|
|
11
21
|
export const Heading: FC<HeadingProps> = ({ level, children, style }) => {
|
|
12
22
|
const { theme } = useMarkdownContext();
|
|
23
|
+
const headingWeight =
|
|
24
|
+
theme.headingWeight ??
|
|
25
|
+
(Platform.OS === "android" &&
|
|
26
|
+
theme.fontFamilies.heading &&
|
|
27
|
+
!ANDROID_SYSTEM_FONTS.has(theme.fontFamilies.heading)
|
|
28
|
+
? "normal"
|
|
29
|
+
: "700");
|
|
13
30
|
const styles = useMemo(
|
|
14
31
|
() =>
|
|
15
32
|
StyleSheet.create({
|
|
16
33
|
heading: {
|
|
17
34
|
color: theme.colors.heading,
|
|
18
|
-
fontWeight:
|
|
35
|
+
fontWeight: headingWeight,
|
|
19
36
|
marginTop: theme.spacing.xl,
|
|
20
37
|
marginBottom: theme.spacing.m,
|
|
21
38
|
fontFamily: theme.fontFamilies.heading,
|
|
39
|
+
letterSpacing: -0.2,
|
|
40
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
22
41
|
},
|
|
23
42
|
h1: {
|
|
24
43
|
fontSize: theme.fontSizes.h1,
|
|
@@ -26,14 +45,17 @@ export const Heading: FC<HeadingProps> = ({ level, children, style }) => {
|
|
|
26
45
|
borderBottomWidth: 1,
|
|
27
46
|
borderBottomColor: theme.colors.border,
|
|
28
47
|
paddingBottom: theme.spacing.s,
|
|
48
|
+
letterSpacing: -0.6,
|
|
29
49
|
},
|
|
30
50
|
h2: {
|
|
31
51
|
fontSize: theme.fontSizes.h2,
|
|
32
52
|
lineHeight: theme.fontSizes.h2 * 1.3,
|
|
53
|
+
letterSpacing: -0.4,
|
|
33
54
|
},
|
|
34
55
|
h3: {
|
|
35
56
|
fontSize: theme.fontSizes.h3,
|
|
36
57
|
lineHeight: theme.fontSizes.h3 * 1.3,
|
|
58
|
+
letterSpacing: -0.2,
|
|
37
59
|
},
|
|
38
60
|
h4: {
|
|
39
61
|
fontSize: theme.fontSizes.h4,
|
package/src/renderers/image.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
Text,
|
|
13
13
|
Image as RNImage,
|
|
14
14
|
StyleSheet,
|
|
15
|
+
Platform,
|
|
15
16
|
type ViewStyle,
|
|
16
17
|
} from "react-native";
|
|
17
18
|
|
|
@@ -82,6 +83,7 @@ export const Image: FC<ImageProps> = ({ url, title, alt, Renderer, style }) => {
|
|
|
82
83
|
color: theme.colors.textMuted,
|
|
83
84
|
fontSize: theme.fontSizes.s,
|
|
84
85
|
fontFamily: theme.fontFamilies.regular,
|
|
86
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
85
87
|
},
|
|
86
88
|
imageError: {
|
|
87
89
|
width: "100%",
|
|
@@ -95,6 +97,7 @@ export const Image: FC<ImageProps> = ({ url, title, alt, Renderer, style }) => {
|
|
|
95
97
|
color: theme.colors.textMuted,
|
|
96
98
|
fontSize: theme.fontSizes.s,
|
|
97
99
|
fontFamily: theme.fontFamilies.regular,
|
|
100
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
98
101
|
},
|
|
99
102
|
imageCaption: {
|
|
100
103
|
color: theme.colors.textMuted,
|
|
@@ -103,6 +106,7 @@ export const Image: FC<ImageProps> = ({ url, title, alt, Renderer, style }) => {
|
|
|
103
106
|
fontStyle: "italic",
|
|
104
107
|
textAlign: "center",
|
|
105
108
|
fontFamily: theme.fontFamilies.regular,
|
|
109
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
106
110
|
},
|
|
107
111
|
}),
|
|
108
112
|
[theme, aspectRatio],
|
package/src/renderers/link.tsx
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ReactNode, useMemo, type FC } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Text,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
Linking,
|
|
6
|
+
Platform,
|
|
7
|
+
type TextStyle,
|
|
8
|
+
} from "react-native";
|
|
3
9
|
import { useMarkdownContext } from "../MarkdownContext";
|
|
4
10
|
|
|
5
11
|
interface LinkProps {
|
|
@@ -16,6 +22,9 @@ export const Link: FC<LinkProps> = ({ href, children, style }) => {
|
|
|
16
22
|
link: {
|
|
17
23
|
color: theme.colors.link,
|
|
18
24
|
textDecorationLine: "underline",
|
|
25
|
+
textDecorationColor: theme.colors.link,
|
|
26
|
+
fontFamily: theme.fontFamilies.regular,
|
|
27
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
19
28
|
},
|
|
20
29
|
}),
|
|
21
30
|
[theme]
|
package/src/renderers/list.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, useMemo, type FC } from "react";
|
|
2
|
-
import { View, Text, StyleSheet, type ViewStyle } from "react-native";
|
|
2
|
+
import { View, Text, StyleSheet, Platform, type ViewStyle } from "react-native";
|
|
3
3
|
import { useMarkdownContext } from "../MarkdownContext";
|
|
4
4
|
|
|
5
5
|
interface ListProps {
|
|
@@ -61,9 +61,10 @@ export const ListItem: FC<ListItemProps> = ({
|
|
|
61
61
|
fontSize: theme.fontSizes.m,
|
|
62
62
|
lineHeight: theme.fontSizes.m * 1.6,
|
|
63
63
|
marginRight: theme.spacing.s,
|
|
64
|
-
minWidth:
|
|
64
|
+
minWidth: 22,
|
|
65
65
|
textAlign: "center",
|
|
66
66
|
fontFamily: theme.fontFamilies.regular,
|
|
67
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
67
68
|
},
|
|
68
69
|
listItemContent: {
|
|
69
70
|
flex: 1,
|
|
@@ -102,10 +103,26 @@ export const TaskListItem: FC<TaskListItemProps> = ({
|
|
|
102
103
|
marginBottom: theme.spacing.s,
|
|
103
104
|
},
|
|
104
105
|
taskCheckbox: {
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
width: 18,
|
|
107
|
+
height: 18,
|
|
108
|
+
borderRadius: 4,
|
|
109
|
+
borderWidth: 2,
|
|
110
|
+
borderColor: theme.colors.accent,
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
justifyContent: "center",
|
|
107
113
|
marginRight: theme.spacing.s,
|
|
108
|
-
|
|
114
|
+
marginTop: 2,
|
|
115
|
+
},
|
|
116
|
+
taskCheckboxChecked: {
|
|
117
|
+
backgroundColor: theme.colors.accent,
|
|
118
|
+
},
|
|
119
|
+
taskCheckboxText: {
|
|
120
|
+
color: theme.colors.surface,
|
|
121
|
+
fontSize: 12,
|
|
122
|
+
lineHeight: 12,
|
|
123
|
+
fontWeight: "700",
|
|
124
|
+
fontFamily: theme.fontFamilies.regular,
|
|
125
|
+
...(Platform.OS === "android" && { includeFontPadding: false }),
|
|
109
126
|
},
|
|
110
127
|
taskContent: {
|
|
111
128
|
flex: 1,
|
|
@@ -116,7 +133,14 @@ export const TaskListItem: FC<TaskListItemProps> = ({
|
|
|
116
133
|
);
|
|
117
134
|
return (
|
|
118
135
|
<View style={[styles.taskListItem, style]}>
|
|
119
|
-
<
|
|
136
|
+
<View
|
|
137
|
+
style={[
|
|
138
|
+
styles.taskCheckbox,
|
|
139
|
+
checked && styles.taskCheckboxChecked,
|
|
140
|
+
]}
|
|
141
|
+
>
|
|
142
|
+
{checked && <Text style={styles.taskCheckboxText}>✓</Text>}
|
|
143
|
+
</View>
|
|
120
144
|
<View style={styles.taskContent}>{children}</View>
|
|
121
145
|
</View>
|
|
122
146
|
);
|