diff --git a/src/Group.js b/src/Group.js index e108c98..791fa6c 100644 --- a/src/Group.js +++ b/src/Group.js @@ -88,6 +88,19 @@ export default class Group { this.app.emitChange() } + // 给指定元素编组 + screenDogroup(elements = []){ + if(elements.length < 1) return + let groupId = uuidv4() + let groupElement = elements + this.groupIdToElementList[groupId] = groupElement + groupElement.forEach(element => { + element.setGroupId(groupId) + }) + this.app.render.render() + this.app.emitChange() + } + // 取消编组 ungroup() { if ( diff --git a/src/index.js b/src/index.js index 0367594..a4e5290 100644 --- a/src/index.js +++ b/src/index.js @@ -187,7 +187,7 @@ class TinyWhiteboard extends EventEmitter { this[method] = this.selection[method].bind(this.selection) }) // 编组类 - ;['dogroup', 'ungroup'].forEach(method => { + ;['dogroup', 'ungroup', 'screenDogroup'].forEach(method => { this[method] = this.group[method].bind(this.group) }) // 网格类