@digitalculture/ochre-sdk 0.17.4 → 0.17.6
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.
- package/dist/index.mjs +40 -20
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -723,10 +723,19 @@ function extractAnnotationMetadata(item) {
|
|
|
723
723
|
const textStylingHeadingLevelProperty = textStylingProperties.find((property) => property.label.uuid === TEXT_ANNOTATION_TEXT_STYLING_HEADING_LEVEL_UUID);
|
|
724
724
|
if (textStylingHeadingLevelProperty != null) textStylingHeadingLevel = parseFakeString(textStylingHeadingLevelProperty.value.content);
|
|
725
725
|
const textStylingCssProperties = textStylingProperties.filter((property) => property.label.uuid !== TEXT_ANNOTATION_TEXT_STYLING_VARIANT_UUID && property.label.uuid !== TEXT_ANNOTATION_TEXT_STYLING_HEADING_LEVEL_UUID);
|
|
726
|
-
if (textStylingCssProperties.length > 0)
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
726
|
+
if (textStylingCssProperties.length > 0) {
|
|
727
|
+
textStylingCss = textStylingCssProperties.map((property) => ({
|
|
728
|
+
label: parseFakeString(property.label.content),
|
|
729
|
+
value: parseFakeString(property.value.content)
|
|
730
|
+
}));
|
|
731
|
+
const colorStyle = textStylingCss.find((style) => style.label === "color");
|
|
732
|
+
if (colorStyle != null) {
|
|
733
|
+
if (!textStylingCss.some((style) => style.label === "textDecorationColor")) textStylingCss.push({
|
|
734
|
+
label: "textDecorationColor",
|
|
735
|
+
value: colorStyle.value
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}
|
|
730
739
|
result.textStyling = {
|
|
731
740
|
variant: textStylingVariant,
|
|
732
741
|
size: textStylingSize,
|
|
@@ -803,44 +812,46 @@ function parseStringDocumentItem(item) {
|
|
|
803
812
|
case "image": if (linkResource.rend === "inline") return applyWhitespaceToResult(`<InlineImage uuid="${linkResource.uuid}" ${linkContent !== null ? `content="${linkContent}"` : ""} height={${linkResource.height?.toString() ?? "null"}} width={${linkResource.width?.toString() ?? "null"}} />`, itemWhitespace);
|
|
804
813
|
else if (linkResource.publicationDateTime != null) {
|
|
805
814
|
const annotationMetadata = extractAnnotationMetadata(item);
|
|
815
|
+
const innerContent = wrapWithTextStyling(itemString, annotationMetadata.textStyling);
|
|
806
816
|
let linkElement;
|
|
807
817
|
switch (annotationMetadata.linkVariant) {
|
|
808
818
|
case "hover-card":
|
|
809
|
-
linkElement = `<Annotation type="hover-card" uuid="${linkResource.uuid}">${
|
|
819
|
+
linkElement = `<Annotation type="hover-card" uuid="${linkResource.uuid}">${innerContent}</Annotation>`;
|
|
810
820
|
break;
|
|
811
821
|
case "item-page":
|
|
812
|
-
linkElement = `<InternalLink type="item" uuid="${linkResource.uuid}">${
|
|
822
|
+
linkElement = `<InternalLink type="item" uuid="${linkResource.uuid}">${innerContent}</InternalLink>`;
|
|
813
823
|
break;
|
|
814
824
|
case "entry-page":
|
|
815
|
-
linkElement = `<InternalLink type="entry" uuid="${linkResource.uuid}">${
|
|
825
|
+
linkElement = `<InternalLink type="entry" uuid="${linkResource.uuid}">${innerContent}</InternalLink>`;
|
|
816
826
|
break;
|
|
817
|
-
default: linkElement = `<InternalLink uuid="${linkResource.uuid}">${
|
|
827
|
+
default: linkElement = `<InternalLink uuid="${linkResource.uuid}">${innerContent}</InternalLink>`;
|
|
818
828
|
}
|
|
819
|
-
return applyWhitespaceToResult(
|
|
829
|
+
return applyWhitespaceToResult(linkElement, itemWhitespace);
|
|
820
830
|
} else return applyWhitespaceToResult(`<TooltipSpan${linkContent !== null ? ` content="${linkContent}"` : ""}>${itemString}</TooltipSpan>`, itemWhitespace);
|
|
821
831
|
case "internalDocument": {
|
|
822
832
|
const annotationMetadata = extractAnnotationMetadata(item);
|
|
833
|
+
const innerContent = wrapWithTextStyling(itemString, annotationMetadata.textStyling);
|
|
823
834
|
let linkElement;
|
|
824
835
|
switch (annotationMetadata.linkVariant) {
|
|
825
836
|
case "hover-card":
|
|
826
|
-
linkElement = `<Annotation type="hover-card" uuid="${linkResource.uuid}">${
|
|
837
|
+
linkElement = `<Annotation type="hover-card" uuid="${linkResource.uuid}">${innerContent}</Annotation>`;
|
|
827
838
|
break;
|
|
828
839
|
case "item-page":
|
|
829
|
-
linkElement = `<InternalLink type="item" uuid="${linkResource.uuid}">${
|
|
840
|
+
linkElement = `<InternalLink type="item" uuid="${linkResource.uuid}">${innerContent}</InternalLink>`;
|
|
830
841
|
break;
|
|
831
842
|
case "entry-page":
|
|
832
|
-
linkElement = `<InternalLink type="entry" uuid="${linkResource.uuid}">${
|
|
843
|
+
linkElement = `<InternalLink type="entry" uuid="${linkResource.uuid}">${innerContent}</InternalLink>`;
|
|
833
844
|
break;
|
|
834
845
|
default: if ("properties" in item && item.properties != null) {
|
|
835
846
|
const itemProperty = Array.isArray(item.properties.property) ? item.properties.property[0] : item.properties.property;
|
|
836
847
|
if (itemProperty != null) {
|
|
837
848
|
const itemPropertyLabelUuid = itemProperty.label.uuid;
|
|
838
849
|
const itemPropertyValueUuid = typeof itemProperty.value === "object" && "uuid" in itemProperty.value && itemProperty.value.uuid != null ? itemProperty.value.uuid : null;
|
|
839
|
-
linkElement = `<InternalLink uuid="${linkResource.uuid}" properties="${itemPropertyLabelUuid}"${itemPropertyValueUuid !== null ? ` value="${itemPropertyValueUuid}"` : ""}>${
|
|
840
|
-
} else linkElement = `<InternalLink uuid="${linkResource.uuid}">${
|
|
841
|
-
} else linkElement = `<InternalLink uuid="${linkResource.uuid}">${
|
|
850
|
+
linkElement = `<InternalLink uuid="${linkResource.uuid}" properties="${itemPropertyLabelUuid}"${itemPropertyValueUuid !== null ? ` value="${itemPropertyValueUuid}"` : ""}>${innerContent}</InternalLink>`;
|
|
851
|
+
} else linkElement = `<InternalLink uuid="${linkResource.uuid}">${innerContent}</InternalLink>`;
|
|
852
|
+
} else linkElement = `<InternalLink uuid="${linkResource.uuid}">${innerContent}</InternalLink>`;
|
|
842
853
|
}
|
|
843
|
-
return applyWhitespaceToResult(
|
|
854
|
+
return applyWhitespaceToResult(linkElement, itemWhitespace);
|
|
844
855
|
}
|
|
845
856
|
case "externalDocument": if (linkResource.publicationDateTime != null) return applyWhitespaceToResult(String.raw`<ExternalLink href="https:\/\/ochre.lib.uchicago.edu/ochre?uuid=${linkResource.uuid}&load" ${linkContent !== null ? `content="${linkContent}"` : ""}>${itemString}</ExternalLink>`, itemWhitespace);
|
|
846
857
|
else return applyWhitespaceToResult(`<TooltipSpan${linkContent !== null ? ` content="${linkContent}"` : ""}>${itemString}</TooltipSpan>`, itemWhitespace);
|
|
@@ -901,10 +912,19 @@ function parseStringDocumentItem(item) {
|
|
|
901
912
|
const textStylingHeadingLevelProperty = textStylingProperties.find((property) => property.label.uuid === TEXT_ANNOTATION_TEXT_STYLING_HEADING_LEVEL_UUID);
|
|
902
913
|
if (textStylingHeadingLevelProperty != null) textStylingHeadingLevel = parseFakeString(textStylingHeadingLevelProperty.value.content);
|
|
903
914
|
const textStylingCssProperties = textStylingProperties.filter((property) => property.label.uuid !== TEXT_ANNOTATION_TEXT_STYLING_VARIANT_UUID && property.label.uuid !== TEXT_ANNOTATION_TEXT_STYLING_HEADING_LEVEL_UUID);
|
|
904
|
-
if (textStylingCssProperties.length > 0)
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
915
|
+
if (textStylingCssProperties.length > 0) {
|
|
916
|
+
textStylingCss = textStylingCssProperties.map((property) => ({
|
|
917
|
+
label: parseFakeString(property.label.content),
|
|
918
|
+
value: parseFakeString(property.value.content)
|
|
919
|
+
}));
|
|
920
|
+
const colorStyle = textStylingCss.find((style) => style.label === "color");
|
|
921
|
+
if (colorStyle != null) {
|
|
922
|
+
if (!textStylingCss.some((style) => style.label === "textDecorationColor")) textStylingCss.push({
|
|
923
|
+
label: "textDecorationColor",
|
|
924
|
+
value: colorStyle.value
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
}
|
|
908
928
|
}
|
|
909
929
|
return applyWhitespaceToResult(`<Annotation type="${textStylingType}" variant="${textStylingVariant}" size="${textStylingSize}"${textStylingHeadingLevel != null ? ` headingLevel="${textStylingHeadingLevel}"` : ""}${textStylingCss.length > 0 ? ` cssStyles={{default: ${JSON.stringify(textStylingCss)}, tablet: [], mobile: []}}` : ""}>${itemString}</Annotation>`, itemWhitespace);
|
|
910
930
|
}
|
package/package.json
CHANGED