@tinglinzh/react-native-markdownview 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/Package.swift +33 -0
  2. package/ios/RNMarkdownView.swift +261 -0
  3. package/ios/RNMarkdownViewComponentView.h +16 -0
  4. package/ios/RNMarkdownViewComponentView.mm +128 -0
  5. package/ios/RNMarkdownViewManager.m +34 -0
  6. package/ios/RNMarkdownViewManager.swift +16 -0
  7. package/ios/react-native-markdownview-Bridging-Header.h +12 -0
  8. package/lib/commonjs/MarkdownView.js +139 -0
  9. package/lib/commonjs/MarkdownView.js.map +1 -0
  10. package/lib/commonjs/NativeMarkdownView.js +22 -0
  11. package/lib/commonjs/NativeMarkdownView.js.map +1 -0
  12. package/lib/commonjs/index.js +13 -0
  13. package/lib/commonjs/index.js.map +1 -0
  14. package/lib/commonjs/package.json +1 -0
  15. package/lib/commonjs/types.js +6 -0
  16. package/lib/commonjs/types.js.map +1 -0
  17. package/lib/module/MarkdownView.js +134 -0
  18. package/lib/module/MarkdownView.js.map +1 -0
  19. package/lib/module/NativeMarkdownView.js +21 -0
  20. package/lib/module/NativeMarkdownView.js.map +1 -0
  21. package/lib/module/index.js +13 -0
  22. package/lib/module/index.js.map +1 -0
  23. package/lib/module/types.js +4 -0
  24. package/lib/module/types.js.map +1 -0
  25. package/lib/typescript/src/MarkdownView.d.ts +25 -0
  26. package/lib/typescript/src/MarkdownView.d.ts.map +1 -0
  27. package/lib/typescript/src/NativeMarkdownView.d.ts +53 -0
  28. package/lib/typescript/src/NativeMarkdownView.d.ts.map +1 -0
  29. package/lib/typescript/src/index.d.ts +12 -0
  30. package/lib/typescript/src/index.d.ts.map +1 -0
  31. package/lib/typescript/src/types.d.ts +126 -0
  32. package/lib/typescript/src/types.d.ts.map +1 -0
  33. package/package.json +67 -0
  34. package/react-native-markdownview.podspec +38 -0
  35. package/src/MarkdownView.tsx +164 -0
  36. package/src/NativeMarkdownView.ts +69 -0
  37. package/src/index.tsx +25 -0
  38. package/src/types.ts +143 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sourceRoot":"../../src","sources":["NativeMarkdownView.ts"],"mappings":";;;;;;AAgBA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAhB7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AA2BA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAoBe,IAAAG,+BAAsB,EACnC,gBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "MarkdownView", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _MarkdownView.MarkdownView;
