add: template editor snippets

This commit is contained in:
windingwind 2024-09-12 08:17:26 +00:00
parent 8efc32b78c
commit 5caced3578
8 changed files with 694 additions and 0 deletions

View File

@ -133,6 +133,37 @@
-moz-default-appearance: -moz-mac-help-button;
min-width: 0;
}
#snippets-container {
display: flex;
flex-wrap: wrap;
gap: 4px;
padding: 4px;
}
.snippet {
border: var(--material-panedivider);
border-radius: 4px;
cursor: pointer;
font-size: 0.916666667em;
line-height: 1.272727273;
overflow: hidden;
padding: 1px 4px;
text-overflow: ellipsis;
white-space: pre;
box-sizing: border-box;
color: var(--fill-primary);
}
.snippet.syntax {
background-color: color-mix(in srgb, var(--accent-yellow) 50%, transparent 50%);
}
.snippet.expression {
background-color: color-mix(in srgb, var(--accent-green) 50%, transparent 50%);
}
.snippet.variable {
background-color: color-mix(in srgb, var(--accent-azure) 50%, transparent 50%);
}
.snippet:hover {
background-color: var(--fill-quinary);
}
</style>
<link
rel="stylesheet"
@ -192,6 +223,7 @@
onmousedown="this.focus()"
></iframe>
</div>
<div id="snippets-container"></div>
</xul:hbox>
<xul:splitter
state="open"

View File

@ -44,3 +44,80 @@ restore =
.label = Restore from backup file
help =
.label = Help
snippet-useMarkdown = use markdown
.title = Parse the template as markdown
snippet-useRefresh = use refresh
.title = Allow the content generated by the template to be refreshed
snippet-inlineScript = inline script
.title = Add an inline JS script, the result of which will be embedded in the note
snippet-multiLineScript = multi-line script
.title = Add a multi-line async JS script, the return value of which will be embedded in the note
snippet-dryRunFlag = dry run flag
.title = Check if the template is running in dry run mode, e.g. for preview. In dry run mode, the script should not have side effects.
snippet-itemBeforeLoop = before loop
.title = Content to be rendered before the loop of items
snippet-itemInLoop = in loop
.title = Content to be rendered for each item in the loop
snippet-itemAfterLoop = after loop
.title = Content to be rendered after the loop of items
snippet-itemItems = items
.title = Type: Zotero.Item[]. The array of items to be rendered, available in beforeLoop and afterLoop stage
snippet-itemItem = item
.title = Type: Zotero.Item. The current item to be rendered, available in inLoop stage
snippet-itemTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `item`, available in inLoop stage
snippet-itemTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached, available in any stage
snippet-itemCopyNoteImage = copy note image
.title = Type: Function. Copy the image of the note to the clipboard, available in any stage
snippet-itemSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data across different stages
snippet-itemFieldTitle = title
.title = Type: string. The title of the top item
snippet-itemFieldAbstract = abstract
.title = Type: string. The abstract of the top item
snippet-itemFieldCitKey = citation key
.title = Type: string. The citation key of the top item
snippet-itemFieldDate = date
.title = Type: string. The publication date of the top item
snippet-itemFieldDOI = DOI
.title = Type: string. The DOI of the top item
snippet-itemFieldDOIURL = DOI or URL
.title = Type: string. The DOI or URL of the top item
snippet-itemFieldAuthors = authors
.title = Type: string. The authors of the top item
snippet-itemFieldJournal = journal
.title = Type: string. The journal of the top item
snippet-itemFieldTitleTranslation = title translation
.title = Type: string. The title translation of the top item
snippet-textTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-textSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data
snippet-quickInsertLink = note link
.title = Type: string. The link of the note item to be linked
snippet-quickInsertLinkText = link text
.title = Type: string. The default label of the link
snippet-quickInsertSubNoteItem = linked note
.title = Type: Zotero.NoteItem. The note item to be linked to
snippet-quickInsertNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickImportLink = note link
.title = Type: string. The link of the note item to be imported
snippet-quickImportNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickNoteAnnotationItem = annotation
.title = Type: Zotero.AnnotationItem. The annotation item to be converted to a note
snippet-quickNoteTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `annotationItem`
snippet-quickNoteNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-exportMDFileNameNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileHeaderNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentMDContent = markdown content
.title = Type: string. The markdown content to be exported

