Skip to content
Open
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
15 changes: 15 additions & 0 deletions src/views/TableEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { table } from "console";
import { useApp, usePlugin } from "context/hooks";
import { Notice, MarkdownView } from "obsidian";
import * as React from "react";
Expand Down Expand Up @@ -155,6 +156,16 @@ export const TableEditor = ({ leafId, cursor, inputData, updateViewData, supress
return table;
}

const addRow = () => {
const newValues = [...values, Array(values[0].length).fill('')];
setValues(newValues);
}

const addCol = () => {
const newValues = values.map(row => [...row, '']);
setValues(newValues);
}

return (
<>
<div className='mte button-container'>
Expand All @@ -166,6 +177,10 @@ export const TableEditor = ({ leafId, cursor, inputData, updateViewData, supress
<div className='mte button-container'>
<button onClick={copyClicked}>{copyText}</button>
</div>
<div className="mte button-container">
<button onClick={addRow}>Add Row</button>
<button onClick={addCol}>Add Column</button>
</div>
<div className="mte grid" style={{
gridTemplateColumns: `repeat(${values[0]?.length}, 1fr)`
}}>
Expand Down