UBERF-5324: allow cmd-k for editable content (#4601)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-02-12 22:42:31 +04:00 committed by GitHub
parent 466298d425
commit 7794771694
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 7 deletions

View File

@ -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']
}

View File

@ -135,13 +135,15 @@ export function canReplyToThread (doc?: ActivityMessage): boolean {
return true
}
export async function canCopyMessageLink (doc?: ActivityMessage): Promise<boolean> {
if (doc === undefined) {
export async function canCopyMessageLink (doc?: ActivityMessage | ActivityMessage[]): Promise<boolean> {
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

View File

@ -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

View File

@ -520,6 +520,7 @@ export interface Action<T extends Doc = Doc, P = Record<string, any>> extends Do
// Avaible only for workspace owners
secured?: boolean
allowedForEditableContent?: boolean
}
/**