View File

@ -44,3 +44,80 @@ restore =
.label = Ripristina da file di backup
help =
.label = Aiuto
snippet-useMarkdown = use markdown
.title = Parse the template as markdown
snippet-useRefresh = use refresh
.title = Allow the content generated by the template to be refreshed
snippet-inlineScript = inline script
.title = Add an inline JS script, the result of which will be embedded in the note
snippet-multiLineScript = multi-line script
.title = Add a multi-line async JS script, the return value of which will be embedded in the note
snippet-dryRunFlag = dry run flag
.title = Check if the template is running in dry run mode, e.g. for preview. In dry run mode, the script should not have side effects.
snippet-itemBeforeLoop = before loop
.title = Content to be rendered before the loop of items
snippet-itemInLoop = in loop
.title = Content to be rendered for each item in the loop
snippet-itemAfterLoop = after loop
.title = Content to be rendered after the loop of items
snippet-itemItems = items
.title = Type: Zotero.Item[]. The array of items to be rendered, available in beforeLoop and afterLoop stage
snippet-itemItem = item
.title = Type: Zotero.Item. The current item to be rendered, available in inLoop stage
snippet-itemTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `item`, available in inLoop stage
snippet-itemTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached, available in any stage
snippet-itemCopyNoteImage = copy note image
.title = Type: Function. Copy the image of the note to the clipboard, available in any stage
snippet-itemSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data across different stages
snippet-itemFieldTitle = title
.title = Type: string. The title of the top item
snippet-itemFieldAbstract = abstract
.title = Type: string. The abstract of the top item
snippet-itemFieldCitKey = citation key
.title = Type: string. The citation key of the top item
snippet-itemFieldDate = date
.title = Type: string. The publication date of the top item
snippet-itemFieldDOI = DOI
.title = Type: string. The DOI of the top item
snippet-itemFieldDOIURL = DOI or URL
.title = Type: string. The DOI or URL of the top item
snippet-itemFieldAuthors = authors
.title = Type: string. The authors of the top item
snippet-itemFieldJournal = journal
.title = Type: string. The journal of the top item
snippet-itemFieldTitleTranslation = title translation
.title = Type: string. The title translation of the top item
snippet-textTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-textSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data
snippet-quickInsertLink = note link
.title = Type: string. The link of the note item to be linked
snippet-quickInsertLinkText = link text
.title = Type: string. The default label of the link
snippet-quickInsertSubNoteItem = linked note
.title = Type: Zotero.NoteItem. The note item to be linked to
snippet-quickInsertNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickImportLink = note link
.title = Type: string. The link of the note item to be imported
snippet-quickImportNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickNoteAnnotationItem = annotation
.title = Type: Zotero.AnnotationItem. The annotation item to be converted to a note
snippet-quickNoteTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `annotationItem`
snippet-quickNoteNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-exportMDFileNameNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileHeaderNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentMDContent = markdown content
.title = Type: string. The markdown content to be exported

View File

@ -44,3 +44,80 @@ restore =
.label = Restore from backup file
help =
.label = Помощь
snippet-useMarkdown = use markdown
.title = Parse the template as markdown
snippet-useRefresh = use refresh
.title = Allow the content generated by the template to be refreshed
snippet-inlineScript = inline script
.title = Add an inline JS script, the result of which will be embedded in the note
snippet-multiLineScript = multi-line script
.title = Add a multi-line async JS script, the return value of which will be embedded in the note
snippet-dryRunFlag = dry run flag
.title = Check if the template is running in dry run mode, e.g. for preview. In dry run mode, the script should not have side effects.
snippet-itemBeforeLoop = before loop
.title = Content to be rendered before the loop of items
snippet-itemInLoop = in loop
.title = Content to be rendered for each item in the loop
snippet-itemAfterLoop = after loop
.title = Content to be rendered after the loop of items
snippet-itemItems = items
.title = Type: Zotero.Item[]. The array of items to be rendered, available in beforeLoop and afterLoop stage
snippet-itemItem = item
.title = Type: Zotero.Item. The current item to be rendered, available in inLoop stage
snippet-itemTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `item`, available in inLoop stage
snippet-itemTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached, available in any stage
snippet-itemCopyNoteImage = copy note image
.title = Type: Function. Copy the image of the note to the clipboard, available in any stage
snippet-itemSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data across different stages
snippet-itemFieldTitle = title
.title = Type: string. The title of the top item
snippet-itemFieldAbstract = abstract
.title = Type: string. The abstract of the top item
snippet-itemFieldCitKey = citation key
.title = Type: string. The citation key of the top item
snippet-itemFieldDate = date
.title = Type: string. The publication date of the top item
snippet-itemFieldDOI = DOI
.title = Type: string. The DOI of the top item
snippet-itemFieldDOIURL = DOI or URL
.title = Type: string. The DOI or URL of the top item
snippet-itemFieldAuthors = authors
.title = Type: string. The authors of the top item
snippet-itemFieldJournal = journal
.title = Type: string. The journal of the top item
snippet-itemFieldTitleTranslation = title translation
.title = Type: string. The title translation of the top item
snippet-textTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-textSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data
snippet-quickInsertLink = note link
.title = Type: string. The link of the note item to be linked
snippet-quickInsertLinkText = link text
.title = Type: string. The default label of the link
snippet-quickInsertSubNoteItem = linked note
.title = Type: Zotero.NoteItem. The note item to be linked to
snippet-quickInsertNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickImportLink = note link
.title = Type: string. The link of the note item to be imported
snippet-quickImportNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickNoteAnnotationItem = annotation
.title = Type: Zotero.AnnotationItem. The annotation item to be converted to a note
snippet-quickNoteTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `annotationItem`
snippet-quickNoteNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-exportMDFileNameNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileHeaderNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentMDContent = markdown content
.title = Type: string. The markdown content to be exported

View File

@ -44,3 +44,80 @@ restore =
.label = Yedek dosyasından geri yükle
help =
.label = Yardım
snippet-useMarkdown = use markdown
.title = Parse the template as markdown
snippet-useRefresh = use refresh
.title = Allow the content generated by the template to be refreshed
snippet-inlineScript = inline script
.title = Add an inline JS script, the result of which will be embedded in the note
snippet-multiLineScript = multi-line script
.title = Add a multi-line async JS script, the return value of which will be embedded in the note
snippet-dryRunFlag = dry run flag
.title = Check if the template is running in dry run mode, e.g. for preview. In dry run mode, the script should not have side effects.
snippet-itemBeforeLoop = before loop
.title = Content to be rendered before the loop of items
snippet-itemInLoop = in loop
.title = Content to be rendered for each item in the loop
snippet-itemAfterLoop = after loop
.title = Content to be rendered after the loop of items
snippet-itemItems = items
.title = Type: Zotero.Item[]. The array of items to be rendered, available in beforeLoop and afterLoop stage
snippet-itemItem = item
.title = Type: Zotero.Item. The current item to be rendered, available in inLoop stage
snippet-itemTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `item`, available in inLoop stage
snippet-itemTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached, available in any stage
snippet-itemCopyNoteImage = copy note image
.title = Type: Function. Copy the image of the note to the clipboard, available in any stage
snippet-itemSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data across different stages
snippet-itemFieldTitle = title
.title = Type: string. The title of the top item
snippet-itemFieldAbstract = abstract
.title = Type: string. The abstract of the top item
snippet-itemFieldCitKey = citation key
.title = Type: string. The citation key of the top item
snippet-itemFieldDate = date
.title = Type: string. The publication date of the top item
snippet-itemFieldDOI = DOI
.title = Type: string. The DOI of the top item
snippet-itemFieldDOIURL = DOI or URL
.title = Type: string. The DOI or URL of the top item
snippet-itemFieldAuthors = authors
.title = Type: string. The authors of the top item
snippet-itemFieldJournal = journal
.title = Type: string. The journal of the top item
snippet-itemFieldTitleTranslation = title translation
.title = Type: string. The title translation of the top item
snippet-textTargetNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-textSharedObj = shared object
.title = Type: Object. A shared object that can be used to store data
snippet-quickInsertLink = note link
.title = Type: string. The link of the note item to be linked
snippet-quickInsertLinkText = link text
.title = Type: string. The default label of the link
snippet-quickInsertSubNoteItem = linked note
.title = Type: Zotero.NoteItem. The note item to be linked to
snippet-quickInsertNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickImportLink = note link
.title = Type: string. The link of the note item to be imported
snippet-quickImportNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-quickNoteAnnotationItem = annotation
.title = Type: Zotero.AnnotationItem. The annotation item to be converted to a note
snippet-quickNoteTopItem = top item
.title = Type: Zotero.Item. The top-level parent of the variable `annotationItem`
snippet-quickNoteNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to which the template is attached
snippet-exportMDFileNameNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileHeaderNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentNoteItem = target note
.title = Type: Zotero.NoteItem. The note item to be exported
snippet-exportMDFileContentMDContent = markdown content
.title = Type: string. The markdown content to be exported

