Skip to content

Commit

Permalink
feat: remove block (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
devlzl authored Jan 13, 2024
1 parent 9835419 commit 7f7e48f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Kernel/Slide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ export class Slide {
this._blocks.push(block)
this.events.blockChange.emit()
}

removeBlock(block: Block) {
this._blocks.splice(this._blocks.indexOf(block), 1)
this.events.blockChange.emit()
}
}
16 changes: 15 additions & 1 deletion src/UserInterface/ToolBar/components/Home/Delete.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
<script setup lang="ts">
import { Close } from '@icon-park/vue-next'
import MenuWrapper from '../MenuWrapper.vue'
import { selectionManager, slideManager } from '@Kernel/index'
import { shallowRef } from 'vue'
const selectedBlocks = shallowRef(selectionManager.selectedBlocks)
selectionManager.events.update.on(() => {
selectedBlocks.value = selectionManager.selectedBlocks
})
const removeBlock = () => {
const slide = slideManager.currentSlide
selectedBlocks.value.forEach((block) => {
slide.removeBlock(block)
selectionManager.remove(block)
})
}
</script>

<template>
<MenuWrapper :name="$t('ToolBar.home.delete')">
<button class="menu-btn flex flex-col items-center">
<button class="menu-btn flex flex-col items-center" @click="removeBlock">
<close theme="outline" size="32" fill="#ED3D3B" :strokeWidth="2" />
<span class="text-xs mt-1">{{ $t('ToolBar.home.delete') }}</span>
</button>
Expand Down

0 comments on commit 7f7e48f

Please sign in to comment.