TOOLS为非官方社区,欢迎一起建设,答疑群:717421103

版本260427.1

全站通知:

常用编辑摘要

阅读

    

2026-03-15更新

    

最新编辑:Lu_23333

阅读:

  

更新日期:2026-03-15

  

最新编辑:Lu_23333

来自ToolsWIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索
页面贡献者 :
Lu_23333
亚衣琴

可以配合修改MediaWiki:Summary,增加一个快捷栏,允许用户点击按钮填充编辑说明,如图所示。

示例-常用编辑摘要.png

点击对应文本,即可快速填充编辑摘要。对于简单的修改非常方便。

示例可以参考


这个功能需要JS支持。可以将下列JS加入全站JS(MediaWiki:Common.js):

/*
* 特性支持: 快捷编辑理由。支持编辑摘要时,点击快捷选项填充编辑理由
* 参考Wikipedia:MediaWiki:Common.js/edit.js 转换为无需JQuery的写法
*/
function fast_edit_summary_btn() {
  if (window.fast_edit_summary_btn_loaded) return; // 避免重复加载
  window.fast_edit_summary_btn_loaded = true;

  if (RLCONF.wgAction == "edit" || RLCONF.wgAction == "submit" || RLCONF.wgCanonicalSpecialPageName == 'Search') { // 编辑页面
    var wpSectionInput = document.querySelector('#editform input[name="wpSection"]');
    
    if (wpSectionInput && wpSectionInput.value === 'new') {
        if (document.getElementById('no-new-title')) {
            document.getElementById('wpSummary').setAttribute('disabled', 'disabled');
        }
        return;
    }

    var presetContainer = document.querySelector('#wpSummaryLabel .mw-summary-preset');
    if (presetContainer) {
        presetContainer.addEventListener('click', function(e) {
            if (e.target && e.target.matches('.mw-summary-preset-item a')) {
                e.preventDefault();
                
                var summaryInput = document.getElementById('wpSummary');
                var summary = summaryInput.value;
                var item = e.target.closest('.mw-summary-preset-item');
                
                summary = summary.replace(/\s+$/g, '');
                if (summary !== '') {
                    summary += ' ';
                }
                
                summary += item.getAttribute('title') || e.target.textContent;
                
                summaryInput.value = summary;
                summaryInput.focus();
            }
        });
    }
  }/* end if 'wgAction'*/
}/* end function */
if (document.readyState === "loading") {
  document.addEventListener("DOMContentLoaded", fast_edit_summary_btn);
} else {
  fast_edit_summary_btn();
}
/* end 特性支持: 快捷编辑理由 */