react-native-nitro-markdown 0.1.2 → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +293 -119
- package/android/src/main/cpp/cpp-adapter.cpp +1 -1
- package/android/src/main/java/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSession.kt +61 -0
- package/android/src/main/java/com/nitromarkdown/NitroMarkdownPackage.kt +5 -1
- package/cpp/bindings/HybridMarkdownParser.cpp +2 -2
- package/cpp/bindings/HybridMarkdownParser.hpp +2 -2
- package/cpp/bindings/HybridMarkdownSession.cpp +0 -0
- package/cpp/core/MarkdownSessionCore.cpp +0 -0
- package/ios/HybridMarkdownSession.swift +64 -0
- package/lib/commonjs/MarkdownContext.js +17 -0
- package/lib/commonjs/MarkdownContext.js.map +1 -0
- package/lib/commonjs/MarkdownSession.js +11 -0
- package/lib/commonjs/MarkdownSession.js.map +1 -0
- package/lib/commonjs/default-markdown-renderer.js +217 -0
- package/lib/commonjs/default-markdown-renderer.js.map +1 -0
- package/lib/commonjs/headless.js +61 -0
- package/lib/commonjs/headless.js.map +1 -0
- package/lib/commonjs/index.js +220 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/markdown-stream.js +32 -0
- package/lib/commonjs/markdown-stream.js.map +1 -0
- package/lib/commonjs/markdown.js +377 -0
- package/lib/commonjs/markdown.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/renderers/blockquote.js +36 -0
- package/lib/commonjs/renderers/blockquote.js.map +1 -0
- package/lib/commonjs/renderers/code.js +99 -0
- package/lib/commonjs/renderers/code.js.map +1 -0
- package/lib/commonjs/renderers/heading.js +63 -0
- package/lib/commonjs/renderers/heading.js.map +1 -0
- package/lib/commonjs/renderers/horizontal-rule.js +29 -0
- package/lib/commonjs/renderers/horizontal-rule.js.map +1 -0
- package/lib/commonjs/renderers/image.js +163 -0
- package/lib/commonjs/renderers/image.js.map +1 -0
- package/lib/commonjs/renderers/link.js +35 -0
- package/lib/commonjs/renderers/link.js.map +1 -0
- package/lib/commonjs/renderers/list.js +118 -0
- package/lib/commonjs/renderers/list.js.map +1 -0
- package/lib/commonjs/renderers/math.js +127 -0
- package/lib/commonjs/renderers/math.js.map +1 -0
- package/lib/commonjs/renderers/paragraph.js +39 -0
- package/lib/commonjs/renderers/paragraph.js.map +1 -0
- package/lib/commonjs/renderers/table.js +290 -0
- package/lib/commonjs/renderers/table.js.map +1 -0
- package/lib/commonjs/specs/MarkdownSession.nitro.js +6 -0
- package/lib/commonjs/specs/MarkdownSession.nitro.js.map +1 -0
- package/lib/commonjs/theme.js +191 -0
- package/lib/commonjs/theme.js.map +1 -0
- package/lib/commonjs/use-markdown-stream.js +71 -0
- package/lib/commonjs/use-markdown-stream.js.map +1 -0
- package/lib/module/MarkdownContext.js +12 -0
- package/lib/module/MarkdownContext.js.map +1 -0
- package/lib/module/MarkdownSession.js +7 -0
- package/lib/module/MarkdownSession.js.map +1 -0
- package/lib/module/default-markdown-renderer.js +212 -0
- package/lib/module/default-markdown-renderer.js.map +1 -0
- package/lib/module/headless.js +54 -0
- package/lib/module/headless.js.map +1 -0
- package/lib/module/index.js +18 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/markdown-stream.js +27 -0
- package/lib/module/markdown-stream.js.map +1 -0
- package/lib/module/markdown.js +372 -0
- package/lib/module/markdown.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/renderers/blockquote.js +31 -0
- package/lib/module/renderers/blockquote.js.map +1 -0
- package/lib/module/renderers/code.js +93 -0
- package/lib/module/renderers/code.js.map +1 -0
- package/lib/module/renderers/heading.js +58 -0
- package/lib/module/renderers/heading.js.map +1 -0
- package/lib/module/renderers/horizontal-rule.js +24 -0
- package/lib/module/renderers/horizontal-rule.js.map +1 -0
- package/lib/module/renderers/image.js +158 -0
- package/lib/module/renderers/image.js.map +1 -0
- package/lib/module/renderers/link.js +30 -0
- package/lib/module/renderers/link.js.map +1 -0
- package/lib/module/renderers/list.js +111 -0
- package/lib/module/renderers/list.js.map +1 -0
- package/lib/module/renderers/math.js +121 -0
- package/lib/module/renderers/math.js.map +1 -0
- package/lib/module/renderers/paragraph.js +34 -0
- package/lib/module/renderers/paragraph.js.map +1 -0
- package/lib/module/renderers/table.js +285 -0
- package/lib/module/renderers/table.js.map +1 -0
- package/lib/module/specs/MarkdownSession.nitro.js +4 -0
- package/lib/module/specs/MarkdownSession.nitro.js.map +1 -0
- package/lib/module/theme.js +186 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/use-markdown-stream.js +66 -0
- package/lib/module/use-markdown-stream.js.map +1 -0
- package/lib/typescript/commonjs/Markdown.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/MarkdownContext.d.ts +65 -0
- package/lib/typescript/commonjs/MarkdownContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/MarkdownSession.d.ts +4 -0
- package/lib/typescript/commonjs/MarkdownSession.d.ts.map +1 -0
- package/lib/typescript/commonjs/default-markdown-renderer.d.ts +10 -0
- package/lib/typescript/commonjs/default-markdown-renderer.d.ts.map +1 -0
- package/lib/typescript/commonjs/headless.d.ts +57 -0
- package/lib/typescript/commonjs/headless.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +22 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/markdown-stream.d.ts +15 -0
- package/lib/typescript/commonjs/markdown-stream.d.ts.map +1 -0
- package/lib/typescript/commonjs/markdown.d.ts +47 -0
- package/lib/typescript/commonjs/markdown.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/renderers/blockquote.d.ts +9 -0
- package/lib/typescript/commonjs/renderers/blockquote.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/code.d.ts +19 -0
- package/lib/typescript/commonjs/renderers/code.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/heading.d.ts +10 -0
- package/lib/typescript/commonjs/renderers/heading.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/horizontal-rule.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/image.d.ts +13 -0
- package/lib/typescript/commonjs/renderers/image.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/link.d.ts +10 -0
- package/lib/typescript/commonjs/renderers/link.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/list.d.ts +26 -0
- package/lib/typescript/commonjs/renderers/list.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/math.d.ts +14 -0
- package/lib/typescript/commonjs/renderers/math.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/paragraph.d.ts +10 -0
- package/lib/typescript/commonjs/renderers/paragraph.d.ts.map +1 -0
- package/lib/typescript/commonjs/renderers/table.d.ts +12 -0
- package/lib/typescript/commonjs/renderers/table.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts +12 -0
- package/lib/typescript/commonjs/specs/MarkdownSession.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/theme.d.ts +65 -0
- package/lib/typescript/commonjs/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/use-markdown-stream.d.ts +22 -0
- package/lib/typescript/commonjs/use-markdown-stream.d.ts.map +1 -0
- package/lib/typescript/module/Markdown.nitro.d.ts +13 -0
- package/lib/typescript/module/Markdown.nitro.d.ts.map +1 -0
- package/lib/typescript/module/MarkdownContext.d.ts +65 -0
- package/lib/typescript/module/MarkdownContext.d.ts.map +1 -0
- package/lib/typescript/module/MarkdownSession.d.ts +4 -0
- package/lib/typescript/module/MarkdownSession.d.ts.map +1 -0
- package/lib/typescript/module/default-markdown-renderer.d.ts +10 -0
- package/lib/typescript/module/default-markdown-renderer.d.ts.map +1 -0
- package/lib/typescript/module/headless.d.ts +57 -0
- package/lib/typescript/module/headless.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +22 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/markdown-stream.d.ts +15 -0
- package/lib/typescript/module/markdown-stream.d.ts.map +1 -0
- package/lib/typescript/module/markdown.d.ts +47 -0
- package/lib/typescript/module/markdown.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/renderers/blockquote.d.ts +9 -0
- package/lib/typescript/module/renderers/blockquote.d.ts.map +1 -0
- package/lib/typescript/module/renderers/code.d.ts +19 -0
- package/lib/typescript/module/renderers/code.d.ts.map +1 -0
- package/lib/typescript/module/renderers/heading.d.ts +10 -0
- package/lib/typescript/module/renderers/heading.d.ts.map +1 -0
- package/lib/typescript/module/renderers/horizontal-rule.d.ts +8 -0
- package/lib/typescript/module/renderers/horizontal-rule.d.ts.map +1 -0
- package/lib/typescript/module/renderers/image.d.ts +13 -0
- package/lib/typescript/module/renderers/image.d.ts.map +1 -0
- package/lib/typescript/module/renderers/link.d.ts +10 -0
- package/lib/typescript/module/renderers/link.d.ts.map +1 -0
- package/lib/typescript/module/renderers/list.d.ts +26 -0
- package/lib/typescript/module/renderers/list.d.ts.map +1 -0
- package/lib/typescript/module/renderers/math.d.ts +14 -0
- package/lib/typescript/module/renderers/math.d.ts.map +1 -0
- package/lib/typescript/module/renderers/paragraph.d.ts +10 -0
- package/lib/typescript/module/renderers/paragraph.d.ts.map +1 -0
- package/lib/typescript/module/renderers/table.d.ts +12 -0
- package/lib/typescript/module/renderers/table.d.ts.map +1 -0
- package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts +12 -0
- package/lib/typescript/module/specs/MarkdownSession.nitro.d.ts.map +1 -0
- package/lib/typescript/module/theme.d.ts +65 -0
- package/lib/typescript/module/theme.d.ts.map +1 -0
- package/lib/typescript/module/use-markdown-stream.d.ts +22 -0
- package/lib/typescript/module/use-markdown-stream.d.ts.map +1 -0
- package/nitro.json +5 -2
- package/nitrogen/generated/android/NitroMarkdown+autolinking.cmake +3 -2
- package/nitrogen/generated/android/NitroMarkdown+autolinking.gradle +1 -1
- package/nitrogen/generated/android/NitroMarkdownOnLoad.cpp +17 -5
- package/nitrogen/generated/android/NitroMarkdownOnLoad.hpp +4 -4
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.cpp +91 -0
- package/nitrogen/generated/android/c++/JHybridMarkdownSessionSpec.hpp +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/HybridMarkdownSessionSpec.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/nitromarkdown/NitroMarkdownOnLoad.kt +1 -1
- package/nitrogen/generated/ios/NitroMarkdown+autolinking.rb +2 -2
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.cpp +28 -4
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Bridge.hpp +72 -6
- package/nitrogen/generated/ios/NitroMarkdown-Swift-Cxx-Umbrella.hpp +11 -4
- package/nitrogen/generated/ios/NitroMarkdownAutolinking.mm +11 -3
- package/nitrogen/generated/ios/NitroMarkdownAutolinking.swift +16 -3
- package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridMarkdownSessionSpecSwift.hpp +108 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridMarkdownSessionSpec_cxx.swift +190 -0
- package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.cpp +3 -3
- package/nitrogen/generated/shared/c++/HybridMarkdownParserSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridMarkdownSessionSpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/ParserOptions.hpp +22 -14
- package/package.json +45 -7
- package/react-native-nitro-markdown.podspec +5 -5
- package/src/MarkdownContext.ts +98 -0
- package/src/MarkdownSession.ts +8 -0
- package/src/default-markdown-renderer.tsx +261 -0
- package/src/headless.ts +116 -0
- package/src/index.ts +47 -60
- package/src/markdown-stream.tsx +32 -0
- package/src/markdown.tsx +497 -0
- package/src/renderers/blockquote.tsx +30 -0
- package/src/renderers/code.tsx +112 -0
- package/src/renderers/heading.tsx +66 -0
- package/src/renderers/horizontal-rule.tsx +23 -0
- package/src/renderers/image.tsx +175 -0
- package/src/renderers/link.tsx +33 -0
- package/src/renderers/list.tsx +131 -0
- package/src/renderers/math.tsx +141 -0
- package/src/renderers/paragraph.tsx +47 -0
- package/src/renderers/table.tsx +370 -0
- package/src/specs/MarkdownSession.nitro.ts +16 -0
- package/src/theme.ts +243 -0
- package/src/use-markdown-stream.ts +83 -0
- package/ios/NitroMarkdown-Bridging-Header.h +0 -14
- package/lib/commonjs/MarkdownJS.reference.js +0 -114
- package/lib/commonjs/MarkdownJS.reference.js.map +0 -1
- package/lib/module/MarkdownJS.reference.js +0 -107
- package/lib/module/MarkdownJS.reference.js.map +0 -1
- package/lib/typescript/Markdown.nitro.d.ts.map +0 -1
- package/lib/typescript/MarkdownJS.reference.d.ts +0 -33
- package/lib/typescript/MarkdownJS.reference.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -22
- package/lib/typescript/index.d.ts.map +0 -1
- package/src/MarkdownJS.reference.ts +0 -122
- /package/lib/typescript/{Markdown.nitro.d.ts → commonjs/Markdown.nitro.d.ts} +0 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TableRenderer = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _MarkdownContext = require("../MarkdownContext.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
const extractTableData = node => {
|
|
12
|
+
const headers = [];
|
|
13
|
+
const rows = [];
|
|
14
|
+
const alignments = [];
|
|
15
|
+
for (const child of node.children ?? []) {
|
|
16
|
+
if (child.type === "table_head") {
|
|
17
|
+
for (const row of child.children ?? []) {
|
|
18
|
+
if (row.type === "table_row") {
|
|
19
|
+
for (const cell of row.children ?? []) {
|
|
20
|
+
headers.push(cell);
|
|
21
|
+
alignments.push(cell.align);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
} else if (child.type === "table_body") {
|
|
26
|
+
for (const row of child.children ?? []) {
|
|
27
|
+
if (row.type === "table_row") {
|
|
28
|
+
const rowCells = [];
|
|
29
|
+
for (const cell of row.children ?? []) {
|
|
30
|
+
rowCells.push(cell);
|
|
31
|
+
}
|
|
32
|
+
rows.push(rowCells);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
headers,
|
|
39
|
+
rows,
|
|
40
|
+
alignments
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const columnWidthsReducer = (state, action) => {
|
|
44
|
+
if (action.type === "SET_WIDTHS") return action.payload;
|
|
45
|
+
return state;
|
|
46
|
+
};
|
|
47
|
+
const TableRenderer = ({
|
|
48
|
+
node,
|
|
49
|
+
Renderer,
|
|
50
|
+
style
|
|
51
|
+
}) => {
|
|
52
|
+
const {
|
|
53
|
+
theme
|
|
54
|
+
} = (0, _MarkdownContext.useMarkdownContext)();
|
|
55
|
+
const {
|
|
56
|
+
headers,
|
|
57
|
+
rows,
|
|
58
|
+
alignments
|
|
59
|
+
} = (0, _react.useMemo)(() => extractTableData(node), [node]);
|
|
60
|
+
const columnCount = headers.length;
|
|
61
|
+
const styles = (0, _react.useMemo)(() => createTableStyles(theme), [theme]);
|
|
62
|
+
const [columnWidths, dispatch] = (0, _react.useReducer)(columnWidthsReducer, []);
|
|
63
|
+
const measuredWidths = (0, _react.useRef)(new Map());
|
|
64
|
+
const measuredCells = (0, _react.useRef)(new Set());
|
|
65
|
+
const widthsCalculated = (0, _react.useRef)(false);
|
|
66
|
+
const onCellLayout = (0, _react.useCallback)((cellKey, width) => {
|
|
67
|
+
measuredWidths.current.set(cellKey, width);
|
|
68
|
+
measuredCells.current.add(cellKey);
|
|
69
|
+
const expectedCells = new Set();
|
|
70
|
+
for (let col = 0; col < columnCount; col++) {
|
|
71
|
+
expectedCells.add(`header-${col}`);
|
|
72
|
+
}
|
|
73
|
+
for (let row = 0; row < rows.length; row++) {
|
|
74
|
+
for (let col = 0; col < columnCount; col++) {
|
|
75
|
+
expectedCells.add(`cell-${row}-${col}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const allCellsMeasured = [...expectedCells].every(key => measuredCells.current.has(key));
|
|
79
|
+
if (!allCellsMeasured || widthsCalculated.current) return;
|
|
80
|
+
const maxWidths = new Array(columnCount).fill(0);
|
|
81
|
+
for (let col = 0; col < columnCount; col++) {
|
|
82
|
+
const headerWidth = measuredWidths.current.get(`header-${col}`);
|
|
83
|
+
if (headerWidth && headerWidth > 0) {
|
|
84
|
+
maxWidths[col] = Math.max(maxWidths[col], headerWidth);
|
|
85
|
+
}
|
|
86
|
+
for (let row = 0; row < rows.length; row++) {
|
|
87
|
+
const cellWidth = measuredWidths.current.get(`cell-${row}-${col}`);
|
|
88
|
+
if (cellWidth && cellWidth > 0) {
|
|
89
|
+
maxWidths[col] = Math.max(maxWidths[col], cellWidth);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
maxWidths[col] = Math.max(maxWidths[col] + 8, 60);
|
|
93
|
+
}
|
|
94
|
+
widthsCalculated.current = true;
|
|
95
|
+
dispatch({
|
|
96
|
+
type: "SET_WIDTHS",
|
|
97
|
+
payload: maxWidths
|
|
98
|
+
});
|
|
99
|
+
}, [columnCount, rows.length]);
|
|
100
|
+
const getAlignment = index => {
|
|
101
|
+
const align = alignments[index];
|
|
102
|
+
if (align === "center") return "center";
|
|
103
|
+
if (align === "right") return "flex-end";
|
|
104
|
+
return "flex-start";
|
|
105
|
+
};
|
|
106
|
+
if (columnCount === 0) return null;
|
|
107
|
+
const hasWidths = columnWidths.length === columnCount;
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
109
|
+
style: [styles.container, style],
|
|
110
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
111
|
+
style: styles.measurementContainer,
|
|
112
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
113
|
+
style: styles.measurementRow,
|
|
114
|
+
children: headers.map((cell, colIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
115
|
+
style: styles.measurementCell,
|
|
116
|
+
onLayout: e => {
|
|
117
|
+
onCellLayout(`header-${colIndex}`, e.nativeEvent.layout.width);
|
|
118
|
+
},
|
|
119
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CellContent, {
|
|
120
|
+
node: cell,
|
|
121
|
+
Renderer: Renderer,
|
|
122
|
+
styles: styles
|
|
123
|
+
})
|
|
124
|
+
}, `measure-header-${colIndex}`))
|
|
125
|
+
}), rows.map((row, rowIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
126
|
+
style: styles.measurementRow,
|
|
127
|
+
children: row.map((cell, colIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
128
|
+
style: styles.measurementCell,
|
|
129
|
+
onLayout: e => {
|
|
130
|
+
onCellLayout(`cell-${rowIndex}-${colIndex}`, e.nativeEvent.layout.width);
|
|
131
|
+
},
|
|
132
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CellContent, {
|
|
133
|
+
node: cell,
|
|
134
|
+
Renderer: Renderer,
|
|
135
|
+
styles: styles
|
|
136
|
+
})
|
|
137
|
+
}, `measure-cell-${rowIndex}-${colIndex}`))
|
|
138
|
+
}, `measure-row-${rowIndex}`))]
|
|
139
|
+
}), hasWidths && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
140
|
+
horizontal: true,
|
|
141
|
+
showsHorizontalScrollIndicator: true,
|
|
142
|
+
style: styles.tableScroll,
|
|
143
|
+
bounces: false,
|
|
144
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
145
|
+
style: styles.table,
|
|
146
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
147
|
+
style: styles.headerRow,
|
|
148
|
+
children: headers.map((cell, colIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
149
|
+
style: [styles.headerCell, {
|
|
150
|
+
width: columnWidths[colIndex],
|
|
151
|
+
alignItems: getAlignment(colIndex)
|
|
152
|
+
}, colIndex === columnCount - 1 && styles.lastCell],
|
|
153
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CellContent, {
|
|
154
|
+
node: cell,
|
|
155
|
+
Renderer: Renderer,
|
|
156
|
+
styles: styles,
|
|
157
|
+
textStyle: styles.headerText
|
|
158
|
+
})
|
|
159
|
+
}, `header-${colIndex}`))
|
|
160
|
+
}), rows.map((row, rowIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
161
|
+
style: [styles.bodyRow, rowIndex === rows.length - 1 && styles.lastRow, rowIndex % 2 === 1 && styles.oddRow],
|
|
162
|
+
children: row.map((cell, colIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
163
|
+
style: [styles.bodyCell, {
|
|
164
|
+
width: columnWidths[colIndex],
|
|
165
|
+
alignItems: getAlignment(colIndex)
|
|
166
|
+
}, colIndex === columnCount - 1 && styles.lastCell],
|
|
167
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CellContent, {
|
|
168
|
+
node: cell,
|
|
169
|
+
Renderer: Renderer,
|
|
170
|
+
styles: styles,
|
|
171
|
+
textStyle: styles.cellText
|
|
172
|
+
})
|
|
173
|
+
}, `cell-${rowIndex}-${colIndex}`))
|
|
174
|
+
}, `row-${rowIndex}`))]
|
|
175
|
+
})
|
|
176
|
+
})]
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
exports.TableRenderer = TableRenderer;
|
|
180
|
+
const CellContent = ({
|
|
181
|
+
node,
|
|
182
|
+
Renderer,
|
|
183
|
+
styles,
|
|
184
|
+
textStyle
|
|
185
|
+
}) => {
|
|
186
|
+
if (!node.children || node.children.length === 0) {
|
|
187
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
188
|
+
style: textStyle,
|
|
189
|
+
children: node.content ?? ""
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
193
|
+
style: styles.cellContentWrapper,
|
|
194
|
+
children: node.children.map((child, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Renderer, {
|
|
195
|
+
node: child,
|
|
196
|
+
depth: 0,
|
|
197
|
+
inListItem: false,
|
|
198
|
+
parentIsText: false
|
|
199
|
+
}, idx))
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const createTableStyles = theme => {
|
|
203
|
+
const colors = theme?.colors || {};
|
|
204
|
+
const borderRadius = theme?.borderRadius || {
|
|
205
|
+
m: 8
|
|
206
|
+
};
|
|
207
|
+
return _reactNative.StyleSheet.create({
|
|
208
|
+
container: {
|
|
209
|
+
marginVertical: theme.spacing.s
|
|
210
|
+
},
|
|
211
|
+
measurementContainer: {
|
|
212
|
+
position: "absolute",
|
|
213
|
+
opacity: 0,
|
|
214
|
+
pointerEvents: "none",
|
|
215
|
+
left: -9999
|
|
216
|
+
},
|
|
217
|
+
measurementRow: {
|
|
218
|
+
flexDirection: "row"
|
|
219
|
+
},
|
|
220
|
+
measurementCell: {
|
|
221
|
+
paddingVertical: 10,
|
|
222
|
+
paddingHorizontal: 12
|
|
223
|
+
},
|
|
224
|
+
tableScroll: {
|
|
225
|
+
flexGrow: 0
|
|
226
|
+
},
|
|
227
|
+
table: {
|
|
228
|
+
borderRadius: borderRadius.m,
|
|
229
|
+
overflow: "hidden",
|
|
230
|
+
borderWidth: 1,
|
|
231
|
+
borderColor: colors.tableBorder || "#374151",
|
|
232
|
+
backgroundColor: colors.surface || "#111827"
|
|
233
|
+
},
|
|
234
|
+
headerRow: {
|
|
235
|
+
flexDirection: "row",
|
|
236
|
+
backgroundColor: colors.tableHeader || "#1f2937",
|
|
237
|
+
borderBottomWidth: 1,
|
|
238
|
+
borderBottomColor: colors.tableBorder || "#374151"
|
|
239
|
+
},
|
|
240
|
+
bodyRow: {
|
|
241
|
+
flexDirection: "row",
|
|
242
|
+
borderBottomWidth: 1,
|
|
243
|
+
borderBottomColor: colors.tableBorder || "#374151"
|
|
244
|
+
},
|
|
245
|
+
oddRow: {
|
|
246
|
+
backgroundColor: colors.tableRowOdd || "rgba(255,255,255,0.02)"
|
|
247
|
+
},
|
|
248
|
+
lastRow: {
|
|
249
|
+
borderBottomWidth: 0
|
|
250
|
+
},
|
|
251
|
+
headerCell: {
|
|
252
|
+
flexShrink: 0,
|
|
253
|
+
paddingVertical: 10,
|
|
254
|
+
paddingHorizontal: 12,
|
|
255
|
+
minWidth: 60,
|
|
256
|
+
borderRightWidth: 1,
|
|
257
|
+
borderRightColor: colors.tableBorder || "#374151"
|
|
258
|
+
},
|
|
259
|
+
bodyCell: {
|
|
260
|
+
flexShrink: 0,
|
|
261
|
+
paddingVertical: 10,
|
|
262
|
+
paddingHorizontal: 12,
|
|
263
|
+
minWidth: 60,
|
|
264
|
+
borderRightWidth: 1,
|
|
265
|
+
borderRightColor: colors.tableBorder || "#374151",
|
|
266
|
+
justifyContent: "center"
|
|
267
|
+
},
|
|
268
|
+
lastCell: {
|
|
269
|
+
borderRightWidth: 0
|
|
270
|
+
},
|
|
271
|
+
headerText: {
|
|
272
|
+
color: colors.tableHeaderText || "#9ca3af",
|
|
273
|
+
fontSize: 12,
|
|
274
|
+
fontWeight: "600",
|
|
275
|
+
fontFamily: theme.fontFamilies?.regular
|
|
276
|
+
},
|
|
277
|
+
cellText: {
|
|
278
|
+
color: colors.text || "#e5e7eb",
|
|
279
|
+
fontSize: 14,
|
|
280
|
+
lineHeight: 20,
|
|
281
|
+
fontFamily: theme.fontFamilies?.regular
|
|
282
|
+
},
|
|
283
|
+
cellContentWrapper: {
|
|
284
|
+
flexDirection: "row",
|
|
285
|
+
flexWrap: "wrap",
|
|
286
|
+
alignItems: "center"
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_MarkdownContext","_jsxRuntime","extractTableData","node","headers","rows","alignments","child","children","type","row","cell","push","align","rowCells","columnWidthsReducer","state","action","payload","TableRenderer","Renderer","style","theme","useMarkdownContext","useMemo","columnCount","length","styles","createTableStyles","columnWidths","dispatch","useReducer","measuredWidths","useRef","Map","measuredCells","Set","widthsCalculated","onCellLayout","useCallback","cellKey","width","current","set","add","expectedCells","col","allCellsMeasured","every","key","has","maxWidths","Array","fill","headerWidth","get","Math","max","cellWidth","getAlignment","index","hasWidths","jsxs","View","container","measurementContainer","jsx","measurementRow","map","colIndex","measurementCell","onLayout","e","nativeEvent","layout","CellContent","rowIndex","ScrollView","horizontal","showsHorizontalScrollIndicator","tableScroll","bounces","table","headerRow","headerCell","alignItems","lastCell","textStyle","headerText","bodyRow","lastRow","oddRow","bodyCell","cellText","exports","Text","content","cellContentWrapper","idx","depth","inListItem","parentIsText","colors","borderRadius","m","StyleSheet","create","marginVertical","spacing","s","position","opacity","pointerEvents","left","flexDirection","paddingVertical","paddingHorizontal","flexGrow","overflow","borderWidth","borderColor","tableBorder","backgroundColor","surface","tableHeader","borderBottomWidth","borderBottomColor","tableRowOdd","flexShrink","minWidth","borderRightWidth","borderRightColor","justifyContent","color","tableHeaderText","fontSize","fontWeight","fontFamily","fontFamilies","regular","text","lineHeight","flexWrap"],"sourceRoot":"../../../src","sources":["renderers/table.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AAYA,IAAAE,gBAAA,GAAAF,OAAA;AAAgF,IAAAG,WAAA,GAAAH,OAAA;AAShF,MAAMI,gBAAgB,GAAIC,IAAkB,IAAgB;EAC1D,MAAMC,OAAuB,GAAG,EAAE;EAClC,MAAMC,IAAsB,GAAG,EAAE;EACjC,MAAMC,UAAkC,GAAG,EAAE;EAE7C,KAAK,MAAMC,KAAK,IAAIJ,IAAI,CAACK,QAAQ,IAAI,EAAE,EAAE;IACvC,IAAID,KAAK,CAACE,IAAI,KAAK,YAAY,EAAE;MAC/B,KAAK,MAAMC,GAAG,IAAIH,KAAK,CAACC,QAAQ,IAAI,EAAE,EAAE;QACtC,IAAIE,GAAG,CAACD,IAAI,KAAK,WAAW,EAAE;UAC5B,KAAK,MAAME,IAAI,IAAID,GAAG,CAACF,QAAQ,IAAI,EAAE,EAAE;YACrCJ,OAAO,CAACQ,IAAI,CAACD,IAAI,CAAC;YAClBL,UAAU,CAACM,IAAI,CAACD,IAAI,CAACE,KAAK,CAAC;UAC7B;QACF;MACF;IACF,CAAC,MAAM,IAAIN,KAAK,CAACE,IAAI,KAAK,YAAY,EAAE;MACtC,KAAK,MAAMC,GAAG,IAAIH,KAAK,CAACC,QAAQ,IAAI,EAAE,EAAE;QACtC,IAAIE,GAAG,CAACD,IAAI,KAAK,WAAW,EAAE;UAC5B,MAAMK,QAAwB,GAAG,EAAE;UACnC,KAAK,MAAMH,IAAI,IAAID,GAAG,CAACF,QAAQ,IAAI,EAAE,E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MACR4C,gBAAgB,EAAE;IACpB,CAAC;IACD1C,UAAU,EAAE;MACV6C,KAAK,EAAE/B,MAAM,CAACgC,eAAe,IAAI,SAAS;MAC1CC,QAAQ,EAAE,EAAE;MACZC,UAAU,EAAE,KAAK;MACjBC,UAAU,EAAEnH,KAAK,CAACoH,YAAY,EAAEC;IAClC,CAAC;IACD9C,QAAQ,EAAE;MACRwC,KAAK,EAAE/B,MAAM,CAACsC,IAAI,IAAI,SAAS;MAC/BL,QAAQ,EAAE,EAAE;MACZM,UAAU,EAAE,EAAE;MACdJ,UAAU,EAAEnH,KAAK,CAACoH,YAAY,EAAEC;IAClC,CAAC;IACD1C,kBAAkB,EAAE;MAClBiB,aAAa,EAAE,KAAK;MACpB4B,QAAQ,EAAE,MAAM;MAChBzD,UAAU,EAAE;IACd;EACF,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/MarkdownSession.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.minimalMarkdownTheme = exports.mergeThemes = exports.lightMarkdownTheme = exports.defaultMarkdownTheme = exports.darkMarkdownTheme = void 0;
|
|
7
|
+
const defaultMarkdownTheme = exports.defaultMarkdownTheme = {
|
|
8
|
+
colors: {
|
|
9
|
+
text: "#e0e0e0",
|
|
10
|
+
textMuted: "#888",
|
|
11
|
+
heading: "#f0f0f0",
|
|
12
|
+
link: "#60a5fa",
|
|
13
|
+
code: "#fbbf24",
|
|
14
|
+
codeBackground: "#1a1a2e",
|
|
15
|
+
codeLanguage: "#4ade80",
|
|
16
|
+
blockquote: "#3b82f6",
|
|
17
|
+
border: "#252525",
|
|
18
|
+
surface: "#151515",
|
|
19
|
+
surfaceLight: "#1a1a1a",
|
|
20
|
+
accent: "#4ade80",
|
|
21
|
+
tableBorder: "#334155",
|
|
22
|
+
tableHeader: "#0f172a",
|
|
23
|
+
tableHeaderText: "#94a3b8",
|
|
24
|
+
tableRowEven: "#0f172a",
|
|
25
|
+
tableRowOdd: "#1e293b"
|
|
26
|
+
},
|
|
27
|
+
spacing: {
|
|
28
|
+
xs: 4,
|
|
29
|
+
s: 8,
|
|
30
|
+
m: 12,
|
|
31
|
+
l: 16,
|
|
32
|
+
xl: 24
|
|
33
|
+
},
|
|
34
|
+
fontSizes: {
|
|
35
|
+
xs: 12,
|
|
36
|
+
s: 14,
|
|
37
|
+
m: 16,
|
|
38
|
+
l: 18,
|
|
39
|
+
xl: 22,
|
|
40
|
+
h1: 32,
|
|
41
|
+
h2: 26,
|
|
42
|
+
h3: 22,
|
|
43
|
+
h4: 18,
|
|
44
|
+
h5: 16,
|
|
45
|
+
h6: 14
|
|
46
|
+
},
|
|
47
|
+
fontFamilies: {
|
|
48
|
+
regular: undefined,
|
|
49
|
+
heading: undefined,
|
|
50
|
+
mono: undefined
|
|
51
|
+
},
|
|
52
|
+
borderRadius: {
|
|
53
|
+
s: 4,
|
|
54
|
+
m: 8,
|
|
55
|
+
l: 12
|
|
56
|
+
},
|
|
57
|
+
showCodeLanguage: true
|
|
58
|
+
};
|
|
59
|
+
const minimalMarkdownTheme = exports.minimalMarkdownTheme = {
|
|
60
|
+
colors: {
|
|
61
|
+
text: undefined,
|
|
62
|
+
textMuted: undefined,
|
|
63
|
+
heading: undefined,
|
|
64
|
+
link: "#0066cc",
|
|
65
|
+
code: undefined,
|
|
66
|
+
codeBackground: "transparent",
|
|
67
|
+
codeLanguage: "#888888",
|
|
68
|
+
blockquote: "#cccccc",
|
|
69
|
+
border: "#cccccc",
|
|
70
|
+
surface: "transparent",
|
|
71
|
+
surfaceLight: "transparent",
|
|
72
|
+
accent: "#0066cc",
|
|
73
|
+
tableBorder: "#cccccc",
|
|
74
|
+
tableHeader: "transparent",
|
|
75
|
+
tableHeaderText: undefined,
|
|
76
|
+
tableRowEven: "transparent",
|
|
77
|
+
tableRowOdd: "transparent"
|
|
78
|
+
},
|
|
79
|
+
spacing: {
|
|
80
|
+
xs: 0,
|
|
81
|
+
s: 0,
|
|
82
|
+
m: 0,
|
|
83
|
+
l: 0,
|
|
84
|
+
xl: 0
|
|
85
|
+
},
|
|
86
|
+
fontSizes: {
|
|
87
|
+
xs: 12,
|
|
88
|
+
s: 14,
|
|
89
|
+
m: 16,
|
|
90
|
+
l: 18,
|
|
91
|
+
xl: 22,
|
|
92
|
+
h1: 32,
|
|
93
|
+
h2: 26,
|
|
94
|
+
h3: 22,
|
|
95
|
+
h4: 18,
|
|
96
|
+
h5: 16,
|
|
97
|
+
h6: 14
|
|
98
|
+
},
|
|
99
|
+
fontFamilies: {
|
|
100
|
+
regular: undefined,
|
|
101
|
+
heading: undefined,
|
|
102
|
+
mono: undefined
|
|
103
|
+
},
|
|
104
|
+
borderRadius: {
|
|
105
|
+
s: 0,
|
|
106
|
+
m: 0,
|
|
107
|
+
l: 0
|
|
108
|
+
},
|
|
109
|
+
showCodeLanguage: false
|
|
110
|
+
};
|
|
111
|
+
const lightMarkdownTheme = exports.lightMarkdownTheme = {
|
|
112
|
+
colors: {
|
|
113
|
+
text: "#1a1a1a",
|
|
114
|
+
textMuted: "#6b7280",
|
|
115
|
+
heading: "#000000",
|
|
116
|
+
link: "#2563eb",
|
|
117
|
+
code: "#ea580c",
|
|
118
|
+
codeBackground: "#f3f4f6",
|
|
119
|
+
codeLanguage: "#10b981",
|
|
120
|
+
blockquote: "#3b82f6",
|
|
121
|
+
border: "#e5e7eb",
|
|
122
|
+
surface: "#ffffff",
|
|
123
|
+
surfaceLight: "#f9fafb",
|
|
124
|
+
accent: "#10b981",
|
|
125
|
+
tableBorder: "#e5e7eb",
|
|
126
|
+
tableHeader: "#f3f4f6",
|
|
127
|
+
tableHeaderText: "#6b7280",
|
|
128
|
+
tableRowEven: "#ffffff",
|
|
129
|
+
tableRowOdd: "#f9fafb"
|
|
130
|
+
},
|
|
131
|
+
spacing: {
|
|
132
|
+
xs: 4,
|
|
133
|
+
s: 8,
|
|
134
|
+
m: 12,
|
|
135
|
+
l: 16,
|
|
136
|
+
xl: 24
|
|
137
|
+
},
|
|
138
|
+
fontSizes: {
|
|
139
|
+
xs: 12,
|
|
140
|
+
s: 14,
|
|
141
|
+
m: 16,
|
|
142
|
+
l: 18,
|
|
143
|
+
xl: 22,
|
|
144
|
+
h1: 32,
|
|
145
|
+
h2: 26,
|
|
146
|
+
h3: 22,
|
|
147
|
+
h4: 18,
|
|
148
|
+
h5: 16,
|
|
149
|
+
h6: 14
|
|
150
|
+
},
|
|
151
|
+
fontFamilies: {
|
|
152
|
+
regular: undefined,
|
|
153
|
+
heading: undefined,
|
|
154
|
+
mono: undefined
|
|
155
|
+
},
|
|
156
|
+
borderRadius: {
|
|
157
|
+
s: 4,
|
|
158
|
+
m: 8,
|
|
159
|
+
l: 12
|
|
160
|
+
},
|
|
161
|
+
showCodeLanguage: true
|
|
162
|
+
};
|
|
163
|
+
const darkMarkdownTheme = exports.darkMarkdownTheme = defaultMarkdownTheme;
|
|
164
|
+
const mergeThemes = (base, partial) => {
|
|
165
|
+
if (!partial) return base;
|
|
166
|
+
return {
|
|
167
|
+
colors: {
|
|
168
|
+
...base.colors,
|
|
169
|
+
...partial.colors
|
|
170
|
+
},
|
|
171
|
+
spacing: {
|
|
172
|
+
...base.spacing,
|
|
173
|
+
...partial.spacing
|
|
174
|
+
},
|
|
175
|
+
fontSizes: {
|
|
176
|
+
...base.fontSizes,
|
|
177
|
+
...partial.fontSizes
|
|
178
|
+
},
|
|
179
|
+
fontFamilies: {
|
|
180
|
+
...base.fontFamilies,
|
|
181
|
+
...partial.fontFamilies
|
|
182
|
+
},
|
|
183
|
+
borderRadius: {
|
|
184
|
+
...base.borderRadius,
|
|
185
|
+
...partial.borderRadius
|
|
186
|
+
},
|
|
187
|
+
showCodeLanguage: partial.showCodeLanguage ?? base.showCodeLanguage
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
exports.mergeThemes = mergeThemes;
|
|
191
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultMarkdownTheme","exports","colors","text","textMuted","heading","link","code","codeBackground","codeLanguage","blockquote","border","surface","surfaceLight","accent","tableBorder","tableHeader","tableHeaderText","tableRowEven","tableRowOdd","spacing","xs","s","m","l","xl","fontSizes","h1","h2","h3","h4","h5","h6","fontFamilies","regular","undefined","mono","borderRadius","showCodeLanguage","minimalMarkdownTheme","lightMarkdownTheme","darkMarkdownTheme","mergeThemes","base","partial"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;;;;;AAwDO,MAAMA,oBAAmC,GAAAC,OAAA,CAAAD,oBAAA,GAAG;EACjDE,MAAM,EAAE;IACNC,IAAI,EAAE,SAAS;IACfC,SAAS,EAAE,MAAM;IACjBC,OAAO,EAAE,SAAS;IAClBC,IAAI,EAAE,SAAS;IACfC,IAAI,EAAE,SAAS;IACfC,cAAc,EAAE,SAAS;IACzBC,YAAY,EAAE,SAAS;IACvBC,UAAU,EAAE,SAAS;IACrBC,MAAM,EAAE,SAAS;IACjBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,MAAM,EAAE,SAAS;IACjBC,WAAW,EAAE,SAAS;IACtBC,WAAW,EAAE,SAAS;IACtBC,eAAe,EAAE,SAAS;IAC1BC,YAAY,EAAE,SAAS;IACvBC,WAAW,EAAE;EACf,CAAC;EACDC,OAAO,EAAE;IACPC,EAAE,EAAE,CAAC;IACLC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE,EAAE;IACLC,CAAC,EAAE,EAAE;IACLC,EAAE,EAAE;EACN,CAAC;EACDC,SAAS,EAAE;IACTL,EAAE,EAAE,EAAE;IACNC,CAAC,EAAE,EAAE;IACLC,CAAC,EAAE,EAAE;IACLC,CAAC,E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
+
exports.useMarkdownSession = useMarkdownSession;
|
|
7
|
+
exports.useStream = useStream;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _MarkdownSession = require("./MarkdownSession.js");
|
|
10
|
+
function useMarkdownSession() {
|
|
11
|
+
const sessionRef = (0, _react.useRef)(null);
|
|
12
|
+
if (sessionRef.current === null) {
|
|
13
|
+
sessionRef.current = (0, _MarkdownSession.createMarkdownSession)();
|
|
14
|
+
}
|
|
15
|
+
const [isStreaming, setIsStreaming] = (0, _react.useState)(false);
|
|
16
|
+
(0, _react.useEffect)(() => {
|
|
17
|
+
const session = sessionRef.current;
|
|
18
|
+
return () => {
|
|
19
|
+
session.clear();
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
const stop = (0, _react.useCallback)(() => {
|
|
23
|
+
setIsStreaming(false);
|
|
24
|
+
}, []);
|
|
25
|
+
const clear = (0, _react.useCallback)(() => {
|
|
26
|
+
stop();
|
|
27
|
+
sessionRef.current.clear();
|
|
28
|
+
sessionRef.current.highlightPosition = 0;
|
|
29
|
+
}, [stop]);
|
|
30
|
+
const setHighlight = (0, _react.useCallback)(position => {
|
|
31
|
+
sessionRef.current.highlightPosition = position;
|
|
32
|
+
}, []);
|
|
33
|
+
const getSession = (0, _react.useCallback)(() => sessionRef.current, []);
|
|
34
|
+
return {
|
|
35
|
+
getSession,
|
|
36
|
+
isStreaming,
|
|
37
|
+
setIsStreaming,
|
|
38
|
+
stop,
|
|
39
|
+
clear,
|
|
40
|
+
setHighlight
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function useStream(timestamps) {
|
|
44
|
+
const engine = useMarkdownSession();
|
|
45
|
+
const [isPlaying, setIsPlaying] = (0, _react.useState)(false);
|
|
46
|
+
const sortedKeys = (0, _react.useRef)([]);
|
|
47
|
+
(0, _react.useEffect)(() => {
|
|
48
|
+
if (timestamps) {
|
|
49
|
+
sortedKeys.current = Object.keys(timestamps).map(Number).sort((a, b) => a - b);
|
|
50
|
+
}
|
|
51
|
+
}, [timestamps]);
|
|
52
|
+
const sync = (0, _react.useCallback)(currentTimeMs => {
|
|
53
|
+
if (!timestamps) return;
|
|
54
|
+
let wordIdx = 0;
|
|
55
|
+
for (const idx of sortedKeys.current) {
|
|
56
|
+
if (currentTimeMs >= timestamps[idx]) {
|
|
57
|
+
wordIdx = idx + 1;
|
|
58
|
+
} else {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
engine.setHighlight(wordIdx);
|
|
63
|
+
}, [timestamps, engine]);
|
|
64
|
+
return {
|
|
65
|
+
...engine,
|
|
66
|
+
isPlaying,
|
|
67
|
+
setIsPlaying,
|
|
68
|
+
sync
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=use-markdown-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_MarkdownSession","useMarkdownSession","sessionRef","useRef","current","createMarkdownSession","isStreaming","setIsStreaming","useState","useEffect","session","clear","stop","useCallback","highlightPosition","setHighlight","position","getSession","useStream","timestamps","engine","isPlaying","setIsPlaying","sortedKeys","Object","keys","map","Number","sort","a","b","sync","currentTimeMs","wordIdx","idx"],"sourceRoot":"../../src","sources":["use-markdown-stream.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAIO,SAASE,kBAAkBA,CAAA,EAAG;EACnC,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAAyB,IAAI,CAAC;EACvD,IAAID,UAAU,CAACE,OAAO,KAAK,IAAI,EAAE;IAC/BF,UAAU,CAACE,OAAO,GAAG,IAAAC,sCAAqB,EAAC,CAAC;EAC9C;EAEA,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAErD,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,OAAO,GAAGR,UAAU,CAACE,OAA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AC1B;EACF,CAAC,EAAE,CAACX,UAAU,CAAC,CAAC;EAEhB,MAAMY,IAAI,GAAG,IAAAlB,kBAAW,EACrBmB,aAAqB,IAAK;IACzB,IAAI,CAACb,UAAU,EAAE;IAEjB,IAAIc,OAAO,GAAG,CAAC;IACf,KAAK,MAAMC,GAAG,IAAIX,UAAU,CAACnB,OAAO,EAAE;MACpC,IAAI4B,aAAa,IAAIb,UAAU,CAACe,GAAG,CAAC,EAAE;QACpCD,OAAO,GAAGC,GAAG,GAAG,CAAC;MACnB,CAAC,MAAM;QACL;MACF;IACF;IACAd,MAAM,CAACL,YAAY,CAACkB,OAAO,CAAC;EAC9B,CAAC,EACD,CAACd,UAAU,EAAEC,MAAM,CACrB,CAAC;EAED,OAAO;IACL,GAAGA,MAAM;IACTC,SAAS;IACTC,YAAY;IACZS;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { defaultMarkdownTheme } from "./theme.js";
|
|
5
|
+
export const MarkdownContext = /*#__PURE__*/createContext({
|
|
6
|
+
renderers: {},
|
|
7
|
+
theme: defaultMarkdownTheme,
|
|
8
|
+
styles: undefined,
|
|
9
|
+
stylingStrategy: "opinionated"
|
|
10
|
+
});
|
|
11
|
+
export const useMarkdownContext = () => useContext(MarkdownContext);
|
|
12
|
+
//# sourceMappingURL=MarkdownContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useContext","defaultMarkdownTheme","MarkdownContext","renderers","theme","styles","undefined","stylingStrategy","useMarkdownContext"],"sourceRoot":"../../src","sources":["MarkdownContext.ts"],"mappings":";;AAAA,SACEA,aAAa,EACbC,UAAU,QAGL,OAAO;AACd,SACEC,oBAAoB,QAIf,YAAS;AA+EhB,OAAO,MAAMC,eAAe,gBAAGH,aAAa,CAAuB;EACjEI,SAAS,EAAE,CAAC,CAAC;EACbC,KAAK,EAAEH,oBAAoB;EAC3BI,MAAM,EAAEC,SAAS;EACjBC,eAAe,EAAE;AACnB,CAAC,CAAC;AAEF,OAAO,MAAMC,kBAAkB,GAAGA,CAAA,KAAMR,UAAU,CAACE,eAAe,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NitroModules","createMarkdownSession","createHybridObject"],"sourceRoot":"../../src","sources":["MarkdownSession.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAKzD,OAAO,SAASC,qBAAqBA,CAAA,EAAoB;EACvD,OAAOD,YAAY,CAACE,kBAAkB,CAAkB,iBAAiB,CAAC;AAC5E","ignoreList":[]}
|