-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
120 lines (99 loc) · 1.93 KB
/
script.js
File metadata and controls
120 lines (99 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var editor = ace.edit("editor");
editor.getSession().setMode("ace/mode/html");
editor.setFontSize("15px");
editor.setPrintMarginColumn(false);
editor.insert(document.getElementById("sample").value);
editor.setOptions({
maxLines: 20
});
document.getElementById('md').innerHTML =
marked(editor.getValue());
// some new chnages
editor.session.on('change', function(delta) {
document.getElementById('md').innerHTML =
marked(editor.getValue());
});
function insertBold()
{
editor.insert("**Bold Text** ");
}
function insertItalic()
{
editor.insert("*italicized text* ");
}
function insertStrike()
{
editor.insert("~~ Strikethrough ~~ ");
}
function insertLink()
{
editor.insert("[title](https://www.example.com) ");
}
function insertQoute()
{
editor.insert(`
> blockquote `);
}
function insertCode()
{
editor.insert("`code` ");
}
function insertBullets()
{
editor.insert(`
- First item
- Second item
- Third item
`);
}
function insertNumList()
{
editor.insert(`
1. First item
2. Second item
3. Third item
`);
}
function insertHeading()
{
editor.insert("# add consequent # to reduce size");
}
function insertHr()
{
editor.insert(`
-------------------
`);
}
function insertUndo()
{
editor.undo();
}
function insertClear()
{
editor.setValue("");
}
function insertRedo()
{
editor.redo();
}
function dynamic_text() {
var x = document.getElementById('md');
var s= x.innerHTML;
return s;
}
function download_file(name, contents, mime_type) {
mime_type = mime_type || "text/html";
var blob = new Blob([contents], { type: mime_type });
var dlink = document.createElement("a");
dlink.download = name;
dlink.href = window.URL.createObjectURL(blob);
dlink.onclick = function(e) {
// revokeObjectURL needs a delay to work properly
var that = this;
setTimeout(function() {
window.URL.revokeObjectURL(that.href);
}, 1500);
};
dlink.click();
dlink.remove();
}