fix bugs due to Slate "nodes" properties being boolean
This commit is contained in:
parent
dd9d49117a
commit
d8a7608a25
@ -241,7 +241,6 @@ Object {
|
||||
Object {
|
||||
"isVoid": true,
|
||||
"kind": "block",
|
||||
"nodes": undefined,
|
||||
"type": "thematic-break",
|
||||
},
|
||||
Object {
|
||||
@ -286,7 +285,6 @@ Object {
|
||||
Object {
|
||||
"isVoid": true,
|
||||
"kind": "block",
|
||||
"nodes": undefined,
|
||||
"type": "thematic-break",
|
||||
},
|
||||
Object {
|
||||
@ -1200,7 +1198,6 @@ more important, there there are only so many sizes that you can use.",
|
||||
Object {
|
||||
"isVoid": true,
|
||||
"kind": "block",
|
||||
"nodes": undefined,
|
||||
"type": "thematic-break",
|
||||
},
|
||||
Object {
|
||||
|
@ -58,6 +58,14 @@ const markMap = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Add nodes to a parent node only if `nodes` is truthy.
|
||||
*/
|
||||
function addNodes(parent, nodes) {
|
||||
return nodes ? { ...parent, nodes } : parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a Slate Inline node.
|
||||
*/
|
||||
@ -67,7 +75,8 @@ function createBlock(type, nodes, props = {}) {
|
||||
nodes = undefined;
|
||||
}
|
||||
|
||||
return { kind: 'block', type, nodes, ...props };
|
||||
const node = { kind: 'block', type, ...props };
|
||||
return addNodes(node, nodes);
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +84,8 @@ function createBlock(type, nodes, props = {}) {
|
||||
* Create a Slate Block node.
|
||||
*/
|
||||
function createInline(type, props = {}, nodes) {
|
||||
return { kind: 'inline', type, nodes, ...props };
|
||||
const node = { kind: 'inline', type, ...props };
|
||||
return addNodes(node, nodes);
|
||||
}
|
||||
|
||||
|
||||
@ -143,7 +153,7 @@ function processMarkNode(node, parentMarks = []) {
|
||||
function convertMarkNode(node) {
|
||||
const slateNodes = processMarkNode(node);
|
||||
|
||||
const convertedSlateNodes = slateNodes.reduce((acc, node, idx, nodes) => {
|
||||
const convertedSlateNodes = slateNodes.reduce((acc, node) => {
|
||||
const lastConvertedNode = last(acc);
|
||||
if (node.text && lastConvertedNode && lastConvertedNode.ranges) {
|
||||
lastConvertedNode.ranges.push(node);
|
||||
|
@ -55,7 +55,8 @@ export default function remarkSquashReferences() {
|
||||
|
||||
const pre = u('text', node.type === 'imageReference' ? '![' : '[');
|
||||
const post = u('text', ']');
|
||||
return [ pre, ...children, post];
|
||||
const nodes = children || [ u('text', node.alt) ];
|
||||
return [ pre, ...nodes, post];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user