Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
5ff64b0f
提交
5ff64b0f
authored
10月 31, 2024
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 新增AI翻译
上级
48334617
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
14 行删除
+22
-14
AITranslate.jsx
src/common/wangeditor-customer/menu/AITranslate.jsx
+8
-14
AIModal.jsx
src/common/wangeditor-customer/menu/common/AIModal.jsx
+14
-0
没有找到文件。
src/common/wangeditor-customer/menu/AITranslate.jsx
浏览文件 @
5ff64b0f
// Extend menu
class
AITranslate
{
import
BaseModalMenu
from
'./common/BaseModalMenu'
import
AIModal
from
'./common/AIModal'
class
AITranslate
extends
BaseModalMenu
{
constructor
()
{
super
()
this
.
title
=
'翻译'
this
.
iconSvg
=
`<svg fill="#000000" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><defs><style>.cls-1{fill:none;}</style></defs><title>translate</title><path d="M27.85,29H30L24,14H21.65l-6,15H17.8l1.6-4h6.85ZM20.2,23l2.62-6.56L25.45,23Z"></path><path d="M18,7V5H11V2H9V5H2V7H12.74a14.71,14.71,0,0,1-3.19,6.18A13.5,13.5,0,0,1,7.26,9H5.16a16.47,16.47,0,0,0,3,5.58A16.84,16.84,0,0,1,3,18l.75,1.86A18.47,18.47,0,0,0,9.53,16a16.92,16.92,0,0,0,5.76,3.84L16,18a14.48,14.48,0,0,1-5.12-3.37A17.64,17.64,0,0,0,14.8,7Z"></path><rect id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" class="cls-1" width="32" height="32"></rect></g></svg>`
this
.
tag
=
'button'
}
getValue
()
{
return
'hello, 音频'
}
isActive
()
{
return
false
}
isDisabled
()
{
return
true
}
exec
(
)
{
return
getValue
(
editor
)
{
return
<
AIModal
key=
{
Date
.
now
()
}
editor=
{
editor
}
docAction=
"translate"
></
AIModal
>
}
}
...
...
src/common/wangeditor-customer/menu/common/AIModal.jsx
浏览文件 @
5ff64b0f
...
...
@@ -28,6 +28,13 @@ const actionMap = {
(2)纠正敏感词或错别字之后正确的句子:
(3)更新之后的完整内容:
具体要校对的内容如下:`
},
translate
:
{
name
:
'翻译'
,
prompt
:
`请将以下文本翻译成英文。具体要求如下:
1、请确保翻译准确、流畅,并尽量保留原文的语义和风格。
2、翻译之后的文本以“翻译结果:”作为开头
待翻译文本:`
}
}
...
...
@@ -79,6 +86,13 @@ export default function AIModal({ editor, docAction }) {
result
=
match
[
1
].
trim
()
}
}
// 翻译结果判断
if
(
docAction
===
'translate'
)
{
const
match
=
result
.
match
(
/翻译结果
[
::
]?\s?([\s\S]
*
)
/
)
if
(
match
)
{
result
=
match
[
1
].
trim
()
}
}
console
.
log
(
result
)
editor
.
restoreSelection
()
// 删除当前选中的节点
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论