mirror of
https://github.com/alamion/obsidian-jira-sync.git
synced 2026-07-22 05:43:04 +00:00
feat: polish comment modal — full-width textarea, Ctrl+Enter to submit
This commit is contained in:
parent
4958fc6a3c
commit
0639461a08
5 changed files with 51 additions and 19 deletions
2
src/localization/source/en/commands/add_comment.yaml
Normal file
2
src/localization/source/en/commands/add_comment.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name: Add comment to Jira
|
||||
error: Error adding comment
|
||||
11
src/localization/source/en/modals/comment.yaml
Normal file
11
src/localization/source/en/modals/comment.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
name: Add Jira comment
|
||||
|
||||
body:
|
||||
name: Comment
|
||||
desc: "Write your comment here, or select text in the editor before running this command to pre-fill it"
|
||||
placeholder: "Write your comment here. Tip: select text in the editor before running this command to pre-fill."
|
||||
|
||||
submit: Submit
|
||||
|
||||
warns:
|
||||
empty: Comment cannot be empty
|
||||
2
src/localization/source/ru/commands/add_comment.yaml
Normal file
2
src/localization/source/ru/commands/add_comment.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name: Add comment to Jira
|
||||
error: Error adding comment
|
||||
11
src/localization/source/ru/modals/comment.yaml
Normal file
11
src/localization/source/ru/modals/comment.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
name: Add Jira comment
|
||||
|
||||
body:
|
||||
name: Comment
|
||||
desc: "Write your comment here, or select text in the editor before running this command to pre-fill it"
|
||||
placeholder: "Write your comment here. Tip: select text in the editor before running this command to pre-fill."
|
||||
|
||||
submit: Submit
|
||||
|
||||
warns:
|
||||
empty: Comment cannot be empty
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import {App, Modal, Notice, Setting} from "obsidian";
|
||||
import {App, Modal, Notice, Setting, TextAreaComponent} from "obsidian";
|
||||
import {useTranslations} from "../localization/translator";
|
||||
|
||||
const t = useTranslations("modals.comment").t;
|
||||
|
|
@ -20,31 +20,37 @@ export class IssueCommentModal extends Modal {
|
|||
onOpen() {
|
||||
new Setting(this.contentEl).setName(t("name")).setHeading();
|
||||
|
||||
new Setting(this.contentEl)
|
||||
.setName(t("body.name"))
|
||||
.addTextArea((text) => {
|
||||
text
|
||||
.setValue(this.commentText)
|
||||
.onChange((value) => {
|
||||
this.commentText = value;
|
||||
});
|
||||
text.inputEl.rows = 10;
|
||||
text.inputEl.style.width = "100%";
|
||||
const textarea = new TextAreaComponent(this.contentEl)
|
||||
.setPlaceholder(t("body.placeholder"))
|
||||
.setValue(this.commentText)
|
||||
.onChange((value) => {
|
||||
this.commentText = value;
|
||||
});
|
||||
textarea.inputEl.rows = 10;
|
||||
textarea.inputEl.style.width = "100%";
|
||||
textarea.inputEl.style.marginBottom = "0.75em";
|
||||
textarea.inputEl.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey && e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
this.submit();
|
||||
}
|
||||
});
|
||||
|
||||
new Setting(this.contentEl)
|
||||
.addButton((btn) =>
|
||||
btn
|
||||
.setButtonText(t("submit"))
|
||||
.setCta()
|
||||
.onClick(() => {
|
||||
if (!this.commentText.trim()) {
|
||||
new Notice(t("warns.empty"));
|
||||
return;
|
||||
}
|
||||
this.close();
|
||||
this.onSubmit(this.commentText);
|
||||
})
|
||||
.onClick(() => this.submit())
|
||||
);
|
||||
}
|
||||
|
||||
private submit() {
|
||||
if (!this.commentText.trim()) {
|
||||
new Notice(t("warns.empty"));
|
||||
return;
|
||||
}
|
||||
this.close();
|
||||
this.onSubmit(this.commentText);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue