34
34
}
35
35
)
36
36
$ ( "#wmd-button-row #wmd-fullscreen-button" ) . before ( `
37
+ <li class="wmd-button custom" id="b-wmd-title" title="插入标题">
38
+ <svg t="1632494349172" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2457" width="64" height="64"><path d="M256 213.333333h104.874667v267.093334h324.48V213.333333h104.874666v640h-104.874666v-283.264H360.874667V853.333333H256z" p-id="2458" fill="#707070"></path></svg>
39
+ </li>
37
40
<li class="wmd-button custom" id="b-wmd-linecode" title="行内代码">
38
41
<svg t="1630835908894" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5268" width="60" height="60"><path d="M539.584 217.92c8.192-20.48 28.8-28.8 49.28-20.48 20.544 8.192 32.896 28.736 28.8 49.28v4.096l-164.352 493.12v4.096c-8.256 20.48-28.8 28.8-49.28 20.48-20.608-8.192-32.896-28.736-28.8-49.28v-4.096L539.52 222.08v-4.16z m163.52-12.288c16.384-16.448 36.928-16.448 53.376-4.16l4.096 4.16 246.592 246.528 4.096 4.096c12.352 16.448 12.352 36.992 0 49.28l-4.096 4.16-246.592 246.528-4.096 4.096c-16.448 12.352-36.992 12.352-49.28 0l-4.096-4.096-4.16-4.096c-12.288-16.448-12.288-36.992 0-49.28l4.16-4.16 217.728-217.792-217.728-217.728-4.16-4.16c-12.288-16.384-12.288-36.928 4.16-53.376zM260.16 205.632a39.68 39.68 0 0 1 57.536 0c16.448 16.448 16.448 36.992 4.096 53.376l-4.096 4.16L99.84 480.896l217.792 217.792c16.448 16.448 16.448 36.992 4.096 53.44l-4.096 4.096c-16.448 16.448-36.992 16.448-53.44 4.096l-4.096-4.096L13.632 509.696c-16.448-16.448-16.448-36.992-4.16-53.44l4.16-4.096 246.528-246.528z" fill="#909399" p-id="5269"></path></svg>
39
42
</li>
@@ -135,10 +138,10 @@ $("#wmd-button-row #wmd-fullscreen-button").before(`
135
138
$ ( "#b-wmd-md-link" ) . on ( "click" , function ( ) {
136
139
$ ( "#ui-datepicker-div" ) . after ( `
137
140
<div class="wmd-prompt-dialog" style="top: 45%;" role="dialog">
138
- <div><p><b>插入链接</b></p><p>请在下方的输入框内输入要插入的链接地址和标题</p></div>
141
+ <div><p><b>插入链接(markdown通用格式) </b></p><p>请在下方的输入框内输入要插入的链接地址和标题</p></div>
139
142
<form>
140
143
链接描述:<input type="text" name="link-title">
141
- 链接地址:<input type="text" name="link-link" value="https://">
144
+ 链接地址:<input type="text" name="link-link" value="https://" onfocus="this.select();" >
142
145
<button type="button" class="btn btn-s primary btn-ok">确定</button>
143
146
<button type="button" class="btn btn-s btn-cancel">取消</button></form>
144
147
</div>` ) ;
@@ -153,10 +156,10 @@ $(".btn-ok").click(function(){
153
156
$ ( "#b-wmd-md-img" ) . on ( "click" , function ( ) {
154
157
$ ( "#ui-datepicker-div" ) . after ( `
155
158
<div class="wmd-prompt-dialog" style="top: 45%;" role="dialog">
156
- <div><p><b>插入图片</b></p><p>请在下方的输入框内输入要插入的图片链接地址和标题</p></div>
159
+ <div><p><b>插入图片(markdown通用格式) </b></p><p>请在下方的输入框内输入要插入的图片链接地址和标题</p></div>
157
160
<form>
158
161
图片描述:<input type="text" name="img-title">
159
- 图片地址:<input type="text" name="img-link" value="https://">
162
+ 图片地址:<input type="text" name="img-link" value="https://" onfocus="this.select();" >
160
163
<button type="button" class="btn btn-s primary btn-ok">确定</button>
161
164
<button type="button" class="btn btn-s btn-cancel">取消</button></form>
162
165
</div>
@@ -173,7 +176,7 @@ $("#b-wmd-linecode").on("click",function() {
173
176
<div class="wmd-prompt-dialog" role="dialog">
174
177
<div><p><b>插入行内代码</b></p></div>
175
178
<form>
176
- 填写内行代码:<input type="text" name="insert-linecode" value="内行代码">
179
+ 填写内行代码:<input type="text" name="insert-linecode" value="内行代码" onfocus="this.select();" >
177
180
<input type="text" style="display:none;">
178
181
<button type="button" class="btn btn-s primary btn-ok">确定</button>
179
182
<button type="button" class="btn btn-s btn-cancel">取消</button></form>
@@ -241,7 +244,7 @@ $(".btn-ok").click(function(){
241
244
let href = $ ( 'input[name="insert-href"]' ) . val ( ) ;
242
245
let contents = $ ( 'input[name="insert-contents"]' ) . val ( ) ;
243
246
let ico = $ ( 'input[name="insert-ico"]' ) . val ( ) ;
244
- insertAtCursor ( '\n[btn href="' + href + '" type="' + type + '' + color + '' + position + '" ico="' + ico + '"]' + contents + '[/btn]\n' ) ;
247
+ insertAtCursor ( '\n[btn href="' + href + '" type="' + type + ' ' + color + '' + position + '" ico="' + ico + '"]' + contents + '[/btn]\n' ) ;
245
248
} ) ;
246
249
} ) ;
247
250
// note
@@ -334,6 +337,25 @@ $(".btn-ok").click(function(){
334
337
insertAtCursor ( '\n!!!\n' + htmlcode + '\n!!!\n' ) ;
335
338
} ) ;
336
339
} ) ;
340
+
341
+ // 标题插入
342
+ $ ( "#b-wmd-title" ) . on ( "click" , function ( ) {
343
+ $ ( "#ui-datepicker-div" ) . after ( `
344
+ <div class="wmd-prompt-dialog" role="dialog">
345
+ <div><p><b>标题插入</b></p></div>
346
+ <form>
347
+ 标题选择:<select id="select-title"><option selected="selected"value="#">h1(默认)</option><option value="##">h2</option><option value="###">h3</option><option value="####">h4</option><option value="#####">h5</option><option value="######">h6</option></select><br/>
348
+ <input type="text" name="my-title" placeholder="标题名">
349
+ <button type="button" class="btn btn-s primary btn-ok">确定</button>
350
+ <button type="button" class="btn btn-s btn-cancel">取消</button></form>
351
+ </div>` ) ;
352
+ $ ( ".btn-ok" ) . click ( function ( ) {
353
+ let titleType = $ ( '#select-title option:selected' ) . val ( ) ;
354
+ let getTitle = $ ( 'input[name="my-title"]' ) . val ( ) ;
355
+ insertAtCursor ( '' + titleType + '' + getTitle + '\n' ) ;
356
+ } ) ;
357
+ } ) ;
358
+
337
359
// 复选框
338
360
$ ( "#b-wmd-wcheakbox" ) . on ( "click" , function ( ) {
339
361
$ ( "#ui-datepicker-div" ) . after ( `
@@ -407,9 +429,10 @@ $("#ui-datepicker-div").after(`
407
429
<div><p><b>说明</b></p></div>
408
430
<hr>
409
431
<p>这是一款兼容typecho原ui的md编辑器</p>
410
- <p>采用typcho同款弹窗生成器 </p>
432
+ <p>采用typecho同款弹窗生成器 </p>
411
433
<p>未来将更新更多内容....</p>
412
434
<p>如有bug或者建议欢迎去<a href="https://github.com/wehaox/Typecho-Butterfly/issues">GitHub</a>向我反馈或者加群:218796706</p>
435
+ <p>有GitHub的同学帮忙点个start,谢谢了🌹</p>
413
436
<button type="button" class="btn btn-s primary btn-ok">确定</button>
414
437
<button type="button" class="btn btn-s btn-cancel">取消</button></form>
415
438
</div>
@@ -434,7 +457,7 @@ $(".btn-ok").click(function(){
434
457
insertAtCursor ( ' [label color="' + color + '"]' + contents + '[/label] ' ) ;
435
458
} ) ;
436
459
} ) ;
437
- $ ( "#b-wmd-linecode,#b-wmd-code,#b-wmd-reply,#b-wmd-nhtml,#b-wmd-wcheakbox,#b-wmd-inline-tag,#b-wmd-radio,#b-wmd-md-link,#b-wmd-md-img,#b-wmd-mark,#b-wmd-btn,#b-wmd-note,#b-wmd-hide-block,#b-wmd-hide-inline,#b-wmd-hide-toggle,#b-wmd-note-ico,#b-wmd-md-explain" ) . click ( function ( ) {
460
+ $ ( "#b-wmd-linecode,#b-wmd-code,#b-wmd-reply,#b-wmd-nhtml,#b-wmd-wcheakbox,#b-wmd-inline-tag,#b-wmd-radio,#b-wmd-md-link,#b-wmd-md-img,#b-wmd-mark,#b-wmd-btn,#b-wmd-note,#b-wmd-hide-block,#b-wmd-hide-inline,#b-wmd-hide-toggle,#b-wmd-note-ico,#b-wmd-md-explain,#b-wmd-title " ) . click ( function ( ) {
438
461
var y = document . createElement ( "div" ) ;
439
462
let height = document . body . scrollHeight ;
440
463
z = y . style ;
@@ -449,8 +472,6 @@ z.left = "0";
449
472
document . body . appendChild ( y ) ;
450
473
$ ( ".btn-cancel,.btn-ok" ) . click ( function ( ) { $ ( ".wmd-prompt-dialog,.wmd-prompt-background" ) . remove ( ) ; } ) ;
451
474
} ) ;
452
-
453
-
454
475
var text = document . getElementById ( 'text' ) ;
455
476
var insert = document . getElementById ( 'insert' ) ;
456
477
function insertAtCursor ( myValue , myField = $ ( '#text' ) [ 0 ] ) {
0 commit comments