Skip to content
Open
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
4 changes: 4 additions & 0 deletions packages/backend/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ type ActionSubstepArgument {

# Only for multirow
subFields: [ActionSubstepArgument]

# Only for rich text
customRteMenuOptions: [String]
}

type DropdownClickableLink {
Expand Down Expand Up @@ -262,6 +265,7 @@ enum AppCategory {
data
communication
logic
ai
others
}

Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/components/InputCreator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default function InputCreator(props: InputCreatorProps): JSX.Element {
variablesEnabled={variables}
isRich
noVariablesMessage={noVariablesMessage}
customRteMenuOptions={schema?.customRteMenuOptions}
/>
)
}
Expand Down
22 changes: 20 additions & 2 deletions packages/frontend/src/components/RichTextEditor/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ enum MenuLabels {
Undo = 'Undo',
Redo = 'Redo',
}
const menuButtons = [
const DEFAULT_MENU_BUTTONS = [
{
label: MenuLabels.Bold,
onClick: (editor: Editor) => editor.chain().focus().toggleBold().run(),
Expand Down Expand Up @@ -238,9 +238,15 @@ interface MenuBarProps {
editor: Editor | null
variableMap: VariableInfoMap
editable: boolean
customMenuOptions?: string[]
}

export const MenuBar = ({ editor, variableMap, editable }: MenuBarProps) => {
export const MenuBar = ({
editor,
variableMap,
editable,
customMenuOptions,
}: MenuBarProps) => {
const {
isOpen: isDialogOpen,
onClose,
Expand Down Expand Up @@ -321,6 +327,18 @@ export const MenuBar = ({ editor, variableMap, editable }: MenuBarProps) => {
[editor, dialogValue, onDialogClose],
)

const menuButtons = useMemo(() => {
if (customMenuOptions) {
return customMenuOptions
.map((option) =>
DEFAULT_MENU_BUTTONS.find(({ label }) => label === option),
)
.filter((button): button is NonNullable<typeof button> => !!button)
}

return DEFAULT_MENU_BUTTONS
}, [customMenuOptions])

if (!editor) {
return null
}
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/components/RichTextEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ interface EditorProps {
autoFocus?: boolean
singleVariableSelection?: boolean
noVariablesMessage?: string
customRteMenuOptions?: string[]
}
const Editor = ({
onChange,
Expand All @@ -114,6 +115,7 @@ const Editor = ({
singleVariableSelection,
autoFocus = false,
noVariablesMessage,
customRteMenuOptions,
}: EditorProps) => {
const { priorExecutionSteps } = useContext(StepExecutionsContext)
const { allApps } = useContext(EditorContext)
Expand Down Expand Up @@ -292,6 +294,7 @@ const Editor = ({
editor={editor}
variableMap={varInfo}
editable={editable ?? false}
customMenuOptions={customRteMenuOptions}
/>
)}
<EditorContent
Expand Down Expand Up @@ -348,6 +351,7 @@ interface RichTextEditorProps {
autoFocus?: boolean
singleVariableSelection?: boolean
noVariablesMessage?: string
customRteMenuOptions?: string[]
}
const RichTextEditor = ({
required,
Expand All @@ -365,6 +369,7 @@ const RichTextEditor = ({
autoFocus,
singleVariableSelection,
noVariablesMessage,
customRteMenuOptions,
}: RichTextEditorProps) => {
const { readOnly } = useContext(EditorContext)
const { control, getValues } = useFormContext()
Expand Down Expand Up @@ -413,6 +418,7 @@ const RichTextEditor = ({
autoFocus={shouldAutoFocus}
singleVariableSelection={singleVariableSelection}
noVariablesMessage={noVariablesMessage}
customRteMenuOptions={customRteMenuOptions}
/>
)}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/graphql/queries/get-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export const GET_APPS = gql`
url
}
singleVariableSelection
customRteMenuOptions
# Only for multi-row
subFields {
label
Expand Down
6 changes: 5 additions & 1 deletion packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ export interface IFieldMultiRow extends IBaseField {
export interface IFieldRichText extends IBaseField {
type: 'rich-text'
value?: string

// Specifies the order and what menu options to show in the RTE
// 'divider' is specified manually to determine when a divider should be shown
customRteMenuOptions?: string[]
}

export interface IFieldDragDrop extends IBaseField {
Expand Down Expand Up @@ -599,7 +603,7 @@ export interface IApp {
setupMessage?: SetupMessage
}

export type AppCategory = 'data' | 'communication' | 'logic' | 'others'
export type AppCategory = 'data' | 'communication' | 'logic' | 'others' | 'ai'

export type TBeforeRequest = (
$: IGlobalVariable,
Expand Down