Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
e2c2d3c7
Commit
e2c2d3c7
authored
Mar 22, 2021
by
yuananting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:wangeditor版本冲突bug修复
parent
ba3410c0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
59 deletions
+62
-59
src/modules/teach-tool/components/NewQuestionTab.jsx
+0
-0
src/modules/teach-tool/components/QuestionEditor.jsx
+57
-56
src/modules/teach-tool/components/QuestionEditor.less
+5
-3
No files found.
src/modules/teach-tool/components/NewQuestionTab.jsx
View file @
e2c2d3c7
This diff is collapsed.
Click to expand it.
src/modules/teach-tool/components/QuestionEditor.jsx
View file @
e2c2d3c7
...
@@ -50,8 +50,8 @@ class QuestionEditor extends Component {
...
@@ -50,8 +50,8 @@ class QuestionEditor extends Component {
static
getDerivedStateFromProps
(
nextProps
,
prevState
)
{
static
getDerivedStateFromProps
(
nextProps
,
prevState
)
{
return
{
return
{
detailInfo
:
nextProps
.
detailInfo
detailInfo
:
nextProps
.
detailInfo
,
}
}
;
}
}
shouldComponentUpdate
(
nextProps
,
nextState
)
{
shouldComponentUpdate
(
nextProps
,
nextState
)
{
...
@@ -62,10 +62,9 @@ class QuestionEditor extends Component {
...
@@ -62,10 +62,9 @@ class QuestionEditor extends Component {
});
});
}
}
if
(
blanksList
!==
this
.
state
.
blanksList
)
{
if
(
blanksList
!==
this
.
state
.
blanksList
)
{
console
.
log
(
"+++++++"
,
blanksList
)
this
.
setState
({
this
.
setState
({
blanksList
blanksList
,
})
})
;
}
}
return
true
;
return
true
;
}
}
...
@@ -94,7 +93,6 @@ class QuestionEditor extends Component {
...
@@ -94,7 +93,6 @@ class QuestionEditor extends Component {
this
.
editorRoot
.
txt
.
html
(
this
.
editorRoot
.
txt
.
html
(
/^
\<
p/
.
test
(
content
)
?
content
:
`<p>
${
content
}
</p>`
/^
\<
p/
.
test
(
content
)
?
content
:
`<p>
${
content
}
</p>`
);
);
this
.
editorRoot
.
change
&&
this
.
editorRoot
.
change
();
};
};
renderEditor
()
{
renderEditor
()
{
...
@@ -104,12 +102,12 @@ class QuestionEditor extends Component {
...
@@ -104,12 +102,12 @@ class QuestionEditor extends Component {
`#editor
${
editorId
}
_tabbar`
,
`#editor
${
editorId
}
_tabbar`
,
`#editor
${
editorId
}
_content`
`#editor
${
editorId
}
_content`
);
);
editorRoot
.
c
ustomC
onfig
.
menus
=
[];
editorRoot
.
config
.
menus
=
[];
editorRoot
.
c
ustomC
onfig
.
uploadImgMaxSize
=
1
*
1024
*
1024
;
editorRoot
.
config
.
uploadImgMaxSize
=
1
*
1024
*
1024
;
editorRoot
.
c
ustomC
onfig
.
customAlert
=
function
(
info
)
{
editorRoot
.
config
.
customAlert
=
function
(
info
)
{
message
.
warning
(
/1M/
.
test
(
info
)
?
"图片大于1M,请使用图片上传"
:
info
);
message
.
warning
(
/1M/
.
test
(
info
)
?
"图片大于1M,请使用图片上传"
:
info
);
};
};
editorRoot
.
c
ustomC
onfig
.
customUploadImg
=
function
(
files
,
insert
)
{
editorRoot
.
config
.
customUploadImg
=
function
(
files
,
insert
)
{
// files 是 input 中选中的文件列表
// files 是 input 中选中的文件列表
// insert 是获取图片 url 后,插入到编辑器的方法
// insert 是获取图片 url 后,插入到编辑器的方法
UploadOss
.
uploadBlobToOSS
(
files
[
0
],
window
.
random_string
(
16
)).
then
(
UploadOss
.
uploadBlobToOSS
(
files
[
0
],
window
.
random_string
(
16
)).
then
(
...
@@ -118,10 +116,11 @@ class QuestionEditor extends Component {
...
@@ -118,10 +116,11 @@ class QuestionEditor extends Component {
}
}
);
);
};
};
editorRoot
.
customConfig
.
zIndex
=
999
;
editorRoot
.
config
.
zIndex
=
999
;
editorRoot
.
customConfig
.
pasteFilterStyle
=
false
;
editorRoot
.
config
.
placeholder
=
""
;
editorRoot
.
config
.
pasteFilterStyle
=
false
;
// 自定义处理粘贴的文本内容
// 自定义处理粘贴的文本内容
editorRoot
.
c
ustomC
onfig
.
pasteTextHandle
=
function
(
content
)
{
editorRoot
.
config
.
pasteTextHandle
=
function
(
content
)
{
if
(
content
==
""
&&
!
content
)
return
""
;
if
(
content
==
""
&&
!
content
)
return
""
;
var
str
=
content
;
var
str
=
content
;
str
=
str
.
replace
(
/<xml>
[\s\S]
*
?
<
\/
xml>/gi
,
""
);
str
=
str
.
replace
(
/<xml>
[\s\S]
*
?
<
\/
xml>/gi
,
""
);
...
@@ -137,32 +136,35 @@ class QuestionEditor extends Component {
...
@@ -137,32 +136,35 @@ class QuestionEditor extends Component {
return
str
;
return
str
;
};
};
let
prevList
=
[]
let
prevList
=
[]
;
let
counter
=
0
;
let
counter
=
0
;
const
isEdit
=
getParameterByName
(
'id'
);
const
isEdit
=
getParameterByName
(
"id"
);
if
(
isEdit
)
{
if
(
isEdit
)
{
const
stemDom
=
document
.
getElementsByClassName
(
"add-fill-line"
);
const
stemDom
=
document
.
getElementsByClassName
(
"add-fill-line"
);
prevList
=
[...
stemDom
].
map
(
item
=>
item
.
id
)
prevList
=
[...
stemDom
].
map
(
(
item
)
=>
item
.
id
);
localStorage
.
setItem
(
'gap_ques_prevList'
,
JSON
.
stringify
(
prevList
));
localStorage
.
setItem
(
"gap_ques_prevList"
,
JSON
.
stringify
(
prevList
));
setTimeout
(
function
()
{
setTimeout
(
const
divHeight
=
document
.
getElementById
(
`editor
${
editorId
}
_content`
)
function
()
{
.
firstChild
.
offsetHeight
;
const
divHeight
=
document
.
getElementById
(
`editor
${
editorId
}
_content`
)
if
(
divHeight
>
30
)
{
.
firstChild
.
offsetHeight
;
this
.
setState
({
isShowSingleInput
:
false
});
if
(
divHeight
>
30
)
{
}
else
{
this
.
setState
({
isShowSingleInput
:
false
});
this
.
setState
({
isShowSingleInput
:
true
});
}
else
{
}
this
.
setState
({
isShowSingleInput
:
true
});
}.
bind
(
this
))
}
}.
bind
(
this
)
);
if
(
counter
===
0
)
{
if
(
counter
===
0
)
{
this
.
props
.
changeBlankCount
(
stemDom
)
this
.
props
.
changeBlankCount
(
stemDom
)
;
}
}
}
}
editorRoot
.
customConfig
.
onchange
=
(
html
)
=>
{
editorRoot
.
config
.
onchange
=
(
html
)
=>
{
const
conLen
=
html
.
replace
(
/<
(?!
img|input
)
.*
?
>/g
,
""
).
length
;
html
=
html
.
replace
(
/<
(?!
img|input
)
.*
?
>/g
,
""
);
const
conLen
=
html
.
length
;
counter
++
;
counter
++
;
const
{
focusFlag
}
=
this
.
state
;
const
{
focusFlag
}
=
this
.
state
;
const
textLength
=
editorRoot
.
txt
.
text
().
replace
(
/
\&
nbsp
\;
/gi
,
" "
)
const
textLength
=
editorRoot
.
txt
.
text
().
replace
(
/
\&
nbsp
\;
/gi
,
" "
)
...
@@ -178,14 +180,17 @@ class QuestionEditor extends Component {
...
@@ -178,14 +180,17 @@ class QuestionEditor extends Component {
}
else
{
}
else
{
this
.
setState
({
isShowSingleInput
:
true
});
this
.
setState
({
isShowSingleInput
:
true
});
}
}
if
(
this
.
state
.
isGapFilling
&&
this
.
state
.
contentType
===
"QUESTION_STEM"
)
{
if
(
this
.
state
.
isGapFilling
&&
this
.
state
.
contentType
===
"QUESTION_STEM"
)
{
const
stemHtml
=
this
.
transferStemDocument
(
html
);
const
stemHtml
=
this
.
transferStemDocument
(
html
);
var
_blanksList
=
stemHtml
.
getElementsByClassName
(
"add-fill-line"
)
var
_blanksList
=
stemHtml
.
getElementsByClassName
(
"add-fill-line"
)
;
const
ids
=
[...
_blanksList
].
map
(
item
=>
item
.
id
);
const
ids
=
[...
_blanksList
].
map
(
(
item
)
=>
item
.
id
);
const
isEdit
=
getParameterByName
(
'id'
);
const
isEdit
=
getParameterByName
(
"id"
);
if
(
isEdit
&&
counter
===
1
)
{
if
(
isEdit
&&
counter
===
1
)
{
const
prev
=
localStorage
.
getItem
(
'gap_ques_prevList'
);
const
prev
=
localStorage
.
getItem
(
"gap_ques_prevList"
);
prevList
=
prev
&&
JSON
.
parse
(
prev
);
prevList
=
prev
&&
JSON
.
parse
(
prev
);
}
}
...
@@ -193,25 +198,31 @@ class QuestionEditor extends Component {
...
@@ -193,25 +198,31 @@ class QuestionEditor extends Component {
if
(
prevList
&&
ids
)
{
if
(
prevList
&&
ids
)
{
idx
=
this
.
getNewArr
(
prevList
,
ids
);
idx
=
this
.
getNewArr
(
prevList
,
ids
);
const
oldLen
=
prevList
.
length
;
const
oldLen
=
prevList
.
length
;
idx
=
idx
>=
oldLen
?
idx
-
oldLen
:
idx
;
idx
=
idx
>=
oldLen
?
idx
-
oldLen
:
idx
}
}
prevList
=
[...
ids
];
prevList
=
[...
ids
];
this
.
setState
({
blanksList
:
_blanksList
},
()
=>
this
.
props
.
changeBlankCount
(
_blanksList
,
idx
))
this
.
setState
({
blanksList
:
_blanksList
},
()
=>
this
.
props
.
changeBlankCount
(
_blanksList
,
idx
)
);
}
}
this
.
setState
(
this
.
setState
(
{
contentLength
,
visiblePlacehold
:
conLen
===
0
&&
!
focusFlag
},
{
contentLength
,
visiblePlacehold
:
(
conLen
===
0
||
(
conLen
===
1
&&
html
===
" "
))
&&
!
focusFlag
,
},
()
=>
{
()
=>
{
onChange
&&
onChange
(
html
,
this
.
state
.
contentLength
);
onChange
&&
onChange
(
html
,
this
.
state
.
contentLength
);
}
}
);
);
};
};
editorRoot
.
customConfig
.
onblur
=
(
html
)
=>
{
editorRoot
.
config
.
onblur
=
(
html
)
=>
{
const
conLen
=
html
.
replace
(
/<
(?!
img|input
)
.*
?
>/g
,
""
).
length
;
html
=
html
.
replace
(
/<
(?!
img|input
)
.*
?
>/g
,
""
);
editorRoot
.
change
&&
editorRoot
.
change
();
html
=
html
.
replace
(
/
\s
+/g
,
""
);
const
conLen
=
html
.
length
;
this
.
setState
({
this
.
setState
({
focusFlag
:
false
,
focusFlag
:
false
,
visibleMediaBox
:
false
,
visibleMediaBox
:
false
,
...
@@ -220,24 +231,14 @@ class QuestionEditor extends Component {
...
@@ -220,24 +231,14 @@ class QuestionEditor extends Component {
});
});
};
};
editorRoot
.
customConfig
.
onfocus
=
()
=>
{
this
.
setState
({
focusFlag
:
true
,
visibleMediaBox
:
true
,
visiblePlacehold
:
false
,
});
};
editorRoot
.
create
();
editorRoot
.
create
();
this
.
editorRoot
=
editorRoot
;
this
.
editorRoot
=
editorRoot
;
// if (detailInfo && detailInfo.content) {
const
contentHtml
=
/^
\<
p/
.
test
(
detailInfo
.
content
)
const
contentHtml
=
/^
\<
p/
.
test
(
detailInfo
.
content
)
?
detailInfo
.
content
?
detailInfo
.
content
:
`<p>
${
detailInfo
.
content
}
</p>`
;
:
`<p>
${
detailInfo
.
content
}
</p>`
;
editorRoot
.
txt
.
html
(
detailInfo
.
content
);
editorRoot
.
txt
.
html
(
detailInfo
.
content
);
const
textLength
=
editorRoot
.
txt
.
text
().
replace
(
/
\&
nbsp
\;
/gi
,
" "
)
const
textLength
=
editorRoot
.
txt
.
text
().
replace
(
/
\&
nbsp
\;
/gi
,
" "
).
length
;
.
length
;
const
imgLength
=
contentHtml
.
match
(
/<img/g
)
const
imgLength
=
contentHtml
.
match
(
/<img/g
)
?
contentHtml
.
match
(
/<img/g
).
length
*
2
?
contentHtml
.
match
(
/<img/g
).
length
*
2
:
0
;
:
0
;
...
@@ -251,13 +252,12 @@ class QuestionEditor extends Component {
...
@@ -251,13 +252,12 @@ class QuestionEditor extends Component {
onChange
&&
onChange
(
contentHtml
,
this
.
state
.
contentLength
);
onChange
&&
onChange
(
contentHtml
,
this
.
state
.
contentLength
);
}
}
);
);
// }
bindChangeContent
&&
bindChangeContent
(
this
.
handleChangeContent
);
bindChangeContent
&&
bindChangeContent
(
this
.
handleChangeContent
);
}
}
getNewArr
(
a
,
b
)
{
getNewArr
(
a
,
b
)
{
const
arr
=
[...
a
,
...
b
];
const
arr
=
[...
a
,
...
b
];
const
idx
=
arr
.
findIndex
(
item
=>
{
const
idx
=
arr
.
findIndex
(
(
item
)
=>
{
return
!
(
a
.
includes
(
item
)
&&
b
.
includes
(
item
));
return
!
(
a
.
includes
(
item
)
&&
b
.
includes
(
item
));
});
});
return
idx
;
return
idx
;
...
@@ -360,8 +360,9 @@ class QuestionEditor extends Component {
...
@@ -360,8 +360,9 @@ class QuestionEditor extends Component {
</
div
>
</
div
>
)
}
)
}
<
div
<
div
className=
{
`editor-limit-tip${contentLength > limitLength ? " mt6" : ""
className=
{
`editor-limit-tip${
}`
}
contentLength > limitLength ? " mt6" : ""
}`
}
style=
{
{
height
:
contentLength
>
limitLength
?
20
:
0
}
}
style=
{
{
height
:
contentLength
>
limitLength
?
20
:
0
}
}
>
>
最多只能输入1000字
最多只能输入1000字
...
...
src/modules/teach-tool/components/QuestionEditor.less
View file @
e2c2d3c7
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
color: #999999;
color: #999999;
margin-top: 8px;
margin-top: 8px;
.editor-fill-info_icon {
.editor-fill-info_icon {
color: #5289fa;
color: #5289fa
!important
;
font-size: 14px;
font-size: 14px;
padding-left: 9px;
padding-left: 9px
!important
;
cursor: pointer;
cursor: pointer;
}
}
}
}
...
@@ -94,7 +94,7 @@
...
@@ -94,7 +94,7 @@
.editor-placehold {
.editor-placehold {
position: absolute;
position: absolute;
top: 0;
top: 0
px
;
left: 0;
left: 0;
right: 0;
right: 0;
font-size: 14px;
font-size: 14px;
...
@@ -104,6 +104,8 @@
...
@@ -104,6 +104,8 @@
white-space: nowrap;
white-space: nowrap;
text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
overflow: hidden;
z-index: 999;
pointer-events: none;
}
}
.edtior-media_box {
.edtior-media_box {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment