discourse-ai/assets/javascripts/discourse/components/ai-helper-custom-prompt.gjs
Keegan George 9cd14b0003
DEV: Move composer AI helper to toolbar (#796)
Previously we had moved the AI helper from the options menu to a selection menu that appears when selecting text in the composer. This had the benefit of making the AI helper a more discoverable feature. Now that some time has passed and the AI helper is more recognized, we will be moving it back to the composer toolbar.

This is better because:
- It consistent with other behavior and ways of accessing tools in the composer
- It has an improved mobile experience
- It reduces unnecessary code and keeps things easier to migrate when we have composer V2.
- It allows for easily triggering AI helper for all content by clicking the button instead of having to select everything.
2024-09-13 11:59:30 -07:00

43 lines
1.2 KiB
Plaintext

import Component from "@glimmer/component";
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import DButton from "discourse/components/d-button";
import withEventValue from "discourse/helpers/with-event-value";
import i18n from "discourse-common/helpers/i18n";
import not from "truth-helpers/helpers/not";
export default class AiHelperCustomPrompt extends Component {
@action
sendInput(event) {
if (event.key !== "Enter") {
return;
}
return this.args.submit(this.args.promptArgs);
}
<template>
<div class="ai-custom-prompt">
<input
{{on "input" (withEventValue (fn (mut @value)))}}
{{on "keydown" this.sendInput}}
value={{@value}}
placeholder={{i18n
"discourse_ai.ai_helper.context_menu.custom_prompt.placeholder"
}}
class="ai-custom-prompt__input"
type="text"
autofocus="autofocus"
/>
<DButton
@icon="discourse-sparkles"
@action={{fn @submit @promptArgs}}
@disabled={{not @value.length}}
class="ai-custom-prompt__submit btn-primary"
/>
</div>
</template>
}