notatio/templates/edit.html

179 lines
9.3 KiB
HTML
Raw Normal View History

2023-11-20 22:10:40 -06:00
<!DOCTYPE html>
<html lang="en_US">
<head>
<title>Edit File</title>
<link rel="stylesheet" type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
<link rel="stylesheet" type="text/css"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
</script>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<script src="/static/build/editor.js" type="text/javascript"></script>
<style>
.editor:empty:not(:focus):before {
content: attr(data-placeholder);
opacity: 45%;
}
[contenteditable]:focus {
outline: 0px solid transparent;
}
</style>
</head>
<body class="vh-100">
<div class="sticky-top bg-light-grey">
<div class="row">
<div class="col-12">
<div class="mx-auto d-flex justify-content-center">
<h1>Editing File: </h1>
<h1 id="filename" onclick="editFileName()" contenteditable="false">{{.Filename}}</h1>
</div>
</div>
</div>
<div class="row sticky-top bg-light-grey">
<div class="col-12">
<div class="d-flex justify-content-between bg-light-grey border-bottom p-2">
<div>
<div class="dropdown d-inline-block">
<button class="btn dropdown-toggle" type="button" id="headingDropdown"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-heading"></i>
</button>
<ul class="dropdown-menu" aria-labelledby="headingDropdown">
<li><button class="dropdown-item" type="button"
onclick="formatText('heading', 'h1')">Heading 1</button></li>
<li><button class="dropdown-item" type="button"
onclick="formatText('heading', 'h2')">Heading 2</button></li>
<li><button class="dropdown-item" type="button"
onclick="formatText('heading', 'h3')">Heading 3</button></li>
<li><button class="dropdown-item" type="button"
onclick="formatText('heading', 'h4')">Heading 4</button></li>
<li><button class="dropdown-item" type="button"
onclick="formatText('heading', 'h5')">Heading 5</button></li>
<li><button class="dropdown-item" type="button"
onclick="formatText('heading', 'h6')">Heading 6</button></li>
</ul>
</div>
<button type="button" class="btn btn-light" onclick="formatText('bold')" aria-label="Bold"><i
class="fas fa-bold"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('italic')"><i
class="fas fa-italic"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('underline')"><i
class="fas fa-underline"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('strikeThrough')"><i
class="fas fa-strikethrough"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('removeFormat')"><i
class="fas fa-eraser"></i></button>
<button class="btn btn-light" onclick="addTable()"><i class="fas fa-table"
disabled></i></button>
<button class="btn btn-light" onclick="addVideo()"><i class="fas fa-video"></i></button>
<button type="button" class="btn btn-light" onclick="undo()"><i
class="fas fa-undo"></i></button>
<button type="button" class="btn btn-light" onclick="redo()"><i
class="fas fa-redo"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('insertUnorderedList')"><i
class="fas fa-list-ul"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('insertOrderedList')"><i
class="fas fa-list-ol"></i></button>
<button type="button" class="btn btn-light" onclick="insertImage()"><i
class="fas fa-image"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('formatBlock', '<blockquote>')"
disabled><i class="fas fa-quote-right"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('formatBlock', '<code>')"
disabled><i class="fas fa-code"></i></button>
<button type="button" class="btn btn-light" onclick="formatText('insertHorizontalRule')"><i
class="fas fa-grip-lines"></i></button>
<button class="btn btn-light" onclick="insertLink()"><i class="fas fa-link"></i></button>
</div>
<div>
<button class="btn btn-light" onclick="confirmOverwrite()"> <i class="fa fa-notes-medical"></i>
Templates</i></button>
<button class="btn btn-light" onclick="saveForm()"><i class="fas fa-save"></i></button>
<button class="btn btn-light" onclick="confirmDeletion()"><i class="fas fa-trash"></i></button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div id="template-modal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title">Templates</h2>
</div>
<div class="modal-body">
<!-- Generate buttons for each template -->
{{ range .Templates }}
<button type="button" class="btn btn-primary"
onclick="redirectToTemplate('/edit?filename={{.Filename}}&template={{.TemplateName}}')">
{{.TemplateName}}
</button><br>
{{ end }}
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<form id="save-form" method="post" action="/save?filename={{.Filename}}">
<textarea hidden="true" id="editor-form-content" name="editor"></textarea>
<input type="hidden" id="filename-form-content" name="filename" value="{{.Filename}}">
<div class="editor shadow-none" id="editor" role="textbox" contenteditable="true"
data-placeholder="The page lays unwritten....">
{{.FileContent}}</div>
</form>
</div>
</div>
<div id="tableModal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Table</h5>
</div>
<div class="modal-body">
<div class="form-row">
<div class="form-group col-sm-6">
<label for="tableRows">Rows</label>
<input type="number" class="form-control" id="tableRows" value="3" min="2">
</div>
<div class="form-group col-sm-6">
<label for="tableColumns">Columns</label>
<input type="number" class="form-control" id="tableColumns" value="3" min="2">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" onclick="document.getElementById('tableModal').style.display = 'none'">Cancel</button>
<button type="button" class="btn btn-primary" onclick="createTable()">Create Table</button>
</div>
</div>
</div>
</div>
</body>
</html>