1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-05 03:33:27 +00:00
Commit Graph

428 Commits

Author SHA1 Message Date
btheado
6f9cf20e77
Fixes reduce, filter, and sortsub operators undefined variable exception (#7156)
* Added failing tests for #7155

* Pass getVariable options through to the widget method. Fixes #7155

* Whitespace fix

* Added tests to verify macro parameters work inside filter, reduce, and sortsub operators
2023-01-03 13:48:20 +00:00
jeremy@jermolene.com
42a408146d Empty or missing type on genesis widget should not render an element/widget
Fixes #7153
2022-12-30 21:42:07 +00:00
jeremy@jermolene.com
3bdc18ab84 Fix json operators retrieving properties of strings and numbers
Fixes #7160
2022-12-30 15:28:34 +00:00
jeremy@jermolene.com
34ce7cacc3 Merge branch 'master' into parameterised-transclusions 2022-12-13 11:08:54 +00:00
Jeremy Ruston
0ce5788747
Fixes for JSON operators (#7105) 2022-12-09 18:31:23 +00:00
jeremy@jermolene.com
31f4c1f6af Merge branch 'master' into parameterised-transclusions 2022-12-05 17:21:33 +00:00
FlashSystems
3918e59cc1
Fixed PR to fix popup position if popup is triggered from within an offsetParent element (#7013)
* Fix popup location for tables

This commit introduces the `popupAbsCoords` option to the $button widget
and implements an absolut coordinate format.

Coordinates for popups are stored in the format `(x,y,w,h)`. These
coordinates are relative to the offset parent of the element that
defines the popup.

This commits adds a second format `@(x,y,w,h)`. Coordinates specified in
this format a relative to the pages root element.

The `popupAbsCoords` option of the $button widget enables the use of
this coordinates.

* Unify the declaration of the RegEx for parsing the popup-position

The regular expression was declared in three locations with the same
content. This commit supplies a new function `parseCoordinates` in
`popup.js`. This function returns the parsed coordinates and understands
the classic/absolute coordinates.

This function is used in `reveal.js` and `action-popup.js` to parse the
coordinates.

* Add documentation for coordinate systems

* Consolidate creating coordinate strings

The Popup object now contains a `buildCoordinates` method that can be
used to build coordinate strings. It takes an "enum" for the coordinate-
system to use. This makes everything easily extensible and prevents the
use of magic values.

* Add tests for `parseCoordinates` and `buildCoordinates`

* Add `tv-popup-abs-coords` to `collectDOMVariables`

This will make the absolute coordinates available for the
`DraggableWidget` and the `EventCatcherWidget`.

* Add documentation for the `tv-popup-abs-coords`

... to the `DraggableWidget` and the `EventCatcherWidget`.

* Fix crash when generating a static version of the TW

The Popup class is not initialized in `startup.js` if `$tw.browser` is
not true. After having consolidated the facilities for parsing
coordinate strings into `popup.js` this breaks because the static build
needs to parse coordinate stings even if no Popup module is initialized.
This commit solves this problem by making `readPopupState`,
`parseCoordinates` and `buildCoordinates` static methods of `popup.js`.
It also adds a comment to these functions to show that these can be called
safely even if the Popup-Class is not initialized.
2022-12-01 21:16:44 +00:00
Cameron Fischer
856aca2f92
Linked-List refactor (#6056)
* Added failing linked-list test for #7059

* Fixed linked-list remove bug #7059

* Added failing linked-list test for #7059

* Switched LinkedList to use Map

* Removed this.last from LinkedList

* Removed this.first from LinkedList

* Switching to deleting old LinkedList entries

* LinkedList rewritten to be better

* Using null as LinkList ends to reduce hashing

* Using adhoc map... cause it's better than ECMA6 Map

* compliance with TiddlyWiki coding conventions

* Made link-list tests confirm the prev links

Co-authored-by: btheado <brian.theado@gmail.com>
2022-11-27 17:48:08 +00:00
jeremy@jermolene.com
b5e4b21707 Merge branch 'master' into parameterised-transclusions 2022-11-27 12:40:51 +00:00
btheado
bea1a6b14f
Fix issue with linked list remove (#7065)
* Added failing linked-list test for #7059

* Fixed linked-list remove bug #7059
2022-11-26 15:05:10 +00:00
jeremy@jermolene.com
00927d2e13 Add parsermode pragma
Fixes #7058
2022-11-23 22:35:32 +00:00
jeremy@jermolene.com
52592a4dbc Add support for named end markers for procedures, functions and widgets 2022-11-23 16:30:20 +00:00
jeremy@jermolene.com
778b8dec7f Merge branch 'master' into parameterised-transclusions 2022-11-23 09:01:42 +00:00
Jeremy Ruston
cb0d0cfa6d
Support nested macro definitions (#7004)
* First commit

* Switched to \end <name> instead of all those repeated backslashes

Thanks @kookma. See https://github.com/Jermolene/TiddlyWiki5/pull/7004#issuecomment-1286429236

* Docs update
2022-11-22 17:10:37 +00:00
jeremy@jermolene.com
45958db074 Merge branch 'master' into parameterised-transclusions 2022-11-22 16:29:45 +00:00
Maurycy Zarzycki
d32d559f93
Add Timestamp to DateFormat (#7043)
* add Timestamp to DateFormat

* improve TIMESTAMP documentation
2022-11-21 16:13:34 +00:00
Cameron Fischer
8ead7e0624
Jasmine command (#6944) 2022-11-20 17:54:18 +00:00
Maurycy Zarzycki
4f7b10e055
CSV parser improvements (#7042) 2022-11-20 17:51:01 +00:00
jeremy@jermolene.com
b9d27e9fd5 Revert "Fix popup position if popup is triggered from within an offsetParent element (#6887)"
This reverts commit 5b85786f73.
2022-10-22 13:22:15 +01:00
FlashSystems
5b85786f73
Fix popup position if popup is triggered from within an offsetParent element (#6887)
* Fix popup location for tables

This commit introduces the `popupAbsCoords` option to the $button widget
and implements an absolut coordinate format.

Coordinates for popups are stored in the format `(x,y,w,h)`. These
coordinates are relative to the offset parent of the element that
defines the popup.

This commits adds a second format `@(x,y,w,h)`. Coordinates specified in
this format a relative to the pages root element.

The `popupAbsCoords` option of the $button widget enables the use of
this coordinates.

* Unify the declaration of the RegEx for parsing the popup-position

The regular expression was declared in three locations with the same
content. This commit supplies a new function `parseCoordinates` in
`popup.js`. This function returns the parsed coordinates and understands
the classic/absolute coordinates.

This function is used in `reveal.js` and `action-popup.js` to parse the
coordinates.

* Add documentation for coordinate systems

* Consolidate creating coordinate strings

The Popup object now contains a `buildCoordinates` method that can be
used to build coordinate strings. It takes an "enum" for the coordinate-
system to use. This makes everything easily extensible and prevents the
use of magic values.

* Add tests for `parseCoordinates` and `buildCoordinates`

* Add `tv-popup-abs-coords` to `collectDOMVariables`

This will make the absolute coordinates available for the
`DraggableWidget` and the `EventCatcherWidget`.

* Add documentation for the `tv-popup-abs-coords`

... to the `DraggableWidget` and the `EventCatcherWidget`.
2022-10-22 13:13:39 +01:00
jeremy@jermolene.com
120b93c242 New test for undefined parameters 2022-10-19 08:37:27 +01:00
jeremy@jermolene.com
32710ef9e6 Merge branch 'master' into parameterised-transclusions 2022-10-18 17:23:57 +01:00
Rob Hoelz
24dbf69180
Fix [is[variable]] operator doesn't work for "fake" variables #6303 (#6996)
* Add tests for [is[variable]] and "faked" variables

See GH #6303

* Make is[variable] and variables[] operators resilient to fake widgets

Co-authored-by: jeremy@jermolene.com <jeremy@jermolene.com>
2022-10-18 17:08:04 +01:00
jeremy@jermolene.com
5194b24108 Parameter parenthesis should be mandatory in function/procedure/widget definitions
See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387
2022-10-17 08:31:07 +01:00
jeremy@jermolene.com
b531984f50 Restore "Add default settings for styled inline SPANs (#6877)"
This reverts commit 6f98edd6bd.
2022-10-16 17:28:36 +01:00
jeremy@jermolene.com
9d4aa47356 Clarify/simplify some tests 2022-10-09 13:54:08 +01:00
jeremy@jermolene.com
6f98edd6bd Revert "Add default settings for styled inline SPANs (#6877)" because of failed tests
This reverts commit 23e0eeb556.
2022-10-07 18:43:09 +01:00
Mario Pietsch
23e0eeb556
Add default settings for styled inline SPANs (#6877)
* add default settings for styled inline SPANs

* change color names in palettes and vanilla-base

* change parser behaviour if custom class is used

* tc-inline-style will only be set if no other custom setting is appliead

* Add tests for inline-styles

* add one more test

* remove space after if
2022-10-07 18:05:49 +01:00
jeremy@jermolene.com
0a309f4865 Merge branch 'master' into parameterised-transclusions 2022-10-01 10:18:34 +01:00
Jeremy Ruston
db6abb9703
Improve recursion detection for transclusion and filters (#6970) 2022-10-01 10:13:40 +01:00
Jeremy Ruston
4e9267ea58
Introduce genesis widget (#6961)
* Initial Commit

* Fix version number

* Fix docs date
2022-09-24 14:07:42 +01:00
jeremy@jermolene.com
e3d13696c8 Remove implementation of $:/globals/
Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created.
2022-09-24 12:56:06 +01:00
jeremy@jermolene.com
fddaa9fdb1 Merge branch 'master' into parameterised-transclusions 2022-09-24 11:07:53 +01:00
Robin Munn
51bdf60ee8
Fix bug when using built-in list field as listField parameter to checkbox widget (#6897)
* Fix bug with checkbox widget and `list` field

The `list` field is stored as a list and frozen against modifications,
and getFieldList() returns it directly without creating a copy. So
before we modify it, we need to make a copy so we're not modifying a
frozen list. This bug doesn't manifest with custom fields, which are
stored as strings, only with the built-in `list` field.

* Fix checkboxes referencing non-existent tiddlers

This fixes the "tiddler is undefined" error when a checkbox's listField
property references a tiddler that doesn't (yet) exist.

* Better logic for checkbox listField handling

If the field contains an array, then it's almost certainly referenced
elsewhere and needs a defensive copy made. If it contained a string,
then it's safe to modify without making a defensive copy.
2022-09-22 18:52:55 +01:00
jeremy@jermolene.com
8f9d5cabaa Missing tests for parameters widget 2022-09-16 16:07:32 +01:00
jeremy@jermolene.com
a3ba6f9370 Tests and docs for function operator 2022-09-11 10:49:02 +01:00
jeremy@jermolene.com
82b22523aa Rejig genesis widget to be easier to use 2022-09-09 10:37:39 +01:00
jeremy@jermolene.com
f6ee0cdf4c Add test to show that global widgets need not use the _parameters field 2022-09-03 12:57:45 +01:00
jeremy@jermolene.com
15ea3ffa9a Remove tests related to obsolete changes to boot.js
Should have been part of 2f494ba152
2022-09-02 20:10:11 +01:00
Jeremy Ruston
35b9faaa89
JSON Filter Operators (Revised Attempt) (#6936)
* First commit

Cherry-picked from #6666

* Adjust release version number

Just in case we decide to make a release before we merge #6666
2022-09-02 18:15:45 +01:00
jeremy@jermolene.com
d852123f61 Tweak semantics of JSON operators to match #6932
This allows us to later bring in the optimisations without breaking backwards compatibility.
2022-09-02 17:14:50 +01:00
jeremy@jermolene.com
9317804464 FIx transcluding of functions
This first implementation concatenates the results of the filter (with no separator) and then wikifies the result.

The test in this commit is quite interesting...
2022-08-04 09:28:56 +01:00
jeremy@jermolene.com
b1cf9f241e Merge branch 'master' into parameterised-transclusions 2022-07-21 10:10:49 +01:00
Saq Imtiaz
0237d9ed94
feat(filters): extend :map filter run prefix to accept a suffix to enable mapflat (#6806) 2022-07-21 09:23:01 +01:00
jeremy@jermolene.com
17c9bf7546 Protect against excessively recursive functions 2022-07-21 09:17:57 +01:00
jeremy@jermolene.com
30f7b37cba Make use of type attribute consistent 2022-07-18 19:44:37 +01:00
Robin Munn
18d8173dcc
New insertafter filter operator (#6771)
* Implement insertafter operator (like insertbefore)

Currently, the behavior of insertafter if the target is not found is to
append the inserted tiddler to the end of the list, like insertbefore
does. In the next commit, we'll add a suffix to customize what both
insertafter and insertbefore do when the target is not found.

* Add failing tests for insertafter suffixes

Also includes tests for insertbefore suffixes (start/end), since we'll
be implementing both of those at the same time.

* Add start/end suffixes for insertafter/before

The tests that exercise the start/end suffixes now pass.
2022-07-13 17:08:17 +01:00
jeremy@jermolene.com
189fe428b7 Merge branch 'master' into parameterised-transclusions 2022-07-04 21:15:42 +01:00
Nolan Darilek
f02bd2392f
Various accessibility improvements (#6742)
* Add `main` and `article` roles to stories and story.

* Support `role` and \aria-checked` in buttons, and integrate with sidebar tabs.

* Add `region` role to sidebar, and set caption as `aria-label`.

* Add accessibility roles and labels to static templates.

* Update test fixtures with new ARIA tab attributes.
2022-06-28 14:05:52 +01:00
jeremy@jermolene.com
05d2c029a4 Merge branch 'master' into parameterised-transclusions 2022-06-14 08:34:47 +01:00
jeremy@jermolene.com
4e6efed58f Revert "Fix #6721"
This reverts commit b216579255 which was committed to the wrong branch
2022-06-14 08:34:42 +01:00
jeremy@jermolene.com
35b0833e0c Fix handling of {!!title} in a filter with no currentTiddler
Fixes #6721
2022-06-14 08:33:47 +01:00
Jeremy Ruston
b216579255 Fix #6721 2022-06-13 15:43:28 +00:00
jeremy@jermolene.com
227079f3da Add format:json operator
I've been finding this useful for debugging, and it kind of goes with the JSON operators
2022-06-10 09:29:56 +01:00
jeremy@jermolene.com
79b20bdaa8 Fix up handling of slot/fill for custom widgets
Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget
2022-06-09 18:02:47 +01:00
jeremy@jermolene.com
f513b403fe Remove support for $:/tags/Global
It is not needed now that we have true global variables
2022-06-01 08:24:20 +01:00
jeremy@jermolene.com
613f4af20f Fix refreshing of global variables
Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions.
2022-05-31 09:19:01 +01:00
jeremy@jermolene.com
006ae6e759 Refactor $parameters widget
The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself.
2022-05-31 09:03:20 +01:00
jeremy@jermolene.com
150266c731 Use underscores for new system fields for global variable tiddlers
For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code.
2022-05-30 18:38:25 +01:00
jeremy@jermolene.com
3af2cc2691 Introduce function operator for calling functions
Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter).
2022-05-30 18:05:54 +01:00
jeremy@jermolene.com
9424e9d1f2 Cleaning up after f636349007 2022-05-28 17:32:09 +01:00
jeremy@jermolene.com
f803e00567 Test showing how to un-override a core widget 2022-05-28 16:58:20 +01:00
jeremy@jermolene.com
5d413d3e2d Change to ? for conditional definitions 2022-05-28 13:49:02 +01:00
jeremy@jermolene.com
0d78b3fa38 Convert the tabs macro into a global
So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR.
2022-05-28 12:24:48 +01:00
jeremy@jermolene.com
f636349007 Introduce true global variables
The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists.

This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro.

In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro
2022-05-28 12:23:50 +01:00
jeremy@jermolene.com
7fc65d0d1a Remove accidental commit 6cc99fcbe3 2022-05-27 08:36:31 +01:00
jeremy@jermolene.com
6f9f92fa69 Add support for $:/tags/Global 2022-05-26 21:11:53 +01:00
jeremy@jermolene.com
0e08150028 Remove unneeded test tiddler 2022-05-25 18:04:32 +01:00
jeremy@jermolene.com
d59eec74a8 Merge branch 'master' into parameterised-transclusions 2022-05-25 15:23:20 +01:00
jeremy@jermolene.com
6cc99fcbe3 WIP 2022-05-25 15:15:17 +01:00
Robin Munn
a226975b3e
Fix UTC format date string test properly this time (#6709)
Hours could also end up as a single-digit number, just like date, if
timezone offset is low enough that it wraps around midnight.
2022-05-24 10:02:45 +01:00
Robin Munn
2a62da1498
Fix unit test for formatDateString UTC format (#6708)
Now the test should run correctly in any timezone
2022-05-24 09:47:02 +01:00
jeremy@jermolene.com
cbce4ebb7b Allow custom functions to be invoked as attributes 2022-05-23 20:18:54 +01:00
jeremy@jermolene.com
9e8d05f699 Require period prefix for custom filter operator functions
To ensure that custom filter operators cannot clash with future core operators.
2022-05-23 16:40:21 +01:00
jeremy@jermolene.com
3e09eacd20 Missed off 22e7ec2381 2022-05-23 16:32:19 +01:00
jeremy@jermolene.com
ec1ec8ccd8 Fix invocation of JS macros 2022-05-21 16:31:34 +01:00
jeremy@jermolene.com
e50101322f Require $$ for custom widgets, and that overridden JS widgets must exist
See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763
2022-05-21 15:47:19 +01:00
jeremy@jermolene.com
bbd9e2f243 Rename <$value> widget to <$fill> 2022-05-13 09:18:25 +01:00
jeremy@jermolene.com
36cf50aa96 Use \widget for custom widget definitions, and remove need for angle brackets
Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property
2022-05-13 08:49:53 +01:00
jeremy@jermolene.com
904e30a0e2 Detect recursion by tracking widget tree depth
The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid
2022-05-12 16:26:33 +01:00
jeremy@jermolene.com
774459fa73 Transclude: replace paramNames/paramValues with more robust JSON payload
More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153
2022-05-11 13:51:11 +01:00
jeremy@jermolene.com
a827290332 Fix stringifying/parsing string arrays containing newlines
A very old bug.

Fixes the ActionListOpsWidget problem @btheado
2022-05-10 10:22:35 +01:00
jeremy@jermolene.com
e092113f9f Switch to using \procedure to define new-style macros, and \function for custom filter operator functions
I now need to update the OP!
2022-05-09 18:00:09 +01:00
jeremy@jermolene.com
64448ae774 Make the macrocall widget delegate to the transclude widget 2022-05-08 20:48:33 +01:00
jeremy@jermolene.com
4f2f689ab9 Clarify that the recent changes allow functions to be invoked with the double bracket syntax
In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately
2022-05-08 16:05:32 +01:00
jeremy@jermolene.com
e9630328f1 Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax 2022-05-08 15:59:20 +01:00
jeremy@jermolene.com
9be05f6f38 Use consistent parse tree node property for params 2022-05-07 13:22:53 +01:00
jeremy@jermolene.com
2fe2d20ddf Genesis widget should pass raw attributes onto child widget...
...so that it can more efficiently handle refreshing itself.
2022-05-07 11:41:28 +01:00
jeremy@jermolene.com
e01dfa1507 Experimental support for custom filter operators
Just as we can define custom widgets we can also define custom parameterised filter operators
2022-05-06 15:01:17 +01:00
jeremy@jermolene.com
a9938a6c67 Improve recursion detection
While retaining backwards compatibility
2022-05-06 15:00:10 +01:00
jeremy@jermolene.com
7caaf82571 Fix variable retrieval bug with test harness 2022-05-06 10:32:20 +01:00
jeremy@jermolene.com
7ead87bd29 Use enlist:raw to preserve duplicates 2022-05-05 11:34:30 +01:00
jeremy@jermolene.com
f307f00e32 Fixes to enable the transclude widget itself to be overridden
There are two big changes here:

Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped.

We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value.
2022-05-05 08:20:14 +01:00
jeremy@jermolene.com
35430d09ed Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray
I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code.
2022-05-05 08:16:20 +01:00
jeremy@jermolene.com
e99137f4cc Cache parse trees when transcluding variables 2022-05-03 17:59:45 +01:00
jeremy@jermolene.com
719a5614cb Change tiddler separator used in wikitext tests
Underscore looked ambiguous; I kept typing dashes by accident
2022-05-03 16:53:00 +01:00
jeremy@jermolene.com
56c2242e4e Introduce genesis widget for dynamically creating widgets
See the "RedefineLet" test for a contrived example of usage
2022-05-03 12:55:10 +01:00
jeremy@jermolene.com
e1df50d981 Fix parameter handling 2022-05-03 12:54:29 +01:00
jeremy@jermolene.com
c4743ebbec Fix importing of function definitions 2022-05-03 09:39:05 +01:00
jeremy@jermolene.com
a888cd57cd Unquoted parameters should not eat a succeeding comma
Fixes #6672
2022-05-02 13:49:41 +01:00
jeremy@jermolene.com
689a6c5b6a Rewrite some tests to use the shortcut syntaxes 2022-05-02 10:56:22 +01:00
jeremy@jermolene.com
5f02cc49fd Add support for accessing function parameters as name/value pairs 2022-05-02 10:00:50 +01:00
jeremy@jermolene.com
8b867be8ef Add pragma rule for parameters declarations 2022-05-02 09:15:45 +01:00
jeremy@jermolene.com
99750d78b5 Allow brackets to be omitted for function definitions with no parameters 2022-04-30 13:06:28 +01:00
jeremy@jermolene.com
c9bd1b5274 Add wikitext shortcut for new-style function definitions 2022-04-30 12:44:26 +01:00
jeremy@jermolene.com
886c8620f5 Replace ubertransclude widget with transclude widget 2022-04-30 10:00:38 +01:00
jeremy@jermolene.com
f78e1f6f7d Importvariables should skip parameters widgets 2022-04-29 22:36:07 +01:00
jeremy@jermolene.com
5bcf7b9edd Add support for shortcut syntax for positional transclusion parameters 2022-04-29 22:35:47 +01:00
jeremy@jermolene.com
9713da5071 Add support for positional parameters 2022-04-26 21:55:43 +01:00
jeremy@jermolene.com
a401732995 Use ts- prefix for system slot names 2022-04-26 14:27:28 +01:00
jeremy@jermolene.com
fae038dcbc Remove need to explicitly clear widget mapping variable when invoking overridden widget 2022-04-26 14:24:31 +01:00
jeremy@jermolene.com
7299d4fd1d Merge branch 'master' into parameterised-transclusions 2022-04-26 14:03:03 +01:00
jeremy@jermolene.com
bdd99edfe8 Tests: Improve transclusion recursion test
Previously we were testing a tiddler transcluding itself, but it's clearer to make it an indirect recursion
2022-04-26 14:02:08 +01:00
jeremy@jermolene.com
66d4b07f7e Add a test for custom action widgets 2022-04-26 13:05:44 +01:00
jeremy@jermolene.com
05b582a202 Fix and test missing target handling 2022-04-26 12:32:46 +01:00
jeremy@jermolene.com
21b10a225f Initial commit
Everything is draft.
2022-04-24 21:24:38 +01:00
Robin Munn
8dec674121
Allow checkboxes to be indeterminate (#6593)
* Documentation for indeterminate checkboxes

* Unit tests for indeterminate checkboxes

* Implement indeterminate checkboxes

* Simplify indeterminate checkbox example

* Slightly simplify refresh logic for indeterminate

That five-line if statement can be turned into a simple assignment.

* Use "yes" and "no" for checkbox indeterminate attr

This makes the "indeterminate" attribute of the checkbox widget work the
same way as other boolean attributes of other widgets.

* Fix bug with invertTag attribute

One place in the checkbox widget code was checking invertTag for
Javascript truthiness rather than the value "yes", which could have
produced incorrect results if anyone wrote invertTag="no". Fixed.
2022-04-18 20:50:03 +01:00
Jeremy Ruston
fd0b985ac5
action-setfield shouldn't write to the current tiddler if the $tiddler attribute is present but has evaluated to a missing attribute
Fixes #5916
2022-04-16 18:02:27 +01:00
lin onetwo
cc25e1f5b4
fix: formatDateString with [UTC]xxx didn't use passed date (#6615)
* fix: formatDateString with [UTC]xxx didn't use passed date

* test: for formatDateString UTC

* fix: not possible to test internal date without hijack

Expected '20220410073037515' to be '20220410073037516'.

* fix: hour
2022-04-16 17:10:57 +01:00
Cameron Fischer
6624ce3716
Fix for broken style block wikitext (#6599)
* Fix for broken style block wikitext

* Fixed it so styles are correct too
2022-04-06 08:33:38 +01:00
Robin Munn
e28af8d594
Checkbox widget: list and filter modes (#6561)
* Docs for CheckboxWidget list and filter modes

This documents the `listField` and `filter` attributes.

* Tests for checkbox widget list mode

* Implement checkbox list mode

* WIP on implementing filter attr for checkboxes

* Improve CheckboxWidget documentation

* Refactor checkbox tests: move function to top

The big findNodeOfType function belongs at the top of the describe
block, so that the checkbox tests are more compact and easy to read.

* Move checkbox widget tests to end of file

The checkbox widget tests are long and involved, so we'll move them to
the end of the file so they aren't a huge block of code you need to read
past to find the next test.

* Improve formatting of CheckboxWidget docs

The \define() calls that are short enough to fit on one line should be
put on one line, for readability. The ones that are quite long have been
kept on multiple lines, for readability.

* Added more passing tests for checkbox widget

* Add some failing tests for checkbox widget

The filter mode where neither checked nor unchecked is specified (in
which case an empty filter result means false and a non-empty result
means true) is not working yet.

* Make failing tests pass

* Uncomment (and improve) test for field mode

We're now ready to start working on making this test pass. (There was
also one small mistake in the test, which this commit corrects).

* All tests now passing

* No indeterminate checkboxes in simple modes

The simple checkbox modes (field and index) should not produce
indeterminate checkboxes. That should be reserved for the advanced modes
(list and filter).

* Minor improvement to unit tests

* Allow indeterminate checkboxes in list and filter modes

This change may require some tweaks to the unit tests to be able to test
it properly.

* Slightly easier to read tests

* Two more tests for list mode

* Greatly simplify unit test code

Turns out there's no need to jump through Object.getPrototypeOf hoops.

* Minor simplification of unit test

* Add tests for indeterminate in list & filter modes

With this, the set of tests is complete.

* More tests to specify list mode behavior

* Unfocus tests so all tests run

* Update docs to say "new in 5.2.3" insetad of 5.2.2

* Move checkbox widget tests into their own file

The test-widget.js file was getting too long with all the checkbox
tests added, so we'll move the checkbox tests into their own file.

* Add checkbox widget tests for index mode

This commit also adds tests for index list mode (with a listIndex
attribute that will parallel the listField attribute) but leaves them
commented out because they don't pass yet: the code that implements the
listIndex attribute hasn't been written yet).

* Add listIndex attribute to checkbox widget

* Remove code that lets checkboxes be indeterminate

This reverts commit 6afcb151be. We will
add this code back in a later PR.

* Remove indeterminate tests for checkbox widget

We're currently not allowing indeterminate checkboxes, so there's no
need for the tests that check for them.

* Document listIndex attribute of CheckboxWidget

* adds class tc-checkbox-checked when checked

* equivalent to #2182 (RadioWidget)
* also applies `tc-checkbox` to checkboxes by default, always

* Move macro definitions inside example text

Since the wikitext-example-without-html macro creates a new parsing
context, it's safe to have macro definitions inside it. That makes these
examples a lot easier to write, and to read.

* Remove all mention of indeterminate checkboxes

Also improve the documentation a little bit: mention what happens in
list mode if neither checked nor unchecked is specified.

* Move filter mode to bottom of checkbox docs

The `filter` attribute should be under both `listField` and `listIndex`
rather than being between them. The documentation for filter mode should
similarly be after the `listIndex` documentation.

* Improve docs for `class` attr of checkbox widget

This brings the wording of the `class` attribute more in line with how
it's worded in the RadioWidget docs.

* Fix bug with list tiddlers

If neither checked nor unchecked was specified, then the behavior should
be "empty = false, non-empty = true". But if *both* are specified yet
neither is found, then the checkbox should be unchecked (false). It had
been falling through to the "non-empty = true" behavior, which was wrong.

* Improve listIndex example of checkbox widgets

* Remove unused function from test-widget.js

Co-authored-by: Tobias Beer <beertobias@gmail.com>
2022-04-02 15:16:08 +01:00
Mario Pietsch
ff42a9e4d4
Update core tabs-macro to make it easier to extend for plugin authors. (#6578)
* tabs activate v5.2.2 tests add whitespace trim

* tabs-macro -- add indentation and code preview

* tabs-macro -- replace substitutions with variables

* split tabs-macro macro into different elements

 - tabs-button
 - tabs-tab
 - tabs-tab-list
 - tabs-tab-body
 - tabs ... main macro

* tabs: add cascade to button and reaveal widgets

This will allow users to create "default tab" configurations similar to the tiddler info tab handling.

* tabs-macro -- add code_body: yes
2022-03-31 15:41:19 +01:00
Cameron Fischer
98a509dbf3
Trim Saga: Another batch of medium-sized files (#6270)
* adding trim: Last of the macros I think

* adding trim: EditTemplate and ItemSidebarIcon

* adding trim: control panel basics

* Another hidden space to guide the uglifier

* More consistent nested quoting

* Reconciling tests for \whitespace trim
2022-03-26 15:19:04 +00:00
Jeremy Ruston
b0c4886d23
Fix action-listops unsafe use of $tw.utils.stringifyList() (#6540)
Fixes #6535
2022-03-18 10:10:43 +00:00
Mario Pietsch
84ad758829
Prepare tabs macro tests for future readability improvements (#6504)
* prepare tabs macro test for future improvements

* update tests for tabs-macro to check all possible parameters
2022-03-11 16:33:58 +00:00
Ben Webber
2c38c8351b
Make butlast[0] consistent with rest (#6483)
butlast[0] now returns the input list unchanged.

Fixes: #5833
2022-02-26 09:42:24 +00:00
Ben Webber
a51191d334
Support specifying insertbefore position title as parameter (#6477)
* Support specifying insertbefore position title as parameter

Closes: #6133

* Update insertbefore calls with new variable parameter syntax

See-also: 96b52606a (Support specifying insertbefore position title as parameter, 2022-02-21)
2022-02-24 11:08:06 +00:00
Ben Webber
7a7472833f
Consider non-existent tiddlers untagged (#6478)
Fixes regression introduced in 575c23359.

Fixes: #6119
See-also: 575c23359 (Update untagged filter to avoid $tw.utils.pushTop (#6034), 2021-09-18)
2022-02-23 12:46:34 +00:00
Cameron Fischer
d0b5b2124a
Is draft (#6442)
* corrected [!is[draft]] to be a proper complement

* Ensuring [is[draft]] and [!is[draft]] are complements

* Made [is[draft]] more analogous to .isDraft()
2022-02-22 16:41:29 +00:00
Ben Webber
95bd694a65
Support case insensitive matching in prefix/suffix operators (#6468)
* Support case insensitive matching in prefix/suffix operators

Support `caseinsensitive`/`caseinsensitive` suffixes in the following
filter operators:

  * prefix
  * suffix
  * removeprefix
  * removesuffix

The suffixes have the same behaviour as in the match operator.

Closes: #6407

* Do not filter titles if suffix/removesuffix operand is empty

Issue: #6407
2022-02-22 16:38:40 +00:00
Jeremy Ruston
36b162a377
Fix for tag ordering issue #6382 (#6383)
* Failing test

* Fix underlying problem

* Less naive fix

Now we make sure we maintain the sort order of the titles array when adding a new tiddler

* Fix failing tests

* Refactor filter tests to repeat them with different store orderings

* Revert "Fix failing tests"

This reverts commit ee03ee57f5.

* Refine fix to retain stylesheet ordering

The order of tiddlers in the HTML file uses localeCompare(), and that determines the insertion order. So if we want to be compatible with older versions we have to use localeCompare() to order tiddlers, not a plain sort()

* Don't sort shadow tiddlers

Instead rely on the existing ordering

* Fix failing tests, take 2

I think that all of these changes are explained by the store no longer retaining insertion order, but now using localecompare ordering

* Fix tests from #6327
2022-02-21 15:34:05 +00:00
Jeremy Ruston
5378b45c40
Allow newlines within filtered transclusions (#6421)
* Allow newlines within filtered transclusions

* Docs
2022-02-21 15:28:21 +00:00
Cameron Fischer
a4ab42da8a
findListingsOfTiddler should cache results (#6327)
* findListingsOfTiddler uses FieldIndexer now

* Turns out FieldIndexer can't help listed[]
2022-02-21 15:07:30 +00:00
Mario Pietsch
6b4e5c74ad
Add "some" flag to search operator (#6293) 2022-02-21 15:05:34 +00:00
Joshua Fontany
1d0af90ba2
Extend lookup operator to work with fields and indexes (#5742)
* extend lookup op flexibility with 2 parameters

* bumped .from macro to .24

* aligned syntax

* lookup fixes

* bugfix

* docs

* messed up the tests somehow

* docs fix

* lookup bugfix

* docs

* docs

* call self.displayError

* Revert "call self.displayError"

This reverts commit 5d599aa979.

* storylist

* tests

* tests pass
2022-02-21 09:48:29 +00:00
Cameron Fischer
1b3c2557b8
Fixed issue: deprecated regexp could cause crash (#6438)
* Fixed issue: deprecated regexp could cause crash

* Different fix which will bother plugins less
2022-02-07 16:39:29 +00:00
Saq Imtiaz
76cdc17f3b
Support macro parameters in filter run prefixes (#6164)
* Support macro params in filter run prefixes and support substitution for variables set by filter run prefixes

* feat: add support macro parameters and variable substitution for all filter run prefixes

* fix: rename options argument to opts for disambiguation

* feat: add support for macro params to cascade filterrun prefix
2021-11-23 13:51:42 +00:00
Jeremy Ruston
a350a76a00
Add "cascade" filter run prefix and use it to control view templates (#6168)
* Initial Commit

* Set currentTiddler and ..currentTiddler for filter evaulation

* Precompile the filters for performance

* Add explicit test for empty result when no filter passes

* Use the cascade filter run prefix to choose the view template body template

* Use the cascade mechanism to choose between the edit and view templates

* Simplify cascade filter

Thanks @saqimtiaz

* Add control panel UI for inspecting the template cascades

* Refactor import listing and plugin listing as alternate body templates

As suggested by @pmario

* Refer to $:/core/ui/{View|Edit}Template via their associated config tiddlers

* Fix typo in previous commit

* Add demo of custom story tiddler template

* Tweak control panel wording

* Standardise "Story Tiddler Template" nomenclature

* Add a cascade for the editor template body

* Add a cascade for the view template title

* Avoid unwanted whitespace

* Add a cascade for dynamically choosing tiddler icons
2021-11-15 21:06:47 +00:00
Saq Imtiaz
b6ce353a7d
Fix: resolved search-replace operator regexp encoding bug (#6162)
* fix: resolved search-replace operator bug with $ character in replacement strings, added test and more examples

* fix: reset regexp after each title
2021-11-01 13:24:30 +00:00
Cameron Fischer
2bfe522b72
Add $let widget (#6148)
* $let widget added and tested

* Documentation for $let, doc improvements for $vars

* let properly avoids refreshing when possible

* $let Changes as recommended by others

* Removed superfluous super method call

Also improved $let test
2021-10-30 11:42:22 +01:00
Saq Imtiaz
c099bf9893
Extends :map filter run prefix to provide missing variables (#6149)
* Extends :map filter run prefix to provide the variables index, revIndex and length to bring it into line with :reduce

* update :maps examples

* docs: fix formatting issue with documentation
2021-10-30 10:04:50 +01:00
Jeremy Ruston
23b4e03cd5
Extend HTML tag parser to maintain an ordered array of attribute names (#6132)
* Extend HTML tag parser to maintain an ordered array of attribute names

* Add some tests for repeated attributes

* Record entire attribute in orderedAttributes array so that we can work with duplicated attributes
2021-10-27 11:35:12 +01:00
jeremy@jermolene.com
5f57bf81cd Merge branch 'pr/4977' 2021-10-27 11:18:57 +01:00
jeremy@jermolene.com
0be39cfbc2 More sorting tests to help with #6053 2021-09-20 11:04:37 +01:00
jeremy@jermolene.com
e6fd0caf6b Update range operator to use multiple operands
We still also support the old way of packing all three parameters into one operand with a delimiter
2021-09-07 17:16:09 +01:00
Simon Huber
c13f04d838
Add m flag for multiline matches to search-replace filter operator (#5968)
* add m flag to search-replace operator and add tests

* update documentation

* Update test-filters.js

* Update test-filters.js

* Update search-replace Operator (Examples).tid

* Fix "Hello There" title (HelloThere)
2021-08-29 17:44:34 +01:00
Saq Imtiaz
cb726f40fa
Fix: bug with List Widget where the counter-last variable is not always accurately updated on refresh (#5883) 2021-07-15 21:59:07 +01:00
Jeremy Ruston
d455072f13
Add support for JSON-formatted tiddler store, and make it the default (#5708)
* Add support for JSON-formatted tiddler store, and make it the default

The change to `getTiddlersAsJson()` is to allow experimentation

* Move JSON tiddlers into their own store area, and fix support for encrypted tiddlers

Also add a dummy old-style store area for backwards compatibility

The current arrangement is that JSON tiddlers will always override old-style tiddlers.

* Use the deserialiser mechanism to decode the content

* Refactor $:/core/modules/deserializers.js before we start extending it

Cleaning up the helper function names and ordering

* Drop support for the "systemArea" div

It was only used in really old v5.0.x

* Update deserializer to support JSON store format and add some tests

* Life UI restrictions on characters in fieldnames

* Add another test case

* Correct mis-merge

* Remove toLowerCase() methods applied to fieldnames

* Insert line breaks in output of getTiddlersAsJson (#5786)

Rather than have the entire store on one line, insert a line break
after each tiddler.

* Refactor #5786 for backwards compatibility

* Only read .tiddlywiki-tiddler-store blocks from script tags

Prompted by @simonbaird's comment here: https://github.com/Jermolene/TiddlyWiki5/pull/5708#discussion_r648833367

* Clean up escaping of unsafe script characters

It seems that escaping `<` is sufficient

* Add docs from @saqimtiaz

Thanks @saqimtiaz

* Docs tweaks

* Remove excess whitespace

Thanks @simonbaird

* Fix templates for lazy loading

* Remove obsolete item from release note

* Clean up whitespace

* Docs for the jsontiddler widget

* Fix whitespace

Fixes #5840

* Comments

* Fix newlines in JSON store area

* Remove obsolete docs change

Co-authored-by: Simon Baird <simon.baird@gmail.com>
2021-07-14 09:15:30 +01:00
Saq Imtiaz
041c3e817c
Support for macro params in filter operands (#5836)
* Exploratory pass at adding support for macro params in filter operands

* whitspace correction

* rename varInfo to varTree for disambiguation

* Refactored parseMacroInvocation to be re-usable, performance improvements for variables with no params and tests

* Revised regular expression and removed spurious white space changes

* Revised regular expression and removed spurious white space changes

* More whitespace cleanup and added more tests for edge cases

* Added test for macro params with square brackets
2021-06-29 22:21:39 +01:00
Saq Imtiaz
a6990128f1
Fixed bug introduced into transclusions for blank fields in #5736 (#5835) 2021-06-29 12:07:14 +01:00