Commit ed0df259 by 杨明

fixed

1 parent 5c1049ad
...@@ -456,7 +456,11 @@ export default { ...@@ -456,7 +456,11 @@ export default {
this.previewList.splice(index, 1) this.previewList.splice(index, 1)
}, },
textInput(val) { textInput(val) {
val = val.replace(/ /g, '') val = val
.replace(/ /g, '')
.replace(/&/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
this.textNum = val.replace(/(\n|\s)/g, '').length this.textNum = val.replace(/(\n|\s)/g, '').length
if (this.textNum > this.maxNum) { if (this.textNum > this.maxNum) {
this.textNum = this.maxNum this.textNum = this.maxNum
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<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> </div>
</template> </template>
<script> <script>
import emoji from '../../../utils/emo' import emoji from '../../../utils/emo'
export default { export default {
...@@ -153,24 +152,6 @@ export default { ...@@ -153,24 +152,6 @@ export default {
let target = this.$refs.wTextareaContent let target = this.$refs.wTextareaContent
this.updateData(target.innerHTML) this.updateData(target.innerHTML)
}, },
promiseAdd(item, num) {
return new Promise((resolve, reject) => {
setTimeout(() => {
document.querySelector('.w-textarea_input').innerHTML += item
document.querySelector('.w-textarea_input').focus()
resolve()
}, num * 100)
})
},
promiseAddNode(item, num) {
return new Promise((resolve, reject) => {
setTimeout(() => {
document.querySelector('.w-textarea_input').innerHTML += item
document.querySelector('.w-textarea_input').focus()
resolve()
}, num * 100)
})
},
addLink(text, url) { addLink(text, url) {
// 创建a标签 // 创建a标签
let node = document.createElement('a') let node = document.createElement('a')
...@@ -209,10 +190,11 @@ export default { ...@@ -209,10 +190,11 @@ export default {
subText(htm) { subText(htm) {
const list = emoji.flat(Infinity) const list = emoji.flat(Infinity)
const cutImg = htm const cutImg = htm
.replace(/<span>([\s\S]*?)<\/span>/g, '$1')
.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, '$1') .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]
return `[${s}]` return `[${s}]`
}) })
...@@ -226,17 +208,15 @@ export default { ...@@ -226,17 +208,15 @@ export default {
// 插入链接 // 插入链接
if (this.isInsert) { if (this.isInsert) {
this.savedRange.insertNode(node) this.savedRange.insertNode(node)
this.savedRange.insertNode(document.createElement('span'))
} else { } else {
document.querySelector('.w-textarea_input').appendChild(node) document.querySelector('.w-textarea_input').appendChild(node)
this.savedRange.insertNode(document.createElement('span'))
} }
this.isInsert = false this.isInsert = false
// 更新双向绑定数据 // 更新双向绑定数据
let target = this.$refs.wTextareaContent let target = this.$refs.wTextareaContent
if (navigator.userAgent.indexOf('Firefox') > 0 || navigator.userAgent.indexOf('QQBrowser') > 0) { this.updateData(target.innerHTML)
this.updateData(target.innerHTML + '&nbsp;')
} else {
this.updateData(target.innerHTML)
}
let htm = target.innerHTML let htm = target.innerHTML
this.subText(htm) this.subText(htm)
}, },
...@@ -316,10 +296,10 @@ export default { ...@@ -316,10 +296,10 @@ export default {
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.w-textarea { .w-textarea {
wise { wise {
user-select: none;
border-radius: 2px; border-radius: 2px;
background-color: #fff; background-color: #fff;
font-size: 14px; font-size: 14px;
...@@ -346,7 +326,6 @@ export default { ...@@ -346,7 +326,6 @@ export default {
} }
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
$borderColor: #e5e5e5; $borderColor: #e5e5e5;
$bgColor: #f5f7fa; $bgColor: #f5f7fa;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!