fix(仪表板、数据大屏): 修复富文本表格定位拖拽点显示位置有偏移问题

This commit is contained in:
wangjiahao 2024-10-28 22:18:52 +08:00
parent 41e1bfcc9b
commit 78339557e9

View File

@ -191,7 +191,6 @@ const init = ref({
originalHandle.style.display = 'none' //
//
const parentDiv = originalHandle.parentNode //
cloneHandle.style.width = `${parentDiv.offsetWidth}px`
parentDiv.appendChild(cloneHandle) //
}
})
@ -219,25 +218,55 @@ const init = ref({
//
originalHandle.style.display = ''
if (cloneHandle) {
originalHandle.parentNode.removeChild(cloneHandle) //
cloneHandle.parentNode.removeChild(cloneHandle) //
}
cloneHandle = null
originalHandle = null
}
})
})
//
// cornerresize
editor.on('ObjectResized', function (e) {
const { target, width, height, origin } = e
if (target.nodeName === 'TABLE' && origin.indexOf('corner') > -1) {
//
target.style.width = `${width}px`
target.style.height = `${height}px`
} else if (target.nodeName === 'TABLE' && origin.indexOf('bar-col') > -1) {
// do nothing
// .mce-resizehandle
const adjustResizeHandles = (aLeft, aTop) => {
nextTick(() => {
const nodeRt = doc.getElementById('mceResizeHandlene')
const nodeRb = doc.getElementById('mceResizeHandlese')
const nodeLb = doc.getElementById('mceResizeHandlesw')
if (nodeRt) {
nodeRt.style.left = `${aLeft}px`
}
if (nodeRb) {
nodeRb.style.left = `${aLeft}px`
nodeRb.style.top = `${aTop}px`
}
if (nodeLb) {
nodeLb.style.top = `${aTop}px`
}
})
}
// ObjectSelected
editor.on('ObjectSelected', event => {
if (event.target.nodeName === 'TABLE') {
adjustResizeHandles(
event.target.offsetWidth + event.target.offsetLeft,
event.target.offsetHeight + event.target.offsetTop
)
}
})
// ObjectResized
//
// cornerresize
editor.on('ObjectResized', function (e) {
const { target, width, height, origin } = e
if (target.nodeName === 'TABLE' && origin.indexOf('corner') > -1) {
//
target.style.width = `${width}px`
target.style.height = `${height}px`
} else if (target.nodeName === 'TABLE' && origin.indexOf('bar-col') > -1) {
// do nothing
}
})
})
}
})