├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── cMenu Bottom.gif ├── cMenu Demo Header.png ├── cMenu status bar menu.gif ├── cMenu-sliding-panes.gif ├── cMenu-v020.gif ├── cMenu.gif ├── cMenu.png ├── chesser cMenu.gif ├── cmenu-and-admonition.gif ├── glass-cMenu.gif ├── hide_show_command.gif └── reorder_commands.gif ├── manifest.json ├── package-lock.json ├── package.json ├── rollup.config.js ├── src ├── icons │ ├── appIcons.ts │ └── customIcons.ts ├── modals │ ├── cMenuModal.ts │ └── suggesterModals.ts ├── plugin │ └── main.ts ├── settings │ ├── settingsData.ts │ └── settingsTab.ts └── util │ ├── statusBarConstants.ts │ └── util.ts ├── styles.css ├── tsconfig.json └── versions.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: chetachiezikeuzor 2 | ko_fi: chetachi 3 | custom: 4 | [ 5 | "https://www.buymeacoffee.com/chetachi", 6 | "https://paypal.me/chelseaezikeuzor", 7 | ] 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Intellij 2 | *.iml 3 | .idea 4 | 5 | # npm 6 | node_modules 7 | package-lock.json 8 | 9 | # build 10 | main.js 11 | .DS_Store 12 | *.js.map 13 | .env 14 | 15 | # obsidian 16 | data.json 17 | 18 | #history 19 | .history 20 | 21 | #DS Store 22 | .DS_Store 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cMenu Plugin 2 | 3 | ![cMenu-Plugin Downloads](https://img.shields.io/github/downloads/chetachiezikeuzor/cMenu-Plugin/total.svg) 4 | ![cMenu-Plugin Releases](https://img.shields.io/github/v/release/chetachiezikeuzor/cMenu-Plugin) 5 | 6 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu%20Demo%20Header.png) 7 | 8 | ### Status: This plugin is now available in Obsidian plugin store 9 | 10 | cMenu is a plugin that adds a minimal and user friendly text editor modal for a smoother writing/editing experience ✍🏽. This plugin makes text editing and firing commands easier for those that don't wish to configure a multitude of hotkeys. 11 | 12 | ## Demo 13 | 14 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu.gif) 15 | 16 | ## Ease of Use 17 | 18 | This plugin was specifically designed for note-takers that want to have a simple text editor to aid in marking up their notes. cMenu solves the issue of having to memorize numerous hotkeys and/or use multiple key presses to get the desired markup. When you use cMenu, you'll only have to focus on writing! 19 | 20 | ## How it Works 21 | 22 | With the newest update of cMenu, you can add just about any command from Obsidian's command library onto the menu bar. By default, the menu bar will have the following commands: Toggle bold, Toggle italics, Toggle strikethrough, cMenu: Toggle Underline, cMenu: Toggle Superscript, cMenu: Toggle Subscript, Toggle code, cMenu: Toggle codeblock, and Toggle blockquote. 23 | 24 | ```javascript 25 | "menuCommands": [ 26 | { 27 | id: "cmenu-plugin:editor:toggle-bold", 28 | name: "cMenu: Toggle bold", 29 | icon: "bold-glyph", 30 | }, 31 | { 32 | id: "cmenu-plugin:editor:toggle-italics", 33 | name: "cMenu: Toggle italics", 34 | icon: "italic-glyph", 35 | }, 36 | { 37 | id: "cmenu-plugin:editor:toggle-strikethrough", 38 | name: "cMenu: Toggle strikethrough", 39 | icon: "strikethrough-glyph", 40 | }, 41 | { 42 | id: "cmenu-plugin:underline", 43 | name: "cMenu: Toggle underline", 44 | icon: "underline-glyph", 45 | }, 46 | { 47 | id: "cmenu-plugin:superscript", 48 | name: "cMenu: Toggle superscript", 49 | icon: "superscript-glyph", 50 | }, 51 | { 52 | id: "cmenu-plugin:subscript", 53 | name: "cMenu: Toggle subscript", 54 | icon: "subscript-glyph", 55 | }, 56 | { 57 | id: "cmenu-plugin:editor:toggle-code", 58 | name: "cMenu: Toggle code", 59 | icon: "code-glyph", 60 | }, 61 | { 62 | id: "cmenu-plugin:codeblock", 63 | name: "cMenu: Toggle codeblock", 64 | icon: "codeblock-glyph", 65 | }, 66 | { 67 | id: "cmenu-plugin:editor:toggle-blockquote", 68 | name: "cMenu: Toggle blockquote", 69 | icon: "quote-glyph", 70 | } 71 | ], 72 | ``` 73 | 74 | As you can see, cMenu adds four new commands to Obsidian's command library and modifies fourteen of Obsidian's text editing commands. Those commands are added to an array of commands that are then read within the generation of the cMenu modal. If you would like to remove and/or add new commands, you can do so within the cMenu settings panel. Use the bright button (your accent color) to add a new command onto the menu. And use the gret button to remove them from the menu. When you add/remove a new command, you will see a message in your console, indicating the status of said command. With the newest update [1.1.2](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.1.2), ycMenu will reload everytime a command is added or deleted. No need for closing out your current notes, 75 | 76 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu.gif) 77 | 78 | The plugins Templater and Hotkeys for Templates are strongly recommended to use with cMenu. For example: I have a template that spawns the chess opening "Alekhine's Defense." With Hotkeys for Templates, I can choose to add this template to Obsidian's command library. Now that it's in the command library, I can choose to append this command to cMenu. This means you can really add just about anything to cMenu now, which makes it much more powerful! 79 | 80 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/chesser%20cMenu.gif) 81 | 82 | cMenu also has a few stylistic changes that are also customizeable. For those that use the plugin Sliding Panes, you can now change cMenu's append method to "body." That way, cMenu will no longer appends to the workspace area, but to the body of the app. This is a bit of a work around for the current issue with Sliding Panes but I'm actively looking into a better solution. 83 | 84 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu-sliding-panes.gif) 85 | 86 | With cMenu, you can change the design aesthetic. Glass morphism is a pretty popular design trend so I thought "why not add this to cMenu?!" You can choose to have a "glass" style for cMenu, which gives it a unique look. 87 | 88 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/glass-cMenu.gif) 89 | 90 | ## cMenu Status Bar Menu 91 | 92 | With the new [1.1.0](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.1.0) update, you can control to bottom value of cMenu, as well as toggle to hide cMenu and add/delete new command items. The delete button will remove the most recently added command. 93 | 94 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu%20status%20bar%20menu.gif) 95 | 96 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu.png) 97 | 98 | ## Installation 99 | 100 | This plugin is now available in the community plugin store. You can install it from there and enable it. For a manual installation, you can download the necessary files and place them within your plugins folder. 101 | 102 | --- 103 | 104 | ## Changelog 105 | 106 | ### [0.1.0](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/0.1.0) - Jul 27, 2021 107 | 108 | ##### Changed 109 | 110 | - Interfaces are renamed to match plugin info 111 | - Now uses `workspace.getActiveViewOfType(MarkdownView)` instead of `activeLeaf` for menu creation 112 | 113 | --- 114 | 115 | ### [0.2.0](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/0.2.0) - Aug 02, 2021 116 | 117 | ##### Changed 118 | 119 | - Now uses `workspace.getActiveViewOfType(MarkdownView)` to store text selection 120 | 121 | ##### Fixed 122 | 123 | - cMenu appends to `.mod-vertical.mod-root` parent instead of `body` parent. 124 | - cMenu left positioning is set by function that finds width dynamically on menu creation. 125 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu-v020.gif) 126 | 127 | --- 128 | 129 | ### [0.3.0](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/0.3.0) - Aug 02, 2021 130 | 131 | ##### Fixed 132 | 133 | - Fixed small [bug](https://github.com/chetachiezikeuzor/cMenu-Plugin/issues/3#issuecomment-891371471) that causes an extra resize handle to be created. 134 | 135 | --- 136 | 137 | ### [1.0.0](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.0.0) - Aug 11, 2021 138 | 139 | ##### Fixed 140 | 141 | - Fixed issue with Sliding Panes with a toggle-able append method setting. 142 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu-sliding-panes.gif) 143 | 144 | ##### Added 145 | 146 | - Added new glass morphism setting. 147 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/glass-cMenu.gif) 148 | - Added new custom commands setting 149 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/chesser%20cMenu.gif) 150 | 151 | --- 152 | 153 | ### [1.0.1](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.0.1) - Aug 11, 2021 154 | 155 | ##### Added 156 | 157 | - Added more icons to command icon chooser 158 | 159 | --- 160 | 161 | ### [1.0.2](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.0.2) - Aug 13, 2021 162 | 163 | ##### Changed 164 | 165 | - Removed most !importants for better custom styling 166 | 167 | ##### Added 168 | 169 | - Added a few more icons 170 | - Added updates to UI 171 | 172 | --- 173 | 174 | ### [1.0.3](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.0.3) - Aug 13, 2021 175 | 176 | ##### Added 177 | 178 | - Added feather icons 179 | 180 | --- 181 | 182 | ### [1.1.0](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.1.0) - Aug 27, 2021 183 | 184 | ##### Added 185 | 186 | - Added new status bar menu for extra cMenu setting: Hide/Show buttons, Bottom value change 187 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/cMenu%20status%20bar%20menu.gif) 188 | - Added modified text editing commands 189 | - Commands will maintain focus in editor after execution 190 | 191 | --- 192 | 193 | ### [1.1.2](https://github.com/chetachiezikeuzor/cMenu-Plugin/releases/tag/1.1.2) - Sep 14, 2021 194 | 195 | ##### Added 196 | 197 | - Added [remix icons](https://remixicon.com) for command customization (makes it a bit slow :/) 198 | - Added reload function (button to execute and execution after add/delete) 199 | - Added custom columns setting 200 | - Added command reordering in settings 201 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/reorder_commands.gif) 202 | - Added command to hide/show cMenu 203 | ![](https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/master/assets/hide_show_command.gif) 204 | - Added [remove tags](https://github.com/chetachiezikeuzor/cMenu-Plugin/pull/23) functionality 205 | 206 | --- 207 | 208 | ## Checklist 209 | 210 | - [x] Glassmorphism setting 211 | - [x] Setting to toggle for glass effect with cMenu 212 | - [x] Fix to work with Sliding Panes (workaround) 213 | - [x] Setting to toggle for cMenu to toggle to body instead of modroot 214 | - [x] Add custom commands to cMenu 215 | - [x] Choose icons for commands without 216 | - [x] [Modify](https://github.com/chetachiezikeuzor/cMenu-Plugin/issues/11#issue-973612232) text editing commands 217 | - [x] Maintain focus in editor 218 | - [x] Change cMenu [bottom value](https://www.reddit.com/r/ObsidianMD/comments/owlaaf/new_obsidian_plugin_cmenu/h8vkn0v?utm_source=share&utm_medium=web2x&context=3) 219 | - [x] [Hide/show](https://github.com/chetachiezikeuzor/cMenu-Plugin/issues/10#issue-971519914) cMenu 220 | - [x] Add more command icons (Remix Icons) 221 | - [x] Custom cMenu columns 222 | - [x] Setting to customize cMenu columns (control number of command buttons per row on cMenu) 223 | - [x] Reload cMenu 224 | - [x] Add reload after new command added and command deletion functions. 225 | - [x] Add general reload button (runs reload function) 226 | - [ ] Identify if text has been [selected](https://github.com/chetachiezikeuzor/cMenu-Plugin/issues/11#issuecomment-901091701) 227 | - [x] Easy command button [reordering](https://github.com/chetachiezikeuzor/cMenu-Plugin/issues/9#issue-969667944) 228 | - [ ] cMenu workspaces/nested menu 229 | - [ ] Follow the cursor setting 230 | - [ ] Setting to toggle for cMenu to follow mouse cursor 231 | 232 | --- 233 | 234 | ## Support 235 | 236 | If you like this plugin and are considering donating to support continued development, use the button below! 237 | 238 | Created with ❤️ by Chetachi 239 | 240 | 241 | -------------------------------------------------------------------------------- /assets/cMenu Bottom.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cMenu Bottom.gif -------------------------------------------------------------------------------- /assets/cMenu Demo Header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cMenu Demo Header.png -------------------------------------------------------------------------------- /assets/cMenu status bar menu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cMenu status bar menu.gif -------------------------------------------------------------------------------- /assets/cMenu-sliding-panes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cMenu-sliding-panes.gif -------------------------------------------------------------------------------- /assets/cMenu-v020.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cMenu-v020.gif -------------------------------------------------------------------------------- /assets/cMenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cMenu.gif -------------------------------------------------------------------------------- /assets/cMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cMenu.png -------------------------------------------------------------------------------- /assets/chesser cMenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/chesser cMenu.gif -------------------------------------------------------------------------------- /assets/cmenu-and-admonition.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/cmenu-and-admonition.gif -------------------------------------------------------------------------------- /assets/glass-cMenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/glass-cMenu.gif -------------------------------------------------------------------------------- /assets/hide_show_command.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/hide_show_command.gif -------------------------------------------------------------------------------- /assets/reorder_commands.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chetachiezikeuzor/cMenu-Plugin/280b4f197362a03b80117d37c6deef7d2148ce60/assets/reorder_commands.gif -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cmenu-plugin", 3 | "name": "cMenu", 4 | "version": "1.1.2", 5 | "minAppVersion": "0.9.12", 6 | "description": "cMenu is a plugin that adds a minimal text editor modal for a smoother writing/editing experience ✍🏽.", 7 | "author": "chetachi", 8 | "authorUrl": "https://github.com/chetachiezikeuzor", 9 | "isDesktopOnly": true 10 | } 11 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cmenu", 3 | "version": "1.1.2", 4 | "lockfileVersion": 1, 5 | "dependencies": { 6 | "@rollup/plugin-commonjs": { 7 | "version": "18.1.0", 8 | "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.1.0.tgz", 9 | "integrity": "sha512-h3e6T9rUxVMAQswpDIobfUHn/doMzM9sgkMrsMWCFLmB84PSoC8mV8tOloAJjSRwdqhXBqstlX2BwBpHJvbhxg==", 10 | "dev": true, 11 | "requires": { 12 | "@rollup/pluginutils": "^3.1.0", 13 | "commondir": "^1.0.1", 14 | "estree-walker": "^2.0.1", 15 | "glob": "^7.1.6", 16 | "is-reference": "^1.2.1", 17 | "magic-string": "^0.25.7", 18 | "resolve": "^1.17.0" 19 | } 20 | }, 21 | "@rollup/plugin-node-resolve": { 22 | "version": "11.2.1", 23 | "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", 24 | "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", 25 | "dev": true, 26 | "requires": { 27 | "@rollup/pluginutils": "^3.1.0", 28 | "@types/resolve": "1.17.1", 29 | "builtin-modules": "^3.1.0", 30 | "deepmerge": "^4.2.2", 31 | "is-module": "^1.0.0", 32 | "resolve": "^1.19.0" 33 | } 34 | }, 35 | "@rollup/plugin-typescript": { 36 | "version": "8.2.3", 37 | "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.2.3.tgz", 38 | "integrity": "sha512-bSkd+DD3wP9OLU6lPet59B6jJF29/RlxHkbwvOVOcf1nk8eQYWw24HpldEdrPo/WG0QAPD7TqI7+2y5jtdqjww==", 39 | "dev": true, 40 | "requires": { 41 | "@rollup/pluginutils": "^3.1.0", 42 | "resolve": "^1.17.0" 43 | } 44 | }, 45 | "@rollup/pluginutils": { 46 | "version": "3.1.0", 47 | "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", 48 | "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", 49 | "dev": true, 50 | "requires": { 51 | "@types/estree": "0.0.39", 52 | "estree-walker": "^1.0.1", 53 | "picomatch": "^2.2.2" 54 | }, 55 | "dependencies": { 56 | "estree-walker": { 57 | "version": "1.0.1", 58 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", 59 | "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", 60 | "dev": true 61 | } 62 | } 63 | }, 64 | "@types/codemirror": { 65 | "version": "0.0.108", 66 | "resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-0.0.108.tgz", 67 | "integrity": "sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==", 68 | "dev": true, 69 | "requires": { 70 | "@types/tern": "*" 71 | } 72 | }, 73 | "@types/estree": { 74 | "version": "0.0.39", 75 | "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", 76 | "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", 77 | "dev": true 78 | }, 79 | "@types/feather-icons": { 80 | "version": "4.7.0", 81 | "resolved": "https://registry.npmjs.org/@types/feather-icons/-/feather-icons-4.7.0.tgz", 82 | "integrity": "sha512-vflOrmlHMGIGVN4AEl6ErPCNKBLcP1ehEpLqnJkTgf69r5QmJzy7BF1WzbBc8Hqs9KffROPT/JqlSKH4o5vB/w==", 83 | "dev": true 84 | }, 85 | "@types/node": { 86 | "version": "14.17.6", 87 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.6.tgz", 88 | "integrity": "sha512-iBxsxU7eswQDGhlr3AiamBxOssaYxbM+NKXVil8jg9yFXvrfEFbDumLD/2dMTB+zYyg7w+Xjt8yuxfdbUHAtcQ==", 89 | "dev": true 90 | }, 91 | "@types/prop-types": { 92 | "version": "15.7.4", 93 | "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz", 94 | "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==", 95 | "dev": true 96 | }, 97 | "@types/react": { 98 | "version": "17.0.19", 99 | "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.19.tgz", 100 | "integrity": "sha512-sX1HisdB1/ZESixMTGnMxH9TDe8Sk709734fEQZzCV/4lSu9kJCPbo2PbTRoZM+53Pp0P10hYVyReUueGwUi4A==", 101 | "dev": true, 102 | "requires": { 103 | "@types/prop-types": "*", 104 | "@types/scheduler": "*", 105 | "csstype": "^3.0.2" 106 | } 107 | }, 108 | "@types/react-dom": { 109 | "version": "17.0.9", 110 | "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.9.tgz", 111 | "integrity": "sha512-wIvGxLfgpVDSAMH5utdL9Ngm5Owu0VsGmldro3ORLXV8CShrL8awVj06NuEXFQ5xyaYfdca7Sgbk/50Ri1GdPg==", 112 | "dev": true, 113 | "requires": { 114 | "@types/react": "*" 115 | } 116 | }, 117 | "@types/resolve": { 118 | "version": "1.17.1", 119 | "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", 120 | "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", 121 | "dev": true, 122 | "requires": { 123 | "@types/node": "*" 124 | } 125 | }, 126 | "@types/scheduler": { 127 | "version": "0.16.2", 128 | "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", 129 | "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", 130 | "dev": true 131 | }, 132 | "@types/sortablejs": { 133 | "version": "1.10.7", 134 | "resolved": "https://registry.npmjs.org/@types/sortablejs/-/sortablejs-1.10.7.tgz", 135 | "integrity": "sha512-lGCwwgpj8zW/ZmaueoPVSP7nnc9t8VqVWXS+ASX3eoUUENmiazv0rlXyTRludXzuX9ALjPsMqBu85TgJNWbTOg==", 136 | "dev": true 137 | }, 138 | "@types/tern": { 139 | "version": "0.23.4", 140 | "resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.4.tgz", 141 | "integrity": "sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==", 142 | "dev": true, 143 | "requires": { 144 | "@types/estree": "*" 145 | } 146 | }, 147 | "balanced-match": { 148 | "version": "1.0.2", 149 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 150 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", 151 | "dev": true 152 | }, 153 | "brace-expansion": { 154 | "version": "1.1.11", 155 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 156 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 157 | "dev": true, 158 | "requires": { 159 | "balanced-match": "^1.0.0", 160 | "concat-map": "0.0.1" 161 | } 162 | }, 163 | "builtin-modules": { 164 | "version": "3.2.0", 165 | "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", 166 | "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", 167 | "dev": true 168 | }, 169 | "classnames": { 170 | "version": "2.3.1", 171 | "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", 172 | "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" 173 | }, 174 | "commondir": { 175 | "version": "1.0.1", 176 | "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", 177 | "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", 178 | "dev": true 179 | }, 180 | "concat-map": { 181 | "version": "0.0.1", 182 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 183 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 184 | "dev": true 185 | }, 186 | "core-js": { 187 | "version": "3.16.1", 188 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.1.tgz", 189 | "integrity": "sha512-AAkP8i35EbefU+JddyWi12AWE9f2N/qr/pwnDtWz4nyUIBGMJPX99ANFFRSw6FefM374lDujdtLDyhN2A/btHw==" 190 | }, 191 | "csstype": { 192 | "version": "3.0.8", 193 | "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.8.tgz", 194 | "integrity": "sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==", 195 | "dev": true 196 | }, 197 | "deepmerge": { 198 | "version": "4.2.2", 199 | "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", 200 | "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", 201 | "dev": true 202 | }, 203 | "estree-walker": { 204 | "version": "2.0.2", 205 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", 206 | "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", 207 | "dev": true 208 | }, 209 | "feather-icons": { 210 | "version": "4.28.0", 211 | "resolved": "https://registry.npmjs.org/feather-icons/-/feather-icons-4.28.0.tgz", 212 | "integrity": "sha512-gRdqKESXRBUZn6Nl0VBq2wPHKRJgZz7yblrrc2lYsS6odkNFDnA4bqvrlEVRUPjE1tFax+0TdbJKZ31ziJuzjg==", 213 | "requires": { 214 | "classnames": "^2.2.5", 215 | "core-js": "^3.1.3" 216 | } 217 | }, 218 | "fs.realpath": { 219 | "version": "1.0.0", 220 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 221 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 222 | "dev": true 223 | }, 224 | "fsevents": { 225 | "version": "2.3.2", 226 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", 227 | "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", 228 | "dev": true, 229 | "optional": true 230 | }, 231 | "function-bind": { 232 | "version": "1.1.1", 233 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", 234 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", 235 | "dev": true 236 | }, 237 | "glob": { 238 | "version": "7.1.7", 239 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", 240 | "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", 241 | "dev": true, 242 | "requires": { 243 | "fs.realpath": "^1.0.0", 244 | "inflight": "^1.0.4", 245 | "inherits": "2", 246 | "minimatch": "^3.0.4", 247 | "once": "^1.3.0", 248 | "path-is-absolute": "^1.0.0" 249 | } 250 | }, 251 | "has": { 252 | "version": "1.0.3", 253 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", 254 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", 255 | "dev": true, 256 | "requires": { 257 | "function-bind": "^1.1.1" 258 | } 259 | }, 260 | "inflight": { 261 | "version": "1.0.6", 262 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 263 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 264 | "dev": true, 265 | "requires": { 266 | "once": "^1.3.0", 267 | "wrappy": "1" 268 | } 269 | }, 270 | "inherits": { 271 | "version": "2.0.4", 272 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 273 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 274 | "dev": true 275 | }, 276 | "is-core-module": { 277 | "version": "2.5.0", 278 | "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.5.0.tgz", 279 | "integrity": "sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg==", 280 | "dev": true, 281 | "requires": { 282 | "has": "^1.0.3" 283 | } 284 | }, 285 | "is-module": { 286 | "version": "1.0.0", 287 | "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", 288 | "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", 289 | "dev": true 290 | }, 291 | "is-reference": { 292 | "version": "1.2.1", 293 | "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", 294 | "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", 295 | "dev": true, 296 | "requires": { 297 | "@types/estree": "*" 298 | } 299 | }, 300 | "js-tokens": { 301 | "version": "4.0.0", 302 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", 303 | "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" 304 | }, 305 | "loose-envify": { 306 | "version": "1.4.0", 307 | "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", 308 | "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", 309 | "requires": { 310 | "js-tokens": "^3.0.0 || ^4.0.0" 311 | } 312 | }, 313 | "magic-string": { 314 | "version": "0.25.7", 315 | "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", 316 | "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", 317 | "dev": true, 318 | "requires": { 319 | "sourcemap-codec": "^1.4.4" 320 | } 321 | }, 322 | "minimatch": { 323 | "version": "3.0.4", 324 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 325 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 326 | "dev": true, 327 | "requires": { 328 | "brace-expansion": "^1.1.7" 329 | } 330 | }, 331 | "moment": { 332 | "version": "2.29.1", 333 | "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", 334 | "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", 335 | "dev": true 336 | }, 337 | "object-assign": { 338 | "version": "4.1.1", 339 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 340 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 341 | }, 342 | "obsidian": { 343 | "version": "0.12.11", 344 | "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.12.11.tgz", 345 | "integrity": "sha512-Kv4m1n4nfd17FzpqHZfqFS2YZAyY+cxAUM7/5jqh1bmbPlmKoNd1XJZC7o9KvkXfTCxALiXfGRdrjHB+GUFAEA==", 346 | "dev": true, 347 | "requires": { 348 | "@types/codemirror": "0.0.108", 349 | "moment": "2.29.1" 350 | } 351 | }, 352 | "once": { 353 | "version": "1.4.0", 354 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 355 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 356 | "dev": true, 357 | "requires": { 358 | "wrappy": "1" 359 | } 360 | }, 361 | "path-is-absolute": { 362 | "version": "1.0.1", 363 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 364 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 365 | "dev": true 366 | }, 367 | "path-parse": { 368 | "version": "1.0.7", 369 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", 370 | "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", 371 | "dev": true 372 | }, 373 | "picomatch": { 374 | "version": "2.3.0", 375 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", 376 | "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", 377 | "dev": true 378 | }, 379 | "react": { 380 | "version": "17.0.2", 381 | "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", 382 | "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", 383 | "requires": { 384 | "loose-envify": "^1.1.0", 385 | "object-assign": "^4.1.1" 386 | } 387 | }, 388 | "react-dom": { 389 | "version": "17.0.2", 390 | "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", 391 | "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", 392 | "requires": { 393 | "loose-envify": "^1.1.0", 394 | "object-assign": "^4.1.1", 395 | "scheduler": "^0.20.2" 396 | } 397 | }, 398 | "react-dom-server": { 399 | "version": "0.0.5", 400 | "resolved": "https://registry.npmjs.org/react-dom-server/-/react-dom-server-0.0.5.tgz", 401 | "integrity": "sha1-dbbA9ZRuCOhNud2m7KXkj+0l9yM=" 402 | }, 403 | "react-icons": { 404 | "version": "4.2.0", 405 | "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.2.0.tgz", 406 | "integrity": "sha512-rmzEDFt+AVXRzD7zDE21gcxyBizD/3NqjbX6cmViAgdqfJ2UiLer8927/QhhrXQV7dEj/1EGuOTPp7JnLYVJKQ==" 407 | }, 408 | "remixicon": { 409 | "version": "2.5.0", 410 | "resolved": "https://registry.npmjs.org/remixicon/-/remixicon-2.5.0.tgz", 411 | "integrity": "sha512-q54ra2QutYDZpuSnFjmeagmEiN9IMo56/zz5dDNitzKD23oFRw77cWo4TsrAdmdkPiEn8mxlrTqxnkujDbEGww==" 412 | }, 413 | "resolve": { 414 | "version": "1.20.0", 415 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", 416 | "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", 417 | "dev": true, 418 | "requires": { 419 | "is-core-module": "^2.2.0", 420 | "path-parse": "^1.0.6" 421 | } 422 | }, 423 | "rollup": { 424 | "version": "2.56.3", 425 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.3.tgz", 426 | "integrity": "sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg==", 427 | "dev": true, 428 | "requires": { 429 | "fsevents": "~2.3.2" 430 | } 431 | }, 432 | "scheduler": { 433 | "version": "0.20.2", 434 | "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", 435 | "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", 436 | "requires": { 437 | "loose-envify": "^1.1.0", 438 | "object-assign": "^4.1.1" 439 | } 440 | }, 441 | "sortablejs": { 442 | "version": "1.14.0", 443 | "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz", 444 | "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==" 445 | }, 446 | "sourcemap-codec": { 447 | "version": "1.4.8", 448 | "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", 449 | "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", 450 | "dev": true 451 | }, 452 | "tslib": { 453 | "version": "2.3.0", 454 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", 455 | "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", 456 | "dev": true 457 | }, 458 | "typescript": { 459 | "version": "4.4.2", 460 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", 461 | "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", 462 | "dev": true 463 | }, 464 | "wrappy": { 465 | "version": "1.0.2", 466 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 467 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 468 | "dev": true 469 | } 470 | } 471 | } 472 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cmenu", 3 | "version": "1.1.2", 4 | "description": "cMenu is a plugin that adds a minimal text editor modal for a smoother writing/editing experience ✍🏽.", 5 | "main": "main.js", 6 | "repository": "https://github.com/chetachiezikeuzor/cMenu-Plugin", 7 | "scripts": { 8 | "dev": "rollup --config rollup.config.js -w", 9 | "build": "rollup --config rollup.config.js --environment BUILD:production" 10 | }, 11 | "keywords": [], 12 | "author": "Chetachi", 13 | "license": "MPL-2.0", 14 | "devDependencies": { 15 | "@rollup/plugin-commonjs": "^18.0.0", 16 | "@rollup/plugin-node-resolve": "^11.2.1", 17 | "@rollup/plugin-typescript": "^8.2.1", 18 | "@types/feather-icons": "^4.7.0", 19 | "@types/node": "^14.17.6", 20 | "@types/react-dom": "^17.0.9", 21 | "@types/sortablejs": "^1.10.7", 22 | "obsidian": "^0.12.11", 23 | "rollup": "^2.56.3", 24 | "rollup-watch": "^4.3.1", 25 | "tslib": "^2.2.0", 26 | "typescript": "^4.4.2", 27 | "typings": "^2.1.1" 28 | }, 29 | "moduleFileExtensions": [ 30 | "js", 31 | "ts" 32 | ], 33 | "dependencies": { 34 | "feather-icons": "^4.28.0", 35 | "react": "^17.0.2", 36 | "react-dom": "^17.0.2", 37 | "react-dom-server": "0.0.5", 38 | "react-icons": "^4.2.0", 39 | "remixicon": "^2.5.0", 40 | "sortablejs": "^1.14.0" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import typescript from "@rollup/plugin-typescript"; 2 | import resolve from "@rollup/plugin-node-resolve"; 3 | import commonjs from "@rollup/plugin-commonjs"; 4 | 5 | const isProd = process.env.BUILD === "production"; 6 | 7 | const banner = `/* 8 | THIS IS A GENERATED/BUNDLED FILE BY ROLLUP 9 | if you want to view the source visit the plugins github repository 10 | */ 11 | `; 12 | 13 | export default { 14 | input: "src/plugin/main.ts", 15 | output: { 16 | dir: "./", 17 | sourcemap: "inline", 18 | sourcemapExcludeSources: isProd, 19 | format: "cjs", 20 | exports: "default", 21 | banner, 22 | }, 23 | external: ["obsidian"], 24 | plugins: [ 25 | typescript(), 26 | resolve({ 27 | browser: true, 28 | }), 29 | commonjs({ include: "node_modules/**" }), 30 | ], 31 | }; 32 | -------------------------------------------------------------------------------- /src/icons/appIcons.ts: -------------------------------------------------------------------------------- 1 | export const appIcons: string[] = [ 2 | // from obsidian app.js file 3 | "add-note-glyph", 4 | "any-key", 5 | "audio-file", 6 | "blocks", 7 | "bold-glyph", 8 | "bot-glyph", 9 | "box-glyph", 10 | "bracket-glyph", 11 | "broken-link", 12 | "bullet-list-glyph", 13 | "bullet-list", 14 | "calendar-glyph", 15 | "calendar-with-checkmark", 16 | "check-in-circle", 17 | "check-small", 18 | "checkbox-glyph", 19 | "checkmark", 20 | "clock-glyph", 21 | "clock", 22 | "cloud", 23 | "codeblock-glyph", 24 | "code-glyph", 25 | "command-glyph", 26 | "compress-glyph", 27 | "create-new", 28 | "cross-in-box", 29 | "cross", 30 | "crossed-star", 31 | "csv", 32 | "deleteColumn", 33 | "deleteRow", 34 | "dice-glyph", 35 | "dice", 36 | "document", 37 | "documents", 38 | "dot-network", 39 | "double-down-arrow-glyph", 40 | "double-up-arrow-glyph", 41 | "down-arrow-with-tail", 42 | "down-chevron-glyph", 43 | "down-curly-arrow-glyph", 44 | "duplicate-glyph", 45 | "enlarge-glyph", 46 | "enter", 47 | "exit-fullscreen", 48 | "expand-vertically", 49 | "file-explorer-glyph", 50 | "filled-pin", 51 | "formula", 52 | "folder", 53 | "forward-arrow", 54 | "fullscreen", 55 | "gear", 56 | "go-to-file", 57 | "graph-glyph", 58 | "hashtag", 59 | "heading-glyph", 60 | "help", 61 | "highlight-glyph", 62 | "horizontal-split", 63 | "image-file", 64 | "image-glyph", 65 | "import-glyph", 66 | "indent-glyph", 67 | "info", 68 | "insertColumn", 69 | "insertRow", 70 | "install", 71 | "italic-glyph", 72 | "keyboard-glyph", 73 | "languages", 74 | "left-arrow-with-tail", 75 | "left-arrow", 76 | "left-chevron-glyph", 77 | "lines-of-text", 78 | "link-glyph", 79 | "link", 80 | "links-coming-in", 81 | "links-going-out", 82 | "logo-crystal", 83 | "magnifying-glass", 84 | "merge-files-glyph", 85 | "merge-files", 86 | "microphone-filled", 87 | "microphone", 88 | "minus-with-circle", 89 | "moveColumnLeft", 90 | "moveColumnRight", 91 | "moveRowDown", 92 | "moveRowUp", 93 | "navigate-glyph", 94 | "note-glyph", 95 | "number-list-glyph", 96 | "open-elsewhere-glyph", 97 | "open-vault", 98 | "pane-layout", 99 | "paper-plane-glyph", 100 | "paper-plane", 101 | "paste-text", 102 | "paste", 103 | "paused", 104 | "pdf-file", 105 | "pencil", 106 | "percent-sign-glyph", 107 | "pin", 108 | "play-audio-glyph", 109 | "plus-minus-glyph", 110 | "plus-with-circle", 111 | "popup-open", 112 | "presentation-glyph", 113 | "presentation", 114 | "price-tag-glyph", 115 | "question-mark-glyph", 116 | "quote-glyph", 117 | "redo-glyph", 118 | "reset", 119 | "restore-file-glyph", 120 | "right-arrow-with-tail", 121 | "right-arrow", 122 | "right-chevron-glyph", 123 | "right-triangle", 124 | "run-command", 125 | "scissors-glyph", 126 | "scissors", 127 | "search-glyph", 128 | "search", 129 | "select-all-text", 130 | "sheets-in-box", 131 | "sortAsc", 132 | "sortDesc", 133 | "spreadsheet", 134 | "split", 135 | "stacked-levels", 136 | "star-glyph", 137 | "star-list", 138 | "star", 139 | "stop-audio-glyph", 140 | "strikethrough-glyph", 141 | "subscript-glyph", 142 | "superscript-glyph", 143 | "switch", 144 | "sync-small", 145 | "sync", 146 | "tag-glyph", 147 | "three-horizontal-bars", 148 | "tomorrow-glyph", 149 | "trash", 150 | "two-blank-pages", 151 | "underline-glyph", 152 | "undo-glyph", 153 | "unindent-glyph", 154 | "up-and-down-arrows", 155 | "up-arrow-with-tail", 156 | "up-chevron-glyph", 157 | "up-curly-arrow-glyph", 158 | "uppercase-lowercase-a", 159 | "vault", 160 | "vertical-split", 161 | "vertical-three-dots", 162 | "workspace-glyph", 163 | "wrench-screwdriver-glyph", 164 | "yesterday-glyph", 165 | ]; 166 | -------------------------------------------------------------------------------- /src/icons/customIcons.ts: -------------------------------------------------------------------------------- 1 | import * as featherIcons from "feather-icons"; 2 | import * as remixicons from "react-icons/ri/"; 3 | import * as boxicons from "react-icons/bi/"; 4 | import { renderToString } from "react-dom/server"; 5 | import { addIcon } from "obsidian"; 6 | 7 | export interface Icon { 8 | id: string; 9 | name: string; 10 | } 11 | 12 | const icons: Record = { 13 | cMenu: ``, 14 | cMenuAdd: ``, 15 | cMenuDelete: ``, 16 | cMenuReload: ``, 17 | "codeblock-glyph": ``, 18 | "underline-glyph": ``, 19 | "superscript-glyph": ``, 20 | "subscript-glyph": ``, 21 | "bot-glyph": ``, 22 | }; 23 | 24 | export default function addIcons() { 25 | Object.keys(icons).forEach((key) => { 26 | addIcon(key, icons[key]); 27 | }); 28 | } 29 | 30 | export function addFeatherIcons(appIcons: string[]) { 31 | Object.values(featherIcons.icons).forEach((icon) => { 32 | const svg = icon.toSvg({ 33 | viewBox: "0 0 24 24", 34 | width: "100", 35 | height: "100", 36 | "stroke-width": "2", 37 | }); 38 | addIcon("feather-" + icon.name, svg); 39 | appIcons.push("feather-" + icon.name); 40 | }); 41 | } 42 | 43 | export function addRemixIcons(appIcons: string[]) { 44 | const iconKeys: Icon[] = []; 45 | for (const icon in remixicons) { 46 | iconKeys.push({ 47 | id: icon, 48 | name: icon.substring(2), 49 | }); 50 | const svg = renderToString( 51 | // @ts-ignore 52 | remixicons[icon]({ 53 | size: "100", 54 | }) 55 | ); 56 | addIcon("remix-" + icon.substring(2), svg); 57 | appIcons.push("remix-" + icon.substring(2)); 58 | } 59 | } 60 | 61 | export function addBoxIcons(appIcons: string[]) { 62 | const iconKeys: Icon[] = []; 63 | for (const icon in boxicons) { 64 | iconKeys.push({ 65 | id: icon, 66 | name: icon.substring(2), 67 | }); 68 | const svg = renderToString( 69 | // @ts-ignore 70 | boxicons[icon]({ 71 | size: "100", 72 | }) 73 | ); 74 | addIcon("bx-" + icon.substring(2), svg); 75 | appIcons.push("bx-" + icon.substring(2)); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/modals/cMenuModal.ts: -------------------------------------------------------------------------------- 1 | import type { cMenuSettings } from "src/settings/settingsData"; 2 | import { App, Command, MarkdownView, ButtonComponent } from "obsidian"; 3 | import { setBottomValue } from "src/util/statusBarConstants"; 4 | 5 | export function selfDestruct() { 6 | let cMenuModalBar = document.getElementById("cMenuModalBar"); 7 | if (cMenuModalBar) { 8 | if (cMenuModalBar.firstChild) { 9 | cMenuModalBar.removeChild(cMenuModalBar.firstChild); 10 | } 11 | cMenuModalBar.remove(); 12 | } 13 | } 14 | 15 | export function cMenuPopover(app: App, settings: cMenuSettings): void { 16 | function createMenu() { 17 | const generateMenu = () => { 18 | var cMenu = createEl("div"); 19 | if (cMenu) { 20 | cMenu.setAttribute( 21 | "style", 22 | `left: calc(50% - calc(${cMenu.offsetWidth}px / 2)); bottom: ${ 23 | settings.cMenuBottomValue 24 | }em; grid-template-columns: ${"1fr ".repeat(settings.cMenuNumRows)}` 25 | ); 26 | } 27 | cMenu.setAttribute("id", "cMenuModalBar"); 28 | settings.aestheticStyle == "default" 29 | ? cMenu.addClass("cMenuDefaultAesthetic") 30 | : cMenu.addClass("cMenuGlassAesthetic"); 31 | settings.appendMethod == "workspace" 32 | ? document.body 33 | .querySelector(".mod-vertical.mod-root") 34 | .insertAdjacentElement("afterbegin", cMenu) 35 | : document.body.appendChild(cMenu); 36 | settings.menuCommands.forEach((item: Command) => { 37 | var button = new ButtonComponent(cMenu); 38 | button 39 | .setIcon(item.icon) 40 | .setClass("cMenuCommandItem") 41 | .setTooltip(item.name) 42 | .onClick(() => { 43 | //@ts-ignore 44 | app.commands.executeCommandById(item.id); 45 | }); 46 | }); 47 | document.addEventListener("selectionchange", function (event) { 48 | setTimeout(async () => { 49 | const activeLeaf = app.workspace.getActiveViewOfType(MarkdownView); 50 | if (activeLeaf) { 51 | cMenu.style.visibility = activeLeaf.editor.somethingSelected() ? "visible" : "hidden"; 52 | const selection = window.getSelection(); 53 | // getCientRects returns all the positioning information we need 54 | const selectionContainer = selection.getRangeAt(0).commonAncestorContainer as HTMLElement; 55 | const rect = selectionContainer.getClientRects()[0] 56 | 57 | cMenu.style.height = `${cMenu.offsetHeight}px`; 58 | // TODO: parents are different, position is error. 59 | cMenu.style.left = `${rect.right - cMenu.offsetWidth * 1.5}px`; 60 | if (rect.bottom + cMenu.offsetHeight < document.body.clientHeight) { 61 | cMenu.style.top = `${rect.bottom}px`; 62 | } else { 63 | cMenu.style.top = `${rect.top - cMenu.offsetHeight * 1.5}px`; 64 | } 65 | // after cancel select 66 | let timmer = setInterval(() => { 67 | if (!activeLeaf.editor.somethingSelected()) { 68 | cMenu.style.visibility = "hidden"; 69 | clearInterval(timmer); 70 | }; 71 | }, 100); 72 | } 73 | }, 10); 74 | }) 75 | }; 76 | let Markdown = app.workspace.getActiveViewOfType(MarkdownView); 77 | if (Markdown) { 78 | var cMenuModalBar = document.getElementById("cMenuModalBar"); 79 | if (cMenuModalBar) { 80 | return; 81 | } else { 82 | generateMenu(); 83 | let cMenuModalBar = document.getElementById("cMenuModalBar"); 84 | setBottomValue(settings.cMenuBottomValue, settings.cMenuNumRows); 85 | settings.cMenuVisibility == false 86 | ? (cMenuModalBar.style.visibility = "hidden") 87 | : (cMenuModalBar.style.visibility = "visible"); 88 | } 89 | } else { 90 | selfDestruct(); 91 | } 92 | } 93 | createMenu(); 94 | } 95 | -------------------------------------------------------------------------------- /src/modals/suggesterModals.ts: -------------------------------------------------------------------------------- 1 | import type cMenuPlugin from "src/plugin/main"; 2 | import { appIcons } from "src/icons/appIcons"; 3 | import { Command, setIcon, FuzzyMatch, FuzzySuggestModal } from "obsidian"; 4 | 5 | class ChooseFromIconList extends FuzzySuggestModal { 6 | plugin: cMenuPlugin; 7 | command: Command; 8 | 9 | constructor(plugin: cMenuPlugin, command: Command) { 10 | super(plugin.app); 11 | this.plugin = plugin; 12 | this.command = command; 13 | this.setPlaceholder("Choose an icon"); 14 | } 15 | 16 | private capitalJoin(string: string): string { 17 | const icon = string.split(" "); 18 | 19 | return icon 20 | .map((icon) => { 21 | return icon[0].toUpperCase() + icon.substring(1); 22 | }) 23 | .join(" "); 24 | } 25 | 26 | getItems(): string[] { 27 | return appIcons; 28 | } 29 | 30 | getItemText(item: string): string { 31 | return this.capitalJoin( 32 | item 33 | .replace("feather-", "") 34 | .replace("remix-", "") 35 | .replace("bx-", "") 36 | .replace(/([A-Z])/g, " $1") 37 | .trim() 38 | .replace(/-/gi, " ") 39 | ); 40 | } 41 | 42 | renderSuggestion(icon: FuzzyMatch, iconItem: HTMLElement): void { 43 | const span = createSpan({ cls: "cMenuIconPick" }); 44 | iconItem.appendChild(span); 45 | setIcon(span, icon.item); 46 | super.renderSuggestion(icon, iconItem); 47 | } 48 | 49 | async onChooseItem(item: string): Promise { 50 | this.command.icon = item; 51 | this.plugin.settings.menuCommands.push(this.command); 52 | await this.plugin.saveSettings(); 53 | setTimeout(() => { 54 | dispatchEvent(new Event("cMenu-NewCommand")); 55 | }, 100); 56 | console.log( 57 | `%cCommand '${this.command.name}' was added to cMenu`, 58 | "color: Violet" 59 | ); 60 | } 61 | } 62 | 63 | export class CommandPicker extends FuzzySuggestModal { 64 | command: Command; 65 | 66 | constructor(private plugin: cMenuPlugin) { 67 | super(plugin.app); 68 | this.app; 69 | this.setPlaceholder("Choose a command"); 70 | } 71 | 72 | getItems(): Command[] { 73 | //@ts-ignore 74 | return this.app.commands.listCommands(); 75 | } 76 | 77 | getItemText(item: Command): string { 78 | return item.name; 79 | } 80 | 81 | async onChooseItem(item: Command): Promise { 82 | if (item.icon) { 83 | this.plugin.settings.menuCommands.push(item); 84 | await this.plugin.saveSettings(); 85 | setTimeout(() => { 86 | dispatchEvent(new Event("cMenu-NewCommand")); 87 | }, 100); 88 | console.log( 89 | `%cCommand '${item.name}' was added to cMenu`, 90 | "color: Violet" 91 | ); 92 | } else { 93 | new ChooseFromIconList(this.plugin, item).open(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/plugin/main.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Menu, 3 | Plugin, 4 | Command, 5 | setIcon, 6 | debounce, 7 | Editor, 8 | MarkdownView, 9 | SliderComponent, 10 | ToggleComponent, 11 | ButtonComponent, 12 | App, 13 | } from "obsidian"; 14 | import { wait } from "src/util/util"; 15 | import { appIcons } from "src/icons/appIcons"; 16 | import { CommandPicker } from "src/modals/suggesterModals"; 17 | import { cMenuSettingTab } from "src/settings/settingsTab"; 18 | import { selfDestruct, cMenuPopover } from "src/modals/cMenuModal"; 19 | import { cMenuSettings, DEFAULT_SETTINGS } from "src/settings/settingsData"; 20 | import addIcons, { 21 | addFeatherIcons, 22 | addRemixIcons, 23 | addBoxIcons, 24 | } from "src/icons/customIcons"; 25 | 26 | import { setMenuVisibility, setBottomValue } from "src/util/statusBarConstants"; 27 | 28 | export default class cMenuPlugin extends Plugin { 29 | app: App; 30 | settings: cMenuSettings; 31 | statusBarIcon: HTMLElement; 32 | cMenuBar: HTMLElement; 33 | modCommands: Command[] = [ 34 | { 35 | id: "editor:insert-embed", 36 | name: "Add embed", 37 | icon: "note-glyph", 38 | }, 39 | { 40 | id: "editor:insert-link", 41 | name: "Insert markdown link", 42 | icon: "link-glyph", 43 | }, 44 | { 45 | id: "editor:insert-tag", 46 | name: "Add tag", 47 | icon: "price-tag-glyph", 48 | }, 49 | { 50 | id: "editor:insert-wikilink", 51 | name: "Add internal link", 52 | icon: "bracket-glyph", 53 | }, 54 | { 55 | id: "editor:toggle-bold", 56 | name: "Toggle bold", 57 | icon: "bold-glyph", 58 | }, 59 | { 60 | id: "editor:toggle-italics", 61 | name: "Toggle italics", 62 | icon: "italic-glyph", 63 | }, 64 | { 65 | id: "editor:toggle-strikethrough", 66 | name: "Toggle strikethrough", 67 | icon: "strikethrough-glyph", 68 | }, 69 | { 70 | id: "editor:toggle-code", 71 | name: "Toggle code", 72 | icon: "code-glyph", 73 | }, 74 | { 75 | id: "editor:toggle-blockquote", 76 | name: "Toggle blockquote", 77 | icon: "quote-glyph", 78 | }, 79 | { 80 | id: "editor:toggle-bullet-list", 81 | name: "Toggle bullet", 82 | icon: "bullet-list-glyph", 83 | }, 84 | { 85 | id: "editor:toggle-checklist-status", 86 | name: "Toggle checklist status", 87 | icon: "checkbox-glyph", 88 | }, 89 | { 90 | id: "editor:toggle-comments", 91 | name: "Toggle comment", 92 | icon: "percent-sign-glyph", 93 | }, 94 | { 95 | id: "editor:toggle-highlight", 96 | name: "Toggle highlight", 97 | icon: "highlight-glyph", 98 | }, 99 | { 100 | id: "editor:toggle-numbered-list", 101 | name: "Toggle numbered list", 102 | icon: "number-list-glyph", 103 | }, 104 | ]; 105 | 106 | async onload(): Promise { 107 | console.log("cMenu v" + this.manifest.version + " loaded"); 108 | await this.loadSettings(); 109 | addIcons(); 110 | addFeatherIcons(appIcons); 111 | addRemixIcons(appIcons); 112 | //addBoxIcons(appIcons); 113 | this.generateCommands(); 114 | this.app.workspace.onLayoutReady(() => { 115 | setTimeout(() => { 116 | this.setupStatusBar(); 117 | }); 118 | }); 119 | this.addSettingTab(new cMenuSettingTab(this.app, this)); 120 | this.registerEvent( 121 | this.app.workspace.on("active-leaf-change", this.handlecMenu) 122 | ); 123 | } 124 | 125 | generateCommands() { 126 | //Hide-show menu 127 | this.addCommand({ 128 | id: "hide-show-menu", 129 | name: "Hide/show ", 130 | icon: "cMenu", 131 | callback: async () => { 132 | this.settings.cMenuVisibility = !this.settings.cMenuVisibility; 133 | this.settings.cMenuVisibility == true 134 | ? setTimeout(() => { 135 | dispatchEvent(new Event("cMenu-NewCommand")); 136 | }, 100) 137 | : setMenuVisibility(this.settings.cMenuVisibility); 138 | selfDestruct(); 139 | await this.saveSettings(); 140 | }, 141 | }); 142 | 143 | const applyCommand = (command: commandPlot, editor: Editor) => { 144 | const selectedText = editor.getSelection(); 145 | const curserStart = editor.getCursor("from"); 146 | const curserEnd = editor.getCursor("to"); 147 | const prefix = command.prefix; 148 | const suffix = command.suffix || prefix; 149 | const setCursor = (mode: number) => { 150 | editor.setCursor( 151 | curserStart.line + command.line * mode, 152 | curserEnd.ch + command.char * mode 153 | ); 154 | }; 155 | const preStart = { 156 | line: curserStart.line - command.line, 157 | ch: curserStart.ch - prefix.length, 158 | }; 159 | const pre = editor.getRange(preStart, curserStart); 160 | 161 | if (pre == prefix.trimStart()) { 162 | const sufEnd = { 163 | line: curserStart.line + command.line, 164 | ch: curserEnd.ch + suffix.length, 165 | }; 166 | const suf = editor.getRange(curserEnd, sufEnd); 167 | if (suf == suffix.trimEnd()) { 168 | editor.replaceRange(selectedText, preStart, sufEnd); // codeblock leave blank lines 169 | return setCursor(-1); 170 | } 171 | } 172 | editor.replaceSelection(`${prefix}${selectedText}${suffix}`); 173 | return setCursor(1); 174 | }; 175 | 176 | type commandPlot = { 177 | char: number; 178 | line: number; 179 | prefix: string; 180 | suffix: string; 181 | }; 182 | 183 | type commandsPlot = { 184 | [key: string]: commandPlot; 185 | }; 186 | 187 | const commandsMap: commandsPlot = { 188 | underline: { 189 | char: 3, 190 | line: 0, 191 | prefix: "", 192 | suffix: "", 193 | }, 194 | superscript: { 195 | char: 5, 196 | line: 0, 197 | prefix: "", 198 | suffix: "", 199 | }, 200 | subscript: { 201 | char: 5, 202 | line: 0, 203 | prefix: "", 204 | suffix: "", 205 | }, 206 | codeblock: { 207 | char: 5, 208 | line: 1, 209 | prefix: "\n```\n", 210 | suffix: "\n```\n", 211 | }, 212 | }; 213 | // Add new commands 214 | Object.keys(commandsMap).forEach((type) => { 215 | this.addCommand({ 216 | id: `${type}`, 217 | name: `Toggle ${type}`, 218 | icon: `${type}-glyph`, 219 | callback: async () => { 220 | const activeLeaf = 221 | this.app.workspace.getActiveViewOfType(MarkdownView); 222 | if (activeLeaf) { 223 | const view = activeLeaf; 224 | const editor = view.editor; 225 | applyCommand(commandsMap[type], editor); 226 | await wait(10); 227 | //@ts-ignore 228 | this.app.commands.executeCommandById("editor:focus"); 229 | } 230 | }, 231 | }); 232 | }); 233 | // Enhance editor commands 234 | this.modCommands.forEach((type) => { 235 | this.addCommand({ 236 | id: `${type["id"]}`, 237 | name: `${type["name"]}`, 238 | icon: `${type["icon"]}`, 239 | callback: async () => { 240 | const activeLeaf = 241 | this.app.workspace.getActiveViewOfType(MarkdownView); 242 | const view = activeLeaf; 243 | const editor = view.editor; 244 | //@ts-ignore 245 | this.app.commands.executeCommandById(`${type["id"]}`); 246 | editor.setCursor(editor.getCursor("to")); 247 | await wait(10); 248 | //@ts-ignore 249 | this.app.commands.executeCommandById("editor:focus"); 250 | }, 251 | }); 252 | }); 253 | } 254 | 255 | setupStatusBar() { 256 | this.statusBarIcon = this.addStatusBarItem(); 257 | this.statusBarIcon.addClass("cMenu-statusbar-button"); 258 | setIcon(this.statusBarIcon, "cMenu"); 259 | 260 | this.registerDomEvent(this.statusBarIcon, "click", () => { 261 | const statusBarRect = 262 | this.statusBarIcon.parentElement.getBoundingClientRect(); 263 | const statusBarIconRect = this.statusBarIcon.getBoundingClientRect(); 264 | 265 | const menu = new Menu(this.app).addItem((item) => { 266 | item.setTitle("Hide & Show"); 267 | 268 | const itemDom = (item as any).dom as HTMLElement; 269 | const toggleComponent = new ToggleComponent(itemDom) 270 | .setValue(this.settings.cMenuVisibility) 271 | .setDisabled(true); 272 | 273 | const toggle = async () => { 274 | this.settings.cMenuVisibility = !this.settings.cMenuVisibility; 275 | toggleComponent.setValue(this.settings.cMenuVisibility); 276 | this.settings.cMenuVisibility == true 277 | ? setTimeout(() => { 278 | dispatchEvent(new Event("cMenu-NewCommand")); 279 | }, 100) 280 | : setMenuVisibility(this.settings.cMenuVisibility); 281 | selfDestruct(); 282 | await this.saveSettings(); 283 | }; 284 | 285 | item.onClick((e) => { 286 | e.preventDefault(); 287 | e.stopImmediatePropagation(); 288 | toggle(); 289 | }); 290 | }); 291 | 292 | const menuDom = (menu as any).dom as HTMLElement; 293 | menuDom.addClass("cMenu-statusbar-menu"); 294 | 295 | const item = menuDom.createDiv("menu-item"); 296 | item.createDiv({ cls: "menu-item-icon" }); 297 | item.createDiv({ text: "Bottom", cls: "menu-item-title" }); 298 | item.onClickEvent((e) => e.stopPropagation()); 299 | 300 | new SliderComponent(item) 301 | .setLimits(2, 18, 0.25) 302 | .setValue(this.settings.cMenuBottomValue) 303 | .onChange( 304 | debounce( 305 | async (value) => { 306 | console.log(`%c${value}em`, "color: Violet"); 307 | this.settings.cMenuBottomValue = value; 308 | setBottomValue( 309 | this.settings.cMenuBottomValue, 310 | this.settings.cMenuNumRows 311 | ); 312 | await this.saveSettings(); 313 | }, 314 | 100, 315 | true 316 | ) 317 | ) 318 | .setDynamicTooltip(); 319 | 320 | const buttonItem = menuDom.createDiv({ cls: "menu-item buttonitem" }); 321 | const addButton = new ButtonComponent(buttonItem); 322 | const deleteButton = new ButtonComponent(buttonItem); 323 | const refreshButton = new ButtonComponent(buttonItem); 324 | addButton 325 | .setIcon("cMenuAdd") 326 | .setClass("cMenuSettingsButton") 327 | .setClass("cMenuSettingsButtonAdd") 328 | .setClass("cMenuStatusButton") 329 | .setTooltip("Add") 330 | .onClick(() => { 331 | new CommandPicker(this).open(); 332 | }); 333 | this.settings.menuCommands.forEach((newCommand) => { 334 | deleteButton 335 | .setIcon("cMenuDelete") 336 | .setClass("cMenuSettingsButton") 337 | .setClass("cMenuSettingsButtonDelete") 338 | .setTooltip("Delete") 339 | .onClick(async () => { 340 | this.settings.menuCommands.remove(newCommand); 341 | await this.saveSettings(); 342 | setTimeout(() => { 343 | dispatchEvent(new Event("cMenu-NewCommand")); 344 | }, 100); 345 | console.log( 346 | `%cCommand '${newCommand.name}' was removed from cMenu`, 347 | "color: #989cab" 348 | ); 349 | }); 350 | }); 351 | refreshButton 352 | .setIcon("cMenuReload") 353 | .setClass("cMenuSettingsButton") 354 | .setClass("cMenuSettingsButtonRefresh") 355 | .setTooltip("Refresh") 356 | .onClick(async () => { 357 | setTimeout(() => { 358 | dispatchEvent(new Event("cMenu-NewCommand")); 359 | }, 100); 360 | console.log(`%ccMenu refreshed`, "color: Violet"); 361 | }); 362 | menu.showAtPosition({ 363 | x: statusBarIconRect.right + 5, 364 | y: statusBarRect.top - 5, 365 | }); 366 | }); 367 | } 368 | 369 | onunload(): void { 370 | selfDestruct(); 371 | console.log("cMenu unloaded"); 372 | this.app.workspace.off("active-leaf-change", this.handlecMenu); 373 | } 374 | 375 | handlecMenu = (): void => { 376 | this.settings.cMenuVisibility == true 377 | ? cMenuPopover(this.app, this.settings) 378 | : false; 379 | }; 380 | 381 | async loadSettings() { 382 | this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); 383 | } 384 | 385 | async saveSettings() { 386 | await this.saveData(this.settings); 387 | } 388 | } 389 | -------------------------------------------------------------------------------- /src/settings/settingsData.ts: -------------------------------------------------------------------------------- 1 | import type { Command } from "obsidian"; 2 | export const APPEND_METHODS = ["body", "workspace"]; 3 | export const AESTHETIC_STYLES = ["glass", "default"]; 4 | 5 | export interface cMenuSettings { 6 | aestheticStyle: string; 7 | menuCommands: Command[]; 8 | appendMethod: string; 9 | shouldShowMenuOnSelect: boolean; 10 | cMenuVisibility: boolean; 11 | cMenuBottomValue: number; 12 | cMenuNumRows: number; 13 | } 14 | 15 | export const DEFAULT_SETTINGS: cMenuSettings = { 16 | aestheticStyle: "default", 17 | menuCommands: [ 18 | { 19 | id: "cmenu-plugin:editor:toggle-bold", 20 | name: "cMenu: Toggle bold", 21 | icon: "bold-glyph", 22 | }, 23 | { 24 | id: "cmenu-plugin:editor:toggle-italics", 25 | name: "cMenu: Toggle italics", 26 | icon: "italic-glyph", 27 | }, 28 | { 29 | id: "cmenu-plugin:editor:toggle-strikethrough", 30 | name: "cMenu: Toggle strikethrough", 31 | icon: "strikethrough-glyph", 32 | }, 33 | { 34 | id: "cmenu-plugin:underline", 35 | name: "cMenu: Toggle underline", 36 | icon: "underline-glyph", 37 | }, 38 | { 39 | id: "cmenu-plugin:superscript", 40 | name: "cMenu: Toggle superscript", 41 | icon: "superscript-glyph", 42 | }, 43 | { 44 | id: "cmenu-plugin:subscript", 45 | name: "cMenu: Toggle subscript", 46 | icon: "subscript-glyph", 47 | }, 48 | { 49 | id: "cmenu-plugin:editor:toggle-code", 50 | name: "cMenu: Toggle code", 51 | icon: "code-glyph", 52 | }, 53 | { 54 | id: "cmenu-plugin:codeblock", 55 | name: "cMenu: Toggle codeblock", 56 | icon: "codeblock-glyph", 57 | }, 58 | { 59 | id: "cmenu-plugin:editor:toggle-blockquote", 60 | name: "cMenu: Toggle blockquote", 61 | icon: "quote-glyph", 62 | }, 63 | ], 64 | appendMethod: "workspace", 65 | shouldShowMenuOnSelect: false, 66 | cMenuVisibility: true, 67 | cMenuBottomValue: 4.25, 68 | cMenuNumRows: 9, 69 | }; 70 | -------------------------------------------------------------------------------- /src/settings/settingsTab.ts: -------------------------------------------------------------------------------- 1 | import type cMenuPlugin from "src/plugin/main"; 2 | import { CommandPicker } from "src/modals/suggesterModals"; 3 | import { App, Setting, PluginSettingTab } from "obsidian"; 4 | import { APPEND_METHODS, AESTHETIC_STYLES } from "src/settings/settingsData"; 5 | import { selfDestruct, cMenuPopover } from "src/modals/cMenuModal"; 6 | import Sortable from "sortablejs"; 7 | import { debounce } from "obsidian"; 8 | 9 | export class cMenuSettingTab extends PluginSettingTab { 10 | plugin: cMenuPlugin; 11 | appendMethod: string; 12 | 13 | constructor(app: App, plugin: cMenuPlugin) { 14 | super(app, plugin); 15 | this.plugin = plugin; 16 | addEventListener("cMenu-NewCommand", () => { 17 | selfDestruct(); 18 | cMenuPopover(app, this.plugin.settings); 19 | this.display(); 20 | }); 21 | } 22 | 23 | display(): void { 24 | const { containerEl } = this; 25 | containerEl.empty(); 26 | containerEl.createEl("h1", { text: "cMenu" }); 27 | containerEl.createEl("p", { text: "Created by " }).createEl("a", { 28 | text: "Chetachi 👩🏽‍💻", 29 | href: "https://github.com/chetachiezikeuzor", 30 | }); 31 | containerEl.createEl("h2", { text: "Plugin Settings" }); 32 | new Setting(containerEl) 33 | .setName("cMenu append method") 34 | .setDesc( 35 | "Choose where cMenu will append upon regeneration. To see the change, hit the refresh button below, or in the status bar menu." 36 | ) 37 | .addDropdown((dropdown) => { 38 | let methods: Record = {}; 39 | APPEND_METHODS.map((method) => (methods[method] = method)); 40 | dropdown.addOptions(methods); 41 | dropdown 42 | .setValue(this.plugin.settings.appendMethod) 43 | .onChange((appendMethod) => { 44 | this.plugin.settings.appendMethod = appendMethod; 45 | this.plugin.saveSettings(); 46 | }); 47 | }); 48 | new Setting(containerEl) 49 | .setName("cMenu aesthetic") 50 | .setDesc( 51 | "Choose between a glass morphism and default style for cMenu. To see the change, hit the refresh button below, or in the status bar menu." 52 | ) 53 | .addDropdown((dropdown) => { 54 | let aesthetics: Record = {}; 55 | AESTHETIC_STYLES.map( 56 | (aesthetic) => (aesthetics[aesthetic] = aesthetic) 57 | ); 58 | dropdown.addOptions(aesthetics); 59 | dropdown 60 | .setValue(this.plugin.settings.aestheticStyle) 61 | .onChange((aestheticStyle) => { 62 | this.plugin.settings.aestheticStyle = aestheticStyle; 63 | this.plugin.saveSettings(); 64 | }); 65 | }); 66 | new Setting(containerEl) 67 | .setName("cMenu columns") 68 | .setDesc( 69 | "Choose the number of columns per row to display on cMenu. To see the change, hit the refresh button below, or in the status bar menu." 70 | ) 71 | .addSlider((slider) => { 72 | slider 73 | .setLimits(1, 18, 1) 74 | .setValue(this.plugin.settings.cMenuNumRows) 75 | .onChange( 76 | debounce( 77 | async (value) => { 78 | this.plugin.settings.cMenuNumRows = value; 79 | await this.plugin.saveSettings(); 80 | }, 81 | 100, 82 | true 83 | ) 84 | ) 85 | .setDynamicTooltip(); 86 | }); 87 | new Setting(containerEl) 88 | .setName("cMenu refresh") 89 | .setDesc( 90 | "cMenu will only refresh automatically after you have either added or deleted a command from it. To see UI changes to cMenu (above settings changes) use the refresh button. If you forget to refresh in settings, no worries. There is also a refresh button in the cMenu status bar menu." 91 | ) 92 | .addButton((reloadButton) => { 93 | reloadButton 94 | .setIcon("cMenuReload") 95 | .setClass("cMenuSettingsButton") 96 | .setClass("cMenuSettingsButtonRefresh") 97 | .setTooltip("Refresh") 98 | .onClick(() => { 99 | setTimeout(() => { 100 | dispatchEvent(new Event("cMenu-NewCommand")); 101 | }, 100); 102 | console.log(`%ccMenu refreshed`, "color: Violet"); 103 | }); 104 | }); 105 | new Setting(containerEl) 106 | .setName("cMenu commands") 107 | .setDesc( 108 | "Add a command onto cMenu from Obsidian's commands library. To reorder the commands, drag and drop the command items. To delete them, use the delete buttom to the right of the command item. cMenu will not automaticaly refresh after reordering commands. Use the refresh button above." 109 | ) 110 | .addButton((addButton) => { 111 | addButton 112 | .setIcon("cMenuAdd") 113 | .setTooltip("Add") 114 | .setClass("cMenuSettingsButton") 115 | .setClass("cMenuSettingsButtonAdd") 116 | .onClick(() => { 117 | new CommandPicker(this.plugin).open(); 118 | setTimeout(() => { 119 | dispatchEvent(new Event("cMenu-NewCommand")); 120 | }, 100); 121 | }); 122 | }); 123 | const cMenuCommandsContainer = containerEl.createEl("div", { 124 | cls: "cMenuSettingsTabsContainer", 125 | }); 126 | Sortable.create(cMenuCommandsContainer, { 127 | animation: 500, 128 | ghostClass: "sortable-ghost", 129 | chosenClass: "sortable-chosen", 130 | dragClass: "sortable-drag", 131 | dragoverBubble: true, 132 | forceFallback: true, 133 | fallbackClass: "sortable-fallback", 134 | easing: "cubic-bezier(1, 0, 0, 1)", 135 | onSort: (command) => { 136 | const arrayResult = this.plugin.settings.menuCommands; 137 | const [removed] = arrayResult.splice(command.oldIndex, 1); 138 | arrayResult.splice(command.newIndex, 0, removed); 139 | this.plugin.saveSettings(); 140 | console.log(arrayResult); 141 | }, 142 | }); 143 | this.plugin.settings.menuCommands.forEach((newCommand: any) => { 144 | const setting = new Setting(cMenuCommandsContainer) 145 | .setClass("cMenuCommandItem") 146 | .setName(newCommand.name) 147 | .addButton((deleteButton) => { 148 | deleteButton 149 | .setIcon("cMenuDelete") 150 | .setTooltip("Delete") 151 | .setClass("cMenuSettingsButton") 152 | .setClass("cMenuSettingsButtonDelete") 153 | .onClick(async () => { 154 | this.plugin.settings.menuCommands.remove(newCommand); 155 | await this.plugin.saveSettings(); 156 | this.display(); 157 | setTimeout(() => { 158 | dispatchEvent(new Event("cMenu-NewCommand")); 159 | }, 100); 160 | console.log( 161 | `%cCommand '${newCommand.name}' was removed from cMenu`, 162 | "color: #989cab" 163 | ); 164 | }); 165 | }); 166 | setting.nameEl; 167 | }); 168 | const cDonationDiv = containerEl.createEl("div", { 169 | cls: "cDonationSection", 170 | }); 171 | 172 | const credit = createEl("p"); 173 | const donateText = createEl("p"); 174 | donateText.appendText( 175 | "If you like this Plugin and are considering donating to support continued development, use the button below!" 176 | ); 177 | credit.appendText("Created with ❤️ by Chetachi"); 178 | credit.setAttribute("style", "color: var(--text-muted)"); 179 | cDonationDiv.appendChild(donateText); 180 | cDonationDiv.appendChild(credit); 181 | 182 | cDonationDiv.appendChild( 183 | createDonateButton("https://www.buymeacoffee.com/chetachi") 184 | ); 185 | } 186 | } 187 | 188 | const createDonateButton = (link: string): HTMLElement => { 189 | const a = createEl("a"); 190 | a.setAttribute("href", link); 191 | a.addClass("buymeacoffee-chetachi-img"); 192 | a.innerHTML = ``; 193 | return a; 194 | }; 195 | -------------------------------------------------------------------------------- /src/util/statusBarConstants.ts: -------------------------------------------------------------------------------- 1 | export const setMenuVisibility = (cMenuVisibility: boolean) => { 2 | let cMenuModalBar = document.getElementById("cMenuModalBar"); 3 | if (cMenuModalBar) { 4 | cMenuVisibility == false 5 | ? (cMenuModalBar.style.visibility = "hidden") 6 | : (cMenuModalBar.style.visibility = "visible"); 7 | } 8 | }; 9 | 10 | export const setBottomValue = ( 11 | cMenuBottomValue: number, 12 | cMenuNumRows: number 13 | ) => { 14 | let cMenuModalBar = document.getElementById("cMenuModalBar"); 15 | if (cMenuModalBar) { 16 | cMenuModalBar.setAttribute( 17 | "style", 18 | `left: calc(50% - calc(${ 19 | cMenuModalBar.offsetWidth 20 | }px / 2)); bottom: ${cMenuBottomValue}em; grid-template-columns: ${"1fr ".repeat( 21 | cMenuNumRows 22 | )}` 23 | ); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /src/util/util.ts: -------------------------------------------------------------------------------- 1 | export async function wait(delay: number) { 2 | return new Promise((resolve) => setTimeout(resolve, delay)); 3 | } 4 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | CMENU TOOLBAR 3 | ----------------------------------------------------------------*/ 4 | 5 | #cMenuModalBar { 6 | width: auto; 7 | height: auto; 8 | padding: 3px; 9 | display: grid; 10 | user-select: none; 11 | border-radius: 6px; 12 | position: absolute; 13 | transition: 200ms ease; 14 | min-width: fit-content; 15 | justify-content: space-around; 16 | z-index: var(--layer-status-bar); 17 | box-shadow: 0px 3px 32px rgb(31 38 135 / 15%); 18 | border: 1px solid var(--background-modifier-border); 19 | } 20 | 21 | #cMenuModalBar .cMenuCommandItem { 22 | margin: 2px; 23 | border: none; 24 | display: flex; 25 | cursor: pointer; 26 | padding: 5px 6px; 27 | box-shadow: none; 28 | margin-left: 3px; 29 | margin-right: 3px; 30 | position: relative; 31 | border-radius: 3px; 32 | font-size: initial !important; 33 | background-color: var(--background-primary-alt); 34 | } 35 | 36 | #cMenuModalBar button.cMenuCommandItem:hover { 37 | background-color: var(--background-secondary); 38 | } 39 | 40 | #cMenuModalBar button.cMenuCommandItem svg { 41 | width: 1.3em; 42 | height: 1.3em; 43 | } 44 | 45 | /*---------------------------------------------------------------- 46 | CMENU SETTINGS BUTTONS 47 | ----------------------------------------------------------------*/ 48 | 49 | .modal.mod-settings 50 | button:not(.mod-cta):not(.mod-warning).cMenuSettingsButton.cMenuSettingsButtonAdd, 51 | button:not(.mod-cta):not(.mod-warning).cMenuSettingsButton.cMenuSettingsButtonAdd { 52 | background-color: var(--interactive-accent); 53 | } 54 | 55 | .modal.mod-settings 56 | button:not(.mod-cta):not(.mod-warning).cMenuSettingsButton.cMenuSettingsButtonDelete, 57 | button:not(.mod-cta):not(.mod-warning).cMenuSettingsButton.cMenuSettingsButtonDelete { 58 | background-color: #989cab; 59 | } 60 | 61 | .modal.mod-settings 62 | button:not(.mod-cta):not(.mod-warning).cMenuSettingsButton.cMenuSettingsButtonRefresh, 63 | button:not(.mod-cta):not(.mod-warning).cMenuSettingsButton.cMenuSettingsButtonRefresh { 64 | background-color: var(--text-accent); 65 | } 66 | 67 | button.cMenuSettingsButton { 68 | padding: 4px 14px; 69 | border-radius: 6px; 70 | } 71 | 72 | .cMenuSettingsButton svg { 73 | width: 1.3em; 74 | height: 1.3em; 75 | display: flex; 76 | } 77 | 78 | /*---------------------------------------------------------------- 79 | CMENU SETTING ITEMS 80 | ----------------------------------------------------------------*/ 81 | .setting-item.cMenuCommandItem:first-child { 82 | padding-top: 18px; 83 | } 84 | 85 | .cMenuCommandItem { 86 | cursor: grab; 87 | padding: 18px 0 18px 0; 88 | } 89 | 90 | .sortable-fallback { 91 | cursor: grabbing; 92 | box-shadow: 0px 3px 32px rgb(31 38 135 / 15%); 93 | } 94 | 95 | .sortable-grab { 96 | cursor: grabbing !important; 97 | } 98 | 99 | .sortable-ghost { 100 | opacity: 0.4; 101 | cursor: grabbing; 102 | } 103 | 104 | .sortable-chosen { 105 | cursor: grabbing; 106 | padding: 18px 0 18px 18px; 107 | background-color: var(--background-primary); 108 | } 109 | 110 | .sortable-drag { 111 | cursor: grabbing; 112 | box-shadow: 0px 3px 32px rgb(31 38 135 / 15%); 113 | } 114 | 115 | .cMenuSettingsTabsContainer { 116 | border-top: 1px solid var(--background-modifier-border); 117 | border-bottom: 1px solid var(--background-modifier-border); 118 | } 119 | 120 | /*---------------------------------------------------------------- 121 | CMENU CLASS CHANGES 122 | ----------------------------------------------------------------*/ 123 | 124 | .cMenuGlassAesthetic { 125 | backdrop-filter: blur(8px); 126 | -webkit-backdrop-filter: blur(8px); 127 | } 128 | 129 | .cMenuDefaultAesthetic { 130 | background-color: var(--background-primary); 131 | } 132 | 133 | /*---------------------------------------------------------------- 134 | CMENU ICONS 135 | ----------------------------------------------------------------*/ 136 | 137 | .cMenuIconPick { 138 | line-height: normal; 139 | vertical-align: middle; 140 | margin-right: 8px; 141 | } 142 | 143 | .cMenuIconPick svg { 144 | width: 17px; 145 | height: 17px; 146 | } 147 | 148 | /*---------------------------------------------------------------- 149 | CMENU STATUS BAR MENU 150 | ----------------------------------------------------------------*/ 151 | 152 | .cMenu-statusbar-menu { 153 | width: 200px; 154 | } 155 | 156 | .cMenu-statusbar-menu .menu-item-icon { 157 | display: none; 158 | } 159 | 160 | .cMenu-statusbar-menu .menu-item { 161 | display: flex; 162 | align-items: center; 163 | justify-content: space-between; 164 | flex-direction: row; 165 | } 166 | 167 | .cMenu-statusbar-menu .menu-item.settings-item { 168 | font-size: 12px; 169 | text-align: center; 170 | line-height: 1; 171 | border-radius: 5px; 172 | height: auto; 173 | padding: 8px 5px 0px 5px; 174 | margin: 0 auto; 175 | width: fit-content; 176 | color: var(--text-faint); 177 | } 178 | 179 | .cMenu-statusbar-menu .menu-item.settings-item .menu-item-title { 180 | text-align: center; 181 | } 182 | 183 | .cMenu-statusbar-menu .menu-item:hover, 184 | .cMenu-statusbar-menu .menu-item .selected:hover, 185 | .cMenu-statusbar-menu .menu-item.selected:not(.is-disabled):not(.is-label) { 186 | background-color: transparent; 187 | } 188 | 189 | .cMenu-statusbar-menu .menu-item-title { 190 | margin-right: 10px; 191 | } 192 | 193 | .cMenu-statusbar-menu .slider { 194 | width: 100%; 195 | } 196 | 197 | .cMenu-statusbar-menu .menu-item.buttonitem { 198 | padding-top: 10px; 199 | padding-bottom: 4px; 200 | height: fit-content; 201 | } 202 | 203 | .cMenu-statusbar-menu .menu-item.buttonitem button.cMenuSettingsButton { 204 | margin: 0; 205 | } 206 | 207 | /*---------------------------------------------------------------- 208 | CMENU STATUS BAR BUTTONS 209 | ----------------------------------------------------------------*/ 210 | 211 | .cMenu-statusbar-button { 212 | cursor: pointer; 213 | display: flex; 214 | align-items: center; 215 | line-height: 1; 216 | } 217 | 218 | .cMenu-statusbar-button svg { 219 | display: flex; 220 | width: 1.3em; 221 | height: 1.3em; 222 | } 223 | 224 | /*---------------------------------------------------------------- 225 | CMENU SUPPORT 226 | ----------------------------------------------------------------*/ 227 | 228 | .cDonationSection { 229 | width: 60%; 230 | height: 50vh; 231 | margin: 0 auto; 232 | text-align: center; 233 | color: var(--text-normal); 234 | } 235 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "src": ["src/*"] 6 | }, 7 | "module": "ESNext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "allowJs": true, 11 | "noImplicitAny": true, 12 | "moduleResolution": "node", 13 | "importHelpers": true, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "esModuleInterop": true, 17 | "allowSyntheticDefaultImports": true, 18 | "types": ["node"], 19 | "lib": ["dom", "es5", "scripthost", "es2015"] 20 | }, 21 | "include": ["**/*.ts", "main.js/*"], 22 | "exclude": ["node_modules/*"] 23 | } 24 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.1.2": "0.9.12" 3 | } 4 | --------------------------------------------------------------------------------