Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
style(ai-assistant): make the dialog's prompt the composer the chat has
Elian Doranb6b01284086f
diff --git a/apps/client/src/stylesheets/theme-next/notes/text.css b/apps/client/src/stylesheets/theme-next/notes/text.cssindex cf39df4164..f3303e5417 100644--- a/apps/client/src/stylesheets/theme-next/notes/text.css+++ b/apps/client/src/stylesheets/theme-next/notes/text.css@@ -600,6 +600,15 @@ button.ck.ck-button:is(.ck-button-action, .ck-button-save, .ck-button-cancel).ckbackground: var(--input-background-color);}+/* AI assistant composer */++:root .ck-ai-assistant-form__prompt-row input.ck.ck-input-text,+:root .ck-ai-assistant-form__prompt-row input.ck.ck-input-text:not([readonly="true"]):hover,+:root .ck-ai-assistant-form__prompt-row input.ck.ck-input-text:not([readonly="true"]):focus {+ outline: none;+ background: transparent;+}+/* Forms */:root .ck.ck-form__row.ck-form__row_with-submit > :not(:first-child) {diff --git a/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.ts b/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.tsindex 980b41f00d..d02862565d 100644--- a/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.ts+++ b/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.ts@@ -260,24 +260,33 @@ export default class AiAssistantFormView extends View {},{tag: "div",+ // One island, as the chat's composer is: what is being written on top, and+ // underneath it what the writing will be sent to and the button that sends it.+ // The border and the focus ring belong to the island, not to the field inside.attributes: { class: ["ck", "ck-ai-assistant-form__prompt-row"] },- // Send and Stop share the slot at the end of the row; the phase decides which- // of the two is on show.children: [+ this.promptInputView,{tag: "div",- attributes: {- class: [- "ck",- "ck-ai-assistant-form__picker",- bind.if("hasPicker", "ck-hidden", (hasPicker) => !hasPicker)- ]- },- children: [this.pickerView]- },- this.promptInputView,- this.sendButtonView,- this.stopButtonView+ attributes: { class: ["ck", "ck-ai-assistant-form__prompt-actions"] },+ // Send and Stop share the slot at the end of the row; the phase decides+ // which of the two is on show.+ children: [+ {+ tag: "div",+ attributes: {+ class: [+ "ck",+ "ck-ai-assistant-form__picker",+ bind.if("hasPicker", "ck-hidden", (hasPicker) => !hasPicker)+ ]+ },+ children: [this.pickerView]+ },+ this.sendButtonView,+ this.stopButtonView+ ]+ }]},{@@ -326,8 +335,8 @@ export default class AiAssistantFormView extends View {this.resultToggleView,this.changesToggleView,this.tryAgainButtonView,- this.pickerView.buttonView,this.promptInputView,+ this.pickerView.buttonView,this.sendButtonView,this.stopButtonView,this.insertBelowButtonView,diff --git a/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.css b/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.cssindex 9353fe660a..e73bc4cabb 100644--- a/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.css+++ b/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.css@@ -26,10 +26,31 @@margin-inline-start: auto;}+/* The composer, as the chat's is: one bordered island holding the field and, under it, the row of+ controls the writing is sent with. */.ck.ck-ai-assistant-form .ck-ai-assistant-form__prompt-row {+ display: flex;+ flex-direction: column;+ gap: var(--ck-spacing-small);+ padding: var(--ck-spacing-small);+ border: 1px solid var(--ck-color-input-border);+ border-radius: var(--ck-border-radius);+ background: var(--ck-color-input-background);+ outline: 2px solid transparent;+ transition: outline-color 100ms linear;+}++/* Keyed off the field's own focus rather than `:focus-within`, so reaching the model or the send+ button does not light the whole island up. */+.ck.ck-ai-assistant-form .ck-ai-assistant-form__prompt-row:has(.ck-input_focused) {+ outline-color: var(--ck-color-focus-border);+}++.ck.ck-ai-assistant-form .ck-ai-assistant-form__prompt-actions {display: flex;align-items: center;- gap: var(--ck-spacing-medium);+ justify-content: flex-end;+ gap: var(--ck-spacing-small);}/* The list scrolls, so it also clips: the panel's inline padding moves onto it, leaving a rule@@ -45,16 +66,28 @@overflow-y: auto;}+/* The island carries the border, the fill and the focus ring, so the field inside carries none. */.ck.ck-ai-assistant-form .ck-ai-assistant-form__prompt-row .ck-input {- flex-grow: 1;+ width: 100%;min-width: 0;+ border: none;+ border-radius: 0;+ box-shadow: none;+ background: transparent;}-/* The prompt is what the row is for, so the picker gives way to it: it is allowed to shrink, down- to a name of a few characters, and truncates rather than pushing the input narrower. */+/* The only thing in the control row allowed to give — everything beside it is a fixed-size button.+ It keeps the row's start, leaving Send at the end. */.ck.ck-ai-assistant-form .ck-ai-assistant-form__picker {flex-shrink: 1;min-width: 0;+ margin-inline-end: auto;+}++/* Smaller than the prompt above it, as the chat's picker is: state to glance at rather than the+ thing the island is for. */+.ck.ck-ai-assistant-form .ck-ai-assistant-form__picker .ck-button {+ font-size: var(--ck-font-size-small);}.ck.ck-ai-assistant-form .ck-ai-assistant-form__picker .ck-button__label {