editor-js / editor-js/document-model

(block-tool-adapter): optimise model listeners count

Open
#72 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
TypeScript
Stars
12
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Right now each call of the `attachInput()` lead adding the new event listener to the model. Then, handler will filter-our other inputs.

```ts
public attachInput(key: DataKey, input: HTMLElement): void {

// ...

this.#model.addEventListener(EventType.Changed, (event: ModelEvents) => this.#handleModelUpdate(event, input, key, caretAdapter));
}
```

We know that Tool can have many inputs (e.g. Table or Nested List). So it would be better to add a single event listener in the adapter's constructor. And then, find and handle events related to attached inputs.

Probably, we will need to store inputs in a private property.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.