├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .npmrc ├── LICENSE.txt ├── README.md ├── esbuild.config.mjs ├── manifest.json ├── package-lock.json ├── package.json ├── src ├── chords │ ├── chord-manager.ts │ ├── chord-utils.ts │ ├── command-chord.ts │ ├── file-chord.ts │ ├── template-chord.ts │ └── text-chord.ts ├── main.ts ├── settings │ ├── settings-tab.ts │ └── settings.ts ├── suggesters │ ├── command-suggester.ts │ ├── file-suggester.ts │ └── suggest.ts └── utils │ └── string.extensions.ts ├── styles.css ├── tsconfig.json ├── version-bump.mjs └── versions.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = tab 9 | indent_size = 4 10 | tab_width = 4 11 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | npm node_modules 2 | build -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "env": { "node": true }, 5 | "plugins": [ 6 | "@typescript-eslint" 7 | ], 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-unused-vars": "off", 18 | "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], 19 | "@typescript-eslint/ban-ts-comment": "off", 20 | "no-prototype-builtins": "off", 21 | "@typescript-eslint/no-empty-function": "off" 22 | } 23 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | .vscode 3 | 4 | # Intellij 5 | *.iml 6 | .idea 7 | 8 | # npm 9 | node_modules 10 | 11 | # Don't include the compiled main.js file in the repo. 12 | # They should be uploaded to GitHub releases instead. 13 | main.js 14 | 15 | # Exclude sourcemaps 16 | *.map 17 | 18 | # obsidian 19 | data.json 20 | 21 | # Exclude macOS Finder (System Explorer) View States 22 | .DS_Store 23 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix="" -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Obsidian Chorded Hotkeys 2 | Use 🎵 chords 🎵 to trigger text insertion, template insertion, or command execution. 3 | A chord is a set of keys pressed at the same time, the order doesn't matter! 4 | 5 | ## Warning 6 | Chorded Hotkeys works through text replacement, it is advised that you create a backup of your vault before installing this plugin. 7 | 8 | ## Use Case 9 | The use of chorded hotkeys is that it lets you quickly and easily trigger an action without using modifier keys (ctrl, alt, shift, etc). Chords are fast to use because the order of key-presses doesn't matter, you just press a set of keys at the same time, and presto, you've triggered a chord. 10 | 11 | You might find this plugin helpful if there are specific commands you use often, templates you include frequently, or patterns of text you repeat. 12 | 13 | ## Creating Your First Chord 14 | 1. After installing, go to the Chored Hotkeys settings tab. 15 | 2. Click 'Add new chord' it will default to a 'Text' chord, which will be a simple text insertion. 16 | 3. The first field is the chord-trigger, the set of keys to execute the chord, these are the keys you'll have to press simultaneously to trigger the chord. So keep it short, Between two and four letters work best. For now, put 'hew' in the first box. 17 | 4. The second field is the value for the chord, it's treated differently depending on the chord type. For a text chord, it's the text to insert. Put 'Hello World'. 18 | 5. That's it! Your first chord is done. To try it out: close the settings, go to a file, and press the three letters 'hew' all at the same time. 19 | 20 | ## Chord Types 21 | The current chord types are: 22 | 1. **Text:** Inserts text. 23 | 2. **Command:** Runs a command. 24 | 3. **File:** Pastes the contents of a file. 25 | 4. **Template:** (Requires [Templater](https://github.com/SilentVoid13/Templater)) Pastes the contents of a template. Functionally equivalent to the file chord but also evaluates templates. 26 | 27 | *Remark*: Since the order of key-presses doesn't matter, the chord-triggers of 'hew', 'hwe', 'ehw', etc. are all considered duplicates. Each chord must have a unique trigger. 28 | 29 | ## Tags 30 | A tag is a special element added to a chord to augment it's effect. 31 | Currently there is only one tag, the cursor tag. Adding '{c}' in the value field of a text chord will move the cursor to that position upon activation. 32 | 33 | ## Demo 34 | https://user-images.githubusercontent.com/14039575/199102931-e87a107d-202f-42e9-8247-10f9b4d6f397.mp4 35 | 36 | ## Roadmap 37 | - Add the ability to have multiple chord dictionaries and switch between them. 38 | - Trigger chords from any context, not just editor. 39 | 40 | # Compare with similar plugins 41 | 42 | **Chorded hotkeys** 43 | 44 | - Use chords for text insertion, template insertion, or command execution. 45 | - Any set of keys can be used as a trigger, the triggering method is to press all the keys at once (like you're playing a musical chord). 46 | 47 | **Key sequence shortcut** 48 | 49 | - Limited to commands. 50 | - Type Ctrl-M to open a menu, then input your character sequence to trigger. 51 | 52 | **Sequence hotkeys**, **Hotkeys chords** 53 | 54 | - Limited to commands. 55 | - Sequence of hotkeys (event keys required) to trigger commands. -------------------------------------------------------------------------------- /esbuild.config.mjs: -------------------------------------------------------------------------------- 1 | import esbuild from "esbuild"; 2 | import process from "process"; 3 | import builtins from 'builtin-modules' 4 | 5 | const banner = 6 | `/* 7 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 8 | if you want to view the source, please visit the github repository of this plugin 9 | */ 10 | `; 11 | 12 | const prod = (process.argv[2] === 'production'); 13 | 14 | esbuild.build({ 15 | banner: { 16 | js: banner, 17 | }, 18 | entryPoints: ['src/main.ts'], 19 | bundle: true, 20 | external: [ 21 | 'obsidian', 22 | 'electron', 23 | '@codemirror/autocomplete', 24 | '@codemirror/collab', 25 | '@codemirror/commands', 26 | '@codemirror/language', 27 | '@codemirror/lint', 28 | '@codemirror/search', 29 | '@codemirror/state', 30 | '@codemirror/view', 31 | '@lezer/common', 32 | '@lezer/highlight', 33 | '@lezer/lr', 34 | ...builtins], 35 | format: 'cjs', 36 | watch: !prod, 37 | target: 'es2018', 38 | logLevel: "info", 39 | sourcemap: prod ? false : 'inline', 40 | treeShaking: true, 41 | outfile: 'main.js', 42 | }).catch(() => process.exit(1)); 43 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "obsidian-chorded-hotkeys", 3 | "name": "Chorded Hotkeys", 4 | "version": "1.1.0", 5 | "minAppVersion": "0.15.0", 6 | "description": "Type multiple letters at the same time to trigger text insertion, template insertion, or command execution.", 7 | "author": "Trey Connor Meyers", 8 | "authorUrl": "https://www.linkedin.com/in/tconnormeyers/", 9 | "isDesktopOnly": true 10 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-sample-plugin", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@codemirror/autocomplete": { 8 | "version": "6.3.0", 9 | "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.3.0.tgz", 10 | "integrity": "sha512-4jEvh3AjJZTDKazd10J6ZsCIqaYxDMCeua5ouQxY8hlFIml+nr7le0SgBhT3SIytFBmdzPK3AUhXGuW3T79nVg==", 11 | "requires": { 12 | "@codemirror/language": "^6.0.0", 13 | "@codemirror/state": "^6.0.0", 14 | "@codemirror/view": "^6.0.0", 15 | "@lezer/common": "^1.0.0" 16 | } 17 | }, 18 | "@codemirror/commands": { 19 | "version": "6.1.2", 20 | "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.1.2.tgz", 21 | "integrity": "sha512-sO3jdX1s0pam6lIdeSJLMN3DQ6mPEbM4yLvyKkdqtmd/UDwhXA5+AwFJ89rRXm6vTeOXBsE5cAmlos/t7MJdgg==", 22 | "requires": { 23 | "@codemirror/language": "^6.0.0", 24 | "@codemirror/state": "^6.0.0", 25 | "@codemirror/view": "^6.0.0", 26 | "@lezer/common": "^1.0.0" 27 | } 28 | }, 29 | "@codemirror/lang-css": { 30 | "version": "6.0.1", 31 | "resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.0.1.tgz", 32 | "integrity": "sha512-rlLq1Dt0WJl+2epLQeAsfqIsx3lGu4HStHCJu95nGGuz2P2fNugbU3dQYafr2VRjM4eMC9HviI6jvS98CNtG5w==", 33 | "requires": { 34 | "@codemirror/autocomplete": "^6.0.0", 35 | "@codemirror/language": "^6.0.0", 36 | "@codemirror/state": "^6.0.0", 37 | "@lezer/css": "^1.0.0" 38 | } 39 | }, 40 | "@codemirror/lang-html": { 41 | "version": "6.1.3", 42 | "resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.1.3.tgz", 43 | "integrity": "sha512-LmtIElopGK6bBfddAyjBitS6hz8nFr/PVUtvqmfomXlHB4m+Op2d5eGk/X9/CSby6Y8NqXXkGa3yDd9lfJ6Qlg==", 44 | "requires": { 45 | "@codemirror/autocomplete": "^6.0.0", 46 | "@codemirror/lang-css": "^6.0.0", 47 | "@codemirror/lang-javascript": "^6.0.0", 48 | "@codemirror/language": "^6.0.0", 49 | "@codemirror/state": "^6.0.0", 50 | "@codemirror/view": "^6.2.2", 51 | "@lezer/common": "^1.0.0", 52 | "@lezer/html": "^1.0.1" 53 | } 54 | }, 55 | "@codemirror/lang-javascript": { 56 | "version": "6.1.1", 57 | "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.1.1.tgz", 58 | "integrity": "sha512-F4+kiuC5d5dUSJmff96tJQwpEXs/tX/4bapMRnZWW6bHKK1Fx6MunTzopkCUWRa9bF87GPmb9m7Qtg7Yv8f3uQ==", 59 | "requires": { 60 | "@codemirror/autocomplete": "^6.0.0", 61 | "@codemirror/language": "^6.0.0", 62 | "@codemirror/lint": "^6.0.0", 63 | "@codemirror/state": "^6.0.0", 64 | "@codemirror/view": "^6.0.0", 65 | "@lezer/common": "^1.0.0", 66 | "@lezer/javascript": "^1.0.0" 67 | } 68 | }, 69 | "@codemirror/lang-markdown": { 70 | "version": "6.0.3", 71 | "resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.0.3.tgz", 72 | "integrity": "sha512-LFF5YlWHPV61udr3PEeiRAfn1TBfqVMakQi8NVSOKXco/GFzTtEqG5wTImY84Lie0sVrNZSwA0pNW8VQZDQq+A==", 73 | "requires": { 74 | "@codemirror/lang-html": "^6.0.0", 75 | "@codemirror/language": "^6.3.0", 76 | "@codemirror/state": "^6.0.0", 77 | "@codemirror/view": "^6.0.0", 78 | "@lezer/common": "^1.0.0", 79 | "@lezer/markdown": "^1.0.0" 80 | }, 81 | "dependencies": { 82 | "@codemirror/language": { 83 | "version": "6.3.0", 84 | "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.3.0.tgz", 85 | "integrity": "sha512-6jOE5DEt6sKD46SXhn3xPbBehn+l48ACcA6Uxs2k+E2YNH9XGF5WdGMTYr2DlggfK4h0QZBK6zEb5S7lkTriWA==", 86 | "requires": { 87 | "@codemirror/state": "^6.0.0", 88 | "@codemirror/view": "^6.0.0", 89 | "@lezer/common": "^1.0.0", 90 | "@lezer/highlight": "^1.0.0", 91 | "@lezer/lr": "^1.0.0", 92 | "style-mod": "^4.0.0" 93 | } 94 | } 95 | } 96 | }, 97 | "@codemirror/language": { 98 | "version": "git+https://github.com/lishid/cm-language.git#073afd8e6bc4d8e5cf6170a50f9b668a98c39f1c", 99 | "from": "git+https://github.com/lishid/cm-language.git", 100 | "requires": { 101 | "@codemirror/state": "^6.0.0", 102 | "@codemirror/view": "^6.0.0", 103 | "@lezer/common": "^1.0.0", 104 | "@lezer/highlight": "^1.0.0", 105 | "@lezer/lr": "^1.0.0", 106 | "style-mod": "^4.0.0" 107 | } 108 | }, 109 | "@codemirror/lint": { 110 | "version": "6.0.0", 111 | "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.0.0.tgz", 112 | "integrity": "sha512-nUUXcJW1Xp54kNs+a1ToPLK8MadO0rMTnJB8Zk4Z8gBdrN0kqV7uvUraU/T2yqg+grDNR38Vmy/MrhQN/RgwiA==", 113 | "requires": { 114 | "@codemirror/state": "^6.0.0", 115 | "@codemirror/view": "^6.0.0", 116 | "crelt": "^1.0.5" 117 | } 118 | }, 119 | "@codemirror/search": { 120 | "version": "6.2.2", 121 | "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.2.2.tgz", 122 | "integrity": "sha512-2pWY599zXk+lSoJ2iv9EuTO4gB7lhgBPLPwFb/zTbimFH4NmZSaKzJSV51okjABZ7/Rj0DYy5klWbIgaJh2LoQ==", 123 | "requires": { 124 | "@codemirror/state": "^6.0.0", 125 | "@codemirror/view": "^6.0.0", 126 | "crelt": "^1.0.5" 127 | } 128 | }, 129 | "@codemirror/state": { 130 | "version": "6.1.2", 131 | "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.1.2.tgz", 132 | "integrity": "sha512-Mxff85Hp5va+zuj+H748KbubXjrinX/k28lj43H14T2D0+4kuvEFIEIO7hCEcvBT8ubZyIelt9yGOjj2MWOEQA==" 133 | }, 134 | "@codemirror/view": { 135 | "version": "6.4.0", 136 | "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.4.0.tgz", 137 | "integrity": "sha512-Kv32b6Tn7QVwFbj/EDswTLSocjk5kgggF6zzBFAL4o4hZ/vmtFD155+EjH1pVlbfoDyVC2M6SedPsMrwYscgNg==", 138 | "requires": { 139 | "@codemirror/state": "^6.0.0", 140 | "style-mod": "^4.0.0", 141 | "w3c-keyname": "^2.2.4" 142 | } 143 | }, 144 | "@lezer/common": { 145 | "version": "1.0.1", 146 | "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.1.tgz", 147 | "integrity": "sha512-8TR5++Q/F//tpDsLd5zkrvEX5xxeemafEaek7mUp7Y+bI8cKQXdSqhzTOBaOogETcMOVr0pT3BBPXp13477ciw==" 148 | }, 149 | "@lezer/css": { 150 | "version": "1.0.1", 151 | "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.0.1.tgz", 152 | "integrity": "sha512-kLGsbzXdp1ntzO2jDwFf+2w76EBlLiD4FKofx7tgkdqeFRoslFiMS2qqbNtAauXw8ihZ4cE5YpxSpfsKXSs5Sg==", 153 | "requires": { 154 | "@lezer/highlight": "^1.0.0", 155 | "@lezer/lr": "^1.0.0" 156 | } 157 | }, 158 | "@lezer/highlight": { 159 | "version": "1.1.2", 160 | "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.1.2.tgz", 161 | "integrity": "sha512-CAun1WR1glxG9ZdOokTZwXbcwB7PXkIEyZRUMFBVwSrhTcogWq634/ByNImrkUnQhjju6xsIaOBIxvcRJtplXQ==", 162 | "requires": { 163 | "@lezer/common": "^1.0.0" 164 | } 165 | }, 166 | "@lezer/html": { 167 | "version": "1.0.1", 168 | "resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.0.1.tgz", 169 | "integrity": "sha512-sC00zEt3GBh3vVO6QaGX4YZCl41S9dHWN/WGBsDixy9G+sqOC7gsa4cxA/fmRVAiBvhqYkJk+5Ul4oul92CPVw==", 170 | "requires": { 171 | "@lezer/common": "^1.0.0", 172 | "@lezer/highlight": "^1.0.0", 173 | "@lezer/lr": "^1.0.0" 174 | } 175 | }, 176 | "@lezer/javascript": { 177 | "version": "1.0.2", 178 | "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.0.2.tgz", 179 | "integrity": "sha512-IjOVeIRhM8IuafWNnk+UzRz7p4/JSOKBNINLYLsdSGuJS9Ju7vFdc82AlTt0jgtV5D8eBZf4g0vK4d3ttBNz7A==", 180 | "requires": { 181 | "@lezer/highlight": "^1.0.0", 182 | "@lezer/lr": "^1.0.0" 183 | } 184 | }, 185 | "@lezer/lr": { 186 | "version": "1.2.3", 187 | "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.2.3.tgz", 188 | "integrity": "sha512-qpB7rBzH8f6Mzjv2AVZRahcm+2Cf7nbIH++uXbvVOL1yIRvVWQ3HAM/saeBLCyz/togB7LGo76qdJYL1uKQlqA==", 189 | "requires": { 190 | "@lezer/common": "^1.0.0" 191 | } 192 | }, 193 | "@lezer/markdown": { 194 | "version": "1.0.2", 195 | "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.0.2.tgz", 196 | "integrity": "sha512-8CY0OoZ6V5EzPjSPeJ4KLVbtXdLBd8V6sRCooN5kHnO28ytreEGTyrtU/zUwo/XLRzGr/e1g44KlzKi3yWGB5A==", 197 | "requires": { 198 | "@lezer/common": "^1.0.0", 199 | "@lezer/highlight": "^1.0.0" 200 | } 201 | }, 202 | "@nodelib/fs.scandir": { 203 | "version": "2.1.5", 204 | "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", 205 | "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", 206 | "dev": true, 207 | "requires": { 208 | "@nodelib/fs.stat": "2.0.5", 209 | "run-parallel": "^1.1.9" 210 | } 211 | }, 212 | "@nodelib/fs.stat": { 213 | "version": "2.0.5", 214 | "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", 215 | "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", 216 | "dev": true 217 | }, 218 | "@nodelib/fs.walk": { 219 | "version": "1.2.8", 220 | "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", 221 | "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", 222 | "dev": true, 223 | "requires": { 224 | "@nodelib/fs.scandir": "2.1.5", 225 | "fastq": "^1.6.0" 226 | } 227 | }, 228 | "@popperjs/core": { 229 | "version": "2.11.6", 230 | "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", 231 | "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==" 232 | }, 233 | "@types/codemirror": { 234 | "version": "0.0.108", 235 | "resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-0.0.108.tgz", 236 | "integrity": "sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==", 237 | "dev": true, 238 | "requires": { 239 | "@types/tern": "*" 240 | } 241 | }, 242 | "@types/estree": { 243 | "version": "1.0.0", 244 | "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", 245 | "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", 246 | "dev": true 247 | }, 248 | "@types/json-schema": { 249 | "version": "7.0.11", 250 | "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", 251 | "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", 252 | "dev": true 253 | }, 254 | "@types/node": { 255 | "version": "16.18.2", 256 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.2.tgz", 257 | "integrity": "sha512-KIGQJyya+opDCFvDSZMNNS899ov5jlNdtN7PypgHWeb8e+5vWISdwTRo/ClsNVlmDihzOGqFyNBDamUs7TQQCA==", 258 | "dev": true 259 | }, 260 | "@types/tern": { 261 | "version": "0.23.4", 262 | "resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.4.tgz", 263 | "integrity": "sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==", 264 | "dev": true, 265 | "requires": { 266 | "@types/estree": "*" 267 | } 268 | }, 269 | "@typescript-eslint/eslint-plugin": { 270 | "version": "5.29.0", 271 | "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.29.0.tgz", 272 | "integrity": "sha512-kgTsISt9pM53yRFQmLZ4npj99yGl3x3Pl7z4eA66OuTzAGC4bQB5H5fuLwPnqTKU3yyrrg4MIhjF17UYnL4c0w==", 273 | "dev": true, 274 | "requires": { 275 | "@typescript-eslint/scope-manager": "5.29.0", 276 | "@typescript-eslint/type-utils": "5.29.0", 277 | "@typescript-eslint/utils": "5.29.0", 278 | "debug": "^4.3.4", 279 | "functional-red-black-tree": "^1.0.1", 280 | "ignore": "^5.2.0", 281 | "regexpp": "^3.2.0", 282 | "semver": "^7.3.7", 283 | "tsutils": "^3.21.0" 284 | } 285 | }, 286 | "@typescript-eslint/parser": { 287 | "version": "5.29.0", 288 | "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.29.0.tgz", 289 | "integrity": "sha512-ruKWTv+x0OOxbzIw9nW5oWlUopvP/IQDjB5ZqmTglLIoDTctLlAJpAQFpNPJP/ZI7hTT9sARBosEfaKbcFuECw==", 290 | "dev": true, 291 | "requires": { 292 | "@typescript-eslint/scope-manager": "5.29.0", 293 | "@typescript-eslint/types": "5.29.0", 294 | "@typescript-eslint/typescript-estree": "5.29.0", 295 | "debug": "^4.3.4" 296 | } 297 | }, 298 | "@typescript-eslint/scope-manager": { 299 | "version": "5.29.0", 300 | "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.29.0.tgz", 301 | "integrity": "sha512-etbXUT0FygFi2ihcxDZjz21LtC+Eps9V2xVx09zFoN44RRHPrkMflidGMI+2dUs821zR1tDS6Oc9IXxIjOUZwA==", 302 | "dev": true, 303 | "requires": { 304 | "@typescript-eslint/types": "5.29.0", 305 | "@typescript-eslint/visitor-keys": "5.29.0" 306 | } 307 | }, 308 | "@typescript-eslint/type-utils": { 309 | "version": "5.29.0", 310 | "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.29.0.tgz", 311 | "integrity": "sha512-JK6bAaaiJozbox3K220VRfCzLa9n0ib/J+FHIwnaV3Enw/TO267qe0pM1b1QrrEuy6xun374XEAsRlA86JJnyg==", 312 | "dev": true, 313 | "requires": { 314 | "@typescript-eslint/utils": "5.29.0", 315 | "debug": "^4.3.4", 316 | "tsutils": "^3.21.0" 317 | } 318 | }, 319 | "@typescript-eslint/types": { 320 | "version": "5.29.0", 321 | "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.29.0.tgz", 322 | "integrity": "sha512-X99VbqvAXOMdVyfFmksMy3u8p8yoRGITgU1joBJPzeYa0rhdf5ok9S56/itRoUSh99fiDoMtarSIJXo7H/SnOg==", 323 | "dev": true 324 | }, 325 | "@typescript-eslint/typescript-estree": { 326 | "version": "5.29.0", 327 | "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.29.0.tgz", 328 | "integrity": "sha512-mQvSUJ/JjGBdvo+1LwC+GY2XmSYjK1nAaVw2emp/E61wEVYEyibRHCqm1I1vEKbXCpUKuW4G7u9ZCaZhJbLoNQ==", 329 | "dev": true, 330 | "requires": { 331 | "@typescript-eslint/types": "5.29.0", 332 | "@typescript-eslint/visitor-keys": "5.29.0", 333 | "debug": "^4.3.4", 334 | "globby": "^11.1.0", 335 | "is-glob": "^4.0.3", 336 | "semver": "^7.3.7", 337 | "tsutils": "^3.21.0" 338 | } 339 | }, 340 | "@typescript-eslint/utils": { 341 | "version": "5.29.0", 342 | "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.29.0.tgz", 343 | "integrity": "sha512-3Eos6uP1nyLOBayc/VUdKZikV90HahXE5Dx9L5YlSd/7ylQPXhLk1BYb29SDgnBnTp+jmSZUU0QxUiyHgW4p7A==", 344 | "dev": true, 345 | "requires": { 346 | "@types/json-schema": "^7.0.9", 347 | "@typescript-eslint/scope-manager": "5.29.0", 348 | "@typescript-eslint/types": "5.29.0", 349 | "@typescript-eslint/typescript-estree": "5.29.0", 350 | "eslint-scope": "^5.1.1", 351 | "eslint-utils": "^3.0.0" 352 | } 353 | }, 354 | "@typescript-eslint/visitor-keys": { 355 | "version": "5.29.0", 356 | "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.29.0.tgz", 357 | "integrity": "sha512-Hpb/mCWsjILvikMQoZIE3voc9wtQcS0A9FUw3h8bhr9UxBdtI/tw1ZDZUOXHXLOVMedKCH5NxyzATwnU78bWCQ==", 358 | "dev": true, 359 | "requires": { 360 | "@typescript-eslint/types": "5.29.0", 361 | "eslint-visitor-keys": "^3.3.0" 362 | } 363 | }, 364 | "array-union": { 365 | "version": "2.1.0", 366 | "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", 367 | "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", 368 | "dev": true 369 | }, 370 | "braces": { 371 | "version": "3.0.2", 372 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 373 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 374 | "dev": true, 375 | "requires": { 376 | "fill-range": "^7.0.1" 377 | } 378 | }, 379 | "builtin-modules": { 380 | "version": "3.3.0", 381 | "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", 382 | "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", 383 | "dev": true 384 | }, 385 | "codemirror": { 386 | "version": "6.0.1", 387 | "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz", 388 | "integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==", 389 | "requires": { 390 | "@codemirror/autocomplete": "^6.0.0", 391 | "@codemirror/commands": "^6.0.0", 392 | "@codemirror/language": "^6.0.0", 393 | "@codemirror/lint": "^6.0.0", 394 | "@codemirror/search": "^6.0.0", 395 | "@codemirror/state": "^6.0.0", 396 | "@codemirror/view": "^6.0.0" 397 | } 398 | }, 399 | "crelt": { 400 | "version": "1.0.5", 401 | "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.5.tgz", 402 | "integrity": "sha512-+BO9wPPi+DWTDcNYhr/W90myha8ptzftZT+LwcmUbbok0rcP/fequmFYCw8NMoH7pkAZQzU78b3kYrlua5a9eA==" 403 | }, 404 | "debug": { 405 | "version": "4.3.4", 406 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 407 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 408 | "dev": true, 409 | "requires": { 410 | "ms": "2.1.2" 411 | } 412 | }, 413 | "dir-glob": { 414 | "version": "3.0.1", 415 | "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", 416 | "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", 417 | "dev": true, 418 | "requires": { 419 | "path-type": "^4.0.0" 420 | } 421 | }, 422 | "esbuild": { 423 | "version": "0.14.47", 424 | "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.47.tgz", 425 | "integrity": "sha512-wI4ZiIfFxpkuxB8ju4MHrGwGLyp1+awEHAHVpx6w7a+1pmYIq8T9FGEVVwFo0iFierDoMj++Xq69GXWYn2EiwA==", 426 | "dev": true, 427 | "requires": { 428 | "esbuild-android-64": "0.14.47", 429 | "esbuild-android-arm64": "0.14.47", 430 | "esbuild-darwin-64": "0.14.47", 431 | "esbuild-darwin-arm64": "0.14.47", 432 | "esbuild-freebsd-64": "0.14.47", 433 | "esbuild-freebsd-arm64": "0.14.47", 434 | "esbuild-linux-32": "0.14.47", 435 | "esbuild-linux-64": "0.14.47", 436 | "esbuild-linux-arm": "0.14.47", 437 | "esbuild-linux-arm64": "0.14.47", 438 | "esbuild-linux-mips64le": "0.14.47", 439 | "esbuild-linux-ppc64le": "0.14.47", 440 | "esbuild-linux-riscv64": "0.14.47", 441 | "esbuild-linux-s390x": "0.14.47", 442 | "esbuild-netbsd-64": "0.14.47", 443 | "esbuild-openbsd-64": "0.14.47", 444 | "esbuild-sunos-64": "0.14.47", 445 | "esbuild-windows-32": "0.14.47", 446 | "esbuild-windows-64": "0.14.47", 447 | "esbuild-windows-arm64": "0.14.47" 448 | } 449 | }, 450 | "esbuild-android-64": { 451 | "version": "0.14.47", 452 | "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.47.tgz", 453 | "integrity": "sha512-R13Bd9+tqLVFndncMHssZrPWe6/0Kpv2/dt4aA69soX4PRxlzsVpCvoJeFE8sOEoeVEiBkI0myjlkDodXlHa0g==", 454 | "dev": true, 455 | "optional": true 456 | }, 457 | "esbuild-android-arm64": { 458 | "version": "0.14.47", 459 | "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.47.tgz", 460 | "integrity": "sha512-OkwOjj7ts4lBp/TL6hdd8HftIzOy/pdtbrNA4+0oVWgGG64HrdVzAF5gxtJufAPOsEjkyh1oIYvKAUinKKQRSQ==", 461 | "dev": true, 462 | "optional": true 463 | }, 464 | "esbuild-darwin-64": { 465 | "version": "0.14.47", 466 | "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.47.tgz", 467 | "integrity": "sha512-R6oaW0y5/u6Eccti/TS6c/2c1xYTb1izwK3gajJwi4vIfNs1s8B1dQzI1UiC9T61YovOQVuePDcfqHLT3mUZJA==", 468 | "dev": true, 469 | "optional": true 470 | }, 471 | "esbuild-darwin-arm64": { 472 | "version": "0.14.47", 473 | "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.47.tgz", 474 | "integrity": "sha512-seCmearlQyvdvM/noz1L9+qblC5vcBrhUaOoLEDDoLInF/VQ9IkobGiLlyTPYP5dW1YD4LXhtBgOyevoIHGGnw==", 475 | "dev": true, 476 | "optional": true 477 | }, 478 | "esbuild-freebsd-64": { 479 | "version": "0.14.47", 480 | "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.47.tgz", 481 | "integrity": "sha512-ZH8K2Q8/Ux5kXXvQMDsJcxvkIwut69KVrYQhza/ptkW50DC089bCVrJZZ3sKzIoOx+YPTrmsZvqeZERjyYrlvQ==", 482 | "dev": true, 483 | "optional": true 484 | }, 485 | "esbuild-freebsd-arm64": { 486 | "version": "0.14.47", 487 | "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.47.tgz", 488 | "integrity": "sha512-ZJMQAJQsIOhn3XTm7MPQfCzEu5b9STNC+s90zMWe2afy9EwnHV7Ov7ohEMv2lyWlc2pjqLW8QJnz2r0KZmeAEQ==", 489 | "dev": true, 490 | "optional": true 491 | }, 492 | "esbuild-linux-32": { 493 | "version": "0.14.47", 494 | "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.47.tgz", 495 | "integrity": "sha512-FxZOCKoEDPRYvq300lsWCTv1kcHgiiZfNrPtEhFAiqD7QZaXrad8LxyJ8fXGcWzIFzRiYZVtB3ttvITBvAFhKw==", 496 | "dev": true, 497 | "optional": true 498 | }, 499 | "esbuild-linux-64": { 500 | "version": "0.14.47", 501 | "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.47.tgz", 502 | "integrity": "sha512-nFNOk9vWVfvWYF9YNYksZptgQAdstnDCMtR6m42l5Wfugbzu11VpMCY9XrD4yFxvPo9zmzcoUL/88y0lfJZJJw==", 503 | "dev": true, 504 | "optional": true 505 | }, 506 | "esbuild-linux-arm": { 507 | "version": "0.14.47", 508 | "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.47.tgz", 509 | "integrity": "sha512-ZGE1Bqg/gPRXrBpgpvH81tQHpiaGxa8c9Rx/XOylkIl2ypLuOcawXEAo8ls+5DFCcRGt/o3sV+PzpAFZobOsmA==", 510 | "dev": true, 511 | "optional": true 512 | }, 513 | "esbuild-linux-arm64": { 514 | "version": "0.14.47", 515 | "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.47.tgz", 516 | "integrity": "sha512-ywfme6HVrhWcevzmsufjd4iT3PxTfCX9HOdxA7Hd+/ZM23Y9nXeb+vG6AyA6jgq/JovkcqRHcL9XwRNpWG6XRw==", 517 | "dev": true, 518 | "optional": true 519 | }, 520 | "esbuild-linux-mips64le": { 521 | "version": "0.14.47", 522 | "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.47.tgz", 523 | "integrity": "sha512-mg3D8YndZ1LvUiEdDYR3OsmeyAew4MA/dvaEJxvyygahWmpv1SlEEnhEZlhPokjsUMfRagzsEF/d/2XF+kTQGg==", 524 | "dev": true, 525 | "optional": true 526 | }, 527 | "esbuild-linux-ppc64le": { 528 | "version": "0.14.47", 529 | "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.47.tgz", 530 | "integrity": "sha512-WER+f3+szmnZiWoK6AsrTKGoJoErG2LlauSmk73LEZFQ/iWC+KhhDsOkn1xBUpzXWsxN9THmQFltLoaFEH8F8w==", 531 | "dev": true, 532 | "optional": true 533 | }, 534 | "esbuild-linux-riscv64": { 535 | "version": "0.14.47", 536 | "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.47.tgz", 537 | "integrity": "sha512-1fI6bP3A3rvI9BsaaXbMoaOjLE3lVkJtLxsgLHqlBhLlBVY7UqffWBvkrX/9zfPhhVMd9ZRFiaqXnB1T7BsL2g==", 538 | "dev": true, 539 | "optional": true 540 | }, 541 | "esbuild-linux-s390x": { 542 | "version": "0.14.47", 543 | "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.47.tgz", 544 | "integrity": "sha512-eZrWzy0xFAhki1CWRGnhsHVz7IlSKX6yT2tj2Eg8lhAwlRE5E96Hsb0M1mPSE1dHGpt1QVwwVivXIAacF/G6mw==", 545 | "dev": true, 546 | "optional": true 547 | }, 548 | "esbuild-netbsd-64": { 549 | "version": "0.14.47", 550 | "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.47.tgz", 551 | "integrity": "sha512-Qjdjr+KQQVH5Q2Q1r6HBYswFTToPpss3gqCiSw2Fpq/ua8+eXSQyAMG+UvULPqXceOwpnPo4smyZyHdlkcPppQ==", 552 | "dev": true, 553 | "optional": true 554 | }, 555 | "esbuild-openbsd-64": { 556 | "version": "0.14.47", 557 | "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.47.tgz", 558 | "integrity": "sha512-QpgN8ofL7B9z8g5zZqJE+eFvD1LehRlxr25PBkjyyasakm4599iroUpaj96rdqRlO2ShuyqwJdr+oNqWwTUmQw==", 559 | "dev": true, 560 | "optional": true 561 | }, 562 | "esbuild-sunos-64": { 563 | "version": "0.14.47", 564 | "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.47.tgz", 565 | "integrity": "sha512-uOeSgLUwukLioAJOiGYm3kNl+1wJjgJA8R671GYgcPgCx7QR73zfvYqXFFcIO93/nBdIbt5hd8RItqbbf3HtAQ==", 566 | "dev": true, 567 | "optional": true 568 | }, 569 | "esbuild-windows-32": { 570 | "version": "0.14.47", 571 | "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.47.tgz", 572 | "integrity": "sha512-H0fWsLTp2WBfKLBgwYT4OTfFly4Im/8B5f3ojDv1Kx//kiubVY0IQunP2Koc/fr/0wI7hj3IiBDbSrmKlrNgLQ==", 573 | "dev": true, 574 | "optional": true 575 | }, 576 | "esbuild-windows-64": { 577 | "version": "0.14.47", 578 | "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.47.tgz", 579 | "integrity": "sha512-/Pk5jIEH34T68r8PweKRi77W49KwanZ8X6lr3vDAtOlH5EumPE4pBHqkCUdELanvsT14yMXLQ/C/8XPi1pAtkQ==", 580 | "dev": true, 581 | "optional": true 582 | }, 583 | "esbuild-windows-arm64": { 584 | "version": "0.14.47", 585 | "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.47.tgz", 586 | "integrity": "sha512-HFSW2lnp62fl86/qPQlqw6asIwCnEsEoNIL1h2uVMgakddf+vUuMcCbtUY1i8sst7KkgHrVKCJQB33YhhOweCQ==", 587 | "dev": true, 588 | "optional": true 589 | }, 590 | "eslint-scope": { 591 | "version": "5.1.1", 592 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", 593 | "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", 594 | "dev": true, 595 | "requires": { 596 | "esrecurse": "^4.3.0", 597 | "estraverse": "^4.1.1" 598 | } 599 | }, 600 | "eslint-utils": { 601 | "version": "3.0.0", 602 | "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", 603 | "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", 604 | "dev": true, 605 | "requires": { 606 | "eslint-visitor-keys": "^2.0.0" 607 | }, 608 | "dependencies": { 609 | "eslint-visitor-keys": { 610 | "version": "2.1.0", 611 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", 612 | "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", 613 | "dev": true 614 | } 615 | } 616 | }, 617 | "eslint-visitor-keys": { 618 | "version": "3.3.0", 619 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", 620 | "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", 621 | "dev": true 622 | }, 623 | "esrecurse": { 624 | "version": "4.3.0", 625 | "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", 626 | "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", 627 | "dev": true, 628 | "requires": { 629 | "estraverse": "^5.2.0" 630 | }, 631 | "dependencies": { 632 | "estraverse": { 633 | "version": "5.3.0", 634 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", 635 | "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", 636 | "dev": true 637 | } 638 | } 639 | }, 640 | "estraverse": { 641 | "version": "4.3.0", 642 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", 643 | "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", 644 | "dev": true 645 | }, 646 | "fast-glob": { 647 | "version": "3.2.12", 648 | "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", 649 | "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", 650 | "dev": true, 651 | "requires": { 652 | "@nodelib/fs.stat": "^2.0.2", 653 | "@nodelib/fs.walk": "^1.2.3", 654 | "glob-parent": "^5.1.2", 655 | "merge2": "^1.3.0", 656 | "micromatch": "^4.0.4" 657 | } 658 | }, 659 | "fastq": { 660 | "version": "1.13.0", 661 | "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", 662 | "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", 663 | "dev": true, 664 | "requires": { 665 | "reusify": "^1.0.4" 666 | } 667 | }, 668 | "fill-range": { 669 | "version": "7.0.1", 670 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 671 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 672 | "dev": true, 673 | "requires": { 674 | "to-regex-range": "^5.0.1" 675 | } 676 | }, 677 | "functional-red-black-tree": { 678 | "version": "1.0.1", 679 | "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", 680 | "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", 681 | "dev": true 682 | }, 683 | "glob-parent": { 684 | "version": "5.1.2", 685 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 686 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 687 | "dev": true, 688 | "requires": { 689 | "is-glob": "^4.0.1" 690 | } 691 | }, 692 | "globby": { 693 | "version": "11.1.0", 694 | "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", 695 | "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", 696 | "dev": true, 697 | "requires": { 698 | "array-union": "^2.1.0", 699 | "dir-glob": "^3.0.1", 700 | "fast-glob": "^3.2.9", 701 | "ignore": "^5.2.0", 702 | "merge2": "^1.4.1", 703 | "slash": "^3.0.0" 704 | } 705 | }, 706 | "ignore": { 707 | "version": "5.2.0", 708 | "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", 709 | "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", 710 | "dev": true 711 | }, 712 | "is-extglob": { 713 | "version": "2.1.1", 714 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 715 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 716 | "dev": true 717 | }, 718 | "is-glob": { 719 | "version": "4.0.3", 720 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 721 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 722 | "dev": true, 723 | "requires": { 724 | "is-extglob": "^2.1.1" 725 | } 726 | }, 727 | "is-number": { 728 | "version": "7.0.0", 729 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 730 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 731 | "dev": true 732 | }, 733 | "lru-cache": { 734 | "version": "6.0.0", 735 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 736 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 737 | "dev": true, 738 | "requires": { 739 | "yallist": "^4.0.0" 740 | } 741 | }, 742 | "merge2": { 743 | "version": "1.4.1", 744 | "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", 745 | "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", 746 | "dev": true 747 | }, 748 | "micromatch": { 749 | "version": "4.0.5", 750 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", 751 | "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", 752 | "dev": true, 753 | "requires": { 754 | "braces": "^3.0.2", 755 | "picomatch": "^2.3.1" 756 | } 757 | }, 758 | "moment": { 759 | "version": "2.29.4", 760 | "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", 761 | "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", 762 | "dev": true 763 | }, 764 | "ms": { 765 | "version": "2.1.2", 766 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 767 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 768 | "dev": true 769 | }, 770 | "obsidian": { 771 | "version": "0.16.3", 772 | "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.16.3.tgz", 773 | "integrity": "sha512-hal9qk1A0GMhHSeLr2/+o3OpLmImiP+Y+sx2ewP13ds76KXsziG96n+IPFT0mSkup1zSwhEu+DeRhmbcyCCXWw==", 774 | "dev": true, 775 | "requires": { 776 | "@types/codemirror": "0.0.108", 777 | "moment": "2.29.4" 778 | } 779 | }, 780 | "path-type": { 781 | "version": "4.0.0", 782 | "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", 783 | "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", 784 | "dev": true 785 | }, 786 | "picomatch": { 787 | "version": "2.3.1", 788 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 789 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 790 | "dev": true 791 | }, 792 | "queue-microtask": { 793 | "version": "1.2.3", 794 | "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", 795 | "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", 796 | "dev": true 797 | }, 798 | "regexpp": { 799 | "version": "3.2.0", 800 | "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", 801 | "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", 802 | "dev": true 803 | }, 804 | "reusify": { 805 | "version": "1.0.4", 806 | "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", 807 | "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", 808 | "dev": true 809 | }, 810 | "run-parallel": { 811 | "version": "1.2.0", 812 | "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", 813 | "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", 814 | "dev": true, 815 | "requires": { 816 | "queue-microtask": "^1.2.2" 817 | } 818 | }, 819 | "semver": { 820 | "version": "7.3.8", 821 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", 822 | "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", 823 | "dev": true, 824 | "requires": { 825 | "lru-cache": "^6.0.0" 826 | } 827 | }, 828 | "slash": { 829 | "version": "3.0.0", 830 | "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", 831 | "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", 832 | "dev": true 833 | }, 834 | "style-mod": { 835 | "version": "4.0.0", 836 | "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.0.0.tgz", 837 | "integrity": "sha512-OPhtyEjyyN9x3nhPsu76f52yUGXiZcgvsrFVtvTkyGRQJ0XK+GPc6ov1z+lRpbeabka+MYEQxOYRnt5nF30aMw==" 838 | }, 839 | "to-regex-range": { 840 | "version": "5.0.1", 841 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 842 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 843 | "dev": true, 844 | "requires": { 845 | "is-number": "^7.0.0" 846 | } 847 | }, 848 | "tslib": { 849 | "version": "2.4.0", 850 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", 851 | "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", 852 | "dev": true 853 | }, 854 | "tsutils": { 855 | "version": "3.21.0", 856 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", 857 | "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", 858 | "dev": true, 859 | "requires": { 860 | "tslib": "^1.8.1" 861 | }, 862 | "dependencies": { 863 | "tslib": { 864 | "version": "1.14.1", 865 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", 866 | "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", 867 | "dev": true 868 | } 869 | } 870 | }, 871 | "typescript": { 872 | "version": "4.7.4", 873 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", 874 | "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", 875 | "dev": true 876 | }, 877 | "w3c-keyname": { 878 | "version": "2.2.6", 879 | "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.6.tgz", 880 | "integrity": "sha512-f+fciywl1SJEniZHD6H+kUO8gOnwIr7f4ijKA6+ZvJFjeGi1r4PDLl53Ayud9O/rk64RqgoQine0feoeOU0kXg==" 881 | }, 882 | "yallist": { 883 | "version": "4.0.0", 884 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 885 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", 886 | "dev": true 887 | } 888 | } 889 | } 890 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-chorded-hotkeys", 3 | "version": "1.1.0", 4 | "description": "Type multiple letters at the same time to trigger text insertion, template insertion, or command execution.", 5 | "main": "main.js", 6 | "scripts": { 7 | "dev": "node esbuild.config.mjs", 8 | "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", 9 | "version": "node version-bump.mjs && git add manifest.json versions.json" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "MIT", 14 | "devDependencies": { 15 | "@types/node": "^16.11.6", 16 | "@typescript-eslint/eslint-plugin": "5.29.0", 17 | "@typescript-eslint/parser": "5.29.0", 18 | "builtin-modules": "3.3.0", 19 | "esbuild": "0.14.47", 20 | "obsidian": "latest", 21 | "tslib": "2.4.0", 22 | "typescript": "4.7.4" 23 | }, 24 | "dependencies": { 25 | "codemirror": "^6.0.0", 26 | "@codemirror/commands": "^6.0.0", 27 | "@codemirror/lang-markdown": "^6.0.0", 28 | "@codemirror/language": "https://github.com/lishid/cm-language", 29 | "@codemirror/search": "^6.0.0", 30 | "@codemirror/state": "^6.0.0", 31 | "@codemirror/view": "^6.0.0", 32 | "@popperjs/core": "^2.11.2" 33 | } 34 | } -------------------------------------------------------------------------------- /src/chords/chord-manager.ts: -------------------------------------------------------------------------------- 1 | import { Editor, Notice, TFile } from "obsidian"; 2 | import "../utils/string.extensions"; 3 | import TextChord from "./text-chord"; 4 | import CommandChord from "./command-chord"; 5 | import ChordsPlugin from "src/main"; 6 | import TemplateChord from "./template-chord"; 7 | import FileChord from "./file-chord"; 8 | 9 | /** 10 | * Represents the different types of chords 11 | */ 12 | export enum ChordType { Text, Command, Template, File } 13 | 14 | /** 15 | * The format in which chords are saved as 16 | */ 17 | export type ChordData = { key: string, value: string, chordType: ChordType }; 18 | 19 | /** 20 | * A mapping of user input to chord indexes (index of saved chords array) 21 | */ 22 | type ChordDictionary = { [input: string]: number }; 23 | 24 | /** 25 | * Chord execution functions, should be a one-to-one mapping with ChordType 26 | */ 27 | const ChordFunctions = { 28 | [ChordType.Text]: TextChord, 29 | [ChordType.Command]: CommandChord, 30 | [ChordType.Template]: TemplateChord, 31 | [ChordType.File]: FileChord, 32 | } 33 | 34 | /** 35 | * Responsible for mapping user input to chords and updating the settings.chords 36 | * TODO: Split into two classes, one for managing settings.chords the other for managing the mapping 37 | */ 38 | export default class ChordManager { 39 | private readonly _plugin: ChordsPlugin; 40 | 41 | private _chordDict: ChordDictionary; 42 | 43 | public constructor(plugin: ChordsPlugin) { 44 | this._plugin = plugin; 45 | this._chordDict = {}; 46 | 47 | this._plugin.Settings.chords.forEach((_, index) => { 48 | this.enableChord(index); 49 | }); 50 | } 51 | 52 | /** 53 | * Attempts to execute a chord based on user input 54 | * @param input user input 55 | * @param editor current editor 56 | */ 57 | public handleChord(input: string, editor: Editor): void { 58 | const chord = this.getChord(input); 59 | 60 | if (chord) { 61 | ChordFunctions[chord.chordType](editor, chord.key, chord.value); 62 | 63 | if ((this._plugin.Settings.showTextChordExecuted && chord.chordType == ChordType.Text) || 64 | (this._plugin.Settings.showCommandChordExecuted && chord.chordType == ChordType.Command)) { 65 | new Notice(`${ChordType[chord.chordType]} Chord Executed: ${chord.key}`); 66 | } 67 | } 68 | } 69 | 70 | /** 71 | * Changes the key of a chord 72 | * @param index index of chord in settings.chords 73 | * @param newKey new key for the chord 74 | */ 75 | public async updateChordKey(index: number, newKey: string): Promise { 76 | this.disableChord(index); 77 | this._plugin.Settings.chords[index].key = newKey; 78 | this.enableChord(index); 79 | await this._plugin.saveSettings(); 80 | } 81 | 82 | /** 83 | * Changes the value of a chord 84 | * @param index index of chord in settings.chords 85 | * @param newValue new value for chord 86 | */ 87 | public async updateChordValue(index: number, newValue: string): Promise { 88 | this._plugin.Settings.chords[index].value = newValue; 89 | await this._plugin.saveSettings(); 90 | } 91 | 92 | /** 93 | * Changes the type of a chord 94 | * @param index index of chord in settings.chords 95 | * @param newChordType new ChordType for the chord 96 | */ 97 | public async updateChordType(index: number, newChordType: ChordType): Promise { 98 | this._plugin.Settings.chords[index].chordType = newChordType; 99 | await this._plugin.saveSettings(); 100 | } 101 | 102 | /** 103 | * Deletes a chord 104 | * @param index index of chord in settings.chords 105 | */ 106 | public async removeChord(index: number): Promise { 107 | this.disableChord(index); 108 | this._plugin.Settings.chords.splice(index, 1); 109 | await this._plugin.saveSettings(); 110 | } 111 | 112 | /** 113 | * Creates an empty text chord 114 | */ 115 | public async addBlankChord(): Promise { 116 | const newChord = { key: "", value: "", chordType: ChordType.Text }; 117 | const count = this._plugin.Settings.chords.push(newChord); 118 | this.enableChord(count - 1); 119 | await this._plugin.saveSettings(); 120 | } 121 | 122 | /** 123 | * Swaps the indexes (position in settings.chords) of two chords 124 | * Used to change display order 125 | * @param index1 index of first chord 126 | * @param index2 index of second chord 127 | */ 128 | public async swapIndex(index1: number, index2: number): Promise { 129 | const fromKey = this._plugin.Settings.chords[index1].key.sort(); 130 | const toKey = this._plugin.Settings.chords[index2].key.sort(); 131 | 132 | if (this._chordDict[fromKey as keyof ChordDictionary] == index1) { 133 | this._chordDict[fromKey as keyof ChordDictionary] = index2; 134 | } 135 | 136 | if (this._chordDict[toKey as keyof ChordDictionary] == index2) { 137 | this._chordDict[toKey as keyof ChordDictionary] = index1; 138 | } 139 | 140 | const element = this._plugin.Settings.chords[index1]; 141 | this._plugin.Settings.chords[index1] = this._plugin.Settings.chords[index2]; 142 | this._plugin.Settings.chords[index2] = element; 143 | 144 | await this._plugin.saveSettings(); 145 | } 146 | 147 | /** 148 | * Checks if a key is a duplicate (both duplicates will return true) 149 | * @param index index of chord in settings.chords 150 | * @return if there are more than one copy of the key 151 | */ 152 | public isDuplicateKey(index: number): boolean { 153 | const key = this._plugin.Settings.chords[index].key.sort(); 154 | return this._plugin.Settings.chords.findIndex((c, i) => c.key.sort() == key && i != index) >= 0; 155 | } 156 | 157 | public hasValidValue(index: number): boolean { 158 | var chord = this._plugin.Settings.chords[index]; 159 | switch (chord.chordType) { 160 | case ChordType.Command: 161 | return app.commands.listCommands().find(c => c.name == chord.value);; 162 | case ChordType.File: 163 | case ChordType.Template: 164 | return app.vault.getAbstractFileByPath(chord.value) instanceof TFile; 165 | case ChordType.Text: 166 | return true; 167 | } 168 | 169 | throw new Error("Unhandled chord type"); 170 | } 171 | 172 | /** 173 | * Enables a chord so it can be used 174 | * Required to set up hashing for keys to chords 175 | * @param index index of chord in settings.chords 176 | */ 177 | private enableChord(index: number): void { 178 | const newKey = this._plugin.Settings.chords[index].key.sort(); 179 | if (newKey in this._chordDict) { 180 | return; 181 | } 182 | 183 | this._chordDict[newKey] = index; 184 | } 185 | 186 | /** 187 | * Disables a chord so it can't be used 188 | * @param index index of chord in settings.chords 189 | */ 190 | private disableChord(index: number): void { 191 | const key = this._plugin.Settings.chords[index].key.sort(); 192 | 193 | if (this._chordDict[key as keyof ChordDictionary] == index) { 194 | delete this._chordDict[key as keyof ChordDictionary]; 195 | 196 | // If the chord being disabled had any duplicates, enable one of them since the slot is now available 197 | const duplicateKey = this._plugin.Settings.chords.findIndex((c, i) => c.key.sort() == key && i != index); 198 | if (duplicateKey >= 0) { 199 | this.enableChord(duplicateKey); 200 | } 201 | } 202 | } 203 | 204 | /** 205 | * Gets a chord from user input 206 | * @param key user input 207 | * @returns chord if found 208 | */ 209 | private getChord(key: string): ChordData | undefined { 210 | key = key.sort(); 211 | const chordIndex = this._chordDict[key as keyof ChordDictionary]; 212 | return this._plugin.Settings.chords[chordIndex]; 213 | } 214 | } -------------------------------------------------------------------------------- /src/chords/chord-utils.ts: -------------------------------------------------------------------------------- 1 | import { Editor } from "obsidian"; 2 | 3 | /** 4 | * Replaces user input prior to the cursor 5 | * @param editor editor for active file 6 | * @param key user input to replace 7 | * @param replacement text to replace key with 8 | */ 9 | export function replaceKeyInput(editor: Editor, key: String, replacement: string = ""): void { 10 | const cursor = editor.getCursor(); 11 | 12 | editor.replaceRange( 13 | replacement, 14 | { line: cursor.line, ch: cursor.ch - key.length }, 15 | { line: cursor.line, ch: cursor.ch } 16 | ); 17 | } -------------------------------------------------------------------------------- /src/chords/command-chord.ts: -------------------------------------------------------------------------------- 1 | import { Editor, Notice } from "obsidian"; 2 | import { replaceKeyInput } from "./chord-utils"; 3 | 4 | /** 5 | * Removes user input and executes a command 6 | * @param editor editor for active file 7 | * @param key user input to trigger the chord 8 | * @param value command name 9 | */ 10 | export default function execute(editor: Editor, key: string, value: string): void { 11 | replaceKeyInput(editor, key); 12 | 13 | //@ts-ignore 14 | const command = app.commands.listCommands().find(c => c.name == value); 15 | 16 | if (command) { 17 | //@ts-ignore 18 | app.commands.executeCommandById(command.id); 19 | } 20 | else { 21 | new Notice(`Command not found: ${value}`); 22 | } 23 | } -------------------------------------------------------------------------------- /src/chords/file-chord.ts: -------------------------------------------------------------------------------- 1 | import { Editor, Notice, TFile } from "obsidian"; 2 | import { replaceKeyInput } from "./chord-utils"; 3 | 4 | /** 5 | * Removes user input and pastes the content of a file 6 | * @param editor editor for active file 7 | * @param key user input to trigger the chord 8 | * @param path file path 9 | */ 10 | export default async function execute(editor: Editor, key: string, path: string): Promise { 11 | replaceKeyInput(editor, key); 12 | 13 | const file = app.vault.getAbstractFileByPath(path); 14 | if (file instanceof TFile) { 15 | const content = await app.vault.read(file); 16 | replaceKeyInput(editor, "", content); 17 | 18 | const cursor = editor.getCursor(); 19 | editor.setCursor({ 20 | line: cursor.line, 21 | ch: cursor.ch + content.length, 22 | }); 23 | } 24 | else { 25 | new Notice(`File not found for chord: ${path}`); 26 | } 27 | } -------------------------------------------------------------------------------- /src/chords/template-chord.ts: -------------------------------------------------------------------------------- 1 | import { Editor, Notice, TFile } from "obsidian"; 2 | import { replaceKeyInput } from "./chord-utils"; 3 | 4 | /** 5 | * Removes user input and pastes the content of a template file 6 | * @param editor editor for active file 7 | * @param key user input to trigger the chord 8 | * @param path template file path 9 | */ 10 | export default async function execute(editor: Editor, key: string, path: string): Promise { 11 | replaceKeyInput(editor, key); 12 | 13 | //@ts-ignore 14 | const templaterPlugin = app.plugins.plugins["templater-obsidian"]; 15 | 16 | if (templaterPlugin) { 17 | const file = app.vault.getAbstractFileByPath(path); 18 | if (file instanceof TFile) { 19 | var content = await app.vault.read(file); 20 | const activeFile = app.workspace.getActiveFile(); 21 | 22 | //@ts-ignore 23 | content = await templaterPlugin.templater.parse_template({ target_file: activeFile, run_mode: 4 }, content); 24 | 25 | if (templaterPlugin.settings.auto_jump_to_cursor) { 26 | var { new_content, positions } = templaterPlugin.editor_handler.cursor_jumper.replace_and_get_cursor_positions(content); 27 | } 28 | 29 | new_content = new_content ?? content; 30 | 31 | replaceKeyInput(editor, "", new_content); 32 | 33 | const cursor = editor.getCursor(); 34 | editor.setCursor({ 35 | line: cursor.line + (positions ? positions[0].line : 0), 36 | ch: (positions ? positions[0].ch : cursor.ch + new_content.length), 37 | }); 38 | } 39 | else { 40 | new Notice(`File not found for chord: ${path}`); 41 | } 42 | } 43 | else { 44 | new Notice("Templater plugin must be enabled for template chords"); 45 | } 46 | } -------------------------------------------------------------------------------- /src/chords/text-chord.ts: -------------------------------------------------------------------------------- 1 | import { Editor } from "obsidian"; 2 | import { replaceKeyInput } from "./chord-utils"; 3 | 4 | /** 5 | * Replaces the user input with the replacement text 6 | * @param editor editor for active file 7 | * @param key user input to trigger the chord 8 | * @param value file path 9 | */ 10 | export default function execute(editor: Editor, key: string, value: string): void { 11 | var text = value; 12 | var cursorOffset = value.length; 13 | 14 | [text, cursorOffset] = handleCursorTag(text, cursorOffset); 15 | 16 | // Handle backslash last since they can be used to prevent other features 17 | [text, cursorOffset] = handleEscapedBackslash(text, cursorOffset); 18 | 19 | const cursor = editor.getCursor(); 20 | 21 | replaceKeyInput(editor, key, text); 22 | 23 | editor.setCursor({ 24 | line: cursor.line, 25 | ch: cursor.ch + cursorOffset - key.length, 26 | }); 27 | } 28 | 29 | /** 30 | * Handles the cursor tag {c}, moves cursor to its position if present 31 | * @param text current replacement text 32 | * @param cursorOffset current cursor offset 33 | * @returns [updated text, new cursor offset] 34 | */ 35 | function handleCursorTag(text: string, cursorOffset: number): [string, number] { 36 | var ctag = text.search(/\{c\}/); 37 | if (ctag >= 0 && 38 | (ctag == 0 || text[ctag - 1] != "\\" || (ctag > 1 && text[ctag - 2] == "\\")) 39 | ) { 40 | cursorOffset += ctag - text.length; 41 | text = text.slice(0, ctag) + text.slice(ctag + 3); 42 | } 43 | 44 | return [text, cursorOffset]; 45 | } 46 | 47 | /** 48 | * Handles replacement tags like {s} for space 49 | * @param text current replacement text 50 | * @param replacements mapping of tags to their replacement value 51 | * @returns updated text 52 | */ 53 | function replaceTags(text: string, replacements: { [tag: string]: string }): string { 54 | for (const [tag, replace] of Object.entries(replacements)) { 55 | text = text.replace(tag, replace); 56 | } 57 | 58 | return text; 59 | } 60 | 61 | /** 62 | * Replace double backslashes with single backslashes and updates the cursor offset 63 | * @param text current replacement text 64 | * @param cursorOffset current cursor offset 65 | * @returns [updated text, new cursor offset] 66 | */ 67 | function handleEscapedBackslash(text: string, cursorOffset: number): [string, number] { 68 | const count = (text.match(/\\\\/g) || []).length; 69 | text = text.replace(/\\\\/g, "\\"); 70 | cursorOffset -= count; 71 | return [text, cursorOffset]; 72 | } -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { Plugin, Editor, MarkdownView, App, PluginManifest } from "obsidian"; 2 | import { ChordsPluginSettings, DEFAULT_SETTINGS } from "./settings/settings"; 3 | import ChordsSettingTab from "./settings/settings-tab"; 4 | import ChordManager from "./chords/chord-manager"; 5 | 6 | export default class ChordsPlugin extends Plugin { 7 | private _input: string; 8 | private _chordManager: ChordManager; 9 | private _timeoutId: NodeJS.Timeout; 10 | 11 | public Settings: ChordsPluginSettings; 12 | 13 | public readonly AppName: string; 14 | public readonly AppVersion: string; 15 | 16 | private constructor(app: App, manifest: PluginManifest) { 17 | super(app, manifest); 18 | 19 | this.AppName = manifest.name; 20 | this.AppVersion = manifest.version; 21 | 22 | this._input = ""; 23 | } 24 | 25 | public async onload(): Promise { 26 | await this.loadSettings(); 27 | 28 | this._chordManager = new ChordManager(this); 29 | 30 | this.addSettingTab(new ChordsSettingTab(this.app, this)); 31 | 32 | this.registerDomEvent(document, "keydown", this.onKeydown.bind(this)); 33 | } 34 | 35 | public getCurrentEditor(): Editor | null { 36 | return this.app.workspace.getActiveViewOfType(MarkdownView)?.editor ?? null; 37 | } 38 | 39 | public async saveSettings(): Promise { 40 | await this.saveData(this.Settings); 41 | } 42 | 43 | public get ChordManager(): ChordManager { 44 | return this._chordManager; 45 | } 46 | 47 | private async loadSettings(): Promise { 48 | this.Settings = Object.assign( 49 | {}, 50 | DEFAULT_SETTINGS, 51 | await this.loadData() 52 | ); 53 | } 54 | 55 | private onKeydown(event: KeyboardEvent): void { 56 | const editor = this.getCurrentEditor(); 57 | if (!editor || !editor.hasFocus()) return; 58 | 59 | // Ignore and reset input because a control key (ctrl, shift, win, etc) was used 60 | if (event.key.length > 1) { 61 | this._input = ""; 62 | return; 63 | } 64 | 65 | this._input += event.key; 66 | 67 | // Reset timeout if one was running 68 | clearTimeout(this._timeoutId); 69 | 70 | // Create timeout to check for valid chords after the delay 71 | this._timeoutId = setTimeout(function () { 72 | this._chordManager.handleChord(this._input, editor); 73 | this._input = ""; 74 | }.bind(this), this.Settings.delay); 75 | } 76 | } -------------------------------------------------------------------------------- /src/settings/settings-tab.ts: -------------------------------------------------------------------------------- 1 | import ChordsPlugin from "../main"; 2 | import { App, Notice, PluginSettingTab, SearchComponent, Setting, TextComponent } from "obsidian"; 3 | import { delayToWpm, wpmToDelay } from "./settings"; 4 | import { ChordType } from "src/chords/chord-manager"; 5 | import { CommandSuggster } from "src/suggesters/command-suggester"; 6 | import { FileSuggest } from "src/suggesters/file-suggester"; 7 | 8 | export default class ChordsSettingTab extends PluginSettingTab { 9 | private readonly _plugin: ChordsPlugin; 10 | 11 | private readonly _chordSettingFunctions = { 12 | [ChordType.Text]: this.addTextChordSettings, 13 | [ChordType.Command]: this.addCommandChordSettings, 14 | [ChordType.Template]: this.addFileChordSettings, 15 | [ChordType.File]: this.addFileChordSettings, 16 | } 17 | 18 | private _chordTriggers: TextComponent[] = []; 19 | 20 | public constructor(app: App, plugin: ChordsPlugin) { 21 | super(app, plugin); 22 | this._plugin = plugin; 23 | } 24 | 25 | /** 26 | * Display settings tab 27 | */ 28 | public display(): void { 29 | this.containerEl.empty(); 30 | 31 | this.containerEl.createEl('h2', { text: `${this._plugin.AppName} - ${this._plugin.AppVersion}` }); 32 | 33 | this.containerEl.createEl('h3', { text: "Notices" }); 34 | this.addNoticeToggle(); 35 | 36 | this.containerEl.createEl('h3', { text: "Delay" }); 37 | this.addDelayDesc(); 38 | this.addDelayWPMToggle(); 39 | if (this._plugin.Settings.setDelayManually) { 40 | this.addDelaySettings(); 41 | } 42 | else { 43 | this.addWpmSettings(); 44 | } 45 | 46 | this.containerEl.createEl('h3', { text: "Chords" }); 47 | this.addChordsSettings() 48 | } 49 | 50 | /** 51 | * Adds notice toggles 52 | * Chords will create a notice when used if their toggle is on 53 | */ 54 | private addNoticeToggle(): void { 55 | new Setting(this.containerEl.createDiv()) 56 | .setName("Text") 57 | .setDesc("Show a notice when a text chord is executed") 58 | .addToggle(t => t.setValue(this._plugin.Settings.showTextChordExecuted).onChange(async v => { 59 | this._plugin.Settings.showTextChordExecuted = v; 60 | await this._plugin.saveSettings(); 61 | })); 62 | 63 | new Setting(this.containerEl.createDiv()) 64 | .setName("Template") 65 | .setDesc("Show a notice when a template chord is executed") 66 | .addToggle(t => t.setValue(this._plugin.Settings.showTemplateChordExecuted).onChange(async v => { 67 | this._plugin.Settings.showTemplateChordExecuted = v; 68 | await this._plugin.saveSettings(); 69 | })); 70 | 71 | new Setting(this.containerEl.createDiv()) 72 | .setName("File") 73 | .setDesc("Show a notice when a file chord is executed") 74 | .addToggle(t => t.setValue(this._plugin.Settings.showFileChordExecuted).onChange(async v => { 75 | this._plugin.Settings.showFileChordExecuted = v; 76 | await this._plugin.saveSettings(); 77 | })); 78 | 79 | new Setting(this.containerEl.createDiv()) 80 | .setName("Command") 81 | .setDesc("Show a notice when a command chord is executed") 82 | .addToggle(t => t.setValue(this._plugin.Settings.showCommandChordExecuted).onChange(async v => { 83 | this._plugin.Settings.showCommandChordExecuted = v; 84 | await this._plugin.saveSettings(); 85 | })); 86 | } 87 | 88 | /** 89 | * Adds a toggle to switch between WPM input and manual delay setting 90 | */ 91 | private addDelayWPMToggle(): void { 92 | new Setting(this.containerEl) 93 | .setName("Set Delay Manually") 94 | .setDesc("Toggle this to set the delay yourself") 95 | .addToggle(t => t.setValue(this._plugin.Settings.setDelayManually).onChange(async v => { 96 | this._plugin.Settings.setDelayManually = v; 97 | await this._plugin.saveSettings(); 98 | this.display(); 99 | })); 100 | } 101 | 102 | /** 103 | * Adds manual delay settings 104 | */ 105 | private addDelaySettings(): void { 106 | new Setting(this.containerEl.createDiv()) 107 | .setName("Delay (ms)") 108 | .setDesc("Must be tailored to your typing speed") 109 | .addText(text => { 110 | text.setValue(String(this._plugin.Settings.delay)).onChange( 111 | async (value) => { 112 | if (!isNaN(Number(value)) && Number(value) >= 0) { 113 | this._plugin.Settings.delay = Number(value); 114 | await this._plugin.saveSettings(); 115 | } else { 116 | new Notice("Specify a valid number."); 117 | } 118 | } 119 | ); 120 | }); 121 | } 122 | 123 | /** 124 | * Adds automatic delay settings via wpm input 125 | */ 126 | private addWpmSettings(): void { 127 | new Setting(this.containerEl.createDiv()) 128 | .setName("Typing Speed (WPM)") 129 | .setDesc("The delay will be calculated automatically based on your typing speed") 130 | .addText(text => { 131 | text.setValue(String(delayToWpm(this._plugin.Settings.delay))).onChange( 132 | async (value) => { 133 | if (!isNaN(Number(value)) && Number(value) >= 0) { 134 | this._plugin.Settings.delay = wpmToDelay(Number(value)); 135 | await this._plugin.saveSettings(); 136 | } else { 137 | new Notice("Specify a valid number."); 138 | } 139 | } 140 | ); 141 | }); 142 | } 143 | 144 | /** 145 | * Adds description explaining what delay is 146 | */ 147 | private addDelayDesc(): void { 148 | new Setting(this.containerEl) 149 | .setDesc(createFragment((descEl) => { 150 | descEl.appendText("For each chord, the first field is the set of keys used to trigger the chord"); 151 | descEl.createEl("br"); 152 | descEl.appendText("The second field is the value for the chord"); 153 | descEl.createEl("br"); 154 | descEl.appendText("The third field is the type of chord"); 155 | })) 156 | .setClass("delay-pre-settings-text"); 157 | } 158 | 159 | /** 160 | * Highlights duplicate triggers in red 161 | */ 162 | private displayDuplicates(): void { 163 | for (var i = 0; i < this._plugin.Settings.chords.length; i++) { 164 | if (this._plugin.ChordManager.isDuplicateKey(i)) { 165 | this._chordTriggers[i].inputEl.addClass("chords-error"); 166 | } 167 | else { 168 | this._chordTriggers[i].inputEl.removeClass("chords-error"); 169 | } 170 | } 171 | } 172 | 173 | /** 174 | * Adds chord input settings 175 | */ 176 | private addChordsSettings(): void { 177 | new Setting(this.containerEl) 178 | .setDesc(createFragment((descEl) => { 179 | descEl.appendText("For each chord, the first field is the set of keys used to trigger the chord"); 180 | descEl.createEl("br"); 181 | descEl.appendText("The second field is the value for the chord"); 182 | descEl.createEl("br"); 183 | descEl.appendText("The third field is the type of chord"); 184 | })) 185 | .setClass("chords-pre-editor-text"); 186 | 187 | this._chordTriggers = []; 188 | 189 | this._plugin.Settings.chords.forEach(({ key, value, chordType }, index) => { 190 | var chordSetting = new Setting(this.containerEl) 191 | .addText(text => { 192 | this._chordTriggers.push(text); 193 | text.setPlaceholder("sav") 194 | .setValue(key) 195 | .onChange(async newKey => { 196 | await this._plugin.ChordManager.updateChordKey(index, newKey); 197 | this.displayDuplicates(); 198 | }); 199 | 200 | text.inputEl.addClass("chords-key"); 201 | }); 202 | 203 | chordSetting = this._chordSettingFunctions[chordType].bind(this)(chordSetting, value, index); 204 | 205 | chordSetting.addDropdown(cb => { 206 | cb.addOptions(Object.fromEntries(Object.keys(ChordType).filter(c => isNaN(Number(c))).map(c => [c, c]))) 207 | .setValue(ChordType[chordType]) 208 | .onChange(async newValue => { 209 | const newChordType = ChordType[newValue as keyof typeof ChordType] 210 | await this._plugin.ChordManager.updateChordType(index, newChordType); 211 | this.display(); 212 | }); 213 | }) 214 | .addExtraButton(cb => { 215 | cb.setIcon("up-chevron-glyph") 216 | .setTooltip("Move up") 217 | .onClick(async () => { 218 | await this._plugin.ChordManager.swapIndex(index, index - 1); 219 | this.display(); 220 | }); 221 | }) 222 | .addExtraButton(cb => { 223 | cb.setIcon("down-chevron-glyph") 224 | .setTooltip("Move down") 225 | .onClick(async () => { 226 | await this._plugin.ChordManager.swapIndex(index, index + 1); 227 | this.display(); 228 | }); 229 | }) 230 | .addExtraButton(cb => { 231 | cb.setIcon("cross") 232 | .setTooltip("Delete") 233 | .onClick(async () => { 234 | await this._plugin.ChordManager.removeChord(index); 235 | this.display(); 236 | }) 237 | }); 238 | chordSetting.infoEl.remove(); 239 | }); 240 | 241 | this.displayDuplicates(); 242 | 243 | new Setting(this.containerEl.createDiv()) 244 | .addButton(cb => { 245 | cb.setButtonText("Add new chord") 246 | .setCta() 247 | .onClick(async () => { 248 | await this._plugin.ChordManager.addBlankChord(); 249 | this.display(); 250 | }); 251 | }); 252 | } 253 | 254 | private validateChordValue(element: HTMLElement, chordIndex: number) { 255 | if (this._plugin.ChordManager.hasValidValue(chordIndex)) { 256 | element.removeClass("chords-error"); 257 | } 258 | else { 259 | element.addClass("chords-error"); 260 | } 261 | } 262 | 263 | /** 264 | * Adds file chord settings 265 | * @param chordSetting current setting to add to 266 | * @param value file path 267 | * @param index index of chord in settings.chords 268 | * @returns updated setted for chaining 269 | */ 270 | private addFileChordSettings(chordSetting: Setting, value: string, index: number): Setting { 271 | chordSetting = chordSetting.addSearch(cb => { 272 | new FileSuggest(app, cb.inputEl); 273 | cb.setPlaceholder("file.md") 274 | .setValue(value) 275 | .onChange(async (newValue) => { 276 | await this._plugin.ChordManager.updateChordValue(index, newValue); 277 | this.validateChordValue(cb.inputEl, index); 278 | }); 279 | 280 | this.validateChordValue(cb.inputEl, index); 281 | 282 | // @ts-ignore 283 | cb.containerEl.addClass("chords-search"); 284 | }); 285 | return chordSetting; 286 | } 287 | 288 | /** 289 | * Adds command chord settings 290 | * @param chordSetting current setting to add to 291 | * @param value command 292 | * @param index index of chord in settings.chords 293 | * @returns updated setted for chaining 294 | */ 295 | private addCommandChordSettings(chordSetting: Setting, value: string, index: number): Setting { 296 | chordSetting = chordSetting.addSearch(cb => { 297 | new CommandSuggster(app, cb.inputEl); 298 | cb.setPlaceholder("Save current file") 299 | .setValue(value) 300 | .onChange(async (newValue) => { 301 | await this._plugin.ChordManager.updateChordValue(index, newValue); 302 | this.validateChordValue(cb.inputEl, index); 303 | }); 304 | 305 | this.validateChordValue(cb.inputEl, index); 306 | 307 | // @ts-ignore 308 | cb.containerEl.addClass("chords-search"); 309 | }); 310 | return chordSetting; 311 | } 312 | 313 | /** 314 | * Adds text chord settings 315 | * @param chordSetting current setting to add to 316 | * @param value replacement text 317 | * @param index index of chord in settings.chords 318 | * @returns updated setted for chaining 319 | */ 320 | private addTextChordSettings(chordSetting: Setting, value: string, index: number): Setting { 321 | chordSetting = chordSetting.addTextArea(cb => { 322 | cb.setPlaceholder("chord here") 323 | .setValue(value) 324 | .onChange(async (newValue) => { 325 | await this._plugin.ChordManager.updateChordValue(index, newValue); 326 | this.validateChordValue(cb.inputEl, index); 327 | }); 328 | 329 | this.validateChordValue(cb.inputEl, index); 330 | 331 | // @ts-ignore 332 | cb.inputEl.addClass("chords-text-area"); 333 | }); 334 | return chordSetting; 335 | } 336 | } -------------------------------------------------------------------------------- /src/settings/settings.ts: -------------------------------------------------------------------------------- 1 | import { ChordData } from "src/chords/chord-manager"; 2 | 3 | /** 4 | * @member delay maximum duration (ms) between keys to be considered part of the chord. Delay needs to be less than the users inter-character typing delay 5 | * @member showWPM determines if we should calculate the delay based on the user's WPM (false) or if the delay is entered manually 6 | * @member showTextChordExecuted if we should display a notice when a text chord is executed 7 | * @member showTemplateChordExecuted if we should display a notice when a template chord is executed 8 | * @member showFileChordExecuted if we should display a notice when a file chord is executed 9 | * @member showCommandChordExecuted if we should display a notice when a command chord is executed 10 | * @member chords array of user created chords 11 | */ 12 | export interface ChordsPluginSettings { 13 | delay: number; 14 | setDelayManually: boolean; 15 | showTextChordExecuted: boolean; 16 | showTemplateChordExecuted: boolean; 17 | showFileChordExecuted: boolean; 18 | showCommandChordExecuted: boolean; 19 | chords: Array; 20 | } 21 | 22 | export const DEFAULT_SETTINGS: ChordsPluginSettings = { 23 | delay: wpmToDelay(80), 24 | setDelayManually: false, 25 | showTextChordExecuted: false, 26 | showTemplateChordExecuted: false, 27 | showFileChordExecuted: false, 28 | showCommandChordExecuted: true, 29 | chords: [], 30 | }; 31 | 32 | /** 33 | * The following two conversion functions are based on this math: 34 | * Delay is equal to the inter-character time of one's typing speed. 35 | * AVG_CHAR_PER_WORD represents the average amount of characters per word 36 | * The time it takes to type one word in ms is: AVG_CHAR_PER_WORD * delay 37 | * Convert to seconds: AVG_CHAR_PER_WORD * delay / 1,000 38 | * Wpm is 60 seconds over the time it takes for a word: wpm = 60 / (AVG_CHAR_PER_WORD * delay / 1,000) 39 | * The average amount of characters per word is 5, we'll add one for spaces: AVG_CHAR_PER_WORD = 6 40 | * Simplifying: wpm = 10,000 / delay 41 | * And the converse: delay = 10,000 / wpm 42 | * 43 | * This converts wpm to delay (ms), but if we use the user's typing speed we will calculate their normal 44 | * typing delay, we want the chord delay to be less than the user's normal delay, otherwise normal typing 45 | * will be considered a chord. To account for this, we'll divide the delay by k. I found that a k value of 3 works best 46 | * but this is more or less arbitrary: k = 3 47 | * 48 | * delay = (10,000 / wpm) / k = 3,333 / wpm 49 | * wpm = 10,000 / (delay * k) = 3,333 / delay 50 | */ 51 | 52 | /** 53 | * Converts delay to wpm 54 | * @param delay delay in ms 55 | * @returns typing speed in wpm 56 | */ 57 | export function delayToWpm(delay: number): number { 58 | return 3_333 / delay; 59 | } 60 | 61 | /** 62 | * Converts wpm to delay 63 | * @param wpm typing speed in wpm 64 | * @returns delay in ms 65 | */ 66 | export function wpmToDelay(wpm: number): number { 67 | return 3_333 / wpm; 68 | } 69 | -------------------------------------------------------------------------------- /src/suggesters/command-suggester.ts: -------------------------------------------------------------------------------- 1 | import { App } from "obsidian"; 2 | import { TextInputSuggest } from "./suggest"; 3 | 4 | export class CommandSuggster extends TextInputSuggest { 5 | private _commands: Array; 6 | 7 | constructor(app: App, inputEl: HTMLInputElement | HTMLTextAreaElement) { 8 | super(app, inputEl); 9 | 10 | // @ts-ignore 11 | this._commands = app.commands.listCommands().map(c => c.name); 12 | } 13 | 14 | public getSuggestions(inputStr?: string | undefined): string[] { 15 | const lowerCaseInputStr = inputStr?.toLowerCase() ?? ""; 16 | return this._commands.filter(c => c.toLowerCase().contains(lowerCaseInputStr)); 17 | } 18 | 19 | public renderSuggestion(item: string, el: HTMLElement): void { 20 | el.setText(item); 21 | } 22 | 23 | public selectSuggestion(item: string, evt: KeyboardEvent | MouseEvent): void { 24 | this.inputEl.value = item; 25 | this.inputEl.trigger("input"); 26 | this.close(); 27 | } 28 | } -------------------------------------------------------------------------------- /src/suggesters/file-suggester.ts: -------------------------------------------------------------------------------- 1 | // Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes 2 | import { TAbstractFile, TFile } from "obsidian"; 3 | import { TextInputSuggest } from "./suggest"; 4 | 5 | export class FileSuggest extends TextInputSuggest { 6 | public getSuggestions(inputStr: string): TFile[] { 7 | const abstractFiles = this.app.vault.getAllLoadedFiles(); 8 | const files: TFile[] = []; 9 | const lowerCaseInputStr = inputStr.toLowerCase(); 10 | 11 | abstractFiles.forEach((file: TAbstractFile) => { 12 | if ( 13 | file instanceof TFile && 14 | file.extension === "md" && 15 | file.path.toLowerCase().contains(lowerCaseInputStr) 16 | ) { 17 | files.push(file); 18 | } 19 | }); 20 | 21 | return files; 22 | } 23 | 24 | public renderSuggestion(file: TFile, el: HTMLElement): void { 25 | el.setText(file.path); 26 | } 27 | 28 | public selectSuggestion(file: TFile): void { 29 | this.inputEl.value = file.path; 30 | this.inputEl.trigger("input"); 31 | this.close(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/suggesters/suggest.ts: -------------------------------------------------------------------------------- 1 | import { App, ISuggestOwner, Scope } from 'obsidian'; 2 | import { createPopper, Instance as PopperInstance } from '@popperjs/core'; 3 | 4 | const wrapAround = (value: number, size: number): number => { 5 | return ((value % size) + size) % size; 6 | }; 7 | 8 | class Suggest { 9 | private owner: ISuggestOwner; 10 | private values: T[]; 11 | private suggestions: HTMLDivElement[]; 12 | private selectedItem: number; 13 | private containerEl: HTMLElement; 14 | 15 | constructor(owner: ISuggestOwner, containerEl: HTMLElement, scope: Scope) { 16 | this.owner = owner; 17 | this.containerEl = containerEl; 18 | 19 | containerEl.on( 20 | 'click', 21 | '.suggestion-item', 22 | this.onSuggestionClick.bind(this), 23 | ); 24 | containerEl.on( 25 | 'mousemove', 26 | '.suggestion-item', 27 | this.onSuggestionMouseover.bind(this), 28 | ); 29 | 30 | scope.register([], 'ArrowUp', (event) => { 31 | if (!event.isComposing) { 32 | this.setSelectedItem(this.selectedItem - 1, true); 33 | return false; 34 | } 35 | }); 36 | 37 | scope.register([], 'ArrowDown', (event) => { 38 | if (!event.isComposing) { 39 | this.setSelectedItem(this.selectedItem + 1, true); 40 | return false; 41 | } 42 | }); 43 | 44 | scope.register([], 'Enter', (event) => { 45 | if (!event.isComposing) { 46 | this.useSelectedItem(event); 47 | return false; 48 | } 49 | }); 50 | } 51 | 52 | onSuggestionClick(event: MouseEvent, el: HTMLDivElement): void { 53 | event.preventDefault(); 54 | 55 | const item = this.suggestions.indexOf(el); 56 | this.setSelectedItem(item, false); 57 | this.useSelectedItem(event); 58 | } 59 | 60 | onSuggestionMouseover(_event: MouseEvent, el: HTMLDivElement): void { 61 | const item = this.suggestions.indexOf(el); 62 | this.setSelectedItem(item, false); 63 | } 64 | 65 | setSuggestions(values: T[]) { 66 | this.containerEl.empty(); 67 | const suggestionEls: HTMLDivElement[] = []; 68 | 69 | values.forEach((value) => { 70 | const suggestionEl = this.containerEl.createDiv('suggestion-item'); 71 | this.owner.renderSuggestion(value, suggestionEl); 72 | suggestionEls.push(suggestionEl); 73 | }); 74 | 75 | this.values = values; 76 | this.suggestions = suggestionEls; 77 | this.setSelectedItem(0, false); 78 | } 79 | 80 | useSelectedItem(event: MouseEvent | KeyboardEvent) { 81 | const currentValue = this.values[this.selectedItem]; 82 | if (currentValue) { 83 | this.owner.selectSuggestion(currentValue, event); 84 | } 85 | } 86 | 87 | setSelectedItem(selectedIndex: number, scrollIntoView: boolean) { 88 | const normalizedIndex = wrapAround(selectedIndex, this.suggestions.length); 89 | const prevSelectedSuggestion = this.suggestions[this.selectedItem]; 90 | const selectedSuggestion = this.suggestions[normalizedIndex]; 91 | 92 | prevSelectedSuggestion?.removeClass('is-selected'); 93 | selectedSuggestion?.addClass('is-selected'); 94 | 95 | this.selectedItem = normalizedIndex; 96 | 97 | if (scrollIntoView) { 98 | selectedSuggestion.scrollIntoView(false); 99 | } 100 | } 101 | } 102 | 103 | export abstract class TextInputSuggest implements ISuggestOwner { 104 | protected app: App; 105 | protected inputEl: HTMLInputElement | HTMLTextAreaElement; 106 | 107 | private popper: PopperInstance; 108 | private scope: Scope; 109 | private suggestEl: HTMLElement; 110 | private suggest: Suggest; 111 | 112 | constructor( 113 | app: App, 114 | inputEl: HTMLInputElement | HTMLTextAreaElement, 115 | ) { 116 | this.app = app; 117 | this.inputEl = inputEl; 118 | this.scope = new Scope(); 119 | 120 | this.suggestEl = createDiv('suggestion-container'); 121 | const suggestion = this.suggestEl.createDiv('suggestion'); 122 | this.suggest = new Suggest(this, suggestion, this.scope); 123 | 124 | this.scope.register([], 'Escape', this.close.bind(this)); 125 | 126 | this.inputEl.addEventListener('input', this.onInputChanged.bind(this)); 127 | this.inputEl.addEventListener('focus', this.onInputChanged.bind(this)); 128 | this.inputEl.addEventListener('blur', this.close.bind(this)); 129 | this.suggestEl.on( 130 | 'mousedown', 131 | '.suggestion-container', 132 | (event: MouseEvent) => { 133 | event.preventDefault(); 134 | }, 135 | ); 136 | } 137 | 138 | onInputChanged(): void { 139 | const inputStr = this.inputEl.value; 140 | const suggestions = this.getSuggestions(inputStr); 141 | 142 | if (!suggestions) { 143 | this.close(); 144 | return; 145 | } 146 | 147 | if (suggestions.length > 0) { 148 | this.suggest.setSuggestions(suggestions); 149 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 150 | this.open((this.app).dom.appContainerEl, this.inputEl); 151 | } else { 152 | this.close(); 153 | } 154 | } 155 | 156 | open(container: HTMLElement, inputEl: HTMLElement): void { 157 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 158 | (this.app).keymap.pushScope(this.scope); 159 | 160 | container.appendChild(this.suggestEl); 161 | this.popper = createPopper(inputEl, this.suggestEl, { 162 | placement: 'bottom-start', 163 | modifiers: [ 164 | { 165 | name: 'sameWidth', 166 | enabled: true, 167 | fn: ({ state, instance }) => { 168 | // Note: positioning needs to be calculated twice - 169 | // first pass - positioning it according to the width of the popper 170 | // second pass - position it with the width bound to the reference element 171 | // we need to early exit to avoid an infinite loop 172 | const targetWidth = `${state.rects.reference.width}px`; 173 | if (state.styles.popper.width === targetWidth) { 174 | return; 175 | } 176 | state.styles.popper.width = targetWidth; 177 | instance.update(); 178 | }, 179 | phase: 'beforeWrite', 180 | requires: ['computeStyles'], 181 | }, 182 | ], 183 | }); 184 | } 185 | 186 | close(): void { 187 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 188 | (this.app).keymap.popScope(this.scope); 189 | 190 | this.suggest.setSuggestions([]); 191 | if (this.popper) this.popper.destroy(); 192 | this.suggestEl.detach(); 193 | } 194 | 195 | abstract getSuggestions(inputStr?: string): T[]; 196 | abstract renderSuggestion(item: T, el: HTMLElement): void; 197 | abstract selectSuggestion(item: T, evt: MouseEvent | KeyboardEvent): void; 198 | } -------------------------------------------------------------------------------- /src/utils/string.extensions.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | interface String { 3 | sort(): string; 4 | } 5 | } 6 | 7 | String.prototype.sort = function (): string { 8 | return this.split("").sort().join(""); 9 | }; 10 | 11 | export { }; -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | .chords-search, 2 | .chords-text-area { 3 | width: calc(100%); 4 | } 5 | 6 | .chords-key { 7 | width: 15%; 8 | } 9 | 10 | .chords-text-area { 11 | height: 30px; 12 | resize: vertical; 13 | } 14 | 15 | .chords-error { 16 | border-color: red !important; 17 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "ES6", 8 | "allowJs": true, 9 | "noImplicitAny": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "isolatedModules": true, 13 | "strictNullChecks": true, 14 | "lib": [ 15 | "DOM", 16 | "ES5", 17 | "ES6", 18 | "ES7" 19 | ] 20 | }, 21 | "include": [ 22 | "**/*.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /version-bump.mjs: -------------------------------------------------------------------------------- 1 | import { readFileSync, writeFileSync } from "fs"; 2 | 3 | const targetVersion = process.env.npm_package_version; 4 | 5 | // read minAppVersion from manifest.json and bump version to target version 6 | let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); 7 | const { minAppVersion } = manifest; 8 | manifest.version = targetVersion; 9 | writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); 10 | 11 | // update versions.json with target version and minAppVersion from manifest.json 12 | let versions = JSON.parse(readFileSync("versions.json", "utf8")); 13 | versions[targetVersion] = minAppVersion; 14 | writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); 15 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.0.0": "0.15.0" 3 | } 4 | --------------------------------------------------------------------------------