editor.html
8.47 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<section>
<h1 class="blue" data-id="#plugins/editor"><i class="ace-icon fa fa-text-height grey"></i> Editor</h1>
<div class="hr hr-double hr32"></div>
<!-- #section:plugins/editor -->
<!-- #section:plugins/editor.wysiwyg -->
<div class="help-content">
<h3 class="info-title smaller" data-id="#plugins/editor.wysiwyg">Wysiwyg Editor</h3>
<div class="info-section">
<ul class="info-list list-unstyled">
<li>
For more info about wysiwyg plugin, please see its page at:
<a href="http://mindmup.github.io/bootstrap-wysiwyg/">http://mindmup.github.io/bootstrap-wysiwyg/</a>
</li>
<li>
To use it, you should include:
<br />
<code>assets/js/jquery.hotkeys.js</code>
<br />
<code>assets/js/bootstrap-wysiwyg.js</code>
</li>
<li>
For ease of use I have made a wrapper for it and some extra options
</li>
<li>
A basic example is as follows:
<pre data-language="html">
<div id="my-editor"><!-- custom html data --></div>
</pre>
<pre data-language="javascript">
$('#my-editor').ace_wysiwyg();
</pre>
</li>
</ul>
</div>
<h3 class="info-title smaller">Options</h3>
<div class="info-section">
<ul class="info-list list-unstyled">
<li>
Current ace_wysiwyg wrapper options are:
<ol>
<li><code>wysiwyg</code> options to send to the plugin</li>
<li><code>speech_button</code> whether to add speech input button in Chrome</li>
<li><code>toolbar</code> an array of toolbar buttons and options</li>
<li><code>toolbar_place</code> optional toolbar placement function</li>
</ol>
For example the following creates a wyswiwyg with 3 toolbar buttons:
<pre data-language="javascript">
$('#my-editor').ace_wysiwyg({
toolbar: {
'bold',
'italic',
null,
{
name: 'font',
title: 'Custom tooltip',
values: ['Some Font!', 'Arial', 'Verdana', 'Comic Sans MS', 'Custom Font!']
}
}
});
</pre>
</li>
<li>
As you can see each toolbar button, is a string or an array of options.
<br />
All buttons have the following properties:
<ol>
<li><code>title</code> which is button's tooltip text</li>
<li><code>icon</code> which is button's icon</li>
<li><code>className</code> which is button's class name</li>
</ol>
</li>
<li>
A <code>null</code> value puts a separator(space) between buttons.
</li>
<li>
Toolbar buttons and options are as follows:
<ol>
<li><code>font</code> which takes an array as font names:
<pre data-language="javascript">
{
name: 'font',
title: 'optional custom tooltip',
icon: 'fa-leaf', //some custom icon
values: ['Some Font!', 'Arial', 'Verdana', 'Comic Sans MS', 'Custom Font!']
}
</pre>
</li>
<li><code>fontSize</code> which takes an array as font sizes:
<pre data-language="javascript">
{
name: 'fontSize',
title: 'optional custom tooltip',
values:{1 : 'Size#1' , 2 : 'Size#2' , 3 : 'Size#3' , 4 : 'Size#4' , 5 : 'Size#5'}
}
</pre>
</li>
<li><code>bold</code>:
<pre data-language="javascript">
'bold',
//or
{
name: 'bold',
title: 'optional custom tooltip',
icon: 'fa-leaf' //some custom icon
}
</pre>
</li>
<li><code>italic</code></li>
<li><code>strikethrough</code></li>
<li><code>underline</code></li>
<li><code>insertunorderedlist</code></li>
<li><code>insertorderedlist</code></li>
<li><code>outdent</code></li>
<li><code>indent</code></li>
<li><code>justifyleft</code></li>
<li><code>justifycenter</code></li>
<li><code>justifyright</code></li>
<li><code>justifyfull</code></li>
<li><code>createLink</code> which inserts a link:
<pre data-language="javascript">
{
name: 'createLink',
title: 'optional custom tooltip',
placeholder: 'link input placeholder',
button_class: 'btn-purple',//insert button's class
button_text: 'Add Link'//insert button's text
}
</pre>
</li>
<li><code>unlink</code></li>
<li><code>insertImage</code> which inserts an image:
<pre data-language="javascript">
{
name: 'createLink',
title: 'optional custom tooltip',
placeholder: 'image url input placeholder',
button_insert_class: 'btn-purple',//insert button's class
button_insert: 'Add Link',//insert button's text
choose_file: true,//'Whether there should be a "Choose File" button
button_class: 'btn-success',//choose button's class
button_text: 'Choose an Image'//choose button's text
}
</pre>
</li>
<li>
<code>foreColor</code> and <code>backColor</code>
which have a list of color values:
<pre data-language="javascript">
{
name: 'foreColor',
title: 'optional custom tooltip',
values: ['red', 'blue', '#FF7721']
}
</pre>
</li>
<li><code>undo</code></li>
<li><code>redo</code></li>
<li><code>viewSource</code></li>
</ol>
</li>
<li>
For an example please see <code>examples/wysiwyg.html</code>
</li>
<li>
By default toolbar is placed before content area.
Using <code>toolbar_place</code> you can put the toolbar somewhere else:
<pre data-language="javascript">
$('#editor2').css({'height':'200px'}).ace_wysiwyg({
toolbar_place: function(toolbar) {
//for example put the toolbar inside '.widget-header'
return $(this).closest('.widget-box')
.find('.widget-header').prepend(toolbar)
.find('.wysiwyg-toolbar').addClass('inline');
}
});
</pre>
It should return the new toolbar
</li>
<li>
Add <code>.wysiwyg-style1</code> and <code>.wysiwyg-style2</code>
to toolbar for alternative styles:
<pre data-language="javascript">
$('#editor2').ace_wysiwyg().prev().addClass('wysiwyg-style2');
</pre>
</li>
</ul>
</div>
<h3 class="info-title smaller">Notes</h3>
<div class="info-section">
<ul class="info-list list-unstyled">
<li>
Normally you want to send the contents of wysiwyg editor to server.
<div class="space-4"></div>
Most plugins convert a textarea element into a wysiwyg editor,
by hiding the textarea and creating an editable DIV or iframe,
and updating textarea's content as needed.
<div class="space-4"></div>
You can use the following method to send html content to server along with form data:
<pre data-language="javascript">
$('#myform').on('submit', function() {
var hidden_input =
$('<input type="hidden" name="my-html-content" />')
.appendTo('#myform');
var html_content = $('#myeditor').html();
hidden_input.val( html_content );
//put the editor's HTML into hidden_input and it will be sent to server
});
</pre>
</li>
<li>
Firefox by default supports image resize inside wyswiwyg editor.
<br />
For other browsers you can use jQuery UI's resizable feature.
<br />
An example is included in wysiwyg demo page:
<br />
<code data-open-file="javascript" class="open-file"><span class="brief-show">mustache/app/views/assets/scripts/</span>wysiwyg.js</code>
<br />
Search for <code>enableImageResize</code> function inside it
</li>
</ul>
</div>
</div>
<!-- /section:plugins/editor.wysiwyg -->
<div class="space-12"></div>
<!-- #section:plugins/editor.markdown -->
<div class="help-content">
<h3 class="info-title smaller" data-id="#plugins/editor.markdown">Markdown Editor</h3>
<div class="info-section">
<ul class="info-list list-unstyled">
<li>
For more info about markdown editor plugin, please see its page at:
<a href="http://toopay.github.io/bootstrap-markdown/">http://toopay.github.io/bootstrap-markdown/</a>
</li>
<li>
To use markdown editor you should include
<code>assets/js/markdown/markdown.js</code>
and
<code>assets/js/markdown/bootstrap-markdown.js</code>
and optionally
<code>assets/js/bootbox.js</code>
if you prefer bootstrap modals to default browser dialogs
</li>
<li>
For better styling you should put it inside a widget box
<pre data-language="html">
<div class="widget-box widget-color-blue">
<div class="widget-header widget-header-small"></div>
<div class="widget-body">
<div class="widget-main no-padding">
<textarea name="content" data-provide="markdown" rows="10"></textarea>
</div>
</div>
</div>
</pre>
</li>
<li>
By specifying <code>data-provide="markdown"</code> attribute for the textarea element,
markdown editor will automatically be initiated.
</li>
</ul>
</div>
</div>
<!-- /section:plugins/editor.markdown -->
<!-- /section:plugins/editor -->
</section>