Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧐[问题] actionsRender怎么自定义actions? #108

Open
Tss-16 opened this issue Mar 5, 2024 · 5 comments
Open

🧐[问题] actionsRender怎么自定义actions? #108

Tss-16 opened this issue Mar 5, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Tss-16
Copy link

Tss-16 commented Mar 5, 2024

🧐 问题描述

chatItemRenderConfig的actionsRender属性可以自定义actions吗?比如删除或自定义’重新生成‘的触发语句或者隐藏’更多‘功能

💻 示例代码

🚑 其他信息

重新编辑弹出的prompt model框的取消和确认按钮是否有暴露的api?希望能够在重新编辑确认的时候实现向后端请求接口等自定义功能

@ONLY-yours
Copy link
Collaborator

🧐 问题描述

chatItemRenderConfig的actionsRender属性可以自定义actions吗?比如删除或自定义’重新生成‘的触发语句或者隐藏’更多‘功能

💻 示例代码

🚑 其他信息

重新编辑弹出的prompt model框的取消和确认按钮是否有暴露的api?希望能够在重新编辑确认的时候实现向后端请求接口等自定义功能

  • chatItemRenderConfig. actionsRender 可以自定义 actions,你返回 null,那一排默认的能力就会关闭
  • 「重新编辑弹出的prompt model框的取消和确认按钮是否有暴露的api?」暂无这个 api,你后面说的那个能力某种意义上不是标准逻辑,应该先 「编辑」,然后「重新生成」

当然程度更高的定义直接使用 chatItemRenderConfig的 render 方法,整块就由你自己来渲染了

@ONLY-yours ONLY-yours added the enhancement New feature or request label Mar 6, 2024
@Tss-16
Copy link
Author

Tss-16 commented Mar 6, 2024

chatItemRenderConfig. actionsRender返回null是可以隐藏actions,返回defaultContent是默认的所有actions,能否自定义保留或删除某些或单个actions 其余actions不做更改?

@ONLY-yours
Copy link
Collaborator

chatItemRenderConfig. actionsRender返回null是可以隐藏actions,返回defaultContent是默认的所有actions,能否自定义保留或删除某些或单个actions 其余actions不做更改?

感觉不如在 chatItemRenderConfig 里面加一个 actionsConfig,透出一些配置出来,但是这块有点细,后面是打算把 ChatItem 这个组件单独拎出来去写里面的参数内容,现在还没准备好。

@Tss-16 动动手给我们先提一个pr?hahaha

@Tss-16
Copy link
Author

Tss-16 commented Mar 11, 2024

chatItemRenderConfig的render方法渲染一个ChatItem组件弹出Modal后不管点击cancel还是confirm都无法关闭Modal?

render: (item, dom, defaultDom) => {
              if (item?.originData?.role === 'user') {
                return (
                  <ChatItem
                    {...control}
                    message={item?.originData?.content}
                    actions={
                      <ActionIconGroup
                        dropdownMenu={dropdownMenu}
                        items={items}
                        onActionClick={(action) => {
                          if (action.key === 'edit') {
                            setEdit(true);
                          }
                        }}
                        type="ghost"
                      />
                    }
                    avatar={{
                      avatar: UserAvatar,
                      title: 'User',
                    }}
                    editing={edit}
                    text={{ title: 'Message' }}
                    onChange={(e) => {
                      console.log('eee', e);
                      setEdit(false);
                    }}
                  />
                );
              }
            },```

@songhanlin
Copy link

songhanlin commented May 8, 2024

chatItemRenderConfig的render方法渲染一个ChatItem组件弹出Modal后不管点击cancel还是confirm都无法关闭Modal?

render: (item, dom, defaultDom) => {
              if (item?.originData?.role === 'user') {
                return (
                  <ChatItem
                    {...control}
                    message={item?.originData?.content}
                    actions={
                      <ActionIconGroup
                        dropdownMenu={dropdownMenu}
                        items={items}
                        onActionClick={(action) => {
                          if (action.key === 'edit') {
                            setEdit(true);
                          }
                        }}
                        type="ghost"
                      />
                    }
                    avatar={{
                      avatar: UserAvatar,
                      title: 'User',
                    }}
                    editing={edit}
                    text={{ title: 'Message' }}
                    onChange={(e) => {
                      console.log('eee', e);
                      setEdit(false);
                    }}
                  />
                );
              }
            },```

我后来仔细的想了一下, setEdit的hooks, 应该是我们使用的有问题, demo上的只有一个chatItem, 直接使用当然没有问题, 但是在ProChat中, 应该是多个, 如果一个编辑打开了, 那么所有的都会打开, 因此这里并不会把hooks传递出去; 因此edit应该是需要在每个ChatItem上都有, 另外OnChange是什么?我用的是onEditingChange, 可以正常的开关对话框

@ONLY-yours ONLY-yours added the documentation Improvements or additions to documentation label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants