From a220cd5ae10c7e5f7df6d018deae0670526dbb73 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Tue, 30 Apr 2019 12:15:22 -0700 Subject: [PATCH] remove leaves (#2715) * first stab at removing leaves with tests passing * add deprecation warning for creating texts with leaves * fixes * update examples --- examples/check-lists/value.json | 64 +-- examples/code-highlighting/value.json | 88 +-- examples/composition/value.json | 84 ++- examples/embeds/value.json | 18 +- examples/emojis/value.json | 30 +- examples/forced-layout/value.json | 16 +- examples/history/value.json | 18 +- examples/hovering-menu/value.json | 78 ++- examples/huge-document/index.js | 4 +- examples/images/value.json | 18 +- examples/input-tester/value.json | 84 ++- examples/links/value.json | 30 +- examples/markdown-shortcuts/value.json | 38 +- examples/mentions/value.json | 8 +- examples/paste-html/value.json | 18 +- examples/placeholder/value.json | 4 +- examples/rich-text/value.json | 110 ++-- examples/rtl/value.json | 40 +- examples/search-highlighting/value.json | 17 +- examples/syncing-operations/value.json | 77 +-- examples/tables/value.json | 120 +--- examples/versions/value.json | 10 +- packages/slate-html-serializer/src/index.js | 43 +- .../test/deserialize/mark-adjacent.js | 8 +- .../test/deserialize/to-json.js | 9 +- packages/slate-hyperscript/src/creators.js | 234 ++++---- .../test/fixtures/block-inline-full.js | 9 +- .../test/fixtures/block-mark-empty.js | 15 +- .../test/fixtures/block-mark-full.js | 15 +- .../test/fixtures/block-mark-multiple.js | 44 ++ .../test/fixtures/block-mark-nested.js | 65 ++- .../test/fixtures/block-string.js | 9 +- .../test/fixtures/block-text-empty.js | 9 +- .../test/fixtures/block-text-full.js | 9 +- .../test/fixtures/cursor-across-block.js | 9 +- .../cursor-across-blocks-and-inlines.js | 54 +- .../test/fixtures/cursor-across-blocks-end.js | 18 +- .../fixtures/cursor-across-blocks-middle.js | 18 +- .../fixtures/cursor-across-blocks-start.js | 18 +- .../fixtures/cursor-across-empty-blocks.js | 81 +++ .../cursor-across-multiple-blocks-end.js | 27 +- .../cursor-across-multiple-blocks-middle.js | 27 +- .../cursor-across-multiple-blocks-start.js | 27 +- .../test/fixtures/cursor-block-end.js | 9 +- .../test/fixtures/cursor-block-middle.js | 9 +- .../test/fixtures/cursor-block-start.js | 9 +- .../fixtures/cursor-custom-block-middle.js | 9 +- .../fixtures/cursor-empty-text-with-key.js | 62 +++ .../test/fixtures/cursor-empty-text.js | 62 +++ .../test/fixtures/cursor-inline-end.js | 27 +- .../test/fixtures/cursor-inline-start.js | 27 +- .../test/fixtures/cursor-inline.js | 27 +- .../test/fixtures/cursor-is-focused-false.js | 9 +- .../test/fixtures/cursor-mark-after.js | 73 +++ .../test/fixtures/cursor-mark-end.js | 49 +- .../test/fixtures/cursor-mark-start.js | 49 +- .../test/fixtures/cursor-mark.js | 49 +- .../test/fixtures/cursor-marks-empty.js | 9 +- .../test/fixtures/custom-marks-with-text.js | 68 +++ .../test/fixtures/custom-tags.js | 53 +- .../test/fixtures/decoration-across-block.js | 19 +- .../decoration-across-multiple-blocks.js | 18 +- .../test/fixtures/inline-full.js | 9 +- .../test/fixtures/selection.js | 13 +- .../test/fixtures/text-empty.js | 9 +- .../test/fixtures/text-full.js | 9 +- .../test/fixtures/text-nested.js | 15 + .../test/fixtures/text-with-key.js | 9 +- packages/slate-plain-serializer/src/index.js | 9 +- .../test/deserialize/to-json.js | 9 +- .../fixtures/custom-block-blurred.js | 8 +- .../test/rendering/fixtures/custom-mark.js | 4 + packages/slate/src/commands/at-range.js | 43 +- packages/slate/src/commands/by-path.js | 270 ++++----- packages/slate/src/commands/with-intent.js | 15 +- packages/slate/src/interfaces/element.js | 107 ++-- packages/slate/src/interfaces/node.js | 17 +- packages/slate/src/models/node.js | 25 +- packages/slate/src/models/operation.js | 10 +- packages/slate/src/models/point.js | 18 +- packages/slate/src/models/text.js | 526 +++--------------- packages/slate/src/models/value.js | 92 +-- packages/slate/src/operations/apply.js | 24 +- packages/slate/src/plugins/core.js | 28 +- packages/slate/src/plugins/schema.js | 13 +- .../add-mark/across-blocks.js | 6 +- .../add-mark/across-inlines.js | 12 +- .../collapsed-selection-end.js} | 10 +- .../add-mark/collapsed-selection-middle.js | 28 + ...ection.js => collapsed-selection-start.js} | 0 .../existing-marks-across-blocks-at-edge.js | 44 ++ .../add-mark/existing-marks-across-blocks.js | 47 ++ .../add-mark/existing-marks.js | 13 +- .../add-mark/first-character.js | 5 +- .../add-mark/last-character.js | 7 +- .../add-mark/middle-character.js | 6 +- .../at-current-range/add-mark/whole-word.js | 6 +- .../add-mark/with-mark-object.js | 5 +- .../add-mark/with-plain-object.js | 5 +- .../add-marks/across-blocks.js | 6 +- .../add-marks/across-inlines.js | 12 +- .../add-marks/across-marks.js | 5 +- .../add-marks/collapsed-selection-end.js | 32 ++ .../add-marks/collapsed-selection-middle.js | 30 + ...ection.js => collapsed-selection-start.js} | 0 .../add-marks/first-character.js | 5 +- .../at-current-range/add-marks/inside-mark.js | 13 +- .../add-marks/last-character.js | 7 +- .../add-marks/middle-character.js | 6 +- .../at-current-range/add-marks/whole-word.js | 6 +- .../add-marks/with-mark-object.js | 20 +- .../add-marks/with-plain-object.js | 27 +- .../delete/expanded-across-whole-mark.js | 35 ++ .../delete/whole-word-mark.js | 31 ++ .../insert-text/expanded-with-mark.js | 4 - .../remove-mark/existing-marks.js | 5 +- .../remove-mark/last-character.js | 7 +- .../remove-mark/middle-character.js | 6 +- .../replace-mark/across-blocks.js | 12 +- .../replace-mark/across-inlines.js | 20 +- .../replace-mark/existing-marks.js | 8 +- .../replace-mark/last-character.js | 14 +- .../replace-mark/middle-character.js | 12 +- .../replace-mark/whole-word.js | 12 +- .../replace-mark/with-mark-object.js | 10 +- .../replace-mark/with-plain-object.js | 10 +- .../toggle-mark/add-across-blocks.js | 6 +- .../toggle-mark/add-across-inlines.js | 16 +- .../toggle-mark/add-collapsed-selection.js | 5 +- .../add-existing-marks-partially-marked.js | 16 +- .../toggle-mark/add-existing-marks.js | 10 +- .../toggle-mark/add-first-character.js | 5 +- .../toggle-mark/add-last-character.js | 7 +- .../toggle-mark/add-middle-character.js | 6 +- .../toggle-mark/add-partially-marked.js | 11 +- .../toggle-mark/add-whole-word.js | 6 +- .../toggle-mark/add-with-mark-object.js | 5 +- .../toggle-mark/add-with-plain-object.js | 5 +- .../toggle-mark/remove-across-blocks.js | 6 +- .../toggle-mark/remove-across-inlines.js | 8 + .../toggle-mark/remove-existing-marks.js | 10 +- .../toggle-mark/remove-first-character.js | 5 +- .../toggle-mark/remove-last-character.js | 7 +- .../toggle-mark/remove-middle-character.js | 6 +- .../toggle-mark/remove-whole-word.js | 6 +- .../toggle-mark/remove-with-mark-object.js | 7 +- .../toggle-mark/remove-with-plain-object.js | 7 +- .../wrap-inline/inside-inlines-begining.js | 12 +- .../wrap-inline/inside-inlines-end.js | 12 +- .../wrap-inline/inside-inlines-with-marks.js | 10 +- .../wrap-inline/inside-inlines.js | 6 +- .../insert-text-by-key/text-end-with-marks.js | 31 ++ .../text-middle-with-marks.js | 6 +- .../text-start-with-marks.js | 31 ++ .../{start-text.js => text-start.js} | 0 .../by-key/replace-node-by-key/text.js | 2 +- .../replace-with-active-marks-with-data.js | 5 +- .../replace-with-mark-and-active-mark.js | 8 +- .../by-key/set-mark-by-key/with-data.js | 6 +- .../slate/test/history/undo/remove-mark.js | 6 +- packages/slate/test/index.js | 14 +- .../across-block-with-marks.js | 6 +- .../node/get-marks-at-position/marked-text.js | 8 +- .../operation/create/add-mark-with-data.js | 4 - .../operation/create/add-mark-without-data.js | 4 - .../apply/insert-text/decoration-before.js | 1 - .../raw/deserialize/block-nested.js | 9 +- .../raw/deserialize/block-with-data.js | 9 +- .../test/serializers/raw/deserialize/block.js | 9 +- .../raw/deserialize/inline-nested.js | 45 +- .../raw/deserialize/inline-with-data.js | 27 +- .../serializers/raw/deserialize/inline.js | 27 +- .../raw/deserialize/range-with-mark.js | 35 +- .../serializers/raw/serialize/block-nested.js | 9 +- .../raw/serialize/block-with-data.js | 9 +- .../test/serializers/raw/serialize/block.js | 9 +- .../raw/serialize/inline-nested.js | 45 +- .../raw/serialize/inline-with-data.js | 27 +- .../test/serializers/raw/serialize/inline.js | 27 +- .../raw/serialize/preserve-data.js | 9 +- .../raw/serialize/preserve-keys.js | 9 +- .../serialize/preserve-selection-and-keys.js | 9 +- .../raw/serialize/preserve-selection.js | 9 +- .../raw/serialize/range-with-mark.js | 35 +- 184 files changed, 2281 insertions(+), 2599 deletions(-) create mode 100644 packages/slate-hyperscript/test/fixtures/block-mark-multiple.js create mode 100644 packages/slate-hyperscript/test/fixtures/cursor-across-empty-blocks.js create mode 100644 packages/slate-hyperscript/test/fixtures/cursor-empty-text-with-key.js create mode 100644 packages/slate-hyperscript/test/fixtures/cursor-empty-text.js create mode 100644 packages/slate-hyperscript/test/fixtures/cursor-mark-after.js create mode 100644 packages/slate-hyperscript/test/fixtures/custom-marks-with-text.js create mode 100644 packages/slate-hyperscript/test/fixtures/text-nested.js rename packages/slate/test/commands/at-current-range/{replace-mark/collapsed-selection.js => add-mark/collapsed-selection-end.js} (70%) create mode 100644 packages/slate/test/commands/at-current-range/add-mark/collapsed-selection-middle.js rename packages/slate/test/commands/at-current-range/add-mark/{collapsed-selection.js => collapsed-selection-start.js} (100%) create mode 100644 packages/slate/test/commands/at-current-range/add-mark/existing-marks-across-blocks-at-edge.js create mode 100644 packages/slate/test/commands/at-current-range/add-mark/existing-marks-across-blocks.js create mode 100644 packages/slate/test/commands/at-current-range/add-marks/collapsed-selection-end.js create mode 100644 packages/slate/test/commands/at-current-range/add-marks/collapsed-selection-middle.js rename packages/slate/test/commands/at-current-range/add-marks/{collapsed-selection.js => collapsed-selection-start.js} (100%) create mode 100644 packages/slate/test/commands/at-current-range/delete/expanded-across-whole-mark.js create mode 100644 packages/slate/test/commands/at-current-range/delete/whole-word-mark.js create mode 100644 packages/slate/test/commands/by-key/insert-text-by-key/text-end-with-marks.js create mode 100644 packages/slate/test/commands/by-key/insert-text-by-key/text-start-with-marks.js rename packages/slate/test/commands/by-key/insert-text-by-key/{start-text.js => text-start.js} (100%) diff --git a/examples/check-lists/value.json b/examples/check-lists/value.json index 708af9e8e..2ca616d73 100644 --- a/examples/check-lists/value.json +++ b/examples/check-lists/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,46 +9,30 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "With Slate you can build complex block types that have their own embedded content and behaviors, like rendering checkboxes inside check list items!" - } - ] + "text": + "With Slate you can build complex block types that have their own embedded content and behaviors, like rendering checkboxes inside check list items!" } ] }, { "object": "block", "type": "check-list-item", - "data": { - "checked": true - }, + "data": { "checked": true }, "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Slide to the left." - } - ] + "text": "Slide to the left." } ] }, { "object": "block", "type": "check-list-item", - "data": { - "checked": true - }, + "data": { "checked": true }, "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Slide to the right." - } - ] + "text": "Slide to the right." } ] }, @@ -59,28 +45,18 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Criss-cross." - } - ] + "text": "Criss-cross." } ] }, { "object": "block", "type": "check-list-item", - "data": { - "checked": true - }, + "data": { "checked": true }, "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Criss-cross!" - } - ] + "text": "Criss-cross!" } ] }, @@ -93,11 +69,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Cha cha real smooth…" - } - ] + "text": "Cha cha real smooth…" } ] }, @@ -110,11 +82,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Let's go to work!" - } - ] + "text": "Let's go to work!" } ] }, @@ -124,11 +92,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Try it out for yourself!" - } - ] + "text": "Try it out for yourself!" } ] } diff --git a/examples/code-highlighting/value.json b/examples/code-highlighting/value.json index 281ddb285..d0e1263b7 100644 --- a/examples/code-highlighting/value.json +++ b/examples/code-highlighting/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,12 +9,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "There are certain behaviors that require rendering dynamic marks on string of text, like rendering code highlighting. For example:" - } - ] + "text": + "There are certain behaviors that require rendering dynamic marks on string of text, like rendering code highlighting. For example:" } ] }, @@ -29,11 +27,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "// A simple FizzBuzz implementation." - } - ] + "text": "// A simple FizzBuzz implementation." } ] }, @@ -43,11 +37,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "for (var i = 1; i <= 100; i++) {" - } - ] + "text": "for (var i = 1; i <= 100; i++) {" } ] }, @@ -57,11 +47,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " if (i % 15 == 0) {" - } - ] + "text": " if (i % 15 == 0) {" } ] }, @@ -71,11 +57,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " console.log('Fizz Buzz');" - } - ] + "text": " console.log('Fizz Buzz');" } ] }, @@ -85,11 +67,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " } else if (i % 5 == 0) {" - } - ] + "text": " } else if (i % 5 == 0) {" } ] }, @@ -99,11 +77,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " console.log('Buzz');" - } - ] + "text": " console.log('Buzz');" } ] }, @@ -113,11 +87,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " } else if (i % 3 == 0) {" - } - ] + "text": " } else if (i % 3 == 0) {" } ] }, @@ -127,11 +97,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " console.log('Fizz');" - } - ] + "text": " console.log('Fizz');" } ] }, @@ -141,11 +107,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " } else {" - } - ] + "text": " } else {" } ] }, @@ -155,11 +117,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " console.log(i);" - } - ] + "text": " console.log(i);" } ] }, @@ -169,11 +127,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": " }" - } - ] + "text": " }" } ] }, @@ -183,11 +137,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "}" - } - ] + "text": "}" } ] } @@ -199,11 +149,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Try it out for yourself!" - } - ] + "text": "Try it out for yourself!" } ] } diff --git a/examples/composition/value.json b/examples/composition/value.json index 8817f5880..91ee48585 100644 --- a/examples/composition/value.json +++ b/examples/composition/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,14 +9,14 @@ "nodes": [ { "object": "text", - "leaves": [ - { "text": "Insert Text: ", "marks": [{ "type": "bold" }] }, - { - "text": - "Type 'cat' before every word 'before' and after every word 'after' and in the middle of the word 'pion' so that it says 'pi cat on' using the virtual keyboard", - "marks": [{ "type": "italic" }] - } - ] + "text": "Insert Text: ", + "marks": [{ "type": "bold" }] + }, + { + "object": "text", + "text": + "Type 'cat' before every word 'before' and after every word 'after' and in the middle of the word 'pion' so that it says 'pi cat on' using the virtual keyboard", + "marks": [{ "type": "italic" }] } ] }, @@ -24,11 +26,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Before there before is pion at after for after" - } - ] + "text": "Before there before is pion at after for after" } ] }, @@ -38,14 +36,14 @@ "nodes": [ { "object": "text", - "leaves": [ - { "text": "Handle Enter: ", "marks": [{ "type": "bold" }] }, - { - "text": - "Hit Enter twice before every word 'before' and after every word 'after' and in the middle of the word 'split'", - "marks": [{ "type": "italic" }] - } - ] + "text": "Handle Enter: ", + "marks": [{ "type": "bold" }] + }, + { + "object": "text", + "text": + "Hit Enter twice before every word 'before' and after every word 'after' and in the middle of the word 'split'", + "marks": [{ "type": "italic" }] } ] }, @@ -55,11 +53,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Before there before is split at after for after" - } - ] + "text": "Before there before is split at after for after" } ] }, @@ -69,20 +63,18 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "Since it's rich text, you can do things like turn a selection of text " - }, - { - "text": "bold", - "marks": [{ "type": "bold" }] - }, - { - "text": - ", or add a semantically rendered block quote in the middle of the page, like this:" - } - ] + "text": + "Since it's rich text, you can do things like turn a selection of text " + }, + { + "object": "text", + "text": "bold", + "marks": [{ "type": "bold" }] + }, + { + "object": "text", + "text": + ", or add a semantically rendered block quote in the middle of the page, like this:" } ] }, @@ -92,11 +84,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "A wise quote." - } - ] + "text": "A wise quote." } ] }, @@ -106,11 +94,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Try it out for yourself!" - } - ] + "text": "Try it out for yourself!" } ] } diff --git a/examples/embeds/value.json b/examples/embeds/value.json index 7c645cbdb..1c4f262dc 100644 --- a/examples/embeds/value.json +++ b/examples/embeds/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,12 +9,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "In addition to simple image nodes, you can actually create complex embedded nodes. For example, this one contains an input element that lets you change the video being rendered!" - } - ] + "text": + "In addition to simple image nodes, you can actually create complex embedded nodes. For example, this one contains an input element that lets you change the video being rendered!" } ] }, @@ -29,12 +27,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "Try it out! If you want another good video URL to try, go with: https://www.youtube.com/embed/6Ejga4kJUts" - } - ] + "text": + "Try it out! If you want another good video URL to try, go with: https://www.youtube.com/embed/6Ejga4kJUts" } ] } diff --git a/examples/emojis/value.json b/examples/emojis/value.json index 7b082e9d9..fffe28215 100644 --- a/examples/emojis/value.json +++ b/examples/emojis/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,27 +9,17 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "In addition to block nodes, you can create inline void nodes, like " - } - ] + "text": + "In addition to block nodes, you can create inline void nodes, like " }, { "object": "inline", "type": "emoji", - "data": { - "code": "😃" - } + "data": { "code": "😃" } }, { "object": "text", - "leaves": [ - { - "text": "!" - } - ] + "text": "!" } ] }, @@ -38,9 +30,7 @@ { "object": "inline", "type": "emoji", - "data": { - "code": "🍔" - } + "data": { "code": "🍔" } } ] }, @@ -50,11 +40,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "This example shows emojis in action." - } - ] + "text": "This example shows emojis in action." } ] } diff --git a/examples/forced-layout/value.json b/examples/forced-layout/value.json index 24240b9ad..c18ffeee0 100644 --- a/examples/forced-layout/value.json +++ b/examples/forced-layout/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,11 +9,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Enforce Your Layout!" - } - ] + "text": "Enforce Your Layout!" } ] }, @@ -21,12 +19,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "This example shows how to enforce your layout with schema-specific rules. This document will always have a title block at the top and at least one paragraph in the body. Try deleting them and see what happens!" - } - ] + "text": + "This example shows how to enforce your layout with schema-specific rules. This document will always have a title block at the top and at least one paragraph in the body. Try deleting them and see what happens!" } ] } diff --git a/examples/history/value.json b/examples/history/value.json index af69aa9e5..83ee3c9d1 100644 --- a/examples/history/value.json +++ b/examples/history/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,12 +9,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "Slate editors save all changes to an internal \"history\" automatically, so you don't need to implement undo/redo yourself. And the editor automatically binds to the browser's default undo/redo keyboard shortcuts." - } - ] + "text": + "Slate editors save all changes to an internal \"history\" automatically, so you don't need to implement undo/redo yourself. And the editor automatically binds to the browser's default undo/redo keyboard shortcuts." } ] }, @@ -22,12 +20,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "Try it out for yourself! Make any changes you'd like then press \"cmd+z\"." - } - ] + "text": + "Try it out for yourself! Make any changes you'd like then press \"cmd+z\"." } ] } diff --git a/examples/hovering-menu/value.json b/examples/hovering-menu/value.json index 244065339..d58c36202 100644 --- a/examples/hovering-menu/value.json +++ b/examples/hovering-menu/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,34 +9,25 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "This example shows how you can make a hovering menu appear above your content, which you can use to make text " - }, - { - "text": "bold", - "marks": [ - { - "type": "bold" - } - ] - }, - { - "text": ", " - }, - { - "text": "italic", - "marks": [ - { - "type": "italic" - } - ] - }, - { - "text": ", or anything else you might want to do!" - } - ] + "text": + "This example shows how you can make a hovering menu appear above your content, which you can use to make text " + }, + { + "object": "text", + "text": "bold", + "marks": [{ "type": "bold" }] + }, + { + "object": "text", + "text": ", " + }, + { + "object": "text", + "text": "italic", + "marks": [{ "type": "italic" }] + }, + { + "text": ", or anything else you might want to do!" } ] }, @@ -44,25 +37,16 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Try it out yourself! Just " - }, - { - "text": "select any piece of text and the menu will appear", - "marks": [ - { - "type": "bold" - }, - { - "type": "italic" - } - ] - }, - { - "text": "." - } - ] + "text": "Try it out yourself! Just " + }, + { + "object": "text", + "text": "select any piece of text and the menu will appear", + "marks": [{ "type": "bold" }, { "type": "italic" }] + }, + { + "object": "text", + "text": "." } ] } diff --git a/examples/huge-document/index.js b/examples/huge-document/index.js index 67d840c3f..ea3dc66dc 100644 --- a/examples/huge-document/index.js +++ b/examples/huge-document/index.js @@ -23,14 +23,14 @@ for (let h = 0; h < HEADINGS; h++) { nodes.push({ object: 'block', type: 'heading', - nodes: [{ object: 'text', leaves: [{ text: faker.lorem.sentence() }] }], + nodes: [{ object: 'text', text: faker.lorem.sentence() }], }) for (let p = 0; p < PARAGRAPHS; p++) { nodes.push({ object: 'block', type: 'paragraph', - nodes: [{ object: 'text', leaves: [{ text: faker.lorem.paragraph() }] }], + nodes: [{ object: 'text', text: faker.lorem.paragraph() }], }) } } diff --git a/examples/images/value.json b/examples/images/value.json index e534cb6f2..e97578355 100644 --- a/examples/images/value.json +++ b/examples/images/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,12 +9,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "In addition to nodes that contain editable text, you can also create other types of nodes, like images or videos." - } - ] + "text": + "In addition to nodes that contain editable text, you can also create other types of nodes, like images or videos." } ] }, @@ -30,12 +28,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "This example shows images in action. It features two ways to add images. You can either add an image via the toolbar icon above, or if you want in on a little secret, copy an image URL to your keyboard and paste it anywhere in the editor!" - } - ] + "text": + "This example shows images in action. It features two ways to add images. You can either add an image via the toolbar icon above, or if you want in on a little secret, copy an image URL to your keyboard and paste it anywhere in the editor!" } ] } diff --git a/examples/input-tester/value.json b/examples/input-tester/value.json index 71b5e9599..c61d0831d 100644 --- a/examples/input-tester/value.json +++ b/examples/input-tester/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,45 +9,35 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "This Slate editor records all of the " - }, - { - "text": "keyboard", - "marks": [ - { - "type": "bold" - } - ] - }, - { - "text": ", " - }, - { - "text": "input", - "marks": [ - { - "type": "bold" - } - ] - }, - { - "text": " and " - }, - { - "text": "selection", - "marks": [ - { - "type": "bold" - } - ] - }, - { - "text": - " event that occur while using it, so you can debug the exact combination of events that is firing for particular editing behaviors." - } - ] + "text": "This Slate editor records all of the " + }, + { + "object": "text", + "text": "keyboard", + "marks": [{ "type": "bold" }] + }, + { + "object": "text", + "text": ", " + }, + { + "object": "text", + "text": "input", + "marks": [{ "type": "bold" }] + }, + { + "object": "text", + "text": " and " + }, + { + "object": "text", + "text": "selection", + "marks": [{ "type": "bold" }] + }, + { + "object": "text", + "text": + " event that occur while using it, so you can debug the exact combination of events that is firing for particular editing behaviors." } ] }, @@ -55,12 +47,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "And this is a quote in case you need to try testing across block types." - } - ] + "text": + "And this is a quote in case you need to try testing across block types." } ] }, @@ -70,11 +58,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Try it out!" - } - ] + "text": "Try it out!" } ] } diff --git a/examples/links/value.json b/examples/links/value.json index 730559545..fa4005850 100644 --- a/examples/links/value.json +++ b/examples/links/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,12 +9,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "In addition to block nodes, you can create inline nodes, like " - } - ] + "text": + "In addition to block nodes, you can create inline nodes, like " }, { "object": "inline", @@ -23,21 +21,13 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "hyperlinks" - } - ] + "text": "hyperlinks" } ] }, { "object": "text", - "leaves": [ - { - "text": "!" - } - ] + "text": "!" } ] }, @@ -47,12 +37,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "This example shows hyperlinks in action. It features two ways to add links. You can either add a link via the toolbar icon above, or if you want in on a little secret, copy a URL to your keyboard and paste it while a range of text is selected." - } - ] + "text": + "This example shows hyperlinks in action. It features two ways to add links. You can either add a link via the toolbar icon above, or if you want in on a little secret, copy a URL to your keyboard and paste it while a range of text is selected." } ] } diff --git a/examples/markdown-shortcuts/value.json b/examples/markdown-shortcuts/value.json index b30603dce..0b91ee19f 100644 --- a/examples/markdown-shortcuts/value.json +++ b/examples/markdown-shortcuts/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,12 +9,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "The editor gives you full control over the logic you can add. For example, it's fairly common to want to add markdown-like shortcuts to editors. So that, when you start a line with \"> \" you get a blockquote that looks like this:" - } - ] + "text": + "The editor gives you full control over the logic you can add. For example, it's fairly common to want to add markdown-like shortcuts to editors. So that, when you start a line with \"> \" you get a blockquote that looks like this:" } ] }, @@ -22,11 +20,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "A wise quote." - } - ] + "text": "A wise quote." } ] }, @@ -36,12 +30,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "Order when you start a line with \"## \" you get a level-two heading, like this:" - } - ] + "text": + "Order when you start a line with \"## \" you get a level-two heading, like this:" } ] }, @@ -51,11 +41,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Try it out!" - } - ] + "text": "Try it out!" } ] }, @@ -65,12 +51,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "Try it out for yourself! Try starting a new line with \">\", \"-\", or \"#\"s." - } - ] + "text": + "Try it out for yourself! Try starting a new line with \">\", \"-\", or \"#\"s." } ] } diff --git a/examples/mentions/value.json b/examples/mentions/value.json index 9b2e3d6eb..896d36d5d 100644 --- a/examples/mentions/value.json +++ b/examples/mentions/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,11 +9,7 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "Try mentioning some users, like Luke or Leia." - } - ] + "text": "Try mentioning some users, like Luke or Leia." } ] } diff --git a/examples/paste-html/value.json b/examples/paste-html/value.json index 2d9340f83..d738c834d 100644 --- a/examples/paste-html/value.json +++ b/examples/paste-html/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,12 +9,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "By default, pasting content into a Slate editor will use the content's plain text representation. This is fine for some use cases, but sometimes you want to actually be able to paste in content and have it parsed into blocks and links and things. To do this, you need to add a parser that triggers on paste. This is an example of doing exactly that!" - } - ] + "text": + "By default, pasting content into a Slate editor will use the content's plain text representation. This is fine for some use cases, but sometimes you want to actually be able to paste in content and have it parsed into blocks and links and things. To do this, you need to add a parser that triggers on paste. This is an example of doing exactly that!" } ] }, @@ -22,12 +20,8 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": - "Try it out for yourself! Copy and paste some rendered HTML content (not the source code) from another site into this editor." - } - ] + "text": + "Try it out for yourself! Copy and paste some rendered HTML content (not the source code) from another site into this editor." } ] } diff --git a/examples/placeholder/value.json b/examples/placeholder/value.json index 6b2e29764..7d4cd5f4d 100644 --- a/examples/placeholder/value.json +++ b/examples/placeholder/value.json @@ -1,5 +1,7 @@ { + "object": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,7 +9,7 @@ "nodes": [ { "object": "text", - "leaves": [] + "text": "" } ] } diff --git a/examples/rich-text/value.json b/examples/rich-text/value.json index f6f0b3dc6..1b5452979 100644 --- a/examples/rich-text/value.json +++ b/examples/rich-text/value.json @@ -1,5 +1,7 @@ { + "objcet": "value", "document": { + "object": "document", "nodes": [ { "object": "block", @@ -7,44 +9,34 @@ "nodes": [ { "object": "text", - "leaves": [ - { - "text": "This is editable " - }, - { - "text": "rich", - "marks": [ - { - "type": "bold" - } - ] - }, - { - "text": " text, " - }, - { - "text": "much", - "marks": [ - { - "type": "italic" - } - ] - }, - { - "text": " better than a " - }, - { - "text": "