alamion_obsidian-jira-sync/src/settings/tools/setupArrayTextString.ts
Alamoin 0786db1535
Feats
- `Super Simple Time Tracker` plugin format support
- Support of multiple Jira connections.
- `AGENTS.md` file from Obidian plugin template and filled with info about project
- Updated eslint configs to `eslint.config.js` format + linted all the code; added prettier with according config
- localization validator improvement; multiple localization fixes
- many minor fixes
2026-04-29 17:41:24 +03:00

29 lines
689 B
TypeScript

import { TextComponent } from 'obsidian';
export function setupArrayTextSetting(
text: TextComponent,
initialArray: string[],
onChange: (array: string[]) => Promise<void>,
) {
text.setValue(initialArray.join(', ')).onChange(async (value) => {
const array = value
.split(',')
.map((field) => field.trim())
.filter((field) => field.length > 0);
await onChange(array);
});
text.inputEl.addEventListener('blur', () => {
const currentValue = text.inputEl.value;
const cleaned = currentValue
.split(',')
.map((field) => field.trim())
.filter((field) => field.length > 0)
.join(', ');
if (currentValue !== cleaned) {
text.setValue(cleaned);
}
});
}