kb/web/templates/edit.html
2025-12-17 09:00:24 -05:00

60 lines
2.1 KiB
HTML

<!-- templates/edit.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit: {{.Title}} - Knowledge Base</title>
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/theme/base16-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/markdown/markdown.min.js"></script>
</head>
<body>
<div class="container">
<header>
<nav>
<a href="/page/{{.Path}}">← Cancel</a>
<h1>Edit: {{.Title}}</h1>
</nav>
</header>
<main>
<form method="POST" action="/save" id="editForm">
<input type="hidden" name="path" value="{{.Path}}">
<textarea id="editor" name="content">{{.RawText}}</textarea>
<div class="button-group">
<button type="submit" class="btn btn-primary">Save</button>
<a href="/page/{{.Path}}" class="btn">Cancel</a>
</div>
</form>
</main>
</div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById('editor'), {
mode: 'markdown',
theme: 'base16-dark',
lineNumbers: true,
lineWrapping: true,
autoCloseBrackets: true,
matchBrackets: true,
indentUnit: 4,
tabSize: 4,
indentWithTabs: false
});
// Keyboard shortcut for save (Ctrl+S or Cmd+S)
editor.setOption("extraKeys", {
"Ctrl-S": function(cm) {
document.getElementById('editForm').submit();
},
"Cmd-S": function(cm) {
document.getElementById('editForm').submit();
}
});
</script>
</body>
</html>