@digitalculture/ochre-sdk 0.4.10 → 0.4.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.cjs CHANGED
@@ -226,7 +226,7 @@ function parseFakeString(string) {
226
226
  } else if (typeof string === "boolean") {
227
227
  returnString = string ? "Yes" : "No";
228
228
  }
229
- return returnString.replaceAll("'", "'");
229
+ return returnString.replaceAll("'", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
230
230
  }
231
231
  function parseStringItem(item) {
232
232
  let returnString = "";
@@ -243,12 +243,16 @@ function parseStringItem(item) {
243
243
  case "object": {
244
244
  const stringItems = Array.isArray(item.string) ? item.string : [item.string];
245
245
  for (const stringItem of stringItems) {
246
- const renderedText = stringItem.rend != null ? parseRenderOptions(
247
- parseFakeString(stringItem.content),
248
- stringItem.rend
249
- ) : parseFakeString(stringItem.content);
250
- const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
251
- returnString += whitespacedText;
246
+ if (typeof stringItem === "string" || typeof stringItem === "number" || typeof stringItem === "boolean") {
247
+ returnString += parseFakeString(stringItem);
248
+ } else {
249
+ const renderedText = stringItem.rend != null ? parseRenderOptions(
250
+ parseFakeString(stringItem.content),
251
+ stringItem.rend
252
+ ) : parseFakeString(stringItem.content);
253
+ const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
254
+ returnString += whitespacedText;
255
+ }
252
256
  }
253
257
  break;
254
258
  }
@@ -257,7 +261,7 @@ function parseStringItem(item) {
257
261
  break;
258
262
  }
259
263
  }
260
- return returnString;
264
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
261
265
  }
262
266
  function parseStringDocumentItem(item, footnotes) {
263
267
  if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
@@ -364,7 +368,7 @@ function parseStringDocumentItem(item, footnotes) {
364
368
  item.whitespace
365
369
  );
366
370
  }
367
- return returnString.replaceAll("'", "'");
371
+ return returnString.replaceAll("'", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
368
372
  } else {
369
373
  returnString = parseFakeString(item.content);
370
374
  if (item.rend != null) {
@@ -380,7 +384,7 @@ function parseStringDocumentItem(item, footnotes) {
380
384
  );
381
385
  }
382
386
  }
383
- return returnString;
387
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
384
388
  }
385
389
  function parseStringContent(content, language = "eng") {
386
390
  switch (typeof content.content) {
@@ -411,7 +415,7 @@ ${JSON.stringify(
411
415
  }
412
416
  }
413
417
  default: {
414
- return String(content.content);
418
+ return String(content.content).replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
415
419
  }
416
420
  }
417
421
  }
@@ -1878,6 +1882,14 @@ async function parseWebElement(elementResource, elementProperties) {
1878
1882
  const cssStyle = property.values[0].content;
1879
1883
  cssStyles.push({ label: property.label, value: cssStyle });
1880
1884
  }
1885
+ const mobileCssProperties = elementResourceProperties.find(
1886
+ (property) => property.label === "presentation" && property.values[0].content === "css-mobile"
1887
+ )?.properties ?? [];
1888
+ const cssStylesMobile = [];
1889
+ for (const property of mobileCssProperties) {
1890
+ const cssStyle = property.values[0].content;
1891
+ cssStylesMobile.push({ label: property.label, value: cssStyle });
1892
+ }
1881
1893
  const titleProperties = elementResourceProperties.find(
1882
1894
  (property) => property.label === "presentation" && property.values[0].content === "title"
1883
1895
  )?.properties;
@@ -1922,6 +1934,7 @@ async function parseWebElement(elementResource, elementProperties) {
1922
1934
  }
1923
1935
  },
1924
1936
  cssStyles,
1937
+ cssStylesMobile,
1925
1938
  ...properties
1926
1939
  };
1927
1940
  }
