windingwind / zotero-better-notes

Everything about note management. All in Zotero.
GNU Affero General Public License v3.0
5.11k stars 182 forks source link

[Bug] Zotero和Obsidian双向同步笔记时报错:Template [ExportMDFileNameV2] Error: TypeError: noteItem.parentItem is undefined #994

Closed Jenny-Qiu-941 closed 2 months ago

Jenny-Qiu-941 commented 2 months ago

Is there an existing issue for this?

Are you using the latest Zotero and the latest plugin?

Environment

Describe the bug

已经用Zotero和Obsidian实现双向同步,近日点击同步笔记时,出现报错信息: Template [ExportMDFileNameV2] Error: TypeError: noteItem.parentItem is undefined 之后右下角显示Betternotes报错: Sync Error:Unix error 1 during operation delete on file /Users/jennyq/Documents/Obsidian/OB/思想文化研究(Operation not permitted)

image

在Obsidian中查看,笔记可以正常从zotero同步到Obsidian。 尝试在Obsidian修改笔记,之后zotero同步,发现无法从obsidian同步到zotero,点击同步之后产生的报错信息和上面相同。也就是说无法实现双向同步了。

附上相关的templates: ExportMDFileNameV2的为: ${noteItem.parentItem.getField('firstCreator').split(" ",1).slice(0)}_${noteItem.parentItem.getField('date')?noteItem.parentItem.getField('date').substring(0, 4):""}_${noteItem.parentItem.getField("title").split(" ").slice(0,4).join("_")}.md 我自己用于同步obsidian的笔记模版为: [Item] 球球论文阅读模版-md // @新奥尔良烤乳猪 // @use-markdown

${topItem.getField('firstCreator').split(" ",1).slice(0)}${topItem.getField('date')?topItem.getField('date').substring(0, 4):""}${topItem.getField("title").split(" ").slice(0,4).join("_")}

File:: [${topItem.firstCreator}, ${topItem.getField("year")}](${await new Promise(async (resolve) => { async function getPDFLink(item) { const att = await item.getBestAttachment(); if (!att || !att.isPDFAttachment()) { return ""; } key = att.key; if (att.libraryID === 1) { return zotero://open-pdf/library/items/${key}; } else { groupID = Zotero.Libraries.get(att.libraryID).id; return zotero://open-pdf/groups/${groupID}/items/${key}; } } resolve(await getPDFLink(topItem)); })})
PubTags:: ${

(() => { let space = " " return Array.prototype.map.call(Zotero.ZoteroStyle.data.ztoolkit.ItemTree.globalCache.renderCellHooks.PublicationTags( 0, Zotero.ZoteroStyle.data.ztoolkit.ItemTree.fieldHooks.globalCache.getFieldHooks.PublicationTags( "", true, true, topItem, undefined) ).childNodes, e => { e.innerText = e.innerText; return e.outerHTML }).join(space) })() }
Citation:: ${Math.max(parseInt(topItem.getField("extra").match(/GSCC:\s(.?)($|\n)/) ? topItem.getField("extra").match(/GSCC:\s(.?)($|\n)/)[1] : 0), parseInt(topItem.getField("extra").match(/👍(.?)(?=[)/) ? topItem.getField("extra").match(/👍(.?)(?=[)/)[1] : 0))}
Author:: ${topItem.getCreators().map((v)=>v.firstName+" "+v.lastName).join("; ")}
Year:: ${topItem.getField('year')}
IF:: ==${topItem.getField('libraryCatalog')}==
DOI:: ${topItem.getField("DOI")}
Journal:: ${topItem.getField('publicationTitle')}
journalAbbreviation:: ${topItem.getField('journalAbbreviation')}
Publisher:: ${topItem.getField('publisher')}
Keywords:: ${topItem.getField('keywordsAll')}
titleTrans:: ${ (topItem.getField("extra").match(/titleTranslation:\s(.?)($|\n)/) ? topItem.getField("extra").match(/titleTranslation:\s(.?)($|\n)/)[0]:"").replace(/(\r\n)|(\n)/g,"").split(":").slice(1)}
Abstract:: ${topItem.getField('abstractNote')}
abstractTrans:: ${ (topItem.getField("extra").match(/abstractTranslation:\s(.?)($|\n)/) ? topItem.getField("extra").match(/abstractTranslation:\s(.?)($|\n)/)[0]:"").replace(/(\r\n)|(\n)/g,"").split(":").slice(1)}

Tips~填写时记得空一格!!
Summary::
Object::
Question::
Model::
Theory::
Scholar::
Method::
Tool::
Type::
Gap::
Limitation::
Contribution::
Future::
Insight::

截图:

image

Debug Output

(3)(+0008021): WebSocket message: {"event":"topicUpdated","topic":"/users/10245386","version":120386}

(3)(+0000001): Library is already up to date

(4)(+0000503): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [28491, 'https://kns.cnki.net/kcms2/article/abstract?v=2dRWw02s3kx20ag5zrfcUm1j9tXP_yJBueziloOaHTHV7kc69vWOHHBgmK3bmL_-M80mhZh1YZsclMQu-IYUt8ypK27lILF8g6EWRC-1YOeu2IOP8jCPdjBmDu-ldTXu&uniplatform=NZKPT&language=gb']

(3)(+0000014): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000000): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000000): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000002): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000001): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000002): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000001): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000000): [Zotero Better Notes] [Warning] Creating element button with no namespace specified. Found multiply namespace matches.

(3)(+0000624): [Zotero Better Notes] sync start manual-editor [{"key":"TJZQFZYL","version":92027,"itemType":"note","parentItem":"KZHKNR22","note":"<div data-citation-items=\"%5B%7B%22uris%22%3A%5B%22http%3A%2F%2Fzotero.org%2Fusers%2F10245386%2Fitems%2FKZHKNR22%22%5D%2C%22itemData%22%3A%7B%22id%22%3A%22http%3A%2F%2Fzotero.org%2Fusers%2F10245386%2Fitems%2FKZHKNR22%22%2C%22type%22%3A%22chapter%22%2C%22container-title%22%3A%22Moving%20Boundaries%20in%20Translation%20Studies%22%2C%22edition%22%3A%221%22%2C%22event-place%22%3A%22London%22%2C%22ISBN%22%3A%22978-1-315-12187-1%22%2C%22language%22%3A%22en%22%2C%22note%22%3A%22DOI%3A%2010.4324%2F9781315121871%5Cnrate%3A%203%22%2C%22page%22%3A%221-11%22%2C%22publisher%22%3A%22Routledge%22%2C%22publisher-place%22%3A%22London%22%2C%22title%22%3A%22Moving%20boundaries%20in%20translation%20studies%3A%20introduction%22%2C%22editor%22%3A%5B%7B%22family%22%3A%22Dam%22%2C%22given%22%3A%22Helle%20V.%22%7D%2C%7B%22family%22%3A%22Br%C3%B8gger%22%2C%22given%22%3A%22Matilde%20Nisbeth%22%7D%2C%7B%22family%22%3A%22Zethsen%22%2C%22given%22%3A%22Karen%20Korning%22%7D%5D%2C%22author%22%3A%5B%7B%22family%22%3A%22Dam%22%2C%22given%22%3A%22Helle%20V.%22%7D%2C%7B%22family%22%3A%22Br%C3%B8gger%22%2C%22given%22%3A%22Matilde%20Nisbeth%22%7D%2C%7B%22family%22%3A%22Zethsen%22%2C%22given%22%3A%22Karen%20Korning%22%7D%5D%2C%22issued%22%3A%7B%22date-parts%22%3A%5B%5B%222018%22%2C10%2C11%5D%5D%7D%7D%7D%5D\" data-schema-version=\"8\">

Dam_2018_Moving_boundaries_in_translation

\n
\n

File:: <a href=\"zotero://open-pdf/library/items/JBLTII3I\" rel=\"noopener noreferrer nofollow\">Dam 等, 2018
PubTags::
Author:: Helle V. Dam; Matilde Nisbeth Brøgger; Karen Korning Zethsen; Helle V. Dam; Matilde Nisbeth Brøgger; Karen Korning Zethsen
Year:: 2018
IF:: ====
DOI::
Journal::
journalAbbreviation::
Keywords::
titleTrans::
Abstract::
abstractTrans::

\n
\n
\n

Tips~填写时记得空一格!!
Summary::
Object::
Question::
Model::
Theory::
Scholar::
Method::
Tool::
Type::
Gap::
Limitation::
Contribution::
Future::
Insight::

\n
\n

发展

\n

语际翻译和符际翻译是近期关注的焦点。

\n

本书的论文讨论翻译研究的移动的边界。

\n

概念创新

\n

Moving conceptual boundaries: so what? - Chetserman

\n

文中讨论了概念创新,新的范畴和名称的创造,并且提出了其运作的四种方式。

\n

platypus concepts:遇到新的实证现象时可能会提出新的概念。

\n

splitter concepts/lumper concepts:源自新的观看问题的学术方式的概念。

\n

rebranding concepts:将新的术语应用于已有概念。

\n

概念不是穷尽式的,彼此之间可能也有重合。

\n

对于概念的评判,不应以对错为标准,而应基于其实用性usefulness。

\n

sub-disciplinary movements

\n

Localisation research in translation studies: expanding the limits or blurring the lines? - Jiménez-Crespo

\n

localisation的概念可以被理解为是rebranding concept、platypus concept,也可以是splitter/lumper concept。

\n

作者从lumper concept的视角进行讨论,考察翻译和本地化之间的相似性。

\n

作者认为作为上级学科的翻译研究和子学科本地化正在日趋融合(界限模糊),同时也相互影响。

\n

Moving boundaries in interpreting - Pöchhacker

\n

也是从lumper concept的视角讨论,口译和翻译存在相似性。

\n

<span class=\"highlight\" data-annotation=\"%7B%22attachmentURI%22%3A%22http%3A%2F%2Fzotero.org%2Fusers%2F10245386%2Fitems%2FJBLTII3I%22%2C%22annotationKey%22%3A%22E46WHQQ3%22%2C%22color%22%3A%22%235fb236%22%2C%22pageLabel%22%3A%224%22%2C%22position%22%3A%7B%22pageIndex%22%3A3%2C%22rects%22%3A%5B%5B323.86%2C475.757%2C388.05%2C487.047%5D%2C%5B64%2C463.257%2C157.732%2C474.547%5D%5D%7D%2C%22citationItem%22%3A%7B%22uris%22%3A%5B%22http%3A%2F%2Fzotero.org%2Fusers%2F10245386%2Fitems%2FKZHKNR22%22%5D%2C%22locator%22%3A%224%22%7D%7D\"><span style=\"background-color: #5fb23680\">“all machine interpreting is in fact translation” <span class=\"citation\" data-citation=\"%7B%22citationItems%22%3A%5B%7B%22uris%22%3A%5B%22http%3A%2F%2Fzotero.org%2Fusers%2F10245386%2Fitems%2FKZHKNR22%22%5D%7D%5D%2C%22properties%22%3A%7B%7D%7D\">(<span class=\"citation-item\">Dam 等, (中间省略很多类似的输出) %2Fzotero.org%2Fusers%2F10245386%2Fitems%2FP26HBF3X%22%5D%2C%22locator%22%3A%2215%22%7D%7D\">“叙述学研究” <span class=\"citation\" data-citation=\"%7B%22citationItems%22%3A%5B%7B%22uris%22%3A%5B%22http%3A%2F%2Fzotero.org%2Fusers%2F10245386%2Fitems%2FP26HBF3X%22%5D%2C%22locator%22%3A%2215%22%7D%5D%2C%22properties%22%3A%7B%7D%7D\">(<span class=\"citation-item\">杨胜刚 和 黄灯, 2016, p. 15)

\n

\n
","tags":[{"tag":"连环画"},{"tag":"叙事"},{"tag":"形象建构"}],"relations":{},"dateAdded":"2024-05-20T16:10:23Z","dateModified":"2024-06-01T02:47:12Z"}] 0

(3)(+0000356): [Zotero Better Notes] {"operation":"read","path":"/Users/jennyq/Documents/Obsidian/OB/思想文化研究","unixErrno":21}

(3)(+0000011): [Zotero Better Notes] will be synced: {"/Users/jennyq/Documents/Obsidian/OB/多模态":[29196],"/Users/jennyq/Documents/Obsidian/OB/思想文化研究":[30111]} [] []

(3)(+0000017): [Zotero Better Notes] runTemplate: [ExportMDFileNameV2]

(3)(+0000001): [Zotero Better Notes] 王文新_2016_文学作品绘画改编中的语—图互文研究——以丰子恺《漫画阿Q正传》为例.md

(3)(+0000073): [Zotero Better Notes] runTemplate: [ExportMDFileHeaderV2]

(4)(+0000001): SELECT collectionID FROM collections WHERE collectionID IN (SELECT collectionID FROM collectionItems WHERE itemID=?) [28491]

(3)(+0000004): [Zotero Better Notes] {"tags":["改编","连环画","叙事"],"parent":"文学作品绘画改编中的语—图互文研究——以丰子恺《漫画阿Q正传》为例","collections":["改编相关"]}

(3)(+0000008): [Zotero Better Notes] runTemplate: [ExportMDFileNameV2]

(3)(+0000000): [Zotero Better Notes] {}

(3)(+0001628): [Zotero Better Notes] runTemplate: [ExportMDFileHeaderV2]

(4)(+0000001): SELECT collectionID FROM collections WHERE collectionID IN (SELECT collectionID FROM collectionItems WHERE itemID=?) [30111]

(3)(+0000044): [Zotero Better Notes] {"tags":["人道主义","思想史"],"parent":"","collections":["0 Main Notes","80年代连环画人道主义话语"]}

(3)(+0000005): [Zotero Better Notes] {"operation":"delete","path":"/Users/jennyq/Documents/Obsidian/OB/思想文化研究","unixErrno":1}

Anything else?

No response

windingwind commented 2 months ago

使用的ExportMDFileNameV2模板有问题,不应假定笔记存在parentItem,因此当同步独立笔记(standalone note)时生成文件名报错。不清楚你从何处获得的这个模板,建议向其作者反馈修改。

Jenny-Qiu-941 commented 2 months ago

使用的ExportMDFileNameV2模板有问题,不应假定笔记存在parentItem,因此当同步独立笔记(standalone note)时生成文件名报错。不清楚你从何处获得的这个模板,建议向其作者反馈修改。

好的,非常感谢~

pengxy0 commented 2 months ago

zotero和obsidian的笔记可以通过better notes双向同步了吗?记得之前是尽量别在ob那边修改笔记的

Jenny-Qiu-941 commented 2 months ago

zotero和obsidian的笔记可以通过better notes双向同步了吗?记得之前是尽量别在ob那边修改笔记的

可以的,我是参考https://github.com/windingwind/zotero-better-notes/discussions/611#discussion-5497766

Jenny-Qiu-941 commented 2 months ago

自己鼓捣了一下,已经解决。解决方法:修改模版[ExportMDFileNameV2]为官方的: ${(noteItem.getNoteTitle ? noteItem.getNoteTitle().replace(/[/\\?%*:|"<> ]/g, "-") : "")}.md (在官方基础上删去了一些部分~) 感谢大佬的指导!! @windingwind

pengxy0 commented 2 months ago

自己鼓捣了一下,已经解决。解决方法:修改模版[ExportMDFileNameV2]为官方的: ${(noteItem.getNoteTitle ? noteItem.getNoteTitle().replace(/[/\\?%*:|"<> ]/g, "-") : "")}.md (在官方基础上删去了一些部分~) 感谢大佬的指导!! @windingwind

你好,我用zotcard做的笔记模板,可以用吗?我现在是不是就用你这个模板把[ExportMDFileNameV2]官方的替换掉就行了?

Jenny-Qiu-941 commented 2 months ago

自己鼓捣了一下,已经解决。解决方法:修改模版[ExportMDFileNameV2]为官方的: ${(noteItem.getNoteTitle ? noteItem.getNoteTitle().replace(/[/\\?%*:|"<> ]/g, "-") : "")}.md (在官方基础上删去了一些部分~) 感谢大佬的指导!! @windingwind

你好,我用zotcard做的笔记模板,可以用吗?我现在是不是就用你这个模板把[ExportMDFileNameV2]官方的替换掉就行了?

你可以试试!我这个和官方的差不多的~

pengxy0 commented 2 months ago

自己鼓捣了一下,已经解决。解决方法:修改模版[ExportMDFileNameV2]为官方的: ${(noteItem.getNoteTitle ? noteItem.getNoteTitle().replace(/[/\\?%*:|"<> ]/g, "-") : "")}.md (在官方基础上删去了一些部分~) 感谢大佬的指导!! @windingwind

你好,我用zotcard做的笔记模板,可以用吗?我现在是不是就用你这个模板把[ExportMDFileNameV2]官方的替换掉就行了?

你可以试试!我这个和官方的差不多的~

好的,感谢,试了下,大致可以的