Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import tsparser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";
import obsidianmd from "eslint-plugin-obsidianmd";
import globals from "globals";

export default defineConfig([
...obsidianmd.configs.recommended,
{
files: ["**/*.ts"],
languageOptions: {
parser: tsparser,
parserOptions: { project: "./tsconfig.json" },
globals: {
...globals.browser,
},
},
rules: {
"obsidianmd/ui/sentence-case": [
"error",
{
// Preserve these proper nouns/acronyms that are not in the default list
ignoreWords: ["UTC", "ISO", "Unix", "GUIDs"],
},
],
},
},
]);
14 changes: 8 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,18 @@ export default class TextToolsPlugin extends Plugin {

this.addCommand({
id: "join-n-lines",
name: "Join every N lines",
name: "Join every n lines",
editorCallback: (editor) => {
new TwoInputModal(this.app, {
title: "Join every N lines",
label1: "N (lines per group)",
title: "Join every n lines",
label1: "Number of lines per group",
label2: "Glue",
placeholder1: "2",
placeholder2: " ",
onSubmit: (nStr, glue) => {
const n = parseInt(nStr, 10);
if (!n || n < 1) {
new Notice("N must be a positive integer.");
new Notice("Enter a positive integer.");
return;
}
transformSelections(editor, (t) => joinEveryNLines(t, n, glue));
Expand Down Expand Up @@ -796,7 +796,9 @@ export default class TextToolsPlugin extends Plugin {
return;
}
this.settings.textSlots[idx] = texts.join("\n");
this.saveSettings();
void this.saveSettings().catch((error) => {
console.error("Text Tools: failed to save settings", error);
});
new Notice(`Text slot ${i} set.`);
},
});
Expand Down Expand Up @@ -844,7 +846,7 @@ export default class TextToolsPlugin extends Plugin {
// =========================================================================

async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
this.settings = Object.assign({}, DEFAULT_SETTINGS, (await this.loadData()) as Partial<TextToolsSettings>);
}

async saveSettings() {
Expand Down
Loading
Loading