MCPcopy
hub / github.com/codex-team/editor.js / selected

Method selected

src/components/block/index.ts:435–452  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

addFakeCursorMethod · 0.80
removeFakeCursorMethod · 0.80
emitMethod · 0.65
toggleMethod · 0.45

Tested by

no test coverage detected