From f18bb55f75a0f283aad3b584a5221fb979522083 Mon Sep 17 00:00:00 2001 From: Kristina Fefelova Date: Mon, 12 Feb 2024 16:53:10 +0400 Subject: [PATCH] UBERF-5324: allow cmd-k for editable content Signed-off-by: Kristina Fefelova --- models/view/src/index.ts | 1 + plugins/chunter-resources/src/utils.ts | 10 ++++++---- .../src/components/ActionHandler.svelte | 14 +++++++++++--- plugins/view/src/index.ts | 1 + 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/models/view/src/index.ts b/models/view/src/index.ts index a10a45ae532..0698f476802 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -735,6 +735,7 @@ export function createModel (builder: Builder): void { category: view.category.GeneralNavigation, input: 'none', target: core.class.Doc, + allowedForEditableContent: true, context: { mode: ['workbench', 'browser', 'panel', 'editor', 'input'] } diff --git a/plugins/chunter-resources/src/utils.ts b/plugins/chunter-resources/src/utils.ts index 9a28577f408..90447c13cd2 100644 --- a/plugins/chunter-resources/src/utils.ts +++ b/plugins/chunter-resources/src/utils.ts @@ -135,13 +135,15 @@ export async function canReplyToThread (doc?: ActivityMessage): Promise return true } -export async function canCopyMessageLink (doc?: ActivityMessage): Promise { - if (doc === undefined) { +export async function canCopyMessageLink (doc?: ActivityMessage | ActivityMessage[]): Promise { + const message = Array.isArray(doc) ? doc[0] : doc + + if (message === undefined) { return false } - if (doc._class === activity.class.DocUpdateMessage) { - return (doc as DocUpdateMessage).objectClass !== activity.class.Reaction + if (message._class === activity.class.DocUpdateMessage) { + return (message as DocUpdateMessage).objectClass !== activity.class.Reaction } return true diff --git a/plugins/view-resources/src/components/ActionHandler.svelte b/plugins/view-resources/src/components/ActionHandler.svelte index b9cb43dfb58..27debccbed4 100644 --- a/plugins/view-resources/src/components/ActionHandler.svelte +++ b/plugins/view-resources/src/components/ActionHandler.svelte @@ -131,9 +131,11 @@ const targetTagName = (evt.target as any)?.tagName?.toLowerCase() let elm = evt.target as HTMLElement + let isContentEditable = false + while (true) { - if (elm.contentEditable === 'true') { - return + if (elm.isContentEditable) { + isContentEditable = true } const prt = elm.parentElement if (prt === null) { @@ -165,7 +167,13 @@ } clearTimeout(timer) - currentActions = currentActions.filter((p) => p.keyBinding !== undefined && p.keyBinding.length > 0) + currentActions = currentActions.filter(({ keyBinding, allowedForEditableContent }) => { + const hasKeyBinding = keyBinding !== undefined && keyBinding.length > 0 + const allowed = !isContentEditable || allowedForEditableContent + + return hasKeyBinding && allowed + }) + if (lastKey !== undefined) { for (const a of sequences) { // TODO: Handle multiple keys here diff --git a/plugins/view/src/index.ts b/plugins/view/src/index.ts index 164836d454f..e9a27d3736a 100644 --- a/plugins/view/src/index.ts +++ b/plugins/view/src/index.ts @@ -520,6 +520,7 @@ export interface Action> extends Do // Avaible only for workspace owners secured?: boolean + allowedForEditableContent?: boolean } /**