@@ -1971,12 +1984,14 @@ async function parseWebpage(webpageResource) {
1971
1984
  blocks: [],
1972
1985
  elements,
1973
1986
  properties: {
1974
- spacing: null,
1975
- gap: "none",
1987
+ spacing: void 0,
1988
+ gap: void 0,
1976
1989
  alignItems: "start",
1977
1990
  justifyContent: "stretch"
1978
1991
  },
1979
- cssStyles: []
1992
+ propertiesMobile: null,
1993
+ cssStyles: [],
1994
+ cssStylesMobile: []
1980
1995
  };
1981
1996
  blocks.push(block);
1982
1997
  elementsToHandle = [];
@@ -1993,12 +2008,14 @@ async function parseWebpage(webpageResource) {
1993
2008
  blocks: [],
1994
2009
  elements,
1995
2010
  properties: {
1996
- spacing: null,
1997
- gap: "none",
2011
+ spacing: void 0,
2012
+ gap: void 0,
1998
2013
  alignItems: "start",
1999
2014
  justifyContent: "stretch"
2000
2015
  },
2001
- cssStyles: []
2016
+ propertiesMobile: null,
2017
+ cssStyles: [],
2018
+ cssStylesMobile: []
2002
2019
  };
2003
2020
  blocks.push(block);
2004
2021
  }
@@ -2051,6 +2068,18 @@ async function parseWebpage(webpageResource) {
2051
2068
  });
2052
2069
  }
2053
2070
  }
2071
+ const mobileCssStyleSubProperties = webpageProperties.find(
2072
+ (property) => property.label === "presentation" && property.values[0]?.content === "css-mobile"
2073
+ )?.properties;
2074
+ const cssStylesMobile = [];
2075
+ if (mobileCssStyleSubProperties) {
2076
+ for (const property of mobileCssStyleSubProperties) {
2077
+ cssStylesMobile.push({
2078
+ label: property.label,
2079
+ value: property.values[0].content
2080
+ });
2081
+ }
2082
+ }
2054
2083
  return {
2055
2084
  title: identification.label,
2056
2085
  slug,
@@ -2061,7 +2090,8 @@ async function parseWebpage(webpageResource) {
2061
2090
  variant,
2062
2091
  backgroundImageUrl: imageLink ? `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load` : null,
2063
2092
  isSidebarDisplayed,
2064
- cssStyles
2093
+ cssStyles,
2094
+ cssStylesMobile
2065
2095
  },
2066
2096
  webpages
2067
2097
  };
@@ -2084,12 +2114,14 @@ async function parseBlock(blockResource) {
2084
2114
  blocks: [],
2085
2115
  elements: [],
2086
2116
  properties: {
2087
- spacing: null,
2088
- gap: "none",
2117
+ spacing: void 0,
2118
+ gap: void 0,
2089
2119
  alignItems: "start",
2090
2120
  justifyContent: "stretch"
2091
2121
  },
2092
- cssStyles: []
2122
+ propertiesMobile: null,
2123
+ cssStyles: [],
2124
+ cssStylesMobile: []
2093
2125
  };
2094
2126
  const blockProperties = blockResource.properties ? parseProperties(
2095
2127
  Array.isArray(blockResource.properties.property) ? blockResource.properties.property : [blockResource.properties.property]
@@ -2128,6 +2160,17 @@ async function parseBlock(blockResource) {
2128
2160
  if (justifyContentProperty) {
2129
2161
  returnBlock.properties.justifyContent = justifyContentProperty.content;
2130
2162
  }
2163
+ const mobileOverwriteProperty = blockMainProperties.find(
2164
+ (property) => property.label === "overwrite-mobile"
2165
+ );
2166
+ if (mobileOverwriteProperty) {
2167
+ const mobileOverwriteProperties = mobileOverwriteProperty.properties;
2168
+ const propertiesMobile = {};
2169
+ for (const property of mobileOverwriteProperties) {
2170
+ propertiesMobile[property.label] = property.values[0].content;
2171
+ }
2172
+ returnBlock.propertiesMobile = propertiesMobile;
2173
+ }
2131
2174
  }
2132
2175
  const blockBlocks = blockResource.resource ? await parseWebpageResources(
2133
2176
  Array.isArray(blockResource.resource) ? blockResource.resource : [blockResource.resource],
@@ -2154,6 +2197,17 @@ async function parseBlock(blockResource) {
2154
2197
  });
2155
2198
  }
2156
2199
  }
2200
+ const blockMobileCssStyles = blockProperties.find(
2201
+ (property) => property.label === "presentation" && property.values[0]?.content === "css-mobile"
2202
+ )?.properties;
2203
+ if (blockMobileCssStyles) {
2204
+ for (const property of blockMobileCssStyles) {
2205
+ returnBlock.cssStylesMobile.push({
2206
+ label: property.label,
2207
+ value: property.values[0].content
2208
+ });
2209
+ }
2210
+ }
2157
2211
  return returnBlock;
2158
2212
  }
2159
2213
  function parseWebsiteProperties(properties) {
@@ -2292,6 +2346,7 @@ async function parseWebsite(websiteTree, projectName, website) {
2292
2346
  let sidebarLayout = "start";
2293
2347
  let sidebarMobileLayout = "default";
2294
2348
  const sidebarCssStyles = [];
2349
+ const sidebarCssStylesMobile = [];
2295
2350
  const sidebarResource = resources.find((resource) => {
2296
2351
  const resourceProperties = resource.properties ? parseProperties(
2297
2352
  Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
@@ -2329,6 +2384,13 @@ async function parseWebsite(websiteTree, projectName, website) {
2329
2384
  const cssStyle = property.values[0].content;
2330
2385
  sidebarCssStyles.push({ label: property.label, value: cssStyle });
2331
2386
  }
2387
+ const mobileCssProperties = sidebarBaseProperties.find(
2388
+ (property) => property.label === "presentation" && property.values[0].content === "css-mobile"
2389
+ )?.properties ?? [];
2390
+ for (const property of mobileCssProperties) {
2391
+ const cssStyle = property.values[0].content;
2392
+ sidebarCssStylesMobile.push({ label: property.label, value: cssStyle });
2393
+ }
2332
2394
  const titleProperties = sidebarBaseProperties.find(
2333
2395
  (property) => property.label === "presentation" && property.values[0].content === "title"
2334
2396
  )?.properties;
@@ -2375,7 +2437,8 @@ async function parseWebsite(websiteTree, projectName, website) {
2375
2437
  title: sidebarTitle,
2376
2438
  layout: sidebarLayout,
2377
2439
  mobileLayout: sidebarMobileLayout,
2378
- cssStyles: sidebarCssStyles
2440
+ cssStyles: sidebarCssStyles,
2441
+ cssStylesMobile: sidebarCssStylesMobile
2379
2442
  };
2380
2443
  }
2381
2444
  return {
package/dist/index.d.cts CHANGED
@@ -415,6 +415,7 @@ type Website = {
415
415
  layout: "start" | "end";
416
416
  mobileLayout: "default" | "inline";
417
417
  cssStyles: Array<Style>;
418
+ cssStylesMobile: Array<Style>;
418
419
  } | null;
419
420
  properties: WebsiteProperties;
420
421
  };
@@ -439,7 +440,7 @@ type Webpage = {
439
440
  title: string;
440
441
  slug: string;
441
442
  properties: WebpageProperties;
442
- blocks: Array<Block>;
443
+ blocks: Array<WebBlock>;
443
444
  webpages: Array<Webpage>;
444
445
  };
445
446
  /**
@@ -452,6 +453,7 @@ type WebpageProperties = {
452
453
  backgroundImageUrl: string | null;
453
454
  isSidebarDisplayed: boolean;
454
455
  cssStyles: Array<Style>;
456
+ cssStylesMobile: Array<Style>;
455
457
  };
456
458
  /**
457
459
  * Base properties for web elements
@@ -469,6 +471,7 @@ type WebElement = {
469
471
  };
470
472
  };
471
473
  cssStyles: Array<Style>;
474
+ cssStylesMobile: Array<Style>;
472
475
  } & WebElementComponent;
473
476
  /**
474
477
  * Union type of all possible web element components
@@ -583,20 +586,20 @@ type Style = {
583
586
  /**
584
587
  * Represents a block of vertical or horizontal content alignment
585
588
  */
586
- type Block = {
589
+ type WebBlock = {
587
590
  uuid: string;
588
591
  layout: "vertical" | "horizontal" | "grid";
589
- blocks: Array<Block>;
592
+ blocks: Array<WebBlock>;
590
593
  elements: Array<WebElement>;
591
594
  properties: {
592
595
  /**
593
596
  * valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
594
597
  */
595
- spacing: string | null;
598
+ spacing: string | undefined;
596
599
  /**
597
600
  * `gap` CSS property value
598
601
  */
599
- gap: "none" | "small" | "medium" | "large";
602
+ gap: string | undefined;
600
603
  /**
601
604
  * `align-items` CSS property value
602
605
  */
@@ -606,7 +609,9 @@ type Block = {
606
609
  */
607
610
  justifyContent: "stretch" | "start" | "center" | "end" | "space-between";
608
611
  };
612
+ propertiesMobile: Record<string, string> | null;
609
613
  cssStyles: Array<Style>;
614
+ cssStylesMobile: Array<Style>;
610
615
  };
611
616
 
612
617
  /**
@@ -715,7 +720,10 @@ type OchreStringItemContent = {
715
720
  * Raw string item with language metadata
716
721
  */
717
722
  type OchreStringItem = {
718
- string: FakeString | OchreStringItemContent | Array<OchreStringItemContent>;
723
+ string:
724
+ | FakeString
725
+ | OchreStringItemContent
726
+ | Array<FakeString | OchreStringItemContent>;
719
727
  lang?: Language["iso6393"]; // 3 character code (zxx = "a.k.a.")
720
728
  languages?: string; // 3 character codes, semicolon separated
721
729
  };
@@ -1838,4 +1846,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1838
1846
  */
1839
1847
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1840
1848
 
1841
- export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
1849
+ export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
package/dist/index.d.ts CHANGED
@@ -415,6 +415,7 @@ type Website = {
415
415
  layout: "start" | "end";
416
416
  mobileLayout: "default" | "inline";
417
417
  cssStyles: Array<Style>;
418
+ cssStylesMobile: Array<Style>;
418
419
  } | null;
419
420
  properties: WebsiteProperties;
420
421
  };
@@ -439,7 +440,7 @@ type Webpage = {
439
440
  title: string;
440
441
  slug: string;
441
442
  properties: WebpageProperties;
442
- blocks: Array<Block>;
443
+ blocks: Array<WebBlock>;
443
444
  webpages: Array<Webpage>;
444
445
  };
445
446
  /**
@@ -452,6 +453,7 @@ type WebpageProperties = {
452
453
  backgroundImageUrl: string | null;
453
454
  isSidebarDisplayed: boolean;
454
455
  cssStyles: Array<Style>;
456
+ cssStylesMobile: Array<Style>;
455
457
  };
456
458
  /**
457
459
  * Base properties for web elements
@@ -469,6 +471,7 @@ type WebElement = {
469
471
  };
470
472
  };
471
473
  cssStyles: Array<Style>;
474
+ cssStylesMobile: Array<Style>;
472
475
  } & WebElementComponent;
473
476
  /**
474
477
  * Union type of all possible web element components
@@ -583,20 +586,20 @@ type Style = {
583
586
  /**
584
587
  * Represents a block of vertical or horizontal content alignment
585
588
  */
586
- type Block = {
589
+ type WebBlock = {
587
590
  uuid: string;
588
591
  layout: "vertical" | "horizontal" | "grid";
589
- blocks: Array<Block>;
592
+ blocks: Array<WebBlock>;
590
593
  elements: Array<WebElement>;
591
594
  properties: {
592
595
  /**
593
596
  * valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
594
597
  */
595
- spacing: string | null;
598
+ spacing: string | undefined;
596
599
  /**
597
600
  * `gap` CSS property value
598
601
  */
599
- gap: "none" | "small" | "medium" | "large";
602
+ gap: string | undefined;
600
603
  /**
601
604
  * `align-items` CSS property value
602
605
  */
@@ -606,7 +609,9 @@ type Block = {
606
609
  */
607
610
  justifyContent: "stretch" | "start" | "center" | "end" | "space-between";
608
611
  };
612
+ propertiesMobile: Record<string, string> | null;
609
613
  cssStyles: Array<Style>;
614
+ cssStylesMobile: Array<Style>;
610
615
  };
611
616
 
612
617
  /**
@@ -715,7 +720,10 @@ type OchreStringItemContent = {
715
720
  * Raw string item with language metadata
716
721
  */
717
722
  type OchreStringItem = {
718
- string: FakeString | OchreStringItemContent | Array<OchreStringItemContent>;
723
+ string:
724
+ | FakeString
725
+ | OchreStringItemContent
726
+ | Array<FakeString | OchreStringItemContent>;
719
727
  lang?: Language["iso6393"]; // 3 character code (zxx = "a.k.a.")
720
728
  languages?: string; // 3 character codes, semicolon separated
721
729
  };
@@ -1838,4 +1846,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1838
1846
  */
1839
1847
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1840
1848
 
1841
- export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
1849
+ export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
package/dist/index.js CHANGED
@@ -149,7 +149,7 @@ function parseFakeString(string) {
149
149
  } else if (typeof string === "boolean") {
150
150
  returnString = string ? "Yes" : "No";
151
151
  }
152
- return returnString.replaceAll("&#39;", "'");
152
+ return returnString.replaceAll("&#39;", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
153
153
  }
154
154
  function parseStringItem(item) {
155
155
  let returnString = "";
@@ -166,12 +166,16 @@ function parseStringItem(item) {
166
166
  case "object": {
167
167
  const stringItems = Array.isArray(item.string) ? item.string : [item.string];
168
168
  for (const stringItem of stringItems) {
169
- const renderedText = stringItem.rend != null ? parseRenderOptions(
170
- parseFakeString(stringItem.content),
171
- stringItem.rend
172
- ) : parseFakeString(stringItem.content);
173
- const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
174
- returnString += whitespacedText;
169
+ if (typeof stringItem === "string" || typeof stringItem === "number" || typeof stringItem === "boolean") {
170
+ returnString += parseFakeString(stringItem);
171
+ } else {
172
+ const renderedText = stringItem.rend != null ? parseRenderOptions(
173
+ parseFakeString(stringItem.content),
174
+ stringItem.rend
175
+ ) : parseFakeString(stringItem.content);
176
+ const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
177
+ returnString += whitespacedText;
178
+ }
175
179
  }
176
180
  break;
177
181
  }
@@ -180,7 +184,7 @@ function parseStringItem(item) {
180
184
  break;
181
185
  }
182
186
  }
183
- return returnString;
187
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
184
188
  }
185
189
  function parseStringDocumentItem(item, footnotes) {
186
190
  if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
@@ -287,7 +291,7 @@ function parseStringDocumentItem(item, footnotes) {
287
291
  item.whitespace
288
292
  );
289
293
  }
290
- return returnString.replaceAll("&#39;", "'");
294
+ return returnString.replaceAll("&#39;", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
291
295
  } else {
292
296
  returnString = parseFakeString(item.content);
293
297
  if (item.rend != null) {
@@ -303,7 +307,7 @@ function parseStringDocumentItem(item, footnotes) {
303
307
  );
304
308
  }
305
309
  }
306
- return returnString;
310
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
307
311
  }
308
312
  function parseStringContent(content, language = "eng") {
309
313
  switch (typeof content.content) {
@@ -334,7 +338,7 @@ ${JSON.stringify(
334
338
  }
335
339
  }
336
340
  default: {
337
- return String(content.content);
341
+ return String(content.content).replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
338
342
  }
339
343
  }
340
344
  }
@@ -1801,6 +1805,14 @@ async function parseWebElement(elementResource, elementProperties) {
1801
1805
  const cssStyle = property.values[0].content;
1802
1806
  cssStyles.push({ label: property.label, value: cssStyle });
1803
1807
  }
1808
+ const mobileCssProperties = elementResourceProperties.find(
1809
+ (property) => property.label === "presentation" && property.values[0].content === "css-mobile"
1810
+ )?.properties ?? [];
1811
+ const cssStylesMobile = [];
1812
+ for (const property of mobileCssProperties) {
1813
+ const cssStyle = property.values[0].content;
1814
+ cssStylesMobile.push({ label: property.label, value: cssStyle });
1815
+ }
1804
1816
  const titleProperties = elementResourceProperties.find(
1805
1817
  (property) => property.label === "presentation" && property.values[0].content === "title"
1806
1818
  )?.properties;
@@ -1845,6 +1857,7 @@ async function parseWebElement(elementResource, elementProperties) {
1845
1857
  }
1846
1858
  },
1847
1859
  cssStyles,
1860
+ cssStylesMobile,
1848
1861
  ...properties
1849
1862
  };
1850
1863
  }
@@ -1894,12 +1907,14 @@ async function parseWebpage(webpageResource) {
1894
1907
  blocks: [],
1895
1908
  elements,
1896
1909
  properties: {
1897
- spacing: null,
1898
- gap: "none",
1910
+ spacing: void 0,
1911
+ gap: void 0,
1899
1912
  alignItems: "start",
1900
1913
  justifyContent: "stretch"
1901
1914
  },
1902
- cssStyles: []
1915
+ propertiesMobile: null,
1916
+ cssStyles: [],
1917
+ cssStylesMobile: []
1903
1918
  };
1904
1919
  blocks.push(block);
1905
1920
  elementsToHandle = [];
@@ -1916,12 +1931,14 @@ async function parseWebpage(webpageResource) {
1916
1931
  blocks: [],
1917
1932
  elements,
1918
1933
  properties: {
1919
- spacing: null,
1920
- gap: "none",
1934
+ spacing: void 0,
1935
+ gap: void 0,
1921
1936
  alignItems: "start",
1922
1937
  justifyContent: "stretch"
1923
1938
  },
1924
- cssStyles: []
1939
+ propertiesMobile: null,
1940
+ cssStyles: [],
1941
+ cssStylesMobile: []
1925
1942
  };
1926
1943
  blocks.push(block);
1927
1944
  }
@@ -1974,6 +1991,18 @@ async function parseWebpage(webpageResource) {
1974
1991
  });
1975
1992
  }
1976
1993
  }
1994
+ const mobileCssStyleSubProperties = webpageProperties.find(
1995
+ (property) => property.label === "presentation" && property.values[0]?.content === "css-mobile"
1996
+ )?.properties;
1997
+ const cssStylesMobile = [];
1998
+ if (mobileCssStyleSubProperties) {
1999
+ for (const property of mobileCssStyleSubProperties) {
2000
+ cssStylesMobile.push({
2001
+ label: property.label,
2002
+ value: property.values[0].content
2003
+ });
2004
+ }
2005
+ }
1977
2006
  return {
1978
2007
  title: identification.label,
1979
2008
  slug,
@@ -1984,7 +2013,8 @@ async function parseWebpage(webpageResource) {
1984
2013
  variant,
1985
2014
  backgroundImageUrl: imageLink ? `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load` : null,
1986
2015
  isSidebarDisplayed,
1987
- cssStyles
2016
+ cssStyles,
2017
+ cssStylesMobile
1988
2018
  },
1989
2019
  webpages
1990
2020
  };
@@ -2007,12 +2037,14 @@ async function parseBlock(blockResource) {
2007
2037
  blocks: [],
2008
2038
  elements: [],
2009
2039
  properties: {
2010
- spacing: null,
2011
- gap: "none",
2040
+ spacing: void 0,
2041
+ gap: void 0,
2012
2042
  alignItems: "start",
2013
2043
  justifyContent: "stretch"
2014
2044
  },
2015
- cssStyles: []
2045
+ propertiesMobile: null,
2046
+ cssStyles: [],
2047
+ cssStylesMobile: []
2016
2048
  };
2017
2049
  const blockProperties = blockResource.properties ? parseProperties(
2018
2050
  Array.isArray(blockResource.properties.property) ? blockResource.properties.property : [blockResource.properties.property]
@@ -2051,6 +2083,17 @@ async function parseBlock(blockResource) {
2051
2083
  if (justifyContentProperty) {
2052
2084
  returnBlock.properties.justifyContent = justifyContentProperty.content;
2053
2085
  }
2086
+ const mobileOverwriteProperty = blockMainProperties.find(
2087
+ (property) => property.label === "overwrite-mobile"
2088
+ );
2089
+ if (mobileOverwriteProperty) {
2090
+ const mobileOverwriteProperties = mobileOverwriteProperty.properties;
2091
+ const propertiesMobile = {};
2092
+ for (const property of mobileOverwriteProperties) {
2093
+ propertiesMobile[property.label] = property.values[0].content;
2094
+ }
2095
+ returnBlock.propertiesMobile = propertiesMobile;
2096
+ }
2054
2097
  }
2055
2098
  const blockBlocks = blockResource.resource ? await parseWebpageResources(
2056
2099
  Array.isArray(blockResource.resource) ? blockResource.resource : [blockResource.resource],
@@ -2077,6 +2120,17 @@ async function parseBlock(blockResource) {
2077
2120
  });
2078
2121
  }
