@@ -208,9 +208,12 @@ export async function previousSiblingBlockCommand() {
208
208
return
209
209
210
210
const cursorPosition = ( await logseq . Editor . getEditingCursorPosition ( ) ) ?. pos
211
+ const content = await logseq . Editor . getEditingBlockContent ( )
212
+ const isPositionOnTheEnd = cursorPosition === undefined || cursorPosition === content . length
213
+
211
214
await logseq . Editor . editBlock (
212
215
prevBlock . uuid ,
213
- cursorPosition ? { pos : cursorPosition } : undefined
216
+ ! isPositionOnTheEnd ? { pos : cursorPosition } : undefined
214
217
)
215
218
}
216
219
@@ -225,9 +228,12 @@ export async function nextSiblingBlockCommand() {
225
228
return
226
229
227
230
const cursorPosition = ( await logseq . Editor . getEditingCursorPosition ( ) ) ?. pos
231
+ const content = await logseq . Editor . getEditingBlockContent ( )
232
+ const isPositionOnTheEnd = cursorPosition === undefined || cursorPosition === content . length
233
+
228
234
await logseq . Editor . editBlock (
229
235
nextBlock . uuid ,
230
- cursorPosition ? { pos : cursorPosition } : undefined
236
+ ! isPositionOnTheEnd ? { pos : cursorPosition } : undefined
231
237
)
232
238
}
233
239
@@ -264,9 +270,12 @@ export async function editPreviousBlockCommand() {
264
270
}
265
271
266
272
const cursorPosition = ( await logseq . Editor . getEditingCursorPosition ( ) ) ?. pos
273
+ const content = await logseq . Editor . getEditingBlockContent ( )
274
+ const isPositionOnTheEnd = cursorPosition === undefined || cursorPosition === content . length
275
+
267
276
await logseq . Editor . editBlock (
268
277
( prevBlock as BlockEntity ) . uuid ,
269
- cursorPosition ? { pos : cursorPosition } : undefined
278
+ ! isPositionOnTheEnd ? { pos : cursorPosition } : undefined
270
279
)
271
280
}
272
281
@@ -311,9 +320,12 @@ export async function editNextBlockCommand() {
311
320
}
312
321
313
322
const cursorPosition = ( await logseq . Editor . getEditingCursorPosition ( ) ) ?. pos
323
+ const content = await logseq . Editor . getEditingBlockContent ( )
324
+ const isPositionOnTheEnd = cursorPosition === undefined || cursorPosition === content . length
325
+
314
326
await logseq . Editor . editBlock (
315
327
( nextBlock as BlockEntity ) . uuid ,
316
- cursorPosition ? { pos : cursorPosition } : undefined
328
+ ! isPositionOnTheEnd ? { pos : cursorPosition } : undefined
317
329
)
318
330
}
319
331
@@ -892,7 +904,6 @@ export async function updateBlocksCommand(
892
904
if ( blocks . length === 0 )
893
905
return
894
906
895
- let position = - 1
896
907
if ( ! isSelectedState )
897
908
blocks [ 0 ] . _selectPosition = getEditingCursorSelection ( ) !
898
909
0 commit comments