mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-13 10:53:06 +00:00
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { getResource } from '@hcengineering/platform'
|
|
import { getClient } from '@hcengineering/presentation'
|
|
import { EmojiPopup, IconEmoji, showPopup } from '@hcengineering/ui'
|
|
import textEditor, { type RefAction } from '@hcengineering/text-editor'
|
|
|
|
import RiMention from '../icons/RIMention.svelte'
|
|
|
|
export const defaultRefActions: RefAction[] = [
|
|
{
|
|
label: textEditor.string.Mention,
|
|
icon: RiMention,
|
|
action: (_element, editorHandler) => {
|
|
editorHandler.insertText('@')
|
|
editorHandler.focus()
|
|
},
|
|
order: 3000
|
|
},
|
|
{
|
|
label: textEditor.string.Emoji,
|
|
icon: IconEmoji,
|
|
action: (element, editorHandler) => {
|
|
showPopup(
|
|
EmojiPopup,
|
|
{},
|
|
element,
|
|
(emoji) => {
|
|
if (emoji === null || emoji === undefined) {
|
|
return
|
|
}
|
|
editorHandler.insertEmoji(emoji.text, emoji.url)
|
|
editorHandler.focus()
|
|
},
|
|
() => {}
|
|
)
|
|
},
|
|
order: 4001
|
|
}
|
|
]
|
|
|
|
export async function getModelRefActions (): Promise<RefAction[]> {
|
|
const client = getClient()
|
|
|
|
const actions: RefAction[] = []
|
|
|
|
const items = await client.findAll(textEditor.class.RefInputActionItem, {})
|
|
for (const item of items) {
|
|
actions.push({
|
|
label: item.label,
|
|
icon: item.icon,
|
|
order: item.order ?? 10000,
|
|
action: await getResource(item.action)
|
|
})
|
|
}
|
|
|
|
return actions
|
|
}
|