I have created a website using Django where users can upload .txt files, and now I want to enhance it by adding an editing feature that integrates ACE editor or any other recommended editor.
Currently, I display a list of the uploaded files and would like to have an 'edit' button that redirects users to an editor page with the file content pre-loaded.
I am trying to figure out how to load the file content into the ACE editor.
I came across some code that directly uploads a file and displays it in an editor here: (https://jsfiddle.net/xlaptop2001/y70gL3kv). However, my goal is to redirect users to a new editor page with the previously uploaded file loaded when they click on the 'edit' button.
{% extends 'base.html' %}
{% block content %}
<h1>Mechanism {{ object.id }} details</h1>
<style>
ul.b {
list-style-type: square;
line-height:200%;
}
</style>
...
<p><a href="/list/">Back to mechanism list</a></p>
{% endblock %}
<!DOCTYPE html>
{% load static %}
<html lang="en">
...
return x;
}</div>
<div id="file-content" style="display: none;"></div>
<script src="{% static 'JS/aceeditor.js' %}" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.4/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/javascript");
</script>
</body>
</html>