mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
feat: 双击开始编辑图表数据
This commit is contained in:
parent
44c6b2fd0c
commit
52380cabbf
@ -2,6 +2,7 @@ import mitt, { Emitter } from 'mitt'
|
||||
|
||||
export const enum EmitterEvents {
|
||||
RICH_TEXT_COMMAND = 'RICH_TEXT_COMMAND',
|
||||
OPEN_CHART_DATA_EDITOR = 'OPEN_CHART_DATA_EDITOR',
|
||||
}
|
||||
|
||||
export interface RichTextCommand {
|
||||
@ -11,6 +12,7 @@ export interface RichTextCommand {
|
||||
|
||||
type Events = {
|
||||
[EmitterEvents.RICH_TEXT_COMMAND]: RichTextCommand | RichTextCommand[];
|
||||
[EmitterEvents.OPEN_CHART_DATA_EDITOR]: void;
|
||||
}
|
||||
|
||||
const emitter: Emitter<Events> = mitt<Events>()
|
||||
|
@ -99,10 +99,11 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, ref, watch } from 'vue'
|
||||
import { computed, defineComponent, onUnmounted, ref, watch } from 'vue'
|
||||
import { IBarChartOptions, ILineChartOptions, IPieChartOptions } from 'chartist'
|
||||
import { MutationTypes, useStore } from '@/store'
|
||||
import { ChartData, PPTChartElement } from '@/types/slides'
|
||||
import emitter, { EmitterEvents } from '@/utils/emitter'
|
||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||
|
||||
import ElementOutline from '../../common/ElementOutline.vue'
|
||||
@ -197,6 +198,13 @@ export default defineComponent({
|
||||
addHistorySnapshot()
|
||||
}
|
||||
|
||||
const openDataEditor = () => chartDataEditorVisible.value = true
|
||||
|
||||
emitter.on(EmitterEvents.OPEN_CHART_DATA_EDITOR, openDataEditor)
|
||||
onUnmounted(() => {
|
||||
emitter.off(EmitterEvents.OPEN_CHART_DATA_EDITOR, openDataEditor)
|
||||
})
|
||||
|
||||
return {
|
||||
chartDataEditorVisible,
|
||||
handleElement,
|
||||
|
@ -15,6 +15,7 @@
|
||||
}"
|
||||
v-contextmenu="contextmenus"
|
||||
@mousedown="$event => handleSelectElement($event)"
|
||||
@dblclick="openDataEditor()"
|
||||
>
|
||||
<ElementOutline
|
||||
:width="elementInfo.width"
|
||||
@ -38,6 +39,7 @@
|
||||
import { defineComponent, PropType } from 'vue'
|
||||
import { PPTChartElement } from '@/types/slides'
|
||||
import { ContextmenuItem } from '@/components/Contextmenu/types'
|
||||
import emitter, { EmitterEvents } from '@/utils/emitter'
|
||||
|
||||
import ElementOutline from '@/views/components/element/ElementOutline.vue'
|
||||
import Chart from './Chart.vue'
|
||||
@ -69,8 +71,13 @@ export default defineComponent({
|
||||
props.selectElement(e, props.elementInfo)
|
||||
}
|
||||
|
||||
const openDataEditor = () => {
|
||||
emitter.emit(EmitterEvents.OPEN_CHART_DATA_EDITOR)
|
||||
}
|
||||
|
||||
return {
|
||||
handleSelectElement,
|
||||
openDataEditor,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user