From 17d676b639dc7ba99a7f57aaf0c4a3f9a929e950 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Fri, 29 Jul 2016 12:05:01 -0700 Subject: [PATCH] refactor rtl support, add rtl example --- examples/index.css | 8 ++ examples/index.js | 3 + examples/rich-text/state.json | 20 ----- examples/rtl/Readme.md | 8 ++ examples/rtl/index.js | 79 +++++++++++++++++++ examples/rtl/state.json | 54 +++++++++++++ lib/components/node.js | 15 ++-- lib/models/block.js | 11 --- lib/models/node.js | 16 ++++ lib/utils/bidi.js | 30 ------- .../fixtures/nested-text-direction/index.js | 4 + .../fixtures/nested-text-direction/input.yaml | 17 ++++ .../nested-text-direction/output.html | 14 ++++ 13 files changed, 212 insertions(+), 67 deletions(-) create mode 100644 examples/rtl/Readme.md create mode 100644 examples/rtl/index.js create mode 100644 examples/rtl/state.json delete mode 100644 lib/utils/bidi.js create mode 100644 test/rendering/fixtures/nested-text-direction/index.js create mode 100644 test/rendering/fixtures/nested-text-direction/input.yaml create mode 100644 test/rendering/fixtures/nested-text-direction/output.html diff --git a/examples/index.css b/examples/index.css index ce344a0a6..336f41591 100644 --- a/examples/index.css +++ b/examples/index.css @@ -29,11 +29,19 @@ img { blockquote { border-left: 2px solid #ddd; margin-left: 0; + margin-right: 0; padding-left: 10px; color: #aaa; font-style: italic; } +blockquote[dir="rtl"] { + border-left: none; + padding-left: 0; + padding-right: 10px; + border-right: 2px solid #ddd; +} + table { border-collapse: collapse; } diff --git a/examples/index.js b/examples/index.js index c8bfd5f20..d894e8666 100644 --- a/examples/index.js +++ b/examples/index.js @@ -18,6 +18,7 @@ import PlainText from './plain-text' import Plugins from './plugins' import ReadOnly from './read-only' import RichText from './rich-text' +import RTL from './rtl' import Tables from './tables' import DevPerformancePlain from './development/performance-plain' import DevPerformanceRich from './development/performance-rich' @@ -73,6 +74,7 @@ class App extends React.Component { {this.renderTab('Code Highlighting', 'code-highlighting')} {this.renderTab('Paste HTML', 'paste-html')} {this.renderTab('Read-only', 'read-only')} + {this.renderTab('RTL', 'rtl')} {this.renderTab('Plugins', 'plugins')} ) @@ -128,6 +130,7 @@ const router = ( + diff --git a/examples/rich-text/state.json b/examples/rich-text/state.json index 2ce81ca27..8e7372be9 100644 --- a/examples/rich-text/state.json +++ b/examples/rich-text/state.json @@ -81,26 +81,6 @@ } ] }, - { - "kind": "block", - "type": "paragraph", - "nodes": [ - { - "kind": "text", - "text": "It support both LTR (English) and RTL (Arabic, Hebrew) edition:" - } - ] - }, - { - "kind": "block", - "type": "paragraph", - "nodes": [ - { - "kind": "text", - "text": "مرحبا بالعالم" - } - ] - }, { "kind": "block", "type": "paragraph", diff --git a/examples/rtl/Readme.md b/examples/rtl/Readme.md new file mode 100644 index 000000000..20aee1528 --- /dev/null +++ b/examples/rtl/Readme.md @@ -0,0 +1,8 @@ + +# Plain Text Example + +![](../../docs/images/plain-text-example.png) + +This is the most basic Slate example. It's basically a glorified `