Skip to content
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

[Feature] collect annotations能把框柱的图表也collect进来吗 #1098

Closed
1 task done
fredericky123 opened this issue Aug 25, 2024 · 3 comments
Closed
1 task done
Assignees
Labels
enhancement New feature or request

Comments

@fredericky123
Copy link

fredericky123 commented Aug 25, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Environment

  • OS: Mac
  • Zotero Version: 7.0.2
  • Plugin Version: 2.0.3

Describe the feature request

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
根据颜色添加注释时,能添加annotation,但是自己框住的图却没加进来,不知如何解决?
如下图
image

Why do you need this feature?
A clear and concise description of why you need this feature.
给图做注释也很重要,希望在提取的笔记中有所体现

Describe the solution you'd like

The solution you'd like
A clear and concise description of what you want to happen.

Alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Anything else?

非常感谢

@fredericky123 fredericky123 added the enhancement New feature or request label Aug 25, 2024
@fredericky123
Copy link
Author

值得是如下自动提取注释的代码:

# This template is specifically for importing/sharing, using better 
# notes 'import from clipboard': copy the content and
# goto Zotero menu bar, click Edit->New Template from Clipboard.  
# Do not copy-paste this to better notes template editor directly.
name: "[Item] gwj1dataview11"
content: |-
  <!-- author:xiehui-->
  <h1><font size="4">${topItem.getField("title")}</font></h1>
  <div><strong>作者</strong>:: ${topItem.getCreators().map((v)=>v.firstName+" "+v.lastName).join("; ")}</div>
  <div><strong>出版年份</strong>:: ${topItem.getField('date')}</div>
  <div><strong>期刊</strong>:: ${topItem.getField('publicationTitle')}</div>
  <div><strong>期刊标签</strong>:: ${{
          let space = " "
          return Array.prototype.map.call(
            Zotero.ZoteroStyle.api.renderCell(topItem, "publicationTags").childNodes,
            e => {
              e.innerText =  space + e.innerText + space;
              return e.outerHTML
            }
            ).join(space)
          }}$</div>
  <div><strong>附件链接</strong>:: <a href="zotero://open-pdf/0_${Zotero.Items.get(topItem.getAttachments())[0].key}">
                  ${Zotero.Items.get(topItem.getAttachments())[0].getFilename()}
              </a></div>
  <div><strong>创新摘要</strong>:: </div>
  
  
  ${await new Promise(async (r) => {
  /*functions */
  	async function getAnnotation(item) {
  		
  		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;
  	}
  
  	async function getAnnotationsByColor(_item, colorFilter) {
  		const annots = _item.getAnnotations().filter(colorFilter);
  		if (annots.length === 0) {
  		  return {
  			html: "",
  		  };
  		}
  		let annotations = [];
  		for (let annot of annots) {
  		  const annotJson = await getAnnotation(annot);
  		  annotJson.attachmentItemID = _item.id;
  		  annotations.push(annotJson);
  		}
  	return Zotero.EditorInstanceUtilities.serializeAnnotations(annotations);
  	}
  
  	/*constants */
  	const attachments = Zotero.Items.get(topItem.getAttachments()).filter((i) =>
  	i.isPDFAttachment()
  	);
  	let res = ``;
  	const colors = ["#aaaaaa","#ffd400", "#ff6666", "#5fb236", "#2ea8e5", "#a28ae5","#e56eee","#f19837"];
  	const colorNames = ["💡Innovation","❓Research question", "📄Background", "📚Literature", "🔨Method", "📜Findings","🔭Future direction","🤔Inspiration"];
  	//                     Light Gray          Yellow            Coral Red     Olive Green     Light Blue    Lavender       Magenta            Deep Orange
  	
  	/*loop each attachment */
  	try {  
  	  for (let attachment of attachments) {
  		// res += `<h2>📄For Document:${attachment.attachmentFilename}</h2>`;
  		for (let i in colors) {
  		  const renderedAnnotations = (
  			await getAnnotationsByColor(
  			  attachment,
  			  (_annot) => _annot.annotationColor === colors[i]
  			)
  		  ).html;
  		  if (renderedAnnotations) {
  			res += `<h3><p style="background-color:${colors[i]};">${colorNames[i]}</p></h3>\n${renderedAnnotations}`;
  		  }
  		}
  		
  		const renderedAnnotations = (
  		  await getAnnotationsByColor(
  			attachment,
  			(_annot) => !colors.includes(_annot.annotationColor)
  		  )
  		).html;
  		
  		if (renderedAnnotations) {
  		  res += `<h2><p>Other Annotations</p></h2>\n${renderedAnnotations}`;
  		}
  	  }
  	  	r(res);
  	  
  		} catch (e) {
  			Zotero.logError(e);
  
  
      }
  })}

@windingwind
Copy link
Owner

模板实现太旧,请参考#236

具体问题请联系模板作者,此处关闭

@windingwind windingwind closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2024
@fredericky123
Copy link
Author

实际上根据颜色collect annotation模板的出处应该是版主
#227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants