Skip to content

Commit b17c344

Browse files
committed
Fix some more tabs/spaces in bidi work
1 parent 6ad71bd commit b17c344

6 files changed

Lines changed: 27 additions & 43 deletions

File tree

editor/js/text/bidi.js

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,29 @@ RED.text.bidi = (function() {
2121
PDF = "\u202C";
2222

2323
function isRTLValue(stringValue) {
24-
for (var ch in stringValue) {
25-
if (isBidiChar(stringValue.charCodeAt(ch))) {
24+
var length = stringValue.length;
25+
for (var i=0;i<length;i++) {
26+
if (isBidiChar(stringValue.charCodeAt(i))) {
2627
return true;
2728
}
28-
else if(isLatinChar(stringValue.charCodeAt(ch))) {
29+
else if(isLatinChar(stringValue.charCodeAt(i))) {
2930
return false;
3031
}
3132
}
3233
return false;
3334
}
3435

3536
function isBidiChar(c) {
36-
if (c >= 0x05d0 && c <= 0x05ff) {
37-
return true;
38-
}
39-
else if (c >= 0x0600 && c <= 0x065f) {
40-
return true;
41-
}
42-
else if (c >= 0x066a && c <= 0x06ef) {
43-
return true;
44-
}
45-
else if (c >= 0x06fa && c <= 0x07ff) {
46-
return true;
47-
}
48-
else if (c >= 0xfb1d && c <= 0xfdff) {
49-
return true;
50-
}
51-
else if (c >= 0xfe70 && c <= 0xfefc) {
52-
return true;
53-
}
54-
else {
55-
return false;
56-
}
37+
return (c >= 0x05d0 && c <= 0x05ff)||
38+
(c >= 0x0600 && c <= 0x065f)||
39+
(c >= 0x066a && c <= 0x06ef)||
40+
(c >= 0x06fa && c <= 0x07ff)||
41+
(c >= 0xfb1d && c <= 0xfdff)||
42+
(c >= 0xfe70 && c <= 0xfefc);
5743
}
5844

5945
function isLatinChar(c){
60-
if((c > 64 && c < 91)||(c > 96 && c < 123)) {
61-
return true;
62-
}
63-
else {
64-
return false;
65-
}
46+
return (c > 64 && c < 91)||(c > 96 && c < 123)
6647
}
6748

6849
/**
@@ -87,15 +68,17 @@ RED.text.bidi = (function() {
8768
}
8869

8970
/**
90-
* Listens to keyup, paste and cut events of a given input field. Upon one of these events the text direction is computed again
71+
* Listens to keyup, paste and cut events of a given input field. Upon one
72+
* of these events the text direction is computed again
9173
* @param input - the input field
9274
*/
9375
function initInputEvents(input) {
9476
input.on("keyup",onInputChange).on("paste",onInputChange).on("cut",onInputChange);
9577
}
9678

9779
/**
98-
* Enforces the text direction of a given string by adding UCC (Unicode Control Characters)
80+
* Enforces the text direction of a given string by adding
81+
* UCC (Unicode Control Characters)
9982
* @param value - the string
10083
*/
10184
function enforceTextDirectionWithUCC(value) {
@@ -112,7 +95,8 @@ RED.text.bidi = (function() {
11295
}
11396

11497
/**
115-
* Enforces the text direction for all the spans with style bidiAware under workpsace or sidebar div
98+
* Enforces the text direction for all the spans with style bidiAware under
99+
* workspace or sidebar div
116100
*/
117101
function enforceTextDirectionOnPage() {
118102
$("#workspace").find('span.bidiAware').each(function() {

editor/js/text/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ RED.text.format = (function() {
475475
// handler: main handler (default - dbidi/stt/handlers/common)
476476
// guiDir: GUI direction (default - "ltr")
477477
// dir: main stt direction (default - guiDir)
478-
// subDir: direction of subsegments
478+
// subDir: direction of subsegments
479479
// points: array of delimiters (default - [])
480480
// bounds: array of definitions of bounds in which handler works
481481
// subs: object defines special handling for some substring if found

editor/js/ui/editor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ RED.editor = (function() {
295295
* @param node - the node being edited
296296
* @param property - the name of the field
297297
* @param prefix - the prefix to use in the input element ids (node-input|node-config-input)
298-
* @param definition - the definition of the field
298+
* @param definition - the definition of the field
299299
*/
300300
function preparePropertyEditor(node,property,prefix,definition) {
301301
var input = $("#"+prefix+"-"+property);
@@ -1298,7 +1298,7 @@ RED.editor = (function() {
12981298
});
12991299

13001300
$("#subflow-input-name").val(subflow.name).attr("dir", RED.text.bidi.resolveBaseTextDir(subflow.name));
1301-
RED.text.bidi.initInputEvents($("#subflow-input-name"));
1301+
RED.text.bidi.initInputEvents($("#subflow-input-name"));
13021302
subflowEditor.getSession().setValue(subflow.info||"",-1);
13031303
var userCount = 0;
13041304
var subflowType = "subflow:"+editing_node.id;

editor/js/ui/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ RED.tabs = (function() {
127127
$('<img src="'+tab.icon+'" class="red-ui-tab-icon"/>').appendTo(link);
128128
}
129129
var span = $('<span/>',{class:"bidiAware"}).text(tab.label).appendTo(link);
130-
span.attr('dir', RED.text.bidi.resolveBaseTextDir(tab.label));
130+
span.attr('dir', RED.text.bidi.resolveBaseTextDir(tab.label));
131131

132132
link.on("click",onTabClick);
133133
link.on("dblclick",onTabDblClick);

editor/js/ui/view.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ RED.view = (function() {
17921792
l = d._def.label;
17931793
try {
17941794
l = (typeof l === "function" ? l.call(d) : l)||"";
1795-
l = RED.text.bidi.enforceTextDirectionWithUCC(l);
1795+
l = RED.text.bidi.enforceTextDirectionWithUCC(l);
17961796
} catch(err) {
17971797
console.log("Definition error: "+d.type+".label",err);
17981798
l = d.type;
@@ -2155,8 +2155,8 @@ RED.view = (function() {
21552155
).classed("link_selected", false);
21562156
}
21572157

2158-
RED.text.bidi.enforceTextDirectionOnPage();
2159-
2158+
RED.text.bidi.enforceTextDirectionOnPage();
2159+
21602160
if (d3.event) {
21612161
d3.event.preventDefault();
21622162
}
@@ -2360,11 +2360,11 @@ RED.view = (function() {
23602360
snapGrid = state;
23612361
redraw();
23622362
},
2363-
toggleTextDir: function(value) {
2363+
toggleTextDir: function(value) {
23642364
RED.text.bidi.setTextDirection(value);
23652365
RED.nodes.eachNode(function(n) { n.dirty = true;});
23662366
redraw();
2367-
RED.palette.refresh();
2367+
RED.palette.refresh();
23682368
},
23692369
scale: function() {
23702370
return scaleFactor;

editor/js/ui/workspaces.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ RED.workspaces = (function() {
110110
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
111111
dialogForm.submit(function(e) { e.preventDefault();});
112112
$("#node-input-name").val(workspace.label).attr("dir", RED.text.bidi.resolveBaseTextDir(workspace.label));
113-
RED.text.bidi.initInputEvents($("#node-input-name"));
113+
RED.text.bidi.initInputEvents($("#node-input-name"));
114114
dialogForm.i18n();
115115
},
116116
close: function() {

0 commit comments

Comments
 (0)