@incremark/react 0.2.5 → 0.2.6
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 +24 -5
- package/dist/index.js +104 -91
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParserOptions, AnimationEffect, TransformerPlugin, ParsedBlock, Root, IncrementalUpdate, IncremarkParser, SourceBlock, TransformerOptions, DisplayBlock, BlockTransformer
|
|
1
|
+
import { ParserOptions, AnimationEffect, TransformerPlugin, ParsedBlock, Root, IncrementalUpdate, IncremarkParser, SourceBlock, TransformerOptions, DisplayBlock, BlockTransformer } 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
4
|
import { Definition, FootnoteDefinition, RootContent, PhrasingContent } from 'mdast';
|
|
@@ -298,9 +298,19 @@ interface BlockWithStableId extends ParsedBlock {
|
|
|
298
298
|
stableId: string;
|
|
299
299
|
isLastPending?: boolean;
|
|
300
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* 代码块配置
|
|
303
|
+
*/
|
|
304
|
+
interface CodeBlockConfig {
|
|
305
|
+
/** 是否从一开始就接管渲染,而不是等到 completed 状态 */
|
|
306
|
+
takeOver?: boolean;
|
|
307
|
+
}
|
|
301
308
|
interface IncremarkProps {
|
|
302
309
|
/** 要渲染的块列表 */
|
|
303
310
|
blocks?: BlockWithStableId[];
|
|
311
|
+
/** 内容是否完全显示完成(用于控制脚注等需要在内容完全显示后才出现的元素)
|
|
312
|
+
* 如果传入了 incremark,则会自动使用 incremark.isDisplayComplete,此 prop 被忽略 */
|
|
313
|
+
isDisplayComplete?: boolean;
|
|
304
314
|
/** 自定义组件映射 */
|
|
305
315
|
components?: Partial<Record<string, React.ComponentType<{
|
|
306
316
|
node: any;
|
|
@@ -314,8 +324,12 @@ interface IncremarkProps {
|
|
|
314
324
|
/** 自定义代码块组件映射,key 为代码语言名称(如 'echart', 'mermaid') */
|
|
315
325
|
customCodeBlocks?: Record<string, React.ComponentType<{
|
|
316
326
|
codeStr: string;
|
|
317
|
-
lang?: string;
|
|
327
|
+
lang?: string | undefined;
|
|
328
|
+
completed?: boolean | undefined;
|
|
329
|
+
takeOver?: boolean | undefined;
|
|
318
330
|
}>>;
|
|
331
|
+
/** 代码块配置映射,key 为代码语言名称 */
|
|
332
|
+
codeBlockConfigs?: Record<string, CodeBlockConfig>;
|
|
319
333
|
/** 是否显示块状态(待处理块边框) */
|
|
320
334
|
showBlockStatus?: boolean;
|
|
321
335
|
/** 自定义类名 */
|
|
@@ -351,19 +365,24 @@ interface ContainerNode {
|
|
|
351
365
|
}
|
|
352
366
|
|
|
353
367
|
interface IncremarkRendererProps {
|
|
354
|
-
node: RootContent
|
|
368
|
+
node: RootContent | ContainerNode;
|
|
355
369
|
components?: Partial<Record<string, React.ComponentType<{
|
|
356
|
-
node:
|
|
370
|
+
node: any;
|
|
357
371
|
}>>>;
|
|
358
372
|
customContainers?: Record<string, React.ComponentType<{
|
|
359
373
|
name: string;
|
|
360
374
|
options?: Record<string, any>;
|
|
361
|
-
children?:
|
|
375
|
+
children?: ReactNode;
|
|
362
376
|
}>>;
|
|
363
377
|
customCodeBlocks?: Record<string, React.ComponentType<{
|
|
364
378
|
codeStr: string;
|
|
365
379
|
lang?: string;
|
|
380
|
+
completed?: boolean;
|
|
381
|
+
takeOver?: boolean;
|
|
366
382
|
}>>;
|
|
383
|
+
codeBlockConfigs?: Record<string, {
|
|
384
|
+
takeOver?: boolean;
|
|
385
|
+
}>;
|
|
367
386
|
blockStatus?: 'pending' | 'stable' | 'completed';
|
|
368
387
|
}
|
|
369
388
|
/**
|
package/dist/index.js
CHANGED
|
@@ -326,12 +326,34 @@ function useIncremark(options = {}) {
|
|
|
326
326
|
const [pendingBlocks, setPendingBlocks] = useState3([]);
|
|
327
327
|
const [isLoading, setIsLoading] = useState3(false);
|
|
328
328
|
const [isFinalized, setIsFinalized] = useState3(false);
|
|
329
|
+
const handleUpdate = useCallback3(
|
|
330
|
+
(update, isFinalize) => {
|
|
331
|
+
setMarkdown(parser.getBuffer());
|
|
332
|
+
if (update.completed.length > 0) {
|
|
333
|
+
setCompletedBlocks((prev) => [...prev, ...update.completed]);
|
|
334
|
+
}
|
|
335
|
+
setPendingBlocks(update.pending);
|
|
336
|
+
if (isFinalize) {
|
|
337
|
+
setIsLoading(false);
|
|
338
|
+
setIsFinalized(true);
|
|
339
|
+
} else {
|
|
340
|
+
setIsLoading(true);
|
|
341
|
+
}
|
|
342
|
+
setFootnoteReferenceOrder(update.footnoteReferenceOrder);
|
|
343
|
+
},
|
|
344
|
+
[parser, setFootnoteReferenceOrder]
|
|
345
|
+
);
|
|
329
346
|
const { blocks, typewriter, transformer, isAnimationComplete } = useTypewriter({
|
|
330
347
|
typewriter: options.typewriter,
|
|
331
348
|
completedBlocks,
|
|
332
349
|
pendingBlocks
|
|
333
350
|
});
|
|
334
|
-
const isDisplayComplete =
|
|
351
|
+
const isDisplayComplete = useMemo2(() => {
|
|
352
|
+
if (!options.typewriter || !typewriter.enabled) {
|
|
353
|
+
return isFinalized;
|
|
354
|
+
}
|
|
355
|
+
return isFinalized && isAnimationComplete;
|
|
356
|
+
}, [options.typewriter, typewriter.enabled, isFinalized, isAnimationComplete]);
|
|
335
357
|
const ast = useMemo2(
|
|
336
358
|
() => ({
|
|
337
359
|
type: "root",
|
|
@@ -341,30 +363,17 @@ function useIncremark(options = {}) {
|
|
|
341
363
|
);
|
|
342
364
|
const append = useCallback3(
|
|
343
365
|
(chunk) => {
|
|
344
|
-
setIsLoading(true);
|
|
345
366
|
const update = parser.append(chunk);
|
|
346
|
-
|
|
347
|
-
if (update.completed.length > 0) {
|
|
348
|
-
setCompletedBlocks((prev) => [...prev, ...update.completed]);
|
|
349
|
-
}
|
|
350
|
-
setPendingBlocks(update.pending);
|
|
351
|
-
setFootnoteReferenceOrder(update.footnoteReferenceOrder);
|
|
367
|
+
handleUpdate(update, false);
|
|
352
368
|
return update;
|
|
353
369
|
},
|
|
354
|
-
[parser,
|
|
370
|
+
[parser, handleUpdate]
|
|
355
371
|
);
|
|
356
372
|
const finalize = useCallback3(() => {
|
|
357
373
|
const update = parser.finalize();
|
|
358
|
-
|
|
359
|
-
if (update.completed.length > 0) {
|
|
360
|
-
setCompletedBlocks((prev) => [...prev, ...update.completed]);
|
|
361
|
-
}
|
|
362
|
-
setPendingBlocks([]);
|
|
363
|
-
setIsLoading(false);
|
|
364
|
-
setIsFinalized(true);
|
|
365
|
-
setFootnoteReferenceOrder(update.footnoteReferenceOrder);
|
|
374
|
+
handleUpdate(update, true);
|
|
366
375
|
return update;
|
|
367
|
-
}, [parser,
|
|
376
|
+
}, [parser, handleUpdate]);
|
|
368
377
|
const abort = useCallback3(() => {
|
|
369
378
|
return finalize();
|
|
370
379
|
}, [finalize]);
|
|
@@ -538,9 +547,6 @@ function useBlockTransformer(sourceBlocks, options = {}) {
|
|
|
538
547
|
};
|
|
539
548
|
}
|
|
540
549
|
|
|
541
|
-
// src/components/IncremarkRenderer.tsx
|
|
542
|
-
import React6 from "react";
|
|
543
|
-
|
|
544
550
|
// src/components/IncremarkInline.tsx
|
|
545
551
|
import React3 from "react";
|
|
546
552
|
import {
|
|
@@ -843,10 +849,12 @@ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
|
843
849
|
var IncremarkCode = ({
|
|
844
850
|
node,
|
|
845
851
|
theme = "github-dark",
|
|
852
|
+
fallbackTheme = "github-dark",
|
|
846
853
|
disableHighlight = false,
|
|
847
854
|
mermaidDelay = 500,
|
|
848
855
|
customCodeBlocks,
|
|
849
|
-
blockStatus = "completed"
|
|
856
|
+
blockStatus = "completed",
|
|
857
|
+
codeBlockConfigs
|
|
850
858
|
}) => {
|
|
851
859
|
const [copied, setCopied] = useState5(false);
|
|
852
860
|
const [highlightedHtml, setHighlightedHtml] = useState5("");
|
|
@@ -863,12 +871,17 @@ var IncremarkCode = ({
|
|
|
863
871
|
const code = node.value;
|
|
864
872
|
const isMermaid = language === "mermaid";
|
|
865
873
|
const CustomCodeBlock = React4.useMemo(() => {
|
|
866
|
-
|
|
874
|
+
const component = customCodeBlocks?.[language];
|
|
875
|
+
if (!component) return null;
|
|
876
|
+
const config = codeBlockConfigs?.[language];
|
|
877
|
+
if (config?.takeOver) {
|
|
878
|
+
return component;
|
|
879
|
+
}
|
|
880
|
+
if (blockStatus !== "completed") {
|
|
867
881
|
return null;
|
|
868
882
|
}
|
|
869
|
-
return
|
|
870
|
-
}, [customCodeBlocks, language, blockStatus]);
|
|
871
|
-
const useCustomComponent = !!CustomCodeBlock;
|
|
883
|
+
return component;
|
|
884
|
+
}, [customCodeBlocks, language, blockStatus, codeBlockConfigs]);
|
|
872
885
|
const toggleMermaidView = useCallback5(() => {
|
|
873
886
|
setMermaidViewMode((prev) => prev === "preview" ? "source" : "preview");
|
|
874
887
|
}, []);
|
|
@@ -949,7 +962,7 @@ var IncremarkCode = ({
|
|
|
949
962
|
}
|
|
950
963
|
const html = highlighter.codeToHtml(code, {
|
|
951
964
|
lang: loadedLanguagesRef.current.has(lang) ? lang : "text",
|
|
952
|
-
theme: loadedThemesRef.current.has(theme) ? theme :
|
|
965
|
+
theme: loadedThemesRef.current.has(theme) ? theme : fallbackTheme
|
|
953
966
|
});
|
|
954
967
|
setHighlightedHtml(html);
|
|
955
968
|
} catch {
|
|
@@ -957,7 +970,7 @@ var IncremarkCode = ({
|
|
|
957
970
|
} finally {
|
|
958
971
|
setIsHighlighting(false);
|
|
959
972
|
}
|
|
960
|
-
}, [code, language, theme, disableHighlight, isMermaid, scheduleRenderMermaid]);
|
|
973
|
+
}, [code, language, theme, fallbackTheme, disableHighlight, isMermaid, scheduleRenderMermaid]);
|
|
961
974
|
useEffect4(() => {
|
|
962
975
|
highlight();
|
|
963
976
|
}, [highlight]);
|
|
@@ -968,8 +981,17 @@ var IncremarkCode = ({
|
|
|
968
981
|
}
|
|
969
982
|
};
|
|
970
983
|
}, []);
|
|
971
|
-
if (
|
|
972
|
-
|
|
984
|
+
if (CustomCodeBlock) {
|
|
985
|
+
const config = codeBlockConfigs?.[language];
|
|
986
|
+
return /* @__PURE__ */ jsx6(
|
|
987
|
+
CustomCodeBlock,
|
|
988
|
+
{
|
|
989
|
+
codeStr: code,
|
|
990
|
+
lang: language,
|
|
991
|
+
completed: blockStatus === "completed",
|
|
992
|
+
takeOver: config?.takeOver
|
|
993
|
+
}
|
|
994
|
+
);
|
|
973
995
|
}
|
|
974
996
|
if (isMermaid) {
|
|
975
997
|
return /* @__PURE__ */ jsxs2("div", { className: "incremark-mermaid", children: [
|
|
@@ -1002,6 +1024,7 @@ var IncremarkCode = ({
|
|
|
1002
1024
|
};
|
|
1003
1025
|
|
|
1004
1026
|
// src/components/IncremarkList.tsx
|
|
1027
|
+
import React5 from "react";
|
|
1005
1028
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1006
1029
|
function getItemInlineContent(item) {
|
|
1007
1030
|
const firstChild = item.children[0];
|
|
@@ -1041,25 +1064,16 @@ var IncremarkList = ({ node }) => {
|
|
|
1041
1064
|
}
|
|
1042
1065
|
return /* @__PURE__ */ jsxs3("li", { className: "incremark-list-item", children: [
|
|
1043
1066
|
/* @__PURE__ */ jsx7(IncremarkInline, { nodes: inlineContent }),
|
|
1044
|
-
blockChildren.map((child, childIndex) => {
|
|
1045
|
-
if (child.type === "list") {
|
|
1046
|
-
return /* @__PURE__ */ jsx7(IncremarkList, { node: child }, childIndex);
|
|
1047
|
-
}
|
|
1048
|
-
return null;
|
|
1049
|
-
})
|
|
1067
|
+
blockChildren.map((child, childIndex) => /* @__PURE__ */ jsx7(React5.Fragment, { children: /* @__PURE__ */ jsx7(IncremarkRenderer, { node: child }) }, childIndex))
|
|
1050
1068
|
] }, index);
|
|
1051
1069
|
}) });
|
|
1052
1070
|
};
|
|
1053
1071
|
|
|
1054
1072
|
// src/components/IncremarkBlockquote.tsx
|
|
1073
|
+
import React6 from "react";
|
|
1055
1074
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1056
1075
|
var IncremarkBlockquote = ({ node }) => {
|
|
1057
|
-
return /* @__PURE__ */ jsx8("blockquote", { className: "incremark-blockquote", children: node.children.map((child, index) => {
|
|
1058
|
-
if (child.type === "paragraph") {
|
|
1059
|
-
return /* @__PURE__ */ jsx8(IncremarkParagraph, { node: child }, index);
|
|
1060
|
-
}
|
|
1061
|
-
return /* @__PURE__ */ jsx8("div", { className: "unknown-child", children: child.type }, index);
|
|
1062
|
-
}) });
|
|
1076
|
+
return /* @__PURE__ */ jsx8("blockquote", { className: "incremark-blockquote", children: node.children.map((child, index) => /* @__PURE__ */ jsx8(React6.Fragment, { children: /* @__PURE__ */ jsx8(IncremarkRenderer, { node: child }) }, index)) });
|
|
1063
1077
|
};
|
|
1064
1078
|
|
|
1065
1079
|
// src/components/IncremarkTable.tsx
|
|
@@ -1156,17 +1170,8 @@ var IncremarkMath = ({
|
|
|
1156
1170
|
return /* @__PURE__ */ jsx11("div", { className: "incremark-math-block", children: renderedHtml && !isLoading ? /* @__PURE__ */ jsx11("div", { className: "math-rendered", dangerouslySetInnerHTML: { __html: renderedHtml } }) : /* @__PURE__ */ jsx11("pre", { className: "math-source-block", children: /* @__PURE__ */ jsx11("code", { children: formula }) }) });
|
|
1157
1171
|
};
|
|
1158
1172
|
|
|
1159
|
-
// src/components/IncremarkDefault.tsx
|
|
1160
|
-
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1161
|
-
var IncremarkDefault = ({ node }) => {
|
|
1162
|
-
return /* @__PURE__ */ jsxs5("div", { className: "incremark-default", children: [
|
|
1163
|
-
/* @__PURE__ */ jsx12("span", { className: "type-badge", children: node.type }),
|
|
1164
|
-
/* @__PURE__ */ jsx12("pre", { children: JSON.stringify(node, null, 2) })
|
|
1165
|
-
] });
|
|
1166
|
-
};
|
|
1167
|
-
|
|
1168
1173
|
// src/components/IncremarkContainer.tsx
|
|
1169
|
-
import { jsx as
|
|
1174
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1170
1175
|
function parseOptions(attributes) {
|
|
1171
1176
|
if (!attributes) return {};
|
|
1172
1177
|
const options = {};
|
|
@@ -1184,52 +1189,57 @@ var IncremarkContainer = ({ node, customContainers }) => {
|
|
|
1184
1189
|
const options = parseOptions(node.attributes);
|
|
1185
1190
|
const CustomContainer = customContainers?.[containerName];
|
|
1186
1191
|
if (CustomContainer) {
|
|
1187
|
-
return /* @__PURE__ */
|
|
1192
|
+
return /* @__PURE__ */ jsx12(CustomContainer, { name: containerName, options, children: node.children?.map((child, index) => /* @__PURE__ */ jsx12(IncremarkRenderer, { node: child }, index)) });
|
|
1188
1193
|
}
|
|
1189
|
-
return /* @__PURE__ */
|
|
1194
|
+
return /* @__PURE__ */ jsx12("div", { className: `incremark-container incremark-container-${containerName}`, children: node.children && node.children.length > 0 && /* @__PURE__ */ jsx12("div", { className: "incremark-container-content", children: node.children.map((child, index) => /* @__PURE__ */ jsx12(IncremarkRenderer, { node: child }, index)) }) });
|
|
1190
1195
|
};
|
|
1191
1196
|
|
|
1192
|
-
// src/components/
|
|
1193
|
-
import {
|
|
1194
|
-
var
|
|
1195
|
-
return /* @__PURE__ */
|
|
1197
|
+
// src/components/IncremarkDefault.tsx
|
|
1198
|
+
import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1199
|
+
var IncremarkDefault = ({ node }) => {
|
|
1200
|
+
return /* @__PURE__ */ jsxs5("div", { className: "incremark-default", children: [
|
|
1201
|
+
/* @__PURE__ */ jsx13("span", { className: "type-badge", children: node.type }),
|
|
1202
|
+
/* @__PURE__ */ jsx13("pre", { children: JSON.stringify(node, null, 2) })
|
|
1203
|
+
] });
|
|
1196
1204
|
};
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
var DefaultBlockquote = ({ node }) => /* @__PURE__ */ jsx14(IncremarkBlockquote, { node });
|
|
1201
|
-
var DefaultTable = ({ node }) => /* @__PURE__ */ jsx14(IncremarkTable, { node });
|
|
1202
|
-
var DefaultThematicBreak = () => /* @__PURE__ */ jsx14(IncremarkThematicBreak, {});
|
|
1203
|
-
var DefaultMath = ({ node }) => /* @__PURE__ */ jsx14(IncremarkMath, { node });
|
|
1204
|
-
var DefaultHtmlElement = ({ node }) => /* @__PURE__ */ jsx14(IncremarkHtmlElement, { node });
|
|
1205
|
-
var DefaultDefault = ({ node }) => /* @__PURE__ */ jsx14(IncremarkDefault, { node });
|
|
1205
|
+
|
|
1206
|
+
// src/components/IncremarkRenderer.tsx
|
|
1207
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1206
1208
|
var defaultComponents = {
|
|
1207
|
-
heading:
|
|
1208
|
-
paragraph:
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1209
|
+
heading: IncremarkHeading,
|
|
1210
|
+
paragraph: IncremarkParagraph,
|
|
1211
|
+
list: IncremarkList,
|
|
1212
|
+
blockquote: IncremarkBlockquote,
|
|
1213
|
+
table: IncremarkTable,
|
|
1214
|
+
thematicBreak: IncremarkThematicBreak,
|
|
1215
|
+
math: IncremarkMath,
|
|
1216
|
+
inlineMath: IncremarkMath,
|
|
1217
|
+
htmlElement: IncremarkHtmlElement,
|
|
1218
|
+
containerDirective: IncremarkContainer,
|
|
1219
|
+
leafDirective: IncremarkContainer,
|
|
1220
|
+
textDirective: IncremarkContainer
|
|
1218
1221
|
};
|
|
1219
1222
|
function isContainerNode(node) {
|
|
1220
1223
|
return node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective";
|
|
1221
1224
|
}
|
|
1225
|
+
function isHtmlNode2(node) {
|
|
1226
|
+
return node.type === "html";
|
|
1227
|
+
}
|
|
1228
|
+
function getComponent(type, userComponents) {
|
|
1229
|
+
return userComponents[type] || defaultComponents[type] || IncremarkDefault;
|
|
1230
|
+
}
|
|
1222
1231
|
var IncremarkRenderer = ({
|
|
1223
1232
|
node,
|
|
1224
1233
|
components = {},
|
|
1225
1234
|
customContainers,
|
|
1226
1235
|
customCodeBlocks,
|
|
1236
|
+
codeBlockConfigs,
|
|
1227
1237
|
blockStatus
|
|
1228
1238
|
}) => {
|
|
1229
1239
|
if (node.type === "footnoteDefinition") {
|
|
1230
1240
|
return null;
|
|
1231
1241
|
}
|
|
1232
|
-
if (node
|
|
1242
|
+
if (isHtmlNode2(node)) {
|
|
1233
1243
|
return /* @__PURE__ */ jsx14("pre", { className: "incremark-html-code", children: /* @__PURE__ */ jsx14("code", { children: node.value }) });
|
|
1234
1244
|
}
|
|
1235
1245
|
if (isContainerNode(node)) {
|
|
@@ -1247,21 +1257,21 @@ var IncremarkRenderer = ({
|
|
|
1247
1257
|
{
|
|
1248
1258
|
node,
|
|
1249
1259
|
customCodeBlocks,
|
|
1260
|
+
codeBlockConfigs,
|
|
1250
1261
|
blockStatus
|
|
1251
1262
|
}
|
|
1252
1263
|
);
|
|
1253
1264
|
}
|
|
1254
|
-
const
|
|
1255
|
-
const Component = mergedComponents[node.type] || DefaultDefault;
|
|
1265
|
+
const Component = getComponent(node.type, components);
|
|
1256
1266
|
return /* @__PURE__ */ jsx14(Component, { node });
|
|
1257
1267
|
};
|
|
1258
1268
|
|
|
1259
1269
|
// src/components/IncremarkFootnotes.tsx
|
|
1260
|
-
import
|
|
1261
|
-
import { jsx as jsx15, jsxs as
|
|
1270
|
+
import React8 from "react";
|
|
1271
|
+
import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1262
1272
|
var IncremarkFootnotes = () => {
|
|
1263
1273
|
const { footnoteDefinitions, footnoteReferenceOrder } = useDefinitions();
|
|
1264
|
-
const orderedFootnotes =
|
|
1274
|
+
const orderedFootnotes = React8.useMemo(() => {
|
|
1265
1275
|
return footnoteReferenceOrder.map((identifier) => ({
|
|
1266
1276
|
identifier,
|
|
1267
1277
|
definition: footnoteDefinitions[identifier]
|
|
@@ -1270,16 +1280,16 @@ var IncremarkFootnotes = () => {
|
|
|
1270
1280
|
if (orderedFootnotes.length === 0) {
|
|
1271
1281
|
return null;
|
|
1272
1282
|
}
|
|
1273
|
-
return /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ jsxs6("section", { className: "incremark-footnotes", children: [
|
|
1274
1284
|
/* @__PURE__ */ jsx15("hr", { className: "incremark-footnotes-divider" }),
|
|
1275
|
-
/* @__PURE__ */ jsx15("ol", { className: "incremark-footnotes-list", children: orderedFootnotes.map((item, index) => /* @__PURE__ */
|
|
1285
|
+
/* @__PURE__ */ jsx15("ol", { className: "incremark-footnotes-list", children: orderedFootnotes.map((item, index) => /* @__PURE__ */ jsxs6(
|
|
1276
1286
|
"li",
|
|
1277
1287
|
{
|
|
1278
1288
|
id: `fn-${item.identifier}`,
|
|
1279
1289
|
className: "incremark-footnote-item",
|
|
1280
1290
|
children: [
|
|
1281
|
-
/* @__PURE__ */
|
|
1282
|
-
/* @__PURE__ */
|
|
1291
|
+
/* @__PURE__ */ jsxs6("div", { className: "incremark-footnote-content", children: [
|
|
1292
|
+
/* @__PURE__ */ jsxs6("span", { className: "incremark-footnote-number", children: [
|
|
1283
1293
|
index + 1,
|
|
1284
1294
|
"."
|
|
1285
1295
|
] }),
|
|
@@ -1308,10 +1318,11 @@ var IncremarkContainerProvider = ({ children, definitions }) => {
|
|
|
1308
1318
|
};
|
|
1309
1319
|
|
|
1310
1320
|
// src/components/Incremark.tsx
|
|
1311
|
-
import { jsx as jsx17, jsxs as
|
|
1321
|
+
import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1312
1322
|
var Incremark = (props) => {
|
|
1313
1323
|
const {
|
|
1314
1324
|
blocks: propsBlocks,
|
|
1325
|
+
isDisplayComplete: propsIsDisplayComplete = false,
|
|
1315
1326
|
components,
|
|
1316
1327
|
customContainers,
|
|
1317
1328
|
customCodeBlocks,
|
|
@@ -1335,7 +1346,7 @@ var Incremark = (props) => {
|
|
|
1335
1346
|
) });
|
|
1336
1347
|
}
|
|
1337
1348
|
const blocks = propsBlocks || [];
|
|
1338
|
-
const isDisplayComplete =
|
|
1349
|
+
const isDisplayComplete = propsIsDisplayComplete;
|
|
1339
1350
|
return /* @__PURE__ */ jsx17(
|
|
1340
1351
|
IncremarkInternal,
|
|
1341
1352
|
{
|
|
@@ -1354,11 +1365,12 @@ var IncremarkInternal = ({
|
|
|
1354
1365
|
components,
|
|
1355
1366
|
customContainers,
|
|
1356
1367
|
customCodeBlocks,
|
|
1368
|
+
codeBlockConfigs,
|
|
1357
1369
|
showBlockStatus,
|
|
1358
1370
|
className,
|
|
1359
1371
|
isDisplayComplete
|
|
1360
1372
|
}) => {
|
|
1361
|
-
return /* @__PURE__ */
|
|
1373
|
+
return /* @__PURE__ */ jsxs7("div", { className: `incremark ${className}`, children: [
|
|
1362
1374
|
blocks.map((block) => {
|
|
1363
1375
|
if (block.node.type === "definition" || block.node.type === "footnoteDefinition") {
|
|
1364
1376
|
return null;
|
|
@@ -1377,6 +1389,7 @@ var IncremarkInternal = ({
|
|
|
1377
1389
|
components,
|
|
1378
1390
|
customContainers,
|
|
1379
1391
|
customCodeBlocks,
|
|
1392
|
+
codeBlockConfigs,
|
|
1380
1393
|
blockStatus: block.status
|
|
1381
1394
|
}
|
|
1382
1395
|
) }, block.stableId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@incremark/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
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.6"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"shiki": "^3.20.0",
|
|
28
|
-
"@incremark/
|
|
29
|
-
"@incremark/
|
|
30
|
-
"@incremark/devtools": "0.2.
|
|
28
|
+
"@incremark/shared": "0.2.6",
|
|
29
|
+
"@incremark/theme": "0.2.6",
|
|
30
|
+
"@incremark/devtools": "0.2.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/mdast": "^4.0.0",
|