forked from sofish/pen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
153 lines (135 loc) · 5.63 KB
/
index.html
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Pen - What You See Is What You Get (WYSIWYG)</title>
<style type="text/css">
*{padding:0;margin:0;}
html{border-top:10px #1abf89 solid;}
body{width:800px;margin:0 auto;padding:5% 20px 20px;font-family:Palatino, Optima, Georgia, serif;}
@media all and (max-width:1024px){ body, pre a{width:60%;} }
small{color:#999;}
pre{white-space:pre-wrap;}
#toolbar{margin-bottom:1em;position:fixed;left:20px;margin-top:5px;}
#toolbar [class^="icon-"]:before, #toolbar [class*=" icon-"]:before{font-family:'pen'}
#mode{color:#1abf89;;cursor:pointer;}
#mode.disabled{color:#666;}
#mode:before{content: '\e813';}
#hinted{color:#1abf89;cursor:pointer;}
#hinted.disabled{color:#666;}
#hinted:before{content: '\e816';}
#tomd{color:#fff;border-radius:2px;line-height:1;padding:1px 3px 0; font-size:0.8em;background:#000;cursor:pointer;}
#fork{position:fixed;right:0;top:0;}
/*
When the webpage is printed
this media query hides extra elements,
and makes the text content fit the page.
*/
@media print {
#fork, #toolbar {
display: none;
}
body {
width: 94%;
padding-top: 1em;
font-size: 12px;
}
html {
border-top: 0;
}
}
</style>
<link rel="stylesheet" href="src/pen.css" />
</head>
<body>
<div id="toolbar">
<span id="mode" class="icon-mode"></span>
<span id="hinted" class="icon-pre disabled" title="Toggle Markdown Hints"></span>
<span id="tomd" title="to markdown">MD</span>
</div>
<!-- <div id="custom-toolbar" class="pen-menu pen-menu" style="display: block; top: 20px; left: 10px;">
<i class="pen-icon icon-insertimage" data-action="insertimage"></i>
<i class="pen-icon icon-blockquote" data-action="blockquote"></i>
<i class="pen-icon icon-h2" data-action="h2"></i>
<i class="pen-icon icon-h3" data-action="h3"></i>
<i class="pen-icon icon-p active" data-action="p"></i>
<i class="pen-icon icon-code" data-action="code"></i>
<i class="pen-icon icon-insertorderedlist" data-action="insertorderedlist"></i>
<i class="pen-icon icon-insertunorderedlist" data-action="insertunorderedlist"></i>
<i class="pen-icon icon-inserthorizontalrule" data-action="inserthorizontalrule"></i>
<i class="pen-icon icon-indent" data-action="indent"></i>
<i class="pen-icon icon-outdent" data-action="outdent"></i>
<i class="pen-icon icon-bold" data-action="bold"></i>
<i class="pen-icon icon-italic" data-action="italic"></i>
<i class="pen-icon icon-underline" data-action="underline"></i>
<i class="pen-icon icon-createlink" data-action="createlink"></i>
</div> -->
<div data-toggle="pen" data-placeholder="im a placeholder">
<h2>Enjoy live editing (+markdown)</h2>
<p><b><i>Click to edit, Select to apply effect, click items of toolbar to toggle effects.</i></b></p>
<hr>
<p>Horizontal-Rule can be inserted by click「...」on the toolbar or just type「... 」/「--- 」/「*** 」at line start. Note that
there's a SPACE at the end of a command.</p>
<p><img src="https://files.slack.com/files-pri/T02SY1UGK-F02UKR9HH/61fecdffjw1em2euxugtdg208w06okjm.gif" alt="oh my god"/></p>
<hr>
<p>To link or unlink, please press the <i>ENTER</i> key after you filled the input field with your a link. A <a
href="/sofish">link</a> can be unlink by applying an empty value to the input field.
<p>
<ul>
<li>Ordered list and unordered list are supported.</li>
<li>Use the toolbar or use markdown syntax like「<b>1. </b>」,「<b>- </b>」or「<b>* </b>」</li>
</ul>
<blockquote>You can quote text by type「<b>></b>」at line start.</blockquote>
<p>What about add underline to text? "<u>Stay Hungry, Stay Foolish - <i>Steve Jobs</i></u>".</p>
<pre>A code block is also supported by type 「```」 at line start and press SPACE.</pre>
<p>For more, please checkout: <a href="https://github.com/sofish/pen#readme" target="_blank">https://github.com/sofish/pen#readme</a>
</p>
</div>
<a id="fork" href="https://github.com/sofish/pen" target="_blank"><img
src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<script src="src/pen.js"></script>
<script src="src/markdown.js"></script>
<script type="text/javascript">
// config
var options = {
// toolbar: document.getElementById('custom-toolbar'),
editor: document.querySelector('[data-toggle="pen"]'),
debug: true,
list: [
'insertimage', 'blockquote', 'h2', 'h3', 'p', 'code', 'insertorderedlist', 'insertunorderedlist', 'inserthorizontalrule',
'indent', 'outdent', 'bold', 'italic', 'underline', 'createlink'
]
};
// create editor
var pen = window.pen = new Pen(options);
pen.focus();
// toggle editor mode
document.querySelector('#mode').addEventListener('click', function() {
var text = this.textContent;
if(this.classList.contains('disabled')) {
this.classList.remove('disabled');
pen.rebuild();
} else {
this.classList.add('disabled');
pen.destroy();
}
});
// export content as markdown
document.querySelector('#tomd').addEventListener('click', function() {
var text = pen.toMd();
document.body.innerHTML = '<a href="javascript:location.reload()">←back to editor</a><br><br><pre>' + text + '</pre>';
});
// toggle editor mode
document.querySelector('#hinted').addEventListener('click', function() {
var pen = document.querySelector('.pen')
if(pen.classList.contains('hinted')) {
pen.classList.remove('hinted');
this.classList.add('disabled');
} else {
pen.classList.add('hinted');
this.classList.remove('disabled');
}
});
</script>
</body>
</html>