* Set selected state * We don't need to mark Block as Selected when it is empty * * @param {boolean} state - 'true' to select, 'false' to remove selection
(state: boolean)
| 433 | * @param {boolean} state - 'true' to select, 'false' to remove selection |
| 434 | */ |
| 435 | public set selected(state: boolean) { |
| 436 | this.holder.classList.toggle(Block.CSS.selected, state); |
| 437 | |
| 438 | const fakeCursorWillBeAdded = state === true && SelectionUtils.isRangeInsideContainer(this.holder); |
| 439 | const fakeCursorWillBeRemoved = state === false && SelectionUtils.isFakeCursorInsideContainer(this.holder); |
| 440 | |
| 441 | if (fakeCursorWillBeAdded || fakeCursorWillBeRemoved) { |
| 442 | this.editorEventBus?.emit(FakeCursorAboutToBeToggled, { state }); // mutex |
| 443 | |
| 444 | if (fakeCursorWillBeAdded) { |
| 445 | SelectionUtils.addFakeCursor(); |
| 446 | } else { |
| 447 | SelectionUtils.removeFakeCursor(this.holder); |
| 448 | } |
| 449 | |
| 450 | this.editorEventBus?.emit(FakeCursorHaveBeenSet, { state }); |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Returns True if it is Selected |
nothing calls this directly
no test coverage detected