diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index 6e7da24da..d5a77d9dd 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -71,6 +71,9 @@ function FramedEngine(options) { if(this.widget.editRows) { this.domNode.setAttribute("rows",this.widget.editRows); } + if(this.widget.editDir) { + this.domNode.setAttribute("dir",this.widget.editDir); + } if(this.widget.editTabIndex) { this.iframeNode.setAttribute("tabindex",this.widget.editTabIndex); } @@ -97,6 +100,7 @@ FramedEngine.prototype.copyStyles = function() { this.domNode.style.width = "100%"; this.domNode.style.margin = "0"; this.domNode.style["background-color"] = this.widget.wiki.extractTiddlerDataItem(this.widget.wiki.getTiddlerText("$:/palette"),"tiddler-editor-background"); + this.domNode.style.direction = ""; // In Chrome setting -webkit-text-fill-color overrides the placeholder text colour this.domNode.style["-webkit-text-fill-color"] = "currentcolor"; }; diff --git a/core/modules/editor/engines/simple.js b/core/modules/editor/engines/simple.js index bb77893d7..7e4997720 100644 --- a/core/modules/editor/engines/simple.js +++ b/core/modules/editor/engines/simple.js @@ -52,6 +52,9 @@ function SimpleEngine(options) { if(this.widget.editTabIndex) { this.domNode.setAttribute("tabindex",this.widget.editTabIndex); } + if(this.widget.editDir) { + this.domNode.setAttribute("dir",this.widget.editDir); + } // Add an input event handler $tw.utils.addEventListeners(this.domNode,[ {name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"}, diff --git a/core/modules/editor/factory.js b/core/modules/editor/factory.js index 8dfc88037..a1f2bfb02 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -177,6 +177,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { this.editFocusPopup = this.getAttribute("focusPopup"); this.editFocus = this.getAttribute("focus"); this.editTabIndex = this.getAttribute("tabindex"); + this.editDir = this.getAttribute("dir"); // Get the default editor element tag and type var tag,type; if(this.editField === "text") { @@ -208,7 +209,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { EditTextWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); // Completely rerender if any of our attributes have changed - if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE]) { + if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.dir || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE]) { this.refreshSelf(); return true; } else if(changedTiddlers[this.editTitle]) { diff --git a/core/modules/widgets/edit.js b/core/modules/widgets/edit.js index 92ac0e1be..3b5130c6f 100644 --- a/core/modules/widgets/edit.js +++ b/core/modules/widgets/edit.js @@ -48,6 +48,7 @@ EditWidget.prototype.execute = function() { this.editPlaceholder = this.getAttribute("placeholder"); this.editTabIndex = this.getAttribute("tabindex"); this.editFocus = this.getAttribute("focus",""); + this.editDir = this.getAttribute("dir"); // Choose the appropriate edit widget this.editorType = this.getEditorType(); // Make the child widgets @@ -60,7 +61,8 @@ EditWidget.prototype.execute = function() { "class": {type: "string", value: this.editClass}, "placeholder": {type: "string", value: this.editPlaceholder}, "tabindex": {type: "string", value: this.editTabIndex}, - "focus": {type: "string", value: this.editFocus} + "focus": {type: "string", value: this.editFocus}, + dir: {type: "string", value: this.editDir} }, children: this.parseTreeNode.children }]); @@ -94,7 +96,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of EditWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); // Refresh if an attribute has changed, or the type associated with the target tiddler has changed - if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) { + if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.dir || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) { this.refreshSelf(); return true; } else { diff --git a/core/modules/widgets/reveal.js b/core/modules/widgets/reveal.js index ebbf490b2..03bbb5601 100755 --- a/core/modules/widgets/reveal.js +++ b/core/modules/widgets/reveal.js @@ -41,6 +41,9 @@ RevealWidget.prototype.render = function(parent,nextSibling) { if(this.style) { domNode.setAttribute("style",this.style); } + if(this.direction) { + domNode.setAttribute("dir",this.direction); + } parent.insertBefore(domNode,nextSibling); this.renderChildren(domNode,null); if(!domNode.isTiddlyWikiFakeDom && this.type === "popup" && this.isOpen) { @@ -107,6 +110,7 @@ RevealWidget.prototype.execute = function() { this["default"] = this.getAttribute("default",""); this.animate = this.getAttribute("animate","no"); this.retain = this.getAttribute("retain","no"); + this.direction = this.getAttribute("dir"); this.openAnimation = this.animate === "no" ? undefined : "open"; this.closeAnimation = this.animate === "no" ? undefined : "close"; // Compute the title of the state tiddler and read it @@ -199,7 +203,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of */ RevealWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); - if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex) { + if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex || changedAttributes.direction) { this.refreshSelf(); return true; } else { diff --git a/plugins/tiddlywiki/codemirror/engine.js b/plugins/tiddlywiki/codemirror/engine.js index 630482d7d..f2ae88499 100755 --- a/plugins/tiddlywiki/codemirror/engine.js +++ b/plugins/tiddlywiki/codemirror/engine.js @@ -109,6 +109,9 @@ function CodeMirrorEngine(options) { if(this.widget.editTabIndex) { config["tabindex"] = this.widget.editTabIndex; } + if(this.widget.editDir) { + config.direction = this.widget.editDir; + } // Create the CodeMirror instance this.cm = window.CodeMirror(function(cmDomNode) { // Note that this is a synchronous callback that is called before the constructor returns