10
+ }
11
+ });
12
+ var _MarkdownView = require("./MarkdownView");
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_MarkdownView","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;AASA,IAAAA,aAAA,GAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ import React, { useCallback, useRef, useState } from 'react';
4
+ import { Platform, requireNativeComponent, View } from 'react-native';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ // ─── Native component handle ──────────────────────────────────────────────────
7
+
8
+ const COMPONENT_NAME = 'RNMarkdownView';
9
+
10
+ /**
11
+ * Old Architecture – loaded lazily so non-iOS platforms don't throw on import.
12
+ * New Architecture uses the codegen-generated component automatically when
13
+ * RCT_NEW_ARCH_ENABLED is set at build time.
14
+ */
15
+ const NativeMarkdownView = Platform.OS === 'ios' ? requireNativeComponent(COMPONENT_NAME) : null;
16
+
17
+ // ─── Theme serialisation ──────────────────────────────────────────────────────
18
+
19
+ function serializeTheme(theme) {
20
+ if (!theme) return undefined;
21
+ try {
22
+ return JSON.stringify(theme);
23
+ } catch {
24
+ return undefined;
25
+ }
26
+ }
27
+
28
+ // ─── Component ────────────────────────────────────────────────────────────────
29
+
30
+ /**
31
+ * `MarkdownView` renders GitHub Flavored Markdown using Apple's native
32
+ * MarkdownView library (tree-sitter syntax highlighting, LaTeX math,
33
+ * unified diff, VoiceOver). iOS 16+ only.
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * <MarkdownView markdown="# Hello\n\nSome **bold** text." />
38
+ * ```
39
+ *
40
+ * @example Custom theme
41
+ * ```tsx
42
+ * <MarkdownView
43
+ * markdown={content}
44
+ * theme={{
45
+ * colors: { body: '#1a1a1a', codeBackground: '#f5f5f5' },
46
+ * fonts: { bodySize: 16 },
47
+ * }}
48
+ * />
49
+ * ```
50
+ */
51
+ export function MarkdownView({
52
+ markdown,
53
+ theme,
54
+ style,
55
+ onLinkPress,
56
+ onImagePress,
57
+ onLineSelection,
58
+ onContentSizeChange
59
+ }) {
60
+ if (Platform.OS !== 'ios' || NativeMarkdownView === null) {
61
+ if (__DEV__) {
62
+ console.warn('[MarkdownView] Only supported on iOS 16+.');
63
+ }
64
+ return /*#__PURE__*/_jsx(View, {
65
+ style: style
66
+ });
67
+ }
68
+
69
+ // eslint-disable-next-line react-hooks/rules-of-hooks
70
+ return /*#__PURE__*/_jsx(MarkdownViewInner, {
71
+ markdown: markdown,
72
+ theme: theme,
73
+ style: style,
74
+ onLinkPress: onLinkPress,
75
+ onImagePress: onImagePress,
76
+ onLineSelection: onLineSelection,
77
+ onContentSizeChange: onContentSizeChange,
78
+ NativeComponent: NativeMarkdownView
79
+ });
80
+ }
81
+
82
+ // Split out so hooks run unconditionally (Platform.OS is constant at runtime).
83
+
84
+ function MarkdownViewInner({
85
+ markdown,
86
+ theme,
87
+ style,
88
+ onLinkPress,
89
+ onImagePress,
90
+ onLineSelection,
91
+ onContentSizeChange,
92
+ NativeComponent
93
+ }) {
94
+ const [autoHeight, setAutoHeight] = useState(undefined);
95
+ const themeJSONRef = useRef(undefined);
96
+
97
+ // Re-serialize only when theme reference changes.
98
+ themeJSONRef.current = serializeTheme(theme);
99
+ const handleContentSizeChange = useCallback(e => {
100
+ const {
101
+ height
102
+ } = e.nativeEvent.contentSize;
103
+ if (height > 0) setAutoHeight(height);
104
+ onContentSizeChange?.(e);
105
+ }, [onContentSizeChange]);
106
+ const handleLinkPress = useCallback(e => {
107
+ onLinkPress?.(e);
108
+ }, [onLinkPress]);
109
+ const handleImagePress = useCallback(e => {
110
+ onImagePress?.(e);
111
+ }, [onImagePress]);
112
+ const handleLineSelection = useCallback(e => {
113
+ onLineSelection?.(e);
114
+ }, [onLineSelection]);
115
+ return /*#__PURE__*/_jsx(NativeComponent, {
116
+ markdown: markdown,
117
+ themeJSON: themeJSONRef.current,
118
+ style: [autoHeight !== undefined && styles.autoHeight(autoHeight), style],
119
+ onLinkPress: handleLinkPress,
120
+ onImagePress: handleImagePress,
121
+ onLineSelection: handleLineSelection,
122
+ onContentSizeChange: handleContentSizeChange
123
+ });
124
+ }
125
+
126
+ // ─── Styles ───────────────────────────────────────────────────────────────────
127
+
128
+ const styles = {
129
+ /** Applied when the native view has reported its content height. */
130
+ autoHeight: h => ({
131
+ height: h
132
+ })
133
+ };
134
+ //# sourceMappingURL=MarkdownView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useRef","useState","Platform","requireNativeComponent","View","jsx","_jsx","COMPONENT_NAME","NativeMarkdownView","OS","serializeTheme","theme","undefined","JSON","stringify","MarkdownView","markdown","style","onLinkPress","onImagePress","onLineSelection","onContentSizeChange","__DEV__","console","warn","MarkdownViewInner","NativeComponent","autoHeight","setAutoHeight","themeJSONRef","current","handleContentSizeChange","e","height","nativeEvent","contentSize","handleLinkPress","handleImagePress","handleLineSelection","themeJSON","styles","h"],"sourceRoot":"../../src","sources":["MarkdownView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAEEC,QAAQ,EACRC,sBAAsB,EAEtBC,IAAI,QACC,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAUtB;;AAEA,MAAMC,cAAc,GAAG,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAmD,GACvDN,QAAQ,CAACO,EAAE,KAAK,KAAK,GAAGN,sBAAsB,CAACI,cAAc,CAAC,GAAG,IAAI;;AAEvE;;AAEA,SAASG,cAAcA,CAACC,KAA+B,EAAsB;EAC3E,IAAI,CAACA,KAAK,EAAE,OAAOC,SAAS;EAC5B,IAAI;IACF,OAAOC,IAAI,CAACC,SAAS,CAACH,KAAK,CAAC;EAC9B,CAAC,CAAC,MAAM;IACN,OAAOC,SAAS;EAClB;AACF;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,YAAYA,CAAC;EAC3BC,QAAQ;EACRL,KAAK;EACLM,KAAK;EACLC,WAAW;EACXC,YAAY;EACZC,eAAe;EACfC;AACiB,CAAC,EAAE;EACpB,IAAInB,QAAQ,CAACO,EAAE,KAAK,KAAK,IAAID,kBAAkB,KAAK,IAAI,EAAE;IACxD,IAAIc,OAAO,EAAE;MACXC,OAAO,CAACC,IAAI,CA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CAAC,EACD,CAACb,YAAY,CACf,CAAC;EAED,MAAMmB,mBAAmB,GAAGvC,WAAW,CACpCiC,CAA2C,IAAK;IAC/CZ,eAAe,GAAGY,CAAC,CAAC;EACtB,CAAC,EACD,CAACZ,eAAe,CAClB,CAAC;EAED,oBACEd,IAAA,CAACoB,eAAe;IACdV,QAAQ,EAAEA,QAAS;IACnBuB,SAAS,EAAEV,YAAY,CAACC,OAAQ;IAChCb,KAAK,EAAE,CAACU,UAAU,KAAKf,SAAS,IAAI4B,MAAM,CAACb,UAAU,CAACA,UAAU,CAAC,EAAEV,KAAK,CAAE;IAC1EC,WAAW,EAAEkB,eAAgB;IAC7BjB,YAAY,EAAEkB,gBAAiB;IAC/BjB,eAAe,EAAEkB,mBAAoB;IACrCjB,mBAAmB,EAAEU;EAAwB,CAC9C,CAAC;AAEN;;AAEA;;AAEA,MAAMS,MAAM,GAAG;EACb;EACAb,UAAU,EAAGc,CAAS,KAAM;IAAER,MAAM,EAAEQ;EAAE,CAAC;AAC3C,CAAC","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Codegen spec for the New Architecture (Fabric).
5
+ *
6
+ * Running `react-native codegen` (or the build system) reads this file and
7
+ * generates C++ component descriptors, props structs, and event emitters under
8
+ * build/generated/ios/RNMarkdownViewSpec/.
9
+ *
10
+ * All prop/event types must use the codegen-compatible primitives from
11
+ * react-native/Libraries/Types/CodegenTypes.
12
+ */
13
+
14
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
15
+
16
+ // ─── Codegen event payload types ─────────────────────────────────────────────
17
+
18
+ // ─── Native component props ───────────────────────────────────────────────────
19
+
20
+ export default codegenNativeComponent('RNMarkdownView');
21
+ //# sourceMappingURL=NativeMarkdownView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["NativeMarkdownView.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,OAAOA,sBAAsB,MAAM,yDAAyD;;AAG5F;;AA2BA;;AAoBA,eAAeA,sBAAsB,CACnC,gBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * react-native-markdownview
5
+ *
6
+ * Native iOS markdown rendering via MarkdownView (HumanInterfaceDesign).
7
+ * Supports GitHub Flavored Markdown, syntax highlighting (tree-sitter),
8
+ * LaTeX math, unified diffs, and VoiceOver accessibility.
9
+ *
10
+ * Requires iOS 16+. Android is not supported (renders nothing with a DEV warning).
11
+ */
12
+ export { MarkdownView } from './MarkdownView';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MarkdownView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gBAAgB","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import type { MarkdownViewProps } from './types';
3
+ /**
4
+ * `MarkdownView` renders GitHub Flavored Markdown using Apple's native
5
+ * MarkdownView library (tree-sitter syntax highlighting, LaTeX math,
6
+ * unified diff, VoiceOver). iOS 16+ only.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <MarkdownView markdown="# Hello\n\nSome **bold** text." />
11
+ * ```
12
+ *
13
+ * @example Custom theme
14
+ * ```tsx
15
+ * <MarkdownView
16
+ * markdown={content}
17
+ * theme={{
18
+ * colors: { body: '#1a1a1a', codeBackground: '#f5f5f5' },
19
+ * fonts: { bodySize: 16 },
20
+ * }}
21
+ * />
22
+ * ```
23
+ */
24
+ export declare function MarkdownView({ markdown, theme, style, onLinkPress, onImagePress, onLineSelection, onContentSizeChange, }: MarkdownViewProps): React.JSX.Element;
25
+ //# sourceMappingURL=MarkdownView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownView.d.ts","sourceRoot":"","sources":["../../../src/MarkdownView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAQ7D,OAAO,KAAK,EAKV,iBAAiB,EAElB,MAAM,SAAS,CAAC;AA2BjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,GACpB,EAAE,iBAAiB,qBAqBnB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Codegen spec for the New Architecture (Fabric).
3
+ *
4
+ * Running `react-native codegen` (or the build system) reads this file and
5
+ * generates C++ component descriptors, props structs, and event emitters under
6
+ * build/generated/ios/RNMarkdownViewSpec/.
7
+ *
8
+ * All prop/event types must use the codegen-compatible primitives from
9
+ * react-native/Libraries/Types/CodegenTypes.
10
+ */
11
+ import type { ViewProps } from 'react-native';
12
+ import type { DirectEventHandler, Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
13
+ import type { HostComponent } from 'react-native';
14
+ export type OnLinkPressEvent = Readonly<{
15
+ url: string;
16
+ isURL: boolean;
17
+ }>;
18
+ export type OnImagePressEvent = Readonly<{
19
+ source: string;
20
+ }>;
21
+ export type OnLineSelectionEvent = Readonly<{
22
+ startLine: Int32;
23
+ endLine: Int32;
24
+ contents: ReadonlyArray<string>;
25
+ language: string;
26
+ }>;
27
+ export type OnContentSizeChangeContentSize = Readonly<{
28
+ width: Double;
29
+ height: Double;
30
+ }>;
31
+ export type OnContentSizeChangeEvent = Readonly<{
32
+ contentSize: OnContentSizeChangeContentSize;
33
+ }>;
34
+ export interface NativeProps extends ViewProps {
35
+ /** Raw markdown string to render. */
36
+ markdown?: string;
37
+ /**
38
+ * JSON-encoded ThemeOptions object.
39
+ * The JS wrapper serialises the theme object before passing it down.
40
+ */
41
+ themeJSON?: string;
42
+ /** @see LinkPressEvent */
43
+ onLinkPress?: DirectEventHandler<OnLinkPressEvent>;
44
+ /** @see ImagePressEvent */
45
+ onImagePress?: DirectEventHandler<OnImagePressEvent>;
46
+ /** @see LineSelectionEvent */
47
+ onLineSelection?: DirectEventHandler<OnLineSelectionEvent>;
48
+ /** @see ContentSizeChangeEvent */
49
+ onContentSizeChange?: DirectEventHandler<OnContentSizeChangeEvent>;
50
+ }
51
+ declare const _default: HostComponent<NativeProps>;
52
+ export default _default;
53
+ //# sourceMappingURL=NativeMarkdownView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeMarkdownView.d.ts","sourceRoot":"","sources":["../../../src/NativeMarkdownView.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,KAAK,EACN,MAAM,2CAA2C,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CAAC;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,WAAW,EAAE,8BAA8B,CAAC;CAC7C,CAAC,CAAC;AAIH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IACnD,2BAA2B;IAC3B,YAAY,CAAC,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IACrD,8BAA8B;IAC9B,eAAe,CAAC,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;IAC3D,kCAAkC;IAClC,mBAAmB,CAAC,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;CACpE;wBAII,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * react-native-markdownview
3
+ *
4
+ * Native iOS markdown rendering via MarkdownView (HumanInterfaceDesign).
5
+ * Supports GitHub Flavored Markdown, syntax highlighting (tree-sitter),
6
+ * LaTeX math, unified diffs, and VoiceOver accessibility.
7
+ *
8
+ * Requires iOS 16+. Android is not supported (renders nothing with a DEV warning).
9
+ */
10
+ export { MarkdownView } from './MarkdownView';
11
+ export type { MarkdownViewProps, ThemeOptions, ThemeFonts, ThemeColors, ThemeSpacings, ThemeTable, FontScale, HexColor, LinkPressEvent, ImagePressEvent, LineSelectionEvent, ContentSizeChangeEvent, } from './types';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,EACb,UAAU,EACV,SAAS,EACT,QAAQ,EACR,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,126 @@
1
+ import type { StyleProp, ViewStyle, NativeSyntheticEvent } from 'react-native';
2
+ /**
3
+ * Color values accepted by MarkdownView.
4
+ * Accepts CSS-style hex strings: "#RRGGBB", "#RRGGBBAA", "RRGGBB", "RRGGBBAA".
5
+ */
6
+ export type HexColor = string;
7
+ /** Font scale presets that delegate to MarkdownTheme.FontScale on the native side. */
8
+ export type FontScale = 'tiny' | 'small' | 'middle' | 'large' | 'huge';
9
+ export interface ThemeFonts {
10
+ /** Font size for body text. Default: system body size. */
11
+ bodySize?: number;
12
+ /** Font size for code blocks and inline code. Default: bodySize * 0.85. */
13
+ codeSize?: number;
14
+ /** PostScript font name for body text (e.g. "Georgia-Regular"). Empty → system font. */
15
+ bodyName?: string;
16
+ /** PostScript font name for code (e.g. "JetBrainsMono-Regular"). Empty → monospaced system font. */
17
+ codeName?: string;
18
+ }
19
+ export interface ThemeColors {
20
+ /** Body text color. */
21
+ body?: HexColor;
22
+ /** Inline code text color. */
23
+ code?: HexColor;
24
+ /** Background color for code blocks. */
25
+ codeBackground?: HexColor;
26
+ /** Highlight / link color. */
27
+ highlight?: HexColor;
28
+ /** Emphasis / italic color. */
29
+ emphasis?: HexColor;
30
+ /** Text-selection tint color. */
31
+ selectionTint?: HexColor;
32
+ }
33
+ export interface ThemeSpacings {
34
+ /** General inter-block spacing in points. Default: 8. */
35
+ general?: number;
36
+ /** Spacing between list items in points. Default: 8. */
37
+ list?: number;
38
+ /** Final (bottom) padding in points. Default: 16. */
39
+ final?: number;
40
+ /** Table cell padding in points. Default: 32. */
41
+ cell?: number;
42
+ }
43
+ export interface ThemeTable {
44
+ /** Corner radius for table borders. Default: 8. */
45
+ cornerRadius?: number;
46
+ /** Border width in points. Default: 1. */
47
+ borderWidth?: number;
48
+ /** Hex color for table borders. */
49
+ borderColor?: HexColor;
50
+ /** Hex color for the header row background. */
51
+ headerBackgroundColor?: HexColor;
52
+ }
53
+ /**
54
+ * Partial theme override passed as a prop.
55
+ * Unset keys use MarkdownTheme's built-in defaults.
56
+ */
57
+ export interface ThemeOptions {
58
+ fonts?: ThemeFonts;
59
+ colors?: ThemeColors;
60
+ spacings?: ThemeSpacings;
61
+ table?: ThemeTable;
62
+ /**
63
+ * Uniformly scale all fonts by a preset offset.
64
+ * Applied *after* individual font settings.
65
+ */
66
+ fontScale?: FontScale;
67
+ /** Show language/label headers above code blocks. Default: true. */
68
+ showsBlockHeaders?: boolean;
69
+ }
70
+ export interface LinkPressEvent {
71
+ /** The URL string or raw link text. */
72
+ url: string;
73
+ /** true if the link was a valid URL, false if it was a plain string. */
74
+ isURL: boolean;
75
+ }
76
+ export interface ImagePressEvent {
77
+ /** The image source URL string. */
78
+ source: string;
79
+ }
80
+ export interface LineSelectionEvent {
81
+ /** 1-based first selected line. */
82
+ startLine: number;
83
+ /** 1-based last selected line. */
84
+ endLine: number;
85
+ /** Text contents of each selected line. */
86
+ contents: string[];
87
+ /** Programming language of the code block, if known. */
88
+ language?: string;
89
+ }
90
+ export interface ContentSizeChangeEvent {
91
+ contentSize: {
92
+ width: number;
93
+ height: number;
94
+ };
95
+ }
96
+ export interface MarkdownViewProps {
97
+ /** The GitHub Flavored Markdown string to render. */
98
+ markdown: string;
99
+ /**
100
+ * Optional theme overrides.
101
+ * Unspecified fields inherit MarkdownTheme defaults.
102
+ */
103
+ theme?: ThemeOptions;
104
+ /**
105
+ * Style applied to the outer wrapper view.
106
+ * If you don't pass an explicit `height`, the component auto-sizes itself
107
+ * vertically via `onContentSizeChange`.
108
+ */
109
+ style?: StyleProp<ViewStyle>;
110
+ /** Fired when the user taps a link. */
111
+ onLinkPress?: (event: NativeSyntheticEvent<LinkPressEvent>) => void;
112
+ /** Fired when the user taps an inline image. */
113
+ onImagePress?: (event: NativeSyntheticEvent<ImagePressEvent>) => void;
114
+ /**
115
+ * Fired when the user selects line(s) in a code block.
116
+ * Opt-in feature of MarkdownView's line-selection mode.
117
+ */
118
+ onLineSelection?: (event: NativeSyntheticEvent<LineSelectionEvent>) => void;
119
+ /**
120
+ * Fired whenever the intrinsic content height changes.
121
+ * The component uses this internally for auto-sizing; you can also
122
+ * listen to it to sync a parent scroll view.
123
+ */
124
+ onContentSizeChange?: (event: NativeSyntheticEvent<ContentSizeChangeEvent>) => void;
125
+ }
126
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAI/E;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,sFAAsF;AACtF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEvE,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oGAAoG;IACpG,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,uBAAuB;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,wCAAwC;IACxC,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,8BAA8B;IAC9B,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,+BAA+B;IAC/B,QAAQ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,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAID,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,uCAAuC;IACvC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACpE,gDAAgD;IAChD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IACtE;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IAC5E;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,KAAK,IAAI,CAAC;CACrF"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@tinglinzh/react-native-markdownview",
3
+ "version": "0.1.0",
4
+ "description": "React Native wrapper for MarkdownView — native iOS/macOS markdown rendering with GFM, syntax highlighting, LaTeX math, and unified diff support",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./lib/module/index.js",
13
+ "require": "./lib/commonjs/index.js",
14
+ "types": "./lib/typescript/src/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "src",
19
+ "lib",
20
+ "ios",
21
+ "react-native-markdownview.podspec",
22
+ "Package.swift"
23
+ ],
24
+ "scripts": {
25
+ "build": "bob build",
26
+ "prepack": "bob build"
27
+ },
28
+ "keywords": [
29
+ "react-native",
30
+ "ios",
31
+ "markdown",
32
+ "markdownview",
33
+ "github-flavored-markdown",
34
+ "syntax-highlighting",
35
+ "native"
36
+ ],
37
+ "author": "",
38
+ "license": "MIT",
39
+ "peerDependencies": {
40
+ "react": "*",
41
+ "react-native": "*"
42
+ },
43
+ "devDependencies": {
44
+ "@types/react": "^18.3.28",
45
+ "react": "18.3.1",
46
+ "react-native": "0.75.0",
47
+ "react-native-builder-bob": "^0.41.0",
48
+ "typescript": "^5.9.3"
49
+ },
50
+ "codegenConfig": {
51
+ "name": "RNMarkdownViewSpec",
52
+ "type": "components",
53
+ "jsSrcsDir": "src",
54
+ "android": {
55
+ "javaPackageName": "com.markdownview"
56
+ }
57
+ },
58
+ "react-native-builder-bob": {
59
+ "source": "src",
60
+ "output": "lib",
61
+ "targets": [
62
+ "commonjs",
63
+ "module",
64
+ "typescript"
65
+ ]
66
+ }
67
+ }
@@ -0,0 +1,38 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "react-native-markdownview"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package.fetch("repository", {}).fetch("url", "https://github.com/HumanInterfaceDesign/MarkdownView")
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+ s.platforms = { :ios => "16.0" }
13
+ s.source = { :git => "https://github.com/your-org/react-native-markdownview.git", :tag => "#{s.version}" }
14
+
15
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
16
+ s.swift_version = "5.9"
17
+
18
+ # Exposes React Objective-C headers to Swift files inside this pod.
19
+ s.pod_target_xcconfig = {
20
+ "SWIFT_OBJC_BRIDGING_HEADER" => "$(PODS_TARGET_SRCROOT)/ios/react-native-markdownview-Bridging-Header.h",
21
+ # Allow the Swift compiler to find the MarkdownView Swift module when it is
22
+ # added to the host app via SPM (Xcode embeds SPM-built modules here).
23
+ "SWIFT_INCLUDE_PATHS" => "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/PackageFrameworks/**",
24
+ }
25
+
26
+ # ─── Dependencies ───────────────────────────────────────────────────────────
27
+ s.dependency "React-Core"
28
+
29
+ # MarkdownView must be added to the host app as a Swift Package dependency:
30
+ # Xcode → File → Add Package Dependencies
31
+ # https://github.com/HumanInterfaceDesign/MarkdownView
32
+ #
33
+ # If your app uses Swift Package Manager for React Native (RN 0.72+), the
34
+ # Package.swift in this repo declares the dependency automatically.
35
+
36
+ # ─── New Architecture (Fabric) ───────────────────────────────────────────────
37
+ install_modules_dependencies(s)
38
+ end