Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
b16eb3b9
提交
b16eb3b9
authored
7月 22, 2026
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(admin): host practice dialogs
上级
007984f7
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
88 行删除
+33
-88
FeatureDialogs.jsx
.../wangeditor-customer/features/practice/FeatureDialogs.jsx
+26
-0
feature.js
...c/common/wangeditor-customer/features/practice/feature.js
+4
-1
node.js
.../src/common/wangeditor-customer/features/practice/node.js
+2
-4
WangEditorCustomer.jsx
...c/common/wangeditor-customer/shell/WangEditorCustomer.jsx
+1
-83
没有找到文件。
apps/admin/src/common/wangeditor-customer/features/practice/FeatureDialogs.jsx
0 → 100644
浏览文件 @
b16eb3b9
import
{
useEffect
}
from
'react'
import
{
Modal
}
from
'antd'
import
{
useDispatch
}
from
'react-redux'
import
{
setPracticeRandom
}
from
'@/store/modules/editor'
import
PracticeInsertDialog
from
'./PracticeInsertDialog'
import
PracticeSettingsDialog
from
'./PracticeSettingsDialog'
const
classNames
=
{
header
:
'editor-header-customer'
,
body
:
'editor-body-customer'
,
wrapper
:
'editor-wrapper-customer'
}
export
function
PracticeInsertFeatureDialog
({
open
,
onClose
,
runtime
})
{
return
<
Modal
open=
{
open
}
footer=
{
null
}
centered
destroyOnHidden
title=
"插入交互练习"
classNames=
{
classNames
}
maskClosable=
{
false
}
onCancel=
{
onClose
}
>
<
PracticeInsertDialog
editor=
{
runtime
.
editor
}
chapterId=
{
runtime
.
chapterId
}
bookId=
{
runtime
.
bookId
}
setPracticeOpenVisible=
{
visible
=>
!
visible
&&
onClose
()
}
/>
</
Modal
>
}
export
function
PracticeSettingsFeatureDialog
({
open
,
onClose
,
payload
,
runtime
})
{
const
dispatch
=
useDispatch
()
useEffect
(()
=>
{
dispatch
(
setPracticeRandom
({
practiceNum
:
payload
.
practiceNum
,
practiceTitle
:
payload
.
title
,
practiceTheme
:
payload
.
theme
}))
return
()
=>
dispatch
(
setPracticeRandom
({
practiceNum
:
null
,
practiceTitle
:
null
}))
},
[
dispatch
,
payload
])
return
<
Modal
open=
{
open
}
footer=
{
null
}
centered
destroyOnHidden
title=
{
null
}
classNames=
{
{
header
:
'practice-topic-header'
,
body
:
'practice-topic-content'
,
wrapper
:
'practice-topic-modal'
}
}
maskClosable=
{
false
}
closeIcon=
{
false
}
width=
"90%"
onCancel=
{
onClose
}
>
<
PracticeSettingsDialog
editor=
{
runtime
.
editor
}
chapterId=
{
runtime
.
chapterId
}
bookId=
{
runtime
.
bookId
}
closePanel=
{
onClose
}
/>
</
Modal
>
}
apps/admin/src/common/wangeditor-customer/features/practice/feature.js
浏览文件 @
b16eb3b9
import
{
defineEditorFeature
}
from
'../../core/define-editor-feature'
import
menu
from
'./menu'
import
nodeModule
from
'./node'
import
{
openEditorDialog
}
from
'../../core/editor-dialog'
import
{
PracticeInsertFeatureDialog
,
PracticeSettingsFeatureDialog
}
from
'./FeatureDialogs'
export
default
defineEditorFeature
({
id
:
'practice'
,
menus
:
[{
order
:
100
,
config
:
menu
}],
nodeModules
:
[{
order
:
90
,
types
:
[
'chapterPractice'
],
module
:
nodeModule
}],
events
:
[{
name
:
'PracticeMenuClick'
,
handler
:
({
runtime
})
=>
runtime
.
openPractice
()
}],
dialogs
:
[{
id
:
'practice.insert'
,
component
:
PracticeInsertFeatureDialog
},
{
id
:
'practice.settings'
,
component
:
PracticeSettingsFeatureDialog
}],
events
:
[{
name
:
'PracticeMenuClick'
,
handler
:
({
editor
})
=>
openEditorDialog
(
editor
,
'practice.insert'
)
}],
})
apps/admin/src/common/wangeditor-customer/features/practice/node.js
浏览文件 @
b16eb3b9
import
{
DomEditor
,
SlateTransforms
,
SlateEditor
}
from
"@wangeditor/editor"
;
import
{
h
}
from
"snabbdom"
;
import
{
openEditorDialog
}
from
'../../core/editor-dialog'
import
iconClose
from
"@/assets/images/icon_chapter_close.png"
;
import
{
delChapterTopic
}
from
"../../utils/request"
;
import
"../../utils/iconfont"
;
...
...
@@ -215,10 +216,7 @@ const renderPractice = (elem, children, editor) => {
try
{
callback
&&
callback
(
practiceNum
,
title
);
}
catch
(
e
)
{}
editor
.
emit
(
"wangeditor-customer:legacy-dialog"
,
{
key
:
"practiceNum"
,
payload
:
{
practiceNum
,
title
,
theme
,
random
:
Math
.
random
()
},
});
openEditorDialog
(
editor
,
'practice.settings'
,
{
practiceNum
,
title
,
theme
,
random
:
Math
.
random
()
})
}
/* 其他... */
,
},
},
...
...
apps/admin/src/common/wangeditor-customer/shell/WangEditorCustomer.jsx
浏览文件 @
b16eb3b9
...
...
@@ -4,8 +4,7 @@ import { EyeOutlined, SaveOutlined, CloseOutlined, HistoryOutlined } from "@ant-
import
dayjs
from
"dayjs"
;
import
"../utils/iconfont"
;
import
{
useSelector
,
useDispatch
}
from
"react-redux"
;
import
{
setPracticeRandom
}
from
"@/store/modules/editor"
;
import
{
useSelector
}
from
"react-redux"
;
// import formulaEditor from 'easy-formula-editor'
import
"../utils/jax.less"
;
import
{
Boot
}
from
"@wangeditor/editor"
;
...
...
@@ -23,9 +22,7 @@ import relativeTime from "dayjs/plugin/relativeTime";
dayjs
.
extend
(
relativeTime
);
import
PracticeModal
from
"../features/practice/PracticeInsertDialog"
;
import
PracticeSettingModal
from
"../features/practice/PracticeSettingsDialog"
;
import
PreviewModal
from
"../features/preview/PreviewDialog"
;
import
HistoryModal
from
"../features/history/HistoryDialog"
;
...
...
@@ -54,7 +51,6 @@ const WangEditorCustomer = (props, ref) => {
isView
=
false
,
}
=
props
;
const
dispatch
=
useDispatch
();
// 自动保存时间
const
{
autosaveTime
}
=
useSelector
((
state
)
=>
state
.
editor
);
...
...
@@ -66,34 +62,11 @@ const WangEditorCustomer = (props, ref) => {
const
[
content
,
setContent
]
=
useState
(
html
);
const
saveRef
=
useRef
();
const
[
practiceOpenVisible
,
setPracticeOpenVisible
]
=
useState
(
false
);
// 练习
const
[
practiceVisible
,
setPracticeVisible
]
=
useState
(
false
);
// 练习答题设置
const
[
priviewVisible
,
setPreviewVisible
]
=
useState
(
false
);
const
[
historyVisible
,
setHistoryVisible
]
=
useState
(
false
);
//点击历史
const
handleLegacyDialog
=
({
key
,
payload
})
=>
{
if
(
key
===
"practiceNum"
)
{
const
{
practiceNum
,
title
,
theme
}
=
payload
;
dispatch
(
setPracticeRandom
({
practiceNum
,
practiceTitle
:
title
,
practiceTheme
:
theme
}));
setPracticeVisible
(
true
);
}
};
useEffect
(()
=>
{
if
(
!
editor
)
return
;
editor
.
on
(
"wangeditor-customer:legacy-dialog"
,
handleLegacyDialog
);
return
()
=>
{
editor
.
off
(
"wangeditor-customer:legacy-dialog"
,
handleLegacyDialog
);
};
},
[
editor
]);
const
closePanel
=
()
=>
{
dispatch
(
setPracticeRandom
({
practiceNum
:
null
,
practiceTitle
:
null
}));
setPracticeVisible
(
false
);
};
useImperativeHandle
(
ref
,
()
=>
{
return
{
editor
,
...
...
@@ -171,8 +144,6 @@ const WangEditorCustomer = (props, ref) => {
],
};
const
practiceRef
=
useRef
();
const
practiceSettingRef
=
useRef
();
const
previewRef
=
useRef
();
const
jsonContent
=
[
...
...
@@ -258,7 +229,6 @@ const WangEditorCustomer = (props, ref) => {
};
const
featureRuntime
=
{
openPractice
:
()
=>
setPracticeOpenVisible
(
true
),
}
useEditorFeatureEvents
({
editor
,
registry
:
editorFeatureRegistry
,
runtime
:
featureRuntime
})
...
...
@@ -343,58 +313,6 @@ const WangEditorCustomer = (props, ref) => {
/>
</
div
>
{
!
isView
&&
<
EditorSidebar
editor=
{
editor
}
toolbarConfig=
{
toolbarConfig
}
toolbarRef=
{
toolbarRef
}
tabKey=
{
tabKey
}
onTabChange=
{
tabKeyChange
}
colorList=
{
colorList
}
onApplyColor=
{
setColor
}
/>
}
{
/* 插入练习 */
}
<
Modal
open=
{
practiceOpenVisible
}
footer=
{
null
}
centered
destroyOnHidden
title=
"插入交互练习"
classNames=
{
{
header
:
"editor-header-customer"
,
body
:
"editor-body-customer"
,
wrapper
:
"editor-wrapper-customer"
,
}
}
maskClosable=
{
false
}
onCancel=
{
()
=>
setPracticeOpenVisible
(
false
)
}
>
<
PracticeModal
ref=
{
practiceRef
}
chapterId=
{
chapterId
}
bookId=
{
bookId
}
editor=
{
editor
}
setPracticeOpenVisible=
{
setPracticeOpenVisible
}
/>
</
Modal
>
<
Modal
open=
{
practiceVisible
}
footer=
{
null
}
centered
destroyOnHidden
title=
{
null
}
classNames=
{
{
header
:
"practice-topic-header"
,
body
:
"practice-topic-content"
,
wrapper
:
"practice-topic-modal"
,
}
}
maskClosable=
{
false
}
onCancel=
{
closePanel
}
closeIcon=
{
false
}
width=
"90%"
>
<
PracticeSettingModal
ref=
{
practiceSettingRef
}
nodes=
{
practiceRef
.
current
&&
practiceRef
.
current
.
nodes
?
practiceRef
.
current
.
nodes
:
null
}
chapterId=
{
chapterId
}
bookId=
{
bookId
}
editor=
{
editor
}
closePanel=
{
closePanel
}
/>
</
Modal
>
{
/* 预览 */
}
<
Modal
open=
{
priviewVisible
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论