|
| 1 | +# Commands |
| 2 | + |
| 3 | +TyX commands are based on Lexical and Mathfield commands. |
| 4 | +The keyboard shortcuts correspond to command sequences, which are commands separated by a semicolon. |
| 5 | + |
| 6 | +Commands consist of a command function followed by optional arguments. |
| 7 | +This page lists the available commands (stored in `the commands file <https://github.com/tyx-editor/TyX/tree/main/src/commands.ts>`\_). |
| 8 | + |
| 9 | +## Toggle Keyboard Map |
| 10 | + |
| 11 | +Given a keyboard map name (or null), if the current keyboard map is that given keyboard map, turn it off. Otherwise, turn it on. |
| 12 | + |
| 13 | +Example: `toggleKeyboardMap Hebrew` |
| 14 | + |
| 15 | +## Format Element |
| 16 | + |
| 17 | +Format the alignment of the current element to one of 'left', 'start', 'center', 'right', 'end', 'justify' or ''. |
| 18 | + |
| 19 | +Example: `formatElement center` |
| 20 | + |
| 21 | +## Format Text |
| 22 | + |
| 23 | +Toggle the format of the current selected text in one of 'bold', 'underline', 'strikethrough', 'italic', 'highlight', 'code', 'subscript', 'superscript' |
| 24 | + |
| 25 | +Example: `formatText bold` |
| 26 | + |
| 27 | +## Clear Formatting |
| 28 | + |
| 29 | +Clear all formatting of the selected text. |
| 30 | + |
| 31 | +Example: `clearFormatting` |
| 32 | + |
| 33 | +## Undo |
| 34 | + |
| 35 | +Undo the last command. |
| 36 | + |
| 37 | +Example: `undo` |
| 38 | + |
| 39 | +## Redo |
| 40 | + |
| 41 | +Redo the last command. |
| 42 | + |
| 43 | +Example: `redo` |
| 44 | + |
| 45 | +## Insert Math |
| 46 | + |
| 47 | +Inserts a math inline/block node according to the second parameter "inline". Setting it to true adds an inline math node. |
| 48 | + |
| 49 | +Example: `insertMath true` |
| 50 | + |
| 51 | +## Insert Ordered List |
| 52 | + |
| 53 | +Insert an ordered list. |
| 54 | + |
| 55 | +Example: `insertOrderedList` |
| 56 | + |
| 57 | +## Insert Unordered List |
| 58 | + |
| 59 | +Insert an unordered list. |
| 60 | + |
| 61 | +Example: `insertUnorderedList` |
| 62 | + |
| 63 | +## Insert Line Break |
| 64 | + |
| 65 | +Insert a line break. Moves to the new line if the second argument is `true`. |
| 66 | + |
| 67 | +Example: `insertUnorderedList true` |
| 68 | + |
| 69 | +## Insert Horizontal Line |
| 70 | + |
| 71 | +Insert a horizontal line. |
| 72 | + |
| 73 | +Example: `insertHorizontalLine` |
| 74 | + |
| 75 | +## Insert Quote |
| 76 | + |
| 77 | +Insert a quote node. |
| 78 | + |
| 79 | +Example: `insertQuote` |
| 80 | + |
| 81 | +## Insert Code Block |
| 82 | + |
| 83 | +Insert a code block node. |
| 84 | + |
| 85 | +Example: `insertCodeBlock` |
| 86 | + |
| 87 | +## Insert Heading |
| 88 | + |
| 89 | +Insert a heading node of the specified level. |
| 90 | + |
| 91 | +Example: `insertHeading 1` |
| 92 | + |
| 93 | +Example: `insertHeading 6` |
| 94 | + |
| 95 | +## Insert Typst Code |
| 96 | + |
| 97 | +Insert a typst code node. |
| 98 | + |
| 99 | +Example: `insertTypstCode` |
| 100 | + |
| 101 | +## Insert Image |
| 102 | + |
| 103 | +Insert an image node with the given source URL. If no argument is given, open a dialog to pick an image. |
| 104 | + |
| 105 | +Note: images are not supported on the web version due to local storage limit concerns. |
| 106 | + |
| 107 | +Example: `insertImage ./example.png` |
| 108 | + |
| 109 | +Example: `insertImage` |
| 110 | + |
| 111 | +## Insert Function Call |
| 112 | + |
| 113 | +Insert a function call node with the given function (and optionally initial parameter values or inline customization). |
| 114 | + |
| 115 | +If no parameters are passed, a modal is used to pick the function. |
| 116 | + |
| 117 | +Example: `insertFunctionCall footnote` |
| 118 | + |
| 119 | +Example: `insertFunctionCall ["h", [{"type": "length", "value": "10", "unit": "pt"}]]` |
| 120 | + |
| 121 | +Example: `insertFunctionCall` |
| 122 | + |
| 123 | +## Set Function Call |
| 124 | + |
| 125 | +Changes the currently selected function call to be the specified function. |
| 126 | + |
| 127 | +If the definition's positional and named parameters is exactly the same, keeps the existing values. |
| 128 | + |
| 129 | +If no function call is currently selected, inserts the specified function call. |
| 130 | + |
| 131 | +Example: `setFunctionCall h` |
| 132 | + |
| 133 | +Example: `setFunctionCall v` |
| 134 | + |
| 135 | +## Toggle Math Inline |
| 136 | + |
| 137 | +Toggles the current math node between inline/block, or inserts a new block math node if no math node is selected. |
| 138 | + |
| 139 | +Example: `toggleMathInline` |
| 140 | + |
| 141 | +## Math |
| 142 | + |
| 143 | +Runs the given `Mathfield command <https://cortexjs.io/mathfield/guides/commands/>`\_ in the currently selected math editor. |
| 144 | + |
| 145 | +Example: `math insert \alpha` |
| 146 | + |
| 147 | +## Indent |
| 148 | + |
| 149 | +Indents the current paragraph or list item (increases the indentation level by one). |
| 150 | + |
| 151 | +Example: `indent` |
| 152 | + |
| 153 | +## Outdent |
| 154 | + |
| 155 | +Outdents the current paragraph or list item (reduces the indentation level by one). |
| 156 | + |
| 157 | +Example: `outdent` |
| 158 | + |
| 159 | +## Insert Table |
| 160 | + |
| 161 | +Inserts a table with the given amount of rows/columns and whether headers are present. |
| 162 | + |
| 163 | +Example: `insertTable {"rows": 3, "columns": 3}` |
| 164 | + |
| 165 | +Example: `insertTable {"rows": 2, "columns": 2, "includeHeaders": false}` |
| 166 | + |
| 167 | +Example: `insertTable {"rows": 2, "columns": 2, "includeHeaders": {"rows": false, "columns": true}}` |
| 168 | + |
| 169 | +## Table Insert Row Below |
| 170 | + |
| 171 | +Inserts a row below the current row in the current table. |
| 172 | + |
| 173 | +Example: `tableInsertRowBelow` |
| 174 | + |
| 175 | +## Table Insert Column Right |
| 176 | + |
| 177 | +Inserts a column to the right of the current column in the current table. |
| 178 | + |
| 179 | +Example: `tableInsertColumnRight` |
| 180 | + |
| 181 | +## Table Remove Row |
| 182 | + |
| 183 | +Removes the current row in the current table. |
| 184 | + |
| 185 | +Example: `tableRemoveRow` |
| 186 | + |
| 187 | +## Table Remove Column |
| 188 | + |
| 189 | +Removes the current column in the current table. |
| 190 | + |
| 191 | +Example: `tableRemoveColumn` |
| 192 | + |
| 193 | +## Set Link |
| 194 | + |
| 195 | +Sets the link of the currently selected text to equal the given URL. |
| 196 | + |
| 197 | +Example: `setLink https://tyx-editor.com` |
| 198 | + |
| 199 | +## Open Link Popup |
| 200 | + |
| 201 | +Opens the link popup to choose a URL to toggle the currently selected text to link to. |
| 202 | + |
| 203 | +Example: `openLinkPopup` |
| 204 | + |
| 205 | +## File Open |
| 206 | + |
| 207 | +Opens the file open dialog. |
| 208 | + |
| 209 | +Example: `fileOpen` |
| 210 | + |
| 211 | +## File New |
| 212 | + |
| 213 | +Opens the new file dialog. |
| 214 | + |
| 215 | +Example: `fileNew` |
| 216 | + |
| 217 | +## File New From Template |
| 218 | + |
| 219 | +Opens the templates dialog to create a new file. |
| 220 | + |
| 221 | +Example: `fileNewFromTemplate` |
| 222 | + |
| 223 | +## File Save |
| 224 | + |
| 225 | +Save the current file. |
| 226 | + |
| 227 | +Example: `fileSave` |
| 228 | + |
| 229 | +## File Save As |
| 230 | + |
| 231 | +Opens the file save as dialog. |
| 232 | + |
| 233 | +Example: `fileSaveAs` |
| 234 | + |
| 235 | +## File Export |
| 236 | + |
| 237 | +Exports the file to the given format. Currently only `typst` is supported. |
| 238 | + |
| 239 | +Example: `fileExport typst` |
| 240 | + |
| 241 | +## File Close |
| 242 | + |
| 243 | +Closes the current file or the file at the specified index. |
| 244 | + |
| 245 | +Example: `fileClose` |
| 246 | + |
| 247 | +Example: `fileClose 0` |
| 248 | + |
| 249 | +## File Preview |
| 250 | + |
| 251 | +Previews the current file as a PDF. |
| 252 | + |
| 253 | +Example: `filePreview` |
| 254 | + |
| 255 | +## Open Settings |
| 256 | + |
| 257 | +Opens the app settings modal. |
| 258 | + |
| 259 | +Example: `openSettings` |
| 260 | + |
| 261 | +## Open Document Settings |
| 262 | + |
| 263 | +Opens the document settings modal. |
| 264 | + |
| 265 | +Example: `openDocumentSettings` |
0 commit comments