summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
authorwoxtu <woxtup@gmail.com>2024-07-18 00:31:52 +0900
committerGitHub <noreply@github.com>2024-07-18 00:31:52 +0900
commit6942a920c8c5bc51b358341bb9b451addcc4ec2b (patch)
tree59af0445f184c25596b4d36fed2b387137318ee3 /packages/frontend/src/scripts
parentchore: Use clipboard API directly (#14227) (diff)
downloadsharkey-6942a920c8c5bc51b358341bb9b451addcc4ec2b.tar.gz
sharkey-6942a920c8c5bc51b358341bb9b451addcc4ec2b.tar.bz2
sharkey-6942a920c8c5bc51b358341bb9b451addcc4ec2b.zip
refactor(frontend): Improve typing (#14240)
* Improve typing * Remove redundant promise * Refactor * Update packages/frontend/src/scripts/mfm-function-picker.ts Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> * Update packages/frontend/src/scripts/mfm-function-picker.ts Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> --------- Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/mfm-function-picker.ts29
1 files changed, 12 insertions, 17 deletions
diff --git a/packages/frontend/src/scripts/mfm-function-picker.ts b/packages/frontend/src/scripts/mfm-function-picker.ts
index 8867a8c50f..9938e534c1 100644
--- a/packages/frontend/src/scripts/mfm-function-picker.ts
+++ b/packages/frontend/src/scripts/mfm-function-picker.ts
@@ -7,29 +7,24 @@ import { Ref, nextTick } from 'vue';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { MFM_TAGS } from '@/const.js';
+import type { MenuItem } from '@/types/menu.js';
/**
* MFMの装飾のリストを表示する
*/
-export function mfmFunctionPicker(src: any, textArea: HTMLInputElement | HTMLTextAreaElement, textRef: Ref<string>) {
- return new Promise((res, rej) => {
- os.popupMenu([{
- text: i18n.ts.addMfmFunction,
- type: 'label',
- }, ...getFunctionList(textArea, textRef)], src);
- });
+export function mfmFunctionPicker(src: HTMLElement | EventTarget | null, textArea: HTMLInputElement | HTMLTextAreaElement, textRef: Ref<string>) {
+ os.popupMenu([{
+ text: i18n.ts.addMfmFunction,
+ type: 'label',
+ }, ...getFunctionList(textArea, textRef)], src);
}
-function getFunctionList(textArea: HTMLInputElement | HTMLTextAreaElement, textRef: Ref<string>) : object[] {
- const ret: object[] = [];
- MFM_TAGS.forEach(tag => {
- ret.push({
- text: tag,
- icon: 'ti ti-icons',
- action: () => add(textArea, textRef, tag),
- });
- });
- return ret;
+function getFunctionList(textArea: HTMLInputElement | HTMLTextAreaElement, textRef: Ref<string>): MenuItem[] {
+ return MFM_TAGS.map(tag => ({
+ text: tag,
+ icon: 'ti ti-icons',
+ action: () => add(textArea, textRef, tag),
+ }));
}
function add(textArea: HTMLInputElement | HTMLTextAreaElement, textRef: Ref<string>, type: string) {