-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move soft-hyphen functionality to
@comet/admin-rte
(#1510)
Move the soft-hyphen functionality from `@comet/cms-admin` to `@comet/admin-rte`. This allows using the soft-hyphen functionality in plain RTEs, and not only in `RichTextBlock`. --------- Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
- Loading branch information
1 parent
60f5208
commit 51d6c2b
Showing
11 changed files
with
83 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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,31 @@ | ||
--- | ||
"@comet/admin-rte": minor | ||
"@comet/cms-admin": minor | ||
--- | ||
|
||
Move soft-hyphen functionality to `@comet/admin-rte` | ||
|
||
This allows using the soft-hyphen functionality in plain RTEs, and not only in `RichTextBlock` | ||
|
||
```tsx | ||
const [useRteApi] = makeRteApi(); | ||
|
||
export default function MyRte() { | ||
const { editorState, setEditorState } = useRteApi(); | ||
return ( | ||
<Rte | ||
value={editorState} | ||
onChange={setEditorState} | ||
options={{ | ||
supports: [ | ||
// Soft Hyphen | ||
"soft-hyphen", | ||
// Other options you may wish to support | ||
"bold", | ||
"italic", | ||
], | ||
}} | ||
/> | ||
); | ||
} | ||
``` |
This file contains 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 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 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
29 changes: 29 additions & 0 deletions
29
packages/admin/admin-rte/src/core/extension/SoftHyphen/EditorComponent.tsx
This file contains 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,29 @@ | ||
import { RteSoftHyphen } from "@comet/admin-icons"; | ||
import { styled } from "@mui/material/styles"; | ||
import { ContentState } from "draft-js"; | ||
import * as React from "react"; | ||
|
||
interface Props { | ||
contentState: ContentState; | ||
entityKey: string; | ||
children?: React.ReactNode; | ||
} | ||
|
||
//TODO: Allow text selection for SoftHyphen | ||
export function EditorComponent({ children }: Props): React.ReactElement { | ||
return ( | ||
<span> | ||
<VisibleHyphen /> | ||
{children} | ||
</span> | ||
); | ||
} | ||
|
||
const VisibleHyphen = styled(RteSoftHyphen)` | ||
font-size: inherit; | ||
color: currentcolor; | ||
opacity: 0.5; | ||
// Arbitrary value to make the icon look centered | ||
padding-top: 0.2em; | ||
`; |
5 changes: 3 additions & 2 deletions
5
...te/extension/SoftHyphen/ToolbarButton.tsx → ...re/extension/SoftHyphen/ToolbarButton.tsx
This file contains 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 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 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 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 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
23 changes: 0 additions & 23 deletions
23
packages/admin/cms-admin/src/blocks/rte/extension/SoftHyphen/EditorComponent.tsx
This file was deleted.
Oops, something went wrong.