Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ export const icons: Record<string, string> = {
<path d="m309.33 128c-8.832 0-16-7.168-16-16v-96c0-8.832 7.168-16 16-16s16 7.168 16 16v96c0 8.832-7.168 16-16 16z"/>
<path d="m309.33 469.33c-8.832 0-16-7.168-16-16v-202.66c0-8.832 7.168-16 16-16s16 7.168 16 16v202.66c0 8.832-7.168 16-16 16z"/>
<path d="m496 368h-373.33c-8.832 0-16-7.168-16-16s7.168-16 16-16h373.33c8.832 0 16 7.168 16 16s-7.168 16-16 16z"/>
</svg>`,
insertRowBelow: `
<svg class="widget-icon" version="1.1" viewBox="0 -21 512 512" xmlns="http://www.w3.org/2000/svg">
<path d="m16 192.67c-1.9844 0-3.9688 0.36328-5.8672 1.1094-6.1211 2.4102-10.133 8.3203-10.133 14.891v160c0 6.5703 4.0117 12.48 10.133 14.891 6.1445 2.4102 13.078 0.85156 17.559-3.9688l74.664-80c5.7617-6.1445 5.7617-15.68 0-21.824l-74.664-80c-3.0938-3.3281-7.3398-5.0977-11.691-5.0977zm16 135.4v-78.805l36.777 39.402z"/>
<path d="m474.67 0h-330.67c-20.586 0-37.332 16.746-37.332 37.332v53.336c0 20.586 16.746 37.332 37.332 37.332h330.67c20.586 0 37.332-16.746 37.332-37.332v-53.336c0-20.586-16.746-37.332-37.332-37.332zm-330.67 96c-2.9453 0-5.332-2.3906-5.332-5.332v-53.336c0-2.9414 2.3867-5.332 5.332-5.332h330.67c2.9414 0 5.332 2.3906 5.332 5.332v53.336c0 2.9414-2.3906 5.332-5.332 5.332z"/>
<path d="m474.67 202.67h-330.67c-20.586 0-37.332 16.746-37.332 37.332v160c0 20.586 16.746 37.332 37.332 37.332h330.67c20.586 0 37.332-16.746 37.332-37.332v-160c0-20.586-16.746-37.332-37.332-37.332zm-330.67 202.66c-2.9453 0-5.332-2.3867-5.332-5.332v-160c0-2.9453 2.3867-5.332 5.332-5.332h330.67c2.9414 0 5.332 2.3867 5.332 5.332v160c0 2.9453-2.3906 5.332-5.332 5.332z"/>
<path d="m309.33 0c-8.832 0-16 7.168-16 16v96c0 8.832 7.168 16 16 16s16-7.168 16-16v-96c0-8.832-7.168-16-16-16z"/>
<path d="m309.33 202.67c-8.832 0-16 7.168-16 16v202.66c0 8.832 7.168 16 16 16s16-7.168 16-16v-202.66c0-8.832-7.168-16-16-16z"/>
<path d="m496 144h-373.33c-8.832 0-16 7.168-16 16s7.168 16 16 16h373.33c8.832 0 16-7.168 16-16s-7.168-16-16-16z"/>
</svg>`,
moveColumnLeft: `
<svg class="widget-icon" version="1.1" viewBox="0 0 512.02 512" xmlns="http://www.w3.org/2000/svg">
Expand Down
9 changes: 9 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ export default class TableEditorPlugin extends Plugin {
}),
});

this.addCommand({
id: 'insert-row-below',
name: 'Insert row after current',
icon: 'insertRowBelow',
editorCheckCallback: this.newPerformTableAction((te: TableEditor) => {
te.insertRowBelow();
}),
});

this.addCommand({
id: 'escape-table',
name: 'Move cursor out of table',
Expand Down
3 changes: 3 additions & 0 deletions src/table-controls-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class TableControlsView extends ItemView {
this.drawBtn(rowThreeBtns, 'insertRow', 'insert row above', (te) =>
te.insertRow(),
);
this.drawBtn(rowThreeBtns, 'insertRowBelow', 'insert row below', (te) =>
te.insertRowBelow(),
);
this.drawBtn(rowThreeBtns, 'insertColumn', 'insert column left', (te) =>
te.insertColumn(),
);
Expand Down
7 changes: 7 additions & 0 deletions src/table-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export class TableEditor {
this.mte.insertRow(this.settings.asOptions());
};

public readonly insertRowBelow = (): void => {
// Since the underlying library doesn't have insertRowBelow,
// we implement it by moving to the next row and inserting there
this.mte.nextRow(this.settings.asOptions());
this.mte.insertRow(this.settings.asOptions());
};

public readonly leftAlignColumn = (): void => {
this.mte.alignColumn(Alignment.LEFT, this.settings.asOptions());
};
Expand Down