mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
fix: 添加模板时形状内文字异常自动聚焦
This commit is contained in:
parent
fb8a6f8c39
commit
7318755011
@ -121,6 +121,10 @@ onUnmounted(() => {
|
|||||||
editorView && editorView.destroy()
|
editorView && editorView.destroy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 暴露 focus 方法
|
||||||
|
const focus = () => editorView.focus()
|
||||||
|
defineExpose({ focus })
|
||||||
|
|
||||||
// 执行富文本命令(可以是一个或多个)
|
// 执行富文本命令(可以是一个或多个)
|
||||||
// 部分命令在执行前先判断当前选区是否为空,如果选区为空先进行全选操作
|
// 部分命令在执行前先判断当前选区是否为空,如果选区为空先进行全选操作
|
||||||
const execCommand = ({ target, action }: RichTextCommand) => {
|
const execCommand = ({ target, action }: RichTextCommand) => {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
v-contextmenu="contextmenus"
|
v-contextmenu="contextmenus"
|
||||||
@mousedown="$event => handleSelectElement($event)"
|
@mousedown="$event => handleSelectElement($event)"
|
||||||
@touchstart="$event => handleSelectElement($event)"
|
@touchstart="$event => handleSelectElement($event)"
|
||||||
@dblclick="editable = true"
|
@dblclick="startEdit()"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
overflow="visible"
|
overflow="visible"
|
||||||
@ -60,12 +60,12 @@
|
|||||||
|
|
||||||
<div class="shape-text" :class="[text.align, { 'editable': editable || text.content }]">
|
<div class="shape-text" :class="[text.align, { 'editable': editable || text.content }]">
|
||||||
<ProsemirrorEditor
|
<ProsemirrorEditor
|
||||||
|
ref="prosemirrorEditorRef"
|
||||||
v-if="editable || text.content"
|
v-if="editable || text.content"
|
||||||
:elementId="elementInfo.id"
|
:elementId="elementInfo.id"
|
||||||
:defaultColor="text.defaultColor"
|
:defaultColor="text.defaultColor"
|
||||||
:defaultFontName="text.defaultFontName"
|
:defaultFontName="text.defaultFontName"
|
||||||
:editable="!elementInfo.lock"
|
:editable="!elementInfo.lock"
|
||||||
:autoFocus="true"
|
|
||||||
:value="text.content"
|
:value="text.content"
|
||||||
@update="value => updateText(value)"
|
@update="value => updateText(value)"
|
||||||
@blur="checkEmptyText()"
|
@blur="checkEmptyText()"
|
||||||
@ -79,7 +79,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, PropType, ref, watch } from 'vue'
|
import { computed, nextTick, PropType, ref, watch } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useMainStore, useSlidesStore } from '@/store'
|
import { useMainStore, useSlidesStore } from '@/store'
|
||||||
import { PPTShapeElement, ShapeText } from '@/types/slides'
|
import { PPTShapeElement, ShapeText } from '@/types/slides'
|
||||||
@ -168,6 +168,12 @@ const checkEmptyText = () => {
|
|||||||
addHistorySnapshot()
|
addHistorySnapshot()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prosemirrorEditorRef = ref<typeof ProsemirrorEditor>()
|
||||||
|
const startEdit = () => {
|
||||||
|
editable.value = true
|
||||||
|
nextTick(() => prosemirrorEditorRef.value && prosemirrorEditorRef.value.focus())
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user