@byline/ui 1.8.2 → 1.9.1

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.
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Copyright (c) Infonomic Company Limited
7
7
  */
8
- import type { Field, FieldComponentSlots } from '@byline/core';
8
+ import type { Field, FieldComponentSlots, RichTextEditorComponent } from '@byline/core';
9
9
  interface FieldRendererProps {
10
10
  field: Field;
11
11
  defaultValue?: any;
@@ -25,6 +25,13 @@ interface FieldRendererProps {
25
25
  * Forwarded to value-field widgets that support custom slots.
26
26
  */
27
27
  components?: FieldComponentSlots;
28
+ /**
29
+ * Per-field rich-text editor component override from the admin config.
30
+ * Takes precedence over the globally registered
31
+ * `ClientConfig.fields.richText.editor` for this single field.
32
+ * Ignored when `field.type !== 'richText'`.
33
+ */
34
+ editor?: RichTextEditorComponent;
28
35
  }
29
- export declare const FieldRenderer: ({ field, defaultValue, basePath, disableSorting, hideLabel, collectionPath, contentLocale, components, }: FieldRendererProps) => import("react").JSX.Element | null;
36
+ export declare const FieldRenderer: ({ field, defaultValue, basePath, disableSorting, hideLabel, collectionPath, contentLocale, components, editor, }: FieldRendererProps) => import("react").JSX.Element | null;
30
37
  export {};
@@ -16,7 +16,7 @@ import { SelectField } from "./select/select-field.js";
16
16
  import { TextField } from "./text/text-field.js";
17
17
  import { TextAreaField } from "./text-area/text-area-field.js";
18
18
  import { useFieldChangeHandler } from "./use-field-change-handler.js";
19
- const FieldRenderer = ({ field, defaultValue, basePath, disableSorting, hideLabel, collectionPath, contentLocale, components })=>{
19
+ const FieldRenderer = ({ field, defaultValue, basePath, disableSorting, hideLabel, collectionPath, contentLocale, components, editor })=>{
20
20
  const path = basePath ? `${basePath}.${field.name}` : field.name;
21
21
  const htmlId = path.replace(/[[\].]/g, '-');
22
22
  const handleChange = useFieldChangeHandler(field, path);
@@ -76,7 +76,7 @@ const FieldRenderer = ({ field, defaultValue, basePath, disableSorting, hideLabe
76
76
  });
77
77
  case 'richText':
78
78
  {
79
- const RichTextEditor = getClientConfig().fields?.richText?.editor;
79
+ const RichTextEditor = editor ?? getClientConfig().fields?.richText?.editor;
80
80
  if (!RichTextEditor) throw new Error("No richText editor registered. Install @byline/richtext-lexical and set `fields.richText.editor` in your admin config.");
81
81
  return /*#__PURE__*/ jsx(RichTextEditor, {
82
82
  field: hideLabel ? {
@@ -325,7 +325,8 @@ const FormContent = ({ mode, fields, onSubmit, onCancel, onStatusChange, onUnpub
325
325
  defaultValue: initialData?.fields?.[field.name],
326
326
  collectionPath: collectionPath,
327
327
  contentLocale: contentLocale,
328
- components: adminConfig?.fields?.[field.name]?.components
328
+ components: adminConfig?.fields?.[field.name]?.components,
329
+ editor: adminConfig?.fields?.[field.name]?.editor
329
330
  }, field.name);
330
331
  };
331
332
  const renderItem = (name)=>{
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "license": "MPL-2.0",
6
- "version": "1.8.2",
6
+ "version": "1.9.1",
7
7
  "engines": {
8
8
  "node": ">=20.9.0"
9
9
  },
@@ -65,9 +65,9 @@
65
65
  "react-diff-viewer-continued": "^4.2.2",
66
66
  "zod": "^4.4.2",
67
67
  "zod-form-data": "^3.0.1",
68
- "@byline/core": "1.8.2",
69
- "@byline/client": "1.8.2",
70
- "@byline/admin": "1.8.2"
68
+ "@byline/client": "1.9.1",
69
+ "@byline/core": "1.9.1",
70
+ "@byline/admin": "1.9.1"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "react": "^19.0.0",
@@ -12,6 +12,7 @@ import type {
12
12
  Field,
13
13
  FieldComponentSlots,
14
14
  GroupField as GroupFieldType,
15
+ RichTextEditorComponent,
15
16
  } from '@byline/core'
16
17
  import { getClientConfig } from '@byline/core'
17
18
  import cx from 'classnames'
@@ -56,6 +57,13 @@ interface FieldRendererProps {
56
57
  * Forwarded to value-field widgets that support custom slots.
57
58
  */
58
59
  components?: FieldComponentSlots
60
+ /**
61
+ * Per-field rich-text editor component override from the admin config.
62
+ * Takes precedence over the globally registered
63
+ * `ClientConfig.fields.richText.editor` for this single field.
64
+ * Ignored when `field.type !== 'richText'`.
65
+ */
66
+ editor?: RichTextEditorComponent
59
67
  }
60
68
 
61
69
  export const FieldRenderer = ({
@@ -67,6 +75,7 @@ export const FieldRenderer = ({
67
75
  collectionPath,
68
76
  contentLocale,
69
77
  components,
78
+ editor,
70
79
  }: FieldRendererProps) => {
71
80
  const path = basePath ? `${basePath}.${field.name}` : field.name
72
81
  const htmlId = path.replace(/[[\].]/g, '-')
@@ -131,7 +140,12 @@ export const FieldRenderer = ({
131
140
  />
132
141
  )
133
142
  case 'richText': {
134
- const RichTextEditor = getClientConfig().fields?.richText?.editor
143
+ // Admin-side per-field override takes precedence over the globally
144
+ // registered editor (`ClientConfig.fields.richText.editor`). The
145
+ // override travels via `FieldAdminConfig.fields.<name>.editor` —
146
+ // see admin-types — so React component references stay out of the
147
+ // schema graph that's loaded by the server bootstrap.
148
+ const RichTextEditor = editor ?? getClientConfig().fields?.richText?.editor
135
149
  if (!RichTextEditor) {
136
150
  throw new Error(
137
151
  'No richText editor registered. Install @byline/richtext-lexical and set ' +
@@ -549,6 +549,7 @@ const FormContent = ({
549
549
  collectionPath={collectionPath}
550
550
  contentLocale={contentLocale}
551
551
  components={adminConfig?.fields?.[field.name]?.components}
552
+ editor={adminConfig?.fields?.[field.name]?.editor}
552
553
  />
553
554
  )
554
555
  }