Browse Source

时间点及图标插入bug修复

lbj
sd 2 months ago
parent
commit
825452a560
  1. 24
      ruoyi-ui/public/stepEditor.html
  2. 17
      ruoyi-ui/src/views/childRoom/BottomTimeline.vue

24
ruoyi-ui/public/stepEditor.html

@ -515,25 +515,43 @@
insertText(text) { insertText(text) {
const editor = this.$refs.editor const editor = this.$refs.editor
const selection = window.getSelection() const selection = window.getSelection()
if (selection.rangeCount > 0) { if (selection.rangeCount > 0) {
const range = selection.getRangeAt(0) const range = selection.getRangeAt(0)
const textNode = document.createTextNode(text) const textNode = document.createTextNode(text)
range.insertNode(textNode) range.insertNode(textNode)
} else { } else {
editor.innerHTML += `<p>${text}</p>` if (editor.innerHTML.trim() === '') {
editor.innerHTML = `<p>${text}</p>`
} else {
editor.innerHTML += `<p>${text}</p>`
}
} }
this.$nextTick(() => {
this.updateWordCount()
})
}, },
insertHTML(html) { insertHTML(html) {
const editor = this.$refs.editor const editor = this.$refs.editor
const selection = window.getSelection() const selection = window.getSelection()
if (selection.rangeCount > 0) { if (selection.rangeCount > 0) {
const range = selection.getRangeAt(0) const range = selection.getRangeAt(0)
const div = document.createElement('div') const div = document.createElement('div')
div.innerHTML = html div.innerHTML = html
range.insertNode(div) range.insertNode(div)
} else { } else {
editor.innerHTML += html if (editor.innerHTML.trim() === '') {
editor.innerHTML = `<p>${html}</p>`
} else {
editor.innerHTML += `<p>${html}</p>`
}
} }
this.$nextTick(() => {
this.updateWordCount()
})
}, },
onInput() { onInput() {
this.content = this.$refs.editor.innerHTML this.content = this.$refs.editor.innerHTML
@ -566,7 +584,7 @@
}, },
onFocus() { onFocus() {
const editor = this.$refs.editor const editor = this.$refs.editor
if (editor.innerText.trim() === '' || editor.innerText === this.placeholder) { if (editor.innerText.trim() === '' && editor.innerHTML.trim() === '') {
editor.innerHTML = '' editor.innerHTML = ''
} }
}, },

17
ruoyi-ui/src/views/childRoom/BottomTimeline.vue

@ -471,18 +471,19 @@ export default {
}) })
this.scaleLabels = [] this.scaleLabels = []
const labelCount = 5 const sortedSegments = [...this.timelineSegments].sort((a, b) => {
for (let i = 0; i <= labelCount; i++) { return this.timeToSeconds(a.time) - this.timeToSeconds(b.time)
const percentage = (i / labelCount) * 100 })
const currentSeconds = startSeconds + (totalSeconds * percentage / 100) sortedSegments.forEach(segment => {
const hours = Math.floor(currentSeconds / 3600) const segmentSeconds = this.timeToSeconds(segment.time)
const minutes = Math.floor((currentSeconds % 3600) / 60) const hours = Math.floor(segmentSeconds / 3600)
const minutes = Math.floor((segmentSeconds % 3600) / 60)
const timeStr = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}` const timeStr = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`
this.scaleLabels.push({ this.scaleLabels.push({
position: percentage, position: segment.position,
time: timeStr time: timeStr
}) })
} })
}, },
editSegment(segment) { editSegment(segment) {

Loading…
Cancel
Save