View File

@ -43,3 +43,80 @@ restore =
.label = 从备份文件恢复
help =
.label = 帮助
snippet-useMarkdown = 使用 markdown
.title = 将模板解析为 markdown
snippet-useRefresh = 允许内容刷新
.title = 允许模板生成的内容刷新
snippet-inlineScript = 内联脚本
.title = 添加一个内联 JS 脚本,其结果将嵌入到笔记中
snippet-multiLineScript = 多行脚本
.title = 添加一个多行异步 JS 脚本,其返回值将嵌入到笔记中
snippet-dryRunFlag = dry run标志
.title = 检查模板是否在dry run模式下运行例如用于预览。在dry run模式下脚本不应有副作用。
snippet-itemBeforeLoop = 循环前
.title = 在条目循环之前渲染的内容
snippet-itemInLoop = 循环中
.title = 为循环中的每个条目渲染的内容
snippet-itemAfterLoop = 循环后
.title = 在条目循环之后渲染的内容
snippet-itemItems = 所有条目
.title = 类型Zotero.Item[]。要渲染的条目数组,可在 beforeLoop 和 afterLoop 阶段使用
snippet-itemItem = 当前条目
.title = 类型Zotero.Item。要渲染的当前条目可在 inLoop 阶段使用
snippet-itemTopItem = 顶级条目
.title = 类型Zotero.Item。变量 `item` 的顶级父级,可在 inLoop 阶段使用
snippet-itemTargetNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。模板插入到的笔记条目可在任何阶段使用
snippet-itemCopyNoteImage = 复制笔记图片
.title = 类型Function。将笔记的图片复制到剪贴板可在任何阶段使用
snippet-itemSharedObj = 共享对象
.title = 类型object。可用于在不同阶段存储数据的共享对象
snippet-itemFieldTitle = 标题
.title = 类型: 字符串。顶级条目的标题。可在 inLoop 阶段使用
snippet-itemFieldAbstract = 摘要
.title = 类型: 字符串。顶级条目的摘要。可在 inLoop 阶段使用
snippet-itemFieldCitKey = citation key
.title = 类型: 字符串。顶级条目的 citation key。可在 inLoop 阶段使用
snippet-itemFieldDate = 日期
.title = 类型: 字符串。顶级条目的发布日期。可在 inLoop 阶段使用
snippet-itemFieldDOI = DOI
.title = 类型: 字符串。顶级条目的DOI。可在 inLoop 阶段使用
snippet-itemFieldDOIURL = DOI或URL
.title = 类型: 字符串。顶级条目的DOI或URL。可在 inLoop 阶段使用
snippet-itemFieldAuthors = 作者
.title = 类型: 字符串。顶级条目的作者。可在 inLoop 阶段使用
snippet-itemFieldJournal = 期刊
.title = 类型: 字符串。顶级条目的期刊。可在 inLoop 阶段使用
snippet-itemFieldTitleTranslation = 标题翻译
.title = 类型: 字符串。顶级条目的标题翻译*需要Translate for Zotero插件。可在 inLoop 阶段使用
snippet-textTargetNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。模板插入到的笔记条目
snippet-textSharedObj = 共享对象
.title = 类型object。可用于存储数据的共享对象
snippet-quickInsertLink = 笔记链接
.title = 类型:字符串。要链接的笔记条目的链接
snippet-quickInsertLinkText = 链接文本
.title = 类型:字符串。链接的默认标签
snippet-quickInsertSubNoteItem = 链接的笔记
.title = 类型Zotero.NoteItem。要链接到的笔记条目
snippet-quickInsertNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。模板插入到的笔记条目
snippet-quickImportLink = 笔记链接
.title = 类型:字符串。要导入的笔记条目的链接
snippet-quickImportNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。模板插入到的笔记条目
snippet-quickNoteAnnotationItem = 注释
.title = 类型Zotero.AnnotationItem。要转换为笔记的注释条目
snippet-quickNoteTopItem = 顶级条目
.title = 类型Zotero.Item。变量 `annotationItem` 的顶级父级
snippet-quickNoteNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。模板插入到的笔记条目
snippet-exportMDFileNameNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。要导出的笔记条目
snippet-exportMDFileHeaderNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。要导出的笔记条目
snippet-exportMDFileContentNoteItem = 目标笔记
.title = 类型Zotero.NoteItem。要导出的笔记条目
snippet-exportMDFileContentMDContent = markdown 内容
.title = 类型:字符串。要导出的 markdown 内容

