Skip to content

Commit f326e35

Browse files
authored
feat: minimized screen recorder (#9619)
Signed-off-by: Alexander Onnikov <[email protected]>
1 parent fb65165 commit f326e35

File tree

54 files changed

+1885
-1134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1885
-1134
lines changed

models/recorder/src/migration.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2024 Hardcore Engineering Inc.
2+
// Copyright © 2025 Hardcore Engineering Inc.
33
//
44
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License. You may
@@ -13,9 +13,37 @@
1313
// limitations under the License.
1414
//
1515

16-
import type { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
16+
import drive from '@hcengineering/drive'
17+
import {
18+
type MigrateOperation,
19+
type MigrationClient,
20+
type MigrationUpgradeClient,
21+
createDefaultSpace,
22+
tryUpgrade
23+
} from '@hcengineering/model'
24+
import { recorderId } from '@hcengineering/recorder'
25+
import recorder from './plugin'
1726

1827
export const recorderOperation: MigrateOperation = {
1928
async migrate (client: MigrationClient, mode): Promise<void> {},
20-
async upgrade (state: Map<string, Set<string>>, client: () => Promise<MigrationUpgradeClient>): Promise<void> {}
29+
async upgrade (state: Map<string, Set<string>>, client: () => Promise<MigrationUpgradeClient>, mode): Promise<void> {
30+
await tryUpgrade(mode, state, client, recorderId, [
31+
{
32+
state: 'create-recorder-drive',
33+
func: async (client) => {
34+
await createDefaultSpace(
35+
client,
36+
recorder.space.Drive,
37+
{
38+
name: 'Screen Recordings',
39+
description: 'Screen recordings',
40+
type: drive.spaceType.DefaultDrive,
41+
autoJoin: true
42+
},
43+
drive.class.Drive
44+
)
45+
}
46+
}
47+
])
48+
}
2149
}

packages/presentation/src/components/FilePreview.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import { imageSizeToRatio } from '../image'
3131
import { FilePreviewExtension } from '../types'
3232
33-
export let file: Ref<Blob>
33+
export let file: Ref<Blob> | string
3434
export let name: string
3535
export let contentType: string
3636
export let metadata: BlobMetadata | undefined

packages/ui/src/components/SplitButton.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
>
7474
{#if icon || $$slots.icon}
7575
<div class="btn-icon pointer-events-none">
76-
{#if icon}<Icon bind:icon size={iconSize} {iconProps} />{/if}
76+
{#if icon}<Icon {icon} size={iconSize} {iconProps} />{/if}
7777
{#if $$slots.icon}<slot name="icon" />{/if}
7878
</div>
7979
{/if}
@@ -95,7 +95,7 @@
9595
>
9696
{#if secondIcon || $$slots.secondIcon}
9797
<div class="btn-icon pointer-events-none">
98-
{#if secondIcon}<Icon bind:icon={secondIcon} size={secondIconSize} iconProps={secondIconProps} />{/if}
98+
{#if secondIcon}<Icon icon={secondIcon} size={secondIconSize} iconProps={secondIconProps} />{/if}
9999
{#if $$slots.secondIcon}<slot name="secondIcon" />{/if}
100100
</div>
101101
{/if}

packages/ui/src/popups.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export function showPopup (
104104
const pos = popups.findIndex((p) => (p as CompAndProps).id === id && p.type === 'popup')
105105
if (pos !== -1) {
106106
popups.splice(pos, 1)
107+
void onClose?.(undefined)
107108
}
108109
return popups
109110
})

plugins/attachment-resources/src/components/AttachmentRefInput.svelte

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
export let objectId: Ref<Doc>
5959
export let space: Ref<Space>
6060
export let _class: Ref<Class<Doc>>
61+
export let docId: Ref<Doc> | undefined = undefined
6162
export let docClass: Ref<Class<Doc>> | undefined = undefined
6263
export let content: Markup = EmptyMarkup
6364
export let iconSend: Asset | AnySvelteComponent | undefined = undefined
@@ -434,6 +435,7 @@
434435
435436
async function onFileUploaded ({ uuid, name, file, metadata }: FileUploadCallbackParams): Promise<void> {
436437
try {
438+
await updateAttachments(objectId)
437439
await _createAttachment(uuid, name, file, metadata)
438440
} catch (err: any) {
439441
void setPlatformStatus(unknownError(err))
@@ -442,25 +444,20 @@
442444
443445
async function uploadWith (uploader: UploadHandlerDefinition): Promise<void> {
444446
const upload = await getResource(uploader.handler)
445-
await upload({ onFileUploaded })
447+
const target = { objectId: docId ?? objectId, objectClass: docClass ?? _class }
448+
await upload({ onFileUploaded, target })
446449
}
447450
448-
let uploadActions: RefAction[] = []
449-
$: void getUploadHandlers({ category: 'media' }).then((handlers) => {
450-
let index = 1000
451-
const actions: RefAction[] = []
452-
for (const handler of handlers) {
453-
actions.push({
454-
order: handler.order ?? index++,
455-
label: handler.label,
456-
icon: handler.icon,
457-
action: () => {
458-
void uploadWith(handler)
459-
}
460-
})
451+
let uploadActionIndex = 1000
452+
const uploadHandlers = getUploadHandlers(client, { category: 'media' })
453+
const uploadActions: RefAction[] = uploadHandlers.map((handler) => ({
454+
order: handler.order ?? uploadActionIndex++,
455+
label: handler.label,
456+
icon: handler.icon,
457+
action: () => {
458+
void uploadWith(handler)
461459
}
462-
uploadActions = actions
463-
})
460+
}))
464461
</script>
465462

466463
<div class="flex-col no-print" bind:this={refContainer}>

plugins/attachment-resources/src/components/AttachmentStyleBoxCollabEditor.svelte

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@
3636
getModelRefActions
3737
} from '@hcengineering/text-editor-resources'
3838
import { AnySvelteComponent, getEventPositionElement, getPopupPositionElement } from '@hcengineering/ui'
39-
import { uploadFiles, type FileUploadCallbackParams } from '@hcengineering/uploader'
39+
import {
40+
getUploadHandlers,
41+
uploadFiles,
42+
UploadHandlerDefinition,
43+
type FileUploadCallbackParams
44+
} from '@hcengineering/uploader'
4045
import { getCollaborationUser, getObjectId } from '@hcengineering/view-resources'
4146
4247
import AttachmentsGrid from './AttachmentsGrid.svelte'
@@ -66,6 +71,7 @@
6671
let refActions: RefAction[] = []
6772
let extraActions: RefAction[] = []
6873
let modelRefActions: RefAction[] = []
74+
let uploadActions: RefAction[] = []
6975
7076
$: if (enableAttachments && !readonly) {
7177
extraActions = [
@@ -79,7 +85,7 @@
7985
label: textEditor.string.Table,
8086
icon: TableIcon,
8187
action: handleTable,
82-
order: 1501
88+
order: 1500
8389
}
8490
]
8591
} else {
@@ -89,11 +95,30 @@
8995
void getModelRefActions().then((actions) => {
9096
modelRefActions = actions
9197
})
98+
99+
async function uploadWith (uploader: UploadHandlerDefinition): Promise<void> {
100+
const upload = await getResource(uploader.handler)
101+
const target = { objectId: object._id, objectClass: object._class }
102+
await upload({ onFileUploaded, target })
103+
}
104+
105+
let uploadActionIndex = 1000
106+
const uploadHandlers = getUploadHandlers(client, { category: 'media' })
107+
uploadActions = uploadHandlers.map((handler) => ({
108+
order: handler.order ?? uploadActionIndex++,
109+
label: handler.label,
110+
icon: handler.icon,
111+
action: () => {
112+
void uploadWith(handler)
113+
}
114+
}))
115+
92116
$: refActions = readonly
93117
? []
94118
: defaultRefActions
95119
.concat(extraActions)
96120
.concat(modelRefActions)
121+
.concat(uploadActions)
97122
.sort((a, b) => a.order - b.order)
98123
99124
let progress = false

plugins/attachment-resources/src/components/Attachments.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@
7070
7171
loading++
7272
try {
73+
const target = { objectId, objectClass: object?._class ?? _class }
7374
const options = {
75+
target,
7476
onFileUploaded,
75-
showProgress: {
76-
target: { objectId, objectClass: object?._class ?? _class }
77-
}
77+
showProgress: { target }
7878
}
7979
await uploadFiles(list, options)
8080
} finally {

plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
{focusIndex}
231231
bind:this={inputRef}
232232
bind:content={inputContent}
233+
docId={object._id}
233234
docClass={object._class}
234235
{_class}
235236
space={getChannelSpace(object._class, object._id, object.space)}

plugins/communication-resources/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@hcengineering/text-editor-resources": "^0.6.0",
6565
"@hcengineering/text-markdown": "^0.6.0",
6666
"@hcengineering/ui": "^0.6.15",
67+
"@hcengineering/uploader": "^0.6.0",
6768
"@hcengineering/view": "^0.6.13",
6869
"@hcengineering/view-resources": "^0.6.0",
6970
"@tiptap/core": "^2.11.7",

plugins/communication-resources/src/components/message/MessageInput.svelte

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
-->
1515

1616
<script lang="ts">
17-
import { generateId, Markup, RateLimiter, Ref } from '@hcengineering/core'
17+
import { Markup, RateLimiter, Ref, generateId } from '@hcengineering/core'
1818
import { tick, createEventDispatcher } from 'svelte'
1919
import {
2020
uploadFile,
@@ -37,6 +37,7 @@
3737
import { AttachmentPresenter, LinkPreviewCard } from '@hcengineering/attachment-resources'
3838
import { areEqualMarkups, isEmptyMarkup } from '@hcengineering/text'
3939
import { updateMyPresence } from '@hcengineering/presence-resources'
40+
import { FileUploadCallbackParams, getUploadHandlers, UploadHandlerDefinition } from '@hcengineering/uploader'
4041
import { Component, showPopup, ThrottledCaller } from '@hcengineering/ui'
4142
import { getCurrentEmployee } from '@hcengineering/contact'
4243
import { Card } from '@hcengineering/card'
@@ -306,18 +307,17 @@
306307
const uuid = await uploadFile(file)
307308
const metadata = await getFileMetadata(file, uuid)
308309
310+
const blob = {
311+
blobId: uuid,
312+
mimeType: file.type,
313+
fileName: file.name,
314+
size: file.size,
315+
metadata
316+
}
317+
309318
draft = {
310319
...draft,
311-
blobs: [
312-
...draft.blobs,
313-
{
314-
blobId: uuid,
315-
mimeType: file.type,
316-
fileName: file.name,
317-
size: file.size,
318-
metadata
319-
}
320-
]
320+
blobs: [...draft.blobs, blob]
321321
}
322322
}
323323
@@ -509,6 +509,51 @@
509509
order: 99999
510510
}
511511
})
512+
513+
async function uploadWith (uploader: UploadHandlerDefinition): Promise<void> {
514+
const cardId = card._id
515+
516+
const onFileUploaded = async ({ uuid, name, file, size, metadata }: FileUploadCallbackParams): Promise<void> => {
517+
const blob = {
518+
blobId: uuid,
519+
mimeType: file.type,
520+
fileName: name,
521+
size: size ?? file.size,
522+
metadata
523+
}
524+
525+
// We are probably in different card, update the draft in storage
526+
let newDraft = getDraft(cardId)
527+
newDraft = {
528+
...newDraft,
529+
blobs: [...newDraft.blobs, blob]
530+
}
531+
saveDraft(cardId, newDraft, true)
532+
533+
// In case we are in the same card, update the draft in memory
534+
if (cardId === card._id) {
535+
draft = {
536+
...draft,
537+
blobs: [...draft.blobs, blob]
538+
}
539+
}
540+
}
541+
542+
const upload = await getResource(uploader.handler)
543+
const target = { objectId: card._id, objectClass: card._class }
544+
await upload({ onFileUploaded, target })
545+
}
546+
547+
let uploadActionIndex = 1000
548+
const uploadHandlers = getUploadHandlers(client, { category: 'media' })
549+
const uploadActions = uploadHandlers.map((handler) => ({
550+
order: handler.order ?? uploadActionIndex++,
551+
label: handler.label,
552+
icon: handler.icon,
553+
action: () => {
554+
void uploadWith(handler)
555+
}
556+
}))
512557
</script>
513558

514559
<!-- svelte-ignore a11y-click-events-have-key-events -->
@@ -536,7 +581,7 @@
536581
placeholderParams={title !== '' ? { title } : undefined}
537582
loading={progress}
538583
hasChanges={hasChanges(draft.blobs, message, draft.applets)}
539-
actions={[...defaultMessageInputActions, attachAction, ...appletActions]}
584+
actions={[...defaultMessageInputActions, attachAction, ...uploadActions, ...appletActions]}
540585
on:submit={handleSubmit}
541586
on:update={onUpdate}
542587
onCancel={onCancel ? handleCancel : undefined}

0 commit comments

Comments
 (0)