Skip to content

Commit c297dff

Browse files
feat(grid): rich-content cells edit in a panel under the cell; related tab pinned (#36278)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XURgXCZHcjPoyo5g9cMEATi)_ Fixes #36023 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 列表里的富文本、Markdown、HTML 格子,选中后回车会在格子下面弹出编辑框,记录页子表页签里也一样;以前这些格子不能改,只提示去记录页改。 - 属于「列表页重做」专题,补上格内编辑重做卡里富文本那一项和子表页签那一项,做完这张卡就齐了。 - 出错的话最多是这三种格子的编辑框不好用,记录页和表单的编辑不受影响;整个改动可以直接撤回。 - 无。 ## What changes The last slice of #36023 (S3, S4 and S5 landed as `Part of`): rich text opens an edit panel under the list cell, and the related tab is pinned to behave like the list. - **Rich-content cells edit in a panel under the cell.** A `markdown`, `html` or `richtext` cell, on Enter / F2 / typing / double-click, opens the record form's own text box (`RichTextField`) over the stored source in the below-cell panel S4 built (`GridCellFacts.editor: 'below'`, `CellOverlay placement="below"`). The cell keeps drawing its value, the row keeps its height (the panel is a fixed-position popper), and the panel is at least the column's width (the overlay's anchor-width floor; the inner box asks for `min-w-80`, as `markdown` already did in `cellEditorWidthClass`). - **Keys, per card item 4 and rulings D2 / D4:** Enter is a new line; Ctrl/Cmd+Enter saves and keeps the cell selected; Esc discards; a click outside saves. No `data-table.tsx` change was needed: its injected-editor wrapper already commits a TEXTAREA only on Ctrl/Cmd+Enter on the select-first grid, discards on Escape and commits on an outside pointer press. Measured by the tests below, not assumed. - **The split (cell vs detail), not a widening of the shared set.** `markdown`, `html` and `richtext` stay in `INLINE_EXCLUDED_FIELD_TYPES`; `hasFieldEditWidget` and `isInlineExcludedFieldType` answer exactly as before, so the record page's field editor (`InlineFieldInput`, `fieldEnrichment`), the required-fields dialogs (grid, kanban, record path, save bar), `RequiredFieldsDialog` and the timesheet keep them out. `@object-ui/fields` adds `hasInCellPanelEditWidget(type)` (true for the three types, false for a retired spelling), and `FieldEditWidget` draws their editor only when the host passes `inCell`. In `plugin-grid`, `fieldInlineReadOnlyKind` exempts exactly what `hasInCellPanelEditWidget` names (the same carve-out shape as `plugin-detail`'s `DETAIL_ROUTED_INLINE_TYPES`), `PANEL_EDITOR_FIELD_TYPES` gains the three types, and `renderCellEditor` accepts either predicate. - **One list, no second spelling (rework round 1).** The three types are now read from `RICH_TEXT_FIELD_TYPES` (`fields/src/widgets/richTextDisplay.tsx`, the keys of `RICH_TEXT_CELL_RENDERERS`) in all three places that named them by hand: `IN_CELL_PANEL_EDIT_WIDGETS` in `FieldEditWidget.tsx` is built from it, `PANEL_EDITOR_FIELD_TYPES` spreads it, and `cellEditorWidthClass` in `ObjectGrid.tsx` checks it before its switch. A type added to the display table gets its cell panel, its below placement and its width in the same commit. Derived rather than pinned only, because the cost is nil: `richTextDisplay.tsx` is already in the eager `ui-components` chunk through `getCellRenderer` (and `ObjectGrid.tsx` already imported the list), so the derivation adds one import of a module that is already loaded. A pin was added as well (see Tests). - **Lazy.** The editor is `React.lazy(() => import('./widgets/RichTextField.js'))` inside `FieldEditWidget`, rendered in the same `Suspense` boundary the date pickers use (`LAZY_EDIT_WIDGETS`). Note: `RichTextField` is already in the eager `ui-components` chunk (it is statically re-exported by the barrel and already listed in `scripts/vite-ineffective-dynamic-imports.ts`), so the `import()` moves no module; the eager-closure reading is in Verification. - **`html` is safe to edit as text.** What the cell then draws goes through `renderSanitizedHtml` (`rehype-sanitize` with `RICH_TEXT_SANITIZE_SCHEMA`, no `dangerouslySetInnerHTML`), the same pipeline every other read surface uses. So `html` is enabled with the other two. - Multi-line text and address are untouched (ruling D3 A). No form or record-page editor face changes, and the save model and undo are unchanged. ## Tests New pins: - `fields` `inCellFaces-35688.test.tsx`, describe "in-cell rich-content panel": the three types answer `hasInCellPanelEditWidget` true while `hasFieldEditWidget` stays false and `isInlineExcludedFieldType` stays true; no other type (text, textarea, address, password, secret, object, file) is a panel; with `inCell` the widget is a TEXTAREA holding the stored source, typing stages, and Enter reaches the grid's wrapper with its default intact; without `inCell` the same field gets no editor. - `plugin-grid` `ObjectGrid.cellSelection-35684.test.tsx`, describe "a rich-content cell edits in a panel under it": markdown, HTML and rich text each open `data-placement="below"` with the cell display still drawn and no read-only reason; Enter writes nothing and keeps the panel; Ctrl+Enter and Cmd+Enter each save one update and the cell stays selected; Esc writes nothing; an outside pointer press saves. - `plugin-grid` `relatedTab.cellEditing-36023.test.tsx` (new file, the real chain `RelatedList` enlarged → `object-grid` → `data-table`): on the related tab a select opens its list under the cell with its value still drawn, Enter saves a text cell and the selection stays, and rich text opens its panel where Enter is a new line and Ctrl+Enter saves. Rewritten tests (the card asks for the list): - `plugin-grid/src/inline-edit-options.test.ts`: "keeps a markdown cell read-only — the detail row editor (objectui#11541) is not a grid one" is replaced by "edits the rich-content types in a cell, in a panel under it (objectstack#36023)", with a control that a `readonly` rich-text field stays `readonly` and that `password`, `secret`, `object`, `file` stay `notInline`. - `plugin-grid/src/objectGridCellFacts-35684.test.ts`: the placement test now lists `markdown`, `html`, `richtext` among the types that open below, and a new pin "every rich-content type the display table serves edits in a panel under the cell" walks `RICH_TEXT_FIELD_TYPES` and asserts, for every entry, `hasInCellPanelEditWidget(t)` is true, `inlineEditorPlacement(t)` is `'below'` and `fieldInlineReadOnlyKind({ type: t })` is null (plus a non-empty guard on the list). - No screenshot baseline is invalidated. `ObjectGrid.requiredPrompt-35956.test.tsx`'s "a field with no in-place editor (rich text) asks nothing" still holds unchanged: the required-fields prompt asks `hasFieldEditWidget`, which this PR does not move. ## Acceptance notes **Browser readings (rework round 1), Chromium at 1280 x 900, showcase field zoo.** Stack: `objectstack dev --seed-admin --fresh` for `examples/app-showcase` plus the console dev server, both from this branch's head `bc9b5c23`. The zoo's default list does not show the rich columns, so `f_markdown`, `f_html` and `f_richtext` were added to its `columns` for the run only (uncommitted, reverted with `git checkout HEAD --` afterwards; `git diff HEAD` empty). Row: "Specimen — Full". The panel was opened by selecting the cell and pressing Enter, and closed with Esc. Theme set through the console's own theme key; the root element's class read `light` / `dark` on each pass. | Type | Theme | Row height before | Row height, panel open | Row after Esc | Cell (w x h) | Panel (w x h, at x,y) | Panel background | |---|---|---|---|---|---|---|---| | markdown | light | 45 | 45 | 45 | 167 x 45 | 330 x 188 at 828,207 | rgb(255, 255, 255) | | html | light | 45 | 45 | 45 | 143 x 45 | 330 x 188 at 942,207 | rgb(255, 255, 255) | | richtext | light | 45 | 45 | 45 | 143 x 45 | 330 x 188 at 942,207 | rgb(255, 255, 255) | | markdown | dark | 45 | 45 | 45 | 167 x 45 | 330 x 188 at 828,207 | rgb(26, 26, 30) | | html | dark | 45 | 45 | 45 | 143 x 45 | 330 x 188 at 942,207 | rgb(26, 26, 30) | | richtext | dark | 45 | 45 | 45 | 143 x 45 | 330 x 188 at 942,207 | rgb(26, 26, 30) | - The row height does not move when the panel opens, in either theme, for any of the three types; the panel starts 2 px under the cell's bottom edge (cell bottom 205, panel top 207) and is gone after Esc. - The panel is wider than the column (330 against 167 / 143). For html and richtext, the two rightmost columns, it is shifted left to x 942 so its right edge (1272) stays inside the 1280 viewport. - The textarea holds the stored source, read from its value: the seed's heading line and two list lines for markdown, and the raw markup (tags included, not rendered) for html and richtext. - Dark-theme look at the open panel (markdown and richtext screenshots read): a dark panel with a violet focus ring, light monospace source text, the selected cell outlined in violet above it, and the row and the cell's drawn value unchanged behind it. No light-on-light or clipped edge. Screenshots were kept local and not committed. - Out of scope, seen during the reading and NOT fixed here: the markdown cell draws the seed's `# Heading` at heading size, truncated to "Headin…", and that row is 45 px against 36 px for the row without rich values. That is the read-only display pipeline (`MarkdownCellRenderer`), which this PR does not touch, and it is the same with the panel closed. Reported to the seat in the os-dev report. - The required-fields dialogs still do not offer a rich-text editor for a rich-text field (they ask `hasFieldEditWidget`); unchanged on purpose, out of this card's scope. **Adjacent fix.** `ui/packages/plugin-grid/README.md` cited `isFieldInlineEditable` as `src/inline-edit-options.ts:82`. This PR edits that file, so the line number would point at other code; the citation now reads `isFieldInlineEditable` in `src/inline-edit-options.ts`, with no line number, so it cannot drift again. - Carried by #36360: seat 7's contract delta 7076344850 S2 (should-fix, non-blocking: the plugin-grid and fields READMEs and the plugin-grid docs page describe the panel and its keys without the select-first scope the changeset now has) and N1 (nit: the changeset's "Before" sentence and the `IN_CELL_PANEL_EDIT_WIDGETS` jsdoc). Text only; per the maintainer's 2026-11-22T07:49Z direction, small later changes go on their own card rather than another rework round. ## Verification Two-minute check: open a list with a rich text column, click a rich text cell, press Enter. Expected: a text box opens under the cell with the stored source, the row does not grow, Enter adds a line, Ctrl+Enter (Cmd+Enter) saves and the cell stays selected, Esc closes without saving. Read first (by risk): 1. `ui/packages/fields/src/FieldEditWidget.tsx`: `IN_CELL_PANEL_EDIT_WIDGETS`, `hasInCellPanelEditWidget` and the one-line `Widget` resolution in `FieldEditWidget` (the only path by which the three types can reach any host, gated on `inCell`). 2. `ui/packages/plugin-grid/src/inline-edit-options.ts`: the carve-out in `fieldInlineReadOnlyKind`, ordered after the binary/computed checks and before the shared exclusion. 3. `ui/packages/plugin-grid/src/objectGridCellFacts.ts`: `PANEL_EDITOR_FIELD_TYPES`. The local test, ablation, gate and eager-closure readings are posted with the os-dev report comments on #36023 (round 0 on `03473f46`; the rework delta on `bc9b5c23`, with the narrowed test run 5 files / 85 tests passed). --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5oY5WCqqqBMtn9qt7m)_ <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5oY5WCqqqBMtn9qt7m --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4101f1f commit c297dff

13 files changed

Lines changed: 466 additions & 19 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/fields': patch
3+
'@object-ui/plugin-grid': patch
4+
---
5+
6+
feat(grid): a markdown, HTML or rich text cell opens a text box in a panel under the cell
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
**The list grid edits the rich-content field types in place** (objectstack#36023). On a select-first grid, selecting a `markdown`, `html` or `richtext` cell and pressing Enter, F2, typing or double-clicking opens the record form's own text box over the stored source in a panel under the cell, at least as wide as the column; the cell keeps showing its value and the row keeps its height. Enter in the panel is a new line; on a select-first grid Ctrl/Cmd+Enter saves and keeps the cell selected, Esc discards, and a click outside saves. Backspace or Delete on the selected cell of a select-first grid clears it as for any other editable cell. On a grid without the select-first cell model (an `ObjectGrid` or `object-grid` mounted without `cellSelection`), one click opens the text box over the cell, not in a panel under it: Enter is a new line, Ctrl/Cmd+Enter does nothing, Esc discards, and a click outside keeps the text as a pending change for the grid's save buttons. Before, these cells opened no editor and said "This field can't be edited in a list". The related tab on the record page draws the same grid and behaves the same way.
12+
13+
**Only the grid's cell changes.** The three types stay in `INLINE_EXCLUDED_FIELD_TYPES`, and `hasFieldEditWidget` and `isInlineExcludedFieldType` answer as before, so the record page's field editor, the required-fields dialogs, the kanban and timesheet editors keep them out. `@object-ui/fields` exports `hasInCellPanelEditWidget(type)`, true for the three types, and `FieldEditWidget` draws their editor only when the host asks for the cell face (`inCell`); the editor loads lazily. `html` is edited as text; what the cell then draws goes through the sanitizing HTML renderer, as on every other read surface.

‎content/docs/frontend/plugins/plugin-grid.mdx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ through the host's data source (`dataSource.update`) with no callback to wire.
365365
definition**, not by a column key — a field marked `readonly`, and
366366
computed/binary field types (formula, autonumber, file, …), never open an
367367
editor. There is no `editable` key on `ListColumn`.
368+
- **Rich text edits in a panel** (objectstack#36023): a `markdown`, `html` or
369+
`richtext` cell opens the record form's text box over the stored source in a
370+
panel under the cell, at least as wide as the column, while the cell keeps
371+
showing its value. Enter there is a new line; on a select-first grid
372+
Ctrl/Cmd+Enter saves, Esc discards and a click outside saves.
368373
- **Visual feedback**: editable cells show a hover state, and the input is
369374
focused and selected when editing begins
370375
- **The editor floats over its cell** (objectstack#35688): it opens on a layer

‎ui/packages/fields/README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ pick and the in-cell colour face after a swatch.
137137
A host that passes neither gets the form faces unchanged; `ObjectGrid` passes
138138
both.
139139

140+
`inCell` also unlocks the rich-content types (`markdown`, `html`, `richtext`):
141+
they stay in `INLINE_EXCLUDED_FIELD_TYPES` and `hasFieldEditWidget` answers
142+
`false` for them, so every other host keeps them out, while
143+
`hasInCellPanelEditWidget(type)` answers `true` and `FieldEditWidget` draws the
144+
form's rich-text box for them (loaded lazily) when the host asks for the cell
145+
face. The list grid opens it in a panel under the cell, where Enter is a new
146+
line.
147+
140148
### Resolving declared action params
141149

142150
An action param is declared either inline (`name` + `type`) or field-backed

‎ui/packages/fields/src/FieldEditWidget.tsx‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ import {
6969
isRetiredFieldType,
7070
reportRetiredFieldType,
7171
} from './field-type-alias.js';
72+
// The rich-content types' one list (the keys `RichTextField` serves); its
73+
// module is already in the eager closure through `getCellRenderer`.
74+
import { RICH_TEXT_FIELD_TYPES } from './widgets/richTextDisplay.js';
7275

7376
/**
7477
* The platform date picker (objectui#12622, objectui#12642), the face the
@@ -96,10 +99,21 @@ const DateTimePickerEditWidget = React.lazy(() =>
9699
import('./widgets/date-picker/DatePickerField.js').then((m) => ({ default: m.DateTimePickerField })),
97100
);
98101

99-
/** The {@link EDIT_WIDGETS} entries that load lazily and need a `Suspense` boundary. */
102+
/**
103+
* The rich-content editor (`RichTextField`, a text box over the stored
104+
* markdown or HTML source), LAZY through the same `import()` `fieldWidgetMap`
105+
* uses for these three types, for the list grid's cell panel
106+
* ({@link IN_CELL_PANEL_EDIT_WIDGETS}).
107+
*/
108+
const RichTextPanelEditWidget = React.lazy(() =>
109+
import('./widgets/RichTextField.js').then((m) => ({ default: m.RichTextField })),
110+
);
111+
112+
/** The edit widgets that load lazily and need a `Suspense` boundary. */
100113
const LAZY_EDIT_WIDGETS: ReadonlySet<unknown> = new Set([
101114
DatePickerEditWidget,
102115
DateTimePickerEditWidget,
116+
RichTextPanelEditWidget,
103117
]);
104118

105119
/**
@@ -193,6 +207,29 @@ export const INLINE_EXCLUDED_FIELD_TYPES = new Set<string>([
193207
'notification-topic', 'notification-channel', 'quiet-hours',
194208
]);
195209

210+
/**
211+
* Members of {@link INLINE_EXCLUDED_FIELD_TYPES} that the LIST GRID's cell
212+
* nevertheless edits, in a panel opened under the cell (objectstack#36023):
213+
* the rich-content types, whose panel is the form's own text box over the
214+
* stored source. Enter in it is a new line; the grid saves on Ctrl/Cmd+Enter
215+
* or a click outside and discards on Esc.
216+
*
217+
* Only a host that asks for the cell face (`inCell`) gets them, so the record
218+
* page's field editor, the required-fields dialogs and every other host of
219+
* {@link FieldEditWidget} keep these types out, exactly as before: they ask
220+
* {@link hasFieldEditWidget}, which still answers `false` for them. The
221+
* exclusion set keeps them too, so `isInlineExcludedFieldType` answers as
222+
* before for every host; the grid asks {@link hasInCellPanelEditWidget}.
223+
*
224+
* `html` is safe to edit as text here because what the cell then draws is
225+
* the sanitizing renderer's output (`./widgets/sanitizedHtml.tsx`), as on
226+
* every other read surface.
227+
*/
228+
const IN_CELL_PANEL_EDIT_WIDGETS: Readonly<Record<string, React.ComponentType<FieldWidgetComponentProps<any>>>> =
229+
// Derived from the one list of the keys `RichTextField` serves, so a type
230+
// added to the display table gets its cell panel with no second spelling.
231+
Object.fromEntries(RICH_TEXT_FIELD_TYPES.map((type) => [type, RichTextPanelEditWidget]));
232+
196233
/** Field types whose value is chosen in one discrete gesture (no free typing). */
197234
export const DISCRETE_EDIT_TYPES = new Set<string>([
198235
'boolean', 'toggle', 'select', 'status', 'radio', 'rating',
@@ -239,6 +276,17 @@ export function hasFieldEditWidget(type: string | undefined): boolean {
239276
return resolveInlineEditType(type) in EDIT_WIDGETS;
240277
}
241278

279+
/**
280+
* True when a field type has no in-place widget but the list grid's cell edits
281+
* it in a panel under the cell (`inCell`, {@link IN_CELL_PANEL_EDIT_WIDGETS}).
282+
* A retired spelling answers `false`, as {@link hasFieldEditWidget} does.
283+
*/
284+
export function hasInCellPanelEditWidget(type: string | undefined): boolean {
285+
if (!type) return false;
286+
if (isRetiredFieldType(type)) return false;
287+
return Object.prototype.hasOwnProperty.call(IN_CELL_PANEL_EDIT_WIDGETS, resolveInlineEditType(type));
288+
}
289+
242290
/**
243291
* True when a field type is deliberately NOT inline-editable (alias-aware:
244292
* `composite` resolves to the excluded `object`, `video` to `file`, …).
@@ -377,7 +425,10 @@ export function FieldEditWidget(
377425
return null;
378426
}
379427
const resolved = field?.type ? resolveInlineEditType(field.type) : undefined;
380-
const Widget = resolved ? EDIT_WIDGETS[resolved] : undefined;
428+
// The cell panel's widgets answer only the host that asks for the cell face.
429+
const Widget = resolved
430+
? EDIT_WIDGETS[resolved] ?? (props.inCell && hasInCellPanelEditWidget(resolved) ? IN_CELL_PANEL_EDIT_WIDGETS[resolved] : undefined)
431+
: undefined;
381432
if (!Widget) return null;
382433
// `compact` is a declared widget prop (objectui#3221 closed this type), so
383434
// the spread no longer needs an `any` escape hatch to get past it.

‎ui/packages/fields/src/__tests__/inCellFaces-35688.test.tsx‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import { TagsField } from '../widgets/TagsField';
2323
import { ColorField } from '../widgets/ColorField';
2424
import { TimeField } from '../widgets/TimeField';
2525
import { DatePickerField, DateTimePickerField } from '../widgets/date-picker/DatePickerField';
26-
import { FieldEditWidget } from '../FieldEditWidget';
26+
import { FieldEditWidget, hasFieldEditWidget, hasInCellPanelEditWidget, isInlineExcludedFieldType } from '../FieldEditWidget';
27+
// The rich-content panel's widget sits behind `React.lazy` in `FieldEditWidget`;
28+
// imported here so its factory resolves at once (ui/AGENTS.md, flaky tests).
29+
import '../widgets/RichTextField';
2730
import { TextField } from '../widgets/TextField';
2831
import { EmailField } from '../widgets/EmailField';
2932
import { PhoneField } from '../widgets/PhoneField';
@@ -458,3 +461,44 @@ describe('in-cell record picker (objectstack#35688)', () => {
458461
expect(screen.queryByRole('listbox')).toBeNull();
459462
});
460463
});
464+
465+
describe('in-cell rich-content panel (objectstack#36023)', () => {
466+
it('markdown, html and rich text get the text box only when the cell face is asked for', () => {
467+
for (const type of ['markdown', 'html', 'richtext']) {
468+
expect(hasInCellPanelEditWidget(type), type).toBe(true);
469+
// Every other host keeps them out, exactly as before.
470+
expect(hasFieldEditWidget(type), type).toBe(false);
471+
expect(isInlineExcludedFieldType(type), type).toBe(true);
472+
}
473+
// CONTROL: no other type, excluded or in-place, is a panel text box.
474+
for (const type of ['text', 'textarea', 'address', 'password', 'secret', 'object', 'file', undefined]) {
475+
expect(hasInCellPanelEditWidget(type), String(type)).toBe(false);
476+
}
477+
});
478+
479+
it('draws the stored source in a text box; typing stages it; Enter is left to the text box (a new line)', async () => {
480+
const onChange = vi.fn();
481+
const onGridKey = vi.fn();
482+
render(
483+
<GridEditor onGridKey={onGridKey}>
484+
<FieldEditWidget field={{ name: 'notes', type: 'richtext' } as unknown as Field} value="<p>Hello</p>" onChange={onChange} inCell />
485+
</GridEditor>,
486+
);
487+
const box = (await screen.findByRole('textbox')) as HTMLTextAreaElement;
488+
expect(box.tagName).toBe('TEXTAREA');
489+
expect(box.value).toBe('<p>Hello</p>');
490+
fireEvent.change(box, { target: { value: '<p>Hello</p>\n<p>World</p>' } });
491+
expect(onChange).toHaveBeenLastCalledWith('<p>Hello</p>\n<p>World</p>');
492+
// The widget does not take Enter: it reaches the grid's wrapper with its
493+
// default intact, and the wrapper commits a text box only on Ctrl/Cmd+Enter.
494+
expect(fireEvent.keyDown(box, { key: 'Enter' })).toBe(true);
495+
expect(onGridKey).toHaveBeenCalledWith('Enter');
496+
});
497+
498+
it('CONTROL: without the cell face the same field gets no editor', () => {
499+
const { container } = render(
500+
<FieldEditWidget field={{ name: 'notes', type: 'markdown' } as unknown as Field} value="# Hi" onChange={() => {}} />,
501+
);
502+
expect(container.innerHTML).toBe('');
503+
});
504+
});

‎ui/packages/plugin-grid/README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,12 @@ the host's data source (`dataSource.update`) with no callback to wire.
994994
- **Per-field read-only**: which cells open is decided by the **field definition**,
995995
not by a column key — a field marked `readonly`, and computed/binary field types
996996
(formula, autonumber, file, …), never open an editor
997-
(`isFieldInlineEditable`, `src/inline-edit-options.ts:82`). There is no
997+
(`isFieldInlineEditable` in `src/inline-edit-options.ts`). There is no
998998
`editable` key on `ListColumn`.
999+
- **Rich text edits in a panel**: a `markdown`, `html` or `richtext` cell opens
1000+
the record form's text box in a panel under the cell (Enter is a new line,
1001+
Ctrl/Cmd+Enter saves, Escape discards, a click outside saves); the cell keeps
1002+
showing its value and the row its height.
9991003
- **Visual feedback**: editable cells show a hover state
10001004
- **Automatic focus**: the input is focused and selected when editing begins
10011005

‎ui/packages/plugin-grid/src/ObjectGrid.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { SchemaRenderer, isPermissionError, useDataScope, useNavigationOverlay,
3232
// what stops a seventh site picking a convention of its own.
3333
import { resolveGridCellRendering } from './cellRendererResolution';
3434
import { isMaskedGridColumn } from './maskedColumn';
35-
import { formatCurrency, formatDate, getBadgeColorClasses, getBadgeHexAppearance, FieldEditWidget, hasFieldEditWidget, DISCRETE_EDIT_TYPES, coerceToSafeValue, MaskedCellRenderer, withKnownObjects, RICH_TEXT_FIELD_TYPES } from '@object-ui/fields';
35+
import { formatCurrency, formatDate, getBadgeColorClasses, getBadgeHexAppearance, FieldEditWidget, hasFieldEditWidget, hasInCellPanelEditWidget, DISCRETE_EDIT_TYPES, coerceToSafeValue, MaskedCellRenderer, withKnownObjects, RICH_TEXT_FIELD_TYPES } from '@object-ui/fields';
3636
import { useLocalization, useDisplayLocale } from '@object-ui/i18n';
3737
// Two resolvers, two vocabularies — the repo spells the distinction into the
3838
// NAMES (objectui#4167). `resolveInlineI18nLabel` is the spec's own
@@ -803,12 +803,13 @@ function opensReferenceInPlace(fieldDef: { type?: unknown; reference?: unknown }
803803
* is never narrower than its cell and grows to fit this; the editor fills it.
804804
*/
805805
function cellEditorWidthClass(type: string): string {
806+
// objectstack#36023 — a rich-content field's text box, as wide as a textarea's.
807+
if ((RICH_TEXT_FIELD_TYPES as readonly string[]).includes(type)) return 'w-full min-w-80';
806808
switch (type) {
807809
case 'address':
808810
case 'location':
809811
return 'w-full min-w-[22rem]';
810812
case 'textarea':
811-
case 'markdown':
812813
case 'code':
813814
case 'json':
814815
return 'w-full min-w-80';
@@ -3627,7 +3628,8 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
36273628
renderCellEditor: inlineEditable
36283629
? (ctx: { column: any; row: any; pendingRow: any; value: any; stage: (v: any) => void; commit: (v?: any) => void }) => {
36293630
const fieldDef = (objectSchema as any)?.fields?.[ctx.column?.accessorKey];
3630-
if (!fieldDef || !hasFieldEditWidget(fieldDef.type)) return null;
3631+
// objectstack#36023 — a rich-content field edits in a panel under the cell.
3632+
if (!fieldDef || !(hasFieldEditWidget(fieldDef.type) || hasInCellPanelEditWidget(fieldDef.type))) return null;
36313633
// objectstack#35688 — a `select` declared `multiple` draws the multi-select
36323634
// check list (`SelectField` hands it to `MultiSelectField`): each check
36333635
// stages, and the edit is saved when the user moves on.

0 commit comments

Comments
 (0)