@bison-lab/payload-core 3.33.1 → 3.34.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.
package/README.md CHANGED
@@ -409,9 +409,10 @@ place of the stock blocks UI. The Header edit view is
409
409
  `@bison-lab/payload-blocks/admin#AdminWorkspace`. Footer is the same
410
410
  workspace on `navigation-footer`; `footer` is a group whose Field is
411
411
  `@bison-lab/payload-blocks/admin#FooterColumnsField`. Columns hold
412
- sections (a required section label plus links). Desktop widths include
413
- the logo column and must add to 100%. Brand copy and social URLs sit on
414
- Brand & social. The copyright line and "Built by Bison Lab." are
412
+ sections (a required section label plus links). Link-column desktop
413
+ widths add to 100% of the space beside the logo, not of the full footer.
414
+ Brand copy and social URLs sit on
415
+ the Logo column. The copyright line and "Built by Bison Lab." are
415
416
  code-locked. A site that already generates the blocks admin map picks
416
417
  both editors up with `payload generate:importmap`; until it does, those
417
418
  slots render as nothing. `bar` stores hide on scroll, shared viewport,
@@ -420,7 +421,8 @@ looks stay on chrome roles, not a variants array on this document. A
420
421
  Footer consume runs `payload generate:importmap`, `payload generate:types`,
421
422
  and `payload migrate:create` — existing `footer.columns` rows are
422
423
  `{ heading, links }` and need a wrap into `{ desktop, sections }`.
423
- `getNavigation` returns `{ header, footer, bar }`.
424
+ Link-column widths that used to include the logo in the 100% need a
425
+ remap (`Normalize desktop`). `getNavigation` returns `{ header, footer, bar }`.
424
426
 
425
427
  A site that already stored footer columns on the `nav` document copies
426
428
  `footer.columns` onto the new global, then drops the footer fields from
@@ -428,8 +430,15 @@ A site that already stored footer columns on the `nav` document copies
428
430
 
429
431
  ## FAQ Library
430
432
 
431
- `createQuestions` is one document per FAQ (question, textarea answer, drafts)
432
- with a kit List that replaces Payload's stock collection list. `createTaxonomy`
433
+ `createQuestions` is one document per FAQ (question, richText answer, drafts)
434
+ with a kit List that replaces Payload's stock collection list. The answer is
435
+ Payload's default Lexical editor — the same one the pages rich-text block
436
+ uses; the kit dialog mounts it, not the stock document form. Hidden
437
+ `answerText` is the varchar the list searches; `syncAnswerText` (the
438
+ collection `beforeChange` hook, also exported) writes it whenever `answer`
439
+ is in the incoming data. A site that replaces `hooks.beforeChange` must
440
+ keep that hook or search stops matching answers. Do not `contains` on
441
+ `answer` — Postgres rejects `ilike` against jsonb. `createTaxonomy`
433
442
  is a name-only terms collection, hidden from the nav; add and delete for
434
443
  `manage: true` facets happen on that list. Pass Anatomy-like collections and
