Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsx-components
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit fd7a537b
authored
Sep 06, 2022
by
杨明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed
1 parent
b27cddad
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
84 deletions
src/assets/welcomeWord/add-code.png
src/packages/Editor/src/index.vue
src/packages/Editor/src/materialModel.vue
src/packages/Editor/src/tag-textarea.vue
src/assets/welcomeWord/add-code.png
0 → 100644
View file @
fd7a537
531 Bytes
src/packages/Editor/src/index.vue
View file @
fd7a537
...
@@ -141,18 +141,21 @@
...
@@ -141,18 +141,21 @@
</div>
</div>
</template>
</template>
</div>
</div>
<div
class=
"btn-group-panel"
>
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<div
class=
"add-btn"
v-for=
"item in btnList"
:key=
"item.type"
>
<div
class=
"add-btn"
v-for=
"item in btnList"
:key=
"item.type"
>
<!-- <i class="el-icon-circle-plus-outline"></i> -->
<!-- <i class="el-icon-circle-plus-outline"></i> -->
<img
:src=
"require(`../../../assets/welcomeWord/add-${checkedType(item.type)}.png`)"
alt
v-if=
"item.type == 'expression'"
@
click=
"selectEmotion"
/>
<img
class=
"emotion-item"
:src=
"require(`../../../assets/welcomeWord/add-${checkedType(item.type)}.png`)"
alt
v-if=
"item.type == 'expression'"
@
click=
"selectEmotion"
/>
<img
:src=
"require(`../../../assets/welcomeWord/add-${checkedType(item.type)}.png`)"
v-else
alt
/>
<img
:src=
"require(`../../../assets/welcomeWord/add-${checkedType(item.type)}.png`)"
v-else
alt
/>
<span
v-if=
"item.type == 'expression'"
@
click
.
stop=
"selectEmotion"
>
{{ item.name }}
</span>
<span
class=
"emotion-item"
v-if=
"item.type == 'expression'"
@
click
.
stop=
"selectEmotion"
>
{{ item.name }}
</span>
<span
v-else
>
{{ item.name }}
</span>
<span
v-else
>
{{ item.name }}
</span>
<input
v-if=
"item.type == 'img'"
type=
"file"
style=
"opacity: 0"
:id=
"item.type + 'file'"
ref=
"file"
class=
"welcome-input upload-img"
:accept=
"item.accept || 'image/png, image/jpeg, image/jpg'"
@
change=
"e => handleImgChange(e)"
/>
<input
v-if=
"item.type == 'img'"
type=
"file"
style=
"opacity: 0"
:id=
"item.type + 'file'"
ref=
"file"
class=
"welcome-input upload-img"
:accept=
"item.accept || 'image/png, image/jpeg, image/jpg'"
@
change=
"e => handleImgChange(e)"
/>
<input
v-else-if=
"item.type == 'video'"
type=
"file"
style=
"opacity: 0"
:id=
"item.type + 'file'"
ref=
"file"
class=
"welcome-input"
:accept=
"item.accept || 'video/*'"
@
change=
"e => handleVideoChange(e)"
/>
<input
v-else-if=
"item.type == 'video'"
type=
"file"
style=
"opacity: 0"
:id=
"item.type + 'file'"
ref=
"file"
class=
"welcome-input"
:accept=
"item.accept || 'video/*'"
@
change=
"e => handleVideoChange(e)"
/>
<el-link
v-else-if=
"item.type == 'link' || item.type == 'nickname' || item.type == 'message' || item.type == 'activity' || item.type == 'material'"
style=
"opacity: 0"
@
click=
"handleFun(item.type
)"
>
{{ item.name }}
</el-link>
<el-link
v-else-if=
"item.type != 'video' && item.type != 'img' && item.type != 'expression'"
style=
"opacity: 0"
@
click=
"handleFun(item
)"
>
{{ item.name }}
</el-link>
</div>
</div>
</div>
</div>
<div
class=
"text-num"
>
{{ textNum }}/{{ maxNum }}
</div>
</div>
</div>
</div>
<div
v-show=
"emotionStatus"
class=
"emotion-panel"
>
<div
v-show=
"emotionStatus"
class=
"emotion-panel"
>
<emotion
class=
"emotion-panel-box"
@
emotion=
"handleEmotion"
:height=
"280"
></emotion>
<emotion
class=
"emotion-panel-box"
@
emotion=
"handleEmotion"
:height=
"280"
></emotion>
...
@@ -179,7 +182,7 @@ const ATT_TYPE = {
...
@@ -179,7 +182,7 @@ const ATT_TYPE = {
ACTIVITY
:
7
,
ACTIVITY
:
7
,
MATERIAL
:
10
MATERIAL
:
10
}
}
const
wordType
=
[
'expression'
,
'img'
,
'video'
,
'nickname'
,
'activity'
,
'material'
,
'message'
,
'link'
]
const
wordType
=
[
'expression'
,
'img'
,
'video'
,
'nickname'
,
'activity'
,
'material'
,
'message'
,
'link'
,
'code'
]
import
emoji
from
'../../../utils/emo'
import
emoji
from
'../../../utils/emo'
import
ActivityModel
from
'./activityModel'
import
ActivityModel
from
'./activityModel'
import
MessageModel
from
'./messageModel'
import
MessageModel
from
'./messageModel'
...
@@ -212,6 +215,8 @@ export default {
...
@@ -212,6 +215,8 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
textNum
:
0
,
maxNum
:
600
,
myArr
:
[{
name
:
888
},
{
name
:
888
}],
myArr
:
[{
name
:
888
},
{
name
:
888
}],
dialogVisibleImg
:
false
,
dialogVisibleImg
:
false
,
dialogSrc
:
''
,
dialogSrc
:
''
,
...
@@ -229,7 +234,12 @@ export default {
...
@@ -229,7 +234,12 @@ export default {
}
}
},
},
mounted
()
{
mounted
()
{
console
.
log
(
vuedraggable
)
document
.
addEventListener
(
'click'
,
e
=>
{
console
.
log
(
e
.
target
.
className
)
if
(
e
.
target
.
className
!=
'emotion-item'
)
{
this
.
emotionStatus
=
false
}
})
},
},
computed
:
{
computed
:
{
activityList
()
{
activityList
()
{
...
@@ -426,9 +436,12 @@ export default {
...
@@ -426,9 +436,12 @@ export default {
}
}
})
})
},
},
handleFun
(
name
)
{
handleFun
(
type
)
{
const
name
=
type
.
type
if
(
name
==
'nickname'
)
{
if
(
name
==
'nickname'
)
{
this
.
$refs
.
textContent
.
addTag
(
'@昵称'
)
this
.
$refs
.
textContent
.
addTag
(
'@昵称'
)
}
else
if
(
name
==
'code'
)
{
this
.
$refs
.
textContent
.
addTag
(
'#兑换码'
)
}
else
if
(
name
==
'activity'
)
{
}
else
if
(
name
==
'activity'
)
{
this
.
$refs
.
activity
.
init
()
this
.
$refs
.
activity
.
init
()
}
else
if
(
name
==
'message'
)
{
}
else
if
(
name
==
'message'
)
{
...
@@ -444,6 +457,12 @@ export default {
...
@@ -444,6 +457,12 @@ export default {
},
},
textInput
(
val
)
{
textInput
(
val
)
{
val
=
val
.
replace
(
/ /g
,
''
)
val
=
val
.
replace
(
/ /g
,
''
)
this
.
textNum
=
val
.
replace
(
/
(\[
.*
?\]
|
\n
|
\s)
/g
,
''
).
length
if
(
this
.
textNum
>
this
.
maxNum
)
{
this
.
textNum
=
this
.
maxNum
this
.
updateList
(
this
.
previewList
,
1
)
return
}
const
hasText
=
this
.
previewList
.
some
(
item
=>
item
.
attType
==
this
.
ATT_TYPE
.
TEXT
)
const
hasText
=
this
.
previewList
.
some
(
item
=>
item
.
attType
==
this
.
ATT_TYPE
.
TEXT
)
if
(
hasText
)
{
if
(
hasText
)
{
this
.
$set
(
this
.
previewList
,
0
,
{
this
.
$set
(
this
.
previewList
,
0
,
{
...
@@ -508,15 +527,20 @@ export default {
...
@@ -508,15 +527,20 @@ export default {
})
})
})
})
}
}
console
.
log
(
html
)
const
idx
=
this
.
previewList
.
findIndex
(
item
=>
item
.
attType
==
this
.
ATT_TYPE
.
TEXT
)
const
idx
=
this
.
previewList
.
findIndex
(
item
=>
item
.
attType
==
this
.
ATT_TYPE
.
TEXT
)
if
(
idx
!==
-
1
)
{
if
(
idx
!==
-
1
)
{
if
(
!
this
.
previewList
[
idx
].
attContent
)
{
if
(
!
this
.
previewList
[
idx
].
attContent
)
{
html
=
html
.
replace
(
'\n'
,
''
).
replace
(
/<br
\/
>/g
,
''
)
html
=
html
.
replace
(
'\n'
,
''
).
replace
(
/<br
\/
>/g
,
''
)
}
}
html
=
html
.
replace
(
/&/g
,
'&'
).
replace
(
/</g
,
'<'
).
replace
(
/>/g
,
'>'
)
html
=
html
.
replace
(
/&/g
,
'&'
).
replace
(
/</g
,
'<'
).
replace
(
/>/g
,
'>'
)
let
textLen
=
this
.
previewList
[
idx
].
attContent
+
html
if
(
textLen
.
replace
(
/
(\n
|
\s)
/g
,
''
).
length
>
this
.
maxNum
)
{
textLen
=
this
.
previewList
[
idx
].
attContent
}
else
{
this
.
textNum
=
textLen
.
replace
(
/
(\n
|
\s)
/g
,
''
).
length
}
this
.
$set
(
this
.
previewList
,
0
,
{
this
.
$set
(
this
.
previewList
,
0
,
{
attContent
:
(
this
.
previewList
[
idx
].
attContent
+
html
).
substring
(
0
,
600
)
,
attContent
:
textLen
,
attType
:
this
.
ATT_TYPE
.
TEXT
attType
:
this
.
ATT_TYPE
.
TEXT
})
})
}
else
{
}
else
{
...
@@ -526,8 +550,14 @@ export default {
...
@@ -526,8 +550,14 @@ export default {
.
replace
(
/&/g
,
'&'
)
.
replace
(
/&/g
,
'&'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/>/g
,
'>'
)
let
textLen
=
html
if
(
textLen
.
replace
(
/
(\n
|
\s)
/g
,
''
).
length
>
this
.
maxNum
)
{
textLen
=
''
}
else
{
this
.
textNum
=
textLen
.
replace
(
/
(\n
|
\s)
/g
,
''
).
length
}
this
.
previewList
.
unshift
({
this
.
previewList
.
unshift
({
attContent
:
html
.
substring
(
0
,
600
)
,
attContent
:
textLen
,
attType
:
this
.
ATT_TYPE
.
TEXT
attType
:
this
.
ATT_TYPE
.
TEXT
})
})
}
}
...
@@ -538,34 +568,6 @@ export default {
...
@@ -538,34 +568,6 @@ export default {
this
.
updateText
(
content
)
this
.
updateText
(
content
)
this
.
textValue
=
content
this
.
textValue
=
content
},
},
insertHtmlAtCaret
(
html
)
{
var
sel
,
range
,
frag
if
(
window
.
getSelection
)
{
sel
=
window
.
getSelection
()
if
(
sel
.
getRangeAt
&&
sel
.
rangeCount
)
{
range
=
sel
.
getRangeAt
(
0
)
range
.
deleteContents
()
var
el
=
document
.
createElement
(
'span'
)
el
.
innerHTML
=
'<span contenteditable="false" class="nickname">@昵称<i class="el-icon-error"></i></span>'
// var el = document.createElement('div')
// el.innerHTML = html
frag
=
document
.
createDocumentFragment
()
var
node
var
lastNode
while
((
node
=
el
.
firstChild
))
{
lastNode
=
frag
.
appendChild
(
node
)
}
range
.
insertNode
(
frag
)
if
(
lastNode
)
{
range
=
range
.
cloneRange
()
range
.
setEndAfter
(
lastNode
)
range
.
collapse
(
true
)
sel
.
removeAllRanges
()
sel
.
addRange
(
range
)
}
}
}
},
changeInput
:
utils
.
debounce
(
function
()
{
changeInput
:
utils
.
debounce
(
function
()
{
var
allNodes
=
document
.
getElementById
(
'editor'
).
childNodes
var
allNodes
=
document
.
getElementById
(
'editor'
).
childNodes
var
str
=
''
var
str
=
''
...
@@ -580,14 +582,17 @@ export default {
...
@@ -580,14 +582,17 @@ export default {
},
300
),
},
300
),
updateList
(
val
,
status
)
{
updateList
(
val
,
status
)
{
this
.
previewList
=
utils
.
deepClone
(
val
)
this
.
previewList
=
utils
.
deepClone
(
val
)
// this.eventBus.$emit('update', this.previewList)
const
obj
=
val
.
find
(
item
=>
item
.
attType
==
this
.
ATT_TYPE
.
TEXT
)
const
obj
=
val
.
find
(
item
=>
item
.
attType
==
this
.
ATT_TYPE
.
TEXT
)
if
(
obj
)
{
if
(
obj
)
{
let
attContent
let
attContent
if
(
status
)
{
if
(
status
)
{
attContent
=
obj
.
attContent
.
replace
(
/
@昵称/g
,
'<wise id="1" contenteditable="false">@昵称
</wise>'
)
attContent
=
obj
.
attContent
.
replace
(
/
(
@昵称|#兑换码
)
/g
,
'<wise id="1" contenteditable="false">$1
</wise>'
)
}
else
{
}
else
{
attContent
=
obj
.
attContent
.
replace
(
/
\[
@昵称
\]
/g
,
'<wise id="1" contenteditable="false">@昵称</wise>'
)
this
.
textNum
=
obj
.
attContent
.
replace
(
/
(\n
|
\s)
/g
,
''
)
.
replace
(
/
\[(
@昵称|#兑换码
)\]
/g
,
'$1'
)
.
replace
(
/
\[[\u
4E00-
\u
9FA56
]{1,4}
]/g
,
''
).
length
attContent
=
obj
.
attContent
.
replace
(
/
\[(
@昵称|#兑换码
)\]
/g
,
'<wise id="1" contenteditable="false">$1</wise>'
)
}
}
let
htm
=
attContent
.
replace
(
/
\[[\u
4E00-
\u
9FA56
]{1,4}
]/gi
,
function
(
res
)
{
let
htm
=
attContent
.
replace
(
/
\[[\u
4E00-
\u
9FA56
]{1,4}
]/gi
,
function
(
res
)
{
let
word
=
res
.
replace
(
/
\[
|
\]
/gi
,
''
)
let
word
=
res
.
replace
(
/
\[
|
\]
/gi
,
''
)
...
@@ -807,13 +812,16 @@ export default {
...
@@ -807,13 +812,16 @@ export default {
margin-bottom
:
0
;
margin-bottom
:
0
;
}
}
}
}
.btn-group
{
.btn-group-panel
{
display
:
flex
;
justify-content
:
space-between
;
padding
:
10px
0
10px
20px
;
padding
:
10px
0
10px
20px
;
border
:
1px
solid
#e5e5e5
;
border
:
1px
solid
#e5e5e5
;
border-top
:
0
;
border-top
:
0
;
background
:
#fafbfe
;
background
:
#fafbfe
;
border-bottom-right-radius
:
4px
;
border-bottom-right-radius
:
4px
;
border-bottom-left-radius
:
4px
;
border-bottom-left-radius
:
4px
;
.btn-group
{
.add-btn
{
.add-btn
{
display
:
inline-flex
;
display
:
inline-flex
;
position
:
relative
;
position
:
relative
;
...
@@ -845,6 +853,11 @@ export default {
...
@@ -845,6 +853,11 @@ export default {
}
}
}
}
}
}
.text-num
{
padding-right
:
10px
;
}
}
.date-picker
{
.date-picker
{
margin-top
:
10px
;
margin-top
:
10px
;
font-size
:
14px
;
font-size
:
14px
;
...
...
src/packages/Editor/src/materialModel.vue
View file @
fd7a537
...
@@ -127,7 +127,7 @@ export default {
...
@@ -127,7 +127,7 @@ export default {
this
.
selectItem
=
item
this
.
selectItem
=
item
},
},
getimgsrc
(
htmlstr
)
{
getimgsrc
(
htmlstr
)
{
var
reg
=
/<img.+
?
src=
(
'|"
)?([^
'"
]
+
)(
'|"
)?(?:\s
+|>
)
/gim
var
reg
=
/<img.+
?
src=
(
'|"
)?([^
'"
]
+
)(
'|"
)?(?:\s
+|
\/?
>
)
/gim
var
arr
=
[]
var
arr
=
[]
var
tem
var
tem
while
((
tem
=
reg
.
exec
(
htmlstr
)))
{
while
((
tem
=
reg
.
exec
(
htmlstr
)))
{
...
...
src/packages/Editor/src/tag-textarea.vue
View file @
fd7a537
<
template
>
<
template
>
<div
class=
"w-textarea"
ref=
"wTextarea"
v-bind=
"$attr"
>
<div
class=
"w-textarea"
ref=
"wTextarea"
v-bind=
"$attr"
>
<div
contenteditable=
"true"
class=
"w-textarea_input"
ref=
"wTextareaContent"
:id=
"contentId"
@
keydown=
"textareaKeydown($event)"
@
click=
"inputClick($event)"
@
focus=
"onFocus"
@
blur=
"onBlur"
@
keydown
.
delete=
"handleDelete($event)"
@
input=
"handleInput($event.target)"
></div>
<div
contenteditable=
"true"
class=
"w-textarea_input"
ref=
"wTextareaContent"
:id=
"contentId"
@
keydown=
"textareaKeydown($event)"
@
click=
"inputClick($event)"
@
focus=
"onFocus"
@
blur=
"onBlur"
@
keydown
.
delete=
"handleDelete($event)"
@
input=
"handleInput($event.target)"
></div>
<!--
<div
class=
"w-textarea_tools"
v-if=
"tools.length > 0 || maxlength"
>
<button
class=
"w-textarea_tools__item"
v-for=
"item in tools"
:key=
"item.type"
@
click=
"openTagDialog(item.type)"
>
{{
item
.
text
}}
</button>
<span
:class=
"['w-textarea_tools__text',
count.num
< 0
?
'
__danger
'
:
'']"
v-if=
"maxlength"
>
{{
count
.
text
}}
</span>
</div>
-->
<!--
<div
class=
"w-textarea_dialog"
>
<slot></slot>
</div>
-->
</div>
</div>
</
template
>
</
template
>
...
@@ -187,30 +171,6 @@ export default {
...
@@ -187,30 +171,6 @@ export default {
},
num
*
100
)
},
num
*
100
)
})
})
},
},
addContent
(
attContent
)
{
attContent
.
forEach
(
async
(
item
,
index
)
=>
{
await
this
.
promiseAdd
(
item
,
index
)
this
.
addTag
(
'@昵称'
)
// await this.promiseAddNode(item, index)
// this.addNode()
// t2(item)
})
// for (let i = 0; i < attContent.length; i++) {
// if (attContent[i] || (i == 0 && !attContent[i])) {
// document.querySelector('.w-textarea_input').innerHTML += attContent[i]
// document.querySelector('.w-textarea_input').focus()
// document.querySelector('.w-textarea_input').click()
// this.$nextTick(()=>{
// this.addTag('@昵称')
// })
// }
// // 代码格式
// // (function(a) {})(b)
// }
},
addLink
(
text
,
url
)
{
addLink
(
text
,
url
)
{
// 创建a标签
// 创建a标签
let
node
=
document
.
createElement
(
'a'
)
let
node
=
document
.
createElement
(
'a'
)
...
@@ -250,7 +210,7 @@ export default {
...
@@ -250,7 +210,7 @@ export default {
const
list
=
emoji
.
flat
(
Infinity
)
const
list
=
emoji
.
flat
(
Infinity
)
const
cutImg
=
htm
const
cutImg
=
htm
.
replace
(
/<img src="https:
\/\/
img01.glsx.com.cn
\/
weapp
\/
resource
\/
saas
\/
scrm
\/
emoji
\/
/g
,
''
)
.
replace
(
/<img src="https:
\/\/
img01.glsx.com.cn
\/
weapp
\/
resource
\/
saas
\/
scrm
\/
emoji
\/
/g
,
''
)
.
replace
(
/<wise.+
?
(?:
<
\/
wise>
)
/g
,
'@昵称
'
)
.
replace
(
/<wise.+
?
>
(
.+
?)(?:
<
\/
wise>
)
/g
,
'$1
'
)
.
replace
(
/<br>/g
,
'\n'
)
.
replace
(
/<br>/g
,
'\n'
)
const
replaceImg
=
cutImg
.
replace
(
/
(\d){3}
.png">/g
,
function
(
str
)
{
const
replaceImg
=
cutImg
.
replace
(
/
(\d){3}
.png">/g
,
function
(
str
)
{
let
s
=
list
[
parseInt
(
str
.
split
(
'.'
)[
0
])
-
1
]
let
s
=
list
[
parseInt
(
str
.
split
(
'.'
)[
0
])
-
1
]
...
@@ -258,7 +218,7 @@ export default {
...
@@ -258,7 +218,7 @@ export default {
})
})
let
Textnode
=
document
.
createElement
(
'div'
)
let
Textnode
=
document
.
createElement
(
'div'
)
Textnode
.
innerHTML
=
replaceImg
Textnode
.
innerHTML
=
replaceImg
this
.
currentText
=
replaceImg
.
substring
(
0
,
600
)
this
.
currentText
=
replaceImg
this
.
$emit
(
'updateText'
,
this
.
currentText
)
this
.
$emit
(
'updateText'
,
this
.
currentText
)
},
},
insertNodeFirst
(
node
)
{
insertNodeFirst
(
node
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment