Improve editor usability on phone
This commit is contained in:
parent
f2251dba22
commit
de49f8fbc7
1 changed files with 85 additions and 109 deletions
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Edit File</title>
|
<title>Edit File</title>
|
||||||
<link rel="stylesheet" type="text/css"
|
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.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.3.2/dist/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" type="text/css"
|
|
||||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
</script>
|
</script>
|
||||||
|
@ -18,7 +16,6 @@
|
||||||
opacity: 45%;
|
opacity: 45%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[contenteditable]:focus {
|
[contenteditable]:focus {
|
||||||
outline: 0px solid transparent;
|
outline: 0px solid transparent;
|
||||||
}
|
}
|
||||||
|
@ -43,102 +40,78 @@
|
||||||
<div class="d-flex justify-content-between bg-light-grey border-bottom p-2">
|
<div class="d-flex justify-content-between bg-light-grey border-bottom p-2">
|
||||||
<div>
|
<div>
|
||||||
<div class="dropdown d-inline-block">
|
<div class="dropdown d-inline-block">
|
||||||
<button class="btn dropdown-toggle" type="button" id="headingDropdown"
|
<button class="btn dropdown-toggle" type="button" id="headingDropdown" data-bs-toggle="dropdown"
|
||||||
data-bs-toggle="dropdown" aria-expanded="false">
|
aria-expanded="false">
|
||||||
<i class="fas fa-heading"></i>
|
<i class="fas fa-heading"></i>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" aria-labelledby="headingDropdown">
|
<ul class="dropdown-menu" aria-labelledby="headingDropdown">
|
||||||
<li><button class="dropdown-item" type="button"
|
<li><button class="dropdown-item" type="button" onclick="formatText('heading', 'h1')">Heading 1</button></li>
|
||||||
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"
|
<li><button class="dropdown-item" type="button" onclick="formatText('heading', 'h3')">Heading 3</button></li>
|
||||||
onclick="formatText('heading', 'h2')">Heading 2</button></li>
|
<li><button class="dropdown-item" type="button" onclick="formatText('heading', 'h4')">Heading 4</button></li>
|
||||||
<li><button class="dropdown-item" type="button"
|
<li><button class="dropdown-item" type="button" onclick="formatText('heading', 'h5')">Heading 5</button></li>
|
||||||
onclick="formatText('heading', 'h3')">Heading 3</button></li>
|
<li><button class="dropdown-item" type="button" onclick="formatText('heading', 'h6')">Heading 6</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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn" onclick="formatText('bold')" aria-label="Bold"><i
|
<button type="button" class="btn" onclick="formatText('bold')" aria-label="Bold"><i class="fas fa-bold"></i></button>
|
||||||
class="fas fa-bold"></i></button>
|
<button type="button" class="btn " onclick="formatText('italic')"><i class="fas fa-italic"></i></button>
|
||||||
<button type="button" class="btn " onclick="formatText('italic')"><i
|
<button type="button" class="btn " onclick="formatText('underline')"><i class="fas fa-underline"></i></button>
|
||||||
class="fas fa-italic"></i></button>
|
<button type="button" class="btn " onclick="formatText('strikeThrough')"><i class="fas fa-strikethrough"></i></button>
|
||||||
<button type="button" class="btn " onclick="formatText('underline')"><i
|
<button type="button" class="btn " onclick="undo()"><i class="fas fa-undo"></i></button>
|
||||||
class="fas fa-underline"></i></button>
|
<button type="button" class="btn " onclick="redo()"><i class="fas fa-redo"></i></button>
|
||||||
<button type="button" class="btn " onclick="formatText('strikeThrough')"><i
|
<button type="button" class="btn " onclick="formatText('removeFormat')"><i class="fas fa-eraser"></i></button>
|
||||||
class="fas fa-strikethrough"></i></button>
|
</div>
|
||||||
<button type="button" class="btn " onclick="formatText('removeFormat')"><i
|
|
||||||
class="fas fa-eraser"></i></button>
|
<!-- First few buttons visible on small screens -->
|
||||||
|
<div class="d-none d-md-block">
|
||||||
<button class="btn " onclick="addTable()"><i class="fas fa-table" disabled></i></button>
|
<button class="btn " onclick="addTable()"><i class="fas fa-table" disabled></i></button>
|
||||||
<button class="btn " onclick="addVideo()"><i class="fas fa-video"></i></button>
|
<button class="btn " onclick="addVideo()"><i class="fas fa-video"></i></button>
|
||||||
|
|
||||||
<button type="button" class="btn " onclick="undo()"><i class="fas fa-undo"></i></button>
|
<button type="button" class="btn " onclick="formatText('insertUnorderedList')"><i class="fas fa-list-ul"></i></button>
|
||||||
<button type="button" class="btn " onclick="redo()"><i class="fas fa-redo"></i></button>
|
<button type="button" class="btn " onclick="formatText('insertOrderedList')"><i class="fas fa-list-ol"></i></button>
|
||||||
<button type="button" class="btn " onclick="formatText('insertUnorderedList')"><i
|
|
||||||
class="fas fa-list-ul"></i></button>
|
|
||||||
<button type="button" class="btn " onclick="formatText('insertOrderedList')"><i
|
|
||||||
class="fas fa-list-ol"></i></button>
|
|
||||||
<button type="button" class="btn " onclick="insertImage()"><i class="fas fa-image"></i></button>
|
<button type="button" class="btn " onclick="insertImage()"><i class="fas fa-image"></i></button>
|
||||||
<button type="button" class="btn " onclick="formatText('formatBlock', '<blockquote>')"
|
<!--- <button type="button" class="btn " onclick="formatText('formatBlock', '<blockquote>')" disabled><i class="fas fa-quote-right"></i></button>
|
||||||
disabled><i class="fas fa-quote-right"></i></button>
|
<button type="button" class="btn " onclick="formatText('formatBlock', '<code>')" disabled><i class="fas fa-code"></i></button> -->
|
||||||
<button type="button" class="btn " onclick="formatText('formatBlock', '<code>')" disabled><i
|
<button type="button" class="btn " onclick="formatText('insertHorizontalRule')"><i class="fas fa-grip-lines"></i></button>
|
||||||
class="fas fa-code"></i></button>
|
|
||||||
<button type="button" class="btn " onclick="formatText('insertHorizontalRule')"><i
|
|
||||||
class="fas fa-grip-lines"></i></button>
|
|
||||||
|
|
||||||
|
|
||||||
<button class="btn " onclick="insertLink()"><i class="fas fa-link"></i></button>
|
<button class="btn " onclick="insertLink()"><i class="fas fa-link"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Dropdown with remaining buttons on small screens -->
|
||||||
|
<div class="dropdown position-relative d-md-none">
|
||||||
|
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false">
|
||||||
|
<i class="fas fa-ellipsis-v"></i>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuButton">
|
||||||
|
<li><button class="dropdown-item" type="button" onclick="addTable()">Add Table</button></li>
|
||||||
|
<li><button class="dropdown-item" type="button" onclick="addVideo()">Add Video</button></li>
|
||||||
|
<li><button class="dropdown-item" type="button"
|
||||||
|
onclick="formatText('insertUnorderedList')">Insert Unordered List</button></li>
|
||||||
|
<li><button class="dropdown-item" type="button" onclick="formatText('insertOrderedList')">Insert Ordered List</button></li>
|
||||||
|
<li><button class="dropdown-item" type="button" onclick="insertImage()">Insert Image</button></li>
|
||||||
|
<li><button class="dropdown-item" type="button" onclick="formatText('insertHorizontalRule')">Insert Horizontal Rule</button></li>
|
||||||
|
<li><button class="dropdown-item" type="button" onclick="insertLink()">Insert Link</button></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button class="btn " onclick="confirmOverwrite()"> <i class="fa fa-notes-medical"></i>
|
<button class="btn " onclick="confirmOverwrite()"> <i class="fa fa-notes-medical"></i> Templates</i></button>
|
||||||
Templates</i></button>
|
|
||||||
<button class="btn " onclick="saveForm()"><i class="fas fa-save"></i></button>
|
<button class="btn " onclick="saveForm()"><i class="fas fa-save"></i></button>
|
||||||
<button class="btn " onclick="confirmDeletion()"><i class="fas fa-trash"></i></button>
|
<button class="btn " onclick="confirmDeletion()"><i class="fas fa-trash"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</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 class="container">
|
||||||
|
<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>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
<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 id="tableModal" class="modal">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
@ -166,38 +139,41 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
</div>
|
||||||
// The deletion is kept here as I (Musselman) have not found a way to implement the {{.Filename}} into the javascript.
|
|
||||||
function confirmDeletion() {
|
<script>
|
||||||
if (confirm("Are you sure you want to delete {{.Filename}}?")) {
|
// The deletion is kept here as I (Musselman) have not found a way to implement the {{.Filename}} into the javascript.
|
||||||
const filename = "{{.Filename}}";
|
function confirmDeletion() {
|
||||||
deleteFile(filename);
|
if (confirm("Are you sure you want to delete {{.Filename}}?")) {
|
||||||
}
|
const filename = "{{.Filename}}";
|
||||||
|
deleteFile(filename);
|
||||||
}
|
}
|
||||||
function deleteFile(filename) {
|
}
|
||||||
// Send a POST request to the server to delete the specified file
|
|
||||||
fetch("/delete", {
|
function deleteFile(filename) {
|
||||||
method: "POST",
|
// Send a POST request to the server to delete the specified file
|
||||||
headers: {
|
fetch("/delete", {
|
||||||
"Content-Type": "application/json",
|
method: "POST",
|
||||||
},
|
headers: {
|
||||||
body: JSON.stringify({ files: [filename] }),
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ files: [filename] }),
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
window.location.replace("/home");
|
||||||
|
} else {
|
||||||
|
// Handle the error, e.g., display an error message
|
||||||
|
console.error("Error deleting file");
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(response => {
|
.catch(error => {
|
||||||
if (response.ok) {
|
console.error("Error deleting file:", error);
|
||||||
window.location.replace("/home");
|
});
|
||||||
} else {
|
}
|
||||||
// Handle the error, e.g., display an error message
|
</script>
|
||||||
console.error("Error deleting file");
|
<script src="/static/build/darkmode.js" type="text/javascript"></script>
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error("Error deleting file:", error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<script src="/static/build/darkmode.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue