1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Allow configuration of default focus field of new tiddlers (#4238)

* add editFocus attribute to edit widget

* add focus condition to title editTemplate

* add focus condition to body-editor editTemplate

* add focus attribute to type editTemplate

* add focus attribute to fields editTemplate

* add focus attribute to tag-picker

* add $:/config/AutoFocus tiddler

... default focus is title

* Update Basics.tid

* Update ControlPanel.multids

* Create minifocusswitcher.tid

* Update minifocusswitcher.tid

* Update Basics.tid

* Update body-editor.tid
This commit is contained in:
Simon Huber 2019-10-12 13:04:10 +02:00 committed by Jeremy Ruston
parent 74172b35ce
commit 66b68f4a58
10 changed files with 19 additions and 5 deletions

View File

@ -5,6 +5,7 @@ Advanced/Hint: Internal information about this TiddlyWiki
Appearance/Caption: Appearance
Appearance/Hint: Ways to customise the appearance of your TiddlyWiki.
Basics/AnimDuration/Prompt: Animation duration:
Basics/AutoFocus/Prompt: Default AutoFocus field:
Basics/Caption: Basics
Basics/DefaultTiddlers/BottomHint: Use &#91;&#91;double square brackets&#93;&#93; for titles with spaces. Or you can choose to <$button set="$:/DefaultTiddlers" setTo="[list[$:/StoryList]]">retain story ordering</$button>
Basics/DefaultTiddlers/Prompt: Default tiddlers:

View File

@ -47,6 +47,7 @@ EditWidget.prototype.execute = function() {
this.editClass = this.getAttribute("class");
this.editPlaceholder = this.getAttribute("placeholder");
this.editTabIndex = this.getAttribute("tabindex");
this.editFocus = this.getAttribute("focus","");
// Choose the appropriate edit widget
this.editorType = this.getEditorType();
// Make the child widgets
@ -58,7 +59,8 @@ EditWidget.prototype.execute = function() {
index: {type: "string", value: this.editIndex},
"class": {type: "string", value: this.editClass},
"placeholder": {type: "string", value: this.editPlaceholder},
"tabindex": {type: "string", value: this.editTabIndex}
"tabindex": {type: "string", value: this.editTabIndex},
"focus": {type: "string", value: this.editFocus}
},
children: this.parseTreeNode.children
}]);

View File

@ -24,6 +24,7 @@ caption: {{$:/language/ControlPanel/Basics/Caption}}
|<$link to="$:/config/NewJournal/Title"><<lingo NewJournal/Title/Prompt>></$link> |<$edit-text tiddler="$:/config/NewJournal/Title" default="" tag="input"/> |
|<$link to="$:/config/NewJournal/Text"><<lingo NewJournal/Text/Prompt>></$link> |<$edit tiddler="$:/config/NewJournal/Text" tag="textarea" class="tc-edit-texteditor" default=""/> |
|<$link to="$:/config/NewJournal/Tags"><<lingo NewJournal/Tags/Prompt>></$link> |<$edit-text tiddler="$:/config/NewJournal/Tags" default="" tag="input"/> |
|<<lingo Autofocus/Prompt>> |{{$:/snippets/minifocusswitcher}} |
|<<lingo Language/Prompt>> |{{$:/snippets/minilanguageswitcher}} |
|<<lingo Tiddlers/Prompt>> |<<show-filter-count "[!is[system]sort[title]]">> |
|<<lingo Tags/Prompt>> |<<show-filter-count "[tags[]sort[title]]">> |

View File

@ -6,6 +6,7 @@ title: $:/core/ui/EditTemplate/body/editor
class="tc-edit-texteditor tc-edit-texteditor-body"
placeholder={{$:/language/EditTemplate/Body/Placeholder}}
tabindex={{$:/config/EditTabIndex}}
focus={{{ [{$:/config/Autofocus}match[text]then[true]] ~[[false]] }}}
><$set

View File

@ -40,7 +40,7 @@ $value={{$:/temp/newfieldvalue}}/>
<td class="tc-edit-field-name">
<$text text=<<currentField>>/>:</td>
<td class="tc-edit-field-value">
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}} tabindex={{$:/config/EditTabIndex}}/>
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}} tabindex={{$:/config/EditTabIndex}} focus={{{ [{$:/config/AutoFocus}match[fields]then[true]] ~[[false]] }}}/>
</td>
<td class="tc-edit-field-remove">
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>

View File

