Skip to content

Commit 2724c79

Browse files
committed
WIP: Fixed some issues with list widget line height. BUGS: multiple issues with list items (cannot add items to environments from toolbar), somewhat fixed toolbar in locating the cursor when adding items to editor (still buggy and doesn't work for all nestings), nesting environments works but editing nested environments does not update them in source, adding commands in visual editor now possible, but still problematic with math blocks $$, experimental edit environment on clicking header (still doesn't work as expected), commands can now be edited but nesting doesn't show during edit, invironment does not visually display commands up until switching to latex source and back.
1 parent 54180c7 commit 2724c79

2 files changed

Lines changed: 40 additions & 13 deletions

File tree

src/styles.css

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,34 +251,48 @@
251251

252252
/* List widget styles */
253253
.latex-visual-list {
254-
margin: 10px 0;
254+
margin: 0;
255+
padding: 0;
256+
line-height: 1.4;
255257
}
256258

257259
.latex-visual-list-element {
258-
margin: 10px 0;
259-
padding-left: 40px; /* Increased padding for better spacing from line numbers */
260+
margin: 0;
261+
padding-left: 40px;
262+
line-height: 1.4;
260263
}
261264

262265
.latex-list-item {
263-
margin: 5px 0;
266+
margin: 0;
267+
padding: 0;
264268
cursor: text;
265-
position: relative; /* Added for better control */
269+
position: relative;
270+
line-height: 1.4;
271+
min-height: 1.4em;
266272
}
267273

268274
.latex-description-item {
269-
margin: 8px 0;
270-
position: relative; /* Added for better control */
275+
margin: 0;
276+
padding: 0;
277+
position: relative;
278+
line-height: 1.4;
271279
}
272280

273281
.latex-description-item dt {
274282
font-weight: bold;
275283
cursor: text;
276-
margin-bottom: 2px;
284+
margin: 0;
285+
padding: 0;
286+
line-height: 1.4;
287+
min-height: 1.4em;
277288
}
278289

279290
.latex-description-item dd {
280-
margin-left: 20px;
291+
margin: 0 0 0 20px;
292+
padding: 0;
281293
cursor: text;
294+
line-height: 1.4;
295+
min-height: 1.4em;
282296
}
283297

284298
.latex-list-item:focus,

src/visual-codemirror/widgets/list-widget.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class ListWidget extends BaseLatexWidget {
2323
const wrapper = document.createElement('div');
2424
wrapper.className = `latex-visual-list latex-list-${this.currentEnvName}`;
2525
wrapper.style.margin = '0';
26+
wrapper.style.padding = '0';
2627
wrapper.style.lineHeight = '1.4';
2728

2829
this.preserveLineHeight(wrapper, this.token.latex);
@@ -37,8 +38,9 @@ export class ListWidget extends BaseLatexWidget {
3738
const listTag = this.getListTag();
3839
const list = document.createElement(listTag);
3940
list.className = 'latex-visual-list-element';
40-
list.style.margin = '10px 0';
41+
list.style.margin = '0';
4142
list.style.paddingLeft = '40px';
43+
list.style.lineHeight = '1.4';
4244

4345
const items = this.parseListItems();
4446

@@ -103,8 +105,11 @@ export class ListWidget extends BaseLatexWidget {
103105
li.className = 'latex-list-item';
104106
li.contentEditable = 'true';
105107
li.style.outline = 'none';
106-
li.style.margin = '5px 0';
108+
li.style.margin = '0';
109+
li.style.padding = '0';
107110
li.style.cursor = 'text';
111+
li.style.lineHeight = '1.4';
112+
li.style.minHeight = '1.4em';
108113
li.dataset.itemIndex = index.toString();
109114

110115
if (this.currentEnvName === 'description' && content.startsWith('[')) {
@@ -130,7 +135,8 @@ export class ListWidget extends BaseLatexWidget {
130135
private createDescriptionItem(content: string, index: number, view: EditorView): HTMLElement {
131136
const wrapper = document.createElement('div');
132137
wrapper.className = 'latex-description-item';
133-
wrapper.style.margin = '5px 0';
138+
wrapper.style.margin = '0';
139+
wrapper.style.lineHeight = '1.4';
134140
wrapper.dataset.itemIndex = index.toString();
135141

136142
let term = '';
@@ -147,14 +153,21 @@ export class ListWidget extends BaseLatexWidget {
147153
dt.style.fontWeight = 'bold';
148154
dt.style.outline = 'none';
149155
dt.style.cursor = 'text';
156+
dt.style.margin = '0';
157+
dt.style.padding = '0';
158+
dt.style.lineHeight = '1.4';
159+
dt.style.minHeight = '1.4em';
150160
dt.textContent = term;
151161
dt.dataset.itemPart = 'term';
152162

153163
const dd = document.createElement('dd');
154164
dd.contentEditable = 'true';
155-
dd.style.marginLeft = '20px';
165+
dd.style.margin = '0 0 0 20px';
166+
dd.style.padding = '0';
156167
dd.style.outline = 'none';
157168
dd.style.cursor = 'text';
169+
dd.style.lineHeight = '1.4';
170+
dd.style.minHeight = '1.4em';
158171
dd.textContent = description;
159172
dd.dataset.itemPart = 'description';
160173

0 commit comments

Comments
 (0)