Spaces:
Running
Running
which i press enter it should also directly give an option to start typing in the next block currently again i am needing to click on the new block to typee
Browse files
script.js
CHANGED
|
@@ -229,13 +229,24 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 229 |
setTimeout(() => {
|
| 230 |
const newBlockElement = document.querySelector(`[data-block-id="${newBlock.id}"]`);
|
| 231 |
if (newBlockElement) {
|
| 232 |
-
newBlockElement.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
}
|
| 234 |
}, 0);
|
| 235 |
}
|
| 236 |
}
|
| 237 |
// Delete block
|
| 238 |
-
|
| 239 |
const blockId = parseInt(target.getAttribute('data-block-id'));
|
| 240 |
const entryId = parseInt(target.closest('.editor-container').getAttribute('data-id'));
|
| 241 |
const entry = entries.find(e => e.id === entryId);
|
|
|
|
| 229 |
setTimeout(() => {
|
| 230 |
const newBlockElement = document.querySelector(`[data-block-id="${newBlock.id}"]`);
|
| 231 |
if (newBlockElement) {
|
| 232 |
+
const editableElement = newBlockElement.querySelector('[contenteditable]');
|
| 233 |
+
if (editableElement) {
|
| 234 |
+
editableElement.focus();
|
| 235 |
+
|
| 236 |
+
// Place cursor at the beginning
|
| 237 |
+
const range = document.createRange();
|
| 238 |
+
const sel = window.getSelection();
|
| 239 |
+
range.selectNodeContents(editableElement);
|
| 240 |
+
range.collapse(true);
|
| 241 |
+
sel.removeAllRanges();
|
| 242 |
+
sel.addRange(range);
|
| 243 |
+
}
|
| 244 |
}
|
| 245 |
}, 0);
|
| 246 |
}
|
| 247 |
}
|
| 248 |
// Delete block
|
| 249 |
+
function deleteBlock(target) {
|
| 250 |
const blockId = parseInt(target.getAttribute('data-block-id'));
|
| 251 |
const entryId = parseInt(target.closest('.editor-container').getAttribute('data-id'));
|
| 252 |
const entry = entries.find(e => e.id === entryId);
|