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

Text editor for custom workflow templates #5654

Merged
merged 53 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b0d4998
add first version of text editor
Oct 19, 2022
2ee65c6
Merge branch 'main' into feat/wysiwyg-workflow-templates
Oct 20, 2022
55178a8
add new editor to email body
Oct 20, 2022
4b4cf8d
fix line height
Oct 20, 2022
7190b9d
remove not needed styles
Oct 20, 2022
bc8e528
allow adding html tags + small refactoring
Oct 21, 2022
2552ab4
fix error when input is empty
Oct 21, 2022
493728b
Merge branch 'main' into feat/wysiwyg-workflow-templates
Oct 24, 2022
0c73250
styling of add variable dropdown
Oct 24, 2022
8b72efb
fix bg on focus
Oct 24, 2022
9512369
small design fixes
Oct 24, 2022
4c71208
improve design
Oct 24, 2022
dd73a2f
show error message for no input
Oct 24, 2022
1ed37bc
Merge branch 'main' into feat/wysiwyg-workflow-templates
Oct 25, 2022
2a133ac
text editor only for email body
Oct 25, 2022
afecf08
remove test button
Oct 25, 2022
46c8b87
code clean up
Oct 25, 2022
1e28855
code clean up
Oct 25, 2022
76c40f6
code clean up
Oct 25, 2022
432e667
fix that added variables weren't saved
Oct 25, 2022
6c11d78
Merge branch 'main' into feat/wysiwyg-workflow-templates
CarinaWolli Oct 25, 2022
306aee4
fix import
Oct 25, 2022
1a15953
Merge branch 'main' into feat/wysiwyg-workflow-templates
Oct 27, 2022
35f2c9c
first version of editor
Oct 27, 2022
ada3b41
connect reminder body of form with new editor
Nov 15, 2022
92f75fe
add pencile for link-editor
Nov 15, 2022
047cbb8
remove TreeViewPlugin
Nov 15, 2022
d577bdc
clean up css file
Nov 15, 2022
fdfd313
code clean up
Nov 15, 2022
37496af
add text indent for list
Nov 15, 2022
3fafcde
improve editor design
Nov 15, 2022
eb09a28
Merge branch 'main' into feat/lexical-text-editor
Nov 15, 2022
ced7d35
fix style
Nov 15, 2022
da4139e
Merge branch 'main' into feat/lexical-text-editor
Nov 22, 2022
5e9e441
slow resizing of editor
Nov 22, 2022
9315c74
fix that new data was removed when leaving tab
Nov 22, 2022
046041b
dont allow italic and bold at same time
Nov 22, 2022
d17adbe
code clean up
Nov 22, 2022
125de6d
fix type error
Nov 22, 2022
8bad091
code clean up
Nov 22, 2022
e1918bf
code clean up
Nov 22, 2022
3ea0065
remove text if changed from SMS to email or other way around
Nov 22, 2022
864a9da
add add variable dropdown
Nov 23, 2022
66e3f60
Merge branch 'main' into feat/lexical-text-editor
Nov 23, 2022
1c30f66
show error message if email body is empty
Nov 23, 2022
aac8c52
add white-space pre-wrap
Nov 23, 2022
6ec02b7
fix import
Nov 23, 2022
09909dc
prettier
Nov 23, 2022
6cf8dd0
fix add variable dropdown for mobile
Nov 24, 2022
9088a63
move dependencies to correct package.json file
Nov 24, 2022
0635131
remove html-to-text
Nov 24, 2022
866bc97
Merge branch 'main' into feat/lexical-text-editor
CarinaWolli Nov 24, 2022
ee82cc3
Merge branch 'main' into feat/lexical-text-editor
CarinaWolli Nov 25, 2022
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
3 changes: 3 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@heroicons/react": "^1.0.6",
"@hookform/error-message": "^2.0.0",
"@hookform/resolvers": "^2.9.7",
"@lexical/react": "^0.5.0",
"@next-auth/prisma-adapter": "^1.0.4",
"@next/bundle-analyzer": "^12.2.5",
"@radix-ui/react-avatar": "^1.0.0",
Expand Down Expand Up @@ -71,9 +72,11 @@
"googleapis": "^84.0.0",
"gray-matter": "^4.0.3",
"handlebars": "^4.7.7",
"html-to-text": "^8.2.1",
"ical.js": "^1.4.0",
"ics": "^2.37.0",
"kbar": "^0.1.0-beta.36",
"lexical": "^0.5.0",
"libphonenumber-js": "^1.10.12",
"lodash": "^4.17.21",
"lottie-react": "^2.3.1",
Expand Down
3 changes: 2 additions & 1 deletion apps/web/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,5 +1372,6 @@
"route_to": "Route to",
"test_preview_description": "Test your routing form without submitting any data",
"test_routing": "Test Routing",
"booking_limit_reached":"Booking Limit for this event type has been reached"
"booking_limit_reached":"Booking Limit for this event type has been reached",
"fill_this_field": "Please fill in this field"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Dropdown, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Icon } from "@calcom/ui";

