react-native-nitro-markdown 0.4.3 → 0.5.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 +417 -25
- package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +46 -8
- package/android/src/main/java/com/nitromarkdown/NitroMarkdownPackage.kt +2 -1
- package/cpp/bindings/HybridMarkdownParser.cpp +216 -66
- package/cpp/bindings/HybridMarkdownParser.hpp +2 -0
- package/ios/HybridMarkdownSession.swift +51 -7
- package/lib/commonjs/MarkdownContext.js.map +1 -1
- package/lib/commonjs/headless.js +61 -5
- package/lib/commonjs/headless.js.map +1 -1
- package/lib/commonjs/index.js +9 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/markdown-stream.js +107 -13
- package/lib/commonjs/markdown-stream.js.map +1 -1
- package/lib/commonjs/markdown.js +191 -26
- package/lib/commonjs/markdown.js.map +1 -1
- package/lib/commonjs/renderers/code.js +21 -2
- package/lib/commonjs/renderers/code.js.map +1 -1
- package/lib/commonjs/renderers/table/cell-content.js +32 -0
- package/lib/commonjs/renderers/table/cell-content.js.map +1 -0
- package/lib/commonjs/renderers/table/index.js +310 -0
- package/lib/commonjs/renderers/table/index.js.map +1 -0
- package/lib/commonjs/renderers/table/table-reducer.js +29 -0
- package/lib/commonjs/renderers/table/table-reducer.js.map +1 -0
- package/lib/commonjs/renderers/table/table-utils.js +68 -0
- package/lib/commonjs/renderers/table/table-utils.js.map +1 -0
- package/lib/commonjs/renderers/table/types.js +6 -0
- package/lib/commonjs/renderers/table/types.js.map +1 -0
- package/lib/commonjs/renderers/table.js +6 -306
- package/lib/commonjs/renderers/table.js.map +1 -1
- package/lib/commonjs/theme.js +10 -1
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/commonjs/use-markdown-stream.js +9 -1
- package/lib/commonjs/use-markdown-stream.js.map +1 -1
- package/lib/commonjs/utils/code-highlight.js +101 -0
- package/lib/commonjs/utils/code-highlight.js.map +1 -0
- package/lib/commonjs/utils/incremental-ast.js +153 -0
- package/lib/commonjs/utils/incremental-ast.js.map +1 -0
- package/lib/module/MarkdownContext.js.map +1 -1
- package/lib/module/headless.js +56 -4
- package/lib/module/headless.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/markdown-stream.js +108 -14
- package/lib/module/markdown-stream.js.map +1 -1
- package/lib/module/markdown.js +193 -28
- package/lib/module/markdown.js.map +1 -1
- package/lib/module/renderers/code.js +21 -2
- package/lib/module/renderers/code.js.map +1 -1
- package/lib/module/renderers/table/cell-content.js +27 -0
- package/lib/module/renderers/table/cell-content.js.map +1 -0
- package/lib/module/renderers/table/index.js +305 -0
- package/lib/module/renderers/table/index.js.map +1 -0
- package/lib/module/renderers/table/table-reducer.js +24 -0
- package/lib/module/renderers/table/table-reducer.js.map +1 -0
- package/lib/module/renderers/table/table-utils.js +62 -0
- package/lib/module/renderers/table/table-utils.js.map +1 -0
- package/lib/module/renderers/table/types.js +4 -0
- package/lib/module/renderers/table/types.js.map +1 -0
- package/lib/module/renderers/table.js +1 -305
- package/lib/module/renderers/table.js.map +1 -1
- package/lib/module/theme.js +10 -1
- package/lib/module/theme.js.map +1 -1
- package/lib/module/use-markdown-stream.js +9 -1
- package/lib/module/use-markdown-stream.js.map +1 -1
- package/lib/module/utils/code-highlight.js +97 -0
- package/lib/module/utils/code-highlight.js.map +1 -0
- package/lib/module/utils/incremental-ast.js +147 -0
- package/lib/module/utils/incremental-ast.js.map +1 -0
- package/lib/typescript/commonjs/Markdown.nitro.d.ts +2 -0
- package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/MarkdownContext.d.ts +6 -0
- package/lib/typescript/commonjs/MarkdownContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/headless.d.ts +18 -0
- package/lib/typescript/commonjs/headless.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown-stream.d.ts +6 -1
- package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/commonjs/markdown.d.ts +77 -1
- 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/table/cell-content.d.ts +15 -0
- package/lib/typescript/commonjs/renderers/table/cell-content.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table/index.d.ts +11 -0
- package/lib/typescript/commonjs/renderers/table/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table/table-reducer.d.ts +5 -0
- package/lib/typescript/commonjs/renderers/table/table-reducer.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table/table-utils.d.ts +10 -0
- package/lib/typescript/commonjs/renderers/table/table-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table/types.d.ts +24 -0
- package/lib/typescript/commonjs/renderers/table/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table.d.ts +1 -11
- package/lib/typescript/commonjs/renderers/table.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts +14 -2
- package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme.d.ts +18 -2
- package/lib/typescript/commonjs/theme.d.ts.map +1 -1
- package/lib/typescript/commonjs/use-markdown-stream.d.ts +4 -0
- package/lib/typescript/commonjs/use-markdown-stream.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/code-highlight.d.ts +8 -0
- package/lib/typescript/commonjs/utils/code-highlight.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/incremental-ast.d.ts +12 -0
- package/lib/typescript/commonjs/utils/incremental-ast.d.ts.map +1 -0
- package/lib/typescript/module/Markdown.nitro.d.ts +2 -0
- package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -1
- package/lib/typescript/module/MarkdownContext.d.ts +6 -0
- package/lib/typescript/module/MarkdownContext.d.ts.map +1 -1
- package/lib/typescript/module/headless.d.ts +18 -0
- package/lib/typescript/module/headless.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/markdown-stream.d.ts +6 -1
- package/lib/typescript/module/markdown-stream.d.ts.map +1 -1
- package/lib/typescript/module/markdown.d.ts +77 -1
- 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/table/cell-content.d.ts +15 -0
- package/lib/typescript/module/renderers/table/cell-content.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table/index.d.ts +11 -0
- package/lib/typescript/module/renderers/table/index.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table/table-reducer.d.ts +5 -0
- package/lib/typescript/module/renderers/table/table-reducer.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table/table-utils.d.ts +10 -0
- package/lib/typescript/module/renderers/table/table-utils.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table/types.d.ts +24 -0
- package/lib/typescript/module/renderers/table/types.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table.d.ts +1 -11
- package/lib/typescript/module/renderers/table.d.ts.map +1 -1
- package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts +14 -2
- package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts.map +1 -1
- package/lib/typescript/module/theme.d.ts +18 -2
- package/lib/typescript/module/theme.d.ts.map +1 -1
- package/lib/typescript/module/use-markdown-stream.d.ts +4 -0
- package/lib/typescript/module/use-markdown-stream.d.ts.map +1 -1
- package/lib/typescript/module/utils/code-highlight.d.ts +8 -0
- package/lib/typescript/module/utils/code-highlight.d.ts.map +1 -0
- package/lib/typescript/module/utils/incremental-ast.d.ts +12 -0
- package/lib/typescript/module/utils/incremental-ast.d.ts.map +1 -0
- package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +38 -26
- package/nitrogen/generated/android/NitroMarkdownOnLoad.hpp +13 -4
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.cpp +49 -34
- package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +25 -24
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/Func_void_double_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec.kt +34 -21
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.hpp +31 -0
- package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.hpp +34 -2
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec.swift +6 -2
- package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec_cxx.swift +57 -9
- package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.hpp +6 -2
- package/package.json +9 -5
- package/react-native-nitro-markdown.podspec +1 -1
- package/src/Markdown.nitro.ts +2 -0
- package/src/MarkdownContext.ts +6 -0
- package/src/headless.ts +54 -4
- package/src/index.ts +10 -0
- package/src/markdown-stream.tsx +163 -15
- package/src/markdown.tsx +381 -26
- package/src/renderers/code.tsx +32 -3
- package/src/renderers/table/cell-content.tsx +38 -0
- package/src/renderers/table/index.tsx +419 -0
- package/src/renderers/table/table-reducer.ts +36 -0
- package/src/renderers/table/table-utils.ts +81 -0
- package/src/renderers/table/types.ts +24 -0
- package/src/renderers/table.tsx +1 -401
- package/src/specs/MarkdownSession.nitro.ts +16 -2
- package/src/theme.ts +29 -1
- package/src/use-markdown-stream.ts +10 -0
- package/src/utils/code-highlight.ts +102 -0
- package/src/utils/incremental-ast.ts +224 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { parseMarkdown, parseMarkdownWithOptions } from "../headless.js";
|
|
4
|
+
const PLAIN_TEXT_APPEND_PATTERN = /[`*_~[\]#!<>()|$\n\r]/;
|
|
5
|
+
const FENCE_LINE_PATTERN = /^ {0,3}(```+|~~~+)/;
|
|
6
|
+
const parseAst = (text, options) => {
|
|
7
|
+
if (options) {
|
|
8
|
+
return parseMarkdownWithOptions(text, options);
|
|
9
|
+
}
|
|
10
|
+
return parseMarkdown(text);
|
|
11
|
+
};
|
|
12
|
+
const isInsideFencedCodeBlock = text => {
|
|
13
|
+
const lines = text.split(/\r?\n/);
|
|
14
|
+
let openFenceChar = null;
|
|
15
|
+
let openFenceLength = 0;
|
|
16
|
+
for (const line of lines) {
|
|
17
|
+
const fenceMatch = line.match(FENCE_LINE_PATTERN);
|
|
18
|
+
if (!fenceMatch) continue;
|
|
19
|
+
const marker = fenceMatch[1];
|
|
20
|
+
const markerChar = marker[0];
|
|
21
|
+
const markerLength = marker.length;
|
|
22
|
+
if (!openFenceChar) {
|
|
23
|
+
openFenceChar = markerChar;
|
|
24
|
+
openFenceLength = markerLength;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (markerChar === openFenceChar && markerLength >= openFenceLength) {
|
|
28
|
+
openFenceChar = null;
|
|
29
|
+
openFenceLength = 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return openFenceChar !== null;
|
|
33
|
+
};
|
|
34
|
+
const containsFenceLine = text => {
|
|
35
|
+
return text.split(/\r?\n/).some(line => FENCE_LINE_PATTERN.test(line));
|
|
36
|
+
};
|
|
37
|
+
const getTrailingLine = text => {
|
|
38
|
+
const lastLineBreak = Math.max(text.lastIndexOf("\n"), text.lastIndexOf("\r"));
|
|
39
|
+
if (lastLineBreak === -1) return text;
|
|
40
|
+
return text.slice(lastLineBreak + 1);
|
|
41
|
+
};
|
|
42
|
+
const getLeadingLine = text => {
|
|
43
|
+
const newlineIndex = text.indexOf("\n");
|
|
44
|
+
const carriageReturnIndex = text.indexOf("\r");
|
|
45
|
+
const hasNewline = newlineIndex !== -1;
|
|
46
|
+
const hasCarriageReturn = carriageReturnIndex !== -1;
|
|
47
|
+
if (!hasNewline && !hasCarriageReturn) return text;
|
|
48
|
+
if (!hasNewline) return text.slice(0, carriageReturnIndex);
|
|
49
|
+
if (!hasCarriageReturn) return text.slice(0, newlineIndex);
|
|
50
|
+
return text.slice(0, Math.min(newlineIndex, carriageReturnIndex));
|
|
51
|
+
};
|
|
52
|
+
const hasSplitFenceBoundary = (previousText, appendedChunk) => {
|
|
53
|
+
if (appendedChunk.length === 0) return false;
|
|
54
|
+
const candidateLine = `${getTrailingLine(previousText)}${getLeadingLine(appendedChunk)}`;
|
|
55
|
+
if (candidateLine.length === 0) return false;
|
|
56
|
+
return FENCE_LINE_PATTERN.test(candidateLine);
|
|
57
|
+
};
|
|
58
|
+
const findTrailingLeafPath = (node, path = []) => {
|
|
59
|
+
const children = node.children;
|
|
60
|
+
if (!children || children.length === 0) {
|
|
61
|
+
return path;
|
|
62
|
+
}
|
|
63
|
+
const lastIndex = children.length - 1;
|
|
64
|
+
return findTrailingLeafPath(children[lastIndex], [...path, lastIndex]);
|
|
65
|
+
};
|
|
66
|
+
const getNodeAtPath = (node, path) => {
|
|
67
|
+
let current = node;
|
|
68
|
+
for (const index of path) {
|
|
69
|
+
const child = current.children?.[index];
|
|
70
|
+
if (!child) return null;
|
|
71
|
+
current = child;
|
|
72
|
+
}
|
|
73
|
+
return current;
|
|
74
|
+
};
|
|
75
|
+
const appendPlainTextToAst = (ast, appendedChunk, previousTextLength) => {
|
|
76
|
+
if (appendedChunk.length === 0) return ast;
|
|
77
|
+
const path = findTrailingLeafPath(ast);
|
|
78
|
+
const leaf = getNodeAtPath(ast, path);
|
|
79
|
+
if (leaf?.type !== "text") return null;
|
|
80
|
+
if (typeof leaf.end !== "number" || leaf.end !== previousTextLength) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const delta = appendedChunk.length;
|
|
84
|
+
const update = (node, depth) => {
|
|
85
|
+
if (depth === path.length) {
|
|
86
|
+
return {
|
|
87
|
+
...node,
|
|
88
|
+
content: (node.content ?? "") + appendedChunk,
|
|
89
|
+
end: typeof node.end === "number" ? node.end + delta : node.end
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const childIndex = path[depth];
|
|
93
|
+
const children = node.children?.map((child, index) => index === childIndex ? update(child, depth + 1) : child);
|
|
94
|
+
return {
|
|
95
|
+
...node,
|
|
96
|
+
end: typeof node.end === "number" ? node.end + delta : node.end,
|
|
97
|
+
children
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
return update(ast, 0);
|
|
101
|
+
};
|
|
102
|
+
const endsAtBlockBoundary = text => {
|
|
103
|
+
return text.endsWith("\n") || text.endsWith("\r");
|
|
104
|
+
};
|
|
105
|
+
export const getNextStreamAst = ({
|
|
106
|
+
allowIncremental = true,
|
|
107
|
+
nextText,
|
|
108
|
+
options,
|
|
109
|
+
previousAst,
|
|
110
|
+
previousText
|
|
111
|
+
}) => {
|
|
112
|
+
if (!allowIncremental || !nextText.startsWith(previousText)) {
|
|
113
|
+
return parseAst(nextText, options);
|
|
114
|
+
}
|
|
115
|
+
const appendedChunk = nextText.slice(previousText.length);
|
|
116
|
+
if (appendedChunk.length === 0) {
|
|
117
|
+
return previousAst;
|
|
118
|
+
}
|
|
119
|
+
const insideFencedCodeBlock = isInsideFencedCodeBlock(previousText);
|
|
120
|
+
const hasFenceBoundary = containsFenceLine(appendedChunk) || hasSplitFenceBoundary(previousText, appendedChunk);
|
|
121
|
+
if (insideFencedCodeBlock && !hasFenceBoundary) {
|
|
122
|
+
const fencedTextAppendAst = appendPlainTextToAst(previousAst, appendedChunk, previousText.length);
|
|
123
|
+
if (fencedTextAppendAst) {
|
|
124
|
+
return fencedTextAppendAst;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (!PLAIN_TEXT_APPEND_PATTERN.test(appendedChunk)) {
|
|
128
|
+
if (endsAtBlockBoundary(previousText)) {
|
|
129
|
+
return parseAst(nextText, options);
|
|
130
|
+
}
|
|
131
|
+
const textAppendedAst = appendPlainTextToAst(previousAst, appendedChunk, previousText.length);
|
|
132
|
+
if (textAppendedAst) {
|
|
133
|
+
return textAppendedAst;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (insideFencedCodeBlock) {
|
|
137
|
+
return parseAst(nextText, options);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Correctness-first fallback: full reparse for all non-trivial appends.
|
|
141
|
+
// Incremental append is only used for plain text chunks at the true trailing leaf.
|
|
142
|
+
return parseAst(nextText, options);
|
|
143
|
+
};
|
|
144
|
+
export const parseMarkdownAst = (text, options) => {
|
|
145
|
+
return parseAst(text, options);
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=incremental-ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseMarkdown","parseMarkdownWithOptions","PLAIN_TEXT_APPEND_PATTERN","FENCE_LINE_PATTERN","parseAst","text","options","isInsideFencedCodeBlock","lines","split","openFenceChar","openFenceLength","line","fenceMatch","match","marker","markerChar","markerLength","length","containsFenceLine","some","test","getTrailingLine","lastLineBreak","Math","max","lastIndexOf","slice","getLeadingLine","newlineIndex","indexOf","carriageReturnIndex","hasNewline","hasCarriageReturn","min","hasSplitFenceBoundary","previousText","appendedChunk","candidateLine","findTrailingLeafPath","node","path","children","lastIndex","getNodeAtPath","current","index","child","appendPlainTextToAst","ast","previousTextLength","leaf","type","end","delta","update","depth","content","childIndex","map","endsAtBlockBoundary","endsWith","getNextStreamAst","allowIncremental","nextText","previousAst","startsWith","insideFencedCodeBlock","hasFenceBoundary","fencedTextAppendAst","textAppendedAst","parseMarkdownAst"],"sourceRoot":"../../../src","sources":["utils/incremental-ast.ts"],"mappings":";;AAAA,SACEA,aAAa,EACbC,wBAAwB,QAEnB,gBAAa;AAGpB,MAAMC,yBAAyB,GAAG,uBAAuB;AACzD,MAAMC,kBAAkB,GAAG,oBAAoB;AAE/C,MAAMC,QAAQ,GAAGA,CAACC,IAAY,EAAEC,OAAuB,KAAmB;EACxE,IAAIA,OAAO,EAAE;IACX,OAAOL,wBAAwB,CAACI,IAAI,EAAEC,OAAO,CAAC;EAChD;EACA,OAAON,aAAa,CAACK,IAAI,CAAC;AAC5B,CAAC;AAED,MAAME,uBAAuB,GAAIF,IAAY,IAAc;EACzD,MAAMG,KAAK,GAAGH,IAAI,CAACI,KAAK,CAAC,OAAO,CAAC;EACjC,IAAIC,aAA+B,GAAG,IAAI;EAC1C,IAAIC,eAAe,GAAG,CAAC;EAEvB,KAAK,MAAMC,IAAI,IAAIJ,KAAK,EAAE;IACxB,MAAMK,UAAU,GAAGD,IAAI,CAACE,KAAK,CAACX,kBAAkB,CAAC;IACjD,IAAI,CAACU,UAAU,EAAE;IAEjB,MAAME,MAAM,GAAGF,UAAU,CAAC,CAAC,CAAC;IAC5B,MAAMG,UAAU,GAAGD,MAAM,CAAC,CAAC,CAAc;IACzC,MAAME,YAAY,GAAGF,MAAM,CAACG,MAAM;IAElC,IAAI,CAACR,aAAa,EAAE;MAClBA,aAAa,GAAGM,UAAU;MAC1BL,eAAe,GAAGM,YAAY;MAC9B;IACF;IAEA,IAAID,UAAU,KAAKN,aAAa,IAAIO,YAAY,IAAIN,eAAe,EAAE;MACnED,aAAa,GAAG,IAAI;MACpBC,eAAe,GAAG,CAAC;IACrB;EACF;EAEA,OAAOD,aAAa,KAAK,IAAI;AAC/B,CAAC;AAED,MAAMS,iBAAiB,GAAId,IAAY,IAAc;EACnD,OAAOA,IAA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CAAC;AACpC,CAAC;AAED,OAAO,MAAMiE,gBAAgB,GAAGA,CAC9BlE,IAAY,EACZC,OAAuB,KACN;EACjB,OAAOF,QAAQ,CAACC,IAAI,EAAEC,OAAO,CAAC;AAChC,CAAC","ignoreList":[]}
|
|
@@ -9,5 +9,7 @@ export interface MarkdownParser extends HybridObject<{
|
|
|
9
9
|
}> {
|
|
10
10
|
parse(text: string): string;
|
|
11
11
|
parseWithOptions(text: string, options: ParserOptions): string;
|
|
12
|
+
extractPlainText(text: string): string;
|
|
13
|
+
extractPlainTextWithOptions(text: string, options: ParserOptions): string;
|
|
12
14
|
}
|
|
13
15
|
//# sourceMappingURL=Markdown.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.nitro.d.ts","sourceRoot":"","sources":["../../../src/Markdown.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC;IACnD,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;IACA,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Markdown.nitro.d.ts","sourceRoot":"","sources":["../../../src/Markdown.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC;IACnD,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;IACA,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;IAC/D,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;CAC3E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode, type ComponentType } from "react";
|
|
2
2
|
import type { MarkdownNode } from "./headless";
|
|
3
3
|
import { type MarkdownTheme, type NodeStyleOverrides, type StylingStrategy } from "./theme";
|
|
4
|
+
import type { CodeHighlighter } from "./utils/code-highlight";
|
|
4
5
|
export type NodeRendererProps = {
|
|
5
6
|
node: MarkdownNode;
|
|
6
7
|
depth: number;
|
|
@@ -60,6 +61,11 @@ export type MarkdownContextValue = {
|
|
|
60
61
|
styles?: NodeStyleOverrides;
|
|
61
62
|
stylingStrategy: StylingStrategy;
|
|
62
63
|
onLinkPress?: LinkPressHandler;
|
|
64
|
+
highlightCode?: boolean | CodeHighlighter;
|
|
65
|
+
tableOptions?: {
|
|
66
|
+
minColumnWidth?: number;
|
|
67
|
+
measurementStabilizeMs?: number;
|
|
68
|
+
};
|
|
63
69
|
};
|
|
64
70
|
export declare const MarkdownContext: import("react").Context<MarkdownContextValue>;
|
|
65
71
|
export declare const useMarkdownContext: () => MarkdownContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownContext.d.ts","sourceRoot":"","sources":["../../../src/MarkdownContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,YAAY,EAA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e,GAAG,OAAO,CACnC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,CAC7C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,eAAe,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,eAAe,EAAE,eAAe,CAAC;IACjC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IAC1C,YAAY,CAAC,EAAE;QACb,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,eAAe,+CAM1B,CAAC;AAEH,eAAO,MAAM,kBAAkB,4BAAoC,CAAC"}
|
|
@@ -29,6 +29,10 @@ export type MarkdownNode = {
|
|
|
29
29
|
isHeader?: boolean;
|
|
30
30
|
/** Text alignment for table cells: 'left', 'center', or 'right'. */
|
|
31
31
|
align?: string;
|
|
32
|
+
/** Source start offset in original markdown text (when provided by native parser). */
|
|
33
|
+
beg?: number;
|
|
34
|
+
/** Source end offset in original markdown text (when provided by native parser). */
|
|
35
|
+
end?: number;
|
|
32
36
|
/** Nested child nodes for hierarchical elements like paragraphs, lists, and tables. */
|
|
33
37
|
children?: MarkdownNode[];
|
|
34
38
|
};
|
|
@@ -46,6 +50,15 @@ export declare function parseMarkdown(text: string): MarkdownNode;
|
|
|
46
50
|
* @returns The root node of the parsed AST
|
|
47
51
|
*/
|
|
48
52
|
export declare function parseMarkdownWithOptions(text: string, options: ParserOptions): MarkdownNode;
|
|
53
|
+
/**
|
|
54
|
+
* Parse markdown and return flattened plain text directly from native parser.
|
|
55
|
+
* Useful for search/indexing flows that don't need full AST rendering.
|
|
56
|
+
*/
|
|
57
|
+
export declare function extractPlainText(text: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Parse markdown with options and return flattened plain text from native parser.
|
|
60
|
+
*/
|
|
61
|
+
export declare function extractPlainTextWithOptions(text: string, options: ParserOptions): string;
|
|
49
62
|
export type { MarkdownParser };
|
|
50
63
|
/**
|
|
51
64
|
* Extract text content from a markdown node recursively.
|
|
@@ -58,4 +71,9 @@ export declare const getTextContent: (node: MarkdownNode) => string;
|
|
|
58
71
|
* recursively extracts plain text from the AST, normalizing spacing.
|
|
59
72
|
*/
|
|
60
73
|
export declare const getFlattenedText: (node: MarkdownNode) => string;
|
|
74
|
+
/**
|
|
75
|
+
* Recursively removes `beg`/`end` source offset fields from an AST.
|
|
76
|
+
* Useful to reduce memory in environments that don't need source mapping.
|
|
77
|
+
*/
|
|
78
|
+
export declare function stripSourceOffsets(node: MarkdownNode): MarkdownNode;
|
|
61
79
|
//# sourceMappingURL=headless.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.ts","sourceRoot":"","sources":["../../../src/headless.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,gGAAgG;IAChG,IAAI,EACA,UAAU,GACV,SAAS,GACT,WAAW,GACX,MAAM,GACN,MAAM,GACN,QAAQ,GACR,eAAe,GACf,MAAM,GACN,OAAO,GACP,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,iBAAiB,GACjB,YAAY,GACZ,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,MAAM,GACN,WAAW,GACX,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,aAAa,CAAC;IAClB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;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F;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,YAAY,KAAG,MAkDrD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAMnE"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./headless";
|
|
2
2
|
export { Markdown } from "./markdown";
|
|
3
|
+
export type { MarkdownProps, AstTransform, MarkdownPlugin, MarkdownVirtualizationOptions, } from "./markdown";
|
|
3
4
|
export { MarkdownStream } from "./markdown-stream";
|
|
5
|
+
export type { MarkdownStreamProps } from "./markdown-stream";
|
|
4
6
|
export { useMarkdownContext, MarkdownContext } from "./MarkdownContext";
|
|
5
7
|
export type { CustomRenderer, CustomRenderers, CustomRendererProps, NodeRendererProps, BaseCustomRendererProps, EnhancedRendererProps, HeadingRendererProps, LinkRendererProps, ImageRendererProps, CodeBlockRendererProps, InlineCodeRendererProps, ListRendererProps, TaskListItemRendererProps, LinkPressHandler, MarkdownContextValue, } from "./MarkdownContext";
|
|
6
8
|
export { defaultMarkdownTheme, minimalMarkdownTheme, mergeThemes, } from "./theme";
|
|
@@ -18,4 +20,6 @@ export { MathInline, MathBlock } from "./renderers/math";
|
|
|
18
20
|
export { createMarkdownSession } from "./MarkdownSession";
|
|
19
21
|
export type { MarkdownSession } from "./MarkdownSession";
|
|
20
22
|
export { useMarkdownSession, useStream } from "./use-markdown-stream";
|
|
23
|
+
export type { HighlightedToken, TokenType, CodeHighlighter } from "./utils/code-highlight";
|
|
24
|
+
export { defaultHighlighter } from "./utils/code-highlight";
|
|
21
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,mBA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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;AAEtE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -22,7 +22,12 @@ export type MarkdownStreamProps = {
|
|
|
22
22
|
* Useful when you want to prioritize user interactions over stream renders.
|
|
23
23
|
*/
|
|
24
24
|
useTransitionUpdates?: boolean;
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Enable incremental AST updates for append-only streams.
|
|
27
|
+
* Automatically falls back to full parse when updates are not safely mergeable.
|
|
28
|
+
*/
|
|
29
|
+
incrementalParsing?: boolean;
|
|
30
|
+
} & Omit<MarkdownProps, "children" | "sourceAst">;
|
|
26
31
|
/**
|
|
27
32
|
* A component that renders streaming Markdown from a MarkdownSession.
|
|
28
33
|
* It efficiently subscribes to session updates to minimize parent re-renders.
|
|
@@ -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,EAML,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAEf,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AA0CrE,MAAM,MAAM,mBAAmB,GAAG;IAChC;;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;IAC/B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAwKlD,CAAC"}
|
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import { type FC } from "react";
|
|
2
|
-
import { type StyleProp, type ViewStyle } from "react-native";
|
|
2
|
+
import { type FlatListProps, type StyleProp, type ViewStyle } from "react-native";
|
|
3
3
|
import { type MarkdownNode } from "./headless";
|
|
4
4
|
import type { ParserOptions } from "./Markdown.nitro";
|
|
5
5
|
import { type CustomRenderers, type LinkPressHandler } from "./MarkdownContext";
|
|
6
6
|
import { type PartialMarkdownTheme, type NodeStyleOverrides, type StylingStrategy } from "./theme";
|
|
7
|
+
import type { CodeHighlighter } from "./utils/code-highlight";
|
|
8
|
+
export type AstTransform = (ast: MarkdownNode) => MarkdownNode;
|
|
9
|
+
export type MarkdownVirtualizationOptions = Pick<FlatListProps<MarkdownNode>, "initialNumToRender" | "maxToRenderPerBatch" | "windowSize" | "updateCellsBatchingPeriod" | "removeClippedSubviews">;
|
|
10
|
+
export type MarkdownPlugin = {
|
|
11
|
+
/**
|
|
12
|
+
* Optional plugin name used for diagnostics and debugging.
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional plugin version metadata for diagnostics.
|
|
17
|
+
*/
|
|
18
|
+
version?: string | number;
|
|
19
|
+
/**
|
|
20
|
+
* Execution priority. Higher values run first (default: 0).
|
|
21
|
+
*/
|
|
22
|
+
priority?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Optional text preprocessor executed before native parsing.
|
|
25
|
+
* Should return a full markdown string.
|
|
26
|
+
*/
|
|
27
|
+
beforeParse?: (markdown: string) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Optional AST postprocessor executed after native parsing.
|
|
30
|
+
*/
|
|
31
|
+
afterParse?: AstTransform;
|
|
32
|
+
};
|
|
7
33
|
export type MarkdownProps = {
|
|
8
34
|
/**
|
|
9
35
|
* The markdown string to parse and render.
|
|
@@ -13,6 +39,20 @@ export type MarkdownProps = {
|
|
|
13
39
|
* Parser options to enable GFM or Math support.
|
|
14
40
|
*/
|
|
15
41
|
options?: ParserOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Optional parser plugins for preprocessing and AST postprocessing.
|
|
44
|
+
*/
|
|
45
|
+
plugins?: MarkdownPlugin[];
|
|
46
|
+
/**
|
|
47
|
+
* Optional pre-parsed AST.
|
|
48
|
+
* When provided, native parse is skipped and this tree is rendered instead.
|
|
49
|
+
*/
|
|
50
|
+
sourceAst?: MarkdownNode;
|
|
51
|
+
/**
|
|
52
|
+
* Optional transform applied after parsing and before rendering.
|
|
53
|
+
* The transformed AST is also returned in `onParseComplete`.
|
|
54
|
+
*/
|
|
55
|
+
astTransform?: AstTransform;
|
|
16
56
|
/**
|
|
17
57
|
* Callback fired when parsing begins.
|
|
18
58
|
*/
|
|
@@ -25,6 +65,13 @@ export type MarkdownProps = {
|
|
|
25
65
|
ast: MarkdownNode;
|
|
26
66
|
text: string;
|
|
27
67
|
}) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Called when a parse error or plugin error occurs.
|
|
70
|
+
* @param error - The thrown error.
|
|
71
|
+
* @param phase - Where the error occurred.
|
|
72
|
+
* @param pluginName - The plugin name, if applicable.
|
|
73
|
+
*/
|
|
74
|
+
onError?: (error: Error, phase: 'parse' | 'before-plugin' | 'after-plugin', pluginName?: string) => void;
|
|
28
75
|
/**
|
|
29
76
|
* Custom renderers for specific markdown node types.
|
|
30
77
|
* Each renderer receives { node, children, Renderer } plus type-specific props.
|
|
@@ -60,6 +107,35 @@ export type MarkdownProps = {
|
|
|
60
107
|
* Return false to prevent the default openURL behavior.
|
|
61
108
|
*/
|
|
62
109
|
onLinkPress?: LinkPressHandler;
|
|
110
|
+
/**
|
|
111
|
+
* Enables top-level block virtualization for very large markdown documents.
|
|
112
|
+
* Best used when Markdown is the primary scroll container on screen.
|
|
113
|
+
* - `true`: always virtualize when block threshold is met
|
|
114
|
+
* - `"auto"`: virtualize only when threshold is met (recommended for large docs)
|
|
115
|
+
* - `false`: disable virtualization (default)
|
|
116
|
+
*/
|
|
117
|
+
virtualize?: boolean | "auto";
|
|
118
|
+
/**
|
|
119
|
+
* Minimum number of top-level blocks before virtualization is activated.
|
|
120
|
+
* Helps avoid FlatList overhead on small documents.
|
|
121
|
+
*/
|
|
122
|
+
virtualizationMinBlocks?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Optional FlatList tuning for virtualization.
|
|
125
|
+
*/
|
|
126
|
+
virtualization?: MarkdownVirtualizationOptions;
|
|
127
|
+
/**
|
|
128
|
+
* Optional configuration for the table renderer.
|
|
129
|
+
*/
|
|
130
|
+
tableOptions?: {
|
|
131
|
+
minColumnWidth?: number;
|
|
132
|
+
measurementStabilizeMs?: number;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Enable built-in syntax highlighting for code blocks.
|
|
136
|
+
* Pass `true` to use the built-in tokenizer, or a custom highlighter function.
|
|
137
|
+
*/
|
|
138
|
+
highlightCode?: boolean | CodeHighlighter;
|
|
63
139
|
};
|
|
64
140
|
export declare const Markdown: FC<MarkdownProps>;
|
|
65
141
|
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown.tsx"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AC,EAAE,OAAO,GAAG,eAAe,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CA4KtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/renderers/code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/renderers/code.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAoFxC,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA8B1C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FC, type ComponentType } from "react";
|
|
2
|
+
import { type StyleProp, type TextStyle } from "react-native";
|
|
3
|
+
import type { MarkdownNode } from "../../headless";
|
|
4
|
+
import type { NodeRendererProps } from "../../MarkdownContext";
|
|
5
|
+
type CellContentProps = {
|
|
6
|
+
node: MarkdownNode;
|
|
7
|
+
Renderer: ComponentType<NodeRendererProps>;
|
|
8
|
+
styles: {
|
|
9
|
+
cellContentWrapper: object;
|
|
10
|
+
};
|
|
11
|
+
textStyle?: StyleProp<TextStyle>;
|
|
12
|
+
};
|
|
13
|
+
export declare const CellContent: FC<CellContentProps>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=cell-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-content.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/cell-content.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,MAAM,EAAE;QACN,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAuB5C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FC, type ComponentType } from "react";
|
|
2
|
+
import { type ViewStyle } from "react-native";
|
|
3
|
+
import { type NodeRendererProps } from "../../MarkdownContext";
|
|
4
|
+
type TableRendererProps = {
|
|
5
|
+
node: import("../../headless").MarkdownNode;
|
|
6
|
+
Renderer: ComponentType<NodeRendererProps>;
|
|
7
|
+
style?: ViewStyle;
|
|
8
|
+
};
|
|
9
|
+
export declare const TableRenderer: FC<TableRendererProps>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAAE,EACP,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAUnF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,EAAE,YAAY,CAAC;IAC5C,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAQF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA+RhD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ColumnWidthAction } from "./types";
|
|
2
|
+
export declare const DEFAULT_MIN_COLUMN_WIDTH = 60;
|
|
3
|
+
export declare const DEFAULT_MEASUREMENT_STABILIZE_MS = 140;
|
|
4
|
+
export declare function columnWidthsReducer(state: number[], action: ColumnWidthAction): number[];
|
|
5
|
+
//# sourceMappingURL=table-reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-reducer.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/table-reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,gCAAgC,MAAM,CAAC;AAEpD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,iBAAiB,GACxB,MAAM,EAAE,CA2BV"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MarkdownNode } from "../../headless";
|
|
2
|
+
type ExtractedTableData = {
|
|
3
|
+
headers: MarkdownNode[];
|
|
4
|
+
rows: MarkdownNode[][];
|
|
5
|
+
alignments: (string | undefined)[];
|
|
6
|
+
};
|
|
7
|
+
export declare const extractTableData: (node: MarkdownNode) => ExtractedTableData;
|
|
8
|
+
export declare const estimateColumnWidths: (headers: MarkdownNode[], rows: MarkdownNode[][], columnCount: number, minColumnWidth: number) => number[];
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=table-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-utils.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/table-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAOnE,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC;IACvB,UAAU,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,YAAY,KAAG,kBA6BrD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,YAAY,EAAE,EACvB,MAAM,YAAY,EAAE,EAAE,EACtB,aAAa,MAAM,EACnB,gBAAgB,MAAM,aAgCvB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MarkdownNode } from "../../headless";
|
|
2
|
+
export type AlignmentType = "left" | "center" | "right" | "default";
|
|
3
|
+
export type TableCell = {
|
|
4
|
+
node: MarkdownNode;
|
|
5
|
+
align: AlignmentType;
|
|
6
|
+
isHeader: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type TableRow = {
|
|
9
|
+
cells: TableCell[];
|
|
10
|
+
};
|
|
11
|
+
export type TableData = {
|
|
12
|
+
headers: TableCell[];
|
|
13
|
+
rows: TableRow[];
|
|
14
|
+
columnCount: number;
|
|
15
|
+
alignments: AlignmentType[];
|
|
16
|
+
};
|
|
17
|
+
export type ColumnWidthAction = {
|
|
18
|
+
type: "RESET_WIDTHS";
|
|
19
|
+
widths: number[];
|
|
20
|
+
} | {
|
|
21
|
+
type: "SET_MONOTONIC_WIDTHS";
|
|
22
|
+
widths: number[];
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/renderers/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpE,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC"}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { type ViewStyle } from "react-native";
|
|
3
|
-
import { type NodeRendererProps } from "../MarkdownContext";
|
|
4
|
-
import type { MarkdownNode } from "../headless";
|
|
5
|
-
type TableRendererProps = {
|
|
6
|
-
node: MarkdownNode;
|
|
7
|
-
Renderer: ComponentType<NodeRendererProps>;
|
|
8
|
-
style?: ViewStyle;
|
|
9
|
-
};
|
|
10
|
-
export declare const TableRenderer: FC<TableRendererProps>;
|
|
11
|
-
export {};
|
|
1
|
+
export { TableRenderer } from "./table/index";
|
|
12
2
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/renderers/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import type { HybridObject } from "react-native-nitro-modules";
|
|
2
|
+
export type MarkdownSessionListener = (from: number, to: number) => void;
|
|
2
3
|
export interface MarkdownSession extends HybridObject<{
|
|
3
4
|
ios: "swift";
|
|
4
5
|
android: "kotlin";
|
|
5
6
|
}> {
|
|
6
|
-
append(chunk: string):
|
|
7
|
+
append(chunk: string): number;
|
|
7
8
|
clear(): void;
|
|
8
9
|
getAllText(): string;
|
|
10
|
+
getLength(): number;
|
|
11
|
+
getTextRange(from: number, to: number): string;
|
|
9
12
|
highlightPosition: number;
|
|
10
|
-
addListener(listener:
|
|
13
|
+
addListener(listener: MarkdownSessionListener): () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Replaces the entire buffer with new text and notifies listeners with (0, newLength).
|
|
16
|
+
*/
|
|
17
|
+
reset(text: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Replaces the text in [from, to) with the given text.
|
|
20
|
+
* Returns the new total buffer length.
|
|
21
|
+
*/
|
|
22
|
+
replace(from: number, to: number, text: string): number;
|
|
11
23
|
}
|
|
12
24
|
//# sourceMappingURL=MarkdownSession.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownSession.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/MarkdownSession.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,YAAY,CAAC;IACpD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"MarkdownSession.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/MarkdownSession.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,MAAM,uBAAuB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;AAEzE,MAAM,WAAW,eAAgB,SAAQ,YAAY,CAAC;IACpD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd,UAAU,IAAI,MAAM,CAAC;IACrB,SAAS,IAAI,MAAM,CAAC;IACpB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAE/C,iBAAiB,EAAE,MAAM,CAAC;IAE1B,WAAW,CAAC,QAAQ,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAAC;IAE3D;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACzD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type TextStyle, type ViewStyle } from "react-native";
|
|
2
|
-
import type { MarkdownNode } from "./headless";
|
|
3
2
|
export type MarkdownTheme = {
|
|
4
3
|
colors: {
|
|
5
4
|
text: string | undefined;
|
|
@@ -19,6 +18,16 @@ export type MarkdownTheme = {
|
|
|
19
18
|
tableHeaderText: string | undefined;
|
|
20
19
|
tableRowEven: string | undefined;
|
|
21
20
|
tableRowOdd: string | undefined;
|
|
21
|
+
codeTokenColors?: {
|
|
22
|
+
keyword?: string;
|
|
23
|
+
string?: string;
|
|
24
|
+
comment?: string;
|
|
25
|
+
number?: string;
|
|
26
|
+
operator?: string;
|
|
27
|
+
punctuation?: string;
|
|
28
|
+
type?: string;
|
|
29
|
+
default?: string;
|
|
30
|
+
};
|
|
22
31
|
};
|
|
23
32
|
spacing: {
|
|
24
33
|
xs: number;
|
|
@@ -57,8 +66,15 @@ export declare const defaultMarkdownTheme: MarkdownTheme;
|
|
|
57
66
|
export type PartialMarkdownTheme = {
|
|
58
67
|
[K in keyof MarkdownTheme]?: K extends "showCodeLanguage" | "headingWeight" ? MarkdownTheme[K] : MarkdownTheme[K] extends object ? Partial<MarkdownTheme[K]> : MarkdownTheme[K];
|
|
59
68
|
};
|
|
60
|
-
|
|
69
|
+
type TextNodeType = "text" | "bold" | "italic" | "strikethrough" | "link" | "code_inline" | "heading" | "paragraph" | "math_inline" | "html_inline";
|
|
70
|
+
type ViewNodeType = "document" | "blockquote" | "code_block" | "horizontal_rule" | "image" | "list" | "list_item" | "task_list_item" | "table" | "table_head" | "table_body" | "table_row" | "table_cell" | "math_block" | "html_block" | "line_break" | "soft_break";
|
|
71
|
+
export type NodeStyleOverrides = Partial<{
|
|
72
|
+
[K in TextNodeType]: TextStyle;
|
|
73
|
+
} & {
|
|
74
|
+
[K in ViewNodeType]: ViewStyle;
|
|
75
|
+
}>;
|
|
61
76
|
export type StylingStrategy = "opinionated" | "minimal";
|
|
62
77
|
export declare const minimalMarkdownTheme: MarkdownTheme;
|
|
63
78
|
export declare const mergeThemes: (base: MarkdownTheme, partial?: PartialMarkdownTheme) => MarkdownTheme;
|
|
79
|
+
export {};
|
|
64
80
|
//# sourceMappingURL=theme.d.ts.map
|