diff --git a/documentation/FEATURES.md b/documentation/FEATURES.md index 78887d6..f9959c1 100644 --- a/documentation/FEATURES.md +++ b/documentation/FEATURES.md @@ -275,6 +275,7 @@ date: {{date}} | `Ctrl+B` | `Cmd+B` | Bold | `**text**` | | `Ctrl+I` | `Cmd+I` | Italic | `*text*` | | `Ctrl+K` | `Cmd+K` | Insert link | `[text](url)` | +| `Ctrl+Alt+T` | `Cmd+Option+T` | Insert table | 3x3 table placeholder | ## 🚀 Performance diff --git a/frontend/app.js b/frontend/app.js index 92cb3a4..9ae9bc2 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -461,6 +461,12 @@ function noteApp() { e.preventDefault(); this.insertLink(); } + + // Ctrl/Cmd + Alt + T for table + if ((e.ctrlKey || e.metaKey) && e.altKey && e.key === 't') { + e.preventDefault(); + this.insertTable(); + } } }); } @@ -2548,6 +2554,39 @@ function noteApp() { this.autoSave(); }, + // Insert a markdown table placeholder + insertTable() { + const editor = document.getElementById('note-editor'); + if (!editor) return; + + const cursorPos = editor.selectionStart; + + // Basic 3x3 table placeholder + const table = `| Header 1 | Header 2 | Header 3 | +|----------|----------|----------| +| Cell 1 | Cell 2 | Cell 3 | +| Cell 4 | Cell 5 | Cell 6 | +`; + + // Add newline before if not at start of line + const textBefore = this.noteContent.substring(0, cursorPos); + const needsNewlineBefore = textBefore.length > 0 && !textBefore.endsWith('\n'); + const prefix = needsNewlineBefore ? '\n\n' : ''; + + // Insert the table + this.noteContent = textBefore + prefix + table + this.noteContent.substring(cursorPos); + + // Position cursor at first header for easy editing + this.$nextTick(() => { + const newPos = cursorPos + prefix.length + 2; // After "| " + editor.setSelectionRange(newPos, newPos + 8); // Select "Header 1" + editor.focus(); + }); + + // Trigger autosave + this.autoSave(); + }, + // Save current note async saveNote() { if (!this.currentNote) return;