fix sync set caret

This commit is contained in:
Peter Savchenko 2024-03-04 23:25:39 +03:00
parent 75bc38069f
commit 0c3c988048
No known key found for this signature in database
GPG key ID: E68306B1AB0F727C
2 changed files with 7 additions and 13 deletions

View file

@ -557,12 +557,9 @@ export default class UI extends Module<UINodes> {
private enterPressed(event: KeyboardEvent): void {
const { BlockManager, BlockSelection } = this.Editor;
console.log('this.someToolbarOpened', this.someToolbarOpened);
// if (this.someToolbarOpened) {
// return;
// }
if (this.someToolbarOpened) {
return;
}
const hasPointerToBlock = BlockManager.currentBlockIndex >= 0;
@ -586,11 +583,6 @@ export default class UI extends Module<UINodes> {
return;
}
console.log('event.target', event.target, (event.target as HTMLElement).tagName);
console.log('hasPointerToBlock', hasPointerToBlock);
/**
* If Caret is not set anywhere, event target on Enter is always Element that we handle
* In our case it is document.body
@ -604,6 +596,10 @@ export default class UI extends Module<UINodes> {
*/
const newBlock = this.Editor.BlockManager.insert();
/**
* Prevent default enter behaviour to prevent adding a new line (<div><br></div>) to the inserted block
*/
event.preventDefault();
this.Editor.Caret.setToBlock(newBlock);
/**

View file

@ -2,8 +2,6 @@
"compilerOptions" : {
"sourceMap": true,
"target": "es2017",
"module": "esnext",
"strict": true,
"declaration": false,
"moduleResolution": "node", // This resolution strategy attempts to mimic the Node.js module resolution mechanism at runtime
"lib": ["dom", "es2017", "es2018", "es2019"],