Skip to content

Commit 9d23270

Browse files
committed
feat(columns): gap 축소 + 빈 컬럼 Backspace로 해제
컬럼 간격 24→16, 컬럼 패딩 8→6 축소. 빈 컬럼에서 Backspace 시 컬럼 레이아웃 해제.
1 parent de17716 commit 9d23270

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/extensions/Columns.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,37 @@ export const Columns = TiptapNode.create({
117117
}
118118
return false;
119119
},
120+
// Backspace at start of empty column: if all columns empty → unset
121+
Backspace: () => {
122+
const { state } = this.editor;
123+
const { from, empty } = state.selection;
124+
if (!empty) return false;
125+
const resolved = state.doc.resolve(from);
126+
// Find columns ancestor
127+
let columnsDepth = -1;
128+
for (let d = resolved.depth; d > 0; d--) {
129+
if (resolved.node(d).type.name === this.name) {
130+
columnsDepth = d;
131+
break;
132+
}
133+
}
134+
if (columnsDepth === -1) return false;
135+
// Must be at start of current textblock
136+
const parentOffset = resolved.parentOffset;
137+
if (parentOffset !== 0) return false;
138+
// All columns must be empty
139+
const columnsNode = resolved.node(columnsDepth);
140+
let allEmpty = true;
141+
columnsNode.descendants((node) => {
142+
if (node.isTextblock && node.textContent.length > 0) {
143+
allEmpty = false;
144+
return false;
145+
}
146+
return true;
147+
});
148+
if (!allEmpty) return false;
149+
return this.editor.chain().focus().unsetColumns().run();
150+
},
120151
};
121152
},
122153
});

src/styles/editor.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@
677677
/* ── 컬럼 레이아웃 ── */
678678
.tiptap div[data-type="columns"] {
679679
display: grid;
680-
gap: 24px;
680+
gap: 16px;
681681
margin: 1em 0;
682682
}
683683

@@ -691,7 +691,7 @@
691691

692692
.tiptap div[data-type="column"] {
693693
min-width: 0;
694-
padding: 4px 8px;
694+
padding: 4px 6px;
695695
border: 1px dashed var(--border);
696696
border-radius: 8px;
697697
}

0 commit comments

Comments
 (0)