1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix some more tabs/spaces in bidi work

This commit is contained in:
Nick O'Leary 2016-08-26 00:28:22 +01:00
parent 6ad71bd222
commit b17c34402d
6 changed files with 27 additions and 43 deletions

View File

@ -21,11 +21,12 @@ RED.text.bidi = (function() {
PDF = "\u202C"; PDF = "\u202C";
function isRTLValue(stringValue) { function isRTLValue(stringValue) {
for (var ch in stringValue) { var length = stringValue.length;
if (isBidiChar(stringValue.charCodeAt(ch))) { for (var i=0;i<length;i++) {
if (isBidiChar(stringValue.charCodeAt(i))) {
return true; return true;
} }
else if(isLatinChar(stringValue.charCodeAt(ch))) { else if(isLatinChar(stringValue.charCodeAt(i))) {
return false; return false;
} }
} }
@ -33,36 +34,16 @@ RED.text.bidi = (function() {
} }
function isBidiChar(c) { function isBidiChar(c) {
if (c >= 0x05d0 && c <= 0x05ff) { return (c >= 0x05d0 && c <= 0x05ff)||
return true; (c >= 0x0600 && c <= 0x065f)||
} (c >= 0x066a && c <= 0x06ef)||
else if (c >= 0x0600 && c <= 0x065f) { (c >= 0x06fa && c <= 0x07ff)||
return true; (c >= 0xfb1d && c <= 0xfdff)||
} (c >= 0xfe70 && c <= 0xfefc);
else if (c >= 0x066a && c <= 0x06ef) {
return true;
}
else if (c >= 0x06fa && c <= 0x07ff) {
return true;
}
else if (c >= 0xfb1d && c <= 0xfdff) {
return true;
}
else if (c >= 0xfe70 && c <= 0xfefc) {
return true;
}
else {
return false;
}
} }
function isLatinChar(c){ function isLatinChar(c){
if((c > 64 && c < 91)||(c > 96 && c < 123)) { return (c > 64 && c < 91)||(c > 96 && c < 123)
return true;
}
else {
return false;
}
} }
/** /**
@ -87,7 +68,8 @@ RED.text.bidi = (function() {
} }
/** /**
* Listens to keyup, paste and cut events of a given input field. Upon one of these events the text direction is computed again * Listens to keyup, paste and cut events of a given input field. Upon one
* of these events the text direction is computed again
* @param input - the input field * @param input - the input field
*/ */
function initInputEvents(input) { function initInputEvents(input) {
@ -95,7 +77,8 @@ RED.text.bidi = (function() {
} }
/** /**
* Enforces the text direction of a given string by adding UCC (Unicode Control Characters) * Enforces the text direction of a given string by adding
* UCC (Unicode Control Characters)
* @param value - the string * @param value - the string
*/ */
function enforceTextDirectionWithUCC(value) { function enforceTextDirectionWithUCC(value) {
@ -112,7 +95,8 @@ RED.text.bidi = (function() {
} }
/** /**
* Enforces the text direction for all the spans with style bidiAware under workpsace or sidebar div * Enforces the text direction for all the spans with style bidiAware under
* workspace or sidebar div
*/ */
function enforceTextDirectionOnPage() { function enforceTextDirectionOnPage() {
$("#workspace").find('span.bidiAware').each(function() { $("#workspace").find('span.bidiAware').each(function() {

View File

@ -475,7 +475,7 @@ RED.text.format = (function() {
// handler: main handler (default - dbidi/stt/handlers/common) // handler: main handler (default - dbidi/stt/handlers/common)
// guiDir: GUI direction (default - "ltr") // guiDir: GUI direction (default - "ltr")
// dir: main stt direction (default - guiDir) // dir: main stt direction (default - guiDir)
// subDir: direction of subsegments // subDir: direction of subsegments
// points: array of delimiters (default - []) // points: array of delimiters (default - [])
// bounds: array of definitions of bounds in which handler works // bounds: array of definitions of bounds in which handler works
// subs: object defines special handling for some substring if found // subs: object defines special handling for some substring if found

View File

@ -295,7 +295,7 @@ RED.editor = (function() {
* @param node - the node being edited * @param node - the node being edited
* @param property - the name of the field * @param property - the name of the field
* @param prefix - the prefix to use in the input element ids (node-input|node-config-input) * @param prefix - the prefix to use in the input element ids (node-input|node-config-input)
* @param definition - the definition of the field * @param definition - the definition of the field
*/ */
function preparePropertyEditor(node,property,prefix,definition) { function preparePropertyEditor(node,property,prefix,definition) {
var input = $("#"+prefix+"-"+property); var input = $("#"+prefix+"-"+property);
@ -1298,7 +1298,7 @@ RED.editor = (function() {
}); });
$("#subflow-input-name").val(subflow.name).attr("dir", RED.text.bidi.resolveBaseTextDir(subflow.name)); $("#subflow-input-name").val(subflow.name).attr("dir", RED.text.bidi.resolveBaseTextDir(subflow.name));
RED.text.bidi.initInputEvents($("#subflow-input-name")); RED.text.bidi.initInputEvents($("#subflow-input-name"));
subflowEditor.getSession().setValue(subflow.info||"",-1); subflowEditor.getSession().setValue(subflow.info||"",-1);
var userCount = 0; var userCount = 0;
var subflowType = "subflow:"+editing_node.id; var subflowType = "subflow:"+editing_node.id;

View File

@ -1792,7 +1792,7 @@ RED.view = (function() {
l = d._def.label; l = d._def.label;
try { try {
l = (typeof l === "function" ? l.call(d) : l)||""; l = (typeof l === "function" ? l.call(d) : l)||"";
l = RED.text.bidi.enforceTextDirectionWithUCC(l); l = RED.text.bidi.enforceTextDirectionWithUCC(l);
} catch(err) { } catch(err) {
console.log("Definition error: "+d.type+".label",err); console.log("Definition error: "+d.type+".label",err);
l = d.type; l = d.type;
@ -2155,7 +2155,7 @@ RED.view = (function() {
).classed("link_selected", false); ).classed("link_selected", false);
} }
RED.text.bidi.enforceTextDirectionOnPage(); RED.text.bidi.enforceTextDirectionOnPage();
if (d3.event) { if (d3.event) {
d3.event.preventDefault(); d3.event.preventDefault();
@ -2360,7 +2360,7 @@ RED.view = (function() {
snapGrid = state; snapGrid = state;
redraw(); redraw();
}, },
toggleTextDir: function(value) { toggleTextDir: function(value) {
RED.text.bidi.setTextDirection(value); RED.text.bidi.setTextDirection(value);
RED.nodes.eachNode(function(n) { n.dirty = true;}); RED.nodes.eachNode(function(n) { n.dirty = true;});
redraw(); redraw();

View File

@ -110,7 +110,7 @@ RED.workspaces = (function() {
$('<input type="text" style="display: none;" />').prependTo(dialogForm); $('<input type="text" style="display: none;" />').prependTo(dialogForm);
dialogForm.submit(function(e) { e.preventDefault();}); dialogForm.submit(function(e) { e.preventDefault();});
$("#node-input-name").val(workspace.label).attr("dir", RED.text.bidi.resolveBaseTextDir(workspace.label)); $("#node-input-name").val(workspace.label).attr("dir", RED.text.bidi.resolveBaseTextDir(workspace.label));
RED.text.bidi.initInputEvents($("#node-input-name")); RED.text.bidi.initInputEvents($("#node-input-name"));
dialogForm.i18n(); dialogForm.i18n();
}, },
close: function() { close: function() {