fix: 🐛 移动快捷键

This commit is contained in:
林熠 2020-05-09 17:35:17 +08:00
parent 9c8afe8203
commit 7c8a27cef9

View File

@ -213,47 +213,52 @@ hotkey.bind(['up', 'down'], (e, action) => {
} }
}); });
// HotKey.bind(['option+up', 'option+down', 'option+left', 'option+right'], (e, action) => { hotkey.bind(['option+up', 'option+down', 'option+left', 'option+right'], (e, action) => {
// if (Viewport.isPreview() || isFormEvent(e) || !isInEditingArea(e)) { const designer = focusing.focusDesigner;
// return; const doc = designer?.currentDocument;
// } if (isFormEvent(e) || !doc) {
return;
}
e.preventDefault();
const selected = doc.selection.getTopNodes(true);
if (!selected || selected.length < 1) {
return;
}
// TODO: 此处需要增加判断当前节点是否可被操作移动原ve里是用 node.canOperating()来判断
// e.preventDefault(); const firstNode = selected[0];
// const selected = Exchange.getSelected(); const parent = firstNode.getParent();
// if (!selected || !selected.canOperating()) return; if (!parent) return;
// const parent = selected.getParent(); const isPrev = /(up|left)$/.test(action);
// if (!parent) return; const isTravel = /(up|down)$/.test(action);
// const isPrev = /(up|left)$/.test(action); const silbing = isPrev ? firstNode.prevSibling : firstNode.nextSibling;
// const isTravel = /(up|down)$/.test(action); if (silbing) {
if (isTravel && silbing.isContainer()) {
// const silbing = isPrev ? selected.prevSibling() : selected.nextSibling(); const place = silbing.getSuitablePlace(firstNode, null);
// if (silbing) { if (isPrev) {
// if (isTravel && silbing.isContainer()) { place.container.insertAfter(firstNode, place.ref);
// const place = silbing.getSuitablePlace(selected, null, true); } else {
// if (isPrev) { place.container.insertBefore(firstNode, place.ref);
// place.container.insertAfter(selected, place.ref); }
// } else { } else if (isPrev) {
// place.container.insertBefore(selected, place.ref); parent.insertBefore(firstNode, silbing);
// } } else {
// } else if (isPrev) { parent.insertAfter(firstNode, silbing);
// parent.insertBefore(selected, silbing); }
// } else { firstNode?.select();
// parent.insertAfter(selected, silbing); return;
// } }
// Exchange.select(selected); if (isTravel) {
// return; const place = parent.getSuitablePlace(firstNode, null); // upwards
// } if (place) {
// if (isTravel) { if (isPrev) {
// const place = parent.getSuitablePlace(selected); // upwards place.container.insertBefore(firstNode, place.ref);
// if (place) { } else {
// if (isPrev) { place.container.insertAfter(firstNode, place.ref);
// place.container.insertBefore(selected, place.ref); }
// } else { firstNode?.select();
// place.container.insertAfter(selected, place.ref); }
// } }
// Exchange.select(selected); });
// }
// }
// });