🐛 Fix focus after selecting mark in text editor
This commit is contained in:
@@ -39,13 +39,13 @@
|
||||
"@trpc/server": "10.16.0",
|
||||
"@typebot.io/js": "workspace:*",
|
||||
"@typebot.io/react": "workspace:*",
|
||||
"@udecode/plate-basic-marks": "20.0.0",
|
||||
"@udecode/plate-common": "^20.0.0",
|
||||
"@udecode/plate-core": "20.0.0",
|
||||
"@udecode/plate-link": "20.0.0",
|
||||
"@udecode/plate-serializer-html": "20.0.0",
|
||||
"@udecode/plate-ui-link": "20.0.0",
|
||||
"@udecode/plate-ui-toolbar": "20.0.0",
|
||||
"@udecode/plate-basic-marks": "20.4.0",
|
||||
"@udecode/plate-common": "^20.4.0",
|
||||
"@udecode/plate-core": "20.4.0",
|
||||
"@udecode/plate-link": "20.4.0",
|
||||
"@udecode/plate-serializer-html": "20.4.0",
|
||||
"@udecode/plate-ui-link": "20.4.0",
|
||||
"@udecode/plate-ui-toolbar": "20.4.0",
|
||||
"@uiw/codemirror-extensions-langs": "^4.19.9",
|
||||
"@uiw/codemirror-theme-github": "^4.19.9",
|
||||
"@uiw/codemirror-theme-tokyo-night": "^4.19.9",
|
||||
@@ -86,7 +86,7 @@
|
||||
"slate": "0.91.4",
|
||||
"slate-history": "0.86.0",
|
||||
"slate-hyperscript": "0.77.0",
|
||||
"slate-react": "0.91.10",
|
||||
"slate-react": "0.92.0",
|
||||
"stripe": "11.14.0",
|
||||
"styled-components": "5.3.9",
|
||||
"svg-round-corners": "0.4.1",
|
||||
|
||||
@@ -38,6 +38,7 @@ const TextBubbleEditorContent = ({
|
||||
const varDropdownRef = useRef<HTMLDivElement | null>(null)
|
||||
const rememberedSelection = useRef<BaseSelection | null>(null)
|
||||
const [isVariableDropdownOpen, setIsVariableDropdownOpen] = useState(false)
|
||||
const [isFirstFocus, setIsFirstFocus] = useState(true)
|
||||
|
||||
const textEditorRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -139,14 +140,16 @@ const TextBubbleEditorContent = ({
|
||||
style: editorStyle(useColorModeValue('white', colors.gray[850])),
|
||||
autoFocus: true,
|
||||
onFocus: () => {
|
||||
if (!isFirstFocus) return
|
||||
if (editor.children.length === 0) return
|
||||
selectEditor(editor, {
|
||||
edge: 'end',
|
||||
})
|
||||
setIsFirstFocus(false)
|
||||
},
|
||||
'aria-label': 'Text editor',
|
||||
onBlur: () => {
|
||||
rememberedSelection.current = editor.selection
|
||||
rememberedSelection.current = editor?.selection
|
||||
},
|
||||
onKeyDown: handleKeyDown,
|
||||
onClick: () => {
|
||||
|
||||
@@ -41,7 +41,7 @@ export const ItemNodesList = ({
|
||||
const isDraggingOnCurrentBlock =
|
||||
(draggedItem && mouseOverBlock?.id === block.id) ?? false
|
||||
const showPlaceholders =
|
||||
draggedItem !== undefined && block.items[0].type === draggedItem.type
|
||||
draggedItem !== undefined && block.items.at(0)?.type === draggedItem.type
|
||||
|
||||
const isLastBlock =
|
||||
isDefined(typebot) &&
|
||||
|
||||
@@ -81,3 +81,9 @@ export const canPublishFileInput = async ({
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export const isUniqueConstraintError = (error: unknown) =>
|
||||
typeof error === 'object' &&
|
||||
error &&
|
||||
'code' in error &&
|
||||
error.code === 'P2002'
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { CollaborationType, WorkspaceRole } from '@typebot.io/prisma'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { canReadTypebots, canWriteTypebots } from '@/helpers/databaseRules'
|
||||
import {
|
||||
canReadTypebots,
|
||||
canWriteTypebots,
|
||||
isUniqueConstraintError,
|
||||
} from '@/helpers/databaseRules'
|
||||
import {
|
||||
badRequest,
|
||||
forbidden,
|
||||
@@ -41,13 +45,23 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
select: { id: true },
|
||||
})
|
||||
if (existingUser) {
|
||||
await prisma.collaboratorsOnTypebots.create({
|
||||
data: {
|
||||
type,
|
||||
typebotId,
|
||||
userId: existingUser.id,
|
||||
},
|
||||
})
|
||||
try {
|
||||
await prisma.collaboratorsOnTypebots.create({
|
||||
data: {
|
||||
type,
|
||||
typebotId,
|
||||
userId: existingUser.id,
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
if (isUniqueConstraintError(error)) {
|
||||
return res.status(400).send({
|
||||
message: 'User already has access to this typebot.',
|
||||
})
|
||||
}
|
||||
throw error
|
||||
}
|
||||
|
||||
await prisma.memberInWorkspace.upsert({
|
||||
where: {
|
||||
userId_workspaceId: {
|
||||
|
||||
Reference in New Issue
Block a user