-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Text editor for custom workflow templates #5654
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
Merged
Merged
Changes from 48 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
b0d4998
add first version of text editor
2ee65c6
Merge branch 'main' into feat/wysiwyg-workflow-templates
55178a8
add new editor to email body
4b4cf8d
fix line height
7190b9d
remove not needed styles
bc8e528
allow adding html tags + small refactoring
2552ab4
fix error when input is empty
493728b
Merge branch 'main' into feat/wysiwyg-workflow-templates
0c73250
styling of add variable dropdown
8b72efb
fix bg on focus
9512369
small design fixes
4c71208
improve design
dd73a2f
show error message for no input
1ed37bc
Merge branch 'main' into feat/wysiwyg-workflow-templates
2a133ac
text editor only for email body
afecf08
remove test button
46c8b87
code clean up
1e28855
code clean up
76c40f6
code clean up
432e667
fix that added variables weren't saved
6c11d78
Merge branch 'main' into feat/wysiwyg-workflow-templates
CarinaWolli 306aee4
fix import
1a15953
Merge branch 'main' into feat/wysiwyg-workflow-templates
35f2c9c
first version of editor
ada3b41
connect reminder body of form with new editor
92f75fe
add pencile for link-editor
047cbb8
remove TreeViewPlugin
d577bdc
clean up css file
fdfd313
code clean up
37496af
add text indent for list
3fafcde
improve editor design
eb09a28
Merge branch 'main' into feat/lexical-text-editor
ced7d35
fix style
da4139e
Merge branch 'main' into feat/lexical-text-editor
5e9e441
slow resizing of editor
9315c74
fix that new data was removed when leaving tab
046041b
dont allow italic and bold at same time
d17adbe
code clean up
125de6d
fix type error
8bad091
code clean up
e1918bf
code clean up
3ea0065
remove text if changed from SMS to email or other way around
864a9da
add add variable dropdown
66e3f60
Merge branch 'main' into feat/lexical-text-editor
1c30f66
show error message if email body is empty
aac8c52
add white-space pre-wrap
6ec02b7
fix import
09909dc
prettier
6cf8dd0
fix add variable dropdown for mobile
9088a63
move dependencies to correct package.json file
0635131
remove html-to-text
866bc97
Merge branch 'main' into feat/lexical-text-editor
CarinaWolli ee82cc3
Merge branch 'main' into feat/lexical-text-editor
CarinaWolli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/features/ee/workflows/components/TextEditor/Editor.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { UseFormReturn } from "react-hook-form"; | ||
|
|
||
| import { FormValues } from "../../pages/workflow"; | ||
| 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> | ||
| ); | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/features/ee/workflows/components/TextEditor/ExampleTheme.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
4 changes: 4 additions & 0 deletions
4
packages/features/ee/workflows/components/TextEditor/images/icons/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
packages/features/ee/workflows/components/TextEditor/images/icons/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
packages/features/ee/workflows/components/TextEditor/images/icons/list-ol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/features/ee/workflows/components/TextEditor/images/icons/list-ul.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/features/ee/workflows/components/TextEditor/images/icons/pencil-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ges/features/ee/workflows/components/TextEditor/images/icons/text-paragraph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/features/ee/workflows/components/TextEditor/images/icons/type-bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/features/ee/workflows/components/TextEditor/images/icons/type-h1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/features/ee/workflows/components/TextEditor/images/icons/type-h2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/features/ee/workflows/components/TextEditor/images/icons/type-italic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions
36
packages/features/ee/workflows/components/TextEditor/plugins/AutoLinkPlugin.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} />; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.