From c60fb3bc2538e094525ab5a2bd7bb7d3baf31bd0 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 26 Aug 2016 00:40:01 +0100 Subject: [PATCH] Move setting text direction into bidi module --- editor/js/main.js | 8 ++++---- editor/js/text/bidi.js | 5 ++++- editor/js/ui/view.js | 8 -------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/editor/js/main.js b/editor/js/main.js index 0a9a0b5ae..c6cf6c7d1 100644 --- a/editor/js/main.js +++ b/editor/js/main.js @@ -177,10 +177,10 @@ var RED = (function() { {id:"menu-item-status",label:RED._("menu.label.displayStatus"),toggle:true,onselect:toggleStatus, selected: true}, null, {id:"menu-item-bidi",label:RED._("menu.label.view.textDir"),options:[ - {id:"menu-item-bidi-default",toggle:"text-direction",label:RED._("menu.label.view.defaultDir"),selected: true, onselect:function(s) { if(s){RED.view.toggleTextDir("")}}}, - {id:"menu-item-bidi-ltr",toggle:"text-direction",label:RED._("menu.label.view.ltr"), onselect:function(s) { if(s){RED.view.toggleTextDir("ltr")}}}, - {id:"menu-item-bidi-rtl",toggle:"text-direction",label:RED._("menu.label.view.rtl"), onselect:function(s) { if(s){RED.view.toggleTextDir("rtl")}}}, - {id:"menu-item-bidi-auto",toggle:"text-direction",label:RED._("menu.label.view.auto"), onselect:function(s) { if(s){RED.view.toggleTextDir("auto")}}} + {id:"menu-item-bidi-default",toggle:"text-direction",label:RED._("menu.label.view.defaultDir"),selected: true, onselect:function(s) { if(s){RED.text.bidi.setTextDirection("")}}}, + {id:"menu-item-bidi-ltr",toggle:"text-direction",label:RED._("menu.label.view.ltr"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("ltr")}}}, + {id:"menu-item-bidi-rtl",toggle:"text-direction",label:RED._("menu.label.view.rtl"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("rtl")}}}, + {id:"menu-item-bidi-auto",toggle:"text-direction",label:RED._("menu.label.view.auto"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("auto")}}} ]}, null, {id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:RED.sidebar.toggleSidebar, selected: true} diff --git a/editor/js/text/bidi.js b/editor/js/text/bidi.js index 747b3dec6..314045c4c 100644 --- a/editor/js/text/bidi.js +++ b/editor/js/text/bidi.js @@ -113,11 +113,14 @@ RED.text.bidi = (function() { */ function setTextDirection(dir) { textDir = dir; + RED.nodes.eachNode(function(n) { n.dirty = true;}); + RED.view.redraw(); + RED.palette.refresh(); + enforceTextDirectionOnPage(); } return { setTextDirection: setTextDirection, - enforceTextDirectionOnPage: enforceTextDirectionOnPage, enforceTextDirectionWithUCC: enforceTextDirectionWithUCC, resolveBaseTextDir: resolveBaseTextDir, initInputEvents: initInputEvents diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index 54836a875..3da1f503c 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -2155,8 +2155,6 @@ RED.view = (function() { ).classed("link_selected", false); } - RED.text.bidi.enforceTextDirectionOnPage(); - if (d3.event) { d3.event.preventDefault(); } @@ -2360,12 +2358,6 @@ RED.view = (function() { snapGrid = state; redraw(); }, - toggleTextDir: function(value) { - RED.text.bidi.setTextDirection(value); - RED.nodes.eachNode(function(n) { n.dirty = true;}); - redraw(); - RED.palette.refresh(); - }, scale: function() { return scaleFactor; },