generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for <Label/> within slate
- Loading branch information
1 parent
482b91a
commit dfa7ac6
Showing
4 changed files
with
53 additions
and
39 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,30 @@ | ||
import React from 'react'; | ||
import { Popup, Label } from 'semantic-ui-react'; | ||
import { serializeNodes } from 'volto-slate/editor/render'; | ||
|
||
const LabelWrapper = (props) => { | ||
const { attributes, children, element } = props; | ||
const { data = {} } = element; | ||
const { uid, label_type } = data; | ||
return ( | ||
<Popup | ||
position={data.pointing} | ||
open={data.always_show || undefined} | ||
on={!data.always_show && 'click'} | ||
trigger={ | ||
label_type ? ( | ||
<Label className={label_type}>{children}</Label> | ||
) : ( | ||
<span id={`label_ref-${uid}`} {...attributes} className="label-node"> | ||
{children} | ||
</span> | ||
) | ||
} | ||
className={`ui label ${data.type}`} | ||
> | ||
{serializeNodes(data.label_content)} | ||
</Popup> | ||
); | ||
}; | ||
|
||
export default LabelWrapper; |
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