mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(editor): 当组件设置的bottom/right是,上下左右快捷键失效
This commit is contained in:
parent
2ccf47f7dd
commit
cda3b04b85
@ -651,9 +651,11 @@ class Editor extends BaseService {
|
|||||||
const parentEl = layout === Layout.FIXED ? doc.body : el?.offsetParent;
|
const parentEl = layout === Layout.FIXED ? doc.body : el?.offsetParent;
|
||||||
if (parentEl && el) {
|
if (parentEl && el) {
|
||||||
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
||||||
|
node.style.right = '';
|
||||||
}
|
}
|
||||||
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
||||||
node.style.left = (parent.style.width - node.style.width) / 2;
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
||||||
|
node.style.right = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
@ -792,20 +794,46 @@ class Editor extends BaseService {
|
|||||||
if (!node || isPage(node)) return;
|
if (!node || isPage(node)) return;
|
||||||
|
|
||||||
const { style, id, type } = node;
|
const { style, id, type } = node;
|
||||||
if (!style || style.position !== 'absolute') return;
|
if (!style || !['absolute', 'fixed'].includes(style.position)) return;
|
||||||
|
|
||||||
if (top && !isNumber(style.top)) return;
|
const update = (style: { [key: string]: any }) =>
|
||||||
if (left && !isNumber(style.left)) return;
|
this.update({
|
||||||
|
id,
|
||||||
|
type,
|
||||||
|
style,
|
||||||
|
});
|
||||||
|
|
||||||
this.update({
|
if (top) {
|
||||||
id,
|
if (isNumber(style.top)) {
|
||||||
type,
|
update({
|
||||||
style: {
|
...style,
|
||||||
...style,
|
top: Number(style.top) + Number(top),
|
||||||
left: Number(style.left) + left,
|
bottom: '',
|
||||||
top: Number(style.top) + top,
|
});
|
||||||
},
|
} else if (isNumber(style.bottom)) {
|
||||||
});
|
update({
|
||||||
|
...style,
|
||||||
|
bottom: Number(style.bottom) - Number(top),
|
||||||
|
top: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (left) {
|
||||||
|
if (isNumber(style.left)) {
|
||||||
|
update({
|
||||||
|
...style,
|
||||||
|
left: Number(style.left) + Number(left),
|
||||||
|
right: '',
|
||||||
|
});
|
||||||
|
} else if (isNumber(style.right)) {
|
||||||
|
update({
|
||||||
|
...style,
|
||||||
|
right: Number(style.right) - Number(left),
|
||||||
|
left: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public resetState() {
|
public resetState() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user