The Amazing PasteUp of @EricShulman

First, please ignore what I previously wrote about preventing below/right overflow by forcing the field rectangle positions to remain “in bounds”. I didn’t particularly like that solution, as it prevents field placements that MIGHT be desireable in some circumstances.

In any case, I’ve reverted that code change because I found a MUCH better way to address the issue:

The new solution uses a combination of zoom and overflow handling that properly hides the layout grid “bleed over” rendering when a field is rotated and the layout grid is zoomed out… and, because this solution uses overflow:hidden CSS, it also prevents dragging items outside the containing grid layout!

With regard to the new issue you’ve raised about using transform:scale(3):

Because of the removal of overflow:hidden from field rendering (to permit better handling for rotated content), the field rectangles now function more like “anchor points” for the field content rather than as strict “bounding boxes”.

A side-effect of this is that it is not possible to interact with any field contents (not just images) that are rendered outside of their field rectangle, which is what you have observed when you used transform:scale(3) (and to a lesser extent when rotated content overflows its field rectangle).

While TiddlyTools PasteUp does not prevent you from using any CSS attributes you want – including attributes that cause overflow rendering to occur – the general principle should be to always try to use field rectangles that completely enclose their content and avoid “bleed over” rendering whenever you can.

For example, when rendering image contents you should omit transform:scale(...) entirely and change the dimensions (top, left, width, and height) of the field rectangle. This will automatically scale the image to fill the available field rectangle (while preserving the original image proportions). For text content, you can use font-size:... or zoom:... to get the desired appearance, and then adjust the field rectangle to fit that text.

-e

1 Like

hah, I’d gotten so focused on the apparent issue of scale via css, I’d forgotten that pasteup’s internal scaling handles things! Excellent :slight_smile:

I have just updated TiddlyTools/PasteUp to apply a “best of both worlds” solution to the issue of field clipping:

By default, all field rectangles now use "overflow:hidden" handling to automatically clip the field content to the containing field rectangle. This avoids the dreaded “overflow content cannot be selected nor dragged to” problem.

However, if a field’s styles contain a “rotate” transformation then the field content is allowed to overflow the containing field rectangle so the corners of the rotated field content won’t get chopped off.

enjoy,
-e

hmm, I’m now seeing the problem that I cannot alter the CSS at all

Example: changing the background on the sample text to red, then clicking save, and the original hasn’t changed, and re-entering this edit area shows the CSS back to white as it originally was.

Same behavior in both firefox and chromium

I had made some small changes that accidentally broke the “gridmodal” dialog, including the “save changes” handler. You may also notice that the gridmodal heading says “Add a field” even though it is clear that you are editing an existing field. The symptoms of the error was that the changes were being saved to a new tiddler using the fieldname as the title (e.g, “test1” and “test1/styles” appear in the sidebar “recent” list).

It took me a little while to isolate the problem and fix the error. Saving from the gridmodal dialog should now be working again. Please retry and confirm.

-e

1 Like

that looks fixed. nice!

