codex-team / codex-team/editor.js
Does not focus block when using insert()
- Vorherrschende Sprache
- TypeScript
- Sterne
- 32k
- Forks
- 2.2k
- Ø Merge
- 1 T. 13 Std.
- Gemergte PRs (30 T.)
- 2
Beschreibung
Hi there, thanks so much for your work on this!
I'm using `insert()` to add a new block when a user clicks a button:
```js
insert(blockType) {
// need to be explicit with index, otherwise editor.js adds block at the beginning...
const index = editor.blocks.getBlocksCount() + 1
editor.blocks.insert(blockType, {}, {}, index, true)
}
```
```vue
- Title
- Text
```
Even though I set the last param (`needToFocus`) to `true`, it doesn't focus the newly inserted block.
Of course, you can use the Caret API to focus the last inserted block like so:
```js
editor.caret.setToLastBlock('start', 0)
```
... but then what is the `needToFocus` param for in the `insert()` method? :)
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginnen Sie mit dem Einstiegspunkt der Blocks API für insert() und verfolgen Sie, wie dessen needToFocus-Argument behandelt wird. Vergleichen Sie dies anschließend mit dem im Bericht gezeigten Aufruf der Caret API. Reproduzieren Sie das Verhalten anhand des Vue-Klickbeispiels und überprüfen Sie, dass das Einfügen eines Blocks mit auf true gesetztem needToFocus den neuen Block wie dokumentiert fokussiert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100