ochre-sdk 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +8 -4
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1008,19 +1008,20 @@ function parseXMLString(string, options) {
1008
1008
  */
1009
1009
  function createMDXComponent(variant, properties) {
1010
1010
  const { uuid, href, height, width, content, text } = properties;
1011
+ const tooltipContent = getDistinctTooltipContent(content, text);
1011
1012
  let returnString = "";
1012
1013
  switch (variant) {
1013
1014
  case "inlineImage":
1014
1015
  returnString = `<InlineImage uuid="${uuid}"${createMDXStringAttribute("content", content)} height={${height ?? "null"}} width={${width ?? "null"}} />`;
1015
1016
  break;
1016
1017
  case "internalLink":
1017
- returnString = `<InternalLink uuid="${uuid}"${createMDXStringAttribute("content", content)}>${text}</InternalLink>`;
1018
+ returnString = `<InternalLink uuid="${uuid}"${createMDXStringAttribute("content", tooltipContent)}>${text}</InternalLink>`;
1018
1019
  break;
1019
1020
  case "externalLink":
1020
- returnString = `<ExternalLink href="${href == null ? "#" : transformPermanentIdentificationUrl(href)}"${createMDXStringAttribute("content", content)}>${text}</ExternalLink>`;
1021
+ returnString = `<ExternalLink href="${href == null ? "#" : transformPermanentIdentificationUrl(href)}"${createMDXStringAttribute("content", tooltipContent)}>${text}</ExternalLink>`;
1021
1022
  break;
1022
1023
  case "documentLink":
1023
- returnString = String.raw`<ExternalLink href="https:\/\/ochre.lib.uchicago.edu/ochre/v2/ochre.php?uuid=${uuid}&load"${createMDXStringAttribute("content", content)}>${text}</ExternalLink>`;
1024
+ returnString = String.raw`<ExternalLink href="https:\/\/ochre.lib.uchicago.edu/ochre/v2/ochre.php?uuid=${uuid}&load"${createMDXStringAttribute("content", tooltipContent)}>${text}</ExternalLink>`;
1024
1025
  break;
1025
1026
  case "tooltipSpan":
1026
1027
  returnString = `<TooltipSpan${createMDXStringAttribute("content", content)}>${text}</TooltipSpan>`;
@@ -1028,6 +1029,9 @@ function createMDXComponent(variant, properties) {
1028
1029
  }
1029
1030
  return returnString;
1030
1031
  }
1032
+ function getDistinctTooltipContent(content, textContent) {
1033
+ return content === textContent ? void 0 : content;
1034
+ }
1031
1035
  function createMDXStringAttribute(name, value) {
1032
1036
  if (value == null || value === "") return "";
1033
1037
  return ` ${name}=${MDX_QUOTED_ATTRIBUTE_ESCAPE_REGEX.test(value) ? `{${JSON.stringify(value)}}` : `"${value}"`}`;
@@ -1173,7 +1177,7 @@ function createInternalLinkComponent(properties) {
1173
1177
  case "hover-card": return `<Annotation type="hover-card" uuid="${properties.uuid}">${innerContent}</Annotation>`;
1174
1178
  case "item-page": return `<InternalLink type="item" uuid="${properties.uuid}">${innerContent}</InternalLink>`;
1175
1179
  case "entry-page": return `<InternalLink type="entry" uuid="${properties.uuid}">${innerContent}</InternalLink>`;
1176
- default: return `<InternalLink uuid="${properties.uuid}"${properties.propertyMetadata != null ? ` properties="${properties.propertyMetadata.labelUuid}"${properties.propertyMetadata.valueUuid != null ? ` value="${properties.propertyMetadata.valueUuid}"` : ""}` : ""}${createMDXStringAttribute("content", properties.content)}>${innerContent}</InternalLink>`;
1180
+ default: return `<InternalLink uuid="${properties.uuid}"${properties.propertyMetadata != null ? ` properties="${properties.propertyMetadata.labelUuid}"${properties.propertyMetadata.valueUuid != null ? ` value="${properties.propertyMetadata.valueUuid}"` : ""}` : ""}${createMDXStringAttribute("content", getDistinctTooltipContent(properties.content, properties.text))}>${innerContent}</InternalLink>`;
1177
1181
  }
1178
1182
  }
1179
1183
  function getXMLRichTextLinks(item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",