New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Note templates issues #177
Comments
There are 3 types of template you could access from menu: Text, Item, and Note. Item and Note templates requires user to select items/notes as input. Generally speaking, the templates will be inserted after the cursor line in the main note if the workspace is open. You could still run a template outside the workspace. That way you would get the result in clipboard. Note that only inserting to the workspace directly guarantees the template runs corrrectly. Some annotation-related templates may not work properly via clipboard. |
I see. Indeed it seems to work only in the Main Note. Also, I find the access from the menu -> Edit a bit confusing, as it does really show where it is going to be inserted. I guess it is related to the ability to copy the template to the clipboard. Would it be possible to insert templates also from a right click in the note? I was testing the "[Item] collect annotations by color". It seems that it cannot collect the annotations made from outside Zotero and later imported to Zotero. I guess this is because they do not have the standard Zotero colour. Should they be collected in "Other colours"? For the template on annotation, can you control completely the format on how they are inserted, or do you simply use the same format as described here? For example, I have seen this post in the Forums asking to get the annotation as: When you insert a note template, is it possible to get it dynamically updated in some way? For example to keep refreshing when new annotations are added? Constantly refreshing is probably overkill, but maybe inserting the template in an imbedded frame with a refresh button at the top right corner? I keep seeing some popup window that do not disappear, like "Running Template". I am not sure why it is not going away? |
It is so because I want to realize it quickly. If we know which note is working on and focused, it is possible to work in other notes.
Yes, I agree.
Yes. That's planned. In this way, we could allow templates to insert into other notes outside the workspace.
OK.
Yes, you are right. adding a new row to collect other colours is easy. Template: Click to expand${await new Promise(async (r) => {
async function getAnnotation(item) {
try {
if (!item || !item.isAnnotation()) {
return null;
}
let json = await Zotero.Annotations.toJSON(item);
json.id = item.key;
delete json.key;
for (let key in json) {
json[key] = json[key] || "";
}
json.tags = json.tags || [];
return json;
} catch (e) {
Zotero.logError(e);
return null;
}
}
async function getAnnotationsByColor(_item, colorFilter) {
const annots = _item
.getAnnotations()
.filter(colorFilter);
let annotations = [];
for (let annot of annots) {
const annotJson = await getAnnotation(annot);
annotJson.attachmentItemID = _item.id;
annotations.push(annotJson);
}
const editor =
await Zotero.Knowledge4Zotero.knowledge.getWorkspaceEditorInstance();
await editor.importImages(annotations);
return Zotero.EditorInstanceUtilities.serializeAnnotations(annotations);
}
const attachments = Zotero.Items.get(topItem.getAttachments()).filter((i) =>
i.isPDFAttachment()
);
let res = "";
let colors = ["#ffd400", "#ff6666", "#5fb236", "#2ea8e5", "#a28ae5"];
let colorYellow = colors[0];
let colorRed = colors[1];
let colorGreen = colors[2];
let colorBlue = colors[3];
let colorPerple = colors[4];
for (let attachment of attachments) {
res += `<h2><p style="background-color:${colorYellow};">Yellow Heading</p></h2>
${(await getAnnotationsByColor(attachment, (_annot) => _annot.annotationColor === colorYellow)).html}
`;
res += `<h2><p style="background-color:${colorRed };">Red Heading</p></h2>
${(await getAnnotationsByColor(attachment, (_annot) => _annot.annotationColor === colorRed)).html}
`;
res += `<h2><p style="background-color:${colorGreen };">Green Heading</p></h2>
${(await getAnnotationsByColor(attachment, (_annot) => _annot.annotationColor === colorGreen)).html}
`;
res += `<h2><p style="background-color:${colorBlue };">Blue Heading</p></h2>
${(await getAnnotationsByColor(attachment, (_annot) => _annot.annotationColor === colorBlue)).html}
`;
res += `<h2><p style="background-color:${colorPerple };">Perple Heading</p></h2>
${(await getAnnotationsByColor(attachment, (_annot) => _annot.annotationColor === colorPerple)).html}
`;
res += `<h2><p>Others Heading</p></h2>
${(await getAnnotationsByColor(attachment, (_annot) => !colors.includes(_annot.annotationColor))).html}
`;
}
r(res);
})}
Yes. Zotero already does this, so we do not need to do it twice. However, it is also allowed if you do want to give the annotations a different format.
No. It only handles the Zotero note. Citing things in an MD file outside Zotero is totally different. However, if you mean citing items in Zotero notes, that's quite possible. We could discuss that in a new thread.
Hard to say, at least, it is not possible right now. The result of the template can change dramatically because it has no limit. Some templates even rely on time or other variables, making things more complex.
That's because the template is still running (the template can be a code sometimes, that's why it may take some time to search the library or process data), or the running process may meet some errors. Just click to hide it. |
@mjthoraval |
You can preview the insert anchor in the right-click menu now(in next release). |
Thank you very much. I confirm that the code for a adding other colours is working. I can also add templates in any notes now. |
Yes, you can edit the template freely. res += `<h2><p style="background-color:${colorPerple };">Perple Heading</p></h2> to res += `<h2><p style="background-color:${colorPerple };">Purple Heading or anything you like</p></h2>
No. System templates (name in yellow) might be updated in the future with a new name, like the 'QuickNoteV2' to 'QuickNoteV3'. The old template is always kept, though they are no longer being used. Other templates are maintained by the user and will not be modified, removed, or reset by the plugin. |
I have a similar question (so I hope it's ok to add to this issue, rather than creating an effective duplicate). I think this is a great addition to zotero, so thank you for the work on it (obviously the extra complexity of function brings challenges!)
At this stage, nothing seems to happen? I see the 'running template' message, but I can't see anything being inserted anywhere. I have successfully run one of the other templates (by colour). Expected behaviour: Tag 1 Item metadata Tag 2 (if I'd selected one) Am I doing something wrong or misunderstanding how this should work? |
I've updated the plugin and some default templates, as well as ones that require active note editors in #85. They should be OK now. Some templates are out-of-dated and wrongly set the variable |
@sjgknight Does it work if you first open the Workspace in a tab by clicking on "Open Workspace" above "My Library", and leave that Workspace tab opened? @windingwind Even with Release 0.7.15 of the plugin, I am still getting the same behaviour as reported in the other thread. The only way to get the same behaviour: the Workspace must be opened in a Zotero tab before I can use the template "[Item] collect annotations by color". See the screen recording. |
@mjthoraval
|
I have made a copy-paste of the new code, and it is working now. Thank you. Do you have the updated version also for the collect annotations by tag template? |
I do this for system templates(marked yellow). They cannot be removed, you can only reset them. When updating system templates, I use another name, like QuickNoteV2 to QuickNoteV3 in case user have important modifications on them. Other templates are not related to the core functions, so they can be deleted.
Yes, I've updated it as well. Does it work? |
Replace the |
Yes, the collect annotations by tag template is also working. I have also tested the title with |
Thanks for the video, can confirm I do have the workspace open, but it still doesn't work (looks like what you had when it wasn't open @mjthoraval ). The 'collect items by tag' function does work, but the annotations are links not pastes (and, 'no results' items are included). But both the [Item] collect annotations and notes by tag and [Item] collect item-notes by tag seperately, just give me the message popup. In the debug I can see a few things like 'Unregistering notifier observer in notifier with id 'collectionTree_Ii'' and 'Unregistering notifier observer in notifier with id 'itemTreeView_y5'' but they're both also present for the functioning template. Is it possible that this is because what I'm trying to do is select notes/annotations that are tagged, rather than tags on their parent items? I've tried both using the saved-search (which lets me select just my notes+parent-item), and selected everything in that library and then using the relevant tag, and neither works. Thanks |
@sjgknight |
@windingwind thanks! I did upstate just before I tried this afternoon (using the inbuilt update functions not any reinstall) and the results are per above |
@sjgknight Could you please show me the template you are using? Copy the content from Edit-Note Template Editor. |
@windingwind absolutely, it's this one (but as above, I've tried a couple of others just copy-pasting from the list of community templates).
|
@sjgknight seem like you are not using the latest template. please copy paste the updated ones from #85 |
@windingwind I wish that'd been it! I've checked with the updated template (thanks, I hadn't noticed these had changed), but I still get the same problem. (Btw I also just changed this line, log said previous filename function is depreciated) Sorry this is probably a separate issue now, I'm happy to open a fresh issue and if there's anything I can do to setup something reproducible/output useful logs, I'd appreciate any help. |
@sjgknight |
@windingwind I've tried both ways. I'm pasting debug log for the right click approach here. I just selected everything in the library except the standalone notes. This master note/workspace is within that library. I know the tag exists on a number of notes where I have used the "add annotation to note" function.
|
@sjgknight seem like you have directly selected pdf attachments, rather than Zotero items. Could you please check if it works when only Zotero items(item with metadata) selected? |
@windingwind I'm not selecting pdf attachments (except indirectly maybe), the annotations are all in notes attached to items, and the notes themselves are tagged (but not the parent items). I just ran it again with 1 parent item selected where I know there is an attached note with the relevant tag.
|
Here is a possible reason: you don't need to call |
@windingwind thank you, that has fixed that so I now get content! I appreciate the help 👍 |
@sjgknight This template only inserts notes as link. If you want to embed the whole note, we could have further discussions in a new issue. |
I do not understand how the note templates features should be used. The options Insert Template from the Edit menu seem to be visible from everywhere. But they do not do anything most of the time.
Could you help me clarify how it should be used? From where to where, what should be opened in order to work? What does it take as an entry and what is the target? Does it work on an individual annotation, or is it only accessible from the item level? Is it only working from the Workspace? Or should I have a note opened to have anything to happen?
The text was updated successfully, but these errors were encountered: