@wix/himalaya-cli 0.1144.0 → 0.1146.0

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 (74) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/comments-v1/src/extensions.d.ts +4 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/forum/src/extensions.d.ts +10 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-comments.mjs +5 -2
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-forum.mjs +13 -0
  5. package/dist/cli.mjs +0 -3
  6. package/guides/sdk-reference.json +13 -1
  7. package/package.json +2 -2
  8. package/templates/beauty-salon/dev/index.ts +62 -3
  9. package/templates/beauty-salon/tier5-src/_shared/rich-body.ts +10 -4
  10. package/templates/beauty-salon/tier5-src/himi-blog-post/index.ts +12 -2
  11. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +35 -4
  12. package/templates/beauty-salon-owner/tier5-src/_shared/rich-body.ts +10 -4
  13. package/templates/branded-lite/dev/index.ts +273 -12
  14. package/templates/branded-lite/tier5-src/_shared/rich-body.ts +10 -4
  15. package/templates/branded-lite/tier5-src/himi-blog-post/index.ts +12 -2
  16. package/templates/branded-lite/tier5-src/himi-branded-lite-cms-collection/index.ts +43 -3
  17. package/templates/branded-lite/tier5-src/himi-branded-lite-faq/index.ts +69 -13
  18. package/templates/branded-lite/tier5-src/himi-branded-lite-feed/index.ts +23 -3
  19. package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +40 -3
  20. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +35 -4
  21. package/templates/branded-lite/tier5-src/wix-spaces-forum-post/index.ts +29 -5
  22. package/templates/community-club/dev/index.ts +135 -5
  23. package/templates/community-club/tier5-src/_shared/rich-body.ts +10 -4
  24. package/templates/community-club/tier5-src/himi-blog-post/index.ts +12 -2
  25. package/templates/community-club/tier5-src/himi-branded-lite-cms-collection/index.ts +43 -3
  26. package/templates/community-club/tier5-src/himi-branded-lite-feed/index.ts +23 -3
  27. package/templates/community-club/tier5-src/himi-events-detail/index.ts +40 -3
  28. package/templates/community-club-owner/tier5-src/_shared/rich-body.ts +10 -4
  29. package/templates/events-meetups/dev/index.ts +91 -4
  30. package/templates/events-meetups/tier5-src/_shared/rich-body.ts +10 -4
  31. package/templates/events-meetups/tier5-src/himi-blog-post/index.ts +12 -2
  32. package/templates/events-meetups/tier5-src/himi-branded-lite-feed/index.ts +23 -3
  33. package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +40 -3
  34. package/templates/events-meetups-owner/tier5-src/_shared/rich-body.ts +10 -4
  35. package/templates/gym-fitness/dev/index.ts +92 -4
  36. package/templates/gym-fitness/tier5-src/_shared/rich-body.ts +10 -4
  37. package/templates/gym-fitness/tier5-src/himi-blog-post/index.ts +12 -2
  38. package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +40 -3
  39. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +35 -4
  40. package/templates/gym-fitness-owner/tier5-src/_shared/rich-body.ts +10 -4
  41. package/templates/nonprofit-cause/dev/index.ts +91 -4
  42. package/templates/nonprofit-cause/tier5-src/_shared/rich-body.ts +10 -4
  43. package/templates/nonprofit-cause/tier5-src/himi-blog-post/index.ts +12 -2
  44. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-feed/index.ts +23 -3
  45. package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +40 -3
  46. package/templates/nonprofit-cause-owner/tier5-src/_shared/rich-body.ts +10 -4
  47. package/templates/owner-lite/tier5-src/_shared/rich-body.ts +10 -4
  48. package/templates/podcast-creator/dev/index.ts +91 -4
  49. package/templates/podcast-creator/tier5-src/_shared/rich-body.ts +10 -4
  50. package/templates/podcast-creator/tier5-src/himi-blog-post/index.ts +12 -2
  51. package/templates/podcast-creator/tier5-src/himi-branded-lite-feed/index.ts +23 -3
  52. package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +40 -3
  53. package/templates/podcast-creator-owner/tier5-src/_shared/rich-body.ts +10 -4
  54. package/templates/portfolio-creative/dev/index.ts +92 -4
  55. package/templates/portfolio-creative/tier5-src/_shared/rich-body.ts +10 -4
  56. package/templates/portfolio-creative/tier5-src/himi-blog-post/index.ts +12 -2
  57. package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +40 -3
  58. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +35 -4
  59. package/templates/portfolio-creative-owner/tier5-src/_shared/rich-body.ts +10 -4
  60. package/templates/restaurant/dev/index.ts +60 -2
  61. package/templates/restaurant/tier5-src/_shared/rich-body.ts +10 -4
  62. package/templates/restaurant/tier5-src/himi-blog-post/index.ts +12 -2
  63. package/templates/restaurant/tier5-src/himi-events-detail/index.ts +40 -3
  64. package/templates/restaurant-owner/tier5-src/_shared/rich-body.ts +10 -4
  65. package/templates/retail-store/dev/index.ts +62 -3
  66. package/templates/retail-store/tier5-src/_shared/rich-body.ts +10 -4
  67. package/templates/retail-store/tier5-src/himi-blog-post/index.ts +12 -2
  68. package/templates/retail-store/tier5-src/himi-store-product/index.ts +35 -4
  69. package/templates/retail-store-owner/tier5-src/_shared/rich-body.ts +10 -4
  70. package/templates/yoga-studio/dev/index.ts +60 -2
  71. package/templates/yoga-studio/tier5-src/_shared/rich-body.ts +10 -4
  72. package/templates/yoga-studio/tier5-src/himi-blog-post/index.ts +12 -2
  73. package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +40 -3
  74. package/templates/yoga-studio-owner/tier5-src/_shared/rich-body.ts +10 -4
@@ -5435,7 +5435,32 @@ const SCREENS = runtimeSetting({
5435
5435
  }
5436
5436
  },
5437
5437
  {
5438
- "id": "",
5438
+ "id": "feed_body_$item.id",
5439
+ "body": {
5440
+ "package": "himalaya",
5441
+ "type": "RichContent",
5442
+ "props": {
5443
+ "documentJsonPath": "$item.bodyJson",
5444
+ "onLink": {
5445
+ "actionId": "tier5.himiBrandedFeed.openLink"
5446
+ },
5447
+ "fallback": {
5448
+ "id": "",
5449
+ "body": {
5450
+ "package": "himalaya",
5451
+ "type": "Text",
5452
+ "props": {
5453
+ "text": "$item.text",
5454
+ "style": "body",
5455
+ "maxLines": 6
5456
+ }
5457
+ }
5458
+ }
5459
+ }
5460
+ }
5461
+ },
5462
+ {
5463
+ "id": "feed_body_text_$item.id",
5439
5464
  "body": {
5440
5465
  "package": "himalaya",
5441
5466
  "type": "Text",
@@ -5444,6 +5469,9 @@ const SCREENS = runtimeSetting({
5444
5469
  "style": "body",
5445
5470
  "maxLines": 6
5446
5471
  }
5472
+ },
5473
+ "modifiers": {
5474
+ "hiddenPath": "$item.hasBodyJson"
5447
5475
  }
5448
5476
  },
5449
5477
  {
@@ -5640,7 +5668,8 @@ const SCREENS = runtimeSetting({
5640
5668
  "integrity": "",
5641
5669
  "contentType": "application/javascript+ts-bundle",
5642
5670
  "declaredCapabilities": [
5643
- "wix_api"
5671
+ "wix_api",
5672
+ "open_url"
5644
5673
  ],
5645
5674
  "minBinaryVersion": "0.1.0",
5646
5675
  "bundleVersion": "0.0.1"
@@ -17473,7 +17502,33 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
17473
17502
  }
17474
17503
  },
17475
17504
  {
17476
- "id": "",
17505
+ "id": "event_body",
17506
+ "body": {
17507
+ "package": "himalaya",
17508
+ "type": "RichContent",
17509
+ "props": {
17510
+ "documentJsonPath": "$service:himiEventDetail.descriptionJson",
17511
+ "onLink": {
17512
+ "actionId": "tier5.himiEventDetail.openLink"
17513
+ },
17514
+ "fallback": {
17515
+ "id": "",
17516
+ "body": {
17517
+ "package": "himalaya",
17518
+ "type": "Text",
17519
+ "props": {
17520
+ "text": "$service:himiEventDetail.description",
17521
+ "style": "body",
17522
+ "color": "textSecondary",
17523
+ "collapseWhenEmpty": true
17524
+ }
17525
+ }
17526
+ }
17527
+ }
17528
+ }
17529
+ },
17530
+ {
17531
+ "id": "event_body_text",
17477
17532
  "body": {
17478
17533
  "package": "himalaya",
17479
17534
  "type": "Text",
@@ -17483,6 +17538,9 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
17483
17538
  "color": "textSecondary",
17484
17539
  "collapseWhenEmpty": true
17485
17540
  }
17541
+ },
17542
+ "modifiers": {
17543
+ "hiddenPath": "$service:himiEventDetail.hasDescriptionJson"
17486
17544
  }
17487
17545
  }
17488
17546
  ]
