github MuiseDestiny/zotero-style 2.4.2
2.4.2: 作者/Creator - 自定义显示;一些优化

latest releases: 5.2.0, 5.1.8, 5.1.4...
20 months ago
  • Creator增加列设置
  • 优化progress列数据存储,优化带来的卡顿
  • GPT结果可以选中复制
  • 优化因为关系图谱setInterval未清理导致的Zotero仍有后台bug
  • 修改视图组切换圆点颜色

自定义作者教程

此功能可以在首选项关闭,对应按钮为:Creator

image

第一作者+最后一位作者
image

一作+二作
image

slices由多个slice组成,一个slice将以:拆分成参数传给Creators.slice(...slice.split(":")),多个slice,隔开,多组slice结果将concat合并成一个newCreators。并以join传入的字符串连接。

具体代码:

const creators = item.getCreators() as any
const firstCreator = item.firstCreator as string;
const format = Zotero.Prefs.get(`${config.addonRef}.creatorColumn.format`) as string
const join = Zotero.Prefs.get(`${config.addonRef}.creatorColumn.join`) as string
let slices = Zotero.Prefs.get(`${config.addonRef}.creatorColumn.slices`) as string
let newCreators: any = []
try {
  slices.split(/,\s*/).forEach((slice: string) => {            
    newCreators = newCreators.concat(
      creators.slice(...slice.split(":").filter(i => i.trim().length).map(i => Number(i)))
    )
  })
} catch { return cellSpan}
let textArray = []
for (let i = 0; i < newCreators.length; i++) {
  textArray.push(
    format
      .replace(/\$\{firstName\}/g, newCreators[i].firstName)
      .replace(/\$\{lastName\}/g, newCreators[i].lastName)
      .replace(/\$\{firstCreator\}/g, firstCreator)
  )
}
cellSpan.innerText = textArray.join(join)

image

Don't miss a new zotero-style release

NewReleases is sending notifications on new releases.