remove entered text from localstorage when sending response
This commit is contained in:
parent
c4ee9d883e
commit
18f4b026ea
@ -67,7 +67,7 @@
|
|||||||
<div id="babycode-preview-container"></div>
|
<div id="babycode-preview-container"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/static/js/babycode-editor.js?v=1"></script>
|
<script src="/static/js/babycode-editor.js?v=2"></script>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro babycode_editor_form(ta_name, prefill = "", cancel_url="", endpoint="") %}
|
{% macro babycode_editor_form(ta_name, prefill = "", cancel_url="", endpoint="") %}
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
ta.addEventListener("keydown", (e) => {
|
ta.addEventListener("keydown", (e) => {
|
||||||
if(e.key === "Enter" && e.ctrlKey) {
|
if(e.key === "Enter" && e.ctrlKey) {
|
||||||
// console.log(e.target.form)
|
// console.log(e.target.form)
|
||||||
|
if (inThread()) {
|
||||||
|
localStorage.removeItem(window.location.pathname);
|
||||||
|
}
|
||||||
e.target.form?.submit();
|
e.target.form?.submit();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -18,7 +21,17 @@
|
|||||||
|
|
||||||
localStorage.setItem(window.location.pathname, ta.value);
|
localStorage.setItem(window.location.pathname, ta.value);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (inThread()) {
|
||||||
|
const form = ta.closest('.post-edit-form');
|
||||||
|
console.log(ta.closest('.post-edit-form'));
|
||||||
|
if (form){
|
||||||
|
form.addEventListener("submit", () => {
|
||||||
|
localStorage.removeItem(window.location.pathname);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
if (!inThread()) return;
|
if (!inThread()) return;
|
||||||
const prevContent = localStorage.getItem(window.location.pathname);
|
const prevContent = localStorage.getItem(window.location.pathname);
|
||||||
|
Loading…
Reference in New Issue
Block a user