diff --git a/editor/js/text/bidi.js b/editor/js/text/bidi.js index 1835f5111..af9620185 100644 --- a/editor/js/text/bidi.js +++ b/editor/js/text/bidi.js @@ -15,7 +15,9 @@ **/ RED.text = {}; RED.text.bidi = (function() { - var textDir = ""; + var textDir = ""; + var textDirPref = "auto"; + var bidiEnabled = false; var LRE = "\u202A", RLE = "\u202B", PDF = "\u202C"; @@ -110,8 +112,8 @@ RED.text.bidi = (function() { } /** - * Sets the text direction preference - * @param dir - the text direction preference + * Sets the text direction + * @param dir - the actual text direction */ function setTextDirection(dir) { textDir = dir; @@ -120,9 +122,44 @@ RED.text.bidi = (function() { RED.palette.refresh(); enforceTextDirectionOnPage(); } - + + /** + * Gets the bidi enabled preference + */ + function getBidiEnabled() { + return bidiEnabled; + } + + /** + * Sets the bidi enabled preference + * @param state - the bidi enabled preference + */ + function setBidiEnabled(state) { + bidiEnabled = state; + setTextDirection((state ? textDirPref : "")); + } + + /** + * Gets the text direction preference + */ + function getTextDirPref() { + return textDirPref; + } + + /** + * Sets the text direction preference + * @param dirPref - text direction preference + */ + function setTextDirPref(dirPref) { + textDirPref = dirPref; + setTextDirection(textDirPref); + } + return { - setTextDirection: setTextDirection, + setBidiEnabled: setBidiEnabled, + setTextDirPref: setTextDirPref, + getBidiEnabled: getBidiEnabled, + getTextDirPref: getTextDirPref, enforceTextDirectionWithUCC: enforceTextDirectionWithUCC, resolveBaseTextDir: resolveBaseTextDir, prepareInput: prepareInput diff --git a/editor/js/ui/userSettings.js b/editor/js/ui/userSettings.js index 39d3c5fd8..c454d517b 100644 --- a/editor/js/ui/userSettings.js +++ b/editor/js/ui/userSettings.js @@ -142,8 +142,34 @@ RED.userSettings = (function() { } }); }) + addBidiPreferences(pane); return pane; } + + function addBidiPreferences(pane) { + $('

').text(RED._("menu.label.bidi")).appendTo(pane); + var row; + + // Bidi enabled toggle + row = $('
').appendTo(pane); + var input = $('').appendTo(row).find("input"); + input.prop('checked',RED.text.bidi.getBidiEnabled()); + + // Text Direction combo + row = $('
').appendTo(pane); + $('').appendTo(row); + var select = $('').appendTo(row); + select.val(RED.text.bidi.getTextDirPref()); + select.prop('disabled', !RED.text.bidi.getBidiEnabled()); + + input.change(function() { + RED.text.bidi.setBidiEnabled(input.prop('checked')); + select.prop('disabled', !RED.text.bidi.getBidiEnabled()); + }); + select.change(function() { + RED.text.bidi.setTextDirPref(select.val()); + }); + } function setSelected(id, value) { var opt = allSettings[id]; diff --git a/red/api/locales/en-US/editor.json b/red/api/locales/en-US/editor.json index 4fd50f177..05d994db8 100644 --- a/red/api/locales/en-US/editor.json +++ b/red/api/locales/en-US/editor.json @@ -67,7 +67,9 @@ "editPalette":"Manage palette", "other": "Other", "showTips": "Show tips", - "help": "Node-RED website" + "help": "Node-RED website", + "bidi": "Bidi", + "bidiSupport": "Enable Bidi support" } }, "user": {