@@ -19377,7 +19435,33 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
19377
19435
  }
19378
19436
  },
19379
19437
  {
19380
- "id": "",
19438
+ "id": "comment_body_$item.id",
19439
+ "body": {
19440
+ "package": "himalaya",
19441
+ "type": "RichContent",
19442
+ "props": {
19443
+ "documentJsonPath": "$item.bodyJson",
19444
+ "onLink": {
19445
+ "actionId": "tier5.himiBlogPost.openLink"
19446
+ },
19447
+ "fallback": {
19448
+ "id": "",
19449
+ "body": {
19450
+ "package": "himalaya",
19451
+ "type": "Text",
19452
+ "props": {
19453
+ "text": "$item.text",
19454
+ "style": "body",
19455
+ "color": "textSecondary",
19456
+ "collapseWhenEmpty": true
19457
+ }
19458
+ }
19459
+ }
19460
+ }
19461
+ }
19462
+ },
19463
+ {
19464
+ "id": "comment_body_text_$item.id",
19381
19465
  "body": {
19382
19466
  "package": "himalaya",
19383
19467
  "type": "Text",
@@ -19387,6 +19471,9 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
19387
19471
  "color": "textSecondary",
19388
19472
  "collapseWhenEmpty": true
19389
19473
  }
19474
+ },
19475
+ "modifiers": {
19476
+ "hiddenPath": "$item.hasBodyJson"
19390
19477
  }
19391
19478
  }
19392
19479
  ]
@@ -20173,6 +20260,48 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
20173
20260
  ]
20174
20261
  }
20175
20262
  }
20263
+ },
20264
+ {
20265
+ "id": "cms_body_$item.id",
20266
+ "body": {
20267
+ "package": "himalaya",
20268
+ "type": "RichContent",
20269
+ "props": {
20270
+ "documentJsonPath": "$item.bodyJson",
20271
+ "onLink": {
20272
+ "actionId": "tier5.himiBrandedCmsCollection.openLink"
20273
+ },
20274
+ "fallback": {
20275
+ "id": "",
20276
+ "body": {
20277
+ "package": "himalaya",
20278
+ "type": "Text",
20279
+ "props": {
20280
+ "text": "$item.bodyText",
20281
+ "style": "body",
20282
+ "color": "textSecondary",
20283
+ "collapseWhenEmpty": true
20284
+ }
20285
+ }
20286
+ }
20287
+ }
20288
+ }
20289
+ },
20290
+ {
20291
+ "id": "cms_body_text_$item.id",
20292
+ "body": {
20293
+ "package": "himalaya",
20294
+ "type": "Text",
20295
+ "props": {
20296
+ "text": "$item.bodyText",
20297
+ "style": "body",
20298
+ "color": "textSecondary",
20299
+ "collapseWhenEmpty": true
20300
+ }
20301
+ },
20302
+ "modifiers": {
20303
+ "hiddenPath": "$item.hasBodyJson"
20304
+ }
20176
20305
  }
20177
20306
  ]
20178
20307
  }
@@ -20275,7 +20404,8 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
20275
20404
  "contentType": "application/javascript+ts-bundle",
20276
20405
  "declaredCapabilities": [
20277
20406
  "wix_api",
20278
- "local_database"
20407
+ "local_database",
20408
+ "open_url"
20279
20409
  ],
20280
20410
  "minBinaryVersion": "0.1.0",
20281
20411
  "bundleVersion": "0.0.1"
@@ -14,15 +14,21 @@ export interface RichBody {
14
14
  bodyText: string;
15
15
  }
16
16
 
17
+ /** [rico] #3372 — the media width for a document drawn in a LIST row (a feed post, a comment, a CMS item): the
18
+ * list-image size (WIX_LIST_IMAGE), so a scrolling list never downloads every image at detail size. */
19
+ export const ROW_IMAGE_WIDTH = 1000;
20
+
17
21
  /** Prepares `richContent` (a Ricos document, as a Wix API returns it, or its JSON string). No document, or one
18
22
  * that is not a document, gives `{ bodyJson: "", bodyText: fallback }`. A document past the viewer's limits
19
23
  * gives bodyJson "" and its plain text — except one rejected as too deep, which is not walked again (the
20
- * plain-text walk has no depth limit), so `fallback` stands in for it. */
21
- export function richBody(richContent: unknown, fallback = ""): RichBody {
24
+ * plain-text walk has no depth limit), so `fallback` stands in for it. `imageWidth` sizes its media (default
25
+ * the 1400 px detail budget). */
26
+ export function richBody(richContent: unknown, fallback = "", imageWidth = 1400): RichBody {
22
27
  const doc = parseRicosJson(richContent);
23
28
  if (!doc) return { bodyJson: "", bodyText: fallback };
24
- // 1400 px — the detail-image budget, which is also the encoder's maximum.
25
- const { json, rejected } = encodeRichContent(doc, { imageWidth: 1400 });
29
+ // 1400 px by default — the detail-image budget, which is also the encoder's maximum; list rows pass
30
+ // ROW_IMAGE_WIDTH.
31
+ const { json, rejected } = encodeRichContent(doc, { imageWidth });
26
32
  const text = rejected === "too_deep" ? "" : ricosToPlainText(doc);
27
33
  return { bodyJson: json, bodyText: text || fallback };
28
34
  }
@@ -8,7 +8,7 @@ import { isSavedId, toggleSavedId } from "../_shared/himi-blog-saved";
8
8
  import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
9
9
  import { formatDateMedium, formatMonthDay } from "../_shared/engine-intl.js";
10
10
  import { openRichLink } from "../_shared/rich-content-link.js";
11
- import { richBody } from "../_shared/rich-body.js";
11
+ import { richBody, ROW_IMAGE_WIDTH } from "../_shared/rich-body.js";
12
12
 
13
13
  // Offline-first (data-offline): the post body is a public read-through — when the
14
14
  // live fetch fails (offline) fall back to the last-synced row the feed cached under
@@ -23,8 +23,14 @@ async function readCachedPost(id: string): Promise<DbEntity | null> {
23
23
  interface CommentRow {
24
24
  id: string;
25
25
  authorName: string;
26
+ /** The comment's plain text: the row RichContent's fallback. */
26
27
  text: string;
27
28
  meta: string;
29
+ /** [rico] #3372 — the comment's Ricos document as ONE string for the row's RichContent; "" when it has none
30
+ * or the encoder rejected it. */
31
+ bodyJson: string;
32
+ /** bodyJson !== "" — gates the row's plain text, because RichContent draws nothing for "". */
33
+ hasBodyJson: boolean;
28
34
  }
29
35
 
30
36
  interface S {
@@ -168,11 +174,15 @@ function commentMeta(row: WixBlogCommentRow): string {
168
174
  }
169
175
 
170
176
  function toCommentRow(row: WixBlogCommentRow): CommentRow {
177
+ // The plain text is the document's own (runs joined as written, not space-separated) when it has one.
178
+ const { bodyJson, bodyText } = richBody(row.richContent, row.text || "Comment", ROW_IMAGE_WIDTH);
171
179
  return {
172
180
  id: row.id,
173
181
  authorName: row.authorName || "Member",
174
- text: row.text || "Comment",
182
+ text: bodyText,
175
183
  meta: commentMeta(row),
184
+ bodyJson,
185
+ hasBodyJson: bodyJson !== "",
176
186
  };
177
187
  }
178
188
 
@@ -10,6 +10,8 @@ import {
10
10
  import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
11
11
  import { getAll, upsert, type DbEntity } from "@himalaya/local-db";
12
12
  import { formatDateMedium } from "../_shared/engine-intl.js";
13
+ import { openRichLink } from "../_shared/rich-content-link.js";
14
+ import { richBody, ROW_IMAGE_WIDTH } from "../_shared/rich-body.js";
13
15
 
14
16
  // Offline-first (data-offline): a collection's items are a public read-through against
15
17
  // the on-device `cms_items` store. Rows are cached per collection (the persisted key is
@@ -23,9 +25,10 @@ async function readCached(collectionId: string): Promise<ItemRow[]> {
23
25
  try {
24
26
  const prefix = `${collectionId}::`;
25
27
  const rows = await getAll(ENTITY);
28
+ // A row cached before [rico] #3372 carries no document fields: it shows its plain text.
26
29
  return rows
27
30
  .filter((r) => typeof r.id === "string" && r.id.startsWith(prefix))
28
- .map((r) => ({ ...(r as unknown as ItemRow), id: (r.id as string).slice(prefix.length) }));
31
+ .map((r) => ({ bodyJson: "", hasBodyJson: false, bodyText: "", ...(r as unknown as Partial<ItemRow>), id: (r.id as string).slice(prefix.length) }) as ItemRow);
29
32
  } catch { return []; }
30
33
  }
31
34
  async function writeCached(collectionId: string, rows: ItemRow[]): Promise<void> {
@@ -41,6 +44,13 @@ interface ItemRow {
41
44
  initial: string;
42
45
  hasImage: boolean;
43
46
  noImage: boolean;
47
+ /** [rico] #3372 — the item's first RICH_CONTENT field as ONE document string for the row's RichContent; ""
48
+ * when the collection has none, the item left it empty, or the encoder rejected it. */
49
+ bodyJson: string;
50
+ /** bodyJson !== "" — gates the row's plain text, because RichContent draws nothing for "". */
51
+ hasBodyJson: boolean;
52
+ /** That field's plain text: the RichContent fallback. */
53
+ bodyText: string;
44
54
  }
45
55
 
46
56
  interface State {
@@ -86,10 +96,26 @@ function dateValue(value: unknown): string {
86
96
  return Number.isNaN(date.getTime()) ? raw : formatDateMedium(date);
87
97
  }
88
98
 
99
+ /** [rico] #3372 — RICH_TEXT is HTML: its text, with the tags removed and the common entities decoded, so a
100
+ * row never shows raw markup. A block or line-break tag separates words; an inline one (`W<i>ix</i>`) joins. */
101
+ export function stripHtml(html: string): string {
102
+ return html
103
+ .replace(/<\/?(?:p|div|br|li|ul|ol|h[1-6]|tr|td|th|blockquote|section|article)\b[^>]*>/gi, " ")
104
+ .replace(/<[^>]+>/g, "")
105
+ .replace(/&nbsp;/g, " ")
106
+ .replace(/&lt;/g, "<")
107
+ .replace(/&gt;/g, ">")
108
+ .replace(/&quot;/g, "\"")
109
+ .replace(/&#39;/g, "'")
110
+ .replace(/&amp;/g, "&")
111
+ .replace(/\s+/g, " ")
112
+ .trim();
113
+ }
114
+
89
115
  function displayValue(value: unknown, type = ""): string {
90
116
  if (value == null) return "";
91
117
  if (type.includes("DATE")) return dateValue(value);
92
- if (typeof value === "string") return value.trim();
118
+ if (typeof value === "string") return type.includes("RICH_TEXT") ? stripHtml(value) : value.trim();
93
119
  if (typeof value === "number" || typeof value === "boolean") return String(value);
94
120
  if (Array.isArray(value)) return value.map((entry) => displayValue(entry)).filter(Boolean).slice(0, 3).join(", ");
95
121
  if (typeof value === "object") {
@@ -116,13 +142,16 @@ function imageValue(data: Record<string, unknown>, fields: CmsFieldDefinition[])
116
142
  function itemRow(item: WixDataItem, collection: CmsCollectionDefinition, index: number): ItemRow {
117
143
  const data = item.data ?? {};
118
144
  const primary = displayValue(data[collection.displayField], collection.fields.find((field) => field.key === collection.displayField)?.type);
145
+ // A RICH_CONTENT field renders as the row's document, never as a detail line.
119
146
  const details = collection.fields
120
- .filter((field) => field.key !== collection.displayField && !field.type.includes("IMAGE"))
147
+ .filter((field) => field.key !== collection.displayField && !field.type.includes("IMAGE") && !field.type.includes("RICH_CONTENT"))
121
148
  .map((field) => ({ label: field.displayName, value: displayValue(data[field.key], field.type) }))
122
149
  .filter((entry) => entry.value)
123
150
  .slice(0, 2);
124
151
  const title = primary || copyTemplate("cmsCollection.itemFallbackTitle", "Item {n}", { n: index + 1 });
125
152
  const image = imageValue(data, collection.fields);
153
+ const rich = collection.fields.find((field) => field.type.includes("RICH_CONTENT"));
154
+ const { bodyJson, bodyText } = richBody(rich ? data[rich.key] : null, "", ROW_IMAGE_WIDTH);
126
155
  return {
127
156
  id: item.id || String(data._id ?? `${collection.id}-${index}`),
128
157
  title,
@@ -132,6 +161,9 @@ function itemRow(item: WixDataItem, collection: CmsCollectionDefinition, index:
132
161
  initial: (title[0] || "C").toUpperCase(),
133
162
  hasImage: Boolean(image),
134
163
  noImage: !image,
164
+ bodyJson,
165
+ hasBodyJson: bodyJson !== "",
166
+ bodyText,
135
167
  };
136
168
  }
137
169
 
@@ -202,6 +234,8 @@ let loadingCollectionId = "";
202
234
  const svc = defineService<State, {
203
235
  load: (state: State, arg?: unknown) => Promise<State>;
204
236
  search: (state: State, arg?: unknown) => State;
237
+ /** [rico] #3372 — a row RichContent's on_link: `{ url }` of the tapped link. */
238
+ openLink: (state: State, arg?: unknown) => Promise<State>;
205
239
  }>("himiBrandedCmsCollection", {
206
240
  state: initial,
207
241
  actions: {
@@ -255,6 +289,12 @@ const svc = defineService<State, {
255
289
  : state.all;
256
290
  return { ...state, rows, noRows: rows.length === 0, noEmpty: rows.length > 0, emptyText: query ? copyParam("cmsCollection.searchEmptyText", "No items match your search.") : copyParam("cmsCollection.emptyText", "This collection has no published items yet.") };
257
291
  },
292
+ // Only http(s), mailto and tel links reach open_url; the collection has no message line, so a refused
293
+ // link simply does nothing.
294
+ openLink: async (state, arg) => {
295
+ await openRichLink(arg);
296
+ return state;
297
+ },
258
298
  },
259
299
  });
260
300
 
@@ -23,6 +23,8 @@ import { signedInEmail } from "../_shared/himi-account";
23
23
  import { initials } from "../_shared/himi-text.js";
24
24
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
25
25
  import { formatMonthDay } from "../_shared/engine-intl.js";
26
+ import { openRichLink } from "../_shared/rich-content-link.js";
27
+ import { richBody, ROW_IMAGE_WIDTH } from "../_shared/rich-body.js";
26
28
 
27
29
  interface FeedRow {
28
30
  id: string;
@@ -33,8 +35,15 @@ interface FeedRow {
33
35
  avatar: string;
34
36
  hasAvatar: boolean;
35
37
  noAvatar: boolean;
38
+ /** The post's plain text: RichContent's fallback, and what shows for a post with no Ricos document. */
36
39
  text: string;
37
- /** First inline IMAGE node in the post content ("" for text-only posts). */
40
+ /** [rico] #3372 — a Ricos post's `content` as ONE document string for the row's RichContent; "" for a
41
+ * DraftJS-blocks post, a lean one, or a document the encoder rejected. */
42
+ bodyJson: string;
43
+ /** bodyJson !== "" — gates the row's plain text, because RichContent draws nothing for "". */
44
+ hasBodyJson: boolean;
45
+ /** First inline IMAGE node in the post content ("" for text-only posts). Shown only for a row with no
46
+ * document: RichContent draws the document's images itself. */
38
47
  image: string;
39
48
  hasImage: boolean;
40
49
  noImage: boolean;
@@ -161,7 +170,10 @@ function feedRow(item: WixFeedItem, profiles: WixFeedProfile[]): FeedRow {
161
170
  const author = authorName(item, profiles);
162
171
  const count = Array.isArray(item.reactionsList) ? item.reactionsList.length : 0;
163
172
  const avatar = authorAvatar(item, profiles);
164
- const image = contentImage(item);
173
+ // A Ricos post's plain text is the whole document's (every node level), not feedText's one-level read.
174
+ const { bodyJson, bodyText: text } = richBody(item.content, feedText(item), ROW_IMAGE_WIDTH);
175
+ // A Ricos post draws its own images in RichContent, so the separate row image would repeat the first one.
176
+ const image = bodyJson ? "" : contentImage(item);
165
177
  return {
166
178
  id: item.feedItemId || "",
167
179
  author,
@@ -169,7 +181,9 @@ function feedRow(item: WixFeedItem, profiles: WixFeedProfile[]): FeedRow {
169
181
  avatar,
170
182
  hasAvatar: !!avatar,
171
183
  noAvatar: !avatar,
172
- text: feedText(item),
184
+ text,
185
+ bodyJson,
186
+ hasBodyJson: bodyJson !== "",
173
187
  image,
174
188
  hasImage: !!image,
175
189
  noImage: !image,
@@ -292,6 +306,8 @@ const svc = defineService<State, {
292
306
  filter: (state: State, arg?: unknown) => State;
293
307
  post: (state: State, arg?: unknown) => Promise<State>;
294
308
  react: (state: State, arg?: unknown) => Promise<State>;
309
+ /** [rico] #3372 — a row RichContent's on_link: `{ url }` of the tapped link. */
310
+ openLink: (state: State, arg?: unknown) => Promise<State>;
295
311
  }>("himiBrandedFeed", {
296
312
  state: derive({
297
313
  status: "loading",
@@ -367,6 +383,10 @@ const svc = defineService<State, {
367
383
  return state;
368
384
  }
369
385
  },
386
+ // Only http(s), mailto and tel links reach open_url; one that does not open says so in the message line.
387
+ openLink: async (state, arg) => ((await openRichLink(arg))
388
+ ? state
389
+ : { ...state, message: copyParam("feed.linkOpenFailed", "This link could not be opened.") }),
370
390
  },
371
391
  });
372
392
 
@@ -35,6 +35,8 @@ import {
35
35
  } from "../_shared/himi-events";
36
36
  import { initials } from "../_shared/himi-text.js";
37
37
  import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
38
+ import { openRichLink } from "../_shared/rich-content-link.js";
39
+ import { richBody } from "../_shared/rich-body.js";
38
40
 
39
41
  interface MapMarker {
40
42
  latitude: number;
@@ -88,7 +90,13 @@ interface S {
88
90
  initial: string;
89
91
  when: string;
90
92
  location: string;
93
+ /** The plain-text description: RichContent's fallback, the calendar notes, and what shows with no document. */
91
94
  description: string;
95
+ /** [rico] #3372 — the v3 Ricos `description` (read with `fields=TEXTS`) as ONE document string for
96
+ * RichContent; "" when the event has none or the encoder rejected it. */
97
+ descriptionJson: string;
98
+ /** descriptionJson !== "" — gates the plain text, because RichContent draws nothing for "". */
99
+ hasDescriptionJson: boolean;
92
100
  image: string;
93
101
  hasImage: boolean;
94
102
  noImage: boolean;
@@ -212,6 +220,7 @@ function derive(s: S): S {
212
220
  const hasAttendees = s.attendeeAvatars.length > 0;
213
221
  return {
214
222
  ...s,
223
+ hasDescriptionJson: s.descriptionJson !== "",
215
224
  noMap: !s.mapUrl,
216
225
  hasMapMarkers,
217
226
  noMapMarkers: !hasMapMarkers,
@@ -357,6 +366,14 @@ async function attendeeSummary(eventId: string): Promise<{ goingLabel: string; a
357
366
  }
358
367
  }
359
368
 
369
+ /** The description pair: the v3 Ricos `description` for RichContent, and its plain text. A string description
370
+ * (or none) keeps `eventDescription`'s legacy read, with no document. */
371
+ function eventBody(e: WixEvent): { description: string; descriptionJson: string } {
372
+ const legacy = eventDescription(e);
373
+ const { bodyJson, bodyText } = richBody((e as unknown as { description?: unknown }).description, legacy);
374
+ return { description: bodyText, descriptionJson: bodyJson };
375
+ }
376
+
360
377
  /** getEvent returns the slim BASE fieldset (no `registration`); enrich from the
361
378
  * richer query when the type is unknown — best-effort, find-by-id. */
362
379
  async function enrichRegistration(id: string, e: WixEvent): Promise<WixEvent> {
@@ -364,7 +381,11 @@ async function enrichRegistration(id: string, e: WixEvent): Promise<WixEvent> {
364
381
  try {
365
382
  const list = await queryEvents({ limit: 100 });
366
383
  const match = (list.events ?? []).find((candidate) => candidate.id === id);
367
- return match ?? e;
384
+ if (!match) return e;
385
+ // [rico] #3372 — the query's rows are read without TEXTS, so they carry no Ricos `description`: keep the
386
+ // one this detail fetched, or the enrichment would silently drop the document on every real site.
387
+ const description = (e as unknown as { description?: unknown }).description;
388
+ return description === undefined ? match : ({ ...match, description } as unknown as WixEvent);
368
389
  } catch {
369
390
  return e;
370
391
  }
@@ -377,6 +398,8 @@ const svc = defineService<S, {
377
398
  openRegistration: (s: S) => Promise<S>;
378
399
  share: (s: S) => Promise<S>;
379
400
  addToCalendar: (s: S) => Promise<S>;
401
+ /** [rico] #3372 — RichContent's on_link: `{ url }` of the tapped link. */
402
+ openLink: (s: S, arg?: unknown) => Promise<S>;
380
403
  }>("himiEventDetail", {
381
404
  state: derive({
382
405
  status: "loading",
@@ -386,6 +409,8 @@ const svc = defineService<S, {
386
409
  when: "",
387
410
  location: "",
388
411
  description: "",
412
+ descriptionJson: "",
413
+ hasDescriptionJson: false,
389
414
  image: "",
390
415
  hasImage: false,
391
416
  noImage: true,
@@ -433,7 +458,8 @@ const svc = defineService<S, {
433
458
  const id = s.id || inputId();
434
459
  if (!id) return derive({ ...s, status: "ready", errored: true });
435
460
  try {
436
- const res = await getEvent(id);
461
+ // TEXTS adds the Ricos `description` to the base fieldset (a bare read returns none).
462
+ const res = await getEvent(id, { fields: ["TEXTS"] });
437
463
  let e = ((res as unknown as { event?: WixEvent }).event ?? res) as WixEvent;
438
464
  e = await enrichRegistration(id, e);
439
465
  const attendees = await attendeeSummary(id);
@@ -460,7 +486,9 @@ const svc = defineService<S, {
460
486
  initial: (title.trim()[0] || "E").toUpperCase(),
461
487
  when: eventWhen(e),
462
488
  location: eventLocation(e),
463
- description: eventDescription(e),
489
+ // The Ricos description when the event has one (its own text is the plain copy); the legacy
490
+ // string fields otherwise.
491
+ ...eventBody(e),
464
492
  image,
465
493
  hasImage: !!image,
466
494
  noImage: !image,
@@ -491,6 +519,9 @@ const svc = defineService<S, {
491
519
  initial: (title.trim()[0] || "E").toUpperCase(),
492
520
  when: cached.dateLine,
493
521
  location: cached.location,
522
+ // The cached list row carries no description: an offline retry of THIS event keeps the pair it
523
+ // already shows, and any other event's is cleared together, so neither half can linger alone.
524
+ ...(s.id === id ? {} : { description: "", descriptionJson: "" }),
494
525
  image: cached.image,
495
526
  hasImage: !!cached.image,
496
527
  noImage: !cached.image,
@@ -665,6 +696,12 @@ const svc = defineService<S, {
665
696
  return derive({ ...s, actionMessage: copyParam("event.calendarAddFailed", "Could not add this event to calendar."), isAddingCalendar: false });
666
697
  }
667
698
  },
699
+ // Only http(s), mailto and tel links reach open_url; a refused link, or one nothing opened, says so, and a
700
+ // link that opens clears an earlier message.
701
+ openLink: async (s, arg) => derive({
702
+ ...s,
703
+ actionMessage: (await openRichLink(arg)) ? "" : copyParam("event.linkOpenFailed", "This link could not be opened."),
704
+ }),
668
705
  },
669
706
  });
670
707
  svc.load();
@@ -14,15 +14,21 @@ export interface RichBody {
14
14
  bodyText: string;
15
15
  }
16
16
 
17
+ /** [rico] #3372 — the media width for a document drawn in a LIST row (a feed post, a comment, a CMS item): the
18
+ * list-image size (WIX_LIST_IMAGE), so a scrolling list never downloads every image at detail size. */
19
+ export const ROW_IMAGE_WIDTH = 1000;
20
+
17
21
  /** Prepares `richContent` (a Ricos document, as a Wix API returns it, or its JSON string). No document, or one
18
22
  * that is not a document, gives `{ bodyJson: "", bodyText: fallback }`. A document past the viewer's limits
19
23
  * gives bodyJson "" and its plain text — except one rejected as too deep, which is not walked again (the
20
- * plain-text walk has no depth limit), so `fallback` stands in for it. */
21
- export function richBody(richContent: unknown, fallback = ""): RichBody {
24
+ * plain-text walk has no depth limit), so `fallback` stands in for it. `imageWidth` sizes its media (default
25
+ * the 1400 px detail budget). */
26
+ export function richBody(richContent: unknown, fallback = "", imageWidth = 1400): RichBody {
22
27
  const doc = parseRicosJson(richContent);
23
28
  if (!doc) return { bodyJson: "", bodyText: fallback };
24
- // 1400 px — the detail-image budget, which is also the encoder's maximum.
25
- const { json, rejected } = encodeRichContent(doc, { imageWidth: 1400 });
29
+ // 1400 px by default — the detail-image budget, which is also the encoder's maximum; list rows pass
30
+ // ROW_IMAGE_WIDTH.
31
+ const { json, rejected } = encodeRichContent(doc, { imageWidth });
26
32
  const text = rejected === "too_deep" ? "" : ricosToPlainText(doc);
27
33
  return { bodyJson: json, bodyText: text || fallback };
28
34
  }