<aside> ✏️

Blockly 클래스들을 이용한 Block 커스텀하기! 시리즈

  1. Blockly 클래스들을 이용한 Block 커스텀하기!(커스텀의 시작과 ConstantProvider의 발견편)
  2. Blockly 클래스들을 이용한 Block 커스텀하기!(블록 외부 그리기 편)
  3. Blockly 클래스들을 이용한 Block 커스텀하기!(필드와 좌표설정 편) </aside>

<aside> ✏️

목차

</aside>

신상짤 (12).jpg

Blockly에서 사용하는 블록들은 어떤 형식으로 렌더링 되고 있을까?

image.png

path의 d속성 바꾸기 챌린지

blockId 값을 가져와 해당 블록의 돔요소를 가져와 수정해주기

blockId 값 가져오기

export class BlockBase extends AbstractEvent {
  override isBlank = true;

  /** The ID of the block associated with this event. */
  blockId?: string;

  /**
   * @param opt_block The block this event corresponds to.
   *     Undefined for a blank event.
   */
  constructor(opt_block?: Block) {
    super();
    this.isBlank = !opt_block;

    if (!opt_block) return;

    this.blockId = opt_block.id;
    this.workspaceId = opt_block.workspace.id;
  }
newWorkspace.addChangeListener((event) => {
	if (event instanceof Blockly.Events.Click && event.blockId) {
	    console.log(event);
	}
})

image.png