* 选中
(id: string)
| 27 | * 选中 |
| 28 | */ |
| 29 | select(id: string) { |
| 30 | if (this._selected.length === 1 && this._selected.indexOf(id) > -1) { |
| 31 | // avoid cause reaction |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | const node = this.doc.getNode(id); |
| 36 | |
| 37 | if (!node?.canSelect()) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | this._selected = [id]; |
| 42 | this.emitter.emit('selectionchange', this._selected); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * 批量选中 |