View File

@ -65,6 +65,7 @@ class Addon {
window?: Window;
tableHelper?: VirtualizedTableHelper;
editor?: any;
monaco?: any;
templates: string[];
};
picker: {

View File

@ -197,6 +197,7 @@ export async function showTemplateEditor() {
language: "javascript",
theme: "vs-" + (isDark ? "dark" : "light"),
});
addon.data.template.editor.monaco = monaco;
addon.data.template.editor.editor = editor;
}
}
@ -278,6 +279,9 @@ function updateEditor() {
const saveTemplate = win?.document.getElementById("save") as XUL.Button;
const deleteTemplate = win?.document.getElementById("delete") as XUL.Button;
const resetTemplate = win?.document.getElementById("reset") as XUL.Button;
const snippets = win?.document.getElementById(
"snippets-container",
) as HTMLDivElement;
if (!name) {
templateType.value = "unknown";
templateType.setAttribute("disabled", "true");
@ -288,6 +292,7 @@ function updateEditor() {
deleteTemplate.setAttribute("disabled", "true");
deleteTemplate.hidden = false;
resetTemplate.hidden = true;
snippets.hidden = true;
} else {
templateType.value = type;
templateName.value = displayName;
@ -307,6 +312,56 @@ function updateEditor() {
editor.hidden = false;
saveTemplate.removeAttribute("disabled");
deleteTemplate.removeAttribute("disabled");
snippets.hidden = false;
updateSnippets(
(type === "system"
? name.slice(1, -1)
: type) as keyof typeof snippetsStore,
);
}
}
async function updateSnippets(type: string) {
const container = addon.data.template.editor.window?.document.querySelector(
"#snippets-container",
);
if (!container) {
return;
}
container.innerHTML = "";
const snippets = snippetsStore[type as keyof typeof snippetsStore].concat(
snippetsStore.global,
);
if (!snippets) {
return;
}
// Add snippets to the container, with each snippet as a button
// Dragging the button to the editor will insert the snippet
for (const snippet of snippets) {
const button = document.createElement("span");
button.classList.add("snippet", snippet.type);
button.dataset.l10nId = `${config.addonRef}-snippet-${snippet.name}`;
button.addEventListener("click", () => {
const { editor, monaco } = addon.data.template.editor;
const selection = editor.getSelection();
const range = new monaco.Range(
selection.startLineNumber,
selection.startColumn,
selection.endLineNumber,
selection.endColumn,
);
const text = snippet.code;
editor.executeEdits("", [
{
range,
text,
forceMoveMarkers: true,
},
]);
});
container.appendChild(button);
}
}
@ -526,3 +581,224 @@ async function restoreTemplates(win: Window) {
}
await refresh();
}
const snippetsStore = {
global: [
{
name: "useMarkdown",
code: "\n// @use-markdown\n",
type: "syntax",
},
{
name: "useRefresh",
code: "\n// @use-refresh\n",
type: "syntax",
},
{
name: "inlineScript",
code: "${ // write your script here }",
type: "syntax",
},
{
name: "multiLineScript",
code: "\n${{\n // write your script here\n}}$\n",
type: "syntax",
},
{
name: "dryRunFlag",
code: "_env.dryRun",
type: "variable",
},
],
item: [
{
name: "itemBeforeLoop",
code: "\n// @beforeloop-begin\n\n// @beforeloop-end\n",
type: "syntax",
},
{
name: "itemInLoop",
code: "\n// @default-begin\n\n// @default-end\n",
type: "syntax",
},
{
name: "itemAfterLoop",
code: "\n// @afterloop-begin\n\n// @afterloop-end\n",
type: "syntax",
},
{
name: "itemItems",
code: "items",
type: "variable",
},
{
name: "itemItem",
code: "item",
type: "variable",
},
{
name: "itemTopItem",
code: "topItem",
type: "variable",
},
{
name: "itemTargetNoteItem",
code: "targetNoteItem",
type: "variable",
},
{
name: "itemCopyNoteImage",
code: "${copyNoteImage(...)}",
type: "expression",
},
{
name: "itemSharedObj",
code: "sharedObj",
type: "variable",
},
{
name: "itemFieldTitle",
code: '${topItem.getField("title")}',
type: "expression",
},
{
name: "itemFieldAbstract",
code: '${topItem.getField("abstractNote")}',
type: "expression",
},
{
name: "itemFieldCitKey",
code: '${topItem.getField("citationKey")}',
type: "expression",
},
{
name: "itemFieldDate",
code: '${topItem.getField("date")}',
type: "expression",
},
{
name: "itemFieldDOI",
code: '${topItem.getField("DOI")}',
type: "expression",
},
{
name: "itemFieldDOIURL",
code: `
\${{
const doi = topItem.getField("DOI");
const url = topItem.getField("url");
if (doi) {
return \`DOI: <a href="https://doi.org/\${doi}">\${doi}</a>\`;
} else {
return \`URL: <a href="\${url}">\${url}</a>\`;
}
}}$
`,
type: "expression",
},
{
name: "itemFieldAuthors",
code: '${topItem.getCreators().map((v)=>v.firstName+" "+v.lastName).join("; ")}',
type: "expression",
},
{
name: "itemFieldJournal",
code: '${topItem.getField("publicationTitle")}',
type: "expression",
},
{
name: "itemFieldTitleTranslation",
code: '${topItem.getField("titleTranslation")}',
type: "expression",
},
],
text: [
{
name: "textTargetNoteItem",
code: "targetNoteItem",
type: "variable",
},
{
name: "textSharedObj",
code: "sharedObj",
type: "variable",
},
],
QuickInsertV2: [
{
name: "quickInsertLink",
code: "link",
type: "variable",
},
{
name: "quickInsertLinkText",
code: "linkText",
type: "variable",
},
{
name: "quickInsertSubNoteItem",
code: "subNoteItem",
type: "variable",
},
{
name: "quickInsertNoteItem",
code: "noteItem",
type: "variable",
},
],
QuickImportV2: [
{
name: "quickImportLink",
code: "link",
type: "variable",
},
{
name: "quickImportNoteItem",
code: "noteItem",
type: "variable",
},
],
QuickNoteV5: [
{
name: "quickNoteAnnotationItem",
code: "annotationItem",
type: "variable",
},
{
name: "quickNoteTopItem",
code: "topItem",
type: "variable",
},
{
name: "quickNoteNoteItem",
code: "noteItem",
type: "variable",
},
],
ExportMDFileNameV2: [
{
name: "exportMDFileNameNoteItem",
code: "noteItem",
type: "variable",
},
],
ExportMDFileHeaderV2: [
{
name: "exportMDFileHeaderNoteItem",
code: "noteItem",
type: "variable",
},
],
ExportMDFileContent: [
{
name: "exportMDFileContentNoteItem",
code: "noteItem",
type: "variable",
},
{
name: "exportMDFileContentMDContent",
code: "mdContent",
type: "variable",
},
],
};