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 {
|
export const enum EmitterEvents {
|
||||||
RICH_TEXT_COMMAND = 'RICH_TEXT_COMMAND',
|
RICH_TEXT_COMMAND = 'RICH_TEXT_COMMAND',
|
||||||
|
OPEN_CHART_DATA_EDITOR = 'OPEN_CHART_DATA_EDITOR',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RichTextCommand {
|
export interface RichTextCommand {
|
||||||
@ -11,6 +12,7 @@ export interface RichTextCommand {
|
|||||||
|
|
||||||
type Events = {
|
type Events = {
|
||||||
[EmitterEvents.RICH_TEXT_COMMAND]: RichTextCommand | RichTextCommand[];
|
[EmitterEvents.RICH_TEXT_COMMAND]: RichTextCommand | RichTextCommand[];
|
||||||
|
[EmitterEvents.OPEN_CHART_DATA_EDITOR]: void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emitter: Emitter<Events> = mitt<Events>()
|
const emitter: Emitter<Events> = mitt<Events>()
|
||||||
|
@ -99,10 +99,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<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 { IBarChartOptions, ILineChartOptions, IPieChartOptions } from 'chartist'
|
||||||
import { MutationTypes, useStore } from '@/store'
|
import { MutationTypes, useStore } from '@/store'
|
||||||
import { ChartData, PPTChartElement } from '@/types/slides'
|
import { ChartData, PPTChartElement } from '@/types/slides'
|
||||||
|
import emitter, { EmitterEvents } from '@/utils/emitter'
|
||||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||||
|
|
||||||
import ElementOutline from '../../common/ElementOutline.vue'
|
import ElementOutline from '../../common/ElementOutline.vue'
|
||||||
@ -197,6 +198,13 @@ export default defineComponent({
|
|||||||
addHistorySnapshot()
|
addHistorySnapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openDataEditor = () => chartDataEditorVisible.value = true
|
||||||
|
|
||||||
|
emitter.on(EmitterEvents.OPEN_CHART_DATA_EDITOR, openDataEditor)
|
||||||
|
onUnmounted(() => {
|
||||||
|
emitter.off(EmitterEvents.OPEN_CHART_DATA_EDITOR, openDataEditor)
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
chartDataEditorVisible,
|
chartDataEditorVisible,
|
||||||
handleElement,
|
handleElement,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
}"
|
}"
|
||||||
v-contextmenu="contextmenus"
|
v-contextmenu="contextmenus"
|
||||||
@mousedown="$event => handleSelectElement($event)"
|
@mousedown="$event => handleSelectElement($event)"
|
||||||
|
@dblclick="openDataEditor()"
|
||||||
>
|
>
|
||||||
<ElementOutline
|
<ElementOutline
|
||||||
:width="elementInfo.width"
|
:width="elementInfo.width"
|
||||||
@ -38,6 +39,7 @@
|
|||||||
import { defineComponent, PropType } from 'vue'
|
import { defineComponent, PropType } from 'vue'
|
||||||
import { PPTChartElement } from '@/types/slides'
|
import { PPTChartElement } from '@/types/slides'
|
||||||
import { ContextmenuItem } from '@/components/Contextmenu/types'
|
import { ContextmenuItem } from '@/components/Contextmenu/types'
|
||||||
|
import emitter, { EmitterEvents } from '@/utils/emitter'
|
||||||
|
|
||||||
import ElementOutline from '@/views/components/element/ElementOutline.vue'
|
import ElementOutline from '@/views/components/element/ElementOutline.vue'
|
||||||
import Chart from './Chart.vue'
|
import Chart from './Chart.vue'
|
||||||
@ -69,8 +71,13 @@ export default defineComponent({
|
|||||||
props.selectElement(e, props.elementInfo)
|
props.selectElement(e, props.elementInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openDataEditor = () => {
|
||||||
|
emitter.emit(EmitterEvents.OPEN_CHART_DATA_EDITOR)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleSelectElement,
|
handleSelectElement,
|
||||||
|
openDataEditor,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user