diff --git a/README.md b/README.md index c97a73d..f60eb32 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,9 @@ Export with its' linked sub-notes to Obsidian: Use customized templates to import data from items/notes!  -[Template Usage](./TemplateUsage.md) +[Learn more about template](./Template.md) -Find templates contributed by the community here: [Template Market](https://github.com/windingwind/zotero-better-notes/issues/85) +See what templates can do and find templates contributed by the community here: [Template Market](https://github.com/windingwind/zotero-better-notes/issues/85) ## Auto-Sync to Files diff --git a/TemplateDoc.md b/TemplateDoc.md index ddb5ed5..8cf3ad6 100644 --- a/TemplateDoc.md +++ b/TemplateDoc.md @@ -4,6 +4,28 @@ This documentation is like a dictionary. For beginners, see [template usage](./T Use `Ctrl+F` to look up what you need and make your own template! +## Stages + +Some type of templates(Item, Note) support stages. + +Code wrapped inside the stage will be called at a specific time. + +For example, the `beforeloop` stage code: + +```js +// @beforeloop-begin +code; +// @beforeloop-end +``` + +| stage | calling time | +| ---------- | --------------------------------- | +| beforeloop | before entering the loop of items | +| default | loop of items | +| beforeloop | after leaving the loop of items | + +In other type of templates, the default stage is called. + ## Variables ### QuickInsert @@ -32,11 +54,15 @@ Use `Ctrl+F` to look up what you need and make your own template! ### Item -> variables: topItem +> beforeloop stage: items, copyNoteImage, editor, sharedObj +> default stage: topItem, itemNotes, copyNoteImage, editor, sharedObj +> afterloop stage: items, copyNoteImage, editor, sharedObj ### Note -> variables: topItem, noteItem, link +> beforeloop stage: notes, copyNoteImage, editor, sharedObj +> default stage: noteItem, topItem, link, copyNoteImage, editor, sharedObj +> afterloop stage: notes, copyNoteImage, editor, sharedObj ## Formats @@ -176,7 +202,7 @@ Required Variable: None. ### Table -Description: +Description: | Table | Column1 | Column2 | | ---- | ---- | ---- | | 00 | 01 | 02 | @@ -188,37 +214,21 @@ Required Variable: None. ```html
|
- Table - |
- - Column1 - | -- Column2 - | +
+ Table + |
+ Column1 | +Column2 |
|---|---|---|---|---|---|
| - 00 - | -- 01 - | -- 02 - | +00 | +01 | +02 |
| - 10 - | -- 11 - | -- 12 - | +|||
| 10 | +11 | +12 |
- ${(() => { + $ + {(() => { if (topItem.itemType === "conferencePaper") { return; topItem.getField("conferenceName") || @@ -321,7 +332,8 @@ Required Variable: topItem. ```js
- ${topItem + $ + {topItem .getCreators() .map((v) => v.firstName + " " + v.lastName) .join("; ")} @@ -392,7 +404,8 @@ Required Variable: topItem. ```js
- ${((topItem) => { + $ + {((topItem) => { const getPDFLink = (_item) => { let libraryID = _item.libraryID; let library = Zotero.Libraries.get(libraryID); diff --git a/src/events.ts b/src/events.ts index 404cba4..19527b5 100644 --- a/src/events.ts +++ b/src/events.ts @@ -1419,7 +1419,7 @@ class AddonEvents extends AddonBase { let renderredTemplate = await this._Addon.template.renderTemplateAsync( message.content.params.templateName, - "items, copyNoteImage, editor, sharedObj", + "notes, copyNoteImage, editor, sharedObj", [notes, copyNoteImage, editor, sharedObj], true, "beforeloop"