Allow field-modules to use special HTML5 input-elements (e.g. date pickers) #6301
Replies: 7 comments 8 replies
-
Thanks @FlashSystems, this is great work, and shows an excellent knowledge of the core internals. However, part of the context is that I now see the tiddler field modules as being a mistake. The problem is that they confer special behaviour on specific fields in a way that is impossible for end users to replicate. As it's turned out, for every special behaviour of the "color", "modified" or "tags" field, users want to be able to confer the same behaviour on their own custom fields. This became evident early on when users started asking about additional fields with the behaviour of the "tags" field. As ever, backwards compatibility constrains us to retain tiddler field modules, but we now try to handle things through explicit type coercion and explicit templating. So, it's not clear the best way to extend the edit-text widget to support HTML 5 date inputs. One option would be to add generic support for date fields in the same format that the HTML 5 date input generates. It would be reasonably straightforward as there is a single Alternately, we could extend the edit text widget to recognise |
Beta Was this translation helpful? Give feedback.
-
Hello @Jermolene, thank you for your detailed reply. I understand your doubts regarding the field modules. But I hesitate hard-coding type coercion into the edit text widget. Maybe field modules have been a mistake, but from an extensibility and isolation standpoint I like the general idea. What do you think about creating a new module type. Let's call them "type modules" that are supplying the
The modules are not meant to be created or modified by the user. They supply the type coercion for different types of HTML5 input elements. That way it is easy to include new types of input boxes into TiddlyWiki as they become supported by the browsers, without having to modify the edit text widget. TiddlyWiki could just include "type modules" for each edit-type it wants to support. Even dropping support for an edit type that has gone out of favor would be possible and and well isolated. As an added benefit, plugins could supply "type modules" for special input elements that are not common enough for TiddlyWiki to support out of the box. |
Beta Was this translation helpful? Give feedback.
-
I'll create a pull request containing a proof of concept implementation for further discussion. |
Beta Was this translation helpful? Give feedback.
-
I've created pull request #6329 that contains an implementation of the proposed "type modules" and some documentation. Your feedback would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
-
Hello @Jermolene, no worries. I'm not getting frustrated and really appreciate the time you take to discuss the pros and cons of my idea and explaining your vision of TiddlyWiki. If I understand your first bullet point correctly, the current 1:1 relationship between a field and the corresponding edit-widget would be changed into a 1:n relationship. This approach would be incredibly flexible. But I think implementing such a change would be beyond my capabilities. My goal was to make the HTML5 date picker usable with TiddlyWiki. I'd like to tackle this in the following way that I hope is more in line with your plans for TiddlyWiki:
The
|
Beta Was this translation helpful? Give feedback.
-
I've created a PoC for my proposal and put up a demo TiddlyWiki where you can try it out. The changes are in the fieldtemplates branch of my fork of the TW5 repo. I'd appreciate your feedback. The changes are a little more complex than my previous proposal. @Jermolene your suggestion using the filter syntax for the conversion makes this approach much more flexible. If you think, that these changes have a chance to get merged I'll clean up the code to comply with the style guide and update the documentation. |
Beta Was this translation helpful? Give feedback.
-
Just to let you all know: There is a discussion going on at Talk TW that discusses naming-conventions about tiddler fields to make date/time formats more interchangeable between TW plugins. |
Beta Was this translation helpful? Give feedback.
-
I tried to add a HTML5 date picker to a tiddler field. Using a field-module I was able to transform the displayed INPUT-element into a date picker:
But now I've got a problem. The HTML5 date picker can not use TiddlyWiki's date format as an input and TiddlyWiki can not use the output of the date picker as a date.
I've implemented a solution, but I'm not sure, if it is a good idea: I extended the field-module by two new methods:
toValue
andfromValue
. They are called by the editor factory to convert the field-value into the value of the INPUT-Element and vice versa. If they're not defined, they are a no-op.A field-module using this will look like that:
This new feature would allow field-modules to use all kinds of HTML5-INPUT-elements: Date pickers, phone-number input, time selectors, etc. Plugins can supply their own field-modules. TiddlyWiki only needs to be extended by approx. 15 Lines of code in
editor/factory.js
.I can supply a pull request with the necessary changes. But before I do it, I'd like to have some feedback of the more experienced TiddlyWiki developers. Is this the right way to do it? Are there any side effects I'm not aware of? Is it worthwhile to supply such an interface?
Beta Was this translation helpful? Give feedback.
All reactions