Commit Graph

4535 Commits

Author SHA1 Message Date
Jeremy Ruston 8663dd51d6 Initial commit
Thanks @PotOfCoffee2Go
2023-11-17 16:44:34 +00:00
Robin Munn 215bd4e015
Avoid skipping extra whitespace in wikiparser.js (#7835)
When wikiparser parses text looking for a pragma block, it skips
whitespace before looking for the next pragma. If no pragma is found,
we should return the parse position to the original location so that the
skipped whitespace can be parsed as a text node. This allows the
attribute `join=" and "` to parse as " and " rather than "and ".
2023-11-14 22:10:58 +00:00
Robin Munn 758089cbb3
Alternate fix for inconsistent list template syntax (#7827)
* Alternate fix for inconsistent list template syntax

First attempt, which fails on the ListWidget/WithMissingTemplate test.

* Make WithMissingTemplate test pass, inefficiently

Unfortunately, this ends up being very inefficient, because the
clone-and-mutate logic is repeated for every list item. Not ideal.

* More efficient way to do it

This also makes the failing test pass, but far more efficiently.

* Improve performance of list template discovery

Since parse tree nodes never change after widget creation (whereas
attribute values *can* change), we can safely search for the explicit
list templtaes only once, at widget creation time. This saves time as
the search doesn't have to be done on each re-render, and also allows us
to safely do a clone-and-mutate step to extract the list widget's body
(if any) without any `$list-empty` or other items. That, in turn, allows
using the list widget's body as the template even if `$list-empty` is
specified inside the widget body.
2023-11-06 21:18:31 +00:00
Robin Munn 801e8e312c
Fix window.btoa call in browser (#7814) 2023-10-26 09:05:59 +01:00
Scott Sauyet 23a576b8bd
Tweak TOC to not show expander for sublist with all children excluded (#7802) 2023-10-25 13:37:24 +01:00
Simon Huber 6a52081d6b
Don't set focus on field-name input field when deleting field using delete-field button (#7806) 2023-10-25 13:29:40 +01:00
Robin Munn 246751be1b
Fix last filter operator when zero items selected (#7809)
Previously, [last[0]] was incorrectly returning the entire list. It now
returns zero items as it should.
2023-10-25 13:14:49 +01:00
Mario Pietsch efaa8dd1e8
tm-open-window set focus to existing window (#7708)
* tm-open-window set focus to existing window

* tm-open-window: update docs
2023-10-18 16:10:04 +01:00
Robin Munn 326ae61929
Fix encodebase64 and decodebase64 filters (#7683)
* Fix encodebase64 and decodebase64 filters

The documentation for encodebase64 says that the input is treated as
binary data, but in fact the input is being treated as text data, with
an extra UTF-8 encoding step being performed first.

Likewise, the decodebase64 documentation says that it outputs binary
data, but in fact it will do a UTF-8 decoding step before producing
output, which will in fact garble binary data.

This commit changes the behavior of encodebase64 and decodebase64 to
match what the documentation says they do. It also adds an optional
`text` suffix to both filters to keep the current behavior.

Finally, an optional `urlsafe` suffix is added to both filters to allow
them to use the "URL-safe" variant of base64 (using `-` instead of `+`
and `_` instead of `/`).

* Try to fix failing test

Turns out a little more than this is going to be needed.

* Fix binary base64 encoding, including unit tests

* Update base64 filter documentation

* Can't use replaceAll, too new

Have to use String.replace with a global regex instead

* Replace uses of window.btoa() in rest of code

Since window.btoa() is not available under Node.js, we'll replace all
uses of it with the $tw.utils.base64encode() function that now works
correctly for binary data.

* Add link to UTF-8 glossary definition at MDN
2023-10-18 16:08:56 +01:00
Simon Huber c185e373c5
Use display: grid for editor toolbar, editor and preview (#7787)
* make toolbar, editor and preview display: grid

* correct display of bitmap editor

* grid-area: toolbar not only when preview is shown

* use dedicated classes and tc-grid and no brittle CSS selectors

* no need for width: 100%

* cleanup style definitions

* use semantic classnames
2023-10-17 11:54:20 +01:00
Ke Wang c93d56667e
Extend ImageWidget to generate the src based on the encoding format of the image entries (#7783)
* Make ImageWidget rendering image tiddler based on encoding of type

* change indent

* use deserializerType instead of type
2023-10-17 09:47:46 +01:00
Simon Huber efa4f34131
Update Basics.tid to not use fixed height in edit widgets (#7789) 2023-10-15 12:32:17 +01:00
Jeremy Ruston ff1437e439
Fix refreshing of transcluded functions (#7698)
* Passing test

* Failing test

* Fix test

It still fails, but now fails correctly

* Fix refreshing transcluded functions (#7755)

We store the previous result of the filter function and recalculate it
when the transclude widget needs to be refreshed, refreshing the widget
if the result is different.

---------

Co-authored-by: Jeremy Ruston <174761+Jermolene@users.noreply.github.com>
Co-authored-by: Robin Munn <rmunn@pobox.com>
2023-10-14 09:44:18 +01:00
Jeremy Ruston 32966c9e91
Introduce jsonset operator (#7742) 2023-10-14 09:43:23 +01:00
Jeremy Ruston b7562f0c7b
Conditional Shortcut Syntax (#7710)
* Initial Commit

* Update docs

* Add support for elseif blocks

* Another test

* WIP

* Change from `{%if%}` to `<%if%>`

See discussion here - https://talk.tiddlywiki.org/t/proposed-if-widget/7882/64

* Don't use the widget body as the template if a list-empty widget is present

See discussion here - https://github.com/Jermolene/TiddlyWiki5/pull/7710#issuecomment-1717193296

* List widget should search recursively for list-template and list-empty

* Allow block mode content within an if/then/else clause

* Update docs

* Add from-version tag to docs
2023-10-14 09:41:21 +01:00
Jeremy Ruston 4c9c85aec5
Add support for list-template and list-empty widgets for specifying list widget templates (#7784)
Cherry picked from #7710
2023-10-14 09:31:11 +01:00
Jeremy Ruston 66a8e2dbf2
Ensure {{}} doesn't generate a transclude widget with no attributes (#7768) 2023-10-07 21:55:39 +01:00
Jeremy Ruston 327ecf8f66
Don't refresh the body editor when switching the preview on and off (#7747)
* Don't refresh the body editor when switching the preview on and off

* Focus editor when switching the preview on or off
2023-10-06 21:49:02 +01:00
Mateusz Wilczek d17525ec8e
Improve file type names (TID, SVG, ICO) in hints (#7764)
* Make filetype names in hints consistent

* Make ICO content type hint more consistent
2023-10-03 21:37:49 +01:00
Joe Bordes 5bb8155422
i18n(ES) update to latest version changes (#7761) 2023-10-01 09:00:06 +01:00
Robin Munn bb2973fc29
Make flexbox or grid layouts possible (#7690)
Both flexbox and grid layouts need the container div to be the direct
parent of the children it lays out. To enable that, we need a class that
can select the direct parent of the list widget in PageTemplate.tid so
that that class can have `display: flex` or `display: grid` applied to
it. The `tc-page-container` div is not suitable, because it contains
a `<$dropzone>` inside it, and the dropzone widget creates a div so
tc-page-container is no longer the direct parent of the list. Instead,
a tc-page-container-inner class is added to the dropzone widget in
addition to its existing tc-dropzone class, so that grid or flexbox
layouts can target tc-page-container-inner for setting the appropriate
CSS `display` property.
2023-09-30 16:33:40 +01:00
Robin Munn 8effb3f218
Fix list widget bug with counter-last when appending items (#7712)
* Add failing test for list widget with counter-last

The failing test appends a value to a list without changing the rest of
the list, and the counter-last value doesn't get updated correctly when
that happens. Also added another test, which passes, testing removing
the last item of the list, just in case of a regression.

* Improve unit tests for counter-last list widget bug

The unit tests were looking very similar to each other, so I factored
out the common code and made them into simple data-driven tests.

* Fix bug where counter-last fails in list widget

The only scenario that was failing was when counter-last was used, but
the list was strictly appended to with no other changes made. The one
unit test that was failing now passes with this fix.

* Improve bugfix to list widget counter-last

Now we only refresh the last item if it was truly necessary.
2023-09-24 20:19:50 +01:00
Robin Munn 780e5d33a4
Slightly speed up [all[shadows+tiddlers]] filters (#7702)
The `all` filter operator has shortcuts to optimise common patterns like
`[all[shadows+tiddlers]]` or `[all[tiddlers]]`. In those cases, the
filter operator function returns early and never uses the `result`
linked list that was created, so it's immediately garbage-collected.
Let's delay creating it until we know it's actually going to be used.
2023-09-24 20:19:04 +01:00
Simon Huber 711d1658e2
Edittemplate delete button should also delete the typeInputTiddler (#7749)
If we don't delete the typeInputTiddler with the click on the "delete" button then the dropdown stays filtered - but the text input seems to be empty. This PR corrects this behavior
2023-09-21 17:57:53 +01:00
Jeremy Ruston b82f012c0c Revert "Make preview editor button focus the editor"
This reverts commit f383863654.
2023-09-19 16:08:13 +01:00
Jeremy Ruston f383863654 Make preview editor button focus the editor 2023-09-19 16:07:52 +01:00
Jeremy Ruston 49c96901f3 Fix typo in 7d8766d2b9 2023-09-13 18:06:30 +01:00
Jeremy Ruston 7d8766d2b9 Test editors shouldn't set type attribute of textareas
fixes #7732
2023-09-13 18:04:12 +01:00
Jeremy Ruston e16635a5ad Tweak wording of server command help
Fixes #7724
2023-09-06 12:33:09 +01:00
Jeremy Ruston fa9bfa07a0 Fix missing closing tag in tag-pill-inner macro
Fixes #7697
2023-08-25 14:06:17 +01:00
Jeremy Ruston 70309c67d1 Prepare for v5.3.2-prerelease 2023-08-20 11:45:38 +01:00
Robin Munn 779ac28bd0
Fix checkbox widget when listIndex field undefined (#7679) 2023-08-15 17:12:49 +01:00
Jeremy Ruston 4bdac09872
Fix transclude inefficiency (#7647)
* Refactor parse mode out of getTransclusionTarget

* Refactor missing transclusion target

* Add a test to avoid regressions on the handling of macros vs procedures

* Refactor condition logic

* Preparing to split getTransclusionTarget into two separate functions

* Split getTransclusionTarget into getTransclusionTargetIncludingParseTreeNodes

* Resolve another inefficiency

The transclusion target was sometimes being parsed twice when transcluding as text/plain

Associated test results are also made more consistent

* Simplify method naming

* Neatening up
2023-07-30 18:04:05 +01:00
Mario Pietsch e60232e0cb
Fix drag and drop from chrome-like browsers to FireFox (#7622)
* fix drag and drop from chrome-like browsers to FireFox

* test feature matchMedia function

* implement new borwser sniffing functions as utilities

* use $tw.browser structure for isMobileChrome detection
2023-07-22 15:47:39 +01:00
Jeremy Ruston ad6e09f1cb Minor refactor transclude widget
Preparing to fix #7592
2023-07-22 14:01:24 +01:00
Mario Pietsch b000f20283
Fix toc indentation problem (#7627)
* fix toc indentation problem

* add caption to Third & Fourth toc tiddlers to see caption-handling

* reset modified fields
2023-07-22 12:41:19 +01:00
Jeremy Ruston 160cc0e9a9 Revert "Add widget.destroy() function (#7468)"
See discussion at https://github.com/Jermolene/TiddlyWiki5/pull/7468#issuecomment-1645753857
2023-07-22 11:41:36 +01:00
Saq Imtiaz 61a08cbd7b
Feat: allow new pragmas to be indented (#7624) 2023-07-21 13:40:42 +01:00
Jeremy Ruston 0a4cfa1164 Revert f61d244410
No evidence that this change improved anything
2023-07-20 22:03:00 +01:00
Jeremy Ruston 9b2af13596 tm-http-request: Add support for binary responses
With a demo courtesy of https://random.dog/

@rmunn you recently worked on the base64 utilities. I tried to use $tw.utils.base64Encode instead of window.btoa, but found that it didn't work. It's concerning because we expose that utility method as a filter operation, and it would be frustrating if we were not base64encoding things properly.
2023-07-17 12:15:20 +01:00
Jeremy Ruston 7182dbf244 Fix whitespace within new journal button image
Fixes #7612
2023-07-17 09:33:38 +01:00
Jeremy Ruston f61d244410 Adjust max widget tree depth to 500
See discussion at https://talk.tiddlywiki.org/t/recursive-error-in-template-tiddler-not-getting-caught-in-5-3-0/7566/12
2023-07-17 09:33:16 +01:00
Saq Imtiaz 284669544b
Trim whitespace when importing variables in $importvariables (#7611)
* fix: trim whitespace when importing variables

* feat: added tests for importing variables
2023-07-17 09:18:42 +01:00
Jeremy Ruston b54a88ce83 Clean up transclude widget
1. Update comments
2. Refactor use of parseTreeNodes so that they are not referenced unnecessarily
3. getTransclusionTarget doesn't need to return the parser object
2023-07-16 14:04:09 +01:00
Mario Pietsch 3bd8c5d50d
Add code-body to unsafe templates, and new cascade for tiddlers with system tags (#7583) 2023-07-15 18:12:10 +01:00
btheado 8e9d8d4fef
Allow attribute substitution to handle variables containing non-word characters (#7606)
* Added failing test for #7604

* Fix attribute substitution regexp

Use the same regexp in wiki.getSubstitutedText as is used in
Widget.prototype.substituteVariableReferences. Fixes #7604.

* Added a test for a variable name containing spaces
2023-07-14 21:42:31 +01:00
Scott Sauyet f517497fe7
Add tabindex to SelectWidget and docs (#7594) 2023-07-09 16:52:35 +01:00
btheado eff158b1ae
Fixed http-request bind-status and bind-progress option names (#7595) 2023-07-09 16:50:48 +01:00
jeremy@jermolene.com 29b5b064d6 Robustify widget.removeLocalDomNodes
Otherwise we get crashes if the DOM nodes generated by a widget have been subsequently modified by something like MathJax – see https://talk.tiddlywiki.org/t/tw-5-3-0-js-exception/7488/2
2023-07-06 09:56:39 +01:00
jeremy@jermolene.com 57d85d4f64 Preparation for v5.3.1 2023-07-01 12:51:58 +01:00