mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
feat: add returns to insertElement methods
This commit is contained in:
parent
ebfb4810fc
commit
ef7e9dd2f1
2 changed files with 9 additions and 3 deletions
|
|
@ -222,8 +222,9 @@ class Core {
|
|||
insertElementBefore(elem: TypeElementBase<keyof TypeElemDesc>, beforeUUID: string) {
|
||||
const index = this[_helper].getElementIndexByUUID(beforeUUID);
|
||||
if (index !== null) {
|
||||
this.insertElementBeforeIndex(elem, index);
|
||||
return this.insertElementBeforeIndex(elem, index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
insertElementBeforeIndex(elem: TypeElementBase<keyof TypeElemDesc>, index: number) {
|
||||
|
|
@ -233,7 +234,9 @@ class Core {
|
|||
this[_data].elements.splice(index, 0, _elem);
|
||||
this[_emitChangeData]();
|
||||
this[_draw]();
|
||||
return _elem.uuid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getSelectedElements() {
|
||||
|
|
@ -243,8 +246,9 @@ class Core {
|
|||
insertElementAfter(elem: TypeElementBase<keyof TypeElemDesc>, beforeUUID: string) {
|
||||
const index = this[_helper].getElementIndexByUUID(beforeUUID);
|
||||
if (index !== null) {
|
||||
this.insertElementAfterIndex(elem, index);
|
||||
return this.insertElementAfterIndex(elem, index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
insertElementAfterIndex(elem: TypeElementBase<keyof TypeElemDesc>, index: number) {
|
||||
|
|
@ -254,7 +258,9 @@ class Core {
|
|||
this[_data].elements.splice(index + 1, 0, _elem);
|
||||
this[_emitChangeData]();
|
||||
this[_draw]();
|
||||
return _elem.uuid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
clearOperation() {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export function getSelectedElements(core: Core): TypeElement<keyof TypeElemDesc>
|
|||
if (elem) elems.push(elem);
|
||||
}
|
||||
});
|
||||
return elems;
|
||||
return deepClone(elems);
|
||||
}
|
||||
|
||||
export function updateElement(core: Core, elem: TypeElement<keyof TypeElemDesc>) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue