From 8fba1e3db1b095eae6cc7b8034a7e5432bcce223 Mon Sep 17 00:00:00 2001 From: Rostislav Nagimov Date: Mon, 30 Jun 2025 13:38:16 +0500 Subject: [PATCH] Copy button notification (#9355) Signed-off-by: Rostislav Nagimov --- packages/presentation/lang/cs.json | 1 + packages/presentation/lang/de.json | 1 + packages/presentation/lang/en.json | 1 + packages/presentation/lang/es.json | 1 + packages/presentation/lang/fr.json | 1 + packages/presentation/lang/it.json | 1 + packages/presentation/lang/ja.json | 1 + packages/presentation/lang/pt.json | 3 +- packages/presentation/lang/ru.json | 1 + packages/presentation/lang/zh.json | 1 + packages/presentation/src/plugin.ts | 1 + .../src/components/CalDavAccess.svelte | 32 +++++++++++++++++-- plugins/document-assets/lang/cs.json | 1 + plugins/document-assets/lang/de.json | 1 + plugins/document-assets/lang/en.json | 1 + plugins/document-assets/lang/es.json | 1 + plugins/document-assets/lang/fr.json | 1 + plugins/document-assets/lang/it.json | 1 + plugins/document-assets/lang/ja.json | 1 + plugins/document-assets/lang/pt.json | 1 + plugins/document-assets/lang/ru.json | 1 + plugins/document-assets/lang/zh.json | 1 + .../src/components/EditDoc.svelte | 13 +++++++- plugins/document-resources/src/plugin.ts | 1 + 24 files changed, 64 insertions(+), 5 deletions(-) diff --git a/packages/presentation/lang/cs.json b/packages/presentation/lang/cs.json index 1bf79fc986..699e019a74 100644 --- a/packages/presentation/lang/cs.json +++ b/packages/presentation/lang/cs.json @@ -41,6 +41,7 @@ "ColorRemove": "Odstraňte předvolbu barev", "ColorReset": "Resetovat předvolby barev", "Copy": "Kopírovat", + "DocumentUrlCopied": "Zkopírováno!", "CopyLink": "Zkopírovat odkaz", "AccessDenied": "Objekt neexistuje nebo k němu nemáte oprávnění.", "UnableToFollowMention": "Nelze otevřít zmíněný objekt" diff --git a/packages/presentation/lang/de.json b/packages/presentation/lang/de.json index fa1ac46a10..05773d2a99 100644 --- a/packages/presentation/lang/de.json +++ b/packages/presentation/lang/de.json @@ -41,6 +41,7 @@ "ColorRemove": "Farbvoreinstellung entfernen", "ColorReset": "Farbvoreinstellungen zurücksetzen", "Copy": "Kopieren", + "DocumentUrlCopied": "Kopiert!", "CopyLink": "Link kopieren", "AccessDenied": "Das Objekt existiert nicht oder Sie haben keinen Zugriff darauf.", "UnableToFollowMention": "Das erwähnte Objekt kann nicht geöffnet werden" diff --git a/packages/presentation/lang/en.json b/packages/presentation/lang/en.json index af9c3b6458..a1be455588 100644 --- a/packages/presentation/lang/en.json +++ b/packages/presentation/lang/en.json @@ -41,6 +41,7 @@ "ColorRemove": "Remove color preset", "ColorReset": "Reset color presets", "Copy": "Copy", + "DocumentUrlCopied": "Copied!", "CopyLink": "Copy link", "AccessDenied": "Object doesn't exist or you are not permitted to access it.", "UnableToFollowMention": "Unable to open mentioned object" diff --git a/packages/presentation/lang/es.json b/packages/presentation/lang/es.json index 2a94940c90..6dc27401bb 100644 --- a/packages/presentation/lang/es.json +++ b/packages/presentation/lang/es.json @@ -41,6 +41,7 @@ "ColorRemove": "Eliminar el ajuste preestablecido de color", "ColorReset": "Restablecer ajustes preestablecidos de color", "Copy": "Copiar", + "DocumentUrlCopied": "¡Copiado!", "CopyLink": "Copiar enlace", "AccessDenied": "El objeto no existe o no tienes permiso para acceder a él.", "UnableToFollowMention": "No se puede abrir el objeto mencionado" diff --git a/packages/presentation/lang/fr.json b/packages/presentation/lang/fr.json index 18be4a534d..4c9e697f54 100644 --- a/packages/presentation/lang/fr.json +++ b/packages/presentation/lang/fr.json @@ -41,6 +41,7 @@ "ColorRemove": "Supprimer le préréglage de couleur", "ColorReset": "Réinitialiser les préréglages de couleur", "Copy": "Copier", + "DocumentUrlCopied": "Copié !", "CopyLink": "Copier le lien", "AccessDenied": "L’objet n’existe pas ou vous n’êtes pas autorisé à y accéder.", "UnableToFollowMention": "Impossible d’ouvrir l’objet mentionné" diff --git a/packages/presentation/lang/it.json b/packages/presentation/lang/it.json index b16ebb1c10..aab152f5d5 100644 --- a/packages/presentation/lang/it.json +++ b/packages/presentation/lang/it.json @@ -41,6 +41,7 @@ "ColorRemove": "Rimuovi preimpostazione colore", "ColorReset": "Ripristina i preset colore", "Copy": "Copia", + "DocumentUrlCopied": "Copiato!", "CopyLink": "Copia collegamento", "AccessDenied": "L'oggetto non esiste oppure non hai i permessi per accedervi.", "UnableToFollowMention": "Impossibile aprire l'oggetto menzionato" diff --git a/packages/presentation/lang/ja.json b/packages/presentation/lang/ja.json index 1ca158b415..5b02be1784 100644 --- a/packages/presentation/lang/ja.json +++ b/packages/presentation/lang/ja.json @@ -41,6 +41,7 @@ "ColorRemove": "カラープリセットを削除", "ColorReset": "カラープリセットをリセット", "Copy": "コピー", + "DocumentUrlCopied": "コピーしました", "CopyLink": "リンクをコピー", "AccessDenied": "オブジェクトが存在しないか、アクセス権限がありません。", "UnableToFollowMention": "言及されたオブジェクトを開くことができません" diff --git a/packages/presentation/lang/pt.json b/packages/presentation/lang/pt.json index 5ce09f306c..d1467665d7 100644 --- a/packages/presentation/lang/pt.json +++ b/packages/presentation/lang/pt.json @@ -40,7 +40,8 @@ "ColorAdd": "Adicionar predefinição de cor", "ColorRemove": "Remover predefinição de cor", "ColorReset": "Repor predefinições de cores", - "Copiar": "Copiar", + "Copy": "Copiar", + "DocumentUrlCopied": "Copiado!", "CopyLink": "Copiar link", "AccessDenied": "O objeto não existe ou você não tem permissão para acessá-lo.", "UnableToFollowMention": "Não foi possível abrir o objeto mencionado" diff --git a/packages/presentation/lang/ru.json b/packages/presentation/lang/ru.json index 71d2edbcf8..ec460477ec 100644 --- a/packages/presentation/lang/ru.json +++ b/packages/presentation/lang/ru.json @@ -41,6 +41,7 @@ "ColorRemove": "Удалить предустановленный цвет", "ColorReset": "Сбросить предустановленные цвета", "Copy": "Копировать", + "DocumentUrlCopied": "Скопировано!", "CopyLink": "Копировать ссылку", "AccessDenied": "Объект не существует или у вас нет прав доступа.", "UnableToFollowMention": "Не удалось открыть упомянутый объект" diff --git a/packages/presentation/lang/zh.json b/packages/presentation/lang/zh.json index c7a592bba6..a379464b39 100644 --- a/packages/presentation/lang/zh.json +++ b/packages/presentation/lang/zh.json @@ -41,6 +41,7 @@ "ColorRemove": "删除颜色预设", "ColorReset": "重置颜色预设", "Copy": "复制", + "DocumentUrlCopied": "已复制", "CopyLink": "复制链接", "AccessDenied": "对象不存在或您无权访问。", "UnableToFollowMention": "无法打开提及的对象" diff --git a/packages/presentation/src/plugin.ts b/packages/presentation/src/plugin.ts index 5921067d7c..b4c76e328a 100644 --- a/packages/presentation/src/plugin.ts +++ b/packages/presentation/src/plugin.ts @@ -142,6 +142,7 @@ export default plugin(presentationId, { ColorRemove: '' as IntlString, ColorReset: '' as IntlString, Copy: '' as IntlString, + DocumentUrlCopied: '' as IntlString, CopyLink: '' as IntlString, UnableToFollowMention: '' as IntlString, AccessDenied: '' as IntlString diff --git a/plugins/calendar-resources/src/components/CalDavAccess.svelte b/plugins/calendar-resources/src/components/CalDavAccess.svelte index c1a83c062b..7dbb019db5 100644 --- a/plugins/calendar-resources/src/components/CalDavAccess.svelte +++ b/plugins/calendar-resources/src/components/CalDavAccess.svelte @@ -30,6 +30,15 @@ const dispatch = createEventDispatcher() + let isServerUrlCopied = false + let serverUrlCopyTimeout: ReturnType | undefined + + let isAccountCopied = false + let accountCopyTimeout: ReturnType | undefined + + let isPasswordCopied = false + let passwordCopyTimeout: ReturnType | undefined + $: wasAccessEnabled = integrationGlobal !== null && integrationWs !== null $: canSave = !!( !loading && @@ -150,14 +159,29 @@ async function copyServer (): Promise { await copyTextToClipboard(serverUrl ?? '') + isServerUrlCopied = true + clearTimeout(serverUrlCopyTimeout) + serverUrlCopyTimeout = setTimeout(() => { + isServerUrlCopied = false + }, 2000) } async function copyAccount (): Promise { await copyTextToClipboard(selectedSocialId?.value ?? '') + isAccountCopied = true + clearTimeout(accountCopyTimeout) + accountCopyTimeout = setTimeout(() => { + isAccountCopied = false + }, 2000) } async function copyPassword (): Promise { await copyTextToClipboard(password) + isPasswordCopied = true + clearTimeout(passwordCopyTimeout) + passwordCopyTimeout = setTimeout(() => { + isPasswordCopied = false + }, 2000) } @@ -202,7 +226,7 @@ size="small" kind="ghost" disabled={!accessEnabled} - showTooltip={{ label: presentation.string.Copy }} + showTooltip={{ label: isServerUrlCopied ? presentation.string.DocumentUrlCopied : presentation.string.Copy }} on:click={copyServer} /> @@ -216,7 +240,7 @@ icon={IconCopy} size="small" kind="ghost" - showTooltip={{ label: presentation.string.Copy }} + showTooltip={{ label: isServerUrlCopied ? presentation.string.DocumentUrlCopied : presentation.string.Copy }} disabled={!accessEnabled} on:click={copyAccount} /> @@ -237,7 +261,9 @@ size="small" kind="ghost" disabled={!accessEnabled} - showTooltip={{ label: presentation.string.Copy }} + showTooltip={{ + label: isServerUrlCopied ? presentation.string.DocumentUrlCopied : presentation.string.Copy + }} on:click={copyPassword} /> diff --git a/plugins/document-assets/lang/cs.json b/plugins/document-assets/lang/cs.json index 4d21bd645b..479bcc7053 100644 --- a/plugins/document-assets/lang/cs.json +++ b/plugins/document-assets/lang/cs.json @@ -39,6 +39,7 @@ "Description": "Popis", "CopyDocumentUrl": "Kopírovat URL dokumentu do schránky", + "DocumentUrlCopied": "Zkopírováno!", "ViewMode": "Zobrazit", "EditMode": "Upravit", diff --git a/plugins/document-assets/lang/de.json b/plugins/document-assets/lang/de.json index 7005ec4e2c..0e5520c55d 100644 --- a/plugins/document-assets/lang/de.json +++ b/plugins/document-assets/lang/de.json @@ -37,6 +37,7 @@ "Untitled": "Unbenannt", "Description": "Beschreibung", "CopyDocumentUrl": "Dokument-URL in die Zwischenablage kopieren", + "DocumentUrlCopied": "Kopiert!", "ViewMode": "Ansicht", "EditMode": "Bearbeiten", "SuggestMode": "Vorschlagen", diff --git a/plugins/document-assets/lang/en.json b/plugins/document-assets/lang/en.json index 3fbf049f75..ae4f37299e 100644 --- a/plugins/document-assets/lang/en.json +++ b/plugins/document-assets/lang/en.json @@ -39,6 +39,7 @@ "Description": "Description", "CopyDocumentUrl": "Copy document URL to clipboard", + "DocumentUrlCopied": "Copied!", "ViewMode": "View", "EditMode": "Edit", diff --git a/plugins/document-assets/lang/es.json b/plugins/document-assets/lang/es.json index 2784c12b08..996f38ab82 100644 --- a/plugins/document-assets/lang/es.json +++ b/plugins/document-assets/lang/es.json @@ -37,6 +37,7 @@ "Untitled": "Sin título", "Description": "Descripción", "CopyDocumentUrl": "Copiar URL del documento al portapapeles", + "DocumentUrlCopied": "¡Copiado!", "ViewMode": "Vista", "EditMode": "Editar", "SuggestMode": "Sugerir", diff --git a/plugins/document-assets/lang/fr.json b/plugins/document-assets/lang/fr.json index 9498491b38..ba9468e0ee 100644 --- a/plugins/document-assets/lang/fr.json +++ b/plugins/document-assets/lang/fr.json @@ -37,6 +37,7 @@ "Untitled": "Sans titre", "Description": "Description", "CopyDocumentUrl": "Copier l'URL du document dans le presse-papiers", + "DocumentUrlCopied": "Copié !", "ViewMode": "Visualiser", "EditMode": "Éditer", "SuggestMode": "Suggérer", diff --git a/plugins/document-assets/lang/it.json b/plugins/document-assets/lang/it.json index 217727b335..58ba65975d 100644 --- a/plugins/document-assets/lang/it.json +++ b/plugins/document-assets/lang/it.json @@ -37,6 +37,7 @@ "Untitled": "Senza titolo", "Description": "Descrizione", "CopyDocumentUrl": "Copia l'URL del documento negli appunti", + "DocumentUrlCopied": "Copiato!", "ViewMode": "Visualizzazione", "EditMode": "Modifica", "SuggestMode": "Suggerisci", diff --git a/plugins/document-assets/lang/ja.json b/plugins/document-assets/lang/ja.json index a0b2e36771..5de4c1d68f 100644 --- a/plugins/document-assets/lang/ja.json +++ b/plugins/document-assets/lang/ja.json @@ -37,6 +37,7 @@ "Untitled": "無題", "Description": "説明", "CopyDocumentUrl": "ドキュメントのURLをクリップボードにコピー", + "DocumentUrlCopied": "コピーしました", "ViewMode": "表示", "EditMode": "編集", "SuggestMode": "提案", diff --git a/plugins/document-assets/lang/pt.json b/plugins/document-assets/lang/pt.json index a622a2d427..eff835270d 100644 --- a/plugins/document-assets/lang/pt.json +++ b/plugins/document-assets/lang/pt.json @@ -37,6 +37,7 @@ "Untitled": "Sin título", "Description": "Descrição", "CopyDocumentUrl": "Copiar URL do documento para a área de transferência", + "DocumentUrlCopied": "Copiado!", "ViewMode": "Visualização", "EditMode": "Edição", "SuggestMode": "Sugestão", diff --git a/plugins/document-assets/lang/ru.json b/plugins/document-assets/lang/ru.json index 2ce87ea534..0c453563f7 100644 --- a/plugins/document-assets/lang/ru.json +++ b/plugins/document-assets/lang/ru.json @@ -39,6 +39,7 @@ "Description": "Описание", "CopyDocumentUrl": "Копировать URL-адрес документа в буфер обмена", + "DocumentUrlCopied": "Скопировано!", "ViewMode": "Просмотр", "EditMode": "Редактирование", diff --git a/plugins/document-assets/lang/zh.json b/plugins/document-assets/lang/zh.json index f30ad17aeb..e0cfac4fc5 100644 --- a/plugins/document-assets/lang/zh.json +++ b/plugins/document-assets/lang/zh.json @@ -39,6 +39,7 @@ "Description": "描述", "CopyDocumentUrl": "复制文档 URL 到剪贴板", + "DocumentUrlCopied": "已复制", "ViewMode": "查看", "EditMode": "编辑", diff --git a/plugins/document-resources/src/components/EditDoc.svelte b/plugins/document-resources/src/components/EditDoc.svelte index 7aed85a5b7..f054bf4ab7 100644 --- a/plugins/document-resources/src/components/EditDoc.svelte +++ b/plugins/document-resources/src/components/EditDoc.svelte @@ -83,6 +83,9 @@ let title = '' let innerWidth: number + let isCopied = false + let copyTimeout: ReturnType + let headings: Heading[] = [] let loadedDocumentContent = false @@ -101,6 +104,7 @@ onDestroy(async () => { void notificationClient.then((client) => client.readDoc(_id)) + clearTimeout(copyTimeout) }) const starredQuery = createQuery() @@ -230,10 +234,17 @@ $: actions = [ { icon: view.icon.CopyId, - label: document.string.CopyDocumentUrl, + label: isCopied ? document.string.DocumentUrlCopied : document.string.CopyDocumentUrl, action: () => { if (doc !== undefined) { void copyTextToClipboard(getDocumentUrl(doc)) + isCopied = true + + clearTimeout(copyTimeout) + + copyTimeout = setTimeout(() => { + isCopied = false + }, 2000) } } }, diff --git a/plugins/document-resources/src/plugin.ts b/plugins/document-resources/src/plugin.ts index 957500ec3a..28e46f7f2a 100644 --- a/plugins/document-resources/src/plugin.ts +++ b/plugins/document-resources/src/plugin.ts @@ -72,6 +72,7 @@ export default mergeIds(documentId, document, { Star: '' as IntlString, Unstar: '' as IntlString, CopyDocumentUrl: '' as IntlString, + DocumentUrlCopied: '' as IntlString, Lock: '' as IntlString, Unlock: '' as IntlString,