From a1638dd90692762e0d959ddc72e77983d4a4ba4b Mon Sep 17 00:00:00 2001 From: AlbertHilb Date: Thu, 8 Dec 2016 00:16:40 +0100 Subject: [PATCH] Add an attribute to uniquely identify divs used to render `content` component (#470) * Add `data-slate-content` attribute to the divs used to render `content` components. Use that attribute to uniquely identify them. Update test expected results. * Fix lint complaints. --- src/components/content.js | 3 ++- test/rendering/fixtures/custom-block-void/output.html | 2 +- test/rendering/fixtures/custom-block/output.html | 2 +- test/rendering/fixtures/custom-decorator/output.html | 2 +- test/rendering/fixtures/custom-inline-void/output.html | 2 +- test/rendering/fixtures/custom-inline/output.html | 2 +- test/rendering/fixtures/custom-mark-with-component/output.html | 2 +- test/rendering/fixtures/custom-mark-with-function/output.html | 2 +- test/rendering/fixtures/custom-mark-with-mixed/output.html | 2 +- test/rendering/fixtures/custom-mark-with-object/output.html | 2 +- test/rendering/fixtures/custom-mark-with-string/output.html | 2 +- test/rendering/fixtures/default-block-and-inline/output.html | 2 +- test/rendering/fixtures/default-block/output.html | 2 +- test/rendering/fixtures/empty-text/output.html | 2 +- test/rendering/fixtures/multiple-custom-block/output.html | 2 +- test/rendering/fixtures/multiple-custom-inline/output.html | 2 +- test/rendering/fixtures/nested-text-direction/output.html | 2 +- test/rendering/fixtures/text-direction/output.html | 2 +- 18 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/components/content.js b/src/components/content.js index 540299ac1..3558020ca 100644 --- a/src/components/content.js +++ b/src/components/content.js @@ -166,7 +166,7 @@ class Content extends React.Component { const { target } = event return ( (target.isContentEditable) && - (target === element || target.closest('[contenteditable]') == element) + (target === element || target.closest('[data-slate-content]') === element) ) } @@ -720,6 +720,7 @@ class Content extends React.Component { return (
+
diff --git a/test/rendering/fixtures/custom-block/output.html b/test/rendering/fixtures/custom-block/output.html index 77a86c71f..5d10e0b42 100644 --- a/test/rendering/fixtures/custom-block/output.html +++ b/test/rendering/fixtures/custom-block/output.html @@ -1,5 +1,5 @@ -
+
word diff --git a/test/rendering/fixtures/custom-decorator/output.html b/test/rendering/fixtures/custom-decorator/output.html index 7bb0da820..64f805971 100644 --- a/test/rendering/fixtures/custom-decorator/output.html +++ b/test/rendering/fixtures/custom-decorator/output.html @@ -1,5 +1,5 @@ -
+
o diff --git a/test/rendering/fixtures/custom-inline-void/output.html b/test/rendering/fixtures/custom-inline-void/output.html index 4d84134c1..660759090 100644 --- a/test/rendering/fixtures/custom-inline-void/output.html +++ b/test/rendering/fixtures/custom-inline-void/output.html @@ -1,5 +1,5 @@ -
+
diff --git a/test/rendering/fixtures/custom-inline/output.html b/test/rendering/fixtures/custom-inline/output.html index 073d3d3d3..54283ef34 100644 --- a/test/rendering/fixtures/custom-inline/output.html +++ b/test/rendering/fixtures/custom-inline/output.html @@ -1,5 +1,5 @@ -
+
diff --git a/test/rendering/fixtures/custom-mark-with-component/output.html b/test/rendering/fixtures/custom-mark-with-component/output.html index 5d51e1900..e35a9a2b9 100644 --- a/test/rendering/fixtures/custom-mark-with-component/output.html +++ b/test/rendering/fixtures/custom-mark-with-component/output.html @@ -1,5 +1,5 @@ -
+
one diff --git a/test/rendering/fixtures/custom-mark-with-function/output.html b/test/rendering/fixtures/custom-mark-with-function/output.html index 5d51e1900..e35a9a2b9 100644 --- a/test/rendering/fixtures/custom-mark-with-function/output.html +++ b/test/rendering/fixtures/custom-mark-with-function/output.html @@ -1,5 +1,5 @@ -
+
one diff --git a/test/rendering/fixtures/custom-mark-with-mixed/output.html b/test/rendering/fixtures/custom-mark-with-mixed/output.html index 8a6981ea4..675567bb9 100644 --- a/test/rendering/fixtures/custom-mark-with-mixed/output.html +++ b/test/rendering/fixtures/custom-mark-with-mixed/output.html @@ -1,5 +1,5 @@ -
+
one diff --git a/test/rendering/fixtures/custom-mark-with-object/output.html b/test/rendering/fixtures/custom-mark-with-object/output.html index 6c28dbfed..332dadd70 100644 --- a/test/rendering/fixtures/custom-mark-with-object/output.html +++ b/test/rendering/fixtures/custom-mark-with-object/output.html @@ -1,5 +1,5 @@ -
+
one diff --git a/test/rendering/fixtures/custom-mark-with-string/output.html b/test/rendering/fixtures/custom-mark-with-string/output.html index 37e4d0e63..f6090c858 100644 --- a/test/rendering/fixtures/custom-mark-with-string/output.html +++ b/test/rendering/fixtures/custom-mark-with-string/output.html @@ -1,5 +1,5 @@ -
+
one diff --git a/test/rendering/fixtures/default-block-and-inline/output.html b/test/rendering/fixtures/default-block-and-inline/output.html index 9546bc3eb..012b257b3 100644 --- a/test/rendering/fixtures/default-block-and-inline/output.html +++ b/test/rendering/fixtures/default-block-and-inline/output.html @@ -1,5 +1,5 @@ -
+
diff --git a/test/rendering/fixtures/default-block/output.html b/test/rendering/fixtures/default-block/output.html index c5269b86e..433add87c 100644 --- a/test/rendering/fixtures/default-block/output.html +++ b/test/rendering/fixtures/default-block/output.html @@ -1,5 +1,5 @@ -
+
word diff --git a/test/rendering/fixtures/empty-text/output.html b/test/rendering/fixtures/empty-text/output.html index 0de2891ea..3833e323b 100644 --- a/test/rendering/fixtures/empty-text/output.html +++ b/test/rendering/fixtures/empty-text/output.html @@ -1,5 +1,5 @@ -
+

diff --git a/test/rendering/fixtures/multiple-custom-block/output.html b/test/rendering/fixtures/multiple-custom-block/output.html index 6efc7c355..5f77624a9 100644 --- a/test/rendering/fixtures/multiple-custom-block/output.html +++ b/test/rendering/fixtures/multiple-custom-block/output.html @@ -1,5 +1,5 @@ -
+
word diff --git a/test/rendering/fixtures/multiple-custom-inline/output.html b/test/rendering/fixtures/multiple-custom-inline/output.html index e63aec31b..3ad4aa6c6 100644 --- a/test/rendering/fixtures/multiple-custom-inline/output.html +++ b/test/rendering/fixtures/multiple-custom-inline/output.html @@ -1,5 +1,5 @@ -
+
diff --git a/test/rendering/fixtures/nested-text-direction/output.html b/test/rendering/fixtures/nested-text-direction/output.html index f946126b8..0a06da98b 100644 --- a/test/rendering/fixtures/nested-text-direction/output.html +++ b/test/rendering/fixtures/nested-text-direction/output.html @@ -1,5 +1,5 @@ -
+
diff --git a/test/rendering/fixtures/text-direction/output.html b/test/rendering/fixtures/text-direction/output.html index a325e6a3e..6d9b387d3 100644 --- a/test/rendering/fixtures/text-direction/output.html +++ b/test/rendering/fixtures/text-direction/output.html @@ -1,5 +1,5 @@ -
+
Hello World