From 73a9625b81976b5bd1b89c9642b03ef855975768 Mon Sep 17 00:00:00 2001 From: FlashSystems Date: Fri, 1 Apr 2022 12:42:16 +0200 Subject: [PATCH] Fix regressions cause by PR #6511 (#6567) * Fix field edit bug This fixes the field edit bug mentioned in https://talk.tiddlywiki.org/t/possible-field-editing-bug-in-5-2-2/2884 . * Revert "Fix visual regression in #6511" This reverts commit c920960942f48c07e95e56e175cf2b018fb3ec9e. * Add new class `tc-edit-fieldeditor` This class must be added to input and select elements that are used as field editors. This class reduces the line height of the input element if it is displayed within the `tc-edit-fields` part of the edit template. This allows the same input and select elements to be used for editing and adding fields. * Add the new class `tc-edit-field` to the docs The example in `Customizing EditTemplate Field Rendering` now uses the new CSS classes. --- core/ui/EditTemplate.tid | 2 +- core/ui/EditTemplate/fieldEditor-default.tid | 2 +- .../concepts/Customizing EditTemplate Field Rendering.tid | 6 +++--- themes/tiddlywiki/vanilla/base.tid | 7 +++++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/ui/EditTemplate.tid b/core/ui/EditTemplate.tid index 480a28658..58852067a 100644 --- a/core/ui/EditTemplate.tid +++ b/core/ui/EditTemplate.tid @@ -5,7 +5,7 @@ title: $:/core/ui/EditTemplate \define save-tiddler-actions() \whitespace trim <$action-sendmessage $message="tm-add-tag" $param={{{ [get[text]] }}}/> -<$action-sendmessage $message="tm-add-field" $name={{{ [get[text]] }}} $value={{{ [get[text]] }}}/> +<$action-sendmessage $message="tm-add-field" $name={{{ [get[text]] }}} $value={{{ [get[text]] :map[get] }}}/> <> <$action-sendmessage $message="tm-save-tiddler"/> \end diff --git a/core/ui/EditTemplate/fieldEditor-default.tid b/core/ui/EditTemplate/fieldEditor-default.tid index 3af55027f..f3242657d 100644 --- a/core/ui/EditTemplate/fieldEditor-default.tid +++ b/core/ui/EditTemplate/fieldEditor-default.tid @@ -1,3 +1,3 @@ title: $:/core/ui/EditTemplate/fieldEditor/default -<$edit-text tiddler=<> field=<> default="" placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}} tabindex={{$:/config/EditTabIndex}} cancelPopups="yes"/> \ No newline at end of file +<$edit-text tiddler=<> field=<> default="" class="tc-edit-texteditor tc-edit-fieldeditor" placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}} tabindex={{$:/config/EditTabIndex}} cancelPopups="yes"/> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/concepts/Customizing EditTemplate Field Rendering.tid b/editions/tw5.com/tiddlers/concepts/Customizing EditTemplate Field Rendering.tid index bc6a31f1f..bbdb4c771 100644 --- a/editions/tw5.com/tiddlers/concepts/Customizing EditTemplate Field Rendering.tid +++ b/editions/tw5.com/tiddlers/concepts/Customizing EditTemplate Field Rendering.tid @@ -13,7 +13,7 @@ The variables `currentTiddler` and `currentField` are set to pass information ab For example, a tiddler containing the following WikiText would render the field as an HTML input element of the type `date`. This will show a date picker for the fields on all modern browsers: ``` -<$edit-text tiddler=<> field=<> type="date" class="tc-edit-texteditor" placeholder="Set your date" tabindex={{$:/config/EditTabIndex}} cancelPopups="yes"/> +<$edit-text tiddler=<> field=<> type="date" class="tc-edit-texteditor tc-edit-fieldeditor" placeholder="Set your date" tabindex={{$:/config/EditTabIndex}} cancelPopups="yes"/> ``` The `tabindex` and `cancelPopups` attributes make sure the HTML input element behaves exactly the default elements provided by TiddlyWiki. @@ -21,11 +21,11 @@ The `tabindex` and `cancelPopups` attributes make sure the HTML input element be Not only the `EditTextWidget` can be used. A tiddler containing the following WikiText will render the field as a drop-down-list that allows the user to select the name of a tiddler. The name of the selected tiddler will be stored in the field. ``` -<$select tiddler=<> field=<> class="tc-edit-texteditor" cancelPopups="yes"> +<$select tiddler=<> field=<> class="tc-edit-texteditor tc-edit-fieldeditor" cancelPopups="yes"> <$list filter='[all[tiddlers]sort[title]]'> ``` -The class `tc-edit-texteditor` should be used to style the `input` and `select` elements to match the theme of the TiddlyWiki installation. \ No newline at end of file +The classes `tc-edit-texteditor` and `tc-edit-fieldeditor` should be used to style the `input` and `select` elements to match the theme of the TiddlyWiki installation. \ No newline at end of file diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index d79b9d788..145c5f2aa 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -1221,6 +1221,13 @@ button.tc-btn-invisible.tc-remove-tag-button { background-color: <>; } +.tc-tiddler-frame .tc-edit-fields input.tc-edit-fieldeditor, +.tc-tiddler-frame .tc-edit-fields select.tc-edit-fieldeditor, +.tc-tiddler-frame .tc-edit-fields textarea.tc-edit-fieldeditor { + margin: 0; + padding: 2px 3px; +} + .tc-tiddler-frame .tc-binary-warning { width: 100%; height: 5em;