interface IAddVariablesDropdown {
addVariable: (isEmailSubject: boolean, variable: string) => void;
addVariable: (variable: string, isEmailSubject?: boolean) => void;
isEmailSubject: boolean;
}

Expand Down Expand Up @@ -39,7 +39,7 @@ export const AddVariablesDropdown = (props: IAddVariablesDropdown) => {
key={variable}
type="button"
className="w-full px-4 py-2"
onClick={() => props.addVariable(props.isEmailSubject, t(`${variable}_workflow`))}>
onClick={() => props.addVariable(t(`${variable}_workflow`), props.isEmailSubject)}>
<div className="sm:grid sm:grid-cols-2">
<div className="mr-3 text-left md:col-span-1">
{`{${t(`${variable}_workflow`).toUpperCase().replace(/ /g, "_")}}`}
Expand Down
69 changes: 69 additions & 0 deletions packages/features/ee/workflows/components/TextEditor/Editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { CodeHighlightNode, CodeNode } from "@lexical/code";
import { AutoLinkNode, LinkNode } from "@lexical/link";
import { ListItemNode, ListNode } from "@lexical/list";
import { TRANSFORMERS } from "@lexical/markdown";
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
import { LexicalComposer } from "@lexical/react/LexicalComposer";
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
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 { FormValues } from "ee/workflows/pages/workflow";
import { UseFormReturn } from "react-hook-form";

import ExampleTheme from "./ExampleTheme";
import AutoLinkPlugin from "./plugins/AutoLinkPlugin";
import ToolbarPlugin from "./plugins/ToolbarPlugin";
import "./stylesEditor.css";

export type TextEditorProps = {
form: UseFormReturn<FormValues>;
stepNumber: number;
};

const editorConfig = {
// The editor theme
theme: ExampleTheme,
// Handling of errors during update
onError(error: any) {
throw error;
},
namespace: "",
// Any custom nodes go here
nodes: [
HeadingNode,
ListNode,
ListItemNode,
QuoteNode,
CodeNode,
CodeHighlightNode,
TableNode,
TableCellNode,
TableRowNode,
AutoLinkNode,
LinkNode,
],
};

export default function Editor(props: TextEditorProps) {
return (
<div className="editor">
<LexicalComposer initialConfig={editorConfig}>
<div className="editor-container">
<ToolbarPlugin form={props.form} stepNumber={props.stepNumber} />
<div className="editor-inner">
<RichTextPlugin contentEditable={<ContentEditable className="editor-input" />} placeholder="" />
<AutoFocusPlugin />
<ListPlugin />
<LinkPlugin />
<AutoLinkPlugin />
<MarkdownShortcutPlugin transformers={TRANSFORMERS} />
</div>
</div>
</LexicalComposer>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const exampleTheme = {
placeholder: "editor-placeholder",
paragraph: "editor-paragraph",
heading: {
h1: "editor-heading-h1",
h2: "editor-heading-h2",
},
list: {
nested: {
listitem: "editor-nested-listitem",
},
ol: "editor-list-ol",
ul: "editor-list-ul",
listitem: "editor-listitem",
},
image: "editor-image",
link: "editor-link",
text: {
bold: "editor-text-bold",
italic: "editor-text-italic",
},
};

export default exampleTheme;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin";

const URL_MATCHER =
/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;

const EMAIL_MATCHER =
/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;

const MATCHERS = [
(text: any) => {
const match = URL_MATCHER.exec(text);
return (
match && {
index: match.index,
length: match[0].length,
text: match[0],
url: match[0],
}
);
},
(text: any) => {
const match = EMAIL_MATCHER.exec(text);
return (
match && {
index: match.index,
length: match[0].length,
text: match[0],
url: `mailto:${match[0]}`,
}
);
},
];

export default function PlaygroundAutoLinkPlugin() {
return <AutoLinkPlugin matchers={MATCHERS} />;
}
Loading