@incremark/react 0.2.2 → 0.2.4
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/dist/index.d.ts +58 -6
- package/dist/index.js +136 -37
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ParserOptions, AnimationEffect, TransformerPlugin, ParsedBlock, Root, IncrementalUpdate, IncremarkParser, SourceBlock, TransformerOptions, DisplayBlock, BlockTransformer, RootContent } from '@incremark/core';
|
|
1
|
+
import { ParserOptions, AnimationEffect, TransformerPlugin, ParsedBlock, Root, IncrementalUpdate, IncremarkParser, SourceBlock, TransformerOptions, DisplayBlock, BlockTransformer, RootContent as RootContent$1 } from '@incremark/core';
|
|
2
2
|
export { AnimationEffect, BlockTransformer, DisplayBlock, IncrementalUpdate, ParsedBlock, ParserOptions, Root, RootContent, SourceBlock, TransformerOptions, TransformerPlugin, TransformerState, allPlugins, cloneNode, codeBlockPlugin, countChars, createBlockTransformer, createPlugin, defaultPlugins, imagePlugin, mathPlugin, mermaidPlugin, sliceAst, thematicBreakPlugin } from '@incremark/core';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
-
import { Definition, FootnoteDefinition, RootContent
|
|
4
|
+
import { Definition, FootnoteDefinition, RootContent, PhrasingContent } from 'mdast';
|
|
5
5
|
import * as _incremark_devtools from '@incremark/devtools';
|
|
6
6
|
import { DevToolsOptions } from '@incremark/devtools';
|
|
7
7
|
import { DesignTokens } from '@incremark/theme';
|
|
@@ -298,6 +298,17 @@ interface IncremarkProps {
|
|
|
298
298
|
components?: Partial<Record<string, React.ComponentType<{
|
|
299
299
|
node: any;
|
|
300
300
|
}>>>;
|
|
301
|
+
/** 自定义容器组件映射,key 为容器名称(如 'warning', 'info') */
|
|
302
|
+
customContainers?: Record<string, React.ComponentType<{
|
|
303
|
+
name: string;
|
|
304
|
+
options?: Record<string, any>;
|
|
305
|
+
children?: React.ReactNode;
|
|
306
|
+
}>>;
|
|
307
|
+
/** 自定义代码块组件映射,key 为代码语言名称(如 'echart', 'mermaid') */
|
|
308
|
+
customCodeBlocks?: Record<string, React.ComponentType<{
|
|
309
|
+
codeStr: string;
|
|
310
|
+
lang?: string;
|
|
311
|
+
}>>;
|
|
301
312
|
/** 是否显示块状态(待处理块边框) */
|
|
302
313
|
showBlockStatus?: boolean;
|
|
303
314
|
/** 自定义类名 */
|
|
@@ -321,11 +332,32 @@ interface IncremarkProps {
|
|
|
321
332
|
*/
|
|
322
333
|
declare const Incremark: React.FC<IncremarkProps>;
|
|
323
334
|
|
|
335
|
+
/**
|
|
336
|
+
* 容器节点类型定义
|
|
337
|
+
* 根据 directive 解析后的结构
|
|
338
|
+
*/
|
|
339
|
+
interface ContainerNode {
|
|
340
|
+
type: 'containerDirective' | 'leafDirective' | 'textDirective';
|
|
341
|
+
name: string;
|
|
342
|
+
attributes?: Record<string, string>;
|
|
343
|
+
children?: RootContent[];
|
|
344
|
+
}
|
|
345
|
+
|
|
324
346
|
interface IncremarkRendererProps {
|
|
325
|
-
node: RootContent;
|
|
347
|
+
node: RootContent$1 | ContainerNode;
|
|
326
348
|
components?: Partial<Record<string, React.ComponentType<{
|
|
327
|
-
node: RootContent;
|
|
349
|
+
node: RootContent$1;
|
|
328
350
|
}>>>;
|
|
351
|
+
customContainers?: Record<string, React.ComponentType<{
|
|
352
|
+
name: string;
|
|
353
|
+
options?: Record<string, any>;
|
|
354
|
+
children?: React.ReactNode;
|
|
355
|
+
}>>;
|
|
356
|
+
customCodeBlocks?: Record<string, React.ComponentType<{
|
|
357
|
+
codeStr: string;
|
|
358
|
+
lang?: string;
|
|
359
|
+
}>>;
|
|
360
|
+
blockStatus?: 'pending' | 'stable' | 'completed';
|
|
329
361
|
}
|
|
330
362
|
/**
|
|
331
363
|
* 渲染单个 AST 节点
|
|
@@ -374,6 +406,26 @@ interface AutoScrollContainerRef {
|
|
|
374
406
|
*/
|
|
375
407
|
declare const AutoScrollContainer: React.ForwardRefExoticComponent<AutoScrollContainerProps & React.RefAttributes<AutoScrollContainerRef>>;
|
|
376
408
|
|
|
409
|
+
interface IncremarkInlineProps {
|
|
410
|
+
nodes: PhrasingContent[];
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* IncremarkInline 组件
|
|
414
|
+
*
|
|
415
|
+
* 渲染行内内容(文本、加粗、斜体、链接、图片等)
|
|
416
|
+
*
|
|
417
|
+
* 支持特性:
|
|
418
|
+
* - 文本节点(含 chunks 动画)
|
|
419
|
+
* - 加粗、斜体、删除线
|
|
420
|
+
* - 行内代码
|
|
421
|
+
* - 链接(link)和引用式链接(linkReference)
|
|
422
|
+
* - 图片(image)和引用式图片(imageReference)
|
|
423
|
+
* - HTML 元素
|
|
424
|
+
*
|
|
425
|
+
* 注意:此组件与 Vue 版本保持完全一致的逻辑和结构
|
|
426
|
+
*/
|
|
427
|
+
declare const IncremarkInline: React.FC<IncremarkInlineProps>;
|
|
428
|
+
|
|
377
429
|
/**
|
|
378
430
|
* HtmlElementNode 类型定义(与 @incremark/core 中的定义一致)
|
|
379
431
|
*/
|
|
@@ -381,7 +433,7 @@ interface HtmlElementNode {
|
|
|
381
433
|
type: 'htmlElement';
|
|
382
434
|
tagName: string;
|
|
383
435
|
attrs: Record<string, string>;
|
|
384
|
-
children: RootContent
|
|
436
|
+
children: RootContent[];
|
|
385
437
|
data?: {
|
|
386
438
|
rawHtml?: string;
|
|
387
439
|
parsed?: boolean;
|
|
@@ -489,4 +541,4 @@ interface ThemeProviderProps {
|
|
|
489
541
|
*/
|
|
490
542
|
declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
491
543
|
|
|
492
|
-
export { AutoScrollContainer, type AutoScrollContainerProps, type AutoScrollContainerRef, type DefinitionsContextValue, DefinitionsProvider, type DefinitionsProviderProps, type HtmlElementNode, Incremark, IncremarkContainerProvider, type IncremarkContainerProviderProps, IncremarkFootnotes, IncremarkHtmlElement, type IncremarkHtmlElementProps, type IncremarkProps, IncremarkRenderer, type IncremarkRendererProps, ThemeProvider, type ThemeProviderProps, type TypewriterControls, type TypewriterOptions, type UseBlockTransformerOptions, type UseBlockTransformerReturn, type UseDevToolsOptions, type UseIncremarkOptions, type UseIncremarkReturn, useBlockTransformer, useDefinitions, useDevTools, useIncremark };
|
|
544
|
+
export { AutoScrollContainer, type AutoScrollContainerProps, type AutoScrollContainerRef, type DefinitionsContextValue, DefinitionsProvider, type DefinitionsProviderProps, type HtmlElementNode, Incremark, IncremarkContainerProvider, type IncremarkContainerProviderProps, IncremarkFootnotes, IncremarkHtmlElement, type IncremarkHtmlElementProps, IncremarkInline, type IncremarkInlineProps, type IncremarkProps, IncremarkRenderer, type IncremarkRendererProps, ThemeProvider, type ThemeProviderProps, type TypewriterControls, type TypewriterOptions, type UseBlockTransformerOptions, type UseBlockTransformerReturn, type UseDevToolsOptions, type UseIncremarkOptions, type UseIncremarkReturn, useBlockTransformer, useDefinitions, useDevTools, useIncremark };
|
package/dist/index.js
CHANGED
|
@@ -822,13 +822,15 @@ var IncremarkParagraph = ({ node }) => {
|
|
|
822
822
|
};
|
|
823
823
|
|
|
824
824
|
// src/components/IncremarkCode.tsx
|
|
825
|
-
import { useState as useState5, useEffect as useEffect4, useRef as useRef5, useCallback as useCallback5 } from "react";
|
|
825
|
+
import React4, { useState as useState5, useEffect as useEffect4, useRef as useRef5, useCallback as useCallback5 } from "react";
|
|
826
826
|
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
827
827
|
var IncremarkCode = ({
|
|
828
828
|
node,
|
|
829
829
|
theme = "github-dark",
|
|
830
830
|
disableHighlight = false,
|
|
831
|
-
mermaidDelay = 500
|
|
831
|
+
mermaidDelay = 500,
|
|
832
|
+
customCodeBlocks,
|
|
833
|
+
blockStatus = "completed"
|
|
832
834
|
}) => {
|
|
833
835
|
const [copied, setCopied] = useState5(false);
|
|
834
836
|
const [highlightedHtml, setHighlightedHtml] = useState5("");
|
|
@@ -844,6 +846,13 @@ var IncremarkCode = ({
|
|
|
844
846
|
const language = node.lang || "text";
|
|
845
847
|
const code = node.value;
|
|
846
848
|
const isMermaid = language === "mermaid";
|
|
849
|
+
const CustomCodeBlock = React4.useMemo(() => {
|
|
850
|
+
if (blockStatus === "pending") {
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
853
|
+
return customCodeBlocks?.[language] || null;
|
|
854
|
+
}, [customCodeBlocks, language, blockStatus]);
|
|
855
|
+
const useCustomComponent = !!CustomCodeBlock;
|
|
847
856
|
const toggleMermaidView = useCallback5(() => {
|
|
848
857
|
setMermaidViewMode((prev) => prev === "preview" ? "source" : "preview");
|
|
849
858
|
}, []);
|
|
@@ -943,6 +952,9 @@ var IncremarkCode = ({
|
|
|
943
952
|
}
|
|
944
953
|
};
|
|
945
954
|
}, []);
|
|
955
|
+
if (useCustomComponent && CustomCodeBlock) {
|
|
956
|
+
return /* @__PURE__ */ jsx6(CustomCodeBlock, { codeStr: code, lang: language });
|
|
957
|
+
}
|
|
946
958
|
if (isMermaid) {
|
|
947
959
|
return /* @__PURE__ */ jsxs2("div", { className: "incremark-mermaid", children: [
|
|
948
960
|
/* @__PURE__ */ jsxs2("div", { className: "mermaid-header", children: [
|
|
@@ -975,19 +987,28 @@ var IncremarkCode = ({
|
|
|
975
987
|
|
|
976
988
|
// src/components/IncremarkList.tsx
|
|
977
989
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
978
|
-
function
|
|
990
|
+
function getItemInlineContent(item) {
|
|
979
991
|
const firstChild = item.children[0];
|
|
980
992
|
if (firstChild?.type === "paragraph") {
|
|
981
993
|
return firstChild.children;
|
|
982
994
|
}
|
|
983
995
|
return [];
|
|
984
996
|
}
|
|
997
|
+
function getItemBlockChildren(item) {
|
|
998
|
+
return item.children.filter((child, index) => {
|
|
999
|
+
if (index === 0 && child.type === "paragraph") {
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
return true;
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
985
1005
|
var IncremarkList = ({ node }) => {
|
|
986
1006
|
const Tag = node.ordered ? "ol" : "ul";
|
|
987
1007
|
const isTaskList = node.children?.some((item) => item.checked !== null && item.checked !== void 0);
|
|
988
1008
|
return /* @__PURE__ */ jsx7(Tag, { className: `incremark-list ${isTaskList ? "task-list" : ""}`, children: node.children?.map((item, index) => {
|
|
989
1009
|
const isTaskItem = item.checked !== null && item.checked !== void 0;
|
|
990
|
-
const
|
|
1010
|
+
const inlineContent = getItemInlineContent(item);
|
|
1011
|
+
const blockChildren = getItemBlockChildren(item);
|
|
991
1012
|
if (isTaskItem) {
|
|
992
1013
|
return /* @__PURE__ */ jsx7("li", { className: "incremark-list-item task-item", children: /* @__PURE__ */ jsxs3("label", { className: "task-label", children: [
|
|
993
1014
|
/* @__PURE__ */ jsx7(
|
|
@@ -999,10 +1020,18 @@ var IncremarkList = ({ node }) => {
|
|
|
999
1020
|
className: "checkbox"
|
|
1000
1021
|
}
|
|
1001
1022
|
),
|
|
1002
|
-
/* @__PURE__ */ jsx7("span", { className: "task-content", children: /* @__PURE__ */ jsx7(IncremarkInline, { nodes:
|
|
1023
|
+
/* @__PURE__ */ jsx7("span", { className: "task-content", children: /* @__PURE__ */ jsx7(IncremarkInline, { nodes: inlineContent }) })
|
|
1003
1024
|
] }) }, index);
|
|
1004
1025
|
}
|
|
1005
|
-
return /* @__PURE__ */
|
|
1026
|
+
return /* @__PURE__ */ jsxs3("li", { className: "incremark-list-item", children: [
|
|
1027
|
+
/* @__PURE__ */ jsx7(IncremarkInline, { nodes: inlineContent }),
|
|
1028
|
+
blockChildren.map((child, childIndex) => {
|
|
1029
|
+
if (child.type === "list") {
|
|
1030
|
+
return /* @__PURE__ */ jsx7(IncremarkList, { node: child }, childIndex);
|
|
1031
|
+
}
|
|
1032
|
+
return null;
|
|
1033
|
+
})
|
|
1034
|
+
] }, index);
|
|
1006
1035
|
}) });
|
|
1007
1036
|
};
|
|
1008
1037
|
|
|
@@ -1120,20 +1149,44 @@ var IncremarkDefault = ({ node }) => {
|
|
|
1120
1149
|
] });
|
|
1121
1150
|
};
|
|
1122
1151
|
|
|
1152
|
+
// src/components/IncremarkContainer.tsx
|
|
1153
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1154
|
+
function parseOptions(attributes) {
|
|
1155
|
+
if (!attributes) return {};
|
|
1156
|
+
const options = {};
|
|
1157
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
1158
|
+
try {
|
|
1159
|
+
options[key] = JSON.parse(value);
|
|
1160
|
+
} catch {
|
|
1161
|
+
options[key] = value;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
return options;
|
|
1165
|
+
}
|
|
1166
|
+
var IncremarkContainer = ({ node, customContainers }) => {
|
|
1167
|
+
const containerName = node.name;
|
|
1168
|
+
const options = parseOptions(node.attributes);
|
|
1169
|
+
const CustomContainer = customContainers?.[containerName];
|
|
1170
|
+
if (CustomContainer) {
|
|
1171
|
+
return /* @__PURE__ */ jsx13(CustomContainer, { name: containerName, options, children: node.children?.map((child, index) => /* @__PURE__ */ jsx13(IncremarkRenderer, { node: child }, index)) });
|
|
1172
|
+
}
|
|
1173
|
+
return /* @__PURE__ */ jsx13("div", { className: `incremark-container incremark-container-${containerName}`, children: node.children && node.children.length > 0 && /* @__PURE__ */ jsx13("div", { className: "incremark-container-content", children: node.children.map((child, index) => /* @__PURE__ */ jsx13(IncremarkRenderer, { node: child }, index)) }) });
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1123
1176
|
// src/components/IncremarkRenderer.tsx
|
|
1124
|
-
import { Fragment as Fragment2, jsx as
|
|
1177
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1125
1178
|
var DefaultHeading = ({ node }) => {
|
|
1126
|
-
return /* @__PURE__ */
|
|
1179
|
+
return /* @__PURE__ */ jsx14(IncremarkHeading, { node });
|
|
1127
1180
|
};
|
|
1128
|
-
var DefaultParagraph = ({ node }) => /* @__PURE__ */
|
|
1129
|
-
var DefaultCode = ({ node }) => /* @__PURE__ */
|
|
1130
|
-
var DefaultList = ({ node }) => /* @__PURE__ */
|
|
1131
|
-
var DefaultBlockquote = ({ node }) => /* @__PURE__ */
|
|
1132
|
-
var DefaultTable = ({ node }) => /* @__PURE__ */
|
|
1133
|
-
var DefaultThematicBreak = () => /* @__PURE__ */
|
|
1134
|
-
var DefaultMath = ({ node }) => /* @__PURE__ */
|
|
1135
|
-
var DefaultHtmlElement = ({ node }) => /* @__PURE__ */
|
|
1136
|
-
var DefaultDefault = ({ node }) => /* @__PURE__ */
|
|
1181
|
+
var DefaultParagraph = ({ node }) => /* @__PURE__ */ jsx14(IncremarkParagraph, { node });
|
|
1182
|
+
var DefaultCode = ({ node }) => /* @__PURE__ */ jsx14(IncremarkCode, { node });
|
|
1183
|
+
var DefaultList = ({ node }) => /* @__PURE__ */ jsx14(IncremarkList, { node });
|
|
1184
|
+
var DefaultBlockquote = ({ node }) => /* @__PURE__ */ jsx14(IncremarkBlockquote, { node });
|
|
1185
|
+
var DefaultTable = ({ node }) => /* @__PURE__ */ jsx14(IncremarkTable, { node });
|
|
1186
|
+
var DefaultThematicBreak = () => /* @__PURE__ */ jsx14(IncremarkThematicBreak, {});
|
|
1187
|
+
var DefaultMath = ({ node }) => /* @__PURE__ */ jsx14(IncremarkMath, { node });
|
|
1188
|
+
var DefaultHtmlElement = ({ node }) => /* @__PURE__ */ jsx14(IncremarkHtmlElement, { node });
|
|
1189
|
+
var DefaultDefault = ({ node }) => /* @__PURE__ */ jsx14(IncremarkDefault, { node });
|
|
1137
1190
|
var defaultComponents = {
|
|
1138
1191
|
heading: DefaultHeading,
|
|
1139
1192
|
paragraph: DefaultParagraph,
|
|
@@ -1147,21 +1200,49 @@ var defaultComponents = {
|
|
|
1147
1200
|
htmlElement: DefaultHtmlElement,
|
|
1148
1201
|
default: DefaultDefault
|
|
1149
1202
|
};
|
|
1150
|
-
|
|
1203
|
+
function isContainerNode(node) {
|
|
1204
|
+
return node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective";
|
|
1205
|
+
}
|
|
1206
|
+
var IncremarkRenderer = ({
|
|
1207
|
+
node,
|
|
1208
|
+
components = {},
|
|
1209
|
+
customContainers,
|
|
1210
|
+
customCodeBlocks,
|
|
1211
|
+
blockStatus
|
|
1212
|
+
}) => {
|
|
1151
1213
|
if (node.type === "footnoteDefinition") {
|
|
1152
1214
|
return null;
|
|
1153
1215
|
}
|
|
1154
1216
|
if (node.type === "html") {
|
|
1155
|
-
return /* @__PURE__ */
|
|
1217
|
+
return /* @__PURE__ */ jsx14("pre", { className: "incremark-html-code", children: /* @__PURE__ */ jsx14("code", { children: node.value }) });
|
|
1218
|
+
}
|
|
1219
|
+
if (isContainerNode(node)) {
|
|
1220
|
+
return /* @__PURE__ */ jsx14(
|
|
1221
|
+
IncremarkContainer,
|
|
1222
|
+
{
|
|
1223
|
+
node,
|
|
1224
|
+
customContainers
|
|
1225
|
+
}
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
if (node.type === "code") {
|
|
1229
|
+
return /* @__PURE__ */ jsx14(
|
|
1230
|
+
IncremarkCode,
|
|
1231
|
+
{
|
|
1232
|
+
node,
|
|
1233
|
+
customCodeBlocks,
|
|
1234
|
+
blockStatus
|
|
1235
|
+
}
|
|
1236
|
+
);
|
|
1156
1237
|
}
|
|
1157
1238
|
const mergedComponents = { ...defaultComponents, ...components };
|
|
1158
1239
|
const Component = mergedComponents[node.type] || DefaultDefault;
|
|
1159
|
-
return /* @__PURE__ */
|
|
1240
|
+
return /* @__PURE__ */ jsx14(Component, { node });
|
|
1160
1241
|
};
|
|
1161
1242
|
|
|
1162
1243
|
// src/components/IncremarkFootnotes.tsx
|
|
1163
1244
|
import React7 from "react";
|
|
1164
|
-
import { jsx as
|
|
1245
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1165
1246
|
var IncremarkFootnotes = () => {
|
|
1166
1247
|
const { footnoteDefinitions, footnoteReferenceOrder } = useDefinitions();
|
|
1167
1248
|
const orderedFootnotes = React7.useMemo(() => {
|
|
@@ -1174,8 +1255,8 @@ var IncremarkFootnotes = () => {
|
|
|
1174
1255
|
return null;
|
|
1175
1256
|
}
|
|
1176
1257
|
return /* @__PURE__ */ jsxs7("section", { className: "incremark-footnotes", children: [
|
|
1177
|
-
/* @__PURE__ */
|
|
1178
|
-
/* @__PURE__ */
|
|
1258
|
+
/* @__PURE__ */ jsx15("hr", { className: "incremark-footnotes-divider" }),
|
|
1259
|
+
/* @__PURE__ */ jsx15("ol", { className: "incremark-footnotes-list", children: orderedFootnotes.map((item, index) => /* @__PURE__ */ jsxs7(
|
|
1179
1260
|
"li",
|
|
1180
1261
|
{
|
|
1181
1262
|
id: `fn-${item.identifier}`,
|
|
@@ -1186,9 +1267,9 @@ var IncremarkFootnotes = () => {
|
|
|
1186
1267
|
index + 1,
|
|
1187
1268
|
"."
|
|
1188
1269
|
] }),
|
|
1189
|
-
/* @__PURE__ */
|
|
1270
|
+
/* @__PURE__ */ jsx15("div", { className: "incremark-footnote-body", children: item.definition.children.map((child, childIndex) => /* @__PURE__ */ jsx15(IncremarkRenderer, { node: child }, childIndex)) })
|
|
1190
1271
|
] }),
|
|
1191
|
-
/* @__PURE__ */
|
|
1272
|
+
/* @__PURE__ */ jsx15(
|
|
1192
1273
|
"a",
|
|
1193
1274
|
{
|
|
1194
1275
|
href: `#fnref-${item.identifier}`,
|
|
@@ -1205,28 +1286,32 @@ var IncremarkFootnotes = () => {
|
|
|
1205
1286
|
};
|
|
1206
1287
|
|
|
1207
1288
|
// src/components/IncremarkContainerProvider.tsx
|
|
1208
|
-
import { jsx as
|
|
1289
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1209
1290
|
var IncremarkContainerProvider = ({ children, definitions }) => {
|
|
1210
|
-
return /* @__PURE__ */
|
|
1291
|
+
return /* @__PURE__ */ jsx16(DefinitionsContext.Provider, { value: definitions, children });
|
|
1211
1292
|
};
|
|
1212
1293
|
|
|
1213
1294
|
// src/components/Incremark.tsx
|
|
1214
|
-
import { jsx as
|
|
1295
|
+
import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1215
1296
|
var Incremark = (props) => {
|
|
1216
1297
|
const {
|
|
1217
1298
|
blocks: propsBlocks,
|
|
1218
1299
|
components,
|
|
1300
|
+
customContainers,
|
|
1301
|
+
customCodeBlocks,
|
|
1219
1302
|
showBlockStatus = true,
|
|
1220
1303
|
className = "",
|
|
1221
1304
|
incremark
|
|
1222
1305
|
} = props;
|
|
1223
1306
|
if (incremark) {
|
|
1224
1307
|
const { blocks: blocks2, isFinalized: isFinalized2, _definitionsContextValue } = incremark;
|
|
1225
|
-
return /* @__PURE__ */
|
|
1308
|
+
return /* @__PURE__ */ jsx17(IncremarkContainerProvider, { definitions: _definitionsContextValue, children: /* @__PURE__ */ jsx17(
|
|
1226
1309
|
IncremarkInternal,
|
|
1227
1310
|
{
|
|
1228
1311
|
blocks: blocks2,
|
|
1229
1312
|
components,
|
|
1313
|
+
customContainers,
|
|
1314
|
+
customCodeBlocks,
|
|
1230
1315
|
showBlockStatus,
|
|
1231
1316
|
className,
|
|
1232
1317
|
isFinalized: isFinalized2
|
|
@@ -1235,11 +1320,13 @@ var Incremark = (props) => {
|
|
|
1235
1320
|
}
|
|
1236
1321
|
const blocks = propsBlocks || [];
|
|
1237
1322
|
const isFinalized = blocks.length > 0 && blocks.every((b) => b.status === "completed");
|
|
1238
|
-
return /* @__PURE__ */
|
|
1323
|
+
return /* @__PURE__ */ jsx17(
|
|
1239
1324
|
IncremarkInternal,
|
|
1240
1325
|
{
|
|
1241
1326
|
blocks,
|
|
1242
1327
|
components,
|
|
1328
|
+
customContainers,
|
|
1329
|
+
customCodeBlocks,
|
|
1243
1330
|
showBlockStatus,
|
|
1244
1331
|
className,
|
|
1245
1332
|
isFinalized
|
|
@@ -1249,6 +1336,8 @@ var Incremark = (props) => {
|
|
|
1249
1336
|
var IncremarkInternal = ({
|
|
1250
1337
|
blocks,
|
|
1251
1338
|
components,
|
|
1339
|
+
customContainers,
|
|
1340
|
+
customCodeBlocks,
|
|
1252
1341
|
showBlockStatus,
|
|
1253
1342
|
className,
|
|
1254
1343
|
isFinalized
|
|
@@ -1265,9 +1354,18 @@ var IncremarkInternal = ({
|
|
|
1265
1354
|
showBlockStatus && "incremark-show-status",
|
|
1266
1355
|
block.isLastPending && "incremark-last-pending"
|
|
1267
1356
|
].filter(Boolean).join(" ");
|
|
1268
|
-
return /* @__PURE__ */
|
|
1357
|
+
return /* @__PURE__ */ jsx17("div", { className: classes, children: /* @__PURE__ */ jsx17(
|
|
1358
|
+
IncremarkRenderer,
|
|
1359
|
+
{
|
|
1360
|
+
node: block.node,
|
|
1361
|
+
components,
|
|
1362
|
+
customContainers,
|
|
1363
|
+
customCodeBlocks,
|
|
1364
|
+
blockStatus: block.status
|
|
1365
|
+
}
|
|
1366
|
+
) }, block.stableId);
|
|
1269
1367
|
}),
|
|
1270
|
-
isFinalized && /* @__PURE__ */
|
|
1368
|
+
isFinalized && /* @__PURE__ */ jsx17(IncremarkFootnotes, {})
|
|
1271
1369
|
] });
|
|
1272
1370
|
};
|
|
1273
1371
|
|
|
@@ -1280,7 +1378,7 @@ import {
|
|
|
1280
1378
|
forwardRef,
|
|
1281
1379
|
useImperativeHandle
|
|
1282
1380
|
} from "react";
|
|
1283
|
-
import { jsx as
|
|
1381
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1284
1382
|
var AutoScrollContainer = forwardRef(
|
|
1285
1383
|
({
|
|
1286
1384
|
children,
|
|
@@ -1378,11 +1476,11 @@ var AutoScrollContainer = forwardRef(
|
|
|
1378
1476
|
}),
|
|
1379
1477
|
[scrollToBottom, isUserScrolledUp]
|
|
1380
1478
|
);
|
|
1381
|
-
return /* @__PURE__ */
|
|
1479
|
+
return /* @__PURE__ */ jsx18(
|
|
1382
1480
|
"div",
|
|
1383
1481
|
{
|
|
1384
1482
|
ref: containerRef,
|
|
1385
|
-
className,
|
|
1483
|
+
className: `auto-scroll-container ${className || ""}`.trim(),
|
|
1386
1484
|
style: {
|
|
1387
1485
|
overflowY: "auto",
|
|
1388
1486
|
height: "100%",
|
|
@@ -1399,7 +1497,7 @@ AutoScrollContainer.displayName = "AutoScrollContainer";
|
|
|
1399
1497
|
// src/ThemeProvider.tsx
|
|
1400
1498
|
import { useEffect as useEffect7, useRef as useRef8 } from "react";
|
|
1401
1499
|
import { applyTheme } from "@incremark/theme";
|
|
1402
|
-
import { jsx as
|
|
1500
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1403
1501
|
var ThemeProvider = ({
|
|
1404
1502
|
theme,
|
|
1405
1503
|
children,
|
|
@@ -1411,7 +1509,7 @@ var ThemeProvider = ({
|
|
|
1411
1509
|
applyTheme(containerRef.current, theme);
|
|
1412
1510
|
}
|
|
1413
1511
|
}, [theme]);
|
|
1414
|
-
return /* @__PURE__ */
|
|
1512
|
+
return /* @__PURE__ */ jsx19("div", { ref: containerRef, className: `incremark-theme-provider ${className}`.trim(), children });
|
|
1415
1513
|
};
|
|
1416
1514
|
|
|
1417
1515
|
// src/index.ts
|
|
@@ -1445,6 +1543,7 @@ export {
|
|
|
1445
1543
|
IncremarkContainerProvider,
|
|
1446
1544
|
IncremarkFootnotes,
|
|
1447
1545
|
IncremarkHtmlElement,
|
|
1546
|
+
IncremarkInline,
|
|
1448
1547
|
IncremarkRenderer,
|
|
1449
1548
|
ThemeProvider,
|
|
1450
1549
|
allPlugins,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@incremark/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Incremark React integration - Incremental Markdown parser for AI streaming",
|
|
6
6
|
"type": "module",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"mermaid": "^10.0.0 || ^11.0.0",
|
|
22
22
|
"katex": "^0.16.0",
|
|
23
23
|
"react": ">=18.0.0",
|
|
24
|
-
"@incremark/core": "0.2.
|
|
24
|
+
"@incremark/core": "0.2.4"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"shiki": "^3.20.0",
|
|
28
|
-
"@incremark/
|
|
29
|
-
"@incremark/shared": "0.2.
|
|
30
|
-
"@incremark/
|
|
28
|
+
"@incremark/theme": "0.2.4",
|
|
29
|
+
"@incremark/shared": "0.2.4",
|
|
30
|
+
"@incremark/devtools": "0.2.4"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/mdast": "^4.0.0",
|