From c8777ea01244f274910892d41baf33d6d44ecba9 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 9 May 2016 10:33:12 -0600 Subject: [PATCH] Add control panel setting for disabling the new editor toolbar --- core/language/en-GB/ControlPanel.multids | 3 +++ core/modules/editor/factory.js | 12 +++++++++--- core/ui/ControlPanel/Settings/EditorToolbar.tid | 9 +++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 core/ui/ControlPanel/Settings/EditorToolbar.tid diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index 516bdaea7..5ad8eaef8 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -99,6 +99,9 @@ Settings/CamelCase/Caption: Camel Case Wiki Links Settings/CamelCase/Hint: You can globally disable automatic linking of ~CamelCase phrases. Requires reload to take effect Settings/CamelCase/Description: Enable automatic ~CamelCase linking Settings/Caption: Settings +Settings/EditorToolbar/Caption: Editor Toolbar +Settings/EditorToolbar/Hint: Enable or disable the editor toolbar: +Settings/EditorToolbar/Description: Show editor toolbar Settings/Hint: These settings let you customise the behaviour of TiddlyWiki. Settings/NavigationAddressBar/Caption: Navigation Address Bar Settings/NavigationAddressBar/Hint: Behaviour of the browser address bar when navigating to a tiddler: diff --git a/core/modules/editor/factory.js b/core/modules/editor/factory.js index 1cc189659..baad9ef94 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -16,6 +16,7 @@ var DEFAULT_MIN_TEXT_AREA_HEIGHT = "100px"; // Minimum height of textareas in pi // Configuration tiddlers var HEIGHT_MODE_TITLE = "$:/config/TextEditor/EditorHeight/Mode"; +var ENABLE_TOOLBAR_TITLE = "$:/config/TextEditor/EnableToolbar"; var Widget = require("$:/core/modules/widgets/widget.js").widget; @@ -196,7 +197,8 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { // Make the child widgets this.makeChildWidgets(); // Determine whether to show the toolbar - this.editShowToolbar = !!(this.children && this.children.length > 0); + this.editShowToolbar = this.wiki.getTiddlerText(ENABLE_TOOLBAR_TITLE,"yes"); + this.editShowToolbar = (this.editShowToolbar === "yes") && !!(this.children && this.children.length > 0); }; /* @@ -205,7 +207,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 || changedTiddlers[HEIGHT_MODE_TITLE]) { + if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE]) { this.refreshSelf(); return true; } else if(changedTiddlers[this.editTitle]) { @@ -213,7 +215,11 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { this.updateEditor(editInfo.value,editInfo.type); } this.engine.fixHeight(); - return this.refreshChildren(changedTiddlers); + if(this.editShowToolbar) { + return this.refreshChildren(changedTiddlers); + } else { + return false; + } }; /* diff --git a/core/ui/ControlPanel/Settings/EditorToolbar.tid b/core/ui/ControlPanel/Settings/EditorToolbar.tid new file mode 100644 index 000000000..aa142bf62 --- /dev/null +++ b/core/ui/ControlPanel/Settings/EditorToolbar.tid @@ -0,0 +1,9 @@ +title: $:/core/ui/ControlPanel/Settings/EditorToolbar +tags: $:/tags/ControlPanel/Settings +caption: {{$:/language/ControlPanel/Settings/EditorToolbar/Caption}} + +\define lingo-base() $:/language/ControlPanel/Settings/EditorToolbar/ +<> + +<$checkbox tiddler="$:/config/TextEditor/EnableToolbar" field="text" checked="yes" unchecked="no" default="yes"> <$link to="$:/config/TextEditor/EnableToolbar"><> +