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, category: view.category.GeneralNavigation,
input: 'none', input: 'none',
target: core.class.Doc, target: core.class.Doc,
allowedForEditableContent: true,
context: { context: {
mode: ['workbench', 'browser', 'panel', 'editor', 'input'] mode: ['workbench', 'browser', 'panel', 'editor', 'input']
} }

View File

@ -135,13 +135,15 @@ export function canReplyToThread (doc?: ActivityMessage): boolean {
return true return true
} }
export async function canCopyMessageLink (doc?: ActivityMessage): Promise<boolean> { export async function canCopyMessageLink (doc?: ActivityMessage | ActivityMessage[]): Promise<boolean> {
if (doc === undefined) { const message = Array.isArray(doc) ? doc[0] : doc
if (message === undefined) {
return false return false
} }
if (doc._class === activity.class.DocUpdateMessage) { if (message._class === activity.class.DocUpdateMessage) {
return (doc as DocUpdateMessage).objectClass !== activity.class.Reaction return (message as DocUpdateMessage).objectClass !== activity.class.Reaction
} }
return true return true

View File

@ -131,9 +131,11 @@
const targetTagName = (evt.target as any)?.tagName?.toLowerCase() const targetTagName = (evt.target as any)?.tagName?.toLowerCase()
let elm = evt.target as HTMLElement let elm = evt.target as HTMLElement
let isContentEditable = false
while (true) { while (true) {
if (elm.contentEditable === 'true') { if (elm.isContentEditable) {
return isContentEditable = true
} }
const prt = elm.parentElement const prt = elm.parentElement
if (prt === null) { if (prt === null) {
@ -165,7 +167,13 @@
} }
clearTimeout(timer) 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) { if (lastKey !== undefined) {
for (const a of sequences) { for (const a of sequences) {
// TODO: Handle multiple keys here // 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 // Avaible only for workspace owners
secured?: boolean secured?: boolean
allowedForEditableContent?: boolean
} }
/** /**