fix(widget-markdown): don't strip new lines from text nodes (#3813)
This commit is contained in:
parent
1419ba1d09
commit
7bc75d095b
@ -32,7 +32,8 @@ Object {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": "Note: Feel free to play with this page. Unlike regular notes, this doesn't automatically save itself.",
|
"text": "Note: Feel free to play with this page. Unlike regular notes, this doesn't
|
||||||
|
automatically save itself.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"object": "block",
|
"object": "block",
|
||||||
@ -52,7 +53,8 @@ Object {
|
|||||||
"nodes": Array [
|
"nodes": Array [
|
||||||
Object {
|
Object {
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": "Paragraphs can be written like so. A paragraph is the basic block of Markdown. A paragraph is what text will turn into when there is no reason it should
|
"text": "Paragraphs can be written like so. A paragraph is the basic block of Markdown.
|
||||||
|
A paragraph is what text will turn into when there is no reason it should
|
||||||
become anything else.",
|
become anything else.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -76,7 +78,8 @@ become anything else.",
|
|||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": " and ",
|
"text": " and
|
||||||
|
",
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"marks": Array [
|
"marks": Array [
|
||||||
@ -298,7 +301,8 @@ uses a fixed-width font.",
|
|||||||
"nodes": Array [
|
"nodes": Array [
|
||||||
Object {
|
Object {
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": "Here is a quote. What this is should be self explanatory. Quotes are automatically indented when they are used.",
|
"text": "Here is a quote. What this is should be self explanatory. Quotes are
|
||||||
|
automatically indented when they are used.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"object": "block",
|
"object": "block",
|
||||||
@ -322,7 +326,8 @@ uses a fixed-width font.",
|
|||||||
"nodes": Array [
|
"nodes": Array [
|
||||||
Object {
|
Object {
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": "There are six levels of headings. They correspond with the six levels of HTML headings. You've probably noticed them already in the page. Each level down
|
"text": "There are six levels of headings. They correspond with the six levels of HTML
|
||||||
|
headings. You've probably noticed them already in the page. Each level down
|
||||||
uses one more hash character.",
|
uses one more hash character.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -384,7 +389,8 @@ uses one more hash character.",
|
|||||||
"nodes": Array [
|
"nodes": Array [
|
||||||
Object {
|
Object {
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": "Of course, demonstrating what headings look like messes up the structure of the page.",
|
"text": "Of course, demonstrating what headings look like messes up the structure of the
|
||||||
|
page.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"object": "block",
|
"object": "block",
|
||||||
@ -394,7 +400,8 @@ uses one more hash character.",
|
|||||||
"nodes": Array [
|
"nodes": Array [
|
||||||
Object {
|
Object {
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": "I don't recommend using more than three or four levels of headings here, because, when you're smallest heading isn't too small, and you're largest
|
"text": "I don't recommend using more than three or four levels of headings here,
|
||||||
|
because, when you're smallest heading isn't too small, and you're largest
|
||||||
heading isn't too big, and you want each size up to look noticeably larger and
|
heading isn't too big, and you want each size up to look noticeably larger and
|
||||||
more important, there there are only so many sizes that you can use.",
|
more important, there there are only so many sizes that you can use.",
|
||||||
},
|
},
|
||||||
@ -618,7 +625,8 @@ more important, there there are only so many sizes that you can use.",
|
|||||||
"nodes": Array [
|
"nodes": Array [
|
||||||
Object {
|
Object {
|
||||||
"object": "text",
|
"object": "text",
|
||||||
"text": "There's actually a lot more to Markdown than this. See the official introduction and syntax for more information. However, be aware that this is
|
"text": "There's actually a lot more to Markdown than this. See the official
|
||||||
|
introduction and syntax for more information. However, be aware that this is
|
||||||
not using the official implementation, and this might work subtly differently
|
not using the official implementation, and this might work subtly differently
|
||||||
in some of the little things.",
|
in some of the little things.",
|
||||||
},
|
},
|
||||||
|
@ -158,7 +158,7 @@ export const markdownToHtml = (markdown, { getAsset, resolveWidget } = {}) => {
|
|||||||
|
|
||||||
const html = unified()
|
const html = unified()
|
||||||
.use(rehypeToHtml, {
|
.use(rehypeToHtml, {
|
||||||
allowDangerousHTML: true,
|
allowDangerousHtml: true,
|
||||||
allowDangerousCharacters: true,
|
allowDangerousCharacters: true,
|
||||||
closeSelfClosing: true,
|
closeSelfClosing: true,
|
||||||
entities: { useNamedReferences: true },
|
entities: { useNamedReferences: true },
|
||||||
|
@ -284,16 +284,8 @@ export default function remarkToSlate({ voidCodeBlock } = {}) {
|
|||||||
return createBlock(typeMap[node.type], nodes, { data });
|
return createBlock(typeMap[node.type], nodes, { data });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Text
|
|
||||||
*
|
|
||||||
* Text nodes contain plain text. We remove newlines because they don't
|
|
||||||
* carry meaning for a rich text editor - a break in rich text would be
|
|
||||||
* expected to result in a break in output HTML, but that isn't the case.
|
|
||||||
* To avoid this confusion we remove them.
|
|
||||||
*/
|
|
||||||
case 'text': {
|
case 'text': {
|
||||||
const text = node.value.replace(/\n/, ' ');
|
const text = node.value;
|
||||||
return createText(text);
|
return createText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user