mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Move bidi code under RED.text
This commit is contained in:
parent
ccc08be0ee
commit
6ad71bd222
@ -104,8 +104,8 @@ module.exports = function(grunt) {
|
||||
"editor/js/settings.js",
|
||||
"editor/js/user.js",
|
||||
"editor/js/comms.js",
|
||||
"editor/js/bidi.js",
|
||||
"editor/js/format.js",
|
||||
"editor/js/text/bidi.js",
|
||||
"editor/js/text/format.js",
|
||||
"editor/js/ui/state.js",
|
||||
"editor/js/nodes.js",
|
||||
"editor/js/history.js",
|
||||
|
1329
editor/js/format.js
1329
editor/js/format.js
File diff suppressed because it is too large
Load Diff
@ -236,7 +236,7 @@ RED.history = (function() {
|
||||
});
|
||||
|
||||
if (ev.node.type === 'subflow') {
|
||||
$("#menu-item-workspace-menu-"+ev.node.id.replace(".","-")).text(RED.bidi.enforceTextDirectionWithUCC(ev.node.name));
|
||||
$("#menu-item-workspace-menu-"+ev.node.id.replace(".","-")).text(RED.text.bidi.enforceTextDirectionWithUCC(ev.node.name));
|
||||
}
|
||||
} else {
|
||||
RED.editor.updateNodeProperties(ev.node);
|
||||
|
@ -176,13 +176,14 @@ var RED = (function() {
|
||||
{id:"menu-item-view-snap-grid",label:RED._("menu.label.view.snapGrid"),toggle:true,onselect:RED.view.toggleSnapGrid},
|
||||
{id:"menu-item-status",label:RED._("menu.label.displayStatus"),toggle:true,onselect:toggleStatus, selected: true},
|
||||
null,
|
||||
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:RED.sidebar.toggleSidebar, selected: true},
|
||||
{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.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")}}}
|
||||
]},
|
||||
null,
|
||||
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:RED.sidebar.toggleSidebar, selected: true}
|
||||
]},
|
||||
null,
|
||||
{id:"menu-item-import",label:RED._("menu.label.import"),options:[
|
||||
|
@ -13,13 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
RED.bidi = (function() {
|
||||
RED.text = {};
|
||||
RED.text.bidi = (function() {
|
||||
var textDir = "";
|
||||
var LRE = "\u202A",
|
||||
RLE = "\u202B",
|
||||
PDF = "\u202C";
|
||||
|
||||
|
||||
function isRTLValue(stringValue) {
|
||||
for (var ch in stringValue) {
|
||||
if (isBidiChar(stringValue.charCodeAt(ch))) {
|
||||
@ -27,7 +27,7 @@ RED.bidi = (function() {
|
||||
}
|
||||
else if(isLatinChar(stringValue.charCodeAt(ch))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -60,14 +60,14 @@ RED.bidi = (function() {
|
||||
if((c > 64 && c < 91)||(c > 96 && c < 123)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Determines the text direction of a given string.
|
||||
* @param value - the string
|
||||
* @param value - the string
|
||||
*/
|
||||
function resolveBaseTextDir(value) {
|
||||
if (textDir == "auto") {
|
||||
@ -76,27 +76,27 @@ RED.bidi = (function() {
|
||||
} else {
|
||||
return "ltr";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return textDir;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onInputChange() {
|
||||
$(this).attr("dir", resolveBaseTextDir($(this).val()));
|
||||
$(this).attr("dir", resolveBaseTextDir($(this).val()));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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) {
|
||||
input.on("keyup",onInputChange).on("paste",onInputChange).on("cut",onInputChange);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
if (value) {
|
||||
@ -110,27 +110,27 @@ RED.bidi = (function() {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Enforces the text direction for all the spans with style bidiAware under workpsace or sidebar div
|
||||
*/
|
||||
function enforceTextDirectionOnPage() {
|
||||
$("#workspace").find('span.bidiAware').each(function() {
|
||||
function enforceTextDirectionOnPage() {
|
||||
$("#workspace").find('span.bidiAware').each(function() {
|
||||
$(this).attr("dir", resolveBaseTextDir($(this).html()));
|
||||
});
|
||||
$("#sidebar").find('span.bidiAware').each(function() {
|
||||
});
|
||||
$("#sidebar").find('span.bidiAware').each(function() {
|
||||
$(this).attr("dir", resolveBaseTextDir($(this).text()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Sets the text direction preference
|
||||
* @param dir - the text direction preference
|
||||
* @param dir - the text direction preference
|
||||
*/
|
||||
function setTextDirection(dir) {
|
||||
textDir = dir;
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
setTextDirection: setTextDirection,
|
||||
enforceTextDirectionOnPage: enforceTextDirectionOnPage,
|
1329
editor/js/text/format.js
Normal file
1329
editor/js/text/format.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -301,19 +301,19 @@ RED.editor = (function() {
|
||||
var input = $("#"+prefix+"-"+property);
|
||||
if (input.attr('type') === "checkbox") {
|
||||
input.prop('checked',node[property]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var val = node[property];
|
||||
if (val == null) {
|
||||
val = "";
|
||||
}
|
||||
if ("format" in definition[property] && definition[property].format !== "" && input[0].nodeName === "DIV") {
|
||||
input.html(RED.format.getHtml(val, definition[property].format, {}, false, "en"));
|
||||
RED.format.attach(input[0], definition[property].format, {}, false, "en");
|
||||
if (definition[property].hasOwnProperty("format") && definition[property].format !== "" && input[0].nodeName === "DIV") {
|
||||
input.html(RED.text.format.getHtml(val, definition[property].format, {}, false, "en"));
|
||||
RED.text.format.attach(input[0], definition[property].format, {}, false, "en");
|
||||
} else {
|
||||
input.val(val).attr("dir", RED.bidi.resolveBaseTextDir(val));
|
||||
RED.bidi.initInputEvents(input);
|
||||
}
|
||||
input.val(val).attr("dir", RED.text.bidi.resolveBaseTextDir(val));
|
||||
RED.text.bidi.initInputEvents(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1205,7 +1205,7 @@ RED.editor = (function() {
|
||||
changes['name'] = editing_node.name;
|
||||
editing_node.name = newName;
|
||||
changed = true;
|
||||
$("#menu-item-workspace-menu-"+editing_node.id.replace(".","-")).text(RED.bidi.enforceTextDirectionWithUCC(newName));
|
||||
$("#menu-item-workspace-menu-"+editing_node.id.replace(".","-")).text(RED.text.bidi.enforceTextDirectionWithUCC(newName));
|
||||
}
|
||||
|
||||
var newDescription = subflowEditor.getValue();
|
||||
@ -1297,8 +1297,8 @@ RED.editor = (function() {
|
||||
value: ""
|
||||
});
|
||||
|
||||
$("#subflow-input-name").val(subflow.name).attr("dir", RED.bidi.resolveBaseTextDir(subflow.name));
|
||||
RED.bidi.initInputEvents($("#subflow-input-name"));
|
||||
$("#subflow-input-name").val(subflow.name).attr("dir", RED.text.bidi.resolveBaseTextDir(subflow.name));
|
||||
RED.text.bidi.initInputEvents($("#subflow-input-name"));
|
||||
subflowEditor.getSession().setValue(subflow.info||"",-1);
|
||||
var userCount = 0;
|
||||
var subflowType = "subflow:"+editing_node.id;
|
||||
|
@ -91,15 +91,15 @@ RED.palette = (function() {
|
||||
el.css({height:multiLineNodeHeight+"px"});
|
||||
|
||||
var labelElement = el.find(".palette_label");
|
||||
labelElement.html(lines).attr('dir', RED.bidi.resolveBaseTextDir(lines));
|
||||
labelElement.html(lines).attr('dir', RED.text.bidi.resolveBaseTextDir(lines));
|
||||
|
||||
el.find(".palette_port").css({top:(multiLineNodeHeight/2-5)+"px"});
|
||||
|
||||
var popOverContent;
|
||||
try {
|
||||
var l = "<p><b>"+RED.bidi.enforceTextDirectionWithUCC(label)+"</b></p>";
|
||||
var l = "<p><b>"+RED.text.bidi.enforceTextDirectionWithUCC(label)+"</b></p>";
|
||||
if (label != type) {
|
||||
l = "<p><b>"+RED.bidi.enforceTextDirectionWithUCC(label)+"</b><br/><i>"+type+"</i></p>";
|
||||
l = "<p><b>"+RED.text.bidi.enforceTextDirectionWithUCC(label)+"</b><br/><i>"+type+"</i></p>";
|
||||
}
|
||||
popOverContent = $(l+(info?info:$("script[data-help-name|='"+type+"']").html()||"<p>"+RED._("palette.noInfo")+"</p>").trim())
|
||||
.filter(function(n) {
|
||||
|
@ -70,7 +70,7 @@ RED.sidebar.info = (function() {
|
||||
var table = '<table class="node-info"><tbody>';
|
||||
table += '<tr class="blank"><td colspan="2">'+RED._("sidebar.info.node")+'</td></tr>';
|
||||
if (node.type != "subflow" && node.name) {
|
||||
table += '<tr><td>'+RED._("common.label.name")+'</td><td> <span class="bidiAware" dir="'+RED.bidi.resolveBaseTextDir(node.name)+'">'+node.name+'</span></td></tr>';
|
||||
table += '<tr><td>'+RED._("common.label.name")+'</td><td> <span class="bidiAware" dir="'+RED.text.bidi.resolveBaseTextDir(node.name)+'">'+node.name+'</span></td></tr>';
|
||||
}
|
||||
table += "<tr><td>"+RED._("sidebar.info.type")+"</td><td> "+node.type+"</td></tr>";
|
||||
table += "<tr><td>"+RED._("sidebar.info.id")+"</td><td> "+node.id+"</td></tr>";
|
||||
@ -93,7 +93,7 @@ RED.sidebar.info = (function() {
|
||||
userCount++;
|
||||
}
|
||||
});
|
||||
table += '<tr><td>'+RED._("common.label.name")+'</td><td><span class="bidiAware" dir=\"'+RED.bidi.resolveBaseTextDir(subflowNode.name)+'">'+subflowNode.name+'</span></td></tr>';
|
||||
table += '<tr><td>'+RED._("common.label.name")+'</td><td><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(subflowNode.name)+'">'+subflowNode.name+'</span></td></tr>';
|
||||
table += "<tr><td>"+RED._("sidebar.info.instances")+"</td><td>"+userCount+"</td></tr>";
|
||||
}
|
||||
|
||||
@ -140,14 +140,14 @@ RED.sidebar.info = (function() {
|
||||
table += "</tbody></table><hr/>";
|
||||
if (!subflowNode && node.type != "comment") {
|
||||
var helpText = $("script[data-help-name|='"+node.type+"']").html()||"";
|
||||
table += '<div class="node-help"><span class="bidiAware" dir=\"'+RED.bidi.resolveBaseTextDir(helpText)+'">'+helpText+'</span></div>';
|
||||
table += '<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(helpText)+'">'+helpText+'</span></div>';
|
||||
}
|
||||
if (subflowNode) {
|
||||
table += '<div class="node-help"><span class="bidiAware" dir=\"'+RED.bidi.resolveBaseTextDir(subflowNode.info||"")+'">'+marked(subflowNode.info||"")+'</span></div>';
|
||||
table += '<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(subflowNode.info||"")+'">'+marked(subflowNode.info||"")+'</span></div>';
|
||||
} else if (node._def && node._def.info) {
|
||||
var info = node._def.info;
|
||||
var textInfo = (typeof info === "function" ? info.call(node) : info);
|
||||
table += '<div class="node-help"><span class="bidiAware" dir=\"'+RED.bidi.resolveBaseTextDir(textInfo)+'">'+marked(textInfo)+'</span></div>';
|
||||
table += '<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(textInfo)+'">'+marked(textInfo)+'</span></div>';
|
||||
//table += '<div class="node-help">'+(typeof info === "function" ? info.call(node) : info)+'</div>';
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ RED.tabs = (function() {
|
||||
$('<img src="'+tab.icon+'" class="red-ui-tab-icon"/>').appendTo(link);
|
||||
}
|
||||
var span = $('<span/>',{class:"bidiAware"}).text(tab.label).appendTo(link);
|
||||
span.attr('dir', RED.bidi.resolveBaseTextDir(tab.label));
|
||||
span.attr('dir', RED.text.bidi.resolveBaseTextDir(tab.label));
|
||||
|
||||
link.on("click",onTabClick);
|
||||
link.on("dblclick",onTabDblClick);
|
||||
@ -240,7 +240,7 @@ RED.tabs = (function() {
|
||||
tabs[id].label = label;
|
||||
var tab = ul.find("a[href='#"+id+"']");
|
||||
tab.attr("title",label);
|
||||
tab.find("span").text(label).attr('dir', RED.bidi.resolveBaseTextDir(label));
|
||||
tab.find("span").text(label).attr('dir', RED.text.bidi.resolveBaseTextDir(label));
|
||||
updateTabWidths();
|
||||
},
|
||||
order: function(order) {
|
||||
|
@ -1792,7 +1792,7 @@ RED.view = (function() {
|
||||
l = d._def.label;
|
||||
try {
|
||||
l = (typeof l === "function" ? l.call(d) : l)||"";
|
||||
l = RED.bidi.enforceTextDirectionWithUCC(l);
|
||||
l = RED.text.bidi.enforceTextDirectionWithUCC(l);
|
||||
} catch(err) {
|
||||
console.log("Definition error: "+d.type+".label",err);
|
||||
l = d.type;
|
||||
@ -2155,7 +2155,7 @@ RED.view = (function() {
|
||||
).classed("link_selected", false);
|
||||
}
|
||||
|
||||
RED.bidi.enforceTextDirectionOnPage();
|
||||
RED.text.bidi.enforceTextDirectionOnPage();
|
||||
|
||||
if (d3.event) {
|
||||
d3.event.preventDefault();
|
||||
@ -2361,7 +2361,7 @@ RED.view = (function() {
|
||||
redraw();
|
||||
},
|
||||
toggleTextDir: function(value) {
|
||||
RED.bidi.setTextDirection(value);
|
||||
RED.text.bidi.setTextDirection(value);
|
||||
RED.nodes.eachNode(function(n) { n.dirty = true;});
|
||||
redraw();
|
||||
RED.palette.refresh();
|
||||
|
@ -94,7 +94,7 @@ RED.workspaces = (function() {
|
||||
workspace_tabs.renameTab(workspace.id,label);
|
||||
RED.nodes.dirty(true);
|
||||
RED.sidebar.config.refresh();
|
||||
$("#menu-item-workspace-menu-"+workspace.id.replace(".","-")).text(RED.bidi.enforceTextDirectionWithUCC(label));
|
||||
$("#menu-item-workspace-menu-"+workspace.id.replace(".","-")).text(RED.text.bidi.enforceTextDirectionWithUCC(label));
|
||||
}
|
||||
RED.tray.close();
|
||||
}
|
||||
@ -109,8 +109,8 @@ RED.workspaces = (function() {
|
||||
'</div>').appendTo(dialogForm);
|
||||
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
|
||||
dialogForm.submit(function(e) { e.preventDefault();});
|
||||
$("#node-input-name").val(workspace.label).attr("dir", RED.bidi.resolveBaseTextDir(workspace.label));
|
||||
RED.bidi.initInputEvents($("#node-input-name"));
|
||||
$("#node-input-name").val(workspace.label).attr("dir", RED.text.bidi.resolveBaseTextDir(workspace.label));
|
||||
RED.text.bidi.initInputEvents($("#node-input-name"));
|
||||
dialogForm.i18n();
|
||||
},
|
||||
close: function() {
|
||||
@ -226,7 +226,7 @@ RED.workspaces = (function() {
|
||||
refresh: function() {
|
||||
RED.nodes.eachWorkspace(function(ws) {
|
||||
workspace_tabs.renameTab(ws.id,ws.label);
|
||||
$("#menu-item-workspace-menu-"+ws.id.replace(".","-")).text(RED.bidi.enforceTextDirectionWithUCC(ws.label));
|
||||
$("#menu-item-workspace-menu-"+ws.id.replace(".","-")).text(RED.text.bidi.enforceTextDirectionWithUCC(ws.label));
|
||||
|
||||
})
|
||||
RED.nodes.eachSubflow(function(sf) {
|
||||
|
Loading…
Reference in New Issue
Block a user