(id: MessageKey)
| 129 | ], |
| 130 | |
| 131 | async runCommand(id: MessageKey) { |
| 132 | const { translations: t, commands, isReady } = get(); |
| 133 | if (!isReady()) { |
| 134 | console.log("editor is not ready!"); |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | const r = await Promise.resolve(commands.find((item) => item.id === id)?.run()); |
| 139 | let isSucc = true; |
| 140 | const name = t!(id); |
| 141 | |
| 142 | if (r !== undefined) { |
| 143 | if (r) { |
| 144 | // @ts-ignore |
| 145 | toastSucc(t!("cmd_exec_succ", { name })); |
| 146 | } else { |
| 147 | // @ts-ignore |
| 148 | toastErr(t!(r ? r : "cmd_exec_fail", { name })); |
| 149 | isSucc = false; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | sendGAEvent("event", "cmd_usage", { name, isSucc }); |
| 154 | }, |
| 155 | |
| 156 | setTranslations(translations: ReturnType<typeof useTranslations>) { |
| 157 | set({ translations }); |
no test coverage detected