Skip to content

Commit

Permalink
Merge pull request #1808 from illacloud/feat/rich-text-autoheight
Browse files Browse the repository at this point in the history
feat: update chat
  • Loading branch information
Wangtaofeng authored Jul 5, 2023
2 parents 5abaffc + 1c36310 commit d35ca82
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
1 change: 1 addition & 0 deletions apps/builder/src/widgetLibrary/ChatWidget/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const ChatWidget: FC<ChatWidgetProps> = (props) => {
<RenderChildrenCanvas
currentComponentNode={footerComponentNode}
columnNumber={columnNumber}
handleUpdateHeight={() => {}}
/>
)
}, [childrenNode, columnNumber])
Expand Down
22 changes: 2 additions & 20 deletions apps/builder/src/widgetLibrary/RichTextWidget/richText.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FC, forwardRef, useCallback, useEffect, useMemo, useRef } from "react"
import { UNIT_HEIGHT } from "@/page/App/components/DotPanel/constant/canvas"
import { AutoHeightContainer } from "@/widgetLibrary/PublicSector/AutoHeightContainer"
import { TooltipWrapper } from "@/widgetLibrary/PublicSector/TooltipWrapper"
import {
Expand Down Expand Up @@ -36,9 +35,6 @@ export const RichTextWidget: FC<RichTextWidgetProps> = (props) => {
displayName,
tooltipText,
dynamicHeight,
dynamicMinHeight,
dynamicMaxHeight,
h,
updateComponentHeight,
deleteComponentRuntimeProps,
updateComponentRuntimeProps,
Expand All @@ -49,22 +45,9 @@ export const RichTextWidget: FC<RichTextWidgetProps> = (props) => {
const editorRef = useRef<ICustomRef>(null)
const containerRef = useRef<HTMLDivElement>(null)

const dynamicOptions = {
dynamicMinHeight,
dynamicMaxHeight,
}

const enableAutoHeight = useMemo(() => {
switch (dynamicHeight) {
case "auto":
return true
case "limited":
return h * UNIT_HEIGHT >= (dynamicMinHeight ?? h * UNIT_HEIGHT)
case "fixed":
default:
return false
}
}, [dynamicHeight, dynamicMinHeight, h])
return dynamicHeight !== "fixed"
}, [dynamicHeight])

useEffect(() => {
updateComponentRuntimeProps({
Expand Down Expand Up @@ -119,7 +102,6 @@ export const RichTextWidget: FC<RichTextWidgetProps> = (props) => {
<AutoHeightContainer
updateComponentHeight={updateComponentHeight}
enable={enableAutoHeight}
dynamicOptions={dynamicOptions}
>
<TooltipWrapper tooltipText={tooltipText} tooltipDisabled={!tooltipText}>
<div ref={containerRef} style={{ height: "100%", width: "100%" }}>
Expand Down

0 comments on commit d35ca82

Please sign in to comment.