1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-17 09:24:30 +00:00
Commit Graph

946 Commits

Author SHA1 Message Date
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
1aba8a1f65 Slight optimisation to user defined widgets 2022-09-24 12:41:28 +01:00
jeremy@jermolene.com
fddaa9fdb1 Merge branch 'master' into parameterised-transclusions 2022-09-24 11:07:53 +01:00
jeremy@jermolene.com
81ac987484 Optimise variable prototype chain handling
With this improvement and 53d229592d I'm measuring a 10-15% performance improvement between v5.2.3 and master using https://github.com/Jermolene/tiddlywiki-performance-test-rig
2022-09-24 08:28:16 +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
977a133028 Tweak comments 2022-09-09 14:16:08 +01:00
jeremy@jermolene.com
b751f7e793 Parameters widget: protect against negative $depth 2022-09-09 12:04:50 +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
e3697e29bb When transcluding functions, pass an empty item list to the filter, and just return the first item 2022-09-09 10:22:06 +01:00
jeremy@jermolene.com
11e0c66a4c Transcluded functions should operate on the entire store 2022-09-03 20:11:45 +01:00
jeremy@jermolene.com
a439cb58be Fix caching of parse variables/macros/procedures 2022-09-03 20:11:23 +01:00
jeremy@jermolene.com
00b6645c94 Disable overriding core widgets in safe mode 2022-09-03 12:58:10 +01:00
jeremy@jermolene.com
2b8b133d4a Merge branch 'master' into parameterised-transclusions 2022-08-17 18:11:21 +01:00
Mario Pietsch
2ff5bd5a0f
Fix removing a field with empty name (#6888)
* allow us to remove a field with empty key

* fix typo in if clause
2022-08-09 18:44:45 +02: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
6207ec4812 Merge branch 'master' into parameterised-transclusions 2022-08-02 17:49:28 +01:00
Saq Imtiaz
613b3df367
Image lazy loading (#6809)
* Extend image widget with lazy loading support

* docs: added from-version to docs update
2022-07-21 15:30:56 +01:00
jeremy@jermolene.com
b1cf9f241e Merge branch 'master' into parameterised-transclusions 2022-07-21 10:10:49 +01:00
jeremy@jermolene.com
745707fea3 Parameters widget: Be defensive about negative depths 2022-07-19 10:27:36 +01:00
jeremy@jermolene.com
d4e0eb193b Slot widget: be more defensive about negative depth values 2022-07-19 10:26:20 +01:00
jeremy@jermolene.com
a2182255cc Simplify the fill widget
We can rely on the default processing in the base class
2022-07-19 10:02:09 +01:00
jeremy@jermolene.com
30f7b37cba Make use of type attribute consistent 2022-07-18 19:44:37 +01:00
Saq Imtiaz
f6e021d70f
Feat: dynamically refresh class for draggable widget DOM node instead of re-rendering the widget (#6787) 2022-07-15 15:37:27 +01:00
jeremy@jermolene.com
ceec7b5737 Style tweaks for #6755 2022-07-05 17:47:57 +01:00
Mario Pietsch
76bc2f7524
Fix svg foreignObject that contains DIVs (#6755)
* xmlns attribute defined in element takes precedence

* use predefined tagNamespaces variable as default value

* change code as suggested by Jeremy
2022-07-05 17:46:31 +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
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
defe3e42e6 Adjust naming of transclusion metaparameter 2022-06-05 16:10:41 +01:00
jeremy@jermolene.com
7680280d87 Fix typo 2022-06-05 15:59:03 +01:00
jeremy@jermolene.com
542df63ccf Simplify metaparameters implementation 2022-06-03 11:21:32 +01:00
jeremy@jermolene.com
c42df2233a Make slot fill data available to transclusions
Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion
2022-06-03 08:53:51 +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
0c3f82855b Minor cleanups 2022-05-29 10:55:15 +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
dec45f0fc3 Fix importvariables to work with setvariables as well as set (they are aliases) 2022-05-26 21:11:32 +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
22e7ec2381 Procedures and widgets inherit whitespace trim setting from their definition 2022-05-23 15:30:33 +01:00
jeremy@jermolene.com
170c4b1799 Merge branch 'master' into parameterised-transclusions 2022-05-23 11:28:12 +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
0b11b499c2 Better backwards compatibility for legacy recursion marker
Fixes the problem with tag dropdowns @btheado
2022-05-10 10:21:56 +01:00
jeremy@jermolene.com
eef7d180a5 Remove obsolete code
Left over after refactoring
2022-05-10 10:21:19 +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
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
Simon Huber
4b8594c4a8
Fix: eventcatcher widget - variables can be undefined (#6668)
* Fix: eventcatcher widget - variables can be undefined

* Fix: selectedNode can be an svg where offsetLeft ... are undefined

* Make check for offsetLeft short

* remove second collectDOMNodeVariables
2022-05-06 17:11:13 +01:00
jeremy@jermolene.com
a9938a6c67 Improve recursion detection
While retaining backwards compatibility
2022-05-06 15:00:10 +01:00
jeremy@jermolene.com
e5164113c4 Don't create variables with value undefined for missing parameters 2022-05-05 14:47:22 +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
e99137f4cc Cache parse trees when transcluding variables 2022-05-03 17:59:45 +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
8f69c27632 Reuse attribute objects when executing custom widgets 2022-05-03 09:38:41 +01:00
jeremy@jermolene.com
2ea0374b55 Allow the let widget to create variables starting with $ 2022-05-03 08:44:33 +01:00
jeremy@jermolene.com
3000d3339c Remove extraneous code 2022-05-03 08:11:00 +01:00
jeremy@jermolene.com
a10106a4a6 Fix crash when transcluding an undefined variable
Thanks @pmario

See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359
2022-05-02 11:15:18 +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
bbc6661192 Remove erroneous "tag" property 2022-05-02 09:26:18 +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
aac2d6ccb0 Refactor ubertransclude functionality into transclude widget 2022-04-30 09:54:55 +01:00
jeremy@jermolene.com
c4991fff9e Refactor transclude widget before uberfying it 2022-04-30 09:30:25 +01:00
jeremy@jermolene.com
f78e1f6f7d Importvariables should skip parameters widgets 2022-04-29 22:36:07 +01:00
jeremy@jermolene.com
89b7a3bd28 Ubertransclusion positional parameters should be based on name, not position 2022-04-29 16:28:03 +01:00
jeremy@jermolene.com
9713da5071 Add support for positional parameters 2022-04-26 21:55:43 +01:00
jeremy@jermolene.com
31c3abb7ab Add a definition for the value widget just so that it doesn't cause errors
Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget...
2022-04-26 14:36:05 +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
35616a0b39 Don't worry about ordered attributes
The changes in 0bffae2108 mean that we don't need to explicitly maintain the ordered attributes
2022-04-26 14:05:56 +01:00
jeremy@jermolene.com
7299d4fd1d Merge branch 'master' into parameterised-transclusions 2022-04-26 14:03:03 +01:00
jeremy@jermolene.com
0bffae2108 Add utility method for getting ordered attributes 2022-04-26 14:02:31 +01:00
jeremy@jermolene.com
cd0617f033 Use the ubertransclude widget for the wikitext transclusion syntax 2022-04-26 12:45:05 +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
Simon Huber
030155ec27
Add "enabled" attribute to draggable widget (#6581)
* Add "enabled" attribute to draggable widget

* Update draggable.js

* Update draggable.js

* Update draggable.js
2022-04-15 14:17:06 +01:00
Simon Huber
58dd47d128
Add "tv-selectednode-width" and "tv-selectednode-height" ... (#6582)
* Add "tv-selectednode-width" and "tv-selectednode-height" ...

... variables to dragstartactions

* Update dragndrop.js

* Update dragndrop.js

* Add docs

* Update dragndrop.js

* Update dragndrop.js

* Update DraggableWidget.tid

* Update modifier Variable.tid

* Update modifier Variable.tid

* Update eventcatcher.js

* Update dom.js

* Update dragndrop.js

* Update dragndrop.js

* Update DraggableWidget.tid

* add a space after //

* Update modifier Variable.tid
2022-04-15 13:46:09 +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
jeremy@jermolene.com
6dbb3ee36e Revert scrollable changes e49dda3b48
See https://talk.tiddlywiki.org/t/stroll-issue-with-5-2-2/2885/2
2022-03-29 09:49:31 +01:00
jeremy@jermolene.com
681f22b66d Remove erroneously included code
See https://github.com/Jermolene/TiddlyWiki5/pull/6540#pullrequestreview-914281218
2022-03-18 12:40:12 +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
c741978e95
Fix the button default fix (#6531) 2022-03-16 11:57:56 +00:00
Mario Pietsch
28a91aafa7
Button Widget: ensure changes to "default" attribute trigger a refresh 2022-03-15 12:35:58 +00:00
Jeremy Ruston
1d8c538e45
Eventcatcher widget: add "matchSelector" attribute (#6523)
* Initial Commit

* Allow matchSelector to be used even if selector attribute isn't used
2022-03-14 09:56:23 +00:00
Saq Imtiaz
4054566493
Extend $draggable to support an optional drag handle (#6480)
* feat: extend  to support a selector attribute identifying the DOM element to be used as the drag handle

* fix: remove redundant variable declaration

* fix: remove extranneous variable declaration
2022-02-24 11:06:18 +00:00
Jeremy Ruston
82c8fe7fa8
Introduce JSON parse utility function with error handling (#6401)
* Introduce JSON parse utility function with error handling

Fixes #6400

* Fix typo
2022-02-21 15:29:25 +00:00
Jeremy Ruston
ab3109d84b
Add support for directly setting style.* attributes on HTML elements (#6388)
* Support direct style attributes on the element widget

* Fix tests

Not all parse tree nodes have an "orderedAttributes" member (eg. the error message generated at 5613bcc884/core/modules/widgets/transclude.js (L73-L75))

* Ensure ordering isn't insertion dependent if orderedAttributes is missing

* Add docs
2022-02-21 15:24:06 +00:00
jeremy@jermolene.com
37a6ff8521 Move tm-rename-tiddler handling from navigator widget into startup module
This reverses an August 2015 change in 68e15c10641e2eda1e64cf29954786a07326a920; the original rationale was wrong: there is nothing related to the navigator widget in the implementation of the tm-rename-tiddler message
2022-02-19 09:20:32 +00:00