@ -1,7 +1,7 @@
title: $:/core/ui/EditTemplate/title
tags: $:/tags/EditTemplate
<$edit-text field="draft.title" class="tc-titlebar tc-edit-texteditor" focus="true" tabindex={{$:/config/EditTabIndex}}/>
<$edit-text field="draft.title" class="tc-titlebar tc-edit-texteditor" focus={{{ [{$:/config/AutoFocus}match[title]then[true]] ~[[false]] }}} tabindex={{$:/config/EditTabIndex}}/>
<$vars pattern="""[\|\[\]{}]""" bad-chars="""`| [ ] { }`""">

View File

@ -3,7 +3,7 @@ tags: $:/tags/EditTemplate
\define lingo-base() $:/language/EditTemplate/
<div class="tc-type-selector"><$fieldmangler>
<em class="tc-edit"><<lingo Type/Prompt>></em> <$edit-text field="type" tag="input" default="" placeholder={{$:/language/EditTemplate/Type/Placeholder}} focusPopup=<<qualify "$:/state/popup/type-dropdown">> class="tc-edit-typeeditor tc-popup-handle" tabindex={{$:/config/EditTabIndex}}/> <$button popup=<<qualify "$:/state/popup/type-dropdown">> class="tc-btn-invisible tc-btn-dropdown" tooltip={{$:/language/EditTemplate/Type/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Type/Dropdown/Caption}}>{{$:/core/images/down-arrow}}</$button> <$button message="tm-remove-field" param="type" class="tc-btn-invisible tc-btn-icon" tooltip={{$:/language/EditTemplate/Type/Delete/Hint}} aria-label={{$:/language/EditTemplate/Type/Delete/Caption}}>{{$:/core/images/delete-button}}</$button>
<em class="tc-edit"><<lingo Type/Prompt>></em> <$edit-text field="type" tag="input" default="" placeholder={{$:/language/EditTemplate/Type/Placeholder}} focusPopup=<<qualify "$:/state/popup/type-dropdown">> class="tc-edit-typeeditor tc-popup-handle" tabindex={{$:/config/EditTabIndex}} focus={{{ [{$:/config/AutoFocus}match[type]then[true]] ~[[false]] }}}/> <$button popup=<<qualify "$:/state/popup/type-dropdown">> class="tc-btn-invisible tc-btn-dropdown" tooltip={{$:/language/EditTemplate/Type/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Type/Dropdown/Caption}}>{{$:/core/images/down-arrow}}</$button> <$button message="tm-remove-field" param="type" class="tc-btn-invisible tc-btn-icon" tooltip={{$:/language/EditTemplate/Type/Delete/Hint}} aria-label={{$:/language/EditTemplate/Type/Delete/Caption}}>{{$:/core/images/delete-button}}</$button>
</$fieldmangler></div>
<div class="tc-block-dropdown-wrapper">

View File

@ -0,0 +1,2 @@
title: $:/config/AutoFocus
text: title

View File

@ -18,7 +18,7 @@ $(actions)$
<div class="tc-edit-add-tag">
<span class="tc-add-tag-name">
<$keyboard key="ENTER" actions=<<add-tag-actions>>>
<$edit-text tiddler="$:/temp/NewTagName" tag="input" default="" placeholder={{$:/language/EditTemplate/Tags/Add/Placeholder}} focusPopup=<<qualify "$:/state/popup/tags-auto-complete">> class="tc-edit-texteditor tc-popup-handle" tabindex=<<tabIndex>>/>
<$edit-text tiddler="$:/temp/NewTagName" tag="input" default="" placeholder={{$:/language/EditTemplate/Tags/Add/Placeholder}} focusPopup=<<qualify "$:/state/popup/tags-auto-complete">> class="tc-edit-texteditor tc-popup-handle" tabindex=<<tabIndex>> focus={{{ [{$:/config/AutoFocus}match[tags]then[true]] ~[[false]] }}}/>
</$keyboard>
</span> <$button popup=<<qualify "$:/state/popup/tags-auto-complete">> class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Tags/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Tags/Dropdown/Caption}}>{{$:/core/images/down-arrow}}</$button> <span class="tc-add-tag-button">
<$set name="tag" value={{$:/temp/NewTagName}}>

View File

@ -0,0 +1,7 @@
title: $:/snippets/minifocusswitcher
<$select tiddler="$:/config/Autofocus">
<$list filter="title tags text type fields">
<option value=<<currentTiddler>>><<currentTiddler>></option>
</$list>
</$select>