mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
fix: 表格单元格编辑优化,处理Firefox下无法编辑的问题(#209)
This commit is contained in:
parent
62c21928c1
commit
22169b9bff
@ -2,15 +2,16 @@
|
||||
<div
|
||||
class="custom-textarea"
|
||||
ref="textareaRef"
|
||||
@focus="handleFocus"
|
||||
@blur="handleBlur"
|
||||
:contenteditable="true"
|
||||
@focus="handleFocus()"
|
||||
@blur="handleBlur()"
|
||||
@input="handleInput()"
|
||||
v-html="text"
|
||||
></div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onUnmounted, ref, watch } from 'vue'
|
||||
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { pasteCustomClipboardString, pasteExcelClipboardString } from '@/utils/clipboard'
|
||||
|
||||
const props = defineProps({
|
||||
@ -18,10 +19,6 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
contenteditable: {
|
||||
type: [Boolean, String],
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
@ -70,7 +67,6 @@ const handleFocus = () => {
|
||||
return
|
||||
}
|
||||
|
||||
emit('updateValue', text)
|
||||
document.execCommand('insertText', false, text)
|
||||
})
|
||||
}
|
||||
@ -84,7 +80,7 @@ const handleBlur = () => {
|
||||
}
|
||||
|
||||
// 清除粘贴事件监听
|
||||
onUnmounted(() => {
|
||||
onBeforeUnmount(() => {
|
||||
if (textareaRef.value) textareaRef.value.onpaste = null
|
||||
})
|
||||
</script>
|
||||
@ -94,6 +90,5 @@ onUnmounted(() => {
|
||||
border: 0;
|
||||
outline: 0;
|
||||
-webkit-user-modify: read-write-plaintext-only;
|
||||
-moz-user-modify: read-write-plaintext-only;
|
||||
}
|
||||
</style>
|
Loading…
x
Reference in New Issue
Block a user