Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/canvas/container/src/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,18 @@ const handleClipboardPaste = (event) => {
const handleCopyEvent = (event) => {
const selectedNodes = multiSelectedStates.value.map(({ schema }) => copyObject(schema))

const dataToCopy = JSON.stringify(selectedNodes)
setClipboardSchema(event, dataToCopy)
// 如果没有选中任何节点,直接返回
if (!selectedNodes.length) {
return
}

// 验证所有选中的节点是否有效(不为空)
const isValidNodes = selectedNodes.every((node) => node && Object.keys(node).length > 0)

if (isValidNodes) {
const dataToCopy = JSON.stringify(selectedNodes)
setClipboardSchema(event, dataToCopy)
}
}

const eventFiltersMap = new WeakMap()
Expand Down
150 changes: 110 additions & 40 deletions packages/common/component/PluginPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,23 @@ export default {

const MIN_WIDTH = PLUGIN_DEFAULT_WIDTH // 固定的最小宽度值
const MAX_WIDTH = 1000 // 固定的最大宽度值
const panel = ref(null)
const panel = ref<HTMLElement | null>(null)
let startX = 0
let startWidth = 0
let rafId: number | null = null // 添加 requestAnimationFrame 标识

const isCollapsed = ref(false)
const settingIcon = computed(() => (isCollapsed.value ? 'collapse_all' : 'expand_all'))

provide('isCollapsed', isCollapsed)

const panelState = inject('panelState')
interface PanelState {
emitEvent: (event: string, ...args: any[]) => void
}

const panelState = inject<PanelState>('panelState')
const fixPanel = () => {
panelState.emitEvent('fixPanel', props.fixedName)
panelState?.emitEvent('fixPanel', props.fixedName)
}

const headerBottomLine = computed(() => (props.showBottomBorder ? 'header-bottom-line' : ''))
Expand All @@ -146,65 +151,101 @@ export default {
const isRightResizer = ref(align.value.includes('right'))
const isWidthResizable = computed(() => isPanelWidthResizable(props.fixedName))

const onMouseMoveRight = (event) => {
const updateWidth = (newWidth: number) => {
if (rafId) {
cancelAnimationFrame(rafId)
}

rafId = requestAnimationFrame(() => {
panelWidth.value = Math.max(MIN_WIDTH, Math.min(newWidth, MAX_WIDTH))
changePluginWidth(props.fixedName, panelWidth.value)
})
}

const onMouseMoveRight = (event: MouseEvent) => {
const newWidth = startWidth + (event.clientX - startX)
panelWidth.value = Math.max(MIN_WIDTH, Math.min(newWidth, MAX_WIDTH))
changePluginWidth(props.fixedName, panelWidth.value)
updateWidth(newWidth)
}

const onMouseMoveLeft = (event) => {
const onMouseMoveLeft = (event: MouseEvent) => {
const newWidth = startWidth - (event.clientX - startX)
panelWidth.value = Math.max(MIN_WIDTH, Math.min(newWidth, MAX_WIDTH))
changePluginWidth(props.fixedName, panelWidth.value)
updateWidth(newWidth)
}

const throttledMouseMoveRight = useThrottleFn(onMouseMoveRight, 50)
const throttledMouseMoveLeft = useThrottleFn(onMouseMoveLeft, 50)
// 降低节流时间,提高响应速度
const throttledMouseMoveRight = useThrottleFn(onMouseMoveRight, 16)
const throttledMouseMoveLeft = useThrottleFn(onMouseMoveLeft, 16)

type ResizerElement = HTMLElement | null

const leftResizer = ref(null)
const rightResizer = ref(null)
const leftResizer = ref<ResizerElement>(null)
const rightResizer = ref<ResizerElement>(null)

const onMouseUpRight = () => {
changeMoveDragBarState(false)
document.removeEventListener('mousemove', throttledMouseMoveRight)
document.removeEventListener('mouseup', onMouseUpRight)
rightResizer.value.style.cursor = ''
rightResizer.value.classList.remove('dragging')
document.body.style.cursor = ''
if (rightResizer.value) {
rightResizer.value.classList.remove('dragging')
}

// 清理 requestAnimationFrame
if (rafId) {
cancelAnimationFrame(rafId)
rafId = null
}
}

const onMouseDownRight = (event) => {
const onMouseDownRight = (event: MouseEvent) => {
changeMoveDragBarState(true)
startX = event.clientX
startWidth = panel.value.offsetWidth
startWidth = panel.value?.offsetWidth || 0
document.addEventListener('mousemove', throttledMouseMoveRight)
document.addEventListener('mouseup', onMouseUpRight)
rightResizer.value.style.cursor = 'ew-resize'
rightResizer.value.classList.add('dragging')
document.body.style.cursor = 'col-resize'
if (rightResizer.value) {
rightResizer.value.classList.add('dragging')
}
}

const onMouseUpLeft = () => {
changeMoveDragBarState(false)
document.removeEventListener('mousemove', throttledMouseMoveLeft)
document.removeEventListener('mouseup', onMouseUpLeft)
leftResizer.value.style.cursor = ''
leftResizer.value.classList.remove('dragging')
document.body.style.cursor = ''
if (leftResizer.value) {
leftResizer.value.classList.remove('dragging')
}

if (rafId) {
cancelAnimationFrame(rafId)
rafId = null
}
}

const onMouseDownLeft = (event) => {
const onMouseDownLeft = (event: MouseEvent) => {
changeMoveDragBarState(true)
startX = event.clientX
startWidth = panel.value.offsetWidth
startWidth = panel.value?.offsetWidth || 0
document.addEventListener('mousemove', throttledMouseMoveLeft)
document.addEventListener('mouseup', onMouseUpLeft)
leftResizer.value.style.cursor = 'ew-resize'
leftResizer.value.classList.add('dragging')
document.body.style.cursor = 'col-resize'
if (leftResizer.value) {
leftResizer.value.classList.add('dragging')
}
}

const initResizerDOM = () => {
leftResizer.value = document.querySelector('.resizer-left')
rightResizer.value = document.querySelector('.resizer-right')
const leftEl = document.querySelector('.resizer-left')
const rightEl = document.querySelector('.resizer-right')
if (leftEl instanceof HTMLElement) {
leftResizer.value = leftEl
}
if (rightEl instanceof HTMLElement) {
rightResizer.value = rightEl
}
}

const clickCollapseIcon = () => {
isCollapsed.value = !isCollapsed.value
emit('updateCollapseStatus', isCollapsed.value)
Expand Down Expand Up @@ -289,42 +330,71 @@ export default {
position: absolute;
top: 0;
right: 0;
width: 1px;
width: 3px;
height: 100%;
cursor: ew-resize;
background-color: rgba(0, 0, 0, 0.1);
transition: width 0.3s ease;
cursor: col-resize;
background-color: transparent;
transition: background-color 0.3s ease;

&::after {
content: '';
position: absolute;
left: 3px;
width: 1px;
height: 100%;
background-color: rgba(0, 0, 0, 0.1);
transition: width 0.3s ease, background-color 0.3s ease;
}
}

.header-bottom-line {
border-bottom: 1px solid var(--te-common-border-divider);
}

.dragging {
width: 2px !important;
background-color: var(--te-component-common-resizer-border-color) !important;
background-color: var(--te-component-common-resizer-border-color);

&::after {
width: 2px !important;
}
}

.resizer-right:hover {
width: 2px;
background-color: var(--te-component-common-resizer-border-color);

&::after {
width: 2px;
}
}

// 左边拖拽线
.resizer-left {
position: absolute;
top: 0;
left: 0;
width: 1px;
width: 3px;
height: 100%;
cursor: ew-resize;
background-color: rgba(0, 0, 0, 0.1);
transition: width 0.3s ease;
cursor: col-resize;
background-color: transparent;
transition: background-color 0.3s ease;

&::after {
content: '';
position: absolute;
right: 3px;
width: 1px;
height: 100%;
background-color: rgba(0, 0, 0, 0.1);
transition: width 0.3s ease, background-color 0.3s ease;
}
}

.resizer-left:hover {
width: 2px;
background-color: var(--te-component-common-resizer-border-color);

&::after {
width: 2px;
}
}

.scroll-content {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/i18n/src/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
:tooltip-config="{ appendToBody: false, placement: 'right' }"
:edit-rules="validRules"
>
<tiny-grid-column type="selection" width="44"></tiny-grid-column>
<tiny-grid-column type="selection" width="42"></tiny-grid-column>
<tiny-grid-column
width="120"
field="key"
Expand Down
13 changes: 12 additions & 1 deletion packages/settings/styles/src/components/spacing/SpacingGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
</template>

<script>
import { computed, reactive } from 'vue'
import { computed, reactive, watch } from 'vue'
import SpacingSetting from './SpacingSetting.vue'
import ModalMask, { useModal } from '../inputs/ModalMask.vue'
import useEvent from '../../js/useEvent'
Expand Down Expand Up @@ -481,6 +481,17 @@ export default {
emit('update', property)
}

watch(
() => props.style,
(newStyle) => {
if (state.showModal) {
// 弹窗打开时,更新当前编辑的属性值
state.property.value = newStyle[state.property.name]
}
},
{ deep: true }
)

return {
state,
spacing,
Expand Down