├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .prettierrc ├── README.md ├── assets ├── Color_Picker.png ├── Mermaid.png ├── Obsidian_Overview.png ├── Obsidian_Overview.svg ├── OrderableAndExpandableRows.gif ├── Panel_Overview.png ├── Panel_Overview_Greek_Letters.png ├── Panel_Overview_Html.png ├── Panel_Overview_Latex.png ├── Suggestion_Window_How_to_use_with_hotkey.gif ├── Suggestion_Window_change_hot_key.gif ├── calloutsMenu.jpg └── icons │ ├── Alpha.svg │ ├── Beta.svg │ ├── Chi.svg │ ├── Delta.svg │ ├── Epsilon.svg │ ├── Eta.svg │ ├── Gamma.svg │ ├── Iota.svg │ ├── Kappa.svg │ ├── Lambda.svg │ ├── LatexEquation.svg │ ├── LatexInlineEquation.svg │ ├── My.svg │ ├── Ny.svg │ ├── Omega.svg │ ├── Omikron.svg │ ├── Phi.svg │ ├── Pi.svg │ ├── Psi.svg │ ├── Rho.svg │ ├── Sigma.svg │ ├── Tau.svg │ ├── Theta.svg │ ├── Xi.svg │ ├── Ypsilon.svg │ ├── Zeta.svg │ ├── alpha.svg │ ├── beta.svg │ ├── chi.svg │ ├── delta.svg │ ├── epsilon.svg │ ├── epsilonV2.svg │ ├── eta.svg │ ├── gamma.svg │ ├── iota.svg │ ├── kappa.svg │ ├── kappaV2.svg │ ├── lambda.svg │ ├── my.svg │ ├── ny.svg │ ├── omega.svg │ ├── omikron.svg │ ├── phi.svg │ ├── pi.svg │ ├── psi.svg │ ├── rho.svg │ ├── rhoV2.svg │ ├── sigma.svg │ ├── tau.svg │ ├── theta.svg │ ├── thetaV2.svg │ ├── xi.svg │ ├── ypsilon.svg │ └── zeta.svg ├── build ├── main.js ├── manifest.json ├── styles.css └── versions.json ├── components └── SidePane │ ├── Colors.ts │ ├── GreekLetters.ts │ ├── Header.ts │ ├── Html.ts │ ├── Latex.ts │ └── TextEditor.ts ├── formatters └── colorFormatter.ts ├── manifest.json ├── nodemon.json ├── obsidan_default_styles.css ├── package.json ├── rollup.config.js ├── rollup.production.config.js ├── src ├── CalloutsListView.ts ├── CommandListView.ts ├── Events.ts ├── SidePanelControlView.ts ├── calloutsFormatter.ts ├── formatter.ts ├── generalFunctions.ts ├── greekFormatter.ts ├── htmlFormatter.ts ├── iconPaths.ts ├── icons.ts ├── latexFormatter.ts └── main.ts ├── styles.css ├── testings.md ├── tsconfig.json ├── versions.json └── yarn.lock /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #custom 2 | Untitled.md 3 | .obsidian/ 4 | .trash/ 5 | 6 | # Intellij 7 | *.iml 8 | .idea 9 | 10 | # npm 11 | node_modules 12 | package-lock.json 13 | 14 | # build 15 | main.js 16 | *.js.map 17 | 18 | # reset git after change 19 | # git rm -rf --cached . 20 | # git add . -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "tabWidth": 2, 4 | "trailingComma": "all", 5 | "overrides": [ 6 | { 7 | "files": ".prettierrc", 8 | "options": { 9 | "parser": "json" 10 | } 11 | }, 12 | { 13 | "files": "*.yml", 14 | "options": { 15 | "tabWidth": 2, 16 | "singleQuote": false 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > # PLUGIN NOT MAINTAINED anymore 2 | > If you want to takover the plugin, write me! 3 | 4 | 5 | 6 | ---- 7 | # Obsidian Markdown Formatting Assistant 8 | 9 | > This Plugin provides easy to use snippets for Markdown, HTML and Latex and a color picker which shows the history of last used colors. Furthermore, it is possible to save any color you want. 10 | > Version 0.4.0 11 | 12 | > If you find a Bug or have a feature request: https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin/issues 13 | 14 | ![](assets/Obsidian_Overview.png) 15 | 16 | ## Side Panel 17 | 18 | The Side Panel can be opened by the Ribbon Icon on the left side. If you changed the side (left or right) of the panel in the settings, just hit this butten/icon again and it will reload on the right side. 19 | 20 | ### Order and expansion of the Sections 21 | 22 | It is possible to change the order of the sections according to the personal wishes. Furthermore it is possible to expand and shrink every section to keep the overview. 23 | 24 | ![](assets/OrderableAndExpandableRows.gif) 25 | 26 | ### Markdown Section 27 | 28 | ![](assets/Panel_Overview.png) 29 | 30 | ### HTML Section 31 | 32 | ![](assets/Panel_Overview_Html.png) 33 | 34 | ### Latex Section 35 | 36 | > Latex Functions only work if they are in a latex equation section like $...$ or $$...$$. 37 | 38 | ![](assets/Panel_Overview_Latex.png) 39 | 40 | ### Greek Letters Section 41 | 42 | > Greek Letters only work if they are in a latex equation section like $...$ or $$...$$. 43 | 44 | ![](assets/Panel_Overview_Greek_Letters.png) 45 | 46 | ### Callouts Section 47 | 48 | ![](assets/calloutsMenu.jpg) 49 | 50 | ## Suggestion Window with Shortcut 51 | 52 | This plugin does have a default shortcut `ALT+Q` which opens a Suggestion Window with all commands of this plugin (except colors and callouts). Once you get used to it, you want never miss it again. Furthermore, this way there is no need to ever leave your keyboard! 53 | 54 | With the default shortcut `ALT-C` a Suggestion Window for Callouts is opened with the same functionality like the common Suggestion Window. 55 | 56 | ### How it works 57 | Just press the shortcut/hotkey `ALT+Q` on any place. It doesn't matter if you are on a specific position or selected some text you want to change. Then enter the name of the command you want to apply. After a few letters your wished command should be suggested in the top 5. 58 | 59 | ![](assets/Suggestion_Window_How_to_use_with_hotkey.gif) 60 | 61 | ### How to change the shortcut/hotkey 62 | 63 | The shortcut/hotkey `ALT+Q` was selected becaus it can be comfortable reached with just one hand, but you can change it to what ever you want. 64 | 65 | ![](assets/Suggestion_Window_change_hot_key.gif) 66 | ## Color Picker 67 | 68 | ### Select a color 69 | 70 | The color picker provides an easy and fast workflow to work with colors. If you pick a color with the `Select a Color` button and leave the window (by clicking outside the color picker), the selected color will be inserted at the current courser position. In addition, it will be copied to the clipboard. 71 | 72 | ### Color History 73 | 74 | Furthermore, the color picker saves the history of the last 10 used colors. 75 | 76 | ### Saved Colors 77 | 78 | To Save the current color even if obsidian will be closed, just click the `Save Color` button. 79 | 80 | ### Sort saved Colors 81 | 82 | All saved colors can be sorted via drop a catch. 83 | 84 | ### Delete a Color 85 | 86 | To delete a saved or last used color just click it with the right mouse button. 87 | 88 | ### Additional Formats 89 | 90 | For a even easier handling you can select additional options to what should be added to the color. 91 | 92 | #### Options 93 | 94 | - Add "color: {your color}" 95 | - ex. `color: #ffffff` 96 | - Add "background-color: {your color} 97 | - ex. `background-color: #ffffff` 98 | - Add tag: "style={your color} 99 | - This option is only helpful, if you also select one of both of the other options like: 100 | - ex. `style="background-color: #ff0000"` 101 | - Add HTML: "`{selected text}`" 102 | - Useful for quickly coloring text. 103 | - ex. `Hello World` 104 | 105 | ![](assets/Color_Picker.png) 106 | 107 | ## Settings 108 | 109 | - Side Pane Side 110 | 111 | - default: right 112 | - options: right, left 113 | - Defines the side of the side pane. By default the side pane will open on the right side/leaf. 114 | 115 | - Saved Colors 116 | - default: "" 117 | - options: any hex color. One hex (#ffffff) color per line. 118 | - Manages the saved colors. Colors can be added, deleted, edited. The order is also considered. 119 | 120 | ## Changelog 121 | - Version: 0.4.1 122 | - Added Callouts-Support 123 | - Version: 0.4.0 124 | - Updated the plugin to the new Obsidian API 0.15.x 125 | - Replace command language with a suggestion window triggered by a hotkey 126 | - Fixed the wrong courser position after use of the header buttons/command (h1,h2, ...) 127 | - Version: 0.3.2 128 | - Additional options for the color picker 129 | - New Highlight Button in the Text Edit section and command line 130 | - Version 0.3.1 131 | - Changeable order of the sections 132 | - Expandable sections 133 | - Corrected the latex `\$\$` and `\$\$\$\$` buttons as they were switched 134 | - Version 0.3.0 135 | - added a Latex and Greek Letters section 136 | - Version 0.2.2 137 | - added /mermaid snipplet to generate mermaid code block - allows drawing diagrams ![](assets/Mermaid.png) 138 | - Version 0.2.1 139 | ⁻ Some Bug Fixes 140 | - No input preview mode 141 | - Highlighting of the html buttons when hover 142 | - Replace selection when insert colors. 143 | - Saved Colors can be added and edited in the settings. 144 | - New HTML Tags `
` and `` 145 | - Vesion 0.2.0 146 | - Added support for HTML snippets in command language and in side pane. 147 | - Added a color picker 148 | - Vesion 0.1.2 149 | - Inital plugin 150 | -------------------------------------------------------------------------------- /assets/Color_Picker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Color_Picker.png -------------------------------------------------------------------------------- /assets/Mermaid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Mermaid.png -------------------------------------------------------------------------------- /assets/Obsidian_Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Obsidian_Overview.png -------------------------------------------------------------------------------- /assets/OrderableAndExpandableRows.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/OrderableAndExpandableRows.gif -------------------------------------------------------------------------------- /assets/Panel_Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Panel_Overview.png -------------------------------------------------------------------------------- /assets/Panel_Overview_Greek_Letters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Panel_Overview_Greek_Letters.png -------------------------------------------------------------------------------- /assets/Panel_Overview_Html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Panel_Overview_Html.png -------------------------------------------------------------------------------- /assets/Panel_Overview_Latex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Panel_Overview_Latex.png -------------------------------------------------------------------------------- /assets/Suggestion_Window_How_to_use_with_hotkey.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Suggestion_Window_How_to_use_with_hotkey.gif -------------------------------------------------------------------------------- /assets/Suggestion_Window_change_hot_key.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/Suggestion_Window_change_hot_key.gif -------------------------------------------------------------------------------- /assets/calloutsMenu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/calloutsMenu.jpg -------------------------------------------------------------------------------- /assets/icons/Alpha.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Beta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Chi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Delta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Epsilon.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Eta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Gamma.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Iota.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Kappa.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Lambda.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/LatexEquation.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /assets/icons/LatexInlineEquation.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /assets/icons/My.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Ny.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Omega.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Omikron.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Phi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Pi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Psi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Rho.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Sigma.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Tau.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Theta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Xi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Ypsilon.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/Zeta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/alpha.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /assets/icons/beta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/chi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/delta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/epsilon.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/epsilonV2.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/eta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/gamma.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/iota.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/kappa.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 60 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /assets/icons/kappaV2.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/lambda.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/my.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/ny.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/omega.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/omikron.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/phi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/pi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/psi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/rho.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/rhoV2.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/sigma.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/tau.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/theta.svg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/icons/theta.svg -------------------------------------------------------------------------------- /assets/icons/thetaV2.svg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/assets/icons/thetaV2.svg -------------------------------------------------------------------------------- /assets/icons/xi.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/ypsilon.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /assets/icons/zeta.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 55 | 59 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /build/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "obsidian-markdown-formatting-assistant-plugin", 3 | "name": "Markdown Formatting Assistant", 4 | "version": "0.4.1", 5 | "minAppVersion": "0.15.6", 6 | "description": "This Plugin provides a simple Editor for Markdown, HTML and Colors and in addition a command interface. The command interface facilitate a faster workflow.", 7 | "author": "Reocin", 8 | "authorUrl": "https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin", 9 | "isDesktopOnly": false 10 | } 11 | -------------------------------------------------------------------------------- /build/styles.css: -------------------------------------------------------------------------------- 1 | /* Sets all the text color to red! */ 2 | .nav-action-button { 3 | color: var(--text-muted); 4 | cursor: pointer; 5 | padding: 0px; 6 | margin: 5px; 7 | border-radius: 4px; 8 | } 9 | 10 | .nav-action-text-button { 11 | color: var(--text-muted); 12 | cursor: pointer; 13 | padding: 5px; 14 | margin: 4px; 15 | border-radius: 4px; 16 | text-align: center; 17 | border: 1px solid; 18 | } 19 | .nav-action-text-button.is-active { 20 | background-color: var(--interactive-accent); 21 | color: var(--text-on-accent); 22 | } 23 | .nav-action-text-button.is-active:hover { 24 | color: var(--text-on-accent); 25 | } 26 | .nav-action-text-button:hover { 27 | color: var(--text-accent); 28 | } 29 | 30 | .color-icon { 31 | color: var(--text-muted); 32 | cursor: pointer; 33 | width: 16px; 34 | min-width: 16px; 35 | max-width: 16px; 36 | height: 16px; 37 | min-height: 16px; 38 | max-height: 16px; 39 | margin: 3px; 40 | display: inline-block; 41 | border-radius: 4px; 42 | } 43 | 44 | .command-list-view-row { 45 | display: flex; 46 | } 47 | .command-list-view-container { 48 | min-width: 60px; 49 | display: flex; 50 | } 51 | 52 | .command-list-view-icon { 53 | height: 24px; 54 | max-height: 24px; 55 | border: 1px solid gray; 56 | margin-right: auto; 57 | } 58 | 59 | .command-list-view-text { 60 | padding-left: 12px; 61 | color: #c7254e; 62 | } 63 | -------------------------------------------------------------------------------- /build/versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "0.1.0": "0.10.9", 3 | "0.1.1": "0.10.9", 4 | "0.1.2": "0.10.9", 5 | "0.2.0": "0.10.9", 6 | "0.2.1": "0.10.9", 7 | "0.2.2": "0.10.9", 8 | "0.3.0": "0.10.9", 9 | "0.3.1": "0.12.4", 10 | "0.3.2": "0.12.4", 11 | "0.4.0": "0.15.6", 12 | "0.4.1": "0.15.6" 13 | } 14 | -------------------------------------------------------------------------------- /components/SidePane/Colors.ts: -------------------------------------------------------------------------------- 1 | // import { checkIfMarkdownSource } from '../../src/generalFunctions'; 2 | // import { colorFormatter } from '../../formatters/colorFormatter'; 3 | 4 | // import { 5 | // ButtonComponent, 6 | // ItemView, 7 | // Notice, 8 | // TFile, 9 | // WorkspaceLeaf, 10 | // } from 'obsidian'; 11 | 12 | // export function addColorBody(mainDiv: HTMLElement, SidePanelControlView: ItemView ) { 13 | // const insertColor = (color: string) => { 14 | // const leaf = this.app.workspace.getMostRecentLeaf(); 15 | // let editor = null; 16 | // if (checkIfMarkdownSource(leaf)) { 17 | // // @ts-ignore 18 | // editor = leaf.view.sourceMode.cmEditor; 19 | // colorFormatter(editor, color); 20 | // editor.focus(); 21 | // } 22 | // }; 23 | 24 | // const drawLastSelectedColorIcons = (container: HTMLElement = null) => { 25 | // if (!container) 26 | // container = document.getElementById('lastSelectedColorsDiv'); 27 | // container.textContent = ''; 28 | 29 | // const table = container.createEl('table'); 30 | // const tbody = table.createEl('tbody'); 31 | // let row: HTMLElement; 32 | // R.reverse(SidePanelControlView.lastColors).forEach((color, index) => { 33 | // if (index % 10 === 0) row = tbody.createEl('tr'); 34 | // const colorBox = row.createEl('td'); 35 | // colorBox.classList.add('color-icon'); 36 | // colorBox.style.backgroundColor = color; 37 | 38 | // colorBox.onClickEvent((ev) => { 39 | // if (ev.type === 'click') { 40 | // insertColor(color); 41 | // } else { 42 | // SidePanelControlView.lastColors = R.without( 43 | // [color], 44 | // SidePanelControlView.lastColors, 45 | // ); 46 | // drawLastSelectedColorIcons(); 47 | // } 48 | // }); 49 | // }); 50 | // }; 51 | 52 | // const drawLastSavedColorIcons = (container: HTMLElement = null) => { 53 | // if (!container) container = document.getElementById('lastSavedColorsDiv'); 54 | 55 | // container.textContent = ''; 56 | // const table = container.createEl('table'); 57 | // const tbody = table.createEl('tbody'); 58 | // let row: HTMLElement; 59 | 60 | // R.reverse(this.plugin.settings.savedColors).forEach((color, index) => { 61 | // if (index % 10 === 0) row = tbody.createEl('tr'); 62 | // const colorBox = row.createEl('td'); 63 | // colorBox.id = 'lastSavedColorsDiv' + color; 64 | // colorBox.classList.add('color-icon'); 65 | // colorBox.style.backgroundColor = color; 66 | // colorBox.draggable = true; 67 | 68 | // colorBox.onClickEvent(async (ev) => { 69 | // if (ev.type === 'click') { 70 | // insertColor(color); 71 | // } else { 72 | // this.plugin.settings.savedColors = R.without( 73 | // [color], 74 | // this.plugin.settings.savedColors, 75 | // ); 76 | // await this.plugin.saveSettings(); 77 | // drawLastSavedColorIcons(); 78 | // } 79 | // }); 80 | // colorBox.ondragstart = (event) => { 81 | // // @ts-ignore 82 | // this.dragStartColor = event.target.id.replace( 83 | // 'lastSavedColorsDiv', 84 | // '', 85 | // ); 86 | // }; 87 | // colorBox.ondrop = async (event) => { 88 | // if (event && event.target) { 89 | // // @ts-ignore 90 | // const id = event.target.id; 91 | // if (id.indexOf('lastSavedColorsDiv') === 0) { 92 | // const startColor = this.dragStartColor; 93 | // const endColor = id.replace('lastSavedColorsDiv', ''); 94 | 95 | // const startIndex = R.indexOf( 96 | // startColor, 97 | // this.plugin.settings.savedColors, 98 | // ); 99 | // const endIndex = R.indexOf( 100 | // endColor, 101 | // this.plugin.settings.savedColors, 102 | // ); 103 | // this.plugin.settings.savedColors[startIndex] = endColor; 104 | // this.plugin.settings.savedColors[endIndex] = startColor; 105 | // await this.plugin.saveSettings(); 106 | // drawLastSavedColorIcons(); 107 | // } 108 | // } 109 | // }; 110 | // colorBox.ondragover = (event) => { 111 | // event.preventDefault(); 112 | // }; 113 | // }); 114 | // }; 115 | 116 | // const colorSection = mainDiv.createDiv(); 117 | // const colorSelector = colorSection.createDiv(); 118 | // colorSelector.style.backgroundColor = R.last( 119 | // SidePanelControlView.lastColors, 120 | // ); 121 | // colorSelector.style.height = '16px'; 122 | // colorSelector.style.borderRadius = '8px'; 123 | // colorSelector.style.padding = '5px'; 124 | // colorSelector.style.margin = '4px'; 125 | // colorSelector.style.marginBottom = '10px'; 126 | // const colorInput = colorSelector.createEl('input'); 127 | // colorInput.id = 'colorInput'; 128 | // colorInput.type = 'color'; 129 | // colorInput.value = R.last(SidePanelControlView.lastColors); 130 | // colorInput.style.visibility = 'hidden'; 131 | // colorInput.style.padding = '0'; 132 | // colorInput.style.margin = '0'; 133 | // // colorInput.style.display = 'block'; 134 | // // colorInput.style.opacity = '0'; 135 | // colorInput.addEventListener('input', (ev) => { 136 | // // @ts-ignore 137 | // const color = ev.target.value; 138 | // colorSelector.style.backgroundColor = color; 139 | // }); 140 | // colorInput.addEventListener( 141 | // 'change', 142 | // (ev) => { 143 | // // @ts-ignore 144 | // const color = ev.target.value; 145 | // // @ts-ignore 146 | // SidePanelControlView.lastColors = R.pipe( 147 | // R.without([color]), 148 | // R.append(color), 149 | // R.takeLast(10), 150 | // )(SidePanelControlView.lastColors); 151 | // drawLastSelectedColorIcons(); 152 | // insertColor(color); 153 | // colorSelector.style.backgroundColor = color; 154 | 155 | // navigator.clipboard.writeText(color).then( 156 | // () => { 157 | // // @ts-ignore 158 | // new Notice('Copied ' + color + ' to clipboard'); 159 | // }, 160 | // () => { 161 | // new Notice('Could not copy the color to clipboard'); 162 | // }, 163 | // ); 164 | // }, 165 | // false, 166 | // ); 167 | 168 | // const colorButton = colorSection.createEl('label'); 169 | // colorButton.classList.add('nav-action-text-button'); 170 | // colorButton.appendText('Select a Color'); 171 | // colorButton.style.display = 'block'; 172 | // colorButton.htmlFor = 'colorInput'; 173 | 174 | // const colorSaveButton = colorSection.createEl('div'); 175 | // colorSaveButton.classList.add('nav-action-text-button'); 176 | // colorSaveButton.appendText('Save Color'); 177 | // colorSaveButton.style.display = 'block'; 178 | // colorSaveButton.onClickEvent(async (ev) => { 179 | // const color = R.last(SidePanelControlView.lastColors); 180 | // this.plugin.settings.savedColors = R.pipe( 181 | // R.without([color]), 182 | // R.append(color), 183 | // )(this.plugin.settings.savedColors); 184 | // drawLastSavedColorIcons(); 185 | // await this.plugin.saveSettings(); 186 | // }); 187 | 188 | // const lastSelectedColorsTitle = colorSection.createEl('p'); 189 | // lastSelectedColorsTitle.appendText('Last used colors:'); 190 | // lastSelectedColorsTitle.style.marginBottom = '0px'; 191 | 192 | // const lastSelectedColors = colorSection.createEl('div'); 193 | // lastSelectedColors.id = 'lastSelectedColorsDiv'; 194 | // lastSelectedColors.style.display = 'flex'; 195 | 196 | // drawLastSelectedColorIcons(lastSelectedColors); 197 | 198 | // const lastSavedColorsTitle = colorSection.createEl('p'); 199 | // lastSavedColorsTitle.appendText('Saved Colors:'); 200 | // lastSavedColorsTitle.style.marginBottom = '0px'; 201 | 202 | // const settingsInfo = colorSection.createEl('p'); 203 | // settingsInfo.appendText( 204 | // 'Saved colors can be directly edited in the settings.', 205 | // ); 206 | // settingsInfo.style.textAlign = 'left'; 207 | // settingsInfo.style.fontSize = '10px'; 208 | // settingsInfo.style.marginTop = '0px'; 209 | 210 | // const lastSavedColors = colorSection.createEl('div'); 211 | // lastSavedColors.id = 'lastSavedColorsDiv'; 212 | // lastSavedColors.style.display = 'flex'; 213 | 214 | // drawLastSavedColorIcons(lastSavedColors); 215 | 216 | // const info = colorSection.createEl('p'); 217 | // info.style.textAlign = 'center'; 218 | // info.style.marginTop = '10px'; 219 | // info.style.marginBottom = '10px'; 220 | 221 | // const link = info.createEl('a'); 222 | // link.appendText('Do you need some Help?'); 223 | // link.style.textAlign = 'center'; 224 | 225 | // link.style.fontSize = '10px'; 226 | // link.href = 227 | // 'https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin#color-picker'; 228 | // } 229 | -------------------------------------------------------------------------------- /components/SidePane/GreekLetters.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/components/SidePane/GreekLetters.ts -------------------------------------------------------------------------------- /components/SidePane/Header.ts: -------------------------------------------------------------------------------- 1 | import MarkdownAutocompletePlugin from '../../src/main'; 2 | import * as R from 'ramda'; 3 | import { svgToElement } from '../../src/icons'; 4 | 5 | const getRegion = (name: string, plugin: MarkdownAutocompletePlugin) => { 6 | return plugin.settings.regionSettings.find((item) => item.name === name); 7 | }; 8 | 9 | const createHeaderDiv = (mainDiv: HTMLElement, regionName: string) => { 10 | let header = mainDiv.createEl('div'); 11 | header.id = 'lastSavedHeaderDiv' + regionName; 12 | 13 | header.style.width = '100%'; 14 | // header.style.border = '2px solid white'; 15 | header.style.display = 'flex'; 16 | header.style.flexWrap = 'nowrap'; 17 | header.style.alignContent = 'center'; 18 | header.style.position = 'relative'; 19 | header.style.cursor = 'move'; 20 | header.draggable = true; 21 | 22 | return header; 23 | }; 24 | 25 | const addDragAndDropForHeader = ( 26 | header: HTMLElement, 27 | plugin: MarkdownAutocompletePlugin, 28 | drawContentOfRootElement: any, 29 | ) => { 30 | header.ondragstart = (event) => { 31 | console.log('ondragstart'); 32 | // @ts-ignore 33 | const sectionId = event.target.id.replace('lastSavedHeaderDiv', ''); 34 | 35 | event.dataTransfer.setData('sectionHeaderMoveId', sectionId); 36 | }; 37 | 38 | const onDrop = async (event: DragEvent) => { 39 | const getId = R.pipe( 40 | R.find(R.pipe(R.prop('id'), R.contains('lastSavedHeaderDiv'))), 41 | R.prop('id'), 42 | R.replace('lastSavedHeaderDiv', ''), 43 | ); 44 | 45 | const start = event.dataTransfer.getData('sectionHeaderMoveId'); 46 | // @ts-ignore 47 | const end = getId(event.path); 48 | 49 | console.log(start, end); 50 | 51 | if (end && plugin.settings.aviabileRegions.contains(end) && start !== end) { 52 | const startIndex = R.findIndex( 53 | R.propEq('name', start), 54 | plugin.settings.regionSettings, 55 | ); 56 | const endIndex = R.findIndex( 57 | R.propEq('name', end), 58 | plugin.settings.regionSettings, 59 | ); 60 | 61 | console.log(startIndex, endIndex); 62 | 63 | const startRegion = plugin.settings.regionSettings[startIndex]; 64 | plugin.settings.regionSettings[startIndex] = 65 | plugin.settings.regionSettings[endIndex]; 66 | plugin.settings.regionSettings[endIndex] = startRegion; 67 | await plugin.saveSettings(); 68 | drawContentOfRootElement(); 69 | } 70 | event.preventDefault(); 71 | }; 72 | 73 | header.ondragover = async (event) => { 74 | event.preventDefault(); 75 | }; 76 | 77 | header.ondrop = onDrop; 78 | }; 79 | 80 | const addBurgerButton = (header: HTMLElement) => { 81 | const burgerButton = header.createDiv({ cls: 'nav-action-button' }); 82 | burgerButton.appendChild(svgToElement('menu')); 83 | burgerButton.style.display = 'flex'; 84 | burgerButton.style.flexWrap = 'nowrap'; 85 | burgerButton.style.alignContent = 'center'; 86 | burgerButton.style.transform = 'scale(0.8,0.8)'; 87 | burgerButton.style.cursor = 'move'; 88 | 89 | return burgerButton; 90 | }; 91 | 92 | const addTitle = (header: HTMLElement, sectionTitle: string) => { 93 | const title = header.createEl('h4'); 94 | title.appendText(sectionTitle); 95 | title.style.flexDirection = 'column'; 96 | title.style.textAlign = 'left'; 97 | title.style.margin = '0px'; 98 | title.style.display = 'flex'; 99 | title.style.flexWrap = 'nowrap'; 100 | title.style.justifyContent = 'center'; 101 | return title; 102 | }; 103 | 104 | const addArrowButton = (div: HTMLElement) => { 105 | let arrowButton = div.createDiv({ cls: 'nav-action-button' }); 106 | arrowButton.appendChild(svgToElement('expandArrowDown')); 107 | arrowButton.style.position = 'absolute'; 108 | arrowButton.style.right = '0px'; 109 | arrowButton.style.top = '0px'; 110 | arrowButton.style.bottom = '0px'; 111 | arrowButton.style.marginTop = 'auto'; 112 | arrowButton.style.marginBottom = 'auto'; 113 | arrowButton.style.width = '24px'; 114 | arrowButton.style.height = '24px'; 115 | 116 | return arrowButton; 117 | }; 118 | 119 | const addArrowButtonEvent = ( 120 | arrowButton: HTMLElement, 121 | content: HTMLElement, 122 | regionName: string, 123 | plugin: MarkdownAutocompletePlugin, 124 | ) => { 125 | arrowButton.onClickEvent(async (e) => { 126 | const region = getRegion(regionName, plugin); 127 | 128 | if (region && region.active) { 129 | if (!region.visible) { 130 | content.style.display = 'block'; 131 | arrowButton.innerHTML = null; 132 | arrowButton.appendChild(svgToElement('expandArrowUp')); 133 | region.visible = true; 134 | } else { 135 | content.style.display = 'none'; 136 | arrowButton.innerHTML = null; 137 | arrowButton.appendChild(svgToElement('expandArrowDown')); 138 | region.visible = false; 139 | } 140 | 141 | return await plugin.saveSettings(); 142 | } 143 | }); 144 | }; 145 | 146 | const addHorizontalRule = (div: HTMLElement) => { 147 | let hr = div.createEl('hr'); 148 | hr.style.marginTop = '0px'; 149 | hr.style.marginBottom = '10px'; 150 | 151 | return hr; 152 | }; 153 | 154 | export function addSelectableHeader( 155 | mainDiv: HTMLElement, 156 | regionName: string, 157 | sectionTitle: string, 158 | plugin: MarkdownAutocompletePlugin, 159 | drawContentOfRootElement: any, 160 | ) { 161 | const header = createHeaderDiv(mainDiv, regionName); 162 | addHorizontalRule(mainDiv); 163 | addDragAndDropForHeader(header, plugin, drawContentOfRootElement); 164 | addBurgerButton(header); 165 | addTitle(header, sectionTitle); 166 | const arrowButton = addArrowButton(header); 167 | 168 | let content = mainDiv.createEl('div'); 169 | 170 | const region = getRegion(regionName, plugin); 171 | if (region && region.active && region.visible) { 172 | content.style.display = 'block'; 173 | } else { 174 | content.style.display = 'none'; 175 | } 176 | 177 | addArrowButtonEvent(arrowButton, content, regionName, plugin); 178 | 179 | return content; 180 | } 181 | -------------------------------------------------------------------------------- /components/SidePane/Html.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/components/SidePane/Html.ts -------------------------------------------------------------------------------- /components/SidePane/Latex.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/components/SidePane/Latex.ts -------------------------------------------------------------------------------- /components/SidePane/TextEditor.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reocin/obsidian-markdown-formatting-assistant-plugin/cf42ac707c01fed04cb90ba09b82015f82706e22/components/SidePane/TextEditor.ts -------------------------------------------------------------------------------- /formatters/colorFormatter.ts: -------------------------------------------------------------------------------- 1 | import { checkIfSelection } from '../src/generalFunctions'; 2 | 3 | export function colorFormatter(editor: CodeMirror.Editor, color: string) { 4 | if (editor) { 5 | const isSelection = checkIfSelection(editor); 6 | const selection = editor.getSelection(); 7 | const curserStart = editor.getCursor('from'); 8 | const curserEnd = editor.getCursor('to'); 9 | const line = editor.getLine(curserStart.line); 10 | 11 | editor.focus(); 12 | 13 | if (isSelection) { 14 | let replacment = selection.trim(); 15 | 16 | editor.replaceSelection(color); 17 | editor.setCursor(curserStart); 18 | } else { 19 | editor.replaceRange(color, curserStart); 20 | editor.setCursor(curserStart); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "obsidian-markdown-formatting-assistant-plugin", 3 | "name": "Markdown Formatting Assistant", 4 | "version": "0.4.1", 5 | "minAppVersion": "0.15.6", 6 | "description": "This Plugin provides a simple Editor for Markdown, HTML and Colors and in addition a command interface. The command interface facilitate a faster workflow.", 7 | "author": "Reocin", 8 | "authorUrl": "https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin", 9 | "isDesktopOnly": false 10 | } 11 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "restartable": "rs", 3 | "ignore": [ 4 | ".git", 5 | "node_modules/", 6 | "dist/", 7 | "coverage/", 8 | ".obsidian", 9 | ".gitignore", 10 | ".prettierrc" 11 | ], 12 | "watch": ["./", "src/"], 13 | "events": { 14 | "start": "rollup --config rollup.config.js; /usr/bin/flatpak run --branch=stable --arch=x86_64 md.obsidian.Obsidian \"$@\"", 15 | "restart": "kill -9 $(ps aux | grep '/app/obsidian' | awk '{print $2}') || true; /usr/bin/flatpak run --branch=stable --arch=x86_64 md.obsidian.Obsidian \"$@\"" 16 | }, 17 | "ext": "js,json,ts" 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-markdown-formatting-assistant-plugin", 3 | "version": "0.4.0", 4 | "description": "This plugin improves the writing of MarkDown files", 5 | "homepage": "https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin", 6 | "main": "main.js", 7 | "scripts": { 8 | "dev": "rollup --config rollup.config.js -w && openObsidian", 9 | "dev2": "nodemon --config nodemon.json", 10 | "openObsidian": "/usr/bin/flatpak run --branch=stable --arch=x86_64 md.obsidian.Obsidian \"$@\"", 11 | "build": "rollup --config rollup.production.config.js" 12 | }, 13 | "keywords": [], 14 | "author": "Reocin ", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@rollup/plugin-commonjs": "^22.0.2", 18 | "@rollup/plugin-node-resolve": "^13.3.0", 19 | "@rollup/plugin-typescript": "^8.3.4", 20 | "@types/node": "^18.6.4", 21 | "@types/ramda": "^0.28.15", 22 | "nodemon": "^2.0.19", 23 | "rollup": "^2.77.2", 24 | "tslib": "^2.4.0", 25 | "typescript": "^4.7.4" 26 | }, 27 | "repository": "git@github.com:Reocin/obsidian-markdown-autocomplete.git", 28 | "dependencies": { 29 | "@mdi/js": "^7.0.96", 30 | "@rollup/plugin-json": "^4.1.0", 31 | "obsidian": "^0.15.9", 32 | "postcss": "^8.4.16", 33 | "ramda": "^0.28.0", 34 | "rollup-plugin-copy": "^3.4.0", 35 | "rollup-plugin-import-css": "^3.0.3", 36 | "rollup-plugin-postcss": "^4.0.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import { nodeResolve } from '@rollup/plugin-node-resolve'; 3 | import commonjs from '@rollup/plugin-commonjs'; 4 | import copy from 'rollup-plugin-copy'; 5 | 6 | const exportFolder = 7 | '.obsidian/plugins/obsidian-markdown-formatting-assistant-plugin'; 8 | export default { 9 | input: 'src/main.ts', 10 | 11 | output: { 12 | dir: exportFolder, 13 | sourcemap: 'inline', 14 | format: 'cjs', 15 | exports: 'default', 16 | }, 17 | external: ['obsidian'], 18 | plugins: [ 19 | typescript(), 20 | nodeResolve({ browser: true }), 21 | copy({ 22 | targets: [ 23 | { src: 'styles.css', dest: exportFolder }, 24 | { src: 'manifest.json', dest: exportFolder }, 25 | { src: 'versions.json', dest: exportFolder }, 26 | ], 27 | }), 28 | commonjs({ 29 | include: 'node_modules/ramda/**', 30 | }), 31 | ], 32 | }; 33 | -------------------------------------------------------------------------------- /rollup.production.config.js: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import { nodeResolve } from '@rollup/plugin-node-resolve'; 3 | import commonjs from '@rollup/plugin-commonjs'; 4 | import copy from 'rollup-plugin-copy'; 5 | 6 | const exportFolder = 'build'; 7 | export default { 8 | input: 'src/main.ts', 9 | output: { 10 | dir: exportFolder, 11 | sourcemap: 'inline', 12 | format: 'cjs', 13 | exports: 'default', 14 | }, 15 | external: ['obsidian'], 16 | plugins: [ 17 | typescript(), 18 | nodeResolve({ browser: true }), 19 | copy({ 20 | targets: [ 21 | { src: 'styles.css', dest: exportFolder }, 22 | { src: 'manifest.json', dest: exportFolder }, 23 | { src: 'versions.json', dest: exportFolder }, 24 | ], 25 | }), 26 | commonjs({ 27 | include: 'node_modules/ramda/**', 28 | }), 29 | ], 30 | }; 31 | -------------------------------------------------------------------------------- /src/CalloutsListView.ts: -------------------------------------------------------------------------------- 1 | import { App, Editor, Notice, SuggestModal } from 'obsidian'; 2 | import { calloutsFormatterSetting } from './calloutsFormatter'; 3 | import * as R from 'ramda'; 4 | import { setIcon } from "obsidian"; 5 | import { calloutsFormatterSettings, calloutsFormatter } from './calloutsFormatter'; 6 | 7 | const suggestions = R.values(calloutsFormatterSettings); 8 | 9 | export class CalloutsSuggestionModal extends SuggestModal { 10 | private editor: Editor; 11 | 12 | public setEditor = (editor: Editor) => { 13 | this.editor = editor; 14 | }; 15 | 16 | // Returns all available suggestions. 17 | getSuggestions(query: string): calloutsFormatterSetting[] { 18 | const filterFunction = (setting: calloutsFormatterSetting) => 19 | setting.des.toLowerCase().includes(query.toLowerCase()); 20 | // @ts-ignore 21 | return R.values(R.filter(filterFunction, suggestions)); 22 | } 23 | 24 | // Renders each suggestion item. 25 | renderSuggestion( 26 | calloutsFormatterSetting: calloutsFormatterSetting, 27 | el: HTMLElement, 28 | ) { 29 | const row = el.createEl('div'); 30 | row.classList.add('command-list-view-row'); 31 | const iconContainer = row.createDiv(); 32 | iconContainer.classList.add('command-list-view-container'); 33 | const iconDiv = iconContainer.createDiv(); 34 | iconDiv.classList.add('command-list-view-icon'); 35 | 36 | const cell2 = row.createDiv(); 37 | cell2.classList.add('command-list-view-text'); 38 | cell2.setText(calloutsFormatterSetting.des); 39 | cell2.style.color = 'var(--text-muted)'; 40 | 41 | const spanIcon = document.createElement('span'); 42 | spanIcon.style.verticalAlign = 'middle'; 43 | spanIcon.style.color = calloutsFormatterSetting.color; 44 | //iconDiv.style.backgroundColor = calloutsFormatterSetting.bgColor; 45 | 46 | setIcon(spanIcon, calloutsFormatterSetting.icon); 47 | iconDiv.appendChild(spanIcon); 48 | row.style.backgroundColor = calloutsFormatterSetting.bgColor; 49 | } 50 | 51 | // Perform action on the selected suggestion. 52 | onChooseSuggestion( 53 | calloutsFormatterSetting: calloutsFormatterSetting, 54 | evt: MouseEvent | KeyboardEvent, 55 | ) { 56 | // @ts-ignore 57 | const item = calloutsFormatterSetting; 58 | calloutsFormatter(this.editor, item); 59 | 60 | // new Notice(`Selected ${calloutsFormatterSetting.des}`); 61 | } 62 | 63 | public static display = (app: App, editor: Editor): void => { 64 | const modal = new CalloutsSuggestionModal(app); 65 | modal.setEditor(editor); 66 | modal.open(); 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /src/CommandListView.ts: -------------------------------------------------------------------------------- 1 | import { App, Editor, Notice, SuggestModal } from 'obsidian'; 2 | import { baseFormatterSetting, iconFormatter } from './formatter'; 3 | import { formatSettings, formatterSetting } from './formatter'; 4 | import * as R from 'ramda'; 5 | import { svgToElement } from './icons'; 6 | import { 7 | greekLowerCaseFormatterSettings, 8 | greekUpperCaseFormatterSettings, 9 | greekFormatter, 10 | } from './greekFormatter'; 11 | import { latexFormatterSettings, latexFormatter } from './latexFormatter'; 12 | import { htmlFormatterSettings, htmlFormatter } from './htmlFormatter'; 13 | 14 | const suggestions = R.values(formatSettings).concat( 15 | // @ts-ignore 16 | R.values(htmlFormatterSettings), 17 | R.values(latexFormatterSettings), 18 | R.values(greekLowerCaseFormatterSettings), 19 | R.values(greekUpperCaseFormatterSettings), 20 | ); 21 | 22 | export class CodeSuggestionModal extends SuggestModal { 23 | private editor: Editor; 24 | 25 | public setEditor = (editor: Editor) => { 26 | this.editor = editor; 27 | }; 28 | 29 | // Returns all available suggestions. 30 | getSuggestions(query: string): baseFormatterSetting[] { 31 | const filterFunction = (setting: baseFormatterSetting) => 32 | setting.des.toLowerCase().includes(query.toLowerCase()); 33 | // @ts-ignore 34 | return R.values(R.filter(filterFunction, suggestions)); 35 | } 36 | 37 | // Renders each suggestion item. 38 | renderSuggestion( 39 | baseFormatterSetting: baseFormatterSetting, 40 | el: HTMLElement, 41 | ) { 42 | const row = el.createEl('div'); 43 | row.classList.add('command-list-view-row'); 44 | const iconContainer = row.createDiv(); 45 | iconContainer.classList.add('command-list-view-container'); 46 | const iconDiv = iconContainer.createDiv(); 47 | iconDiv.classList.add('command-list-view-icon'); 48 | 49 | const cell2 = row.createDiv(); 50 | 51 | cell2.classList.add('command-list-view-text'); 52 | cell2.setText(baseFormatterSetting.des); 53 | 54 | console.log(baseFormatterSetting.objectType); 55 | if (baseFormatterSetting.objectType === 'formatterSetting') { 56 | iconDiv.appendChild(svgToElement(baseFormatterSetting.icon)); 57 | cell2.style.color = '#c7254e'; 58 | } else if (baseFormatterSetting.objectType === 'htmlFormatterSetting') { 59 | iconDiv.appendText('HTML'); 60 | cell2.style.color = '#0055F2'; 61 | } else if (baseFormatterSetting.objectType === 'greekFormatterSetting') { 62 | iconDiv.appendChild(svgToElement(baseFormatterSetting.icon)); 63 | cell2.style.color = '#25e712'; 64 | } else if (baseFormatterSetting.objectType === 'latexFormatterSetting') { 65 | const item = baseFormatterSetting; 66 | if (item.type === 'icon') { 67 | let svg = svgToElement(item.text); 68 | svg.style.display = 'inline-block'; 69 | svg.style.verticalAlign = 'middle'; 70 | iconDiv.appendChild(svg); 71 | } else if (item.type === 'text') { 72 | let div = document.createElement('div'); 73 | div.innerHTML = item.text; 74 | iconDiv.appendChild(div); 75 | } 76 | cell2.style.color = '#25e712'; 77 | } else { 78 | iconDiv.appendText('HTML'); 79 | } 80 | } 81 | 82 | // Perform action on the selected suggestion. 83 | onChooseSuggestion( 84 | baseFormatterSetting: baseFormatterSetting, 85 | evt: MouseEvent | KeyboardEvent, 86 | ) { 87 | // @ts-ignore 88 | const item = baseFormatterSetting; 89 | 90 | console.log(baseFormatterSetting); 91 | if (item.objectType === 'formatterSetting') { 92 | // @ts-ignore 93 | iconFormatter(this.editor, item); 94 | } else if (item.objectType === 'htmlFormatterSetting') { 95 | // @ts-ignore 96 | htmlFormatter(this.editor, item); 97 | } else if (item.objectType === 'latexFormatterSetting') { 98 | // @ts-ignore 99 | latexFormatter(this.editor, item); 100 | } else if (item.objectType === 'greekFormatterSetting') { 101 | // @ts-ignore 102 | greekFormatter(this.editor, item); 103 | } 104 | 105 | // new Notice(`Selected ${baseFormatterSetting.des}`); 106 | } 107 | 108 | public static display = (app: App, editor: Editor): void => { 109 | const modal = new CodeSuggestionModal(app); 110 | modal.setEditor(editor); 111 | modal.open(); 112 | }; 113 | } 114 | -------------------------------------------------------------------------------- /src/Events.ts: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/calloutsFormatter.ts: -------------------------------------------------------------------------------- 1 | import { Editor } from 'obsidian'; 2 | 3 | export interface calloutsFormatterSetting { 4 | des: string; 5 | text: string; 6 | icon: string; 7 | color: string; 8 | bgColor: string; 9 | symbol: string; 10 | shift: number; 11 | selectionInput: number; 12 | newLine: boolean; 13 | } 14 | 15 | export const calloutsFormatterSettings = { 16 | note: { 17 | des: 'note', 18 | text: 'Note', 19 | icon: 'lucide-pencil', 20 | color: 'rgb(68,138,255)', 21 | bgColor: 'rgba(68,138,255,0.1)', 22 | symbol: '> [!note] \n> ', 23 | shift: 13, 24 | selectionInput: 13, 25 | newLine: false, 26 | objectType: 'calloutsFormatterSetting', 27 | }, 28 | info: { 29 | des: 'info', 30 | text: 'Info', 31 | icon: 'lucide-info', 32 | color: 'rgb(0,184,212)', 33 | bgColor: 'rgba(0,184,212,0.1)', 34 | symbol: '> [!info] \n> ', 35 | shift: 13, 36 | selectionInput: 13, 37 | newLine: false, 38 | objectType: 'calloutsFormatterSetting', 39 | }, 40 | todo: { 41 | des: 'todo', 42 | text: 'Todo', 43 | icon: 'lucide-check-circle-2', 44 | color: 'rgb(0,184,212)', 45 | bgColor: 'rgba(0,184,212,0.1)', 46 | symbol: '> [!todo] \n> ', 47 | shift: 13, 48 | selectionInput: 13, 49 | newLine: false, 50 | objectType: 'calloutsFormatterSetting', 51 | }, 52 | abstract: { 53 | des: 'abstract', 54 | text: 'Abstract', 55 | icon: 'lucide-clipboard-list', 56 | color: 'rgb(0, 176, 255)', 57 | bgColor: 'rgba(0, 176, 255,0.1)', 58 | symbol: '> [!abstract] \n> ', 59 | shift: 17, 60 | selectionInput: 17, 61 | newLine: false, 62 | objectType: 'calloutsFormatterSetting', 63 | }, 64 | summary: { 65 | des: 'summary', 66 | text: 'Summary', 67 | icon: 'lucide-clipboard-list', 68 | color: 'rgb(0, 176, 255)', 69 | bgColor: 'rgba(0, 176, 255,0.1)', 70 | symbol: '> [!summary] \n> ', 71 | shift: 16, 72 | selectionInput: 16, 73 | newLine: false, 74 | objectType: 'calloutsFormatterSetting', 75 | }, 76 | tldr: { 77 | des: 'tldr', 78 | text: 'TLDR', 79 | icon: 'lucide-clipboard-list', 80 | color: 'rgb(0, 176, 255)', 81 | bgColor: 'rgba(0, 176, 255,0.1)', 82 | symbol: '> [!tldr] \n> ', 83 | shift: 13, 84 | selectionInput: 13, 85 | newLine: false, 86 | objectType: 'calloutsFormatterSetting', 87 | }, 88 | //step 2 89 | tip: { 90 | des: 'tip', 91 | text: 'Tip', 92 | icon: 'lucide-flame', 93 | color: 'rgb(0, 191, 165)', 94 | bgColor: 'rgba(0, 191, 165,0.1)', 95 | symbol: '> [!tip] \n> ', 96 | shift: 12, 97 | selectionInput: 12, 98 | newLine: false, 99 | objectType: 'calloutsFormatterSetting', 100 | }, 101 | hint: { 102 | des: 'hint', 103 | text: 'Hint', 104 | icon: 'lucide-flame', 105 | color: 'rgb(0, 191, 165)', 106 | bgColor: 'rgba(0, 191, 165,0.1)', 107 | symbol: '> [!hint] \n> ', 108 | shift: 13, 109 | selectionInput: 13, 110 | newLine: false, 111 | objectType: 'calloutsFormatterSetting', 112 | }, 113 | important: { 114 | des: 'important', 115 | text: 'Important', 116 | icon: 'lucide-flame', 117 | color: 'rgb(0, 191, 165)', 118 | bgColor: 'rgba(0, 191, 165,0.1)', 119 | symbol: '> [!important] \n> ', 120 | shift: 18, 121 | selectionInput: 18, 122 | newLine: false, 123 | objectType: 'calloutsFormatterSetting', 124 | }, 125 | success: { 126 | des: 'success', 127 | text: 'Success', 128 | icon: 'lucide-check', 129 | color: 'rgb(0, 200, 83)', 130 | bgColor: 'rgba(0, 200, 83,0.1)', 131 | symbol: '> [!success] \n> ', 132 | shift: 16, 133 | selectionInput: 16, 134 | newLine: false, 135 | objectType: 'calloutsFormatterSetting', 136 | }, 137 | check: { 138 | des: 'check', 139 | text: 'Check', 140 | icon: 'lucide-check', 141 | color: 'rgb(0, 200, 83)', 142 | bgColor: 'rgba(0, 200, 83,0.1)', 143 | symbol: '> [!check] \n> ', 144 | shift: 14, 145 | selectionInput: 14, 146 | newLine: false, 147 | objectType: 'calloutsFormatterSetting', 148 | }, 149 | done: { 150 | des: 'done', 151 | text: 'Done', 152 | icon: 'lucide-check', 153 | color: 'rgb(0, 200, 83)', 154 | bgColor: 'rgba(0, 200, 83,0.1)', 155 | symbol: '> [!done] \n> ', 156 | shift: 13, 157 | selectionInput: 13, 158 | newLine: false, 159 | objectType: 'calloutsFormatterSetting', 160 | }, 161 | question: { 162 | des: 'question', 163 | text: 'Question', 164 | icon: 'help-circle', 165 | color: 'rgb(100, 221, 23)', 166 | bgColor: 'rgba(100, 221, 23,0.1)', 167 | symbol: '> [!question] \n> ', 168 | shift: 17, 169 | selectionInput: 17, 170 | newLine: false, 171 | objectType: 'calloutsFormatterSetting', 172 | }, 173 | help: { 174 | des: 'help', 175 | text: 'Help', 176 | icon: 'help-circle', 177 | color: 'rgb(100, 221, 23)', 178 | bgColor: 'rgba(100, 221, 23,0.1)', 179 | symbol: '> [!help] \n> ', 180 | shift: 13, 181 | selectionInput: 13, 182 | newLine: false, 183 | objectType: 'calloutsFormatterSetting', 184 | }, 185 | faq: { 186 | des: 'faq', 187 | text: 'FAQ', 188 | icon: 'help-circle', 189 | color: 'rgb(100, 221, 23)', 190 | bgColor: 'rgba(100, 221, 23,0.1)', 191 | symbol: '> [!faq] \n> ', 192 | shift: 12, 193 | selectionInput: 12, 194 | newLine: false, 195 | objectType: 'calloutsFormatterSetting', 196 | }, 197 | warning: { 198 | des: 'warning', 199 | text: 'Warning', 200 | icon: 'lucide-alert-triangle', 201 | color: 'rgb(255, 145, 0)', 202 | bgColor: 'rgba(255, 145, 0,0.1)', 203 | symbol: '> [!warning] \n> ', 204 | shift: 16, 205 | selectionInput: 16, 206 | newLine: false, 207 | objectType: 'calloutsFormatterSetting', 208 | }, 209 | caution: { 210 | des: 'caution', 211 | text: 'Caution', 212 | icon: 'lucide-alert-triangle', 213 | color: 'rgb(255, 145, 0)', 214 | bgColor: 'rgba(255, 145, 0,0.1)', 215 | symbol: '> [!caution] \n> ', 216 | shift: 16, 217 | selectionInput: 16, 218 | newLine: false, 219 | objectType: 'calloutsFormatterSetting', 220 | }, 221 | attention: { 222 | des: 'attention', 223 | text: 'Attention', 224 | icon: 'lucide-alert-triangle', 225 | color: 'rgb(255, 145, 0)', 226 | bgColor: 'rgba(255, 145, 0,0.1)', 227 | symbol: '> [!attention] \n> ', 228 | shift: 18, 229 | selectionInput: 18, 230 | newLine: false, 231 | objectType: 'calloutsFormatterSetting', 232 | }, 233 | failure: { 234 | des: 'failure', 235 | text: 'Failure', 236 | icon: 'lucide-x', 237 | color: 'rgb(255, 82, 82)', 238 | bgColor: 'rgba(255, 82, 82,0.1)', 239 | symbol: '> [!failure] \n> ', 240 | shift: 16, 241 | selectionInput: 16, 242 | newLine: false, 243 | objectType: 'calloutsFormatterSetting', 244 | }, 245 | fail: { 246 | des: 'fail', 247 | text: 'Fail', 248 | icon: 'lucide-x', 249 | color: 'rgb(255, 82, 82)', 250 | bgColor: 'rgba(255, 82, 82,0.1)', 251 | symbol: '> [!fail] \n> ', 252 | shift: 13, 253 | selectionInput: 13, 254 | newLine: false, 255 | objectType: 'calloutsFormatterSetting', 256 | }, 257 | missing: { 258 | des: 'missing', 259 | text: 'Missing', 260 | icon: 'lucide-x', 261 | color: 'rgb(255, 82, 82)', 262 | bgColor: 'rgba(255, 82, 82,0.1)', 263 | symbol: '> [!missing] \n> ', 264 | shift: 16, 265 | selectionInput: 16, 266 | newLine: false, 267 | objectType: 'calloutsFormatterSetting', 268 | }, 269 | danger: { 270 | des: 'danger', 271 | text: 'Danger', 272 | icon: 'lucide-zap', 273 | color: 'rgb(255, 23, 68)', 274 | bgColor: 'rgba(255, 23, 68,0.1)', 275 | symbol: '> [!danger] \n> ', 276 | shift: 15, 277 | selectionInput: 15, 278 | newLine: false, 279 | objectType: 'calloutsFormatterSetting', 280 | }, 281 | error: { 282 | des: 'error', 283 | text: 'Error', 284 | icon: 'lucide-zap', 285 | color: 'rgb(255, 23, 68)', 286 | bgColor: 'rgba(255, 23, 68,0.1)', 287 | symbol: '> [!error] \n> ', 288 | shift: 14, 289 | selectionInput: 14, 290 | newLine: false, 291 | objectType: 'calloutsFormatterSetting', 292 | }, 293 | bug: { 294 | des: 'bug', 295 | text: 'Bug', 296 | icon: 'lucide-bug', 297 | color: 'rgb(245, 0, 87)', 298 | bgColor: 'rgba(245, 0, 87,0.1)', 299 | symbol: '> [!bug] \n> ', 300 | shift: 12, 301 | selectionInput: 12, 302 | newLine: false, 303 | objectType: 'calloutsFormatterSetting', 304 | }, 305 | example: { 306 | des: 'example', 307 | text: 'Example', 308 | icon: 'lucide-list', 309 | color: 'rgb(124, 77, 255)', 310 | bgColor: 'rgba(124, 77, 255,0.1)', 311 | symbol: '> [!example] \n> ', 312 | shift: 16, 313 | selectionInput: 16, 314 | newLine: false, 315 | objectType: 'calloutsFormatterSetting', 316 | }, 317 | quote: { 318 | des: 'quote', 319 | text: 'Quote', 320 | icon: 'quote-glyph', 321 | color: 'rgb(158, 158, 158)', 322 | bgColor: 'rgba(158, 158, 158,0.1)', 323 | symbol: '> [!quote] \n> ', 324 | shift: 14, 325 | selectionInput: 14, 326 | newLine: false, 327 | objectType: 'calloutsFormatterSetting', 328 | }, 329 | glyph: { 330 | des: 'glyph', 331 | text: 'Glyph', 332 | icon: 'quote-glyph', 333 | color: 'rgb(158, 158, 158)', 334 | bgColor: 'rgba(158, 158, 158,0.1)', 335 | symbol: '> [!glyph] \n> ', 336 | shift: 14, 337 | selectionInput: 14, 338 | newLine: false, 339 | objectType: 'calloutsFormatterSetting', 340 | }, 341 | 342 | 343 | 344 | }; 345 | 346 | export function calloutsFormatter(editor: Editor, item: calloutsFormatterSetting) { 347 | if (editor) { 348 | const isSelection = editor.somethingSelected; 349 | const selection = editor.getSelection(); 350 | const curserStart = editor.getCursor('from'); 351 | const curserEnd = editor.getCursor('to'); 352 | const line = editor.getLine(curserStart.line); 353 | 354 | editor.focus(); 355 | if (isSelection) { 356 | let replacment = selection.trim(); 357 | 358 | editor.replaceSelection( 359 | item.symbol.substring(0, item.selectionInput) + 360 | replacment + 361 | item.symbol.substring(item.selectionInput), 362 | ); 363 | editor.setCursor(curserStart.line, curserStart.ch + item.shift); 364 | } else { 365 | editor.replaceRange(item.symbol, curserStart); 366 | editor.setCursor(curserStart.line, curserStart.ch + item.shift); 367 | } 368 | } 369 | } 370 | -------------------------------------------------------------------------------- /src/generalFunctions.ts: -------------------------------------------------------------------------------- 1 | import { MarkdownView, WorkspaceLeaf } from 'obsidian'; 2 | 3 | export function checkIfSelection(editor: CodeMirror.Editor) { 4 | const selection = editor.getSelection(); 5 | if (!selection || selection === '') { 6 | return false; 7 | } else { 8 | return true; 9 | } 10 | } 11 | 12 | export function checkIfMarkdownSource(leaf: WorkspaceLeaf) { 13 | return ( 14 | // @ts-ignore 15 | leaf.view instanceof MarkdownView && leaf.view.currentMode.type === 'source' 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /src/greekFormatter.ts: -------------------------------------------------------------------------------- 1 | import { Editor } from 'obsidian'; 2 | import { baseFormatterSetting } from './formatter'; 3 | 4 | export interface greekFormatterSetting extends baseFormatterSetting { 5 | symbol: string; 6 | shift: number; 7 | } 8 | 9 | export const greekLowerCaseFormatterSettings = { 10 | alpha: { 11 | des: 'alpha', 12 | icon: 'alpha', 13 | symbol: '\\alpha', 14 | shift: 6, 15 | objectType: 'greekFormatterSetting', 16 | }, 17 | beta: { 18 | des: 'beta', 19 | icon: 'beta', 20 | symbol: '\\beta', 21 | shift: 5, 22 | objectType: 'greekFormatterSetting', 23 | }, 24 | gamma: { 25 | des: 'gamma', 26 | icon: 'gamma', 27 | symbol: '\\gamma', 28 | shift: 6, 29 | objectType: 'greekFormatterSetting', 30 | }, 31 | delta: { 32 | des: 'delta', 33 | icon: 'delta', 34 | symbol: '\\delta', 35 | shift: 6, 36 | objectType: 'greekFormatterSetting', 37 | }, 38 | epsilon: { 39 | des: 'epsilon', 40 | icon: 'epsilon', 41 | symbol: '\\epsilon', 42 | shift: 8, 43 | objectType: 'greekFormatterSetting', 44 | }, 45 | zeta: { 46 | des: 'zeta', 47 | icon: 'zeta', 48 | symbol: '\\zeta', 49 | shift: 5, 50 | objectType: 'greekFormatterSetting', 51 | }, 52 | eta: { 53 | des: 'eta', 54 | icon: 'eta', 55 | symbol: '\\eta', 56 | shift: 4, 57 | objectType: 'greekFormatterSetting', 58 | }, 59 | theta: { 60 | des: 'theta', 61 | icon: 'theta', 62 | symbol: '\\theta', 63 | shift: 6, 64 | objectType: 'greekFormatterSetting', 65 | }, 66 | iota: { 67 | des: 'iota', 68 | icon: 'iota', 69 | symbol: '\\iota', 70 | shift: 5, 71 | objectType: 'greekFormatterSetting', 72 | }, 73 | kappa: { 74 | des: 'kappa', 75 | icon: 'kappa', 76 | symbol: '\\kappa', 77 | shift: 6, 78 | objectType: 'greekFormatterSetting', 79 | }, 80 | lambda: { 81 | des: 'lambda', 82 | icon: 'lambda', 83 | symbol: '\\lambda', 84 | shift: 7, 85 | objectType: 'greekFormatterSetting', 86 | }, 87 | mu: { 88 | des: 'mu', 89 | icon: 'my', 90 | symbol: '\\mu', 91 | shift: 3, 92 | objectType: 'greekFormatterSetting', 93 | }, 94 | nu: { 95 | des: 'nu', 96 | icon: 'ny', 97 | symbol: '\\nu', 98 | shift: 3, 99 | objectType: 'greekFormatterSetting', 100 | }, 101 | xi: { 102 | des: 'xi', 103 | icon: 'xi', 104 | symbol: '\\xi', 105 | shift: 3, 106 | objectType: 'greekFormatterSetting', 107 | }, 108 | pi: { 109 | des: 'pi', 110 | icon: 'pi', 111 | symbol: '\\pi', 112 | shift: 3, 113 | objectType: 'greekFormatterSetting', 114 | }, 115 | rho: { 116 | des: 'rho', 117 | icon: 'rho', 118 | symbol: '\\rho', 119 | shift: 4, 120 | objectType: 'greekFormatterSetting', 121 | }, 122 | sigma: { 123 | des: 'sigma', 124 | icon: 'sigma', 125 | symbol: '\\sigma', 126 | shift: 6, 127 | objectType: 'greekFormatterSetting', 128 | }, 129 | tau: { 130 | des: 'tau', 131 | icon: 'tau', 132 | symbol: '\\tau', 133 | shift: 4, 134 | objectType: 'greekFormatterSetting', 135 | }, 136 | upsilon: { 137 | des: 'upsilon', 138 | icon: 'ypsilon', 139 | symbol: '\\upsilon', 140 | shift: 8, 141 | objectType: 'greekFormatterSetting', 142 | }, 143 | phi: { 144 | des: 'phi', 145 | icon: 'phi', 146 | symbol: '\\phi', 147 | shift: 4, 148 | objectType: 'greekFormatterSetting', 149 | }, 150 | chi: { 151 | des: 'chi', 152 | icon: 'chi', 153 | symbol: '\\chi', 154 | shift: 4, 155 | objectType: 'greekFormatterSetting', 156 | }, 157 | psi: { 158 | des: 'psi', 159 | icon: 'psi', 160 | symbol: '\\psi', 161 | shift: 4, 162 | objectType: 'greekFormatterSetting', 163 | }, 164 | omega: { 165 | des: 'omega', 166 | icon: 'omega', 167 | symbol: '\\omega', 168 | shift: 6, 169 | objectType: 'greekFormatterSetting', 170 | }, 171 | }; 172 | 173 | export const greekUpperCaseFormatterSettings = { 174 | // Alpha: { 175 | // des: 'Alpha', 176 | // icon: 'Alpha', 177 | // symbol: '\\Alpha', 178 | // shift: 6, 179 | // objectType: 'greekFormatterSetting',}, 180 | // Beta: { 181 | // des: 'Beta', 182 | // icon: 'Beta', 183 | // symbol: '\\Beta', 184 | // shift: 5, 185 | // objectType: 'greekFormatterSetting',}, 186 | Gamma: { 187 | des: 'Gamma', 188 | icon: 'Gamma', 189 | symbol: '\\Gamma', 190 | shift: 6, 191 | objectType: 'greekFormatterSetting', 192 | }, 193 | Delta: { 194 | des: 'Delta', 195 | icon: 'Delta', 196 | symbol: '\\Delta', 197 | shift: 6, 198 | objectType: 'greekFormatterSetting', 199 | }, 200 | // Epsilon: { 201 | // des: 'Epsilon', 202 | // icon: 'Epsilon', 203 | // symbol: '\\Epsilon', 204 | // shift: 8, 205 | // objectType: 'greekFormatterSetting',}, 206 | // Zeta: { 207 | // des: 'Zeta', 208 | // icon: 'Zeta', 209 | // symbol: '\\Zeta', 210 | // shift: 5, 211 | // objectType: 'greekFormatterSetting',}, 212 | // Eta: { 213 | // des: 'Eta', 214 | // icon: 'Eta', 215 | // symbol: '\\Eta', 216 | // shift: 4, 217 | // objectType: 'greekFormatterSetting',}, 218 | Theta: { 219 | des: 'Theta', 220 | icon: 'Theta', 221 | symbol: '\\Theta', 222 | shift: 6, 223 | objectType: 'greekFormatterSetting', 224 | }, 225 | // Iota: { 226 | // des: 'Iota', 227 | // icon: 'Iota', 228 | // symbol: '\\Iota', 229 | // shift: 5, 230 | // objectType: 'greekFormatterSetting',}, 231 | // Kappa: { 232 | // des: 'Kappa', 233 | // icon: 'Kappa', 234 | // symbol: '\\Kappa', 235 | // shift: 6, 236 | // objectType: 'greekFormatterSetting',}, 237 | Lambda: { 238 | des: 'Lambda', 239 | icon: 'Lambda', 240 | symbol: '\\Lambda', 241 | shift: 7, 242 | objectType: 'greekFormatterSetting', 243 | }, 244 | // Mu: { 245 | // des: 'Mu', 246 | // icon: 'My', 247 | // symbol: '\\Mu', 248 | // shift: 3, 249 | // objectType: 'greekFormatterSetting',}, 250 | // Nu: { 251 | // des: 'Nu', 252 | // icon: 'Ny', 253 | // symbol: '\\Nu', 254 | // shift: 3, 255 | // objectType: 'greekFormatterSetting',}, 256 | Xi: { 257 | des: 'Xi', 258 | icon: 'Xi', 259 | symbol: '\\Xi', 260 | shift: 3, 261 | objectType: 'greekFormatterSetting', 262 | }, 263 | // Omikron: { 264 | // des: 'Omikron', 265 | // icon: 'Omikron', 266 | // symbol: '\\Omikron', 267 | // shift: 8, 268 | // objectType: 'greekFormatterSetting',}, 269 | Pi: { 270 | des: 'Pi', 271 | icon: 'Pi', 272 | symbol: '\\Pi', 273 | shift: 3, 274 | objectType: 'greekFormatterSetting', 275 | }, 276 | // Rho: { 277 | // des: 'Rho', 278 | // icon: 'Rho', 279 | // symbol: '\\Rho', 280 | // shift: 4, 281 | // objectType: 'greekFormatterSetting',}, 282 | Sigma: { 283 | des: 'Sigma', 284 | icon: 'Sigma', 285 | symbol: '\\Sigma', 286 | shift: 6, 287 | objectType: 'greekFormatterSetting', 288 | }, 289 | // Tau: { 290 | // des: 'Tau', 291 | // icon: 'Tau', 292 | // symbol: '\\Tau', 293 | // shift: 4, 294 | // objectType: 'greekFormatterSetting',}, 295 | Upsilon: { 296 | des: 'Upsilon', 297 | icon: 'Ypsilon', 298 | symbol: '\\Upsilon', 299 | shift: 8, 300 | objectType: 'greekFormatterSetting', 301 | }, 302 | Phi: { 303 | des: 'Phi', 304 | icon: 'Phi', 305 | symbol: '\\Phi', 306 | shift: 4, 307 | objectType: 'greekFormatterSetting', 308 | }, 309 | // Chi: { 310 | // des: 'Chi', 311 | // icon: 'Chi', 312 | // symbol: '\\Chi', 313 | // shift: 4, 314 | // objectType: 'greekFormatterSetting',}, 315 | Psi: { 316 | des: 'Psi', 317 | icon: 'Psi', 318 | symbol: '\\Psi', 319 | shift: 4, 320 | objectType: 'greekFormatterSetting', 321 | }, 322 | Omega: { 323 | des: 'Omega', 324 | icon: 'Omega', 325 | symbol: '\\Omega', 326 | shift: 6, 327 | objectType: 'greekFormatterSetting', 328 | }, 329 | }; 330 | 331 | export function greekFormatter(editor: Editor, item: greekFormatterSetting) { 332 | if (editor) { 333 | const isSelection = editor.somethingSelected; 334 | const selection = editor.getSelection(); 335 | const curserStart = editor.getCursor('from'); 336 | const curserEnd = editor.getCursor('to'); 337 | const line = editor.getLine(curserStart.line); 338 | 339 | editor.focus(); 340 | editor.replaceRange(item.symbol, curserStart); 341 | editor.setCursor(curserStart.line, curserStart.ch + item.shift); 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /src/htmlFormatter.ts: -------------------------------------------------------------------------------- 1 | import { Editor } from 'obsidian'; 2 | import { baseFormatterSetting } from './formatter'; 3 | 4 | export interface htmlFormatterSetting extends baseFormatterSetting { 5 | symbol: string; 6 | shift: number; 7 | selectionInput: number; 8 | } 9 | 10 | export const htmlFormatterSettings = { 11 | br: { 12 | des: '
', 13 | symbol: '
', 14 | shift: 5, 15 | selectionInput: 5, 16 | objectType: 'htmlFormatterSetting', 17 | }, 18 | div: { 19 | des: '
', 20 | symbol: '
', 21 | shift: 5, 22 | selectionInput: 5, 23 | objectType: 'htmlFormatterSetting', 24 | }, 25 | span: { 26 | des: '', 27 | symbol: '', 28 | shift: 6, 29 | selectionInput: 6, 30 | objectType: 'htmlFormatterSetting', 31 | }, 32 | img: { 33 | des: '', 34 | symbol: '', 35 | shift: 10, 36 | selectionInput: 38, 37 | objectType: 'htmlFormatterSetting', 38 | }, 39 | a: { 40 | des: '', 41 | symbol: '', 42 | shift: 3, 43 | selectionInput: 3, 44 | objectType: 'htmlFormatterSetting', 45 | }, 46 | p: { 47 | des: '

', 48 | symbol: '

', 49 | shift: 3, 50 | selectionInput: 3, 51 | objectType: 'htmlFormatterSetting', 52 | }, 53 | font: { 54 | des: '', 55 | symbol: 56 | '', 57 | shift: 64, 58 | selectionInput: 64, 59 | objectType: 'htmlFormatterSetting', 60 | }, 61 | table: { 62 | des: '', 63 | symbol: '
', 64 | shift: 7, 65 | selectionInput: 7, 66 | objectType: 'htmlFormatterSetting', 67 | }, 68 | thead: { 69 | des: '', 70 | symbol: '', 71 | shift: 7, 72 | selectionInput: 7, 73 | objectType: 'htmlFormatterSetting', 74 | }, 75 | tbody: { 76 | des: '', 77 | symbol: '', 78 | shift: 7, 79 | selectionInput: 7, 80 | objectType: 'htmlFormatterSetting', 81 | }, 82 | tfoot: { 83 | des: '', 84 | symbol: '', 85 | shift: 7, 86 | selectionInput: 7, 87 | objectType: 'htmlFormatterSetting', 88 | }, 89 | tr: { 90 | des: '', 91 | symbol: '', 92 | shift: 4, 93 | selectionInput: 4, 94 | objectType: 'htmlFormatterSetting', 95 | }, 96 | td: { 97 | des: '', 98 | symbol: '', 99 | shift: 4, 100 | selectionInput: 4, 101 | objectType: 'htmlFormatterSetting', 102 | }, 103 | th: { 104 | des: '', 105 | symbol: '', 106 | shift: 4, 107 | selectionInput: 4, 108 | objectType: 'htmlFormatterSetting', 109 | }, 110 | details: { 111 | des: '
', 112 | symbol: '
', 113 | shift: 9, 114 | selectionInput: 9, 115 | objectType: 'htmlFormatterSetting', 116 | }, 117 | summary: { 118 | des: '', 119 | symbol: '', 120 | shift: 9, 121 | selectionInput: 9, 122 | objectType: 'htmlFormatterSetting', 123 | }, 124 | u: { 125 | des: '', 126 | symbol: '', 127 | shift: 3, 128 | selectionInput: 3, 129 | objectType: 'htmlFormatterSetting', 130 | }, 131 | }; 132 | 133 | export function htmlFormatter(editor: Editor, item: htmlFormatterSetting) { 134 | if (editor) { 135 | const isSelection = editor.somethingSelected; 136 | const selection = editor.getSelection(); 137 | const curserStart = editor.getCursor('from'); 138 | const curserEnd = editor.getCursor('to'); 139 | const line = editor.getLine(curserStart.line); 140 | 141 | editor.focus(); 142 | 143 | if (isSelection) { 144 | let replacment = selection.trim(); 145 | 146 | editor.replaceSelection( 147 | item.symbol.substring(0, item.selectionInput) + 148 | replacment + 149 | item.symbol.substring(item.selectionInput), 150 | ); 151 | editor.setCursor(curserStart.line, curserStart.ch + item.shift); 152 | } else { 153 | editor.replaceRange(item.symbol, curserStart); 154 | editor.setCursor(curserStart.line, curserStart.ch + item.shift); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/icons.ts: -------------------------------------------------------------------------------- 1 | import * as R from 'ramda'; 2 | import { addIcon } from 'obsidian'; 3 | import * as mdiIcons from '@mdi/js'; 4 | import * as iconPaths from './iconPaths'; 5 | 6 | function pathToSvg(icon: string) { 7 | return ` 8 | 9 | 10 | `; 11 | } 12 | 13 | function importIconPaths() { 14 | let res = {}; 15 | console.log(iconPaths); 16 | R.forEachObjIndexed((value, key, obj) => { 17 | // @ts-ignore 18 | res = R.mergeLeft(res, R.map(pathToSvg, value)); 19 | }, iconPaths); 20 | return res; 21 | } 22 | 23 | export const icons: Record = { 24 | ...importIconPaths(), 25 | 26 | division: pathToSvg(mdiIcons.mdiDivision), 27 | multiplication: pathToSvg(mdiIcons.mdiCircleSmall), 28 | 29 | h1: pathToSvg(mdiIcons.mdiFormatHeader1), 30 | h2: pathToSvg(mdiIcons.mdiFormatHeader2), 31 | h3: pathToSvg(mdiIcons.mdiFormatHeader3), 32 | h4: pathToSvg(mdiIcons.mdiFormatHeader4), 33 | h5: pathToSvg(mdiIcons.mdiFormatHeader5), 34 | h6: pathToSvg(mdiIcons.mdiFormatHeader6), 35 | bold: pathToSvg(mdiIcons.mdiFormatBold), 36 | italic: pathToSvg(mdiIcons.mdiFormatItalic), 37 | strikethrough: pathToSvg(mdiIcons.mdiFormatStrikethroughVariant), 38 | codeInline: pathToSvg(mdiIcons.mdiCodeTags), 39 | codeBlock: pathToSvg(mdiIcons.mdiXml), 40 | link: pathToSvg(mdiIcons.mdiLinkVariant), 41 | mermaidBlock: pathToSvg(mdiIcons.mdiGraph), 42 | fileLink: pathToSvg(mdiIcons.mdiFileLink), 43 | image: pathToSvg(mdiIcons.mdiImage), 44 | quote: pathToSvg(mdiIcons.mdiFormatIndentIncrease), 45 | bulletList: pathToSvg(mdiIcons.mdiFormatListBulleted), 46 | numberList: pathToSvg(mdiIcons.mdiFormatListNumbered), 47 | checkList: pathToSvg(mdiIcons.mdiFormatListBulletedSquare), 48 | viewIcon: pathToSvg(mdiIcons.mdiLanguageMarkdown), 49 | underline: pathToSvg(mdiIcons.mdiFormatUnderline), 50 | menu: pathToSvg(mdiIcons.mdiMenu), 51 | expandArrowDown: pathToSvg(mdiIcons.mdiChevronDown), 52 | expandArrowUp: pathToSvg(mdiIcons.mdiChevronUp), 53 | highlight: pathToSvg(mdiIcons.mdiMarker), 54 | }; 55 | 56 | export const addIcons = (): void => { 57 | Object.keys(icons).forEach((key) => { 58 | addIcon(key, icons[key]); 59 | }); 60 | }; 61 | 62 | /** 63 | * Convert an svg string into an HTML element. 64 | * 65 | * @param svgText svg image as a string 66 | */ 67 | export const svgToElement = (key: string | number): HTMLElement => { 68 | if (key.toString().contains('.svg')) { 69 | const img = document.createElement('img'); 70 | img.src = key.toString(); 71 | img.style.width = '24px'; 72 | img.style.height = '24px'; 73 | 74 | return img; 75 | } else { 76 | const parser = new DOMParser(); 77 | return parser.parseFromString(icons[key], 'text/xml').documentElement; 78 | } 79 | }; 80 | -------------------------------------------------------------------------------- /src/latexFormatter.ts: -------------------------------------------------------------------------------- 1 | import { Editor } from 'obsidian'; 2 | 3 | export interface latexFormatterSetting { 4 | des: string; 5 | text: string; 6 | symbol: string; 7 | shift: number; 8 | selectionInput: number; 9 | type: string; 10 | newLine: boolean; 11 | } 12 | 13 | export const latexFormatterSettings = { 14 | inlineEquation: { 15 | des: 'inline equation', 16 | text: '$$x$$', 17 | symbol: '$$$$', 18 | shift: 2, 19 | selectionInput: 2, 20 | type: 'text', 21 | newLine: false, 22 | objectType: 'latexFormatterSetting', 23 | }, 24 | equation: { 25 | des: 'equation', 26 | text: '$x$', 27 | symbol: '$$', 28 | shift: 1, 29 | selectionInput: 1, 30 | type: 'text', 31 | newLine: false, 32 | objectType: 'latexFormatterSetting', 33 | }, 34 | division: { 35 | des: 'frac', 36 | text: 'division', 37 | symbol: '\\frac{}{}', 38 | shift: 6, 39 | selectionInput: 6, 40 | type: 'icon', 41 | newLine: true, 42 | objectType: 'latexFormatterSetting', 43 | }, 44 | multiplication: { 45 | des: 'times', 46 | text: 'multiplication', 47 | symbol: '\\times', 48 | shift: 6, 49 | selectionInput: 6, 50 | type: 'icon', 51 | newLine: false, 52 | objectType: 'latexFormatterSetting', 53 | }, 54 | sup: { 55 | des: 'superscript', 56 | text: 'xy', 57 | symbol: '^{}', 58 | shift: 2, 59 | selectionInput: 2, 60 | type: 'text', 61 | newLine: false, 62 | objectType: 'latexFormatterSetting', 63 | }, 64 | div: { 65 | des: 'division', 66 | text: 'x-1', 67 | symbol: '^{-1}', 68 | shift: 5, 69 | selectionInput: 5, 70 | type: 'text', 71 | newLine: false, 72 | objectType: 'latexFormatterSetting', 73 | }, 74 | sub: { 75 | des: 'subscript', 76 | text: 'xy', 77 | symbol: '_{}', 78 | shift: 2, 79 | selectionInput: 2, 80 | type: 'text', 81 | newLine: false, 82 | objectType: 'latexFormatterSetting', 83 | }, 84 | pi: { 85 | des: 'pi', 86 | text: 'pi', 87 | symbol: '\\pi', 88 | shift: 3, 89 | selectionInput: 3, 90 | type: 'icon', 91 | newLine: false, 92 | objectType: 'latexFormatterSetting', 93 | }, 94 | e: { 95 | des: 'e', 96 | text: 'ex', 97 | symbol: 'e^{}', 98 | shift: 3, 99 | selectionInput: 3, 100 | type: 'text', 101 | newLine: true, 102 | objectType: 'latexFormatterSetting', 103 | }, 104 | exp: { 105 | des: 'exp', 106 | text: 'exp', 107 | symbol: '\\exp()', 108 | shift: 5, 109 | selectionInput: 5, 110 | type: 'text', 111 | newLine: false, 112 | objectType: 'latexFormatterSetting', 113 | }, 114 | log: { 115 | des: 'log', 116 | text: 'log', 117 | symbol: '\\log()', 118 | shift: 5, 119 | selectionInput: 5, 120 | type: 'text', 121 | newLine: false, 122 | objectType: 'latexFormatterSetting', 123 | }, 124 | sin: { 125 | des: 'sin', 126 | text: 'sin', 127 | symbol: '\\sin()', 128 | shift: 5, 129 | selectionInput: 5, 130 | type: 'text', 131 | newLine: true, 132 | objectType: 'latexFormatterSetting', 133 | }, 134 | cos: { 135 | des: 'cos', 136 | text: 'cos', 137 | symbol: '\\cos()', 138 | shift: 5, 139 | selectionInput: 5, 140 | type: 'text', 141 | newLine: false, 142 | objectType: 'latexFormatterSetting', 143 | }, 144 | tan: { 145 | des: 'tan', 146 | text: 'tan', 147 | symbol: '\\tan()', 148 | shift: 5, 149 | selectionInput: 5, 150 | type: 'text', 151 | newLine: false, 152 | objectType: 'latexFormatterSetting', 153 | }, 154 | cot: { 155 | des: 'cot', 156 | text: 'cot', 157 | symbol: '\\cot()', 158 | shift: 5, 159 | selectionInput: 5, 160 | type: 'text', 161 | newLine: false, 162 | objectType: 'latexFormatterSetting', 163 | }, 164 | sin2: { 165 | des: 'cos^2', 166 | text: 'sin2', 167 | symbol: '\\sin^2()', 168 | shift: 7, 169 | selectionInput: 7, 170 | type: 'text', 171 | newLine: true, 172 | objectType: 'latexFormatterSetting', 173 | }, 174 | cos2: { 175 | des: 'cos^2', 176 | text: 'cos2', 177 | symbol: '\\cos^2()', 178 | shift: 7, 179 | selectionInput: 7, 180 | type: 'text', 181 | newLine: false, 182 | objectType: 'latexFormatterSetting', 183 | }, 184 | tan2: { 185 | des: 'tan^2', 186 | text: 'tan2', 187 | symbol: '\\tan^2()', 188 | shift: 7, 189 | selectionInput: 7, 190 | type: 'text', 191 | newLine: false, 192 | objectType: 'latexFormatterSetting', 193 | }, 194 | cot2: { 195 | des: 'cot^2', 196 | text: 'cot2', 197 | symbol: '\\cot^2()', 198 | shift: 7, 199 | selectionInput: 7, 200 | type: 'text', 201 | newLine: false, 202 | objectType: 'latexFormatterSetting', 203 | }, 204 | roundBrackets: { 205 | des: 'round brackets', 206 | text: '(x)', 207 | symbol: '\\left(\\right)', 208 | shift: 6, 209 | selectionInput: 6, 210 | type: 'text', 211 | newLine: true, 212 | objectType: 'latexFormatterSetting', 213 | }, 214 | squareBrackets: { 215 | des: 'square brackets', 216 | text: '[x]', 217 | symbol: '\\left[\\right]', 218 | shift: 6, 219 | selectionInput: 6, 220 | type: 'text', 221 | newLine: false, 222 | objectType: 'latexFormatterSetting', 223 | }, 224 | curlyBrackets: { 225 | des: 'curly brackets', 226 | text: '{x}', 227 | symbol: '\\left\\{\\right\\}', 228 | shift: 7, 229 | selectionInput: 7, 230 | type: 'text', 231 | newLine: false, 232 | objectType: 'latexFormatterSetting', 233 | }, 234 | pipeBrackets: { 235 | des: 'pipe brackets', 236 | text: '|x|', 237 | symbol: '\\left|\\right|', 238 | shift: 6, 239 | selectionInput: 6, 240 | type: 'text', 241 | newLine: false, 242 | objectType: 'latexFormatterSetting', 243 | }, 244 | doublePipeBrackets: { 245 | des: 'double pipe brackets', 246 | text: '||x||', 247 | symbol: '\\left\\|\\right\\|', 248 | shift: 7, 249 | selectionInput: 7, 250 | type: 'text', 251 | newLine: false, 252 | objectType: 'latexFormatterSetting', 253 | }, 254 | }; 255 | 256 | export function latexFormatter(editor: Editor, item: latexFormatterSetting) { 257 | if (editor) { 258 | const isSelection = editor.somethingSelected; 259 | const selection = editor.getSelection(); 260 | const curserStart = editor.getCursor('from'); 261 | const curserEnd = editor.getCursor('to'); 262 | const line = editor.getLine(curserStart.line); 263 | 264 | editor.focus(); 265 | if (isSelection) { 266 | let replacment = selection.trim(); 267 | 268 | editor.replaceSelection( 269 | item.symbol.substring(0, item.selectionInput) + 270 | replacment + 271 | item.symbol.substring(item.selectionInput), 272 | ); 273 | editor.setCursor(curserStart.line, curserStart.ch + item.shift); 274 | } else { 275 | editor.replaceRange(item.symbol, curserStart); 276 | editor.setCursor(curserStart.line, curserStart.ch + item.shift); 277 | } 278 | } 279 | } 280 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /* Sets all the text color to red! */ 2 | .nav-action-button { 3 | color: var(--text-muted); 4 | cursor: pointer; 5 | padding: 0px; 6 | margin: 5px; 7 | border-radius: 4px; 8 | } 9 | 10 | .nav-action-text-button { 11 | color: var(--text-muted); 12 | cursor: pointer; 13 | padding: 5px; 14 | margin: 4px; 15 | border-radius: 4px; 16 | text-align: center; 17 | border: 1px solid; 18 | } 19 | .nav-action-text-button.is-active { 20 | background-color: var(--interactive-accent); 21 | color: var(--text-on-accent); 22 | } 23 | .nav-action-text-button.is-active:hover { 24 | color: var(--text-on-accent); 25 | } 26 | .nav-action-text-button:hover { 27 | color: var(--text-accent); 28 | } 29 | 30 | .color-icon { 31 | color: var(--text-muted); 32 | cursor: pointer; 33 | width: 16px; 34 | min-width: 16px; 35 | max-width: 16px; 36 | height: 16px; 37 | min-height: 16px; 38 | max-height: 16px; 39 | margin: 3px; 40 | display: inline-block; 41 | border-radius: 4px; 42 | } 43 | 44 | .command-list-view-row { 45 | display: flex; 46 | } 47 | .command-list-view-container { 48 | min-width: 60px; 49 | display: flex; 50 | } 51 | 52 | .command-list-view-icon { 53 | height: 24px; 54 | max-height: 24px; 55 | border: 1px solid gray; 56 | margin-right: auto; 57 | } 58 | 59 | .command-list-view-text { 60 | padding-left: 12px; 61 | color: #c7254e; 62 | } 63 | -------------------------------------------------------------------------------- /testings.md: -------------------------------------------------------------------------------- 1 | 2 | ## How to use the hotkey ALT+Q 3 | 4 | ``` json 5 | { 6 | "id": "obsidian-markdown-formatting-assistant-plugin", 7 | "name": "Markdown Formatting Assistant", 8 | "version": "0.4.0", 9 | "minAppVersion": "0.15.6", 10 | "description": "This Plugin provides a simple Editor for Markdown, HTML and Colors and in addition a command interface. The command interface facilitate a faster workflow.", 11 | "author": "Reocin", 12 | "authorUrl": "https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin", 13 | "isDesktopOnly": false 14 | } 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "es5", 8 | "allowJs": true, 9 | "noImplicitAny": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "lib": [ 13 | "dom", 14 | "es5", 15 | "scripthost", 16 | "es2015" 17 | ] 18 | }, 19 | "include": [ 20 | "**/*.ts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "0.1.0": "0.10.9", 3 | "0.1.1": "0.10.9", 4 | "0.1.2": "0.10.9", 5 | "0.2.0": "0.10.9", 6 | "0.2.1": "0.10.9", 7 | "0.2.2": "0.10.9", 8 | "0.3.0": "0.10.9", 9 | "0.3.1": "0.12.4", 10 | "0.3.2": "0.12.4", 11 | "0.4.0": "0.15.6", 12 | "0.4.1": "0.15.6" 13 | } 14 | --------------------------------------------------------------------------------