@simmalugnt-se/payload-editor-assistant 0.13.0 → 0.13.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.1
|
|
4
|
+
|
|
5
|
+
- The chat composer starts at three lines and grows with typed or pasted text up to eight lines
|
|
6
|
+
(or 30% of the viewport), then scrolls. It also resizes after prefilled prompts and panel reopening.
|
|
7
|
+
|
|
3
8
|
## 0.13.0
|
|
4
9
|
|
|
5
10
|
- Attach reference images to chat with file selection, drag-and-drop or clipboard paste. Show
|
|
@@ -40,6 +40,28 @@ export function EditorAssistantAside() {
|
|
|
40
40
|
}
|
|
41
41
|
}, [prefill, setPrefill]);
|
|
42
42
|
const threadRef = useRef(null);
|
|
43
|
+
const composerRef = useRef(null);
|
|
44
|
+
// Grow on typing/prefill and remeasure when the panel reopens or its width changes.
|
|
45
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: draft changes and returning from a batch require remeasuring the DOM.
|
|
46
|
+
useLayoutEffect(() => {
|
|
47
|
+
const textarea = composerRef.current;
|
|
48
|
+
if (!textarea || !open)
|
|
49
|
+
return;
|
|
50
|
+
const resize = () => {
|
|
51
|
+
textarea.style.height = "auto";
|
|
52
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
53
|
+
};
|
|
54
|
+
resize();
|
|
55
|
+
let width = textarea.clientWidth;
|
|
56
|
+
const observer = new ResizeObserver(() => {
|
|
57
|
+
if (textarea.clientWidth === width)
|
|
58
|
+
return;
|
|
59
|
+
width = textarea.clientWidth;
|
|
60
|
+
resize();
|
|
61
|
+
});
|
|
62
|
+
observer.observe(textarea);
|
|
63
|
+
return () => observer.disconnect();
|
|
64
|
+
}, [draft, open, batch]);
|
|
43
65
|
/** Whether the editor typed in the form while a preview was in it; undo would discard that. */
|
|
44
66
|
const editedSinceRef = useRef(false);
|
|
45
67
|
const [confirmUndo, setConfirmUndo] = useState(false);
|
|
@@ -471,7 +493,7 @@ export function EditorAssistantAside() {
|
|
|
471
493
|
void send(translate.prompt);
|
|
472
494
|
}, size: "small", children: translate.label })) : null, visibleShortcuts.map((shortcut) => (_jsx(Button, { buttonStyle: "pill", disabled: status === "streaming", margin: false, onClick: () => {
|
|
473
495
|
void send(shortcut.prompt);
|
|
474
|
-
}, size: "small", children: shortcut.label }, shortcut.id)))] })) : null, selection && bridge ? (_jsxs("div", { className: "ea-selection", children: [_jsxs("span", { className: "ea-selection__label", children: [copy.selected, ": ", _jsx("strong", { children: selection.label })] }), _jsx("button", { "aria-label": copy.clearSelection, className: "ea-selection__clear", type: "button", onClick: () => setSelection(null), children: _jsx(XIcon, {}) })] })) : null, _jsxs("div", { className: "ea-composer__box", children: [attachments.input, attachments.preview, _jsx("textarea", { disabled: status === "streaming", placeholder: copy.placeholder, rows:
|
|
496
|
+
}, size: "small", children: shortcut.label }, shortcut.id)))] })) : null, selection && bridge ? (_jsxs("div", { className: "ea-selection", children: [_jsxs("span", { className: "ea-selection__label", children: [copy.selected, ": ", _jsx("strong", { children: selection.label })] }), _jsx("button", { "aria-label": copy.clearSelection, className: "ea-selection__clear", type: "button", onClick: () => setSelection(null), children: _jsx(XIcon, {}) })] })) : null, _jsxs("div", { className: "ea-composer__box", children: [attachments.input, attachments.preview, _jsx("textarea", { ref: composerRef, disabled: status === "streaming", placeholder: copy.placeholder, rows: 3, value: draft, onChange: (event) => setDraft(event.target.value), onKeyDown: onKeyDown, onPaste: attachments.onPaste }), _jsxs("div", { className: "ea-composer__bar", children: [_jsx(Button, { buttonStyle: "subtle", type: "button", margin: false, size: "small", disabled: status === "streaming" || attachments.preparing, onClick: attachments.choose, children: copy.attachImage }), status === "streaming" ? (
|
|
475
497
|
// While the assistant works, Send becomes Stop, where the editor's eye already is.
|
|
476
498
|
_jsx(Button, { "aria-label": copy.stop, buttonStyle: "secondary", className: "ea-composer__stop", icon: _jsx("span", { className: "ea-stop-icon", "aria-hidden": "true" }), iconPosition: "left", margin: false, onClick: () => stop(), size: "medium", type: "button", children: copy.stop })) : (_jsx(Button, { buttonStyle: "primary", disabled: attachments.preparing ||
|
|
477
499
|
(draft.trim() === "" && attachments.images.length === 0), margin: false, size: "medium", type: "submit", children: copy.send }))] })] })] })] }))] }));
|
|
@@ -358,7 +358,9 @@ html[data-theme="dark"] .ea-aside {
|
|
|
358
358
|
.ea-composer textarea {
|
|
359
359
|
width: 100%;
|
|
360
360
|
box-sizing: border-box;
|
|
361
|
-
min-height:
|
|
361
|
+
min-height: 4.5em;
|
|
362
|
+
max-height: min(12em, 30vh);
|
|
363
|
+
overflow-y: auto;
|
|
362
364
|
padding: 0;
|
|
363
365
|
border: 0;
|
|
364
366
|
background: transparent;
|