Skip to content

Commit

Permalink
add softbreak plugin; fix #304
Browse files Browse the repository at this point in the history
  • Loading branch information
maerzhase committed Aug 1, 2022
1 parent 0ae8209 commit 90ba32e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/NFTArticle/SlateEditor/Plugins/SoftBreakPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { EnhanceEditorWith } from "../../../../types/ArticleEditor/Editor";

export const withSoftBreak: EnhanceEditorWith = (editor) => {
const { insertText } = editor

editor.insertSoftBreak = () => {
insertText('\n')
return true;
}

return editor
}
2 changes: 2 additions & 0 deletions src/components/NFTArticle/SlateEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { withHistory } from "slate-history"
import { TezosStorageProps } from "../elements/TezosStorage"
import { withAutoFormat } from './AutoFormatPlugin/'
import { withSoftBreak } from './Plugins/SoftBreakPlugin'
import { withImages } from "./Plugins/SlateImagePlugin"
import { ImageElement } from "../elements/ImageElement"
import { onKeyDownHotkeyPlugin } from "./HotkeyPlugin/HotkeyPlugin"
Expand Down Expand Up @@ -115,6 +116,7 @@ export const SlateEditor = forwardRef<FxEditor, SlateEditorProps>(({
{ f: withImages },
{ f: withTables },
{ f: withConstraints },
{ f: withSoftBreak }
]
const enhancedEditor = withs.reduce((e, enhanceWith) => {
return enhanceWith.f(e, ...Object.values(enhanceWith.args || {}));
Expand Down

0 comments on commit 90ba32e

Please sign in to comment.