Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74b3a16151 | ||
|
|
b8461c3eb0 | ||
|
|
b031cd7e04 | ||
|
|
254fcc1b41 |
No files matched your search
@@ -0,0 +1,69 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project are documented in this file.
|
||||
Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
## [1.2.0] - 2026-10-08
|
||||
|
||||
### Added
|
||||
|
||||
- **Delete Previous Word** and **Delete Next Word** commands, configurable through
|
||||
Obsidian's Hotkeys settings and individually enabled under Line Operations.
|
||||
Native editor word deletion handles selections, multiple cursors, and undo.
|
||||
No default hotkeys are assigned; existing word-deletion shortcuts are unchanged.
|
||||
|
||||
## [1.1.0] - 2026-09-07
|
||||
|
||||
### Added
|
||||
|
||||
- **Settings page now visually groups commands by category.** Each category
|
||||
(Better Formatting, Line Operations, etc.) renders as a collapsible card with
|
||||
a bordered/shaded header and an "N/M enabled" badge, instead of a flat list
|
||||
separated only by bold text headings. The sentence-matching regex setting
|
||||
moved into the Sentence Navigator category card, since it configures that
|
||||
category's commands. Toggling a setting no longer collapses open categories.
|
||||
(`src/settings.ts`, `styles.css`)
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Heading toggle corrupted lines starting with a tag (`#tag ...`).** `HEADING_REGEX`
|
||||
(`src/Constants.ts`) matched any run of leading `#` characters as a heading marker,
|
||||
even without a following space. Obsidian tags like `#project meeting notes` were
|
||||
therefore misread as an existing H1, so running *Toggle Heading - H1* on such a
|
||||
line stripped the `#` instead of adding a heading (and running any other heading
|
||||
level inserted a stray heading marker before the tag). The regex now requires the
|
||||
`#` run to be followed by whitespace or end-of-line before it counts as a heading,
|
||||
matching the ATX heading rule already used by *Toggle Heading (strip formatting)*.
|
||||
(`src/Constants.ts`, `src/ToggleHeading.ts`)
|
||||
|
||||
- **Command enable/disable toggles in Settings required an Obsidian restart.**
|
||||
`registerCommands()` only ran once in `onload()`, checking `enabledCommands` at
|
||||
registration time. Flipping a toggle in the settings tab saved the new state but
|
||||
had no effect on the already-registered commands until the plugin was reloaded,
|
||||
contradicting the setting's own description ("Disabled commands will not appear
|
||||
in the command palette"). Commands are now always registered and gated through
|
||||
`checkCallback`/`editorCheckCallback`, so palette visibility and hotkeys respond
|
||||
immediately to settings changes. Command IDs are unchanged, so existing hotkey
|
||||
bindings are unaffected. (`src/main.ts`)
|
||||
|
||||
- **"New Adjacent File" failed after the first use in a folder.** The command
|
||||
always targeted a literal `Untitled.md`; `vault.create()` throws if that path
|
||||
already exists (very likely, since it's also Obsidian's own default new-note
|
||||
name), surfacing a raw error `Notice` on every subsequent use. It now finds the
|
||||
next available `Untitled N.md` name in the folder, mirroring Obsidian's built-in
|
||||
new-note behavior. (`src/FileHelper.ts`)
|
||||
|
||||
- **Selection-tracking listeners went stale for editors opened after startup.**
|
||||
`registerSelectionChangeListeners()` attached `keydown`/`click`/`dblclick`
|
||||
listeners to every `.cm-content` element found via a single `querySelectorAll`
|
||||
at layout-ready. Editors created afterward (new panes, splits, tabs) got their
|
||||
own `.cm-content` element that was never instrumented, silently degrading the
|
||||
manual-vs-programmatic selection heuristic used by *Select Next/Previous
|
||||
Occurrence*. Listeners are now delegated from `document` in the capture phase,
|
||||
so any editor present now or opened later is covered. (`src/main.ts`)
|
||||
|
||||
### Chore
|
||||
|
||||
- Reinstalled `node_modules` to pull the `@esbuild/win32-x64` binary; the checked
|
||||
in lockfile/install had resolved only `@esbuild/linux-x64`, so `npm run build`
|
||||
and `npm run dev` failed outright on this machine.
|
||||
@@ -54,6 +54,8 @@ Essential line manipulation commands for efficient editing.
|
||||
| Delete Line | Remove the current line entirely |
|
||||
| Delete to Start of Line | Remove all text from cursor to the beginning of the line |
|
||||
| Delete to End of Line | Remove all text from cursor to the end of the line |
|
||||
| Delete Previous Word | Delete to the previous word boundary, or delete the selection |
|
||||
| Delete Next Word | Delete to the next word boundary, or delete the selection |
|
||||
| Join Lines | Merge the current line with the next line |
|
||||
| Duplicate Line | Copy the current line and insert it below |
|
||||
| Copy Line Up | Duplicate the current line above (VSCode style) |
|
||||
@@ -178,6 +180,18 @@ All commands can be assigned custom keyboard shortcuts:
|
||||
3. Click the `+` icon next to any command
|
||||
4. Press your desired key combination
|
||||
|
||||
For word deletion, search for **BindThem: Delete Previous Word** or
|
||||
**BindThem: Delete Next Word**. These commands have no default hotkeys and leave
|
||||
the built-in `Ctrl+Backspace` and `Ctrl+Delete` shortcuts unchanged. They use the
|
||||
editor's native word boundaries, support multiple cursors, and can be undone.
|
||||
If the cursor is inside a word, only the portion in the chosen direction is
|
||||
deleted; an existing selection is deleted instead.
|
||||
|
||||
Enable or disable these commands under **Settings > BindThem > Line Operations**.
|
||||
On Windows, `Ctrl+Alt+Delete` is reserved by the operating system and cannot be
|
||||
assigned to an Obsidian command. Use another combination, such as
|
||||
`Ctrl+Alt+Backspace` or `Ctrl+Alt+Shift+Delete`, provided it has no conflicting binding.
|
||||
|
||||
## Credits
|
||||
|
||||
This plugin merges and refactors functionality from:
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "bindthem",
|
||||
"name": "BindThem",
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Enhanced editor shortcuts and formatting tools. Combines smart text wrapping (bold, italic, code, etc.), directional copy/move, heading toggles (H1-H6), line operations, case transformation, multi-cursor support, and file utilities into one unified plugin.",
|
||||
"author": "Olivier Legendre",
|
||||
|
||||
Generated
+167
-103
@@ -1,17 +1,19 @@
|
||||
{
|
||||
"name": "bindthem",
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "bindthem",
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.8.1",
|
||||
"obsidian": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/view": "6.38.6",
|
||||
"@eslint/js": "9.30.1",
|
||||
"@types/node": "^16.11.6",
|
||||
"esbuild": "0.25.5",
|
||||
@@ -23,22 +25,53 @@
|
||||
"typescript-eslint": "8.35.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/commands": {
|
||||
"version": "6.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.8.1.tgz",
|
||||
"integrity": "sha512-KlGVYufHMQzxbdQONiLyGQDUW0itrLZwq3CcY7xpv9ZLRHqzkBSoteocBHtMCoY7/Ci4xhzSrToIeLg7FxHuaw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.4.0",
|
||||
"@codemirror/view": "^6.27.0",
|
||||
"@lezer/common": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/language": {
|
||||
"version": "6.13.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.13.1.tgz",
|
||||
"integrity": "sha512-zfvU2r3TyylQLMj/te+5CnQ0rSqZi8B1oTCBbQkagcLW4Xc6imab6qN+pEJhsuNOLaJqiRyBXp9UhWA1DhVvDw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/streamparser": "^6.0.0",
|
||||
"@codemirror/view": "^6.23.0",
|
||||
"@lezer/common": "^1.5.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0",
|
||||
"style-mod": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/state": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.0.tgz",
|
||||
"integrity": "sha512-MwBHVK60IiIHDcoMet78lxt6iw5gJOGSbNbOIVBHWVXIH4/Nq1+GQgLLGgI1KlnN86WDXsPudVaqYHKBIx7Eyw==",
|
||||
"version": "6.7.6",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.6.tgz",
|
||||
"integrity": "sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@marijn/find-cluster-break": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/streamparser": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/streamparser/-/streamparser-6.0.0.tgz",
|
||||
"integrity": "sha512-JTFPF6xrfjt0mnfGPgzcLiMwYmvIyNaoizp8BYzv8FE8KrT6GBGDZ190rtt+O7Wke3gG/MFHyiY9YGNeimof4w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@codemirror/view": {
|
||||
"version": "6.38.6",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.38.6.tgz",
|
||||
"integrity": "sha512-qiS0z1bKs5WOvHIAC0Cybmv4AJSkAXgX5aD6Mqd2epSLlVJsQl8NG23jCVouIgkh4All/mrbdsf2UOLFnJw0tw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.5.0",
|
||||
"crelt": "^1.0.6",
|
||||
@@ -695,12 +728,35 @@
|
||||
"url": "https://github.com/sponsors/nzakas"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/common": {
|
||||
"version": "1.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.3.tgz",
|
||||
"integrity": "sha512-H0iErY4e43LpXbYDyBci5W4v/RwTgGV3YzYOlJPiGZ8RY8w51kVE+xLn1tg3Z6UmSfyETvtsUK3r7YsgDQEI7Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@lezer/highlight": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.5.tgz",
|
||||
"integrity": "sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/lr": {
|
||||
"version": "1.4.11",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.11.tgz",
|
||||
"integrity": "sha512-UwgZcl1R66H2hDzBrA7kWyYmX6s8p5TQ+e/t7CuvgCtBEPxbEPaHYHu+pJBvTvDotEJpuQkJjbXuHiw5Cixxgw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@marijn/find-cluster-break": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
|
||||
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@microsoft/eslint-plugin-sdl": {
|
||||
"version": "1.1.0",
|
||||
@@ -885,9 +941,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
|
||||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz",
|
||||
"integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==",
|
||||
"version": "7.0.12",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz",
|
||||
"integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1044,9 +1100,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
|
||||
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
|
||||
"version": "2.1.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
|
||||
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1054,13 +1110,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
||||
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
|
||||
"version": "9.0.9",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
|
||||
"integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
"brace-expansion": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
@@ -1070,9 +1126,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -1148,9 +1204,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "6.12.6",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
|
||||
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
|
||||
"version": "6.15.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz",
|
||||
"integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1381,9 +1437,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.12",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
|
||||
"integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
|
||||
"version": "1.1.21",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz",
|
||||
"integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1512,8 +1568,7 @@
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
|
||||
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
@@ -2005,9 +2060,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-compat-utils/node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -2080,9 +2135,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-depend/node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -2188,9 +2243,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-json-schema-validator/node_modules/ajv": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz",
|
||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||
"version": "8.20.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
|
||||
"integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2205,9 +2260,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-json-schema-validator/node_modules/brace-expansion": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
|
||||
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
|
||||
"version": "2.1.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
|
||||
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2222,9 +2277,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/eslint-plugin-json-schema-validator/node_modules/minimatch": {
|
||||
"version": "8.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.4.tgz",
|
||||
"integrity": "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==",
|
||||
"version": "8.0.7",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.7.tgz",
|
||||
"integrity": "sha512-V+1uQNdzybxa14e/p00HZnQNNcTjnRJjDxg2V8wtkjFctq4M7hXFws4oekyTP0Jebeq7QYtpFyOeBAjc88zvYg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -2264,9 +2319,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-n/node_modules/brace-expansion": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
|
||||
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
|
||||
"version": "2.1.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
|
||||
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2287,13 +2342,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-n/node_modules/minimatch": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
||||
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
|
||||
"version": "9.0.9",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
|
||||
"integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
"brace-expansion": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
@@ -2303,9 +2358,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-n/node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -2358,21 +2413,6 @@
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-obsidianmd/node_modules/obsidian": {
|
||||
"version": "1.8.7",
|
||||
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.8.7.tgz",
|
||||
"integrity": "sha512-h4bWwNFAGRXlMlMAzdEiIM2ppTGlrh7uGOJS6w4gClrsjc+ei/3YAtU2VdFUlCiPuTHpY4aBpFJJW75S1Tl/JA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/codemirror": "5.60.8",
|
||||
"moment": "2.29.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-obsidianmd/node_modules/typescript": {
|
||||
"version": "5.4.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
|
||||
@@ -2421,19 +2461,25 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react/node_modules/resolve": {
|
||||
"version": "2.0.0-next.5",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.5.tgz",
|
||||
"integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==",
|
||||
"version": "2.0.0-next.7",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.7.tgz",
|
||||
"integrity": "sha512-tqt+NBWwyaMgw3zDsnygx4CByWjQEJHOPMdslYhppaQSJUtL/D4JO9CcBBlhPoI8lz9oJIDXkwXfhF4aWqP8xQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-core-module": "^2.13.0",
|
||||
"es-errors": "^1.3.0",
|
||||
"is-core-module": "^2.16.2",
|
||||
"node-exports-info": "^1.6.0",
|
||||
"object-keys": "^1.1.1",
|
||||
"path-parse": "^1.0.7",
|
||||
"supports-preserve-symlinks-flag": "^1.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"resolve": "bin/resolve"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
@@ -2986,9 +3032,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
|
||||
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -3135,13 +3181,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/is-core-module": {
|
||||
"version": "2.16.1",
|
||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
|
||||
"integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==",
|
||||
"version": "2.17.0",
|
||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.17.0.tgz",
|
||||
"integrity": "sha512-J/vG0zBCbIKOQFfufSwyXdMrsohyJIUNkrnmo6WZGzoM7tr/lsbfW5b2BvisL6zsyMzK9UxV9L6c7AoFbyXHOA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"hasown": "^2.0.2"
|
||||
"hasown": "^2.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -3522,9 +3568,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/json-schema-migrate/node_modules/ajv": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz",
|
||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||
"version": "8.20.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
|
||||
"integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -3623,9 +3669,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jsonc-eslint-parser/node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -3746,9 +3792,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
||||
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -3798,6 +3844,25 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-exports-info": {
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmjs.org/node-exports-info/-/node-exports-info-1.6.2.tgz",
|
||||
"integrity": "sha512-kXs9Go0cah0qHVV2v389IXQLdLCeE1xfFtjOAF+iobu0OIoG1pje8At2vMHyaPMiPMnG/LWP50twML21eMcAag==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"array.prototype.flatmap": "^1.3.3",
|
||||
"es-errors": "^1.3.0",
|
||||
"object.entries": "^1.1.9",
|
||||
"semver": "^6.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
@@ -3922,17 +3987,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/obsidian": {
|
||||
"version": "1.10.3",
|
||||
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.10.3.tgz",
|
||||
"integrity": "sha512-VP+ZSxNMG7y6Z+sU9WqLvJAskCfkFrTz2kFHWmmzis+C+4+ELjk/sazwcTHrHXNZlgCeo8YOlM6SOrAFCynNew==",
|
||||
"version": "1.8.7",
|
||||
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.8.7.tgz",
|
||||
"integrity": "sha512-h4bWwNFAGRXlMlMAzdEiIM2ppTGlrh7uGOJS6w4gClrsjc+ei/3YAtU2VdFUlCiPuTHpY4aBpFJJW75S1Tl/JA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/codemirror": "5.60.8",
|
||||
"moment": "2.29.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@codemirror/state": "6.5.0",
|
||||
"@codemirror/view": "6.38.6"
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
@@ -4191,13 +4256,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/resolve": {
|
||||
"version": "1.22.11",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz",
|
||||
"integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==",
|
||||
"version": "1.22.13",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.13.tgz",
|
||||
"integrity": "sha512-Dj/cW9zBV2aRj6XzCxuGIs3ESZKv02jixne3q6jFZYZ3/Tg09gHHviSMDL4kObh9pqSahdRHEnDoaP2gn8YLhA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-core-module": "^2.16.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"is-core-module": "^2.17.0",
|
||||
"path-parse": "^1.0.7",
|
||||
"supports-preserve-symlinks-flag": "^1.0.0"
|
||||
},
|
||||
@@ -4659,8 +4725,7 @@
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",
|
||||
"integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/supports-color": {
|
||||
"version": "7.2.0",
|
||||
@@ -4982,8 +5047,7 @@
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
|
||||
+13
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bindthem",
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.0",
|
||||
"description": "A merged plugin combining obsidian-tweaks, obsidian-editor-shortcuts, and heading-toggler functionalities.",
|
||||
"main": "main.js",
|
||||
"type": "module",
|
||||
@@ -10,20 +10,28 @@
|
||||
"version": "node version-bump.mjs && git add manifest.json versions.json",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"keywords": ["obsidian", "plugin", "editor", "shortcuts", "formatting"],
|
||||
"keywords": [
|
||||
"obsidian",
|
||||
"plugin",
|
||||
"editor",
|
||||
"shortcuts",
|
||||
"formatting"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@codemirror/view": "6.38.6",
|
||||
"@eslint/js": "9.30.1",
|
||||
"@types/node": "^16.11.6",
|
||||
"esbuild": "0.25.5",
|
||||
"eslint-plugin-obsidianmd": "0.1.9",
|
||||
"globals": "14.0.0",
|
||||
"jiti": "2.6.1",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "8.35.1",
|
||||
"@eslint/js": "9.30.1",
|
||||
"jiti": "2.6.1"
|
||||
"typescript-eslint": "8.35.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.8.1",
|
||||
"obsidian": "latest"
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -37,6 +37,10 @@ export const LIST_CHARACTER_REGEX = /^\s*(-|\+|\*|\d+\.|>) (\[.\] )?$/
|
||||
// ============================================================
|
||||
|
||||
/**
|
||||
* Regex for matching heading markers at the start of a line
|
||||
* Regex for matching heading markers at the start of a line.
|
||||
* A valid ATX heading marker is 1-6 `#` characters immediately followed
|
||||
* by whitespace or end of line. This lookahead excludes tag-like
|
||||
* prefixes such as `#project` (no space) from being misdetected as
|
||||
* headings — matches[1] is undefined when there is no valid marker.
|
||||
*/
|
||||
export const HEADING_REGEX = /^(#*)( *)(.*)/
|
||||
export const HEADING_REGEX = /^(#{1,6}(?=[ \t]|$))?( *)(.*)/
|
||||
+17
-2
@@ -41,7 +41,9 @@ export class FileHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file in the same directory as the current file
|
||||
* Create a new file in the same directory as the current file.
|
||||
* If "Untitled.md" already exists, finds the next available
|
||||
* "Untitled N.md" name (mirrors Obsidian's own new-note behavior).
|
||||
*/
|
||||
public async newAdjacentFile(editor: Editor, view: MarkdownView | MarkdownFileInfo): Promise<void> {
|
||||
const activeFile = this.app.workspace.getActiveFile()
|
||||
@@ -51,7 +53,7 @@ export class FileHelper {
|
||||
}
|
||||
|
||||
const parentPath = activeFile.parent?.path ?? ''
|
||||
const newFilePath = parentPath + '/' + 'Untitled.md'
|
||||
const newFilePath = this.getAvailablePath(parentPath, 'Untitled', 'md')
|
||||
|
||||
try {
|
||||
const newFile = await this.app.vault.create(newFilePath, '')
|
||||
@@ -62,4 +64,17 @@ export class FileHelper {
|
||||
new Notice(String(e))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first unused "<basename>.md" / "<basename> N.md" path in a folder
|
||||
*/
|
||||
private getAvailablePath(parentPath: string, basename: string, extension: string): string {
|
||||
let candidate = `${parentPath}/${basename}.${extension}`
|
||||
let n = 1
|
||||
while (this.app.vault.getAbstractFileByPath(candidate) !== null) {
|
||||
candidate = `${parentPath}/${basename} ${n}.${extension}`
|
||||
n++
|
||||
}
|
||||
return candidate
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export class ToggleHeading {
|
||||
}
|
||||
const to: EditorPosition = {
|
||||
line: line,
|
||||
ch: matches[1].length + matches[2].length,
|
||||
ch: (matches[1]?.length ?? 0) + matches[2].length,
|
||||
}
|
||||
|
||||
const replacementStr = heading === Heading.NORMAL ? '' : headingStr + ' '
|
||||
@@ -61,7 +61,7 @@ export class ToggleHeading {
|
||||
const text = editor.getLine(line)
|
||||
const matches = HEADING_REGEX.exec(text)!
|
||||
|
||||
return matches[1].length as Heading
|
||||
return (matches[1]?.length ?? 0) as Heading
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+72
-28
@@ -1,4 +1,6 @@
|
||||
import { Editor, MarkdownView, MarkdownFileInfo, Plugin } from 'obsidian';
|
||||
import { deleteGroupBackward, deleteGroupForward } from '@codemirror/commands';
|
||||
import type { EditorView } from '@codemirror/view';
|
||||
|
||||
import {
|
||||
BindThemSettings,
|
||||
@@ -98,13 +100,33 @@ export default class BindThemPlugin extends Plugin {
|
||||
editorCallback?: (editor: Editor, view: MarkdownView | MarkdownFileInfo) => void;
|
||||
callback?: () => void;
|
||||
}): void {
|
||||
if (this.isCommandEnabled(options.id)) {
|
||||
const { id, name, icon, editorCallback, callback } = options;
|
||||
|
||||
// Commands are always registered; enabled state is enforced via
|
||||
// checkCallback so toggling a command in settings takes effect
|
||||
// immediately (hides it from the palette and disables its hotkey)
|
||||
// without requiring a plugin reload.
|
||||
if (editorCallback) {
|
||||
this.addCommand({
|
||||
id: options.id,
|
||||
name: options.name,
|
||||
icon: options.icon,
|
||||
editorCallback: options.editorCallback,
|
||||
callback: options.callback,
|
||||
id,
|
||||
name,
|
||||
icon,
|
||||
editorCheckCallback: (checking, editor, view) => {
|
||||
if (!this.isCommandEnabled(id)) return false;
|
||||
if (!checking) editorCallback(editor, view);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
} else if (callback) {
|
||||
this.addCommand({
|
||||
id,
|
||||
name,
|
||||
icon,
|
||||
checkCallback: (checking) => {
|
||||
if (!this.isCommandEnabled(id)) return false;
|
||||
if (!checking) callback();
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -452,6 +474,23 @@ export default class BindThemPlugin extends Plugin {
|
||||
editorCallback: (editor: Editor, view: MarkdownView | MarkdownFileInfo) => {
|
||||
this.deleteToLineBoundary(editor, 'end');
|
||||
}});
|
||||
this.addConditionalCommand({
|
||||
id: 'delete-previous-word',
|
||||
name: 'Delete Previous Word',
|
||||
icon: 'delete',
|
||||
editorCallback: (editor: Editor) => {
|
||||
// Obsidian's Editor.exec API does not expose word deletion.
|
||||
deleteGroupBackward((editor as Editor & { cm: EditorView }).cm);
|
||||
}
|
||||
});
|
||||
this.addConditionalCommand({
|
||||
id: 'delete-next-word',
|
||||
name: 'Delete Next Word',
|
||||
icon: 'delete',
|
||||
editorCallback: (editor: Editor) => {
|
||||
deleteGroupForward((editor as Editor & { cm: EditorView }).cm);
|
||||
}
|
||||
});
|
||||
this.addConditionalCommand({
|
||||
id: 'join-lines',
|
||||
name: 'Join Lines',
|
||||
@@ -903,31 +942,36 @@ export default class BindThemPlugin extends Plugin {
|
||||
* - Programmatic changes → within-word matching
|
||||
*/
|
||||
private registerSelectionChangeListeners(): void {
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
const MODIFIER_KEYS = [
|
||||
'Control', 'Shift', 'Alt', 'Meta', 'CapsLock', 'Fn',
|
||||
]
|
||||
const MODIFIER_KEYS = [
|
||||
'Control', 'Shift', 'Alt', 'Meta', 'CapsLock', 'Fn',
|
||||
]
|
||||
|
||||
const handleSelectionChange = (evt: Event) => {
|
||||
if (
|
||||
evt instanceof KeyboardEvent &&
|
||||
MODIFIER_KEYS.includes(evt.key)
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (!getIsProgrammaticSelectionChange()) {
|
||||
setIsManualSelection(true)
|
||||
}
|
||||
setIsProgrammaticSelectionChange(false)
|
||||
const handleSelectionChange = (evt: Event) => {
|
||||
if (
|
||||
evt instanceof KeyboardEvent &&
|
||||
MODIFIER_KEYS.includes(evt.key)
|
||||
) {
|
||||
return
|
||||
}
|
||||
const target = evt.target as HTMLElement | null
|
||||
if (!target?.closest('.cm-content')) {
|
||||
return
|
||||
}
|
||||
if (!getIsProgrammaticSelectionChange()) {
|
||||
setIsManualSelection(true)
|
||||
}
|
||||
setIsProgrammaticSelectionChange(false)
|
||||
}
|
||||
|
||||
// Observe CodeMirror 6 editors (new Obsidian editor)
|
||||
document.querySelectorAll('.cm-content').forEach((el) => {
|
||||
this.registerDomEvent(el as HTMLElement, 'keydown', handleSelectionChange)
|
||||
this.registerDomEvent(el as HTMLElement, 'click', handleSelectionChange)
|
||||
this.registerDomEvent(el as HTMLElement, 'dblclick', handleSelectionChange)
|
||||
})
|
||||
})
|
||||
// Delegate from `document` in the capture phase instead of
|
||||
// enumerating `.cm-content` elements once at layout-ready:
|
||||
// editors opened in new panes/splits/tabs after startup get
|
||||
// their own `.cm-content` element and would otherwise never
|
||||
// be instrumented. Capture phase guarantees we observe the
|
||||
// event even if CodeMirror stops propagation during bubbling.
|
||||
this.registerDomEvent(document, 'keydown', handleSelectionChange, true)
|
||||
this.registerDomEvent(document, 'click', handleSelectionChange, true)
|
||||
this.registerDomEvent(document, 'dblclick', handleSelectionChange, true)
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
|
||||
+111
-48
@@ -1,4 +1,4 @@
|
||||
import { App, PluginSettingTab, Setting } from 'obsidian';
|
||||
import { App, PluginSettingTab, Setting, TextComponent } from 'obsidian';
|
||||
import BindThemPlugin from './main';
|
||||
import { DEFAULT_SENTENCE_REGEX } from './Constants';
|
||||
|
||||
@@ -75,6 +75,8 @@ export const COMMANDS: Record<keyof typeof COMMAND_CATEGORIES, CommandDefinition
|
||||
{ id: 'delete-line', name: 'Delete line' },
|
||||
{ id: 'delete-to-start-of-line', name: 'Delete to start of line' },
|
||||
{ id: 'delete-to-end-of-line', name: 'Delete to end of line' },
|
||||
{ id: 'delete-previous-word', name: 'Delete previous word' },
|
||||
{ id: 'delete-next-word', name: 'Delete next word' },
|
||||
{ id: 'join-lines', name: 'Join lines' },
|
||||
{ id: 'duplicate-line', name: 'Duplicate line' },
|
||||
{ id: 'copy-line-up', name: 'Copy line up' },
|
||||
@@ -164,6 +166,13 @@ export const DEFAULT_SETTINGS: BindThemSettings = {
|
||||
export class BindThemSettingTab extends PluginSettingTab {
|
||||
plugin: BindThemPlugin;
|
||||
|
||||
/**
|
||||
* Refresh functions for each rendered category body. Bulk actions call
|
||||
* these directly instead of re-running `display()`, so toggling a
|
||||
* setting never collapses categories the user has open.
|
||||
*/
|
||||
private categoryRefreshers: Array<() => void> = [];
|
||||
|
||||
constructor(app: App, plugin: BindThemPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
@@ -172,6 +181,7 @@ export class BindThemSettingTab extends PluginSettingTab {
|
||||
display(): void {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
this.categoryRefreshers = [];
|
||||
|
||||
// Hotkeys link at the top
|
||||
containerEl.createEl('a', {
|
||||
@@ -184,14 +194,10 @@ export class BindThemSettingTab extends PluginSettingTab {
|
||||
}, (el) => {
|
||||
el.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const hotkeysTab = (this.app as unknown as { setting: { openTabById: (id: string) => unknown } }).setting.openTabById('hotkeys');
|
||||
if (hotkeysTab) {
|
||||
(hotkeysTab as unknown as { searchComponent: { setValue: (v: string) => void } }).searchComponent.setValue('BindThem');
|
||||
}
|
||||
this.openHotkeysSearch();
|
||||
});
|
||||
});
|
||||
|
||||
// General settings
|
||||
new Setting(containerEl)
|
||||
.setName('Debug mode')
|
||||
.setDesc('Enable debug logging to console')
|
||||
@@ -202,36 +208,16 @@ export class BindThemSettingTab extends PluginSettingTab {
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Sentence regex')
|
||||
.setDesc('Regular expression used to match sentences')
|
||||
.addText(text => text
|
||||
.setValue(this.plugin.settings.sentenceRegexSource)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.sentenceRegexSource = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Reset sentence regex')
|
||||
.addButton(button => button
|
||||
.setButtonText('Reset')
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.sentenceRegexSource = DEFAULT_SENTENCE_REGEX;
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
}));
|
||||
|
||||
// Commands section header
|
||||
new Setting(containerEl)
|
||||
.setName('Command availability')
|
||||
.setDesc('Toggle which commands are available in Obsidian. Disabled commands will not appear in the command palette.')
|
||||
.setDesc('Toggle which commands are available in Obsidian. Disabled commands will not appear in the command palette. Select a category below to see its commands.')
|
||||
.setHeading();
|
||||
|
||||
// Category toggle buttons
|
||||
// Global toggle-all buttons
|
||||
new Setting(containerEl)
|
||||
.setName('Enable/disable all')
|
||||
.setDesc('Toggle all commands on or off')
|
||||
.setDesc('Toggle every command in every category on or off')
|
||||
.addButton(button => button
|
||||
.setButtonText('Enable all')
|
||||
.onClick(async () => {
|
||||
@@ -239,7 +225,7 @@ export class BindThemSettingTab extends PluginSettingTab {
|
||||
this.plugin.settings.enabledCommands[cmdId] = true;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
this.refreshAllCategories();
|
||||
}))
|
||||
.addButton(button => button
|
||||
.setButtonText('Disable all')
|
||||
@@ -249,12 +235,13 @@ export class BindThemSettingTab extends PluginSettingTab {
|
||||
this.plugin.settings.enabledCommands[cmdId] = false;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
this.refreshAllCategories();
|
||||
}));
|
||||
|
||||
// Render each category
|
||||
// Render each category as a collapsible, visually grouped card
|
||||
const categoryListEl = containerEl.createDiv({ cls: 'bindthem-category-list' });
|
||||
for (const [categoryKey, categoryName] of Object.entries(COMMAND_CATEGORIES)) {
|
||||
this.renderCategory(containerEl, categoryKey, categoryName);
|
||||
this.renderCategory(categoryListEl, categoryKey, categoryName);
|
||||
}
|
||||
|
||||
// About section
|
||||
@@ -265,35 +252,78 @@ export class BindThemSettingTab extends PluginSettingTab {
|
||||
.setHeading();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Hotkeys settings tab and pre-fills its search with "BindThem".
|
||||
* `app.setting` (the settings modal controller) isn't part of Obsidian's
|
||||
* public API types, so the shape is narrowed once here rather than cast
|
||||
* inline at each property access.
|
||||
*/
|
||||
private openHotkeysSearch(): void {
|
||||
const appWithSettingModal = this.app as unknown as {
|
||||
setting: {
|
||||
openTabById: (id: string) => { searchComponent: { setValue: (v: string) => void } } | null;
|
||||
};
|
||||
};
|
||||
const hotkeysTab = appWithSettingModal.setting.openTabById('hotkeys');
|
||||
if (hotkeysTab) {
|
||||
hotkeysTab.searchComponent.setValue('BindThem');
|
||||
}
|
||||
}
|
||||
|
||||
private refreshAllCategories(): void {
|
||||
for (const refresh of this.categoryRefreshers) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private renderCategory(containerEl: HTMLElement, categoryKey: string, categoryName: string): void {
|
||||
const commands = COMMANDS[categoryKey as keyof typeof COMMANDS];
|
||||
if (!commands || commands.length === 0) return;
|
||||
|
||||
// Category header with toggle all
|
||||
const categorySetting = new Setting(containerEl)
|
||||
.setName(categoryName)
|
||||
.setHeading();
|
||||
const details = containerEl.createEl('details', { cls: 'bindthem-category' });
|
||||
const summary = details.createEl('summary', { cls: 'bindthem-category-summary' });
|
||||
summary.createSpan({ text: categoryName, cls: 'bindthem-category-name' });
|
||||
const badge = summary.createSpan({ cls: 'bindthem-category-count' });
|
||||
|
||||
// Check if all commands in this category are enabled
|
||||
const allEnabled = commands.every(cmd => this.plugin.settings.enabledCommands[cmd.id] !== false);
|
||||
const content = details.createDiv({ cls: 'bindthem-category-content' });
|
||||
|
||||
// Add toggle all button for this category
|
||||
categorySetting.addToggle(toggle => {
|
||||
toggle
|
||||
.setValue(allEnabled)
|
||||
const refresh = () => this.renderCategoryBody(content, badge, categoryKey, commands);
|
||||
refresh();
|
||||
this.categoryRefreshers.push(refresh);
|
||||
}
|
||||
|
||||
private renderCategoryBody(
|
||||
content: HTMLElement,
|
||||
badge: HTMLElement,
|
||||
categoryKey: string,
|
||||
commands: CommandDefinition[]
|
||||
): void {
|
||||
content.empty();
|
||||
|
||||
const enabledCount = commands.filter(cmd => this.plugin.settings.enabledCommands[cmd.id] !== false).length;
|
||||
badge.setText(`${enabledCount}/${commands.length} enabled`);
|
||||
|
||||
// Sentence regex configures the Sentence Navigator commands, so it
|
||||
// lives inside that category's card instead of the general section.
|
||||
if (categoryKey === 'sentenceNavigator') {
|
||||
this.renderSentenceRegexSetting(content);
|
||||
}
|
||||
|
||||
new Setting(content)
|
||||
.setName('Enable all in this category')
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(enabledCount === commands.length)
|
||||
.setTooltip('Toggle all commands in this category')
|
||||
.onChange(async (value) => {
|
||||
for (const cmd of commands) {
|
||||
this.plugin.settings.enabledCommands[cmd.id] = value;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
});
|
||||
});
|
||||
this.renderCategoryBody(content, badge, categoryKey, commands);
|
||||
}));
|
||||
|
||||
// Render individual commands
|
||||
for (const cmd of commands) {
|
||||
new Setting(containerEl)
|
||||
new Setting(content)
|
||||
.setName(cmd.name)
|
||||
.setDesc(cmd.description || `Command ID: ${cmd.id}`)
|
||||
.addToggle(toggle => toggle
|
||||
@@ -301,7 +331,40 @@ export class BindThemSettingTab extends PluginSettingTab {
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.enabledCommands[cmd.id] = value;
|
||||
await this.plugin.saveSettings();
|
||||
const newCount = commands.filter(c => this.plugin.settings.enabledCommands[c.id] !== false).length;
|
||||
badge.setText(`${newCount}/${commands.length} enabled`);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the sentence-matching regex setting and its reset button.
|
||||
* Updates the text field directly on reset instead of re-rendering.
|
||||
*/
|
||||
private renderSentenceRegexSetting(containerEl: HTMLElement): void {
|
||||
let textComponent: TextComponent | undefined;
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Sentence regex')
|
||||
.setDesc('Regular expression used to match sentences')
|
||||
.addText(text => {
|
||||
textComponent = text;
|
||||
text
|
||||
.setValue(this.plugin.settings.sentenceRegexSource)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.sentenceRegexSource = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Reset sentence regex')
|
||||
.addButton(button => button
|
||||
.setButtonText('Reset')
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.sentenceRegexSource = DEFAULT_SENTENCE_REGEX;
|
||||
await this.plugin.saveSettings();
|
||||
textComponent?.setValue(DEFAULT_SENTENCE_REGEX);
|
||||
}));
|
||||
}
|
||||
}
|
||||
+66
-2
@@ -3,6 +3,70 @@
|
||||
This CSS file will be included with your plugin, and
|
||||
available in the app when your plugin is enabled.
|
||||
|
||||
If your plugin does not need CSS, delete this file.
|
||||
|
||||
*/
|
||||
|
||||
/* ============================================================
|
||||
Settings tab — command category grouping
|
||||
============================================================ */
|
||||
|
||||
.bindthem-category-list {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.bindthem-category {
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
border-radius: var(--radius-m);
|
||||
margin-bottom: 0.5em;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bindthem-category > summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75em;
|
||||
padding: 0.65em 1em;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
background-color: var(--background-secondary);
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.bindthem-category > summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bindthem-category > summary::before {
|
||||
content: '▸';
|
||||
display: inline-block;
|
||||
margin-right: 0.5em;
|
||||
color: var(--text-muted);
|
||||
transition: transform 0.15s ease-in-out;
|
||||
}
|
||||
|
||||
.bindthem-category[open] > summary::before {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.bindthem-category-name {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.bindthem-category-count {
|
||||
font-weight: 400;
|
||||
font-size: var(--font-ui-smaller);
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bindthem-category-content {
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
.bindthem-category-content .setting-item {
|
||||
border-top: 1px solid var(--background-modifier-border);
|
||||
}
|
||||
|
||||
.bindthem-category-content .setting-item:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
{
|
||||
"1.0.0": "0.15.0"
|
||||
"1.0.0": "0.15.0",
|
||||
"1.1.0": "0.15.0",
|
||||
"1.2.0": "0.15.0"
|
||||
}
|
||||
Reference in new issue
Block a user