Skip to content

Commit cfec419

Browse files
committed
Added comments
1 parent c37bb5e commit cfec419

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
184184

185185
let chainedCommands = chain();
186186

187+
// Moves the children of the current block to the previous one.
187188
if (blockInfo.childContainer) {
188189
chainedCommands.insertContentAt(
189190
blockInfo.bnBlock.afterPos,
@@ -437,6 +438,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
437438
const newBlockContentPos = newBlockInsertionPos + 2;
438439

439440
if (dispatch) {
441+
// Creates a new block with the children of the current block,
442+
// if it has any.
440443
const newBlock = state.schema.nodes[
441444
"blockContainer"
442445
].createAndFill(
@@ -448,12 +451,15 @@ export const KeyboardShortcutsExtension = Extension.create<{
448451
].filter((node) => node !== undefined),
449452
)!;
450453

454+
// Inserts the new block and moves the selection to it.
451455
tr.insert(newBlockInsertionPos, newBlock)
452456
.setSelection(
453457
new TextSelection(tr.doc.resolve(newBlockContentPos)),
454458
)
455459
.scrollIntoView();
456460

461+
// Deletes old block's children, as they have been moved to
462+
// the new one.
457463
if (blockInfo.childContainer) {
458464
tr.delete(
459465
blockInfo.childContainer.beforePos,

0 commit comments

Comments
 (0)