Site Notice

hello, world

InPageEdit-v2/SDK

From Project-EPB Commons
< InPageEdit-v2
Revision as of 22:56, 23 November 2019 by 机智的小鱼君 (talk | contribs) ([InPageEdit] 没有编辑摘要 (第6部分))

快速编辑

InPageEdit.edit(options)

  • options: {object}
    • page: 必须;编辑的页面名
    • revision: 修订版本号,如果与当前页面版本号不同则取代
    • section: 编辑的段落编号

最基础的调用

InPageEdit.edit({
  page: mw.config.get('wgPageName')
});

<html><button onclick="InPageEdit.edit({

 page: mw.config.get('wgPageName')

});">测试</button></html>

快速重定向

InPageEdit.redirect(type)

  • type: string(to,from)
    • from 重定向页面至此
    • to 将此页面重定向到

最基础的调用

InPageEdit.redirect('from');
InPageEdit.redirect('to');

<html><button onclick="InPageEdit.redirect('from')">测试from</button> <button onclick="InPageEdit.redirect('to')">测试to</button></html>

快速删除

InPageEdit.deletepage()

快速重命名

InPageEdit.renamepage()

InPageEdit设置

InPageEdit.preference()

  • 打开设置窗口

<html><button onclick="InPageEdit.preference()">InPageEdit.preference()</button></html>

比较差异

InPageEdit.quickDiff(options)

  • options: {object}
    • fromtitle: First title to compare.
    • fromid: First page ID to compare. Type: integer
    • fromrev: First revision to compare. Type: integer
    • fromtext: Use this text instead of the content specified by fromtitle, fromid or fromrev.
    • frompst: Do a pre-save transform on fromtext. Type: boolean
    • <code">totitle: Second title to compare.
    • toid: Second page ID to compare. Type: integer
    • torev: Second revision to compare. Type: integer
    • torelative: Compare to a relative revision of fromtitle, fromid or fromrev. All the other "to" options will be ignored. Possible values: prev, next, cur
    • totext: Use this text instead of the content specified by totitle, toid, torev, or torelative.
    • topst: Do a pre-save transform on totext. Type: boolean

最简单的示例,比较本页面最后一次修改

InPageEdit.quickDiff({
  fromtitle: mw.config.get('wgPageName'),
  torelative: 'prev'
});

<html><button onclick="InPageEdit.quickDiff({

 fromtitle: mw.config.get('wgPageName'),
 torelative: 'prev'

});">测试</button></html>

添加编辑链接

InPageEdit.articleLink()

示例

在编辑链接后添加快速编辑链接

此示例代码已在Vector、Timeless以及Hydra皮肤上测试可用

$(function(){
  $('#ca-view').after(
    $('<li>',{
      id:'ca-quick-edit',
      class:'collapsible'
    }).append(
      $('<span>').append(
        $('<a>',{
          href: 'javascript:void(0)'
        })
        .text('快速编辑')
        .click(function(){
          InPageEdit.edit({
            page: mw.config.get('wgPageName'),
            revision: mw.config.get('wgRevisionId')
          });
        })
      )
    )
  );
});