Skip to content
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
2 changes: 1 addition & 1 deletion src/app/client-preview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default async function ClientPreviewPage({
<div
className={`overflow-y-auto overflow-x-hidden max-h-screen w-full`}
style={{
fontFamily: workspace.font.replaceAll('+', ' '),
fontFamily: workspace.font?.replaceAll('+', ' '),
background: `${settings.backgroundColor}`,
}}
>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/EditorInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const EditorInterface = ({
if (
appState?.appState.originalTemplate?.replace(/\s/g, '') !==
replaceCustomLabelsWithPlaceholders(
defaultState.replaceAll(' ', ''),
defaultState?.replaceAll(' ', ''),
Comment on lines 219 to +220

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does replaceCustomLabelsWithPlaceholders handle undefined as a first param? If not, we should default to an empty string:

Suggested change
replaceCustomLabelsWithPlaceholders(
defaultState.replaceAll(' ', ''),
defaultState?.replaceAll(' ', ''),
replaceCustomLabelsWithPlaceholders(
defaultState?.replaceAll(' ', '') ?? '',

appState?.appState?.customLabels,
) ||
appState?.appState.bannerImgUrl !== defaultBannerImagePath ||
Expand Down
2 changes: 1 addition & 1 deletion src/components/autofillFields/AutofillFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const AutofillFields = () => {
{/* edit mode */}
<When condition={!appState?.appState.readOnly}>
{staticAutofillValues.map((el, key) => {
const labelText = el.replaceAll('{{', '').replaceAll('}}', '')
const labelText = el?.replaceAll('{{', '').replaceAll('}}', '')
return (
<AutofillText
key={key}
Expand Down
9 changes: 9 additions & 0 deletions src/components/tiptap/autofieldSelector/AutofillMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,25 @@ export const AutofillMenu = forwardRef((props: any, ref: any) => {
}

const upHandler = () => {
if (props.items.length === 0) {
return
}
setSelectedIndex(
(selectedIndex + props.items.length - 1) % props.items.length,
)
}

const downHandler = () => {
if (props.items.length === 0) {
return
}
setSelectedIndex((selectedIndex + 1) % props.items.length)
}

const enterHandler = () => {
if (props.items.length === 0) {
return
}
selectItem(selectedIndex)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const autofillMenuSuggestion = {
.map((text) => prepareCustomLabel(text, appContextData?.customLabels))

.filter((item: any) =>
item.toLowerCase().replaceAll('{{', '').startsWith(query.toLowerCase()),
item
.toLowerCase()
Comment on lines +42 to +43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
item
.toLowerCase()
item
?.toLowerCase()

?.replaceAll('{{', '')
.startsWith(query.toLowerCase()),
)
.slice(0, 10)
},
Expand Down
12 changes: 10 additions & 2 deletions src/components/tiptap/floatingMenu/FloatingMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
BulletListIcon,
UploadIcon2,
CalloutIcon,
LinkIcon,
TableIcon,
EmbedIcon,
} from '@/icons'
Expand Down Expand Up @@ -86,19 +85,28 @@ export const FloatingMenu = forwardRef((props: any, ref: any) => {
}

const upHandler = () => {
if (props.items.length === 0) {
return
}
setSelectedIndex(
(selectedIndex + props.items.length - 1) % props.items.length,
)
}

const downHandler = () => {
if (props.items.length === 0) {
return
}
setSelectedIndex((selectedIndex + 1) % props.items.length)
}

const enterHandler = () => {
if (props.items.length === 0) {
return
}
selectItem(selectedIndex)
//handle link input here
if (props.items[0].title === 'Link') {
if (props.items[0]?.title === 'Link') {
appState?.toggleShowLinkInput(true)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/customLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const prepareCustomLabel = (
if (!opts?.isClientMode) {
replacement = customLabels?.[key] || replacement
}
result = result.replaceAll(placeholder, replacement.toLowerCase())
result = result?.replaceAll(placeholder, replacement.toLowerCase())
}
return result
}
Expand Down
Loading