Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement model for editor shortcuts & commands #6953

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"@hcengineering/analytics-collector-assets": "^0.6.0",
"@hcengineering/analytics-collector-resources": "^0.6.0",
"@hcengineering/ai-bot": "^0.6.0",
"@hcengineering/ai-bot-assets": "^0.6.0",
"@hcengineering/ai-bot-resources": "^0.6.0",
"electron-squirrel-startup": "~1.0.0",
"dotenv": "~16.0.0",
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/ui/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { documentsId } from '@hcengineering/controlled-documents'
import aiBot, { aiBotId } from '@hcengineering/ai-bot'

import '@hcengineering/activity-assets'
import '@hcengineering/ai-bot-assets'
import '@hcengineering/attachment-assets'
import '@hcengineering/bitrix-assets'
import '@hcengineering/board-assets'
Expand Down Expand Up @@ -185,6 +186,7 @@ function configureI18n (): void {
addStringsLoader(loveId, async (lang: string) => await import(`@hcengineering/love-assets/lang/${lang}.json`))
addStringsLoader(printId, async (lang: string) => await import(`@hcengineering/print-assets/lang/${lang}.json`))
addStringsLoader(analyticsCollectorId, async (lang: string) => await import(`@hcengineering/analytics-collector-assets/lang/${lang}.json`))
addStringsLoader(aiBotId, async (lang: string) => await import(`@hcengineering/ai-bot-assets/lang/${lang}.json`))
}

export async function configurePlatform (): Promise<void> {
Expand Down
1 change: 1 addition & 0 deletions dev/prod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"@hcengineering/products-assets": "^0.1.0",
"@hcengineering/products-resources": "^0.1.0",
"@hcengineering/ai-bot": "^0.6.0",
"@hcengineering/ai-bot-assets": "^0.6.0",
"@hcengineering/ai-bot-resources": "^0.6.0",
"@sentry/svelte": "~7.101.0",
"posthog-js": "~1.122.0"
Expand Down
2 changes: 2 additions & 0 deletions dev/prod/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import aiBot, { aiBotId } from '@hcengineering/ai-bot'
import { bitrixId } from '@hcengineering/bitrix'

import '@hcengineering/activity-assets'
import '@hcengineering/ai-bot-assets'
import '@hcengineering/attachment-assets'
import '@hcengineering/bitrix-assets'
import '@hcengineering/board-assets'
Expand Down Expand Up @@ -224,6 +225,7 @@ function configureI18n(): void {
addStringsLoader(loveId, async (lang: string) => await import(`@hcengineering/love-assets/lang/${lang}.json`))
addStringsLoader(printId, async (lang: string) => await import(`@hcengineering/print-assets/lang/${lang}.json`))
addStringsLoader(analyticsCollectorId, async (lang: string) => await import(`@hcengineering/analytics-collector-assets/lang/${lang}.json`))
addStringsLoader(aiBotId, async (lang: string) => await import(`@hcengineering/ai-bot-assets/lang/${lang}.json`))
}

export async function configurePlatform() {
Expand Down
1 change: 1 addition & 0 deletions models/ai-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"dependencies": {
"@hcengineering/ai-bot": "^0.6.0",
"@hcengineering/text-editor": "^0.6.0",
"@hcengineering/analytics-collector": "^0.6.0",
"@hcengineering/chunter": "^0.6.20",
"@hcengineering/core": "^0.6.32",
Expand Down
14 changes: 14 additions & 0 deletions models/ai-bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { type Builder } from '@hcengineering/model'
import core, { type Domain } from '@hcengineering/core'
import chunter from '@hcengineering/chunter'
import analyticsCollector from '@hcengineering/analytics-collector'
import textEditor from '@hcengineering/text-editor'
import view from '@hcengineering/view'

import aiBot from './plugin'

Expand All @@ -31,4 +33,16 @@ export function createModel (builder: Builder): void {
ofClass: analyticsCollector.class.OnboardingChannel,
component: aiBot.component.OnboardingChannelPanelExtension
})

builder.createDoc(textEditor.class.TextEditorInlineCommand, core.space.Model, {
command: 'translate',
commandTemplate: '/translate [lang] [text]',
title: aiBot.string.Translate,
description: aiBot.string.InstantlyTranslateText,
icon: view.icon.Translate,
category: 'general',
type: 'command',
action: aiBot.command.Translate,
visibilityTester: aiBot.function.IsAiEnabled
})
}
9 changes: 8 additions & 1 deletion models/ai-bot/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
// limitations under the License.
//

import { mergeIds } from '@hcengineering/platform'
import { type Resource, mergeIds } from '@hcengineering/platform'
import aiBot, { aiBotId } from '@hcengineering/ai-bot'
import type { AnyComponent } from '@hcengineering/ui/src/types'
import { type InlineCommandAction, type InlineCommandVisibilityTester } from '@hcengineering/text-editor'

export default mergeIds(aiBotId, aiBot, {
function: {
IsAiEnabled: '' as Resource<InlineCommandVisibilityTester>
},
component: {
OnboardingChannelPanelExtension: '' as AnyComponent
},
command: {
Translate: '' as Resource<InlineCommandAction>
}
})
8 changes: 6 additions & 2 deletions models/chunter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import {
TObjectChatPanel,
TThreadMessage,
TTypingInfo,
TChunterExtension
TChunterExtension,
TPrivateThreadMessage,
TPrivateChatMessage
} from './types'

export { chunterId } from '@hcengineering/chunter'
Expand All @@ -57,7 +59,9 @@ export function createModel (builder: Builder): void {
TChatSyncInfo,
TInlineButton,
TTypingInfo,
TChunterExtension
TChunterExtension,
TPrivateThreadMessage,
TPrivateChatMessage
)

builder.createDoc(
Expand Down
22 changes: 20 additions & 2 deletions models/chunter/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import type {
ObjectChatPanel,
ThreadMessage,
TypingInfo,
ChunterExtensionPoint
ChunterExtensionPoint,
PrivateThreadMessage,
PrivateChatMessage
} from '@hcengineering/chunter'
import {
type Class,
Expand All @@ -50,7 +52,11 @@ import {
type Ref,
type Timestamp
} from '@hcengineering/core'
import contact, { type ChannelProvider as SocialChannelProvider, type Person } from '@hcengineering/contact'
import contact, {
type ChannelProvider as SocialChannelProvider,
type Person,
type PersonSpace
} from '@hcengineering/contact'
import activity, { type ActivityMessage } from '@hcengineering/activity'
import { TActivityMessage } from '@hcengineering/model-activity'
import attachment from '@hcengineering/model-attachment'
Expand Down Expand Up @@ -119,6 +125,18 @@ export class TThreadMessage extends TChatMessage implements ThreadMessage {
objectClass!: Ref<Class<Doc>>
}

@Model(chunter.class.PrivateChatMessage, chunter.class.ChatMessage)
@UX(chunter.string.Message, chunter.icon.Thread, undefined, undefined, undefined, chunter.string.Threads)
export class TPrivateChatMessage extends TChatMessage implements PrivateChatMessage {
declare space: Ref<PersonSpace>
}

@Model(chunter.class.PrivateThreadMessage, chunter.class.ThreadMessage)
@UX(chunter.string.ThreadMessage, chunter.icon.Thread, undefined, undefined, undefined, chunter.string.Threads)
export class TPrivateThreadMessage extends TThreadMessage implements PrivateThreadMessage {
declare space: Ref<PersonSpace>
}

@Model(chunter.class.ChatMessageViewlet, core.class.Doc, DOMAIN_MODEL)
export class TChatMessageViewlet extends TDoc implements ChatMessageViewlet {
@Prop(TypeRef(core.class.Doc), core.string.Class)
Expand Down
3 changes: 2 additions & 1 deletion models/text-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@hcengineering/ui": "^0.6.15",
"@hcengineering/text": "^0.6.5",
"@hcengineering/text-editor": "^0.6.0",
"@hcengineering/model-core": "^0.6.0"
"@hcengineering/model-core": "^0.6.0",
"@hcengineering/view": "^0.6.13"
}
}
Loading
Loading