435
444
  Topics through `organizeBy` — the package does not know "anatomy". Feature
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/preview-mode.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;cCsBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCOjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cM4Da,cAAA,EAAgB,0BAAA;;;;;;;cCnDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cC0IhB,YAAA,EAAc,sBAAA;;;;;;;;iBCtIX,qBAAA,CAAA;;AVAhB;;;iBUQgB,eAAA,CAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA;;iBA0Bf,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;KCrCpB,gBAAA;AAAA,iBAkCI,mBAAA,CAAoB,IAAA,EAAM,gBAAA;;;;;;;cClC7B,gBAAA,EAAkB,sBAAA;;;;;;;cCIlB,SAAA,EAAW,wBAAA;;;;;;;;cCqBX,gBAAA,EAAkB,yBAAA;;;;;;iBC1Bf,aAAA,CAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;cCChB,aAAA,EAAe,wBAAA;;;;;;;;;cC2Bf,SAAA,EAAW,wBAAA;;;;;;;iBC1BR,aAAA,CAAc,KAAA,EAAO,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cCAjD,aAAA,EAAe,wBAAA;;;;;;;;cC8Cf,UAAA,EAAY,0BAAA;;;;;;;;cChCZ,gBAAA,EAAkB,wBAAA;;;;;;;;;ArBZ/B;;csB0Ca,mBAAA,EAAqB,yBAAA;;;iBCflB,oBAAA,CAAA;EAAuB;AAAA;EAAc,QAAA,GAAW,SAAA;AAAA,IAAW,kBAAA,CAAA,GAAA,CAAA,OAAA;;;iBCxB3D,iBAAA,CAAA;EAAoB;AAAA;EAAU,IAAA;AAAA,IAAc,kBAAA,CAAA,GAAA,CAAA,OAAA;;;UCmB3C,uBAAA;EACf,WAAA;EACA,OAAA;AAAA;;;UC5Be,aAAA;EACf,eAAA,GAAkB,uBAAA;AAAA;;;A1BGpB;;;iB0B6CgB,QAAA,CAAA;EAAW;AAAA,GAAmB,aAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;iBCnD3C,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBCGhB,oBAAA,CAAA,GAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;cCEvB,mBAAA,EAAqB,wBAAA;;;;;;;;A7BClC;U8BFiB,cAAA;;EAEf,MAAA;E9ByED;E8BvEC,IAAA;;EAEA,KAAA;E7BkBW;E6BhBX,MAAA;AAAA;AAAA,UAGe,eAAA;E7BgEhB;E6B9DC,IAAA;;EAEA,KAAA;E5BgBW;E4BdX,UAAA;;;;;EAKA,MAAA;;EAEA,IAAA,GAAO,cAAA;AAAA;;;iBC+JO,aAAA,CACd,KAAA,EAAO,mBAAA;EAAwB,UAAA,YAAsB,eAAA;AAAA,IAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBCtL1D,gBAAA,CAAA;EAAmB;AAAA;EAAU,IAAA;AAAA;;;iBC2G7B,aAAA,CAAc,KAAA,EAAO,mBAAA,GAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/preview-mode.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;cCsBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCOjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cM4Da,cAAA,EAAgB,0BAAA;;;;;;;cCnDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cC0IhB,YAAA,EAAc,sBAAA;;;;;;;;iBCtIX,qBAAA,CAAA;;AVAhB;;;iBUQgB,eAAA,CAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA;;iBA0Bf,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;KCrCpB,gBAAA;AAAA,iBAkCI,mBAAA,CAAoB,IAAA,EAAM,gBAAA;;;;;;;cClC7B,gBAAA,EAAkB,sBAAA;;;;;;;cCIlB,SAAA,EAAW,wBAAA;;;;;;;;cCqBX,gBAAA,EAAkB,yBAAA;;;;;;iBC1Bf,aAAA,CAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;cCChB,aAAA,EAAe,wBAAA;;;;;;;;;cC2Bf,SAAA,EAAW,wBAAA;;;;;;;iBC1BR,aAAA,CAAc,KAAA,EAAO,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cCAjD,aAAA,EAAe,wBAAA;;;;;;;;cC8Cf,UAAA,EAAY,0BAAA;;;;;;;;cChCZ,gBAAA,EAAkB,wBAAA;;;;;;;;;ArBZ/B;;csB0Ca,mBAAA,EAAqB,yBAAA;;;iBCflB,oBAAA,CAAA;EAAuB;AAAA;EAAc,QAAA,GAAW,SAAA;AAAA,IAAW,kBAAA,CAAA,GAAA,CAAA,OAAA;;;iBCxB3D,iBAAA,CAAA;EAAoB;AAAA;EAAU,IAAA;AAAA,IAAc,kBAAA,CAAA,GAAA,CAAA,OAAA;;;UCmB3C,uBAAA;EACf,WAAA;EACA,OAAA;AAAA;;;UC5Be,aAAA;EACf,eAAA,GAAkB,uBAAA;AAAA;;;A1BGpB;;;iB0B6CgB,QAAA,CAAA;EAAW;AAAA,GAAmB,aAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;iBCnD3C,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBCGhB,oBAAA,CAAA,GAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;cCEvB,mBAAA,EAAqB,wBAAA;;;;;;;;A7BClC;U8BFiB,cAAA;;EAEf,MAAA;E9ByED;E8BvEC,IAAA;;EAEA,KAAA;E7BkBW;E6BhBX,MAAA;AAAA;AAAA,UAGe,eAAA;E7BgEhB;E6B9DC,IAAA;;EAEA,KAAA;E5BgBW;E4BdX,UAAA;;;;;EAKA,MAAA;;EAEA,IAAA,GAAO,cAAA;AAAA;;;iBCyKO,aAAA,CACd,KAAA,EAAO,mBAAA;EAAwB,UAAA,YAAsB,eAAA;AAAA,IAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;iBChM1D,gBAAA,CAAA;EAAmB;AAAA;EAAU,IAAA;AAAA;;;iBC2G7B,aAAA,CAAc,KAAA,EAAO,mBAAA,GAAmB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
package/dist/admin.mjs CHANGED
@@ -4,11 +4,12 @@ import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, Field
4
4
  import { GREY_SCALES, SHADE_STEPS, contrastForeground, contrastRatio, createColorScale, deriveDarkPalette, deriveLightPalette, hexToHSL, hslToString, includedShadeSteps, isThemeHex, presetHints, setColorScaleInclude } from "@bison-lab/tokens";
5
5
  import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { Badge, Button as Button$1, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Input, KitProvider, Label, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Table, TableActions, TableCell, TableHead, TableRow, Textarea, Thumbnail } from "@bison-lab/admin-ui";
7
+ import { Badge, Button as Button$1, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Fold, Input, KitProvider, Label, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Stack, Switch, Table, TableActions, TableCell, TableHead, TableRow, Thumbnail } from "@bison-lab/admin-ui";
8
8
  import { HexColorPicker } from "react-colorful";
9
9
  import { createPortal } from "react-dom";
10
10
  import { findFont, fontFaceCss, isFontId } from "@bison-lab/fonts";
11
11
  import "payload";
12
+ import { RenderLexical } from "@payloadcms/richtext-lexical/client";
12
13
  import { formatAdminURL, formatFilesize } from "payload/shared";
13
14
  //#region src/admin/color-field.tsx
14
15
  const HEX_ERROR = "Enter a six-digit hex colour like #1e3a5f";
@@ -4109,14 +4110,12 @@ const QUESTIONS_LIST_CSS = `
4109
4110
  .bl-faq-library__taxrow .bl-faq-library__taxmeta{display:inline-flex;align-items:center;gap:14px}
4110
4111
  .bl-faq-library__addrow{display:flex;gap:7px;padding:10px;border-top:1px solid var(--bl-kit-border);background:var(--bl-kit-surface-well)}
4111
4112
  .bl-faq-library__addrow .bl-nav-kit__input{flex:1;min-width:0}
4112
- .bl-faq-library__modal .bl-nav-kit__modal-card,.bl-faq-library__dialog.bl-nav-kit__modal-card{width:min(760px,100%)}
4113
+ .bl-faq-library__answer-editor{min-height:180px}
4114
+ .bl-faq-library__answer-editor .rich-text-lexical{border:1px solid var(--bl-kit-border);border-radius:var(--bl-kit-radius-sm);background:var(--bl-kit-surface)}
4115
+ .bl-faq-library__modal .bl-nav-kit__modal-card{width:min(840px,calc(100vw - 2rem))}
4113
4116
  .bl-faq-library__modal-card{width:min(760px,calc(100vw - 2rem));max-height:calc(100vh - 48px);overflow:auto;background:var(--bl-kit-surface);border:1px solid var(--bl-kit-border);border-radius:var(--bl-kit-radius-lg);box-shadow:var(--bl-kit-shadow)}
4114
- .bl-faq-library__modal-head{display:flex;justify-content:space-between;align-items:center;padding:18px 22px;border-bottom:1px solid var(--bl-kit-border);position:sticky;top:0;background:var(--bl-kit-surface);z-index:2}
4115
- .bl-faq-library__modal-head h2{margin:0;font-size:20px}
4116
- .bl-faq-library__modal-body{padding:20px 22px}
4117
4117
  .bl-faq-library__grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}
4118
4118
  .bl-faq-library__section{font-weight:800;margin:4px 0 12px;padding-top:14px;border-top:1px solid var(--bl-kit-border-divider)}
4119
- .bl-faq-library__hint{display:block;margin-top:6px;color:var(--bl-kit-ink-muted);font-size:12px}
4120
4119
  .bl-faq-library__choicebox{border:1px solid var(--bl-kit-border-strong);border-radius:var(--bl-kit-radius-sm);overflow:hidden;background:var(--bl-kit-surface)}
4121
4120
  .bl-faq-library__choice{display:flex;align-items:center;gap:9px;margin:0;padding:9px 11px;border-bottom:1px solid var(--bl-kit-border-divider);cursor:pointer;font-weight:500}
4122
4121
  .bl-faq-library__choice:last-child{border-bottom:0}
@@ -4124,7 +4123,8 @@ const QUESTIONS_LIST_CSS = `
4124
4123
  .bl-faq-library__addtag{border:0;background:transparent;color:var(--bl-kit-accent,#2563eb);padding:8px 0 0;cursor:pointer;font-weight:650}
4125
4124
  .bl-faq-library__addtag:hover{text-decoration:underline}
4126
4125
  .bl-faq-library__inline-add{display:flex;gap:7px;margin-top:8px}
4127
- .bl-faq-library__notice{padding:11px 12px;border-radius:var(--bl-kit-radius-sm);background:var(--bl-kit-accent-soft);color:var(--bl-kit-accent,#2563eb);font-size:13px}
4126
+ .bl-faq-library__modal .bl-nav-kit__fold-body{padding:0 12px 12px}
4127
+ .bl-faq-library__modal .bl-nav-kit__fold .bl-faq-library__choicebox{margin-top:2px}
4128
4128
  .bl-faq-library__modal-foot{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:16px 22px;border-top:1px solid var(--bl-kit-border);position:sticky;bottom:0;background:var(--bl-kit-surface)}
4129
4129
  .bl-faq-library__published{display:flex;align-items:center;gap:8px;color:var(--bl-kit-ink-muted);cursor:pointer}
4130
4130
  .bl-faq-library__foot-actions{display:flex;gap:8px}
@@ -4146,6 +4146,46 @@ const QUESTIONS_LIST_CSS = `
4146
4146
  }
4147
4147
  `;
4148
4148
  //#endregion
4149
+ //#region src/questions/lexical-text.ts
4150
+ /**
4151
+ * Plain text inside a Lexical document (or a leftover string). Empty
4152
+ * when there are no text nodes, or only whitespace — the same rule the
4153
+ * kit dialog uses to refuse an empty answer.
4154
+ */
4155
+ function lexicalPlainText(value) {
4156
+ if (value == null) return "";
4157
+ if (typeof value === "string") return value.replace(/\s+/g, " ").trim();
4158
+ return collect(value).replace(/\s+/g, " ").trim();
4159
+ }
4160
+ const BLOCK_SIBLING = new Set([
4161
+ "paragraph",
4162
+ "heading",
4163
+ "quote",
4164
+ "list",
4165
+ "listitem"
4166
+ ]);
4167
+ function isBlockSibling(node) {
4168
+ if (!node || typeof node !== "object") return false;
4169
+ return BLOCK_SIBLING.has(String(node.type));
4170
+ }
4171
+ function collect(node) {
4172
+ if (typeof node === "string") return node;
4173
+ if (!node || typeof node !== "object") return "";
4174
+ const rec = node;
4175
+ if (typeof rec.text === "string") return rec.text;
4176
+ if (rec.type === "linebreak") return " ";
4177
+ if (rec.root) return collect(rec.root);
4178
+ if (!Array.isArray(rec.children)) return "";
4179
+ let out = "";
4180
+ for (const child of rec.children) {
4181
+ const piece = collect(child);
4182
+ if (!piece) continue;
4183
+ if (out && isBlockSibling(child)) out += " ";
4184
+ out += piece;
4185
+ }
4186
+ return out;
4187
+ }
4188
+ //#endregion
4149
4189
  //#region src/admin/questions-list.tsx
4150
4190
  const ALL = "__all__";
4151
4191
  const PAGE_SIZE = 25;
@@ -4161,9 +4201,19 @@ function idsFrom(value) {
4161
4201
  if (!Array.isArray(value)) return [];
4162
4202
  return value.map(asId).filter((id) => id !== null);
4163
4203
  }
4164
- function termName(value) {
4165
- if (value && typeof value === "object" && "name" in value && typeof value.name === "string") return value.name;
4166
- return "";
4204
+ function stringField(doc, key) {
4205
+ const value = doc[key];
4206
+ return typeof value === "string" && value.trim() ? value.trim() : "";
4207
+ }
4208
+ function titleFieldFor(collectionSlug, collections) {
4209
+ const title = collections.find((entry) => entry.slug === collectionSlug)?.admin?.useAsTitle;
4210
+ return typeof title === "string" && title.trim() ? title : "name";
4211
+ }
4212
+ /** Label from the collection title field, then `name`, then `title`. */
4213
+ function termName(value, titleField = "name") {
4214
+ if (!value || typeof value !== "object") return "";
4215
+ const rec = value;
4216
+ return stringField(rec, titleField) || stringField(rec, "name") || stringField(rec, "title");
4167
4217
  }
4168
4218
  function familyFromDoc(value) {
4169
4219
  if (!value || typeof value !== "object") return void 0;
@@ -4230,10 +4280,6 @@ function manageIntro(entries) {
4230
4280
  }
4231
4281
  return parts.join(" ");
4232
4282
  }
4233
- function facetHint(entry) {
4234
- if (entry.manage) return `Use ${entry.label.toLowerCase()} to group related FAQs.`;
4235
- return `Select every ${termSingular(entry.label)} this FAQ applies to.`;
4236
- }
4237
4283
  function useApi() {
4238
4284
  const { config } = useConfig();
4239
4285
  const base = `${config.serverURL}${config.routes.api}`;
@@ -4267,6 +4313,7 @@ function QuestionsList(props) {
4267
4313
  }
4268
4314
  function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4269
4315
  const { setStepNav } = useStepNav();
4316
+ const { config } = useConfig();
4270
4317
  const organizeBy = useOrganizeBy(collectionSlug, organizeByProp);
4271
4318
  const request = useApi();
4272
4319
  useEffect(() => {
@@ -4284,7 +4331,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4284
4331
  const [faqOpen, setFaqOpen] = useState(false);
4285
4332
  const [editing, setEditing] = useState(null);
4286
4333
  const [draftQuestion, setDraftQuestion] = useState("");
4287
- const [draftAnswer, setDraftAnswer] = useState("");
4334
+ const [draftAnswer, setDraftAnswer] = useState(null);
4288
4335
  const [draftFacets, setDraftFacets] = useState({});
4289
4336
  const [published, setPublished] = useState(true);
4290
4337
  const [inlineTopic, setInlineTopic] = useState(null);
@@ -4296,20 +4343,28 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4296
4343
  const loadTerms = useCallback(async () => {
4297
4344
  const next = {};
4298
4345
  await Promise.all(organizeBy.map(async (entry) => {
4299
- const data = await request(`/${entry.collection}?limit=200&sort=name&depth=0`);
4300
- next[entry.name] = (data.docs ?? []).map((doc) => ({
4301
- id: doc.id,
4302
- name: typeof doc.name === "string" ? doc.name : String(doc.id),
4303
- family: familyFromDoc(doc)
4304
- }));
4346
+ const titleField = titleFieldFor(entry.collection, config.collections);
4347
+ const data = await request(`/${entry.collection}?limit=200&sort=${encodeURIComponent(titleField)}&depth=0`);
4348
+ next[entry.name] = (data.docs ?? []).map((doc) => {
4349
+ const id = asId(doc) ?? String(doc.id ?? "");
4350
+ return {
4351
+ id,
4352
+ name: termName(doc, titleField) || String(id),
4353
+ family: familyFromDoc(doc)
4354
+ };
4355
+ });
4305
4356
  }));
4306
4357
  setTerms(next);
4307
- }, [organizeBy, request]);
4358
+ }, [
4359
+ config.collections,
4360
+ organizeBy,
4361
+ request
4362
+ ]);
4308
4363
  const loadDocs = useCallback(async () => {
4309
4364
  const where = { and: [] };
4310
4365
  const and = where.and;
4311
4366
  const q = search.trim();
4312
- if (q) and.push({ or: [{ question: { contains: q } }, { answer: { contains: q } }] });
4367
+ if (q) and.push({ or: [{ question: { contains: q } }, { answerText: { contains: q } }] });
4313
4368
  for (const [field, value] of Object.entries(filters)) if (value) and.push({ [field]: { equals: value } });
4314
4369
  const params = new URLSearchParams({
4315
4370
  depth: "1",
@@ -4381,7 +4436,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4381
4436
  function openFaq(doc) {
4382
4437
  setEditing(doc);
4383
4438
  setDraftQuestion(doc?.question ?? "");
4384
- setDraftAnswer(doc?.answer ?? "");
4439
+ setDraftAnswer(doc?.answer ?? null);
4385
4440
  setPublished(doc ? doc._status !== "draft" : true);
4386
4441
  const selected = {};
4387
4442
  for (const entry of organizeBy) selected[entry.name] = doc ? idsFrom(doc[entry.name]) : [];
@@ -4402,8 +4457,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4402
4457
  }
4403
4458
  async function saveFaq() {
4404
4459
  const question = draftQuestion.trim();
4405
- const answer = draftAnswer.trim();
4406
- if (!question || !answer) {
4460
+ if (!question || !lexicalPlainText(draftAnswer)) {
4407
4461
  setError("Question and answer are required.");
4408
4462
  return;
4409
4463
  }
@@ -4411,7 +4465,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4411
4465
  setError(null);
4412
4466
  const body = {
4413
4467
  question,
4414
- answer,
4468
+ answer: draftAnswer,
4415
4469
  _status: published ? "published" : "draft",
4416
4470
  ...Object.fromEntries(organizeBy.map((entry) => [entry.name, draftFacets[entry.name] ?? []]))
4417
4471
  };
@@ -4582,7 +4636,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4582
4636
  children: doc.question
4583
4637
  }), /* @__PURE__ */ jsx("p", {
4584
4638
  className: "bl-faq-library__answer",
4585
- children: doc.answer
4639
+ children: lexicalPlainText(doc.answer)
4586
4640
  })] }),
4587
4641
  organizeBy.map((entry) => {
4588
4642
  const chips = chipsFrom$1(doc[entry.name]);
@@ -4709,139 +4763,101 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
4709
4763
  })
4710
4764
  ]
4711
4765
  }),
4712
- faqOpen ? /* @__PURE__ */ jsx("div", {
4713
- className: "bl-nav-kit__modal bl-faq-library__modal",
4714
- role: "dialog",
4715
- "aria-modal": "true",
4716
- "aria-labelledby": "bl-faq-library-title",
4717
- onClick: () => setFaqOpen(false),
4718
- children: /* @__PURE__ */ jsxs("div", {
4719
- className: "bl-faq-library__modal-card",
4720
- onClick: (event) => event.stopPropagation(),
4721
- children: [
4722
- /* @__PURE__ */ jsxs("div", {
4723
- className: "bl-faq-library__modal-head",
4724
- children: [/* @__PURE__ */ jsx("h2", {
4725
- id: "bl-faq-library-title",
4726
- children: editing ? "Edit FAQ" : "New FAQ"
4766
+ /* @__PURE__ */ jsxs(Dialog, {
4767
+ open: faqOpen,
4768
+ className: "bl-faq-library__modal",
4769
+ title: editing ? "Edit FAQ" : "New FAQ",
4770
+ description: "Pages should select FAQs from this library. Editing an FAQ here updates every page that references it.",
4771
+ cancelLabel: "Cancel",
4772
+ confirmLabel: "Save FAQ",
4773
+ confirmDisabled: busy,
4774
+ onCancel: () => setFaqOpen(false),
4775
+ onConfirm: () => void saveFaq(),
4776
+ footerStart: /* @__PURE__ */ jsxs("label", {
4777
+ className: "bl-faq-library__published",
4778
+ children: [/* @__PURE__ */ jsx(Switch, {
4779
+ checked: published,
4780
+ onCheckedChange: setPublished
4781
+ }), "Published"]
4782
+ }),
4783
+ children: [
4784
+ /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(Label, { children: "Question" }), /* @__PURE__ */ jsx(Input, {
4785
+ value: draftQuestion,
4786
+ onChange: (event) => setDraftQuestion(event.target.value),
4787
+ placeholder: "e.g. How long does recovery usually take?"
4788
+ })] }),
4789
+ /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(Label, { children: "Answer" }), /* @__PURE__ */ jsx("div", {
4790
+ className: "bl-faq-library__answer-editor",
4791
+ children: /* @__PURE__ */ jsx(RenderLexical, {
4792
+ field: {
4793
+ name: "answer",
4794
+ type: "richText"
4795
+ },
4796
+ path: "answer",
4797
+ schemaPath: `collection.${collectionSlug}.answer`,
4798
+ value: draftAnswer && typeof draftAnswer === "object" ? draftAnswer : void 0,
4799
+ setValue: (next) => setDraftAnswer(next)
4800
+ }, editing ? String(editing.id) : "new")
4801
+ })] }),
4802
+ organizeBy.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
4803
+ className: "bl-faq-library__section",
4804
+ children: "Organization"
4805
+ }), /* @__PURE__ */ jsx(Stack, { children: organizeBy.map((entry) => /* @__PURE__ */ jsxs(Fold, {
4806
+ title: entry.label,
4807
+ defaultOpen: true,
4808
+ children: [/* @__PURE__ */ jsx("div", {
4809
+ className: "bl-faq-library__choicebox",
4810
+ children: (terms[entry.name] ?? []).map((term) => {
4811
+ return /* @__PURE__ */ jsxs("label", {
4812
+ className: "bl-faq-library__choice",
4813
+ children: [/* @__PURE__ */ jsx(Checkbox, {
4814
+ checked: (draftFacets[entry.name] ?? []).some((id) => String(id) === String(term.id)),
4815
+ onCheckedChange: (value) => toggleFacet(entry.name, term.id, value === true)
4816
+ }), /* @__PURE__ */ jsx("span", { children: term.name })]
4817
+ }, String(term.id));
4818
+ })
4819
+ }), entry.manage ? inlineTopic?.field === entry.name ? /* @__PURE__ */ jsxs("form", {
4820
+ className: "bl-faq-library__inline-add",
4821
+ onSubmit: (event) => {
4822
+ event.preventDefault();
4823
+ addTerm(entry, inlineTopic.name);
4824
+ },
4825
+ children: [/* @__PURE__ */ jsx(Input, {
4826
+ autoFocus: true,
4827
+ value: inlineTopic.name,
4828
+ onChange: (event) => setInlineTopic({
4829
+ field: entry.name,
4830
+ name: event.target.value
4831
+ }),
4832
+ placeholder: `New ${termSingular(entry.label)} name`
4727
4833
  }), /* @__PURE__ */ jsx(Button$1, {
4728
- size: "icon",
4729
- variant: "ghost",
4730
- "aria-label": "Close",
4731
- onClick: () => setFaqOpen(false),
4732
- children: "×"
4733
- })]
4734
- }),
4735
- /* @__PURE__ */ jsxs("div", {
4736
- className: "bl-faq-library__modal-body",
4737
- children: [
4738
- /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(Label, { children: "Question" }), /* @__PURE__ */ jsx(Input, {
4739
- value: draftQuestion,
4740
- onChange: (event) => setDraftQuestion(event.target.value),
4741
- placeholder: "e.g. How long does recovery usually take?"
4742
- })] }),
4743
- /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(Label, { children: "Answer" }), /* @__PURE__ */ jsx(Textarea, {
4744
- value: draftAnswer,
4745
- onChange: (event) => setDraftAnswer(event.target.value),
4746
- placeholder: "Write the reusable answer…"
4747
- })] }),
4748
- organizeBy.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
4749
- className: "bl-faq-library__section",
4750
- children: "Organization"
4751
- }), /* @__PURE__ */ jsx("div", {
4752
- className: "bl-faq-library__grid",
4753
- children: organizeBy.map((entry) => /* @__PURE__ */ jsxs(Field, {
4754
- as: "div",
4755
- children: [
4756
- /* @__PURE__ */ jsx(Label, { children: entry.label }),
4757
- /* @__PURE__ */ jsx("div", {
4758
- className: "bl-faq-library__choicebox",
4759
- children: (terms[entry.name] ?? []).map((term) => {
4760
- return /* @__PURE__ */ jsxs("label", {
4761
- className: "bl-faq-library__choice",
4762
- children: [/* @__PURE__ */ jsx(Checkbox, {
4763
- checked: (draftFacets[entry.name] ?? []).some((id) => String(id) === String(term.id)),
4764
- onCheckedChange: (value) => toggleFacet(entry.name, term.id, value === true)
4765
- }), /* @__PURE__ */ jsx("span", { children: term.name })]
4766
- }, String(term.id));
4767
- })
4768
- }),
4769
- entry.manage ? inlineTopic?.field === entry.name ? /* @__PURE__ */ jsxs("form", {
4770
- className: "bl-faq-library__inline-add",
4771
- onSubmit: (event) => {
4772
- event.preventDefault();
4773
- addTerm(entry, inlineTopic.name);
4774
- },
4775
- children: [/* @__PURE__ */ jsx(Input, {
4776
- autoFocus: true,
4777
- value: inlineTopic.name,
4778
- onChange: (event) => setInlineTopic({
4779
- field: entry.name,
4780
- name: event.target.value
4781
- }),
4782
- placeholder: `New ${termSingular(entry.label)} name`
4783
- }), /* @__PURE__ */ jsx(Button$1, {
4784
- type: "submit",
4785
- variant: "outline",
4786
- disabled: busy,
4787
- children: "Add"
4788
- })]
4789
- }) : /* @__PURE__ */ jsx("button", {
4790
- type: "button",
4791
- className: "bl-faq-library__addtag",
4792
- onClick: () => setInlineTopic({
4793
- field: entry.name,
4794
- name: ""
4795
- }),
4796
- children: `+ Create new ${termSingular(entry.label)}`
4797
- }) : null,
4798
- /* @__PURE__ */ jsx("small", {
4799
- className: "bl-faq-library__hint",
4800
- children: facetHint(entry)
4801
- })
4802
- ]
4803
- }, entry.name))
4804
- })] }) : null,
4805
- /* @__PURE__ */ jsx("div", {
4806
- className: "bl-faq-library__notice",
4807
- children: "Pages should select FAQs from this library. Editing an FAQ here updates every page that references it."
4808
- })
4809
- ]
4810
- }),
4811
- /* @__PURE__ */ jsxs("div", {
4812
- className: "bl-faq-library__modal-foot",
4813
- children: [/* @__PURE__ */ jsxs("label", {
4814
- className: "bl-faq-library__published",
4815
- children: [/* @__PURE__ */ jsx(Switch, {
4816
- checked: published,
4817
- onCheckedChange: setPublished
4818
- }), "Published"]
4819
- }), /* @__PURE__ */ jsxs("div", {
4820
- className: "bl-faq-library__foot-actions",
4821
- children: [/* @__PURE__ */ jsx(Button$1, {
4822
- variant: "outline",
4823
- onClick: () => setFaqOpen(false),
4824
- children: "Cancel"
4825
- }), /* @__PURE__ */ jsx(Button$1, {
4826
- disabled: busy,
4827
- onClick: () => void saveFaq(),
4828
- children: "Save FAQ"
4829
- })]
4834
+ type: "submit",
4835
+ variant: "outline",
4836
+ disabled: busy,
4837
+ children: "Add"
4830
4838
  })]
4831
- })
4832
- ]
4833
- })
4834
- }) : null,
4839
+ }) : /* @__PURE__ */ jsx("button", {
4840
+ type: "button",
4841
+ className: "bl-faq-library__addtag",
4842
+ onClick: () => setInlineTopic({
4843
+ field: entry.name,
4844
+ name: ""
4845
+ }),
4846
+ children: `+ Create new ${termSingular(entry.label)}`
4847
+ }) : null]
4848
+ }, entry.name)) })] }) : null
4849
+ ]
4850
+ }),
4835
4851
  /* @__PURE__ */ jsx(Dialog, {
4836
4852
  open: Boolean(deleteFaq),
4837
4853
  title: "Delete this FAQ?",
4854
+ description: "Pages using it would need another FAQ selected.",
4838
4855
  cancelLabel: "Cancel",
4839
4856
  confirmLabel: "Delete FAQ",
4840
4857
  confirmVariant: "danger",
4841
4858
  confirmDisabled: busy,
4842
4859
  onCancel: () => setDeleteFaq(null),
4843
- onConfirm: () => void confirmDeleteFaq(),
4844
- children: "Pages using it would need another FAQ selected."
4860
+ onConfirm: () => void confirmDeleteFaq()
4845
4861
  }),
4846
4862
  deleteTerm ? /* @__PURE__ */ jsx("div", {
4847
4863
  className: "bl-nav-kit__modal",