-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from JohnGrubba/dev
E-Mail Editor
- Loading branch information
Showing
76 changed files
with
16,892 additions
and
38 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script src="../apikey.js"></script> | ||
<script src="script.js"></script> | ||
<link rel="icon" type="image/x-icon" href="../assets/ezauth_logo.png"> | ||
<link href="../index.css" rel="stylesheet"> | ||
<link href="style.css" rel="stylesheet"> | ||
<title>EZAuth - Admin Panel / E-Mails</title> | ||
</head> | ||
|
||
<body> | ||
<h1> | ||
<span>E-Mail Editor</span> | ||
<a style="float: right;" href="/admin"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"> | ||
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" /> | ||
</svg> | ||
</a> | ||
</h1> | ||
<div class="extensions"> | ||
<textarea id="htmeditor"></textarea> | ||
<script src="./js/htmeditor.min.js" htmeditor_textarea="htmeditor" full_screen="no" editor_height="480" | ||
run_local="yes"> </script> | ||
|
||
<div class="actions"> | ||
<button class="restore" onclick="sendEmail()">Send E-Mail</button> | ||
</div> | ||
|
||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,292 @@ | ||
// Function to download data to a file | ||
function download(data, filename, type) { | ||
var file = new Blob([data], { | ||
type: type, | ||
}) | ||
if (window.navigator.msSaveOrOpenBlob) | ||
// IE10+ | ||
window.navigator.msSaveOrOpenBlob(file, filename) | ||
else { | ||
// Others | ||
var a = document.createElement("a"), | ||
url = URL.createObjectURL(file) | ||
a.href = url | ||
a.download = filename | ||
document.body.appendChild(a) | ||
a.click() | ||
setTimeout(function () { | ||
document.body.removeChild(a) | ||
window.URL.revokeObjectURL(url) | ||
}, 0) | ||
} | ||
} | ||
|
||
function format(node, level) { | ||
var indentBefore = new Array(level++ + 1).join(" "), | ||
indentAfter = new Array(level - 1).join(" "), | ||
textNode | ||
|
||
for (var i = 0; i < node.children.length; i++) { | ||
textNode = document.createTextNode("\n" + indentBefore) | ||
node.insertBefore(textNode, node.children[i]) | ||
|
||
format(node.children[i], level) | ||
|
||
if (node.lastElementChild == node.children[i]) { | ||
textNode = document.createTextNode("\n" + indentAfter) | ||
node.appendChild(textNode) | ||
} | ||
} | ||
|
||
return node | ||
} | ||
|
||
var Init = function (htmeditor_textarea, full_screen = false, editor_height = 480) { | ||
//Reszie the editor when the window is resized | ||
|
||
if (full_screen == "yes") { | ||
window.onresize = function () { | ||
tinymce.activeEditor.editorContainer.style.height = window.innerHeight + "px" | ||
tinymce.activeEditor.editorContainer.style.width = window.innerWidth + "px" | ||
} | ||
} | ||
|
||
tinymce.init({ | ||
//Do not remove new lines | ||
apply_source_formatting: false, | ||
remove_linebreaks: false, | ||
verify_html: false, | ||
resize: false, | ||
|
||
//Disable quick insert popup | ||
quickbars_insert_toolbar: "", | ||
|
||
branding: false, | ||
selector: "textarea#" + htmeditor_textarea, | ||
plugins: | ||
"print preview paste importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern noneditable help charmap quickbars emoticons", | ||
imagetools_cors_hosts: ["picsum.photos"], | ||
|
||
toolbar: | ||
"preview | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | table | undo redo | bold italic underline strikethrough | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | print | insertfile image media template link anchor codesample | ltr rtl", | ||
|
||
toolbar_sticky: true, | ||
autosave_ask_before_unload: true, | ||
autosave_interval: "30s", | ||
autosave_prefix: "{path}{query}-{id}-", | ||
autosave_restore_when_empty: false, | ||
autosave_retention: "2m", | ||
image_advtab: true, | ||
|
||
//Set the bootstrap style | ||
content_css: "./css/bootstrap.css", | ||
|
||
//Set the content padding | ||
content_style: "body {padding: 10px}", | ||
|
||
|
||
//Set the htmeditor custom | ||
menu: { | ||
custom_file: { | ||
title: "File", | ||
items: "newdocument basicitem | openfile saveas | code preview | print", | ||
}, | ||
custom_tools: { | ||
title: "Tools", | ||
items: "code wordcount", | ||
}, | ||
custom_help: { | ||
title: "Help", | ||
items: "help", | ||
}, | ||
}, | ||
|
||
//Create the menu | ||
menubar: "custom_file edit view insert format custom_tools table, custom_help", | ||
|
||
importcss_append: true, | ||
|
||
mobile: { | ||
theme: 'silver', | ||
plugins: | ||
"print preview paste importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern noneditable help charmap quickbars emoticons", | ||
toolbar: | ||
"preview | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | table | undo redo | bold italic underline strikethrough | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | print | insertfile image media template link anchor codesample | ltr rtl", | ||
|
||
//Create the menu | ||
menubar: "custom_file edit view insert format custom_tools table, custom_help" | ||
}, | ||
|
||
file_picker_callback: function (callback, value, meta) { | ||
/* Provide file and text for the link dialog */ | ||
if (meta.filetype === "file") { | ||
callback("https://www.google.com/logos/google.jpg", { | ||
text: "My text", | ||
}) | ||
} | ||
|
||
/* Provide image and alt text for the image dialog */ | ||
if (meta.filetype === "image") { | ||
callback("https://www.google.com/logos/google.jpg", { | ||
alt: "My alt text", | ||
}) | ||
} | ||
|
||
/* Provide alternative source and posted for the media dialog */ | ||
if (meta.filetype === "media") { | ||
callback("movie.mp4", { | ||
source2: "alt.ogg", | ||
poster: "https://www.google.com/logos/google.jpg", | ||
}) | ||
} | ||
}, | ||
templates: [ | ||
{ | ||
title: "New Table", | ||
description: "creates a new table", | ||
content: '<div class="mceTmpl"><table width="98%%" border="0" cellspacing="0" cellpadding="0"><tr><th scope="col"> </th><th scope="col"> </th></tr><tr><td> </td><td> </td></tr></table></div>', | ||
}, | ||
{ | ||
title: "Starting my story", | ||
description: "A cure for writers block", | ||
content: "Once upon a time...", | ||
}, | ||
{ | ||
title: "New list with dates", | ||
description: "New List with dates", | ||
content: '<div class="mceTmpl"><span class="cdate">cdate</span><br /><span class="mdate">mdate</span><h2>My List</h2><ul><li></li><li></li></ul></div>', | ||
}, | ||
], | ||
template_cdate_format: "[Date Created (CDATE): %m/%d/%Y : %H:%M:%S]", | ||
template_mdate_format: "[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S]", | ||
|
||
image_caption: true, | ||
quickbars_selection_toolbar: "bold italic | quicklink h2 h3 blockquote quickimage quicktable", | ||
noneditable_noneditable_class: "mceNonEditable", | ||
toolbar_mode: "sliding", | ||
contextmenu: "link image imagetools table", | ||
|
||
//Set the height | ||
height: parseInt(editor_height), | ||
|
||
|
||
setup: function (editor) { | ||
editor.ui.registry.addMenuItem("basicitem", { | ||
text: "New window document", | ||
icon: "duplicate", | ||
onAction: function () { | ||
window.open("/author/", "_blank") | ||
}, | ||
}) | ||
editor.ui.registry.addMenuItem("openfile", { | ||
text: "Open File", | ||
icon: "browse", | ||
onAction: function () { | ||
const fileSelector = document.getElementById("htmeditor-file-input-open-file") | ||
fileSelector.addEventListener("change", (event) => { | ||
const fileList = event.target.files | ||
|
||
var file = fileList[0] | ||
|
||
if (file.type == "text/html") { | ||
const reader = new FileReader() | ||
reader.addEventListener("load", (event) => { | ||
tinymce.activeEditor.setContent(event.target.result) | ||
}) | ||
reader.readAsText(file, "UTF-8") | ||
} | ||
}) | ||
|
||
document.getElementById("htmeditor-file-input-open-file").click() | ||
}, | ||
}) | ||
|
||
editor.ui.registry.addMenuItem("saveas", { | ||
text: "Save As", | ||
icon: "save", | ||
onAction: function () { | ||
|
||
console.log(tinyMCE.activeEditor.getContent()) | ||
|
||
var str = tinyMCE.activeEditor.getContent() | ||
var div = document.createElement("div") | ||
div.innerHTML = str.trim() | ||
|
||
download(format(div, 0).innerHTML, "mypage.html", "text/html") | ||
}, | ||
}) | ||
|
||
editor.ui.registry.addMenuItem("convert_to_app", { | ||
text: "Convert To Mobile App", | ||
icon: "reload", | ||
onAction: function () { | ||
window.open("https://webintoapp.com?ref=htmeditor", "_blank") | ||
}, | ||
}) | ||
|
||
editor.ui.registry.addMenuItem("recommended_hosting", { | ||
text: "Recommended Web Hosting Services", | ||
icon: "checkmark", | ||
onAction: function () { | ||
window.open("https://webhosting4me.com?ref=htmeditor", "_blank") | ||
}, | ||
}) | ||
|
||
editor.on("init", function (e) { | ||
if (full_screen == "yes") editor.execCommand("mceFullScreen") | ||
}) | ||
}, | ||
}) | ||
} | ||
|
||
//Load the tinymce JS dynamically | ||
var loadScript = function (url, callback) { | ||
|
||
var script = document.createElement("script") | ||
script.type = "text/javascript" | ||
script.src = url | ||
|
||
// Then bind the event to the callback function. | ||
// There are several events for cross browser compatibility. | ||
script.onreadystatechange = callback | ||
script.onload = callback | ||
|
||
//Add it begore the text area element | ||
document.getElementById(htmeditor_textarea).prepend(script) | ||
|
||
//Or add it after the text area element | ||
//document.getElementById(htmeditor_textarea).appendChild(script); | ||
|
||
} | ||
|
||
//Init the editor after the JS was loaded | ||
var load_js_callback = function () { | ||
|
||
Init(htmeditor_textarea, full_screen, editor_height) | ||
} | ||
|
||
//Get the parameters | ||
var htmeditor_textarea = document.currentScript.getAttribute("htmeditor_textarea") | ||
var full_screen = document.currentScript.getAttribute("full_screen") == null ? "no" : document.currentScript.getAttribute("full_screen") | ||
var editor_height = document.currentScript.getAttribute("editor_height") == null ? "480" : document.currentScript.getAttribute("editor_height") | ||
var run_local = document.currentScript.getAttribute("run_local") == null ? "no" : document.currentScript.getAttribute("run_local") | ||
|
||
// Create a file input for save the file | ||
var file = document.createElement("input") | ||
file.setAttribute("id", "htmeditor-file-input-open-file") | ||
file.setAttribute("type", "file") | ||
file.setAttribute("accept", ".html, .html") | ||
file.setAttribute("style", "display: none;") | ||
|
||
//Append the div to the container div | ||
document.getElementById(htmeditor_textarea).prepend(file) | ||
|
||
//window.onload = function () { | ||
|
||
//Run local? So add a dot in the beginning | ||
if (run_local == "yes") | ||
loadScript("./js/tinymce/tinymce.min.js", load_js_callback) | ||
else | ||
loadScript("https://htmeditor.com/js/tinymce/tinymce.min.js", load_js_callback) | ||
|
||
//}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is where language files should be placed. | ||
|
||
Please DO NOT translate these directly use this service: https://www.transifex.com/projects/p/tinymce/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.