|
|
第136行: |
第136行: |
| }) | | }) |
| </script></html>}} | | </script></html>}} |
− |
| |
− | == customized edit toolbar ==
| |
− |
| |
− | <html><style>
| |
− | #lnnblog-edittoolbar {
| |
− | font-size: 0.75rem;
| |
− | background: #f9f9f9;
| |
− | border: 1px solid #ddd;
| |
− | width: fit-content;
| |
− | padding: 2px;
| |
− | margin-bottom: 2px;
| |
− | border-radius: 3px;
| |
− | }
| |
− | #lnnblog-edittoolbar div {
| |
− | display: inline-block;
| |
− | margin-right: 0.25rem;
| |
− | }
| |
− | #lnnblog-edittoolbar button {
| |
− | margin-right: 1px;
| |
− | font-size: inherit;
| |
− | line-height: 1.25;
| |
− | }
| |
− | </style><script>
| |
− | $( function () {
| |
− |
| |
− | /* 重新定义编辑工具栏 */
| |
− | if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
| |
− | var $newToolbar = $( '<div id="lnnblog-edittoolbar" lang="zh-cmn-Hans">' )
| |
− | var $group = null
| |
− |
| |
− | function addButton( label, title, before, after, sample ) {
| |
− | $group.append( $( "<button>" )
| |
− | .attr( "type", "button" )
| |
− | .attr( "class", "lnnblog-button-small" )
| |
− | .attr( "title", title )
| |
− | .append( $( "<tt>" ).text( label ) )
| |
− | .on( "mousedown", false ) // 防止焦点离开文本框
| |
− | .click( mw.toolbar.insertTags.bind(mw.toolbar, before, after || "", sample || "") ) )
| |
− | }
| |
− | function newGroup() {
| |
− | $group = $( '<div>' ).appendTo( $newToolbar )
| |
− | }
| |
− |
| |
− | newGroup()
| |
− | addButton( "[[]]", "内链", "[[", "]]" )
| |
− | addButton( "lelink", "英文内链", "{{lelink|", "}}" )
| |
− | addButton( "{{|}}", "模板调用", "{{|", "}}" )
| |
− | newGroup()
| |
− | addButton( "le", "英文文本", "{{le|", "}}" )
| |
− | addButton( "lj", "逻辑语文本", "{{lj|", "}}" )
| |
− | addButton( "lang", "文本语言", "{{lang|und|", "}}" )
| |
− | newGroup()
| |
− | addButton( "h2", "二级标题", "== ", " ==" )
| |
− | addButton( "h3", "三级标题", "=== ", " ===" )
| |
− | newGroup()
| |
− | addButton( "table", "wikitable 表格", "{|class=wikitable\n! ", "\n|-\n|\n|}" )
| |
− | addButton( "box", "box 模板", "{{box|标题|2=\n", "\n}}" )
| |
− | addButton( "hidebox", "hidebox 模板", "{{hidebox|标题|2=\n", "\n}}" )
| |
− | newGroup()
| |
− | addButton( "nw", "nowiki 标签", "<nowiki>", "</nowiki>" )
| |
− | addButton( "nw/", "空 nowiki 标签", "<nowiki/>" )
| |
− | addButton( "code", "行内代码", "{{code|", "}}" )
| |
− | addButton( "pre", "pre 块", "<pre>\n", "\n</pre>" )
| |
− | addButton( "syntax", "代码高亮块", "<syntaxhighlight lang=javascript>\n", "\n</syntaxhighlight>" )
| |
− | newGroup()
| |
− | addButton( "subst", "模板替代", "{{subst:", "}}" )
| |
− | addButton( "pn", "当前页面名称", mw.config.get( 'wgTitle' ) )
| |
− | addButton( "fpn", "带名字空间的当前页面名称", mw.config.get( 'wgPageName' ) )
| |
− | newGroup()
| |
− | addButton( "Cat", "分类", "[[分类:", "]]" )
| |
− | addButton( "SORT", "默认排序字", "{{DEFAULTSORT:", "}}", mw.config.get( "wgTitle" ) )
| |
− | newGroup()
| |
− | addButton( "<!--", "HTML 注释", "<!--", "-->" )
| |
− | addButton( "ni", "noinclude 标签", "<noinclude>", "</noinclude>" )
| |
− | addButton( "ni/", "空 noinclude 标签", "<noinclude/>", "" )
| |
− | addButton( "io", "includeonly 标签", "<includeonly>", "</includeonly>" )
| |
− | addButton( "oi", "onlyinclude 标签", "<onlyinclude>", "</onlyinclude>" )
| |
− | newGroup()
| |
− | addButton( "html", "原始 HTML 块", "{{MywikiParaHack|<html>", "<\/html>}}" )
| |
− | addButton( "/html", "反向原始 HTML 标签", "<\/html>", "<html>" )
| |
− | addButton( "script", "script 标签", "<script>\n", "\n<\/script>" )
| |
− | addButton( "style", "style 标签", "<style>\n", "\n</style>" )
| |
− |
| |
− | $( "#ydnedittoolbar" ).parent().replaceWith( $newToolbar )
| |
− | }
| |
− |
| |
− | } )
| |
− | </script></html>
| |