diff --git a/src/components/Widgets/MarkdownControl/VisualEditor/index.js b/src/components/Widgets/MarkdownControl/VisualEditor/index.js index 1239f369..81628983 100644 --- a/src/components/Widgets/MarkdownControl/VisualEditor/index.js +++ b/src/components/Widgets/MarkdownControl/VisualEditor/index.js @@ -90,27 +90,36 @@ const MARK_TAGS = { code: 'code' } -const NODE_COMPONENTS = { - 'quote': props =>
{props.children}, +const BLOCK_COMPONENTS = { + 'paragraph': props =>
{props.children}
, + 'list-item': props =>{props.children}, + 'code': props =>
{props.children}
,
'heading-one': props => {props.children}
,
- 'link': props => {props.children},
- 'paragraph': props => {props.children}
, }; +const NODE_COMPONENTS = { + ...BLOCK_COMPONENTS, + 'link': props => { + const href = props.node && props.node.getIn(['data', 'href']) || props.href; + return {props.children}; + }, +} + + const MARK_COMPONENTS = { bold: props => {props.children}, - code: props =>{props.children}
,
italic: props => {props.children},
underlined: props => {props.children},
+ strikethrough: props => {props.children}
,
};
const RULES = [
@@ -125,7 +134,7 @@ const RULES = [
}
},
serialize(entity, children) {
- const component = NODE_COMPONENTS[entity.type]
+ const component = BLOCK_COMPONENTS[entity.type]
if (!component) {
return;
}
@@ -166,7 +175,6 @@ const RULES = [
}
},
},
- /*
{
// Special case for links, to grab their href.
deserialize(el, next) {
@@ -180,8 +188,19 @@ const RULES = [
}
}
},
+ serialize(entity, children) {
+ if (entity.type !== 'link') {
+ return;
+ }
+ const data = entity.get('data');
+ const props = {
+ href: data.get('href'),
+ attributes: data.get('attributes'),
+ children,
+ };
+ return NODE_COMPONENTS.link(props);
+ }
},
- */
]
const serializer = new SlateHtml({ rules: RULES });