2079
2122
  }
2123
+ const blockMobileCssStyles = blockProperties.find(
2124
+ (property) => property.label === "presentation" && property.values[0]?.content === "css-mobile"
2125
+ )?.properties;
2126
+ if (blockMobileCssStyles) {
2127
+ for (const property of blockMobileCssStyles) {
2128
+ returnBlock.cssStylesMobile.push({
2129
+ label: property.label,
2130
+ value: property.values[0].content
2131
+ });
2132
+ }
2133
+ }
2080
2134
  return returnBlock;
2081
2135
  }
2082
2136
  function parseWebsiteProperties(properties) {
@@ -2215,6 +2269,7 @@ async function parseWebsite(websiteTree, projectName, website) {
2215
2269
  let sidebarLayout = "start";
2216
2270
  let sidebarMobileLayout = "default";
2217
2271
  const sidebarCssStyles = [];
2272
+ const sidebarCssStylesMobile = [];
2218
2273
  const sidebarResource = resources.find((resource) => {
2219
2274
  const resourceProperties = resource.properties ? parseProperties(
2220
2275
  Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
@@ -2252,6 +2307,13 @@ async function parseWebsite(websiteTree, projectName, website) {
2252
2307
  const cssStyle = property.values[0].content;
2253
2308
  sidebarCssStyles.push({ label: property.label, value: cssStyle });
2254
2309
  }
2310
+ const mobileCssProperties = sidebarBaseProperties.find(
2311
+ (property) => property.label === "presentation" && property.values[0].content === "css-mobile"
2312
+ )?.properties ?? [];
2313
+ for (const property of mobileCssProperties) {
2314
+ const cssStyle = property.values[0].content;
2315
+ sidebarCssStylesMobile.push({ label: property.label, value: cssStyle });
2316
+ }
2255
2317
  const titleProperties = sidebarBaseProperties.find(
2256
2318
  (property) => property.label === "presentation" && property.values[0].content === "title"
2257
2319
  )?.properties;
@@ -2298,7 +2360,8 @@ async function parseWebsite(websiteTree, projectName, website) {
2298
2360
  title: sidebarTitle,
2299
2361
  layout: sidebarLayout,
2300
2362
  mobileLayout: sidebarMobileLayout,
2301
- cssStyles: sidebarCssStyles
2363
+ cssStyles: sidebarCssStyles,
2364
+ cssStylesMobile: sidebarCssStylesMobile
2302
2365
  };
2303
2366
  }
2304
2367
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
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",