Skip to content

Commit

Permalink
feat: non-editable element drag conveniently (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
devlzl authored Jan 31, 2024
1 parent a1235d9 commit e7de791
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/BlockHub/PictureBlock/Picture.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ block.props.events.update.on(({ key, to }) => {

<template>
<div class="picture">
<img :src="props.url" :style="{ width: '100%', height: '100%' }" />
<img :src="props.url" :style="{ width: '100%', height: '100%' }" @dragstart.prevent />
</div>
</template>
5 changes: 5 additions & 0 deletions src/UserInterface/Slide/components/SelectableBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ const showSelectHandle = computed(() => {
selectionManager.events.update.on(() => {
selected.value = selectionManager.isSelected(block)
})
const editable = computed(() => {
return ['TextBox', 'Table'].includes(block.type)
})
</script>

<template>
<div
class="selectable-block absolute"
:class="{ 'move-handle': !editable }"
:data-block-id="block.id"
:style="{
left: `${props.x}px`,
Expand Down
3 changes: 2 additions & 1 deletion src/UserInterface/ToolBar/components/Insert/Picture.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Pic } from '@icon-park/vue-next'
import ButtonGroup from '../ButtonGroup.vue'
import { pickFile } from '@Utils/pickFile'
import { PictureBlock } from '@BlockHub/PictureBlock/PictureBlock'
import { slideManager } from '@Kernel/index'
import { selectionManager, slideManager } from '@Kernel/index'
import ToolButton from '../ToolButton.vue'
async function insertPicture() {
Expand All @@ -13,6 +13,7 @@ async function insertPicture() {
block.url = URL.createObjectURL(file)
}
slideManager.currentSlide.addBlock(block)
selectionManager.focus(block)
}
</script>

Expand Down

0 comments on commit e7de791

Please sign in to comment.