diff --git a/packages/netlify-cms-widget-markdown/package.json b/packages/netlify-cms-widget-markdown/package.json index 327c1def..e2b27705 100644 --- a/packages/netlify-cms-widget-markdown/package.json +++ b/packages/netlify-cms-widget-markdown/package.json @@ -30,12 +30,12 @@ "remark-parse": "^3.0.1", "remark-rehype": "^2.0.0", "remark-stringify": "^3.0.1", - "slate": "^0.30.0", - "slate-edit-list": "^0.10.1", - "slate-edit-table": "^0.12.0", - "slate-plain-serializer": "^0.4.0", - "slate-react": "0.10.11", - "slate-soft-break": "^0.6.0", + "slate": "^0.34.0", + "slate-edit-list": "^0.11.3", + "slate-edit-table": "^0.15.1", + "slate-plain-serializer": "^0.5.15", + "slate-react": "0.12.9", + "slate-soft-break": "^0.6.1", "unified": "^6.1.4", "unist-builder": "^1.0.2", "unist-util-visit-parents": "^1.1.1" diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/VisualEditor.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/VisualEditor.js index 608d1b9a..30829e42 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/VisualEditor.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/VisualEditor.js @@ -21,7 +21,7 @@ const VisualEditorContainer = styled.div` const createEmptyRawDoc = () => { const emptyText = Text.create(''); - const emptyBlock = Block.create({ kind: 'block', type: 'paragraph', nodes: [emptyText] }); + const emptyBlock = Block.create({ object: 'block', type: 'paragraph', nodes: [emptyText] }); return { nodes: [emptyBlock] }; }; @@ -86,7 +86,7 @@ export default class Editor extends React.Component { // Handle everything except list buttons. if (!['bulleted-list', 'numbered-list'].includes(type)) { const isActive = this.selectionHasBlock(type); - change = change.setBlock(isActive ? 'paragraph' : type); + change = change.setBlocks(isActive ? 'paragraph' : type); } // Handle the extra wrapping required for list buttons. @@ -144,7 +144,7 @@ export default class Editor extends React.Component { const { value } = this.state; const nodes = [Text.create('')]; const block = { - kind: 'block', + object: 'block', type: 'shortcode', data: { shortcode: pluginId, @@ -157,7 +157,7 @@ export default class Editor extends React.Component { let change = value.change(); const { focusBlock } = change.value; - if (focusBlock.text === '') { + if (focusBlock.text === '' && focusBlock.type === 'paragraph') { change = change.setNodeByKey(focusBlock.key, block); } else { change = change.insertBlock(block); diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/__tests__/__snapshots__/parser.spec.js.snap b/packages/netlify-cms-widget-markdown/src/MarkdownControl/__tests__/__snapshots__/parser.spec.js.snap index baedbaa2..a7b66cc0 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/__tests__/__snapshots__/parser.spec.js.snap +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/__tests__/__snapshots__/parser.spec.js.snap @@ -2,369 +2,366 @@ exports[`Compile markdown to Slate Raw AST should compile a markdown ordered list 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H1", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { "data": Object { "start": 1, }, - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "yo", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "bro", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "fro", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, ], + "object": "block", "type": "numbered-list", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile bulleted lists 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H1", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { "data": Object { "start": null, }, - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "yo", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "bro", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "fro", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, ], + "object": "block", "type": "bulleted-list", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile code blocks 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { "data": Object { "lang": "javascript", }, - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "var a = 1;", }, ], + "object": "text", }, ], + "object": "block", "type": "code", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile horizontal rules 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H1", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { "isVoid": true, - "kind": "block", + "object": "block", "type": "thematic-break", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "blue moon", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile horizontal rules 2`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H1", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { "isVoid": true, - "kind": "block", + "object": "block", "type": "thematic-break", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "blue moon", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile images 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "![super](duper.jpg)", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile inline code 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Word", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "This is some sweet ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -375,64 +372,64 @@ Object { "text": "inline code", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " yo!", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile kitchen sink example 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "An exhibit of Markdown", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "This note demonstrates some of what Markdown is capable of doing.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -444,31 +441,31 @@ Object { automatically save itself.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Basic formatting", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Paragraphs can be written like so. A paragraph is the basic block of Markdown. @@ -476,25 +473,25 @@ A paragraph is what text will turn into when there is no reason it should become anything else.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Paragraphs must be separated by a blank line. Basic formatting of ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -505,20 +502,20 @@ become anything else.", "text": "italics", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " and ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -529,19 +526,19 @@ become anything else.", "text": "bold", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " is supported. This ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -571,85 +568,85 @@ become anything else.", "text": " like", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " so.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Lists", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Ordered list", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-three", }, Object { "data": Object { "start": 1, }, - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Item 1 2. A second item 3. Number 3 4. Ⅳ", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, ], + "object": "block", "type": "numbered-list", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -660,94 +657,94 @@ become anything else.", "text": "Note: the fourth item uses the Unicode character for Roman numeral four.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Unordered list", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-three", }, Object { "data": Object { "start": null, }, - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "An item Another item Yet another item And there's more...", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, ], + "object": "block", "type": "bulleted-list", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Paragraph modifiers", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Code block", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-three", }, Object { "data": Object { "lang": null, }, - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Code blocks are very useful for developers and other people who look at @@ -755,25 +752,25 @@ code or other things that are written in plain text. As you can see, it uses a fixed-width font.", }, ], + "object": "text", }, ], + "object": "block", "type": "code", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "You can also make ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -784,77 +781,77 @@ uses a fixed-width font.", "text": "inline code", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " to add code into other things.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Quote", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-three", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Here is a quote. What this is should be self explanatory. Quotes are automatically indented when they are used.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "quote", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Headings", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "There are six levels of headings. They correspond with the six levels of HTML @@ -862,25 +859,25 @@ headings. You've probably noticed them already in the page. Each level down uses one more hash character.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Headings ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -891,19 +888,19 @@ uses one more hash character.", "text": "can", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " also contain ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -914,25 +911,25 @@ uses one more hash character.", "text": "formatting", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-three", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "They can even contain ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -943,32 +940,32 @@ uses one more hash character.", "text": "inline code", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-three", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Of course, demonstrating what headings look like messes up the structure of the page.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "I don't recommend using more than three or four levels of headings here, @@ -977,85 +974,83 @@ 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.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "URLs", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "URLs can be made in a handful of ways:", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { "data": Object { "start": null, }, - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "A named link to MarkItDown. The easiest way to do these is to select what you", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "want to make a link and hit ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -1066,206 +1061,208 @@ more important, there there are only so many sizes that you can use.", "text": "Ctrl+L", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": ". Another named link to", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": Object { "title": null, "url": "http://www.markitdown.net/", }, - "kind": "inline", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "MarkItDown", }, ], + "object": "text", }, ], + "object": "inline", "type": "link", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " Sometimes you just want a URL like", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": Object { "title": null, "url": "http://www.markitdown.net/", }, - "kind": "inline", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "http://www.markitdown.net/", }, ], + "object": "text", }, ], + "object": "inline", "type": "link", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": ".", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "list-item", }, ], + "object": "block", "type": "bulleted-list", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Horizontal rule", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "A horizontal rule is a line that goes across the middle of the page.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { "isVoid": true, - "kind": "block", + "object": "block", "type": "thematic-break", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "It's sometimes handy for breaking things up.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Images", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Markdown can also contain images. I'll need to add something here sometime.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Finally", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "There's actually a lot more to Markdown than this. See the official @@ -1274,170 +1271,170 @@ not using the official implementation, and this might work subtly differently in some of the little things.", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile links 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Word", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "How far is it to ", }, ], + "object": "text", }, Object { "data": Object { "title": null, "url": "https://google.com", }, - "kind": "inline", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Google", }, ], + "object": "text", }, ], + "object": "inline", "type": "link", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " land?", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile multiple header levels 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H1", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H2", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-two", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H3", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-three", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile nested inline markup 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "Word", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "This is ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -1467,25 +1464,25 @@ Object { "text": " content", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "perhaps ", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "marks": Array [ @@ -1496,147 +1493,150 @@ Object { "text": "scalding", }, ], + "object": "text", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " even", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile plugins 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "![test](test.png)", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "{{< test >}}", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile simple markdown 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "H1", }, ], + "object": "text", }, ], + "object": "block", "type": "heading-one", }, Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "sweet body", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; exports[`Compile markdown to Slate Raw AST should compile soft breaks (double space) 1`] = ` Object { - "kind": "block", "nodes": Array [ Object { - "kind": "block", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "blue moon", }, ], + "object": "text", }, Object { - "kind": "inline", "nodes": Array [ Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": " ", }, ], + "object": "text", }, ], + "object": "inline", "type": "break", }, Object { "data": undefined, - "kind": "text", "leaves": Array [ Object { "text": "footballs", }, ], + "object": "text", }, ], + "object": "block", "type": "paragraph", }, ], + "object": "block", "type": "root", } `; diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins.js index ecc24fd3..2f1fa74f 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/plugins.js @@ -70,7 +70,7 @@ const BackspaceCloseBlock = (options = {}) => ({ if (ignoreIn && ignoreIn.includes(type)) return; if (startBlock.text === '') { - return change.setBlock(defaultBlock).focus(); + return change.setBlocks(defaultBlock).focus(); } }, }); diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/validators.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/validators.js index ece167c9..db2449b7 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/validators.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/validators.js @@ -8,7 +8,7 @@ export function validateNode(node) { /** * Validation of the document itself. */ - if (node.kind === 'document') { + if (node.object === 'document') { const doc = node; /** * If the editor is ever in an empty state, insert an empty diff --git a/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js b/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js index 439b40e0..02fb7590 100644 --- a/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js +++ b/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js @@ -71,7 +71,7 @@ function createBlock(type, nodes, props = {}) { nodes = undefined; } - const node = { kind: 'block', type, ...props }; + const node = { object: 'block', type, ...props }; return addNodes(node, nodes); } @@ -79,7 +79,7 @@ function createBlock(type, nodes, props = {}) { * Create a Slate Block node. */ function createInline(type, props = {}, nodes) { - const node = { kind: 'inline', type, ...props }; + const node = { object: 'inline', type, ...props }; return addNodes(node, nodes); } @@ -87,7 +87,7 @@ function createInline(type, props = {}, nodes) { * Create a Slate Raw text node. */ function createText(value, data) { - const node = { kind: 'text', data }; + const node = { object: 'text', data }; const leaves = isArray(value) ? value : [{ text: value }]; return { ...node, leaves }; } diff --git a/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js b/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js index 7f7ddd6d..6d9a5e6c 100644 --- a/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js +++ b/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js @@ -76,7 +76,7 @@ function transform(node) { /** * Run individual nodes through conversion factories. */ - return ['text'].includes(node.kind) + return ['text'].includes(node.object) ? convertTextNode(node) : convertNode(node, children, shortcodePlugins); } @@ -117,15 +117,15 @@ function combineTextAndInline(nodes) { * children, so we remove the child node here. */ if (node.type === 'break') { - acc.push({ kind: 'inline', type: 'break' }); + acc.push({ object: 'inline', type: 'break' }); return acc; } /** * Convert remaining inline nodes to standalone text nodes with leaves. */ - if (node.kind === 'inline') { - acc.push({ kind: 'text', leaves: [{ node, marks: data.marks }] }); + if (node.object === 'inline') { + acc.push({ object: 'text', leaves: [{ node, marks: data.marks }] }); return acc; } @@ -175,7 +175,7 @@ function processCodeMark(markTypes) { * For example, this Slate text node: * * { - * kind: 'text', + * object: 'text', * leaves: [ * { * text: 'test', @@ -221,7 +221,7 @@ function convertTextNode(node) { return condensedNodes.nodes; } - if (node.kind === 'inline') { + if (node.object === 'inline') { return transform(node); } diff --git a/yarn.lock b/yarn.lock index c2433336..1d58d550 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2893,7 +2893,7 @@ deasync@^0.1.12: bindings "~1.2.1" nan "^2.0.7" -debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.2, debug@^2.3.3, debug@^2.6.6, debug@^2.6.8, debug@^2.6.9: +debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.6, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -6041,7 +6041,7 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" -lodash@4.17.10, lodash@^4.11.2, lodash@^4.12.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: +lodash@4.17.10, lodash@^4.1.1, lodash@^4.11.2, lodash@^4.12.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" @@ -8605,70 +8605,89 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" -slate-base64-serializer@^0.2.8: - version "0.2.45" - resolved "https://registry.yarnpkg.com/slate-base64-serializer/-/slate-base64-serializer-0.2.45.tgz#a4c5f5e59b3681cb1caac2641c6891a542b599b4" +slate-base64-serializer@^0.2.34: + version "0.2.47" + resolved "https://registry.yarnpkg.com/slate-base64-serializer/-/slate-base64-serializer-0.2.47.tgz#f7dbc62246d8eb0eef4f6a93a9f387575ab89554" dependencies: isomorphic-base64 "^1.0.2" -slate-dev-logger@^0.1.32, slate-dev-logger@^0.1.33, slate-dev-logger@^0.1.36, slate-dev-logger@^0.1.42: +slate-dev-environment@^0.1.2, slate-dev-environment@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/slate-dev-environment/-/slate-dev-environment-0.1.4.tgz#d5dd0d9a5b80b364a23bb7985202ce4e5bd3e8d3" + dependencies: + is-in-browser "^1.1.3" + +slate-dev-logger@^0.1.39, slate-dev-logger@^0.1.42: version "0.1.42" resolved "https://registry.yarnpkg.com/slate-dev-logger/-/slate-dev-logger-0.1.42.tgz#922c4693469e6d60deaa10adfd22b627c9632fbf" -slate-edit-list@^0.10.1: - version "0.10.3" - resolved "https://registry.yarnpkg.com/slate-edit-list/-/slate-edit-list-0.10.3.tgz#10f0b78c0bc9fd29e22d274d4f559bb1e00d8930" +slate-edit-list@^0.11.3: + version "0.11.3" + resolved "https://registry.yarnpkg.com/slate-edit-list/-/slate-edit-list-0.11.3.tgz#d27ff2ff93a83bef49131a6a44b87a9558c9d44c" -slate-edit-table@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/slate-edit-table/-/slate-edit-table-0.12.0.tgz#9163e67b8025c3c09d6037eb76cb5e652b65dd47" +slate-edit-table@^0.15.1: + version "0.15.2" + resolved "https://registry.yarnpkg.com/slate-edit-table/-/slate-edit-table-0.15.2.tgz#f26b67451b507f936106151f55a0bffbdbca0213" -slate-plain-serializer@^0.4.0, slate-plain-serializer@^0.4.6: - version "0.4.16" - resolved "https://registry.yarnpkg.com/slate-plain-serializer/-/slate-plain-serializer-0.4.16.tgz#eff277b58943e130905114c7da431ab307cb4c1e" +slate-hotkeys@^0.1.2: + version "0.1.4" + resolved "https://registry.yarnpkg.com/slate-hotkeys/-/slate-hotkeys-0.1.4.tgz#5b10b2a178affc60827f9284d4c0a5d7e5041ffe" dependencies: - slate-dev-logger "^0.1.36" + is-hotkey "^0.1.1" + slate-dev-environment "^0.1.4" -slate-prop-types@^0.4.6: - version "0.4.43" - resolved "https://registry.yarnpkg.com/slate-prop-types/-/slate-prop-types-0.4.43.tgz#d23e75d598d9121edbbd5e665d0dcbedded45fee" +slate-plain-serializer@^0.5.15: + version "0.5.28" + resolved "https://registry.yarnpkg.com/slate-plain-serializer/-/slate-plain-serializer-0.5.28.tgz#4c872a5044333229804c9140fc1a66792fdd2e99" dependencies: slate-dev-logger "^0.1.42" -slate-react@0.10.11: - version "0.10.11" - resolved "https://registry.yarnpkg.com/slate-react/-/slate-react-0.10.11.tgz#5fbfbf0da2dd726df468d788d2bd81dd578a15a3" +slate-prop-types@^0.4.32: + version "0.4.45" + resolved "https://registry.yarnpkg.com/slate-prop-types/-/slate-prop-types-0.4.45.tgz#7110f3fbb7a4356182144d6f0579fd36694bae30" dependencies: - debug "^2.3.2" + slate-dev-logger "^0.1.42" + +slate-react@0.12.9: + version "0.12.9" + resolved "https://registry.yarnpkg.com/slate-react/-/slate-react-0.12.9.tgz#6cb6f1fa86c868f56b5dce064146520545884351" + dependencies: + debug "^3.1.0" get-window "^1.1.1" - is-hotkey "^0.1.1" - is-in-browser "^1.1.3" is-window "^1.0.2" keycode "^2.1.2" + lodash "^4.1.1" prop-types "^15.5.8" react-immutable-proptypes "^2.1.0" react-portal "^3.1.0" selection-is-backward "^1.0.0" - slate-base64-serializer "^0.2.8" - slate-dev-logger "^0.1.32" - slate-plain-serializer "^0.4.6" - slate-prop-types "^0.4.6" + slate-base64-serializer "^0.2.34" + slate-dev-environment "^0.1.2" + slate-dev-logger "^0.1.39" + slate-hotkeys "^0.1.2" + slate-plain-serializer "^0.5.15" + slate-prop-types "^0.4.32" -slate-soft-break@^0.6.0: +slate-schema-violations@^0.1.20: + version "0.1.26" + resolved "https://registry.yarnpkg.com/slate-schema-violations/-/slate-schema-violations-0.1.26.tgz#6613f98a62ed1516a6d517f6df4881850a15d987" + +slate-soft-break@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/slate-soft-break/-/slate-soft-break-0.6.1.tgz#b5e9ccf3cb876168c10266428274e2523b0d3dd9" -slate@^0.30.0: - version "0.30.7" - resolved "https://registry.yarnpkg.com/slate/-/slate-0.30.7.tgz#98b5e4d8529775eaf2e7e3a2306db8cc49034772" +slate@^0.34.0: + version "0.34.7" + resolved "https://registry.yarnpkg.com/slate/-/slate-0.34.7.tgz#5908e1d0fc092a2212488beca65671f01e0eb80a" dependencies: - debug "^2.3.2" + debug "^3.1.0" direction "^0.1.5" esrever "^0.2.0" is-empty "^1.0.0" is-plain-object "^2.0.4" lodash "^4.17.4" - slate-dev-logger "^0.1.33" + slate-dev-logger "^0.1.39" + slate-schema-violations "^0.1.20" type-of "^2.0.1" slice-ansi@0.0.4: