ochre-sdk 1.0.40 → 1.0.42
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/parsers/string.mjs
CHANGED
|
@@ -15,17 +15,12 @@ const HEADING_LEVEL_TOKEN = "heading-level";
|
|
|
15
15
|
const RAW_MDX_BLOCK_DELIMITER = "``md``";
|
|
16
16
|
const RAW_MDX_BLOCK_PLACEHOLDER_PREFIX = "\0raw-mdx-block:";
|
|
17
17
|
const RAW_MDX_BLOCK_PLACEHOLDER_SUFFIX = "\0";
|
|
18
|
-
const RICH_LINE_BREAK = "<br />\n";
|
|
19
|
-
const RICH_PARAGRAPH_BREAK = "\n\n";
|
|
20
18
|
const MDX_QUOTED_ATTRIBUTE_ESCAPE_REGEX = /[\n\r"]/;
|
|
21
19
|
const MDX_RENDER_ELEMENTS = {
|
|
22
20
|
bold: "strong",
|
|
23
21
|
italic: "em",
|
|
24
22
|
underline: "u"
|
|
25
23
|
};
|
|
26
|
-
function hasNewlineWhitespace(value) {
|
|
27
|
-
return value?.split(" ").includes("newline") === true;
|
|
28
|
-
}
|
|
29
24
|
function isXMLRichTextLink(value) {
|
|
30
25
|
return typeof value === "object" && value != null;
|
|
31
26
|
}
|
|
@@ -73,9 +68,12 @@ function applyMDXRenderElements(contentString, options) {
|
|
|
73
68
|
}
|
|
74
69
|
function applyNewlineWhitespace(contentString, whitespace, rendering) {
|
|
75
70
|
if (whitespace == null) return contentString;
|
|
76
|
-
if (!
|
|
77
|
-
if (contentString === ""
|
|
78
|
-
|
|
71
|
+
if (!whitespace.split(" ").includes("newline")) return contentString;
|
|
72
|
+
if (contentString === "") {
|
|
73
|
+
if (rendering === "rich") return "<br />\n<br />\n";
|
|
74
|
+
return "\n\n";
|
|
75
|
+
}
|
|
76
|
+
if (rendering === "rich") return contentString.trim() === "***" ? `${contentString}\n` : `<br />\n${contentString}`;
|
|
79
77
|
return `\n${contentString}`;
|
|
80
78
|
}
|
|
81
79
|
/**
|
|
@@ -263,7 +261,7 @@ function parseNestedStringItems(items, contentItem, options) {
|
|
|
263
261
|
let result = "";
|
|
264
262
|
let rawMDXBlockStartIndex = null;
|
|
265
263
|
for (const [index, item] of items.entries()) {
|
|
266
|
-
if (item.payload === RAW_MDX_BLOCK_DELIMITER &&
|
|
264
|
+
if (item.payload === RAW_MDX_BLOCK_DELIMITER && item.rend == null && item.links == null && item.properties == null && item.annotation == null && item.string == null) {
|
|
267
265
|
if (rawMDXBlockStartIndex == null) {
|
|
268
266
|
rawMDXBlockStartIndex = index;
|
|
269
267
|
continue;
|
|
@@ -278,7 +276,7 @@ function parseNestedStringItems(items, contentItem, options) {
|
|
|
278
276
|
rawMDXBlocks: options.rawMDXBlocks
|
|
279
277
|
});
|
|
280
278
|
}
|
|
281
|
-
if (rawMDXBlock !== "" && !rawMDXBlock.endsWith("\n") &&
|
|
279
|
+
if (rawMDXBlock !== "" && !rawMDXBlock.endsWith("\n") && item.whitespace?.split(" ").includes("newline") === true) rawMDXBlock += "\n";
|
|
282
280
|
if (options.rendering === "rich" && options.rawMDXBlocks != null) {
|
|
283
281
|
const placeholder = `${RAW_MDX_BLOCK_PLACEHOLDER_PREFIX}${options.rawMDXBlocks.length}${RAW_MDX_BLOCK_PLACEHOLDER_SUFFIX}`;
|
|
284
282
|
options.rawMDXBlocks.push(rawMDXBlock);
|
|
@@ -288,8 +286,7 @@ function parseNestedStringItems(items, contentItem, options) {
|
|
|
288
286
|
continue;
|
|
289
287
|
}
|
|
290
288
|
if (rawMDXBlockStartIndex != null) continue;
|
|
291
|
-
|
|
292
|
-
result += options.rendering === "rich" && result.endsWith("\n") && parsedItem.startsWith(RICH_LINE_BREAK) ? parsedItem.slice(6) : parsedItem;
|
|
289
|
+
result += parseXMLStringItem(item, contentItem, options);
|
|
293
290
|
}
|
|
294
291
|
if (rawMDXBlockStartIndex != null) for (let index = rawMDXBlockStartIndex; index < items.length; index += 1) {
|
|
295
292
|
const item = items[index];
|
|
@@ -383,6 +383,7 @@ function parseWebElementProperties(componentProperty, elementResource, options,
|
|
|
383
383
|
const isFilterSidebarDisplayed = componentReader.valueOr("filter-sidebar-displayed", false);
|
|
384
384
|
const filterSidebarSort = componentReader.valueOr("filter-sidebar-sort", "default");
|
|
385
385
|
const imageLayout = componentReader.valueOr("image-layout", "start");
|
|
386
|
+
const isImagePlaceholderDisplayed = componentReader.valueOr("image-placeholder-displayed", true);
|
|
386
387
|
const componentOptions = parseWebsiteOptions(elementResource.options, options);
|
|
387
388
|
properties = {
|
|
388
389
|
component: "collection",
|
|
@@ -395,6 +396,7 @@ function parseWebElementProperties(componentProperty, elementResource, options,
|
|
|
395
396
|
paginationVariant,
|
|
396
397
|
loadingVariant,
|
|
397
398
|
imageLayout,
|
|
399
|
+
isImagePlaceholderDisplayed,
|
|
398
400
|
expectedItemCount,
|
|
399
401
|
isUsingQueryParams,
|
|
400
402
|
isSortDisplayed,
|
package/dist/types/website.d.mts
CHANGED
|
@@ -296,6 +296,7 @@ type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
|
|
|
296
296
|
paginationVariant: "default" | "numeric";
|
|
297
297
|
loadingVariant: "spinner" | "skeleton" | "animation" | "none";
|
|
298
298
|
imageLayout: "top" | "bottom" | "start" | "end" | null;
|
|
299
|
+
isImagePlaceholderDisplayed: boolean;
|
|
299
300
|
expectedItemCount: number | null;
|
|
300
301
|
isSortDisplayed: boolean;
|
|
301
302
|
isUsingQueryParams: boolean;
|