Skip to content

Commit

Permalink
SALEOR 3115 Fix EditorJS inline formatting (#1096)
Browse files Browse the repository at this point in the history
* Fix EditorJS inline formatting

* Update changelog
  • Loading branch information
orzechdev authored and jwm0 committed May 7, 2021
1 parent 074c76f commit a4ac442
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ All notable, unreleased changes to this project will be documented in this file.
- useFormset.setItemValue wrong updates,
- Drop deprecated fields - #1071 by @jwm0
- Add service worker - #1073 by @dominik-zeglen
- Fix EditorJS inline formatting - #1096 by @orzechdev

# 2.11.1

Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@editorjs/header": "^2.6.1",
"@editorjs/image": "^2.6.0",
"@editorjs/list": "^1.6.1",
"@editorjs/paragraph": "^2.8.0",
"@editorjs/quote": "^2.4.0",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
Expand Down
20 changes: 17 additions & 3 deletions src/components/RichTextEditor/RichTextEditorContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import EditorJS, {
} from "@editorjs/editorjs";
import Header from "@editorjs/header";
import List from "@editorjs/list";
import Paragraph from "@editorjs/paragraph";
import Quote from "@editorjs/quote";
import strikethroughIcon from "@saleor/icons/StrikethroughIcon";
import classNames from "classnames";
Expand All @@ -20,16 +21,29 @@ export interface RichTextEditorContentProps {
onReady?: () => void;
}

const inlineToolbar = ["link", "bold", "italic", "strikethrough"];

export const tools: Record<string, ToolConstructable | ToolSettings> = {
header: {
class: Header,
config: {
defaultLevel: 1,
levels: [1, 2, 3]
}
},
inlineToolbar
},
list: {
class: List,
inlineToolbar
},
quote: {
class: Quote,
inlineToolbar
},
paragraph: {
class: Paragraph,
inlineToolbar
},
list: List,
quote: Quote,
strikethrough: createGenericInlineTool({
sanitize: {
s: {}
Expand Down

0 comments on commit a4ac442

Please sign in to comment.