diff --git a/src/configs/imageClip.ts b/src/configs/imageClip.ts index 893d614..013196c 100644 --- a/src/configs/imageClip.ts +++ b/src/configs/imageClip.ts @@ -56,12 +56,4 @@ export const CLIPPATHS = { return `M ${width / 2} 0 L ${width} ${height / 2} L ${width / 2} ${height} L 0 ${height / 2} Z` }, }, - star: { - name: '五角星', - type: ClipPathTypes.POLYGON, - style: 'polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%)', - createPath: (width: number, height: number) => { - return `M ${width / 2} 0 L ${0.61 * width} ${0.35 * height} L ${0.98 * width} ${0.35 * height} L ${0.68 * width} ${0.57 * height} L ${0.79 * width} ${0.91 * height} L ${0.50 * width} ${0.70 * height} L ${0.21 * width} ${0.91 * height} L ${0.32 * width} ${0.57 * height} L ${0.02 * width} ${0.35 * height} L ${0.39 * width} ${0.35 * height} Z` - }, - }, } \ No newline at end of file diff --git a/src/plugins/clickOutside.ts b/src/plugins/clickOutside.ts index ba74950..b74511f 100644 --- a/src/plugins/clickOutside.ts +++ b/src/plugins/clickOutside.ts @@ -15,7 +15,9 @@ const clickListener = (el: HTMLElement, event: MouseEvent, binding: DirectiveBin const ClickOutsideDirective: Directive = { mounted(el: HTMLElement, binding) { el[CTX_CLICK_OUTSIDE_HANDLER] = (event: MouseEvent) => clickListener(el, event, binding) - document.addEventListener('click', el[CTX_CLICK_OUTSIDE_HANDLER]) + setTimeout(() => { + document.addEventListener('click', el[CTX_CLICK_OUTSIDE_HANDLER]) + }, 0) }, unmounted(el: HTMLElement) { diff --git a/src/store/constants.ts b/src/store/constants.ts index 793b701..d750a7e 100644 --- a/src/store/constants.ts +++ b/src/store/constants.ts @@ -22,6 +22,7 @@ export enum MutationTypes { UPDATE_SLIDE_INDEX = 'updateSlideIndex', ADD_ELEMENT = 'addElement', UPDATE_ELEMENT = 'updateElement', + REMOVE_ELEMENT_PROP = 'removeElementProp', // snapshot SET_SNAPSHOT_CURSOR = 'setSnapshotCursor', diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 29e5ed1..daafee1 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -6,6 +6,11 @@ import { CreatingElement } from '@/types/edit' import { FONT_NAMES } from '@/configs/fontName' import { isSupportFontFamily } from '@/utils/fontFamily' +interface RemoveElementPropData { + id: string; + propName: string; +} + interface UpdateElementData { id: string | string[]; props: Partial; @@ -115,6 +120,18 @@ export const mutations: MutationTree = { state.slides[slideIndex].elements = (elements as PPTElement[]) }, + [MutationTypes.REMOVE_ELEMENT_PROP](state, data: RemoveElementPropData) { + const { id, propName } = data + + const slideIndex = state.slideIndex + const slide = state.slides[slideIndex] + const elements = slide.elements.map(el => { + if(el.id === id) delete el[propName] + return el + }) + state.slides[slideIndex].elements = (elements as PPTElement[]) + }, + // snapshot [MutationTypes.SET_SNAPSHOT_CURSOR](state, cursor: number) { diff --git a/src/views/Editor/Toolbar/ElementStylePanel/ImageStylePanel.vue b/src/views/Editor/Toolbar/ElementStylePanel/ImageStylePanel.vue index a491ea2..e369131 100644 --- a/src/views/Editor/Toolbar/ElementStylePanel/ImageStylePanel.vue +++ b/src/views/Editor/Toolbar/ElementStylePanel/ImageStylePanel.vue @@ -5,7 +5,38 @@ :style="{ backgroundImage: `url(${handleElement.src})` }" > - + + + +