markdown-flow-ui 0.1.69-beta.2 → 0.1.69-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.js +1 -1
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.js +1 -1
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.js +1 -1
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.js +1 -1
  5. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.3-beta.0/node_modules/remark-flow/dist/remark-custom-variable.js +1 -1
  6. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.3-beta.0/node_modules/remark-flow/dist/remark-interaction.js +1 -1
  7. package/dist/_virtual/index3.js +4 -5
  8. package/dist/_virtual/index3.js.map +1 -1
  9. package/dist/_virtual/index4.js +5 -4
  10. package/dist/_virtual/index4.js.map +1 -1
  11. package/dist/components/ui/inputGroup/textarea.js +1 -1
  12. package/dist/editor.d.ts +1 -2
  13. package/dist/index.js +10 -10
  14. package/dist/index.js.map +1 -1
  15. package/dist/renderer.d.ts +4 -4
  16. package/dist/renderer.js +7 -7
  17. package/dist/renderer.js.map +1 -1
  18. package/package.json +1 -1
  19. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js +0 -13
  20. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js.map +0 -1
  21. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.js +0 -74
  22. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.js.map +0 -1
  23. package/dist/components/MarkdownFlow/useScrollToBottom.js +0 -68
  24. package/dist/components/MarkdownFlow/useScrollToBottom.js.map +0 -1
@@ -2,7 +2,7 @@ import $ from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
2
2
  import oe from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/extends.js";
3
3
  import r from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/defineProperty.js";
4
4
  import te from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/typeof.js";
5
- import d from "../../../../../../../../../_virtual/index3.js";
5
+ import d from "../../../../../../../../../_virtual/index4.js";
6
6
  import l, { useRef as q, cloneElement as ie } from "react";
7
7
  import { hasPrefixSuffix as re, hasAddon as de } from "./utils/commonUtils.js";
8
8
  var xe = /* @__PURE__ */ l.forwardRef(function(e, z) {
@@ -4,7 +4,7 @@ import w from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
4
4
  import J from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/typeof.js";
5
5
  import s from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/slicedToArray.js";
6
6
  import K from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js";
7
- import Q from "../../../../../../../../../_virtual/index3.js";
7
+ import Q from "../../../../../../../../../_virtual/index4.js";
8
8
  import ee from "../../../../rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
9
9
  import M from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
10
10
  import te from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useMergedState.js";
@@ -4,7 +4,7 @@ import d from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
4
4
  import Ae from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js";
5
5
  import x from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/slicedToArray.js";
6
6
  import Fe from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js";
7
- import h from "../../../../../../../../../_virtual/index3.js";
7
+ import h from "../../../../../../../../../_virtual/index4.js";
8
8
  import Ne from "../../../../rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.js";
9
9
  import Te from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useMergedState.js";
10
10
  import o, { useRef as Y, useImperativeHandle as $e, useEffect as Ie } from "react";
@@ -1,5 +1,5 @@
1
1
  import t from "./TextArea.js";
2
- import "../../../../../../../../../_virtual/index3.js";
2
+ import "../../../../../../../../../_virtual/index4.js";
3
3
  import "../../../../rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
4
4
  import "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
5
5
  import "react";
@@ -1,5 +1,5 @@
1
1
  import { __exports as a } from "../../../../../../../../../_virtual/remark-custom-variable.js";
2
- import g from "../../../../../../../../../_virtual/index4.js";
2
+ import g from "../../../../../../../../../_virtual/index3.js";
3
3
  import { __require as h } from "./interaction-parser.js";
4
4
  var m;
5
5
  function C() {
@@ -1,5 +1,5 @@
1
1
  import { __exports as n } from "../../../../../../../../../_virtual/remark-interaction.js";
2
- import I from "../../../../../../../../../_virtual/index4.js";
2
+ import I from "../../../../../../../../../_virtual/index3.js";
3
3
  import { __require as g } from "./interaction-parser.js";
4
4
  var m;
5
5
  function k() {
@@ -1,8 +1,7 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
- import { __require as s } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
3
- var e = s();
4
- const t = /* @__PURE__ */ r(e);
1
+ import { getAugmentedNamespace as e } from "./_commonjsHelpers.js";
2
+ import * as r from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js";
3
+ const m = /* @__PURE__ */ e(r);
5
4
  export {
6
- t as default
5
+ m as default
7
6
  };
8
7
  //# sourceMappingURL=index3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -1,7 +1,8 @@
1
- import { getAugmentedNamespace as e } from "./_commonjsHelpers.js";
2
- import * as r from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js";
3
- const m = /* @__PURE__ */ e(r);
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as s } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
3
+ var e = s();
4
+ const t = /* @__PURE__ */ r(e);
4
5
  export {
5
- m as default
6
+ t as default
6
7
  };
7
8
  //# sourceMappingURL=index4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,7 +1,7 @@
1
1
  import { j as i } from "../../../_virtual/jsx-runtime.js";
2
2
  import * as d from "react";
3
3
  import n from "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.js";
4
- import "../../../_virtual/index3.js";
4
+ import "../../../_virtual/index4.js";
5
5
  import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
6
6
  import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
7
7
  import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/raf.js";
package/dist/editor.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { default as MarkdownFlowEditor, EditMode, UploadProps, ImageResource } from './components/MarkdownFlowEditor';
2
- import { OnSendContentParams, CustomRenderBarProps } from './components/types';
3
2
  export { MarkdownFlowEditor };
4
- export type { OnSendContentParams, CustomRenderBarProps, EditMode, UploadProps, ImageResource, };
3
+ export type { EditMode, UploadProps, ImageResource };
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { default as t } from "./components/MarkdownFlowEditor/MarkdownFlowEditor.js";
2
- import { default as l } from "./components/MarkdownFlow/MarkdownFlow.js";
3
- import { default as f } from "./components/MarkdownFlow/ScrollableMarkdownFlow.js";
4
- import { default as w } from "./components/ContentRender/ContentRender.js";
5
- import { default as m } from "./components/ContentRender/MarkdownFlowInput.js";
1
+ import { default as d } from "./components/MarkdownFlowEditor/MarkdownFlowEditor.js";
2
+ import { default as p } from "./components/MarkdownFlow/MarkdownFlow.js";
3
+ import "./_virtual/jsx-runtime.js";
6
4
  import "react";
5
+ /* empty css */
6
+ import { default as m } from "./components/ContentRender/ContentRender.js";
7
+ import { default as w } from "./components/ContentRender/MarkdownFlowInput.js";
7
8
  export {
8
- w as ContentRender,
9
- l as MarkdownFlow,
10
- t as MarkdownFlowEditor,
11
- m as MarkdownFlowInput,
12
- f as ScrollableMarkdownFlow
9
+ m as ContentRender,
10
+ p as MarkdownFlow,
11
+ d as MarkdownFlowEditor,
12
+ w as MarkdownFlowInput
13
13
  };
14
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -1,8 +1,8 @@
1
- import { default as MarkdownFlow, ScrollableMarkdownFlow } from './components/MarkdownFlow';
1
+ import { default as MarkdownFlow } from './components/MarkdownFlow';
2
2
  import { default as ContentRender } from './components/ContentRender';
3
3
  import { default as MarkdownFlowInput, MarkdownFlowInputProps } from './components/ContentRender/MarkdownFlowInput';
4
4
  import { MarkdownFlowProps } from './components/MarkdownFlow/MarkdownFlow';
5
- import { ScrollableMarkdownFlowProps } from './components/MarkdownFlow/ScrollableMarkdownFlow';
6
5
  import { ContentRenderProps } from './components/ContentRender/ContentRender';
7
- export { MarkdownFlow, ScrollableMarkdownFlow, ContentRender, MarkdownFlowInput, };
8
- export type { MarkdownFlowProps, ScrollableMarkdownFlowProps, ContentRenderProps, MarkdownFlowInputProps, };
6
+ import { OnSendContentParams, CustomRenderBarProps } from './components/types';
7
+ export { MarkdownFlow, ContentRender, MarkdownFlowInput };
8
+ export type { OnSendContentParams, CustomRenderBarProps, MarkdownFlowProps, ContentRenderProps, MarkdownFlowInputProps, };
package/dist/renderer.js CHANGED
@@ -1,12 +1,12 @@
1
- import { default as e } from "./components/MarkdownFlow/MarkdownFlow.js";
2
- import { default as l } from "./components/MarkdownFlow/ScrollableMarkdownFlow.js";
3
- import { default as f } from "./components/ContentRender/ContentRender.js";
4
- import { default as p } from "./components/ContentRender/MarkdownFlowInput.js";
1
+ import { default as p } from "./components/MarkdownFlow/MarkdownFlow.js";
2
+ import "./_virtual/jsx-runtime.js";
5
3
  import "react";
4
+ /* empty css */
5
+ import { default as f } from "./components/ContentRender/ContentRender.js";
6
+ import { default as n } from "./components/ContentRender/MarkdownFlowInput.js";
6
7
  export {
7
8
  f as ContentRender,
8
- e as MarkdownFlow,
9
- p as MarkdownFlowInput,
10
- l as ScrollableMarkdownFlow
9
+ p as MarkdownFlow,
10
+ n as MarkdownFlowInput
11
11
  };
12
12
  //# sourceMappingURL=renderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"renderer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
package/package.json CHANGED
@@ -149,7 +149,7 @@
149
149
  "storybook": "storybook dev -p 6006",
150
150
  "test": "echo \"No tests specified\" && exit 0"
151
151
  },
152
- "version": "0.1.69-beta.2",
152
+ "version": "0.1.69-beta.3",
153
153
  "type": "module",
154
154
  "exports": {
155
155
  ".": {
@@ -1,13 +0,0 @@
1
- import o from "../createLucideIcon.js";
2
- /**
3
- * @license lucide-react v0.525.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */
8
- const e = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], c = o("chevron-down", e);
9
- export {
10
- e as __iconNode,
11
- c as default
12
- };
13
- //# sourceMappingURL=chevron-down.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chevron-down.js","sources":["../../../../../../../../../../../../node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js"],"sourcesContent":["/**\n * @license lucide-react v0.525.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [[\"path\", { d: \"m6 9 6 6 6-6\", key: \"qrunsl\" }]];\nconst ChevronDown = createLucideIcon(\"chevron-down\", __iconNode);\n\nexport { __iconNode, ChevronDown as default };\n//# sourceMappingURL=chevron-down.js.map\n"],"names":["__iconNode","ChevronDown","createLucideIcon"],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASK,MAACA,IAAa,CAAC,CAAC,QAAQ,EAAE,GAAG,gBAAgB,KAAK,UAAU,CAAC,GAC5DC,IAAcC,EAAiB,gBAAgBF,CAAU;","x_google_ignoreList":[0]}
@@ -1,74 +0,0 @@
1
- import { j as o } from "../../_virtual/jsx-runtime.js";
2
- import { useRef as b } from "react";
3
- import w from "./MarkdownFlow.js";
4
- import v from "./useScrollToBottom.js";
5
- import { Button as x } from "../ui/button.js";
6
- /* empty css */
7
- import g from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js";
8
- const T = ({
9
- initialContentList: r = [],
10
- customRenderBar: e,
11
- onSend: t,
12
- onBlockComplete: s,
13
- typingSpeed: a,
14
- enableTypewriter: n = !1,
15
- height: m = "100%",
16
- className: c = "",
17
- confirmButtonText: i,
18
- copyButtonText: h,
19
- copiedButtonText: f,
20
- ...u
21
- }) => {
22
- const l = b(null), { showScrollToBottom: d, handleUserScrollToBottom: p } = v(
23
- l,
24
- [
25
- r?.length >= 1 ? JSON.stringify(r[r?.length - 1]) : null
26
- ],
27
- {
28
- // Listen for content count changes
29
- behavior: "smooth",
30
- autoScrollOnInit: !0,
31
- scrollDelay: 100
32
- }
33
- );
34
- return /* @__PURE__ */ o.jsxs(
35
- "div",
36
- {
37
- className: `scrollable-markdown-container ${c}`,
38
- style: { height: m, position: "relative" },
39
- ...u,
40
- children: [
41
- /* @__PURE__ */ o.jsx("div", { ref: l, style: { height: "100%", overflow: "auto" }, children: /* @__PURE__ */ o.jsx(
42
- w,
43
- {
44
- initialContentList: r,
45
- customRenderBar: e,
46
- onSend: t,
47
- typingSpeed: a,
48
- enableTypewriter: n,
49
- onBlockComplete: s,
50
- confirmButtonText: i,
51
- copyButtonText: h,
52
- copiedButtonText: f
53
- }
54
- ) }),
55
- d && /* @__PURE__ */ o.jsx(
56
- x,
57
- {
58
- className: "h-6 w-6 border hover:bg-gray-200 scroll-to-bottom-btn",
59
- type: "button",
60
- variant: "ghost",
61
- size: "icon",
62
- onClick: p,
63
- "aria-label": "滚动到底部",
64
- children: /* @__PURE__ */ o.jsx(g, {})
65
- }
66
- )
67
- ]
68
- }
69
- );
70
- };
71
- export {
72
- T as default
73
- };
74
- //# sourceMappingURL=ScrollableMarkdownFlow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScrollableMarkdownFlow.js","sources":["../../../src/components/MarkdownFlow/ScrollableMarkdownFlow.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport MarkdownFlow from \"./MarkdownFlow\";\nimport useScrollToBottom from \"./useScrollToBottom\";\n// import type { OnSendContentParams, CustomRenderBarProps } from \"../types\";\nimport { ChevronDown } from \"lucide-react\";\nimport { Button } from \"../ui/button\";\nimport type { MarkdownFlowProps } from \"./MarkdownFlow\";\n\nimport \"./markdownFlow.css\";\n\nexport interface ScrollableMarkdownFlowProps extends MarkdownFlowProps {\n height?: string | number;\n className?: string;\n}\n\nconst ScrollableMarkdownFlow: React.FC<ScrollableMarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend,\n onBlockComplete,\n typingSpeed,\n enableTypewriter = false,\n height = \"100%\",\n className = \"\",\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n ...restProps\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n const { showScrollToBottom, handleUserScrollToBottom } = useScrollToBottom(\n containerRef,\n [\n initialContentList?.length >= 1\n ? JSON.stringify(initialContentList[initialContentList?.length - 1])\n : null,\n ],\n {\n // Listen for content count changes\n behavior: \"smooth\",\n autoScrollOnInit: true,\n scrollDelay: 100,\n }\n );\n\n return (\n <div\n className={`scrollable-markdown-container ${className}`}\n style={{ height, position: \"relative\" }}\n {...restProps}\n >\n <div ref={containerRef} style={{ height: \"100%\", overflow: \"auto\" }}>\n <MarkdownFlow\n initialContentList={initialContentList}\n customRenderBar={customRenderBar}\n onSend={onSend}\n typingSpeed={typingSpeed}\n enableTypewriter={enableTypewriter}\n onBlockComplete={onBlockComplete}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n />\n </div>\n {showScrollToBottom && (\n <Button\n className=\"h-6 w-6 border hover:bg-gray-200 scroll-to-bottom-btn\"\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n onClick={handleUserScrollToBottom}\n aria-label=\"滚动到底部\"\n >\n <ChevronDown />\n </Button>\n )}\n </div>\n );\n};\n\nexport default ScrollableMarkdownFlow;\n"],"names":["ScrollableMarkdownFlow","initialContentList","customRenderBar","onSend","onBlockComplete","typingSpeed","enableTypewriter","height","className","confirmButtonText","copyButtonText","copiedButtonText","restProps","containerRef","useRef","showScrollToBottom","handleUserScrollToBottom","useScrollToBottom","jsxs","jsx","MarkdownFlow","Button","ChevronDown"],"mappings":";;;;;;;AAeA,MAAMA,IAAgE,CAAC;AAAA,EACrE,oBAAAC,IAAqB,CAAA;AAAA,EACrB,iBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC,IAAmB;AAAA,EACnB,QAAAC,IAAS;AAAA,EACT,WAAAC,IAAY;AAAA,EACZ,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAeC,EAAuB,IAAI,GAE1C,EAAE,oBAAAC,GAAoB,0BAAAC,EAAA,IAA6BC;AAAA,IACvDJ;AAAA,IACA;AAAA,MACEZ,GAAoB,UAAU,IAC1B,KAAK,UAAUA,EAAmBA,GAAoB,SAAS,CAAC,CAAC,IACjE;AAAA,IAAA;AAAA,IAEN;AAAA;AAAA,MAEE,UAAU;AAAA,MACV,kBAAkB;AAAA,MAClB,aAAa;AAAA,IAAA;AAAA,EACf;AAGF,SACEiB,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,iCAAiCV,CAAS;AAAA,MACrD,OAAO,EAAE,QAAAD,GAAQ,UAAU,WAAA;AAAA,MAC1B,GAAGK;AAAA,MAEJ,UAAA;AAAA,QAAAO,gBAAAA,EAAAA,IAAC,OAAA,EAAI,KAAKN,GAAc,OAAO,EAAE,QAAQ,QAAQ,UAAU,OAAA,GACzD,UAAAM,gBAAAA,EAAAA;AAAAA,UAACC;AAAA,UAAA;AAAA,YACC,oBAAAnB;AAAA,YACA,iBAAAC;AAAA,YACA,QAAAC;AAAA,YACA,aAAAE;AAAA,YACA,kBAAAC;AAAA,YACA,iBAAAF;AAAA,YACA,mBAAAK;AAAA,YACA,gBAAAC;AAAA,YACA,kBAAAC;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,QACCI,KACCI,gBAAAA,EAAAA;AAAAA,UAACE;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,SAASL;AAAA,YACT,cAAW;AAAA,YAEX,gCAACM,GAAA,CAAA,CAAY;AAAA,UAAA;AAAA,QAAA;AAAA,MACf;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -1,68 +0,0 @@
1
- import { useState as A, useRef as f, useCallback as n, useEffect as a } from "react";
2
- const L = (e, E = [], b = {}) => {
3
- const {
4
- behavior: T = "smooth",
5
- autoScrollOnInit: h = !0,
6
- scrollDelay: B = 100,
7
- scrollThreshold: S = 10
8
- } = b, [g, s] = A(!1), [C, u] = A(!0), o = f(!0), m = f(!0), r = f({
9
- scroll: null,
10
- init: null,
11
- content: null
12
- }), d = n(() => {
13
- Object.values(r.current).forEach((t) => {
14
- t && clearTimeout(t);
15
- });
16
- }, []), w = n(() => {
17
- const t = e.current;
18
- if (!t) return !0;
19
- const { scrollTop: i, scrollHeight: v, clientHeight: H } = t;
20
- return i + H >= v - S;
21
- }, [e, S]), c = n(() => {
22
- const t = e.current;
23
- t && t.scrollTo({
24
- top: t.scrollHeight,
25
- behavior: T
26
- });
27
- }, [e, T]), l = n(() => {
28
- const t = w();
29
- return u(t), s(!t), t;
30
- }, [w]), p = n(() => {
31
- c(), o.current = !0, s(!1), u(!0);
32
- }, [c]);
33
- return a(() => {
34
- const t = e.current;
35
- if (!t) return;
36
- const i = () => {
37
- r.current.scroll && clearTimeout(r.current.scroll), r.current.scroll = setTimeout(() => {
38
- l() ? o.current = !0 : o.current = !1;
39
- }, 150);
40
- };
41
- return t.addEventListener("scroll", i), l(), () => {
42
- t.removeEventListener("scroll", i), r.current.scroll && clearTimeout(r.current.scroll);
43
- };
44
- }, [e, l]), a(() => (h && m.current && (r.current.init = setTimeout(() => {
45
- c(), u(!0), s(!1), o.current = !0, m.current = !1;
46
- }, B)), () => {
47
- r.current.init && clearTimeout(r.current.init);
48
- }), [h, c, B]), a(() => {
49
- if (!m.current)
50
- return r.current.content = setTimeout(() => {
51
- o.current ? (c(), u(!0), s(!1)) : l();
52
- }, 50), () => {
53
- r.current.content && clearTimeout(r.current.content);
54
- };
55
- }, [...E, c, l]), a(() => () => {
56
- d();
57
- }, [d]), {
58
- showScrollToBottom: g,
59
- scrollToBottom: p,
60
- handleUserScrollToBottom: p,
61
- isAtBottom: C,
62
- followNewContent: o.current
63
- };
64
- };
65
- export {
66
- L as default
67
- };
68
- //# sourceMappingURL=useScrollToBottom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useScrollToBottom.js","sources":["../../../src/components/MarkdownFlow/useScrollToBottom.ts"],"sourcesContent":["import { useRef, useEffect, useCallback, RefObject, useState } from \"react\";\n\ninterface UseScrollToBottomOptions {\n behavior?: \"smooth\" | \"auto\";\n autoScrollOnInit?: boolean;\n scrollDelay?: number;\n scrollThreshold?: number;\n}\n\ninterface UseScrollToBottomReturn {\n showScrollToBottom: boolean;\n scrollToBottom: () => void;\n handleUserScrollToBottom: () => void;\n isAtBottom: boolean;\n followNewContent: boolean;\n}\n\nconst useScrollToBottom = (\n containerRef: RefObject<HTMLDivElement | null>,\n dependencies: any[] = [],\n options: UseScrollToBottomOptions = {}\n): UseScrollToBottomReturn => {\n const {\n behavior = \"smooth\",\n autoScrollOnInit = true,\n scrollDelay = 100,\n scrollThreshold = 10,\n } = options;\n\n const [showScrollToBottom, setShowScrollToBottom] = useState(false);\n const [isAtBottom, setIsAtBottom] = useState(true);\n const followNewContent = useRef(true);\n const isFirstLoad = useRef(true);\n const timers = useRef({\n scroll: null as NodeJS.Timeout | null,\n init: null as NodeJS.Timeout | null,\n content: null as NodeJS.Timeout | null,\n });\n\n // Clear all timers\n const clearAllTimers = useCallback(() => {\n Object.values(timers.current).forEach((timer) => {\n if (timer) clearTimeout(timer);\n });\n }, []);\n\n // Check if scrolled to bottom\n const checkIfAtBottom = useCallback((): boolean => {\n const container = containerRef.current;\n if (!container) return true;\n\n const { scrollTop, scrollHeight, clientHeight } = container;\n return scrollTop + clientHeight >= scrollHeight - scrollThreshold;\n }, [containerRef, scrollThreshold]);\n\n // Scroll to bottom\n const scrollToBottom = useCallback(() => {\n const container = containerRef.current;\n if (container) {\n container.scrollTo({\n top: container.scrollHeight,\n behavior,\n });\n }\n }, [containerRef, behavior]);\n\n // Update scroll state\n const updateScrollState = useCallback(() => {\n const atBottom = checkIfAtBottom();\n setIsAtBottom(atBottom);\n setShowScrollToBottom(!atBottom);\n return atBottom;\n }, [checkIfAtBottom]);\n\n // Handle user manually scrolling to bottom\n const handleUserScrollToBottom = useCallback(() => {\n scrollToBottom();\n followNewContent.current = true;\n setShowScrollToBottom(false);\n setIsAtBottom(true);\n }, [scrollToBottom]);\n\n // Scroll event listener\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n const handleScroll = () => {\n // Debounce handling\n if (timers.current.scroll) {\n clearTimeout(timers.current.scroll);\n }\n\n timers.current.scroll = setTimeout(() => {\n const atBottom = updateScrollState();\n\n // Key logic: disable auto-follow when user manually scrolls\n if (!atBottom) {\n followNewContent.current = false;\n } else {\n followNewContent.current = true;\n }\n }, 150);\n };\n\n container.addEventListener(\"scroll\", handleScroll);\n // Initialize state\n updateScrollState();\n\n return () => {\n container.removeEventListener(\"scroll\", handleScroll);\n if (timers.current.scroll) {\n clearTimeout(timers.current.scroll);\n }\n };\n }, [containerRef, updateScrollState]);\n\n // Auto-scroll on first load\n useEffect(() => {\n if (autoScrollOnInit && isFirstLoad.current) {\n timers.current.init = setTimeout(() => {\n scrollToBottom();\n setIsAtBottom(true);\n setShowScrollToBottom(false);\n followNewContent.current = true;\n isFirstLoad.current = false;\n }, scrollDelay);\n }\n\n return () => {\n if (timers.current.init) {\n clearTimeout(timers.current.init);\n }\n };\n }, [autoScrollOnInit, scrollToBottom, scrollDelay]);\n\n // Handle content changes\n useEffect(() => {\n if (isFirstLoad.current) return;\n\n timers.current.content = setTimeout(() => {\n if (followNewContent.current) {\n // Auto-scroll when user hasn't manually scrolled\n scrollToBottom();\n setIsAtBottom(true);\n setShowScrollToBottom(false);\n } else {\n // Only update button state after user manual scroll\n updateScrollState();\n }\n }, 50);\n\n return () => {\n if (timers.current.content) {\n clearTimeout(timers.current.content);\n }\n };\n }, [...dependencies, scrollToBottom, updateScrollState]);\n\n // Cleanup on component unmount\n useEffect(() => {\n return () => {\n clearAllTimers();\n };\n }, [clearAllTimers]);\n\n return {\n showScrollToBottom,\n scrollToBottom: handleUserScrollToBottom,\n handleUserScrollToBottom,\n isAtBottom,\n followNewContent: followNewContent.current,\n };\n};\n\nexport default useScrollToBottom;\n"],"names":["useScrollToBottom","containerRef","dependencies","options","behavior","autoScrollOnInit","scrollDelay","scrollThreshold","showScrollToBottom","setShowScrollToBottom","useState","isAtBottom","setIsAtBottom","followNewContent","useRef","isFirstLoad","timers","clearAllTimers","useCallback","timer","checkIfAtBottom","container","scrollTop","scrollHeight","clientHeight","scrollToBottom","updateScrollState","atBottom","handleUserScrollToBottom","useEffect","handleScroll"],"mappings":"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"}