Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-5324: allow cmd-k in text editors #4601

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions models/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand Down
10 changes: 6 additions & 4 deletions plugins/chunter-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ export async function canReplyToThread (doc?: ActivityMessage): Promise<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
Expand Down
14 changes: 11 additions & 3 deletions plugins/view-resources/src/components/ActionHandler.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions plugins/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
Loading