Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
ec63f18b
提交
ec63f18b
authored
11月 07, 2025
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 增加批量去空格和文字气泡转成图标气泡
上级
1afbfb14
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
140 行增加
和
7 行删除
+140
-7
ConvertTooltipType.js
...common/wangeditor-customer/customer/ConvertTooltipType.js
+58
-0
Gallery.js
src/common/wangeditor-customer/customer/Gallery.js
+1
-1
Image.js
src/common/wangeditor-customer/customer/Image.js
+1
-1
RemoveSpaces.js
src/common/wangeditor-customer/customer/RemoveSpaces.js
+56
-0
index.jsx
src/common/wangeditor-customer/index.jsx
+24
-5
没有找到文件。
src/common/wangeditor-customer/customer/ConvertTooltipType.js
0 → 100644
浏览文件 @
ec63f18b
class
ConvertTooltipType
{
constructor
()
{
this
.
title
=
'气泡转换'
this
.
iconSvg
=
`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="currentColor" d="M8 0L3 5h3v11h4V5h3L8 0z"/></svg>`
this
.
tag
=
'button'
}
// eslint-disable-next-line no-unused-vars
getValue
(
editor
)
{
return
''
}
// eslint-disable-next-line no-unused-vars
isActive
(
editor
)
{
return
false
}
// eslint-disable-next-line no-unused-vars
isDisabled
(
editor
)
{
return
false
}
exec
(
editor
)
{
// 获取当前 HTML
const
html
=
editor
.
getHtml
()
console
.
log
(
html
)
if
(
!
html
)
{
return
}
// 使用正则表达式批量将文字气泡(tooltipType="1")转换为图标气泡(tooltipType="2")
// 匹配 data-tooltipType="1"、data-tooltipType='1'、data-tooltip-type="1"、data-tooltip-type='1' 等格式
const
htmlConverted
=
html
.
replace
(
/data-tooltipType="1"/gi
,
'data-tooltipType="2"'
)
.
replace
(
/data-tooltipType='1'/gi
,
"data-tooltipType='2'"
)
.
replace
(
/data-tooltip-type="1"/gi
,
'data-tooltip-type="2"'
)
.
replace
(
/data-tooltip-type='1'/gi
,
"data-tooltip-type='2'"
)
console
.
log
(
htmlConverted
)
// 如果内容有变化,设置回去
if
(
htmlConverted
!==
html
)
{
// 保存当前选区
// 设置处理后的 HTML
editor
.
setHtml
(
htmlConverted
)
}
}
}
export
default
{
key
:
'ConvertTooltipType'
,
// 定义 menu key :要保证唯一、不重复(重要)
factory
()
{
return
new
ConvertTooltipType
()
},
}
export
{
ConvertTooltipType
}
src/common/wangeditor-customer/customer/Gallery.js
浏览文件 @
ec63f18b
...
@@ -2,7 +2,7 @@ import { DomEditor, SlateTransforms, SlateRange } from '@wangeditor/editor';
...
@@ -2,7 +2,7 @@ import { DomEditor, SlateTransforms, SlateRange } from '@wangeditor/editor';
class
GalleryAuto
{
class
GalleryAuto
{
constructor
()
{
constructor
()
{
this
.
title
=
'
离线
画廊'
this
.
title
=
'画廊'
this
.
iconSvg
=
`<svg width="24px" height="19px" viewBox="0 0 24 19" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
this
.
iconSvg
=
`<svg width="24px" height="19px" viewBox="0 0 24 19" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>图标</title>
<title>图标</title>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
...
...
src/common/wangeditor-customer/customer/Image.js
浏览文件 @
ec63f18b
...
@@ -3,7 +3,7 @@ import { DomEditor, SlateTransforms as Transforms, SlateRange } from '@wangedito
...
@@ -3,7 +3,7 @@ import { DomEditor, SlateTransforms as Transforms, SlateRange } from '@wangedito
// Extend menu
// Extend menu
class
ImageAuto
{
class
ImageAuto
{
constructor
()
{
constructor
()
{
this
.
title
=
'
离线
图片'
this
.
title
=
'图片'
this
.
iconSvg
=
`<svg width="23px" height="21px" viewBox="0 0 23 21" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
this
.
iconSvg
=
`<svg width="23px" height="21px" viewBox="0 0 23 21" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>编辑器图片样式</title>
<title>编辑器图片样式</title>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
...
...
src/common/wangeditor-customer/customer/RemoveSpaces.js
0 → 100644
浏览文件 @
ec63f18b
class
RemoveSpaces
{
constructor
()
{
this
.
title
=
'去空格'
this
.
iconSvg
=
`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="currentColor" d="M2 2h12v12H2V2zm1 1v10h10V3H3zm2 2h6v1H5V5zm0 2h6v1H5V7zm0 2h4v1H5V9z"/></svg>`
this
.
tag
=
'button'
}
// eslint-disable-next-line no-unused-vars
getValue
(
editor
)
{
return
''
}
// eslint-disable-next-line no-unused-vars
isActive
(
editor
)
{
return
false
}
// eslint-disable-next-line no-unused-vars
isDisabled
(
editor
)
{
return
false
}
exec
(
editor
)
{
// 获取当前 HTML
const
html
=
editor
.
getHtml
()
if
(
!
html
)
{
return
}
// 使用正则表达式去除 HTML 标签之间文本的空格
// 匹配 >文本< 之间的内容,去除空格字符(包括多个相邻的空格)和 ,保留其他字符和标签结构
const
htmlWithoutSpaces
=
html
.
replace
(
/>
([^
<
]
*
?)
</g
,
(
match
,
text
)
=>
{
// 先去除所有的 HTML 实体
let
textWithoutSpaces
=
text
.
replace
(
/ +/gi
,
''
)
// 然后去除所有空格字符(包括多个相邻的空格),保留其他字符
textWithoutSpaces
=
textWithoutSpaces
.
replace
(
/ +/g
,
''
)
return
`>
${
textWithoutSpaces
}
<`
})
// 如果内容有变化,设置回去
if
(
htmlWithoutSpaces
!==
html
)
{
// 设置处理后的 HTML
editor
.
setHtml
(
htmlWithoutSpaces
)
}
}
}
export
default
{
key
:
'RemoveSpaces'
,
// 定义 menu key :要保证唯一、不重复(重要)
factory
()
{
return
new
RemoveSpaces
()
},
}
export
{
RemoveSpaces
}
src/common/wangeditor-customer/index.jsx
浏览文件 @
ec63f18b
...
@@ -34,6 +34,8 @@ import TooltipAutoConf from './customer/Tooltip'
...
@@ -34,6 +34,8 @@ import TooltipAutoConf from './customer/Tooltip'
import
ImageEditorConf
from
'./customer/ImageEditor'
import
ImageEditorConf
from
'./customer/ImageEditor'
import
CustomerLinkConf
from
'./customer/CustomerLink'
import
CustomerLinkConf
from
'./customer/CustomerLink'
import
ExpandReadConf
from
'./customer/ExpandRead'
import
ExpandReadConf
from
'./customer/ExpandRead'
import
RemoveSpacesConf
from
'./customer/RemoveSpaces'
import
ConvertTooltipTypeConf
from
'./customer/ConvertTooltipType'
// AI对话
// AI对话
import
AIChat
from
'./menu/AIChat'
import
AIChat
from
'./menu/AIChat'
...
@@ -54,6 +56,8 @@ import AIDigitalHuman from './menu/AIDigitalHuman'
...
@@ -54,6 +56,8 @@ import AIDigitalHuman from './menu/AIDigitalHuman'
import
AITranslate
from
'./menu/AITranslate'
import
AITranslate
from
'./menu/AITranslate'
import
AISearch
from
'./menu/AISearch'
import
AISearch
from
'./menu/AISearch'
import
AIWrite
from
'./menu/AIWrite'
import
AIWrite
from
'./menu/AIWrite'
import
AIImage
from
'./menu/AIImage'
import
AIBaiduSearch
from
'./menu/AIBaiduSearch'
import
ImageModal
from
'./components/image'
import
ImageModal
from
'./components/image'
import
VideoModal
from
'./components/video'
import
VideoModal
from
'./components/video'
...
@@ -105,6 +109,8 @@ const module = {
...
@@ -105,6 +109,8 @@ const module = {
ImageEditorConf
,
ImageEditorConf
,
CustomerLinkConf
,
CustomerLinkConf
,
ExpandReadConf
,
ExpandReadConf
,
RemoveSpacesConf
,
ConvertTooltipTypeConf
,
AIChat
,
AIChat
,
AIRewrite
,
AIRewrite
,
AIExpand
,
AIExpand
,
...
@@ -121,6 +127,8 @@ const module = {
...
@@ -121,6 +127,8 @@ const module = {
AITranslate
,
AITranslate
,
AISearch
,
AISearch
,
AIWrite
,
AIWrite
,
AIImage
,
AIBaiduSearch
,
],
],
}
}
Boot
.
registerModule
(
module
)
Boot
.
registerModule
(
module
)
...
@@ -195,7 +203,7 @@ const WangEditorCustomer = (props, ref) => {
...
@@ -195,7 +203,7 @@ const WangEditorCustomer = (props, ref) => {
const
[
isOnline
,
setIsOnline
]
=
useState
(
false
)
const
[
isOnline
,
setIsOnline
]
=
useState
(
false
)
window
.
addEventListener
(
'setItemEvent'
,
function
(
e
)
{
const
handleSetItemEvent
=
(
e
)
=>
{
if
(
e
.
key
===
'chapterTitleNum'
)
{
if
(
e
.
key
===
'chapterTitleNum'
)
{
setTitleInfo
(
JSON
.
parse
(
e
.
newValue
))
setTitleInfo
(
JSON
.
parse
(
e
.
newValue
))
setTitleVisible
(
true
)
setTitleVisible
(
true
)
...
@@ -240,7 +248,14 @@ const WangEditorCustomer = (props, ref) => {
...
@@ -240,7 +248,14 @@ const WangEditorCustomer = (props, ref) => {
window
.
localStorage
.
removeItem
(
'chapterExpand'
)
window
.
localStorage
.
removeItem
(
'chapterExpand'
)
},
100
)
},
100
)
}
}
})
}
useEffect
(()
=>
{
window
.
addEventListener
(
'setItemEvent'
,
handleSetItemEvent
)
return
()
=>
{
window
.
removeEventListener
(
'setItemEvent'
,
handleSetItemEvent
)
}
},
[])
const
closePanel
=
()
=>
{
const
closePanel
=
()
=>
{
dispatch
(
setPracticeRandom
({
practiceNum
:
null
,
practiceTitle
:
null
}))
dispatch
(
setPracticeRandom
({
practiceNum
:
null
,
practiceTitle
:
null
}))
...
@@ -332,10 +347,11 @@ const WangEditorCustomer = (props, ref) => {
...
@@ -332,10 +347,11 @@ const WangEditorCustomer = (props, ref) => {
'justifyJustify'
,
'justifyJustify'
,
'divider'
,
'divider'
,
'|'
,
'|'
,
// 'AIImage',
'ImageAuto'
,
'ImageAuto'
,
'ImageAutoOnline'
,
//
'ImageAutoOnline',
'GalleryAuto'
,
'GalleryAuto'
,
'GalleryAutoOnline'
,
//
'GalleryAutoOnline',
'VideoAuto'
,
'VideoAuto'
,
'AudioAuto'
,
'AudioAuto'
,
'insertTable'
,
'insertTable'
,
...
@@ -349,6 +365,8 @@ const WangEditorCustomer = (props, ref) => {
...
@@ -349,6 +365,8 @@ const WangEditorCustomer = (props, ref) => {
'Practice'
,
'Practice'
,
'TooltipAuto'
,
'TooltipAuto'
,
'ExpandRead'
,
'ExpandRead'
,
'RemoveSpaces'
,
'ConvertTooltipType'
,
'|'
,
'|'
,
'AIRewrite'
,
'AIRewrite'
,
'AIExpand'
,
'AIExpand'
,
...
@@ -366,7 +384,8 @@ const WangEditorCustomer = (props, ref) => {
...
@@ -366,7 +384,8 @@ const WangEditorCustomer = (props, ref) => {
'AIDigitalHuman'
,
'AIDigitalHuman'
,
'AITranslate'
,
'AITranslate'
,
'AISearch'
,
'AISearch'
,
'AIWrite'
,
// 'AIWrite',
// 'AIBaiduSearch',
],
],
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论