ochre-sdk 1.0.0-beta.10 → 1.0.0-beta.12
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 +21 -9
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -805,6 +805,7 @@ const ITEM_PAGE_TOKEN = "item-page";
|
|
|
805
805
|
const ENTRY_PAGE_TOKEN = "entry-page";
|
|
806
806
|
const VARIANT_TOKEN = "variant";
|
|
807
807
|
const HEADING_LEVEL_TOKEN = "heading-level";
|
|
808
|
+
const MDX_QUOTED_ATTRIBUTE_ESCAPE_REGEX = /[\n\r"]/;
|
|
808
809
|
function isXMLRichTextLink(value) {
|
|
809
810
|
return typeof value === "object" && value != null;
|
|
810
811
|
}
|
|
@@ -951,23 +952,27 @@ function createMDXComponent(variant, properties) {
|
|
|
951
952
|
let returnString = "";
|
|
952
953
|
switch (variant) {
|
|
953
954
|
case "inlineImage":
|
|
954
|
-
returnString = `<InlineImage uuid="${uuid}"
|
|
955
|
+
returnString = `<InlineImage uuid="${uuid}"${createMDXStringAttribute("content", content)} height={${height ?? "null"}} width={${width ?? "null"}} />`;
|
|
955
956
|
break;
|
|
956
957
|
case "internalLink":
|
|
957
|
-
returnString = `<InternalLink uuid="${uuid}"${content
|
|
958
|
+
returnString = `<InternalLink uuid="${uuid}"${createMDXStringAttribute("content", content)}>${text}</InternalLink>`;
|
|
958
959
|
break;
|
|
959
960
|
case "externalLink":
|
|
960
|
-
returnString = `<ExternalLink href="${href == null ? "#" : transformPermanentIdentificationUrl(href)}"${content
|
|
961
|
+
returnString = `<ExternalLink href="${href == null ? "#" : transformPermanentIdentificationUrl(href)}"${createMDXStringAttribute("content", content)}>${text}</ExternalLink>`;
|
|
961
962
|
break;
|
|
962
963
|
case "documentLink":
|
|
963
|
-
returnString = String.raw`<ExternalLink href="https:\/\/ochre.lib.uchicago.edu/ochre/v2/ochre.php?uuid=${uuid}&load"${content
|
|
964
|
+
returnString = String.raw`<ExternalLink href="https:\/\/ochre.lib.uchicago.edu/ochre/v2/ochre.php?uuid=${uuid}&load"${createMDXStringAttribute("content", content)}>${text}</ExternalLink>`;
|
|
964
965
|
break;
|
|
965
966
|
case "tooltipSpan":
|
|
966
|
-
returnString = `<TooltipSpan${content
|
|
967
|
+
returnString = `<TooltipSpan${createMDXStringAttribute("content", content)}>${text}</TooltipSpan>`;
|
|
967
968
|
break;
|
|
968
969
|
}
|
|
969
970
|
return returnString;
|
|
970
971
|
}
|
|
972
|
+
function createMDXStringAttribute(name, value) {
|
|
973
|
+
if (value == null || value === "") return "";
|
|
974
|
+
return ` ${name}=${MDX_QUOTED_ATTRIBUTE_ESCAPE_REGEX.test(value) ? `{${JSON.stringify(value)}}` : `"${value}"`}`;
|
|
975
|
+
}
|
|
971
976
|
function applyWhitespaceToResult(result, whitespace, rendering) {
|
|
972
977
|
return whitespace == null ? result : parseWhitespace(result, whitespace, rendering);
|
|
973
978
|
}
|
|
@@ -1110,7 +1115,7 @@ function createInternalLinkComponent(properties) {
|
|
|
1110
1115
|
case "hover-card": return `<Annotation type="hover-card" uuid="${properties.uuid}">${innerContent}</Annotation>`;
|
|
1111
1116
|
case "item-page": return `<InternalLink type="item" uuid="${properties.uuid}">${innerContent}</InternalLink>`;
|
|
1112
1117
|
case "entry-page": return `<InternalLink type="entry" uuid="${properties.uuid}">${innerContent}</InternalLink>`;
|
|
1113
|
-
default: return `<InternalLink uuid="${properties.uuid}"${properties.propertyMetadata != null ? ` properties="${properties.propertyMetadata.labelUuid}"${properties.propertyMetadata.valueUuid != null ? ` value="${properties.propertyMetadata.valueUuid}"` : ""}` : ""}${
|
|
1118
|
+
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>`;
|
|
1114
1119
|
}
|
|
1115
1120
|
}
|
|
1116
1121
|
function getXMLRichTextLinks(item) {
|
|
@@ -5006,12 +5011,19 @@ declare function local:put-property-detail(
|
|
|
5006
5011
|
return
|
|
5007
5012
|
if (
|
|
5008
5013
|
empty($existing)
|
|
5009
|
-
or (
|
|
5014
|
+
or (not($existing/content) and exists($label-content))
|
|
5015
|
+
or (
|
|
5016
|
+
not($existing/content)
|
|
5017
|
+
and string-length(string($existing)) = 0
|
|
5018
|
+
and string-length($display) gt 0
|
|
5019
|
+
)
|
|
5010
5020
|
) then
|
|
5011
5021
|
map:put(
|
|
5012
5022
|
$details,
|
|
5013
5023
|
$key,
|
|
5014
|
-
<propertyValue scope="{$scope}" variableUuid="{$variable-uuid}" uuid="{$value-uuid}" rawValue="{$raw-value}" dataType="{$data-type}">{
|
|
5024
|
+
<propertyValue scope="{$scope}" variableUuid="{$variable-uuid}" uuid="{$value-uuid}" rawValue="{$raw-value}" dataType="{$data-type}">{
|
|
5025
|
+
if (exists($label-content)) then $label-content else $display
|
|
5026
|
+
}</propertyValue>
|
|
5015
5027
|
)
|
|
5016
5028
|
else ()
|
|
5017
5029
|
};
|
|
@@ -5086,7 +5098,7 @@ let $property-values :=
|
|
|
5086
5098
|
let $detail := map:get($variable-property-details, $key)
|
|
5087
5099
|
let $global-key := map:get($variable-property-global-keys, $key)
|
|
5088
5100
|
return <propertyValue scope="variable" variableUuid="{string($detail/@variableUuid)}" uuid="{string($detail/@uuid)}" rawValue="{string($detail/@rawValue)}" dataType="{string($detail/@dataType)}" count="{map:get($variable-property-counts, $key)}" globalCount="{map:get($global-property-counts, $global-key)}">{
|
|
5089
|
-
|
|
5101
|
+
$detail/node()
|
|
5090
5102
|
}</propertyValue>
|
|
5091
5103
|
)`);
|
|
5092
5104
|
returnedSequences.push("$property-values");
|
package/package.json
CHANGED