MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / actions

Function actions

src/handlers/quickTools.js:203–321  ·  view source on GitHub ↗
(action, value)

Source from the content-addressed store, hash-verified

201 * @returns {boolean} Whether the action was performed
202 */
203export default function actions(action, value) {
204 setQuicktoolsUsed();
205
206 const { editor } = editorManager;
207 const { $input, $replaceInput } = quickTools;
208
209 if (Object.keys(state).includes(action)) {
210 setInput();
211 value = !state[action];
212 state[action] = value;
213 events[action].forEach((cb) => cb(value));
214 if (Object.values(state).includes(true)) {
215 $input.focus();
216 } else if (input) {
217 input.focus();
218 } else {
219 $input.blur();
220 }
221
222 return value;
223 }
224
225 switch (action) {
226 case "insert":
227 return insertText(value);
228
229 case "command": {
230 const commandName =
231 typeof value === "string" ? value : String(value ?? "");
232 if (!commandName) return false;
233 return executeCommand(commandName, editor);
234 }
235
236 case "key": {
237 value = Number.parseInt(value, 10);
238 if (value < 37 || value > 40) {
239 resetKeys();
240 }
241 setInput();
242 getInput().dispatchEvent(
243 KeyboardEvent("keydown", getKeys({ keyCode: value })),
244 );
245 return true;
246 }
247
248 case "search":
249 toggleSearch();
250 return actionStack.has("search-bar");
251
252 case "toggle":
253 toggle();
254 return true;
255
256 case "set-height":
257 if (typeof value === "object") {
258 setHeight(value.height, value.save);
259 } else {
260 setHeight(value);

Callers 7

afterRenderFunction · 0.85
editorFile.jsFile · 0.85
findFunction · 0.85
runFunction · 0.85
callbackFunction · 0.85
initFunction · 0.85
clickFunction · 0.85

Calls 15

executeCommandFunction · 0.90
setQuicktoolsUsedFunction · 0.85
setInputFunction · 0.85
insertTextFunction · 0.85
StringInterface · 0.85
resetKeysFunction · 0.85
getInputFunction · 0.85
KeyboardEventFunction · 0.85
getKeysFunction · 0.85
toggleSearchFunction · 0.85
searchSettingsFunction · 0.85
getRefValueFunction · 0.85

Tested by

no test coverage detected