react-native-nitro-markdown 0.6.2 → 0.7.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 (48) hide show
  1. package/README.md +24 -9
  2. package/android/gradle.properties +2 -2
  3. package/lib/commonjs/headless.js +0 -4
  4. package/lib/commonjs/headless.js.map +1 -1
  5. package/lib/commonjs/index.js.map +1 -1
  6. package/lib/commonjs/markdown.js +0 -1
  7. package/lib/commonjs/markdown.js.map +1 -1
  8. package/lib/commonjs/renderers/image.js +0 -1
  9. package/lib/commonjs/renderers/image.js.map +1 -1
  10. package/lib/commonjs/renderers/link.js +0 -1
  11. package/lib/commonjs/renderers/link.js.map +1 -1
  12. package/lib/commonjs/renderers/math.js +0 -1
  13. package/lib/commonjs/renderers/math.js.map +1 -1
  14. package/lib/module/headless.js +0 -4
  15. package/lib/module/headless.js.map +1 -1
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/markdown.js +0 -1
  18. package/lib/module/markdown.js.map +1 -1
  19. package/lib/module/renderers/image.js +0 -1
  20. package/lib/module/renderers/image.js.map +1 -1
  21. package/lib/module/renderers/link.js +0 -1
  22. package/lib/module/renderers/link.js.map +1 -1
  23. package/lib/module/renderers/math.js +0 -1
  24. package/lib/module/renderers/math.js.map +1 -1
  25. package/lib/typescript/commonjs/headless.d.ts +6 -3
  26. package/lib/typescript/commonjs/headless.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/index.d.ts +1 -1
  28. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/markdown.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -1
  33. package/lib/typescript/module/headless.d.ts +6 -3
  34. package/lib/typescript/module/headless.d.ts.map +1 -1
  35. package/lib/typescript/module/index.d.ts +1 -1
  36. package/lib/typescript/module/index.d.ts.map +1 -1
  37. package/lib/typescript/module/markdown.d.ts.map +1 -1
  38. package/lib/typescript/module/renderers/image.d.ts.map +1 -1
  39. package/lib/typescript/module/renderers/link.d.ts.map +1 -1
  40. package/lib/typescript/module/renderers/math.d.ts.map +1 -1
  41. package/package.json +5 -5
  42. package/react-native-nitro-markdown.podspec +1 -1
  43. package/src/headless.ts +35 -34
  44. package/src/index.ts +8 -1
  45. package/src/markdown.tsx +0 -1
  46. package/src/renderers/image.tsx +0 -1
  47. package/src/renderers/link.tsx +0 -1
  48. package/src/renderers/math.tsx +0 -1
package/src/headless.ts CHANGED
@@ -15,44 +15,49 @@ import type { MarkdownParser, ParserOptions } from "./Markdown.nitro";
15
15
 
16
16
  export type { ParserOptions } from "./Markdown.nitro";
17
17
 
18
+ export type MarkdownNodeType =
19
+ | "document"
20
+ | "heading"
21
+ | "paragraph"
22
+ | "text"
23
+ | "bold"
24
+ | "italic"
25
+ | "strikethrough"
26
+ | "link"
27
+ | "image"
28
+ | "code_inline"
29
+ | "code_block"
30
+ | "blockquote"
31
+ | "horizontal_rule"
32
+ | "line_break"
33
+ | "soft_break"
34
+ | "table"
35
+ | "table_head"
36
+ | "table_body"
37
+ | "table_row"
38
+ | "table_cell"
39
+ | "list"
40
+ | "list_item"
41
+ | "task_list_item"
42
+ | "math_inline"
43
+ | "math_block"
44
+ | "html_block"
45
+ | "html_inline";
46
+
47
+ export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
48
+ export type TableCellAlign = "left" | "center" | "right";
49
+
18
50
  /**
19
51
  * Represents a node in the Markdown AST (Abstract Syntax Tree).
20
52
  * Each node has a type and optional properties depending on the node type.
21
53
  */
22
54
  export type MarkdownNode = {
23
55
  /** The type of markdown element this node represents. Used to decide how to render the node. */
24
- type:
25
- | "document"
26
- | "heading"
27
- | "paragraph"
28
- | "text"
29
- | "bold"
30
- | "italic"
31
- | "strikethrough"
32
- | "link"
33
- | "image"
34
- | "code_inline"
35
- | "code_block"
36
- | "blockquote"
37
- | "horizontal_rule"
38
- | "line_break"
39
- | "soft_break"
40
- | "table"
41
- | "table_head"
42
- | "table_body"
43
- | "table_row"
44
- | "table_cell"
45
- | "list"
46
- | "list_item"
47
- | "task_list_item"
48
- | "math_inline"
49
- | "math_block"
50
- | "html_block"
51
- | "html_inline";
56
+ type: MarkdownNodeType;
52
57
  /** Text content for text, code, and similar nodes. */
53
58
  content?: string;
54
59
  /** Heading level (1-6) for heading nodes. */
55
- level?: number;
60
+ level?: HeadingLevel;
56
61
  /** URL for link and image nodes. */
57
62
  href?: string;
58
63
  /** Title attribute for link and image nodes. */
@@ -70,7 +75,7 @@ export type MarkdownNode = {
70
75
  /** Whether a table cell is part of the header row. */
71
76
  isHeader?: boolean;
72
77
  /** Text alignment for table cells: 'left', 'center', or 'right'. */
73
- align?: string;
78
+ align?: TableCellAlign;
74
79
  /** Source start offset in original markdown text (when provided by native parser). */
75
80
  beg?: number;
76
81
  /** Source end offset in original markdown text (when provided by native parser). */
@@ -86,7 +91,6 @@ const createEmptyDocument = (): MarkdownNode => ({
86
91
 
87
92
  function reportNativeParserFailure(methodName: string, error?: unknown): void {
88
93
  if (__DEV__) {
89
- // eslint-disable-next-line no-console
90
94
  console.error(
91
95
  `[NitroMarkdown] ${methodName}: native parser failed.`,
92
96
  error,
@@ -100,7 +104,6 @@ try {
100
104
  NitroModules.createHybridObject<MarkdownParser>("MarkdownParser");
101
105
  } catch (e) {
102
106
  if (__DEV__) {
103
- // eslint-disable-next-line no-console
104
107
  console.error("[NitroMarkdown] Failed to create native MarkdownParser:", e);
105
108
  }
106
109
  }
@@ -143,7 +146,6 @@ export function parseMarkdown(
143
146
  }
144
147
 
145
148
  if (__DEV__) {
146
- // eslint-disable-next-line no-console
147
149
  console.error(
148
150
  "[NitroMarkdown] parseMarkdown: native parser unavailable — check installation.",
149
151
  );
@@ -175,7 +177,6 @@ export function parseMarkdownWithOptions(
175
177
  }
176
178
 
177
179
  if (__DEV__) {
178
- // eslint-disable-next-line no-console
179
180
  console.error(
180
181
  "[NitroMarkdown] parseMarkdownWithOptions: native parser unavailable — check installation.",
181
182
  );
package/src/index.ts CHANGED
@@ -8,7 +8,14 @@ export {
8
8
  getFlattenedText,
9
9
  stripSourceOffsets,
10
10
  } from "./headless";
11
- export type { MarkdownNode, ParserOptions, MarkdownParser } from "./headless";
11
+ export type {
12
+ MarkdownNode,
13
+ MarkdownNodeType,
14
+ HeadingLevel,
15
+ TableCellAlign,
16
+ ParserOptions,
17
+ MarkdownParser,
18
+ } from "./headless";
12
19
 
13
20
  export { Markdown } from "./markdown";
14
21
  export type {
package/src/markdown.tsx CHANGED
@@ -93,7 +93,6 @@ function safeOnError<P extends string>(
93
93
  );
94
94
  } catch (callbackError) {
95
95
  if (__DEV__) {
96
- // eslint-disable-next-line no-console
97
96
  console.warn(
98
97
  "[NitroMarkdown] onError callback threw an exception:",
99
98
  callbackError,
@@ -150,7 +150,6 @@ export const Image: FC<ImageProps> = ({ url, title, alt, Renderer, style }) => {
150
150
  },
151
151
  (error) => {
152
152
  if (__DEV__) {
153
- // eslint-disable-next-line no-console
154
153
  console.warn(
155
154
  "[NitroMarkdown] Failed to get image dimensions:",
156
155
  error,
@@ -52,7 +52,6 @@ export const Link: FC<LinkProps> = ({ href, children, style }) => {
52
52
  await Linking.openURL(allowedExternalHref);
53
53
  } catch (error) {
54
54
  if (__DEV__) {
55
- // eslint-disable-next-line no-console
56
55
  console.warn("[NitroMarkdown] Link press handler failed:", error);
57
56
  }
58
57
  }
@@ -29,7 +29,6 @@ try {
29
29
  RaTeXViewComponent = ratexModule.RaTeXView ?? null;
30
30
  } catch {
31
31
  if (__DEV__) {
32
- // eslint-disable-next-line no-console
33
32
  console.warn(
34
33
  "[NitroMarkdown] ratex-react-native not found — math will render as plain text.",
35
34
  );