From 23cd12c46bfd5b97dc7f11a5d8df442925e84e07 Mon Sep 17 00:00:00 2001 From: lyc Date: Fri, 5 Jul 2024 15:38:50 +0800 Subject: [PATCH] edit --- src/Group.js | 13 +++++++++++++ src/index.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) 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) }) // 网格类