* Various fixes * Remove tooltip * another string change * Fix width of custom event name modal to prevent overflow * Booking questions fixes * minor string fix * checkbox alignment * padding in reassign dialog * fix: update FormBuilder tests for checkbox UI changes - Updated test utilities to work with CheckboxField instead of BooleanToggleGroupField - Fixed badge expectations to check for 'optional' instead of 'required' - Updated dialog interaction methods to use checkbox.checked instead of button text - All 13 FormBuilder tests now pass successfully Fixes failing tests in PR #22727 caused by UI changes from toggle buttons to checkboxes for required field selection. Co-Authored-By: amit@cal.com <samit91848@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: amit@cal.com <samit91848@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
120 lines
4.3 KiB
TypeScript
120 lines
4.3 KiB
TypeScript
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
import { ListItemNode, ListNode } from "@lexical/list";
|
|
import { TRANSFORMERS } from "@lexical/markdown";
|
|
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
|
|
|
|
import classNames from "@calcom/ui/classNames";
|
|
|
|
import ExampleTheme from "./ExampleTheme";
|
|
import { VariableNode } from "./nodes/VariableNode";
|
|
import AddVariablesPlugin from "./plugins/AddVariablesPlugin";
|
|
import AutoLinkPlugin from "./plugins/AutoLinkPlugin";
|
|
import EditablePlugin from "./plugins/EditablePlugin";
|
|
import PlainTextPlugin from "./plugins/PlainTextPlugin";
|
|
import ToolbarPlugin from "./plugins/ToolbarPlugin";
|
|
import CustomEnterKeyPlugin from "./plugins/customEnterKeyPlugin";
|
|
import "./stylesEditor.css";
|
|
import type { TextEditorProps } from "./types";
|
|
|
|
/*
|
|
Default toolbar items:
|
|
- blockType
|
|
- bold
|
|
- italic
|
|
- link
|
|
*/
|
|
|
|
const editorConfig = {
|
|
theme: ExampleTheme,
|
|
onError(error: Error) {
|
|
throw error;
|
|
},
|
|
namespace: "",
|
|
nodes: [
|
|
HeadingNode,
|
|
ListNode,
|
|
ListItemNode,
|
|
QuoteNode,
|
|
CodeNode,
|
|
CodeHighlightNode,
|
|
TableNode,
|
|
TableCellNode,
|
|
TableRowNode,
|
|
AutoLinkNode,
|
|
LinkNode,
|
|
VariableNode,
|
|
],
|
|
};
|
|
|
|
export const Editor = (props: TextEditorProps) => {
|
|
const editable = props.editable ?? true;
|
|
const plainText = props.plainText ?? false;
|
|
return (
|
|
<div className="editor rounded-md">
|
|
{props.label && <label className="mb-1 block text-sm font-medium leading-6">{props.label}</label>}
|
|
<LexicalComposer initialConfig={{ ...editorConfig }}>
|
|
<div className="editor-container hover:border-emphasis focus-within:ring-brand-default !rounded-lg p-0 transition focus-within:ring-2 focus-within:ring-offset-0">
|
|
<ToolbarPlugin
|
|
getText={props.getText}
|
|
setText={props.setText}
|
|
editable={editable}
|
|
excludedToolbarItems={props.excludedToolbarItems}
|
|
variables={props.variables}
|
|
addVariableButtonTop={props.addVariableButtonTop}
|
|
updateTemplate={props.updateTemplate}
|
|
firstRender={props.firstRender}
|
|
setFirstRender={props.setFirstRender}
|
|
/>
|
|
<div
|
|
className={classNames("editor-inner scroll-bar overflow-x-hidden", !editable && "!bg-subtle")}
|
|
style={{ height: props.height, maxHeight: props.maxHeight }}>
|
|
<RichTextPlugin
|
|
contentEditable={
|
|
<ContentEditable
|
|
readOnly={!editable}
|
|
style={{ height: props.height }}
|
|
className="editor-input focus:outline-none"
|
|
data-testid="editor-input"
|
|
/>
|
|
}
|
|
placeholder={
|
|
props?.placeholder ? (
|
|
<div className="text-muted -mt-11 p-3 text-sm">{props.placeholder}</div>
|
|
) : null
|
|
}
|
|
ErrorBoundary={LexicalErrorBoundary}
|
|
/>
|
|
<ListPlugin />
|
|
<LinkPlugin />
|
|
<AutoLinkPlugin />
|
|
<CustomEnterKeyPlugin />
|
|
{props?.variables ? <AddVariablesPlugin variables={props.variables} /> : null}
|
|
<HistoryPlugin />
|
|
<MarkdownShortcutPlugin
|
|
transformers={
|
|
props.disableLists
|
|
? TRANSFORMERS.filter((value, index) => {
|
|
if (index !== 3 && index !== 4) return value;
|
|
})
|
|
: TRANSFORMERS
|
|
}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<EditablePlugin editable={editable} />
|
|
<PlainTextPlugin setText={props.setText} plainText={plainText} />
|
|
</LexicalComposer>
|
|
</div>
|
|
);
|
|
};
|