I cannot remove any fields at the moment however (I can add new ones by duplicating by changing name when editing. Noting that this was not an obvious thing to discover - something for documentation, or maybe a “duplicate” button when in edit mode?

Another thing I’ve found causing glitching is appears to be a performance thing - only on firefox: when editing a field and typing styles, the preview is live-updated, and during the time between typing and the preview being updated, firefox does not accept keystrokes. A number of times I’ve set a colour to “red” (easy to type for testing) and it appear as “rd”, or lost a digit when testing rotation angles. I’ve not seen this in Chromium, but I dont know if that’s because Chromium is not blocking keyboard input when updating the preview, or simply performing the preview fast enough that I can’t beat it with human typing speed.

The “remove field from layout” button was also broken by the small changes I had made… and should now be fixed.

I also added an entirely new “delete field” button to the modal field editor. While the “remove field from layout” button just clears the top/left/bottom/right/layer values for the field, the “delete field” button asks for confirmation and then completely removes the entire field definition (i.e., value, layout and styles).

Regarding adding new fields:

There are at least 3 ways to add a field:

  • Editing an existing field using the modal field editor and then changing the name
  • Dragging on an empty area of the layout grid to select some empty squares and then click on the highlighted selection to open the modal field editor.
  • Use the field table’s “add new field” function to enter a new field name and optional field value and press the [+] button.

Regarding the modal field editor’s preview update in Firefox:

I will do some more testing to see if I can either improve the preview update performance or somehow enable Firefox to not block input during the refresh.

enjoy,
-e

I’ve added a new “hold” checkbox option to the modal field editor:

  • When this checkbox is selected, the preview no longer updates as you type into the “styles” textarea so it won’t interfere with Firefox accepting keystrokes
  • Clearing the checkbox immediately redraws the preview to render the currently entered styles
  • All value, layout, and style change made in the modal editor are still applied when you press the editor’s “save” button
  • The “hold” checkbox is automatically reset each time you open the modal field editor.

-e

Ciao @EricShulman

Reporting back. All seems to be good on the Pasteup mechanisms.

I have 3 questions mainly regarding purely cosmetic CSS.

  • The grid is, I think, missing a right border-line?

Border

  • Is there a “div” with a “class” for the controls bar? I want to hide it sometimes. I can create a hider myself. I just couldn’t find the right div/class combo.

  • Finally the grid itself—is there a named wrapper for it? Sometimes I want to centre it. I can do that myself. But I couldn’t figure out if there was a class for it’s wrapper.

Grid

Many thanks,
TT

  • re: missing right border… There was an erroneous " + 1" being added to the calulations for the grid width and height. This was left over from some older code where it was needed, but it’s not needed anymore, so I removed it. The right border line now displays properly.

  • re: the “controls bar” in TiddlyTools/PasteUp/View… I’ve added a classname, .tt-pasteup-controls. This classname does not have any default styles associated with it, but is available for use by others so they can apply customizations as desired.

  • re: the “grid wrapper” in Tiddlytools/PasteUp… I’ve added a classname, .tt-pasteup-layout. As with the .tt-pasteup-controls classname, this classname does not have any default styles associated with it, but is available for use by others so they can apply customizations as desired.

enjoy,
-e

3 Likes

Thanks! Very useful!
TT

Interesting, simplified, example of the power of @EricShulman’s PasteUp .

I tested if videos would play at an angle. They do!

Lesson: This tool is Premium Front Control!

A comment
TT


P.S. --- They will also play upside down ...

You might also be interested in playing with the (as yet undocumented) TiddlyTools/PasteUp/Embed macro, which provides a “wrapper” for embedding read-only PasteUp layouts in other tiddler content.

Basic macro syntax is:
<<pasteUpEmbed tiddler:"..." width:"..." height:"..." border:"..." background:"..." nocopy:"...">>

Where:

  • tiddler is the title of the tiddler containing the PasteUp layout you want to display
  • width and height are CSS dimensions (e.g., “50%”, “30em”, “5in”, “40vw”, etc.)
  • border: is a CSS border attribute (e.g., “2px dotted green”) for a box the contains the layout grid
  • background: is either an image tiddler title or a CSS color value (X11, rgb hex, rgb(…) decimal, etc.)
    Note that images are automatically “tiled” to allow use of repeating textures (such as TiddlyTools/Backgrounds/wood.jpg)
  • nocopy: is either “yes” or “no” (default)
    By default, clicking on a field will copy the value of that field to the clipboard. When nocopy is set to “yes”, this behavior is disabled.

You can use this macro to embed a PasteUp layout within other tiddler content and you can wrap the <<pasteUpEmbed ...>> macro inside an HTML div element with whatever styles you like (e.g., “float:right;”)

You can also use pasteUpEmbed as a “template transclusion”, where the macro parameters are set as variables before transcluding, like this:

<$tiddler tiddler="MyLayout">
<$let width="..." height="..." border="..." background="..." nocopy="...">
{{||TiddlyTools/PasteUp/Embed}}
</$let>
</$tiddler>

This makes it easy to use parameters values that are

  • retrieved from “config” tiddlers using regular transclusions
    e.g., width={{MyConfig!!width}}
  • generated dynamically using filtered transclusions
    e.g., height={{{ [{$:/info/browser/screen/height}divide[2]] }}}
  • macro references
    e.g., background=<<colour background>>

enjoy,
-e

You can now visit TiddlyTools/PasteUp to view online documentation including instructions and examples for use.

Please review and let me know if there are any typos or suggested changes/additions to the documentation.

enjoy,
-e

2 Likes

I will comment on docs a bit later …

But the tool deserves much attention!
You can do much with it.

I am using it and trying to understand it’s full power.

Small point … because of the tripartite structure (Data / Layout / Style are separate yet inter-thingied) it gets infinitely flexible.

Meanwhile, yesterday…

TT

Small Cosmetic issue (Chrome on Chromebook) …

TT

Although the “delete” buttons use $action-confirm before actually deleting a field, it seems like a sensible adjustment to avoid triggering the delete action due a “fat finger” usability issue.

Done and updated online.

enjoy,
-e

Right! I forgot to say 83.47% of TW users have FFs. :slightly_smiling_face:

Another small issue.

The option on “Background” tiles (great!) but could we have a “stretch to fill” Option too?

Why? Here is an example where I’ve got stuck in tiling where I need stretch…

TT

Good suggestion… and relatively easy to add!

You can now select “[x] stretch-to-fit” in the PasteUp “settings” (gear) popup. If you are using TiddlyTools/PasteUp/Embed, you can specify bgsize:"100% 100%" to apply stretch-to-fit.

See background-size - CSS | MDN for other values you can use for this parameter.

Get the latest updates here:
TiddlyTools/PasteUp
TiddlyTools/PasteUp/Info
TiddlyTools/PasteUp/Embed

enjoy,
-e

2 Likes