aecreations / clippings

Clippings: an extension for Mozilla Firefox
20 stars 4 forks source link

Preset placeholder: clipping in clipping #467

Closed aecreations closed 4 days ago

aecreations commented 4 months ago

New built-in (preset) placeholder, $[CLIPPING(clipping)], for inserting a clipping into a clipping. The argument to the placeholder name is the name of the clipping to insert.

Referencing the clipping by its name, e.g. $[CLIPPING(Reply to customer inquiry)], may be the most user friendly approach, except that clipping names can be long, and there could be more than one clipping with the same name. As for IndexedDB database lookups, the name field in the clippings data store is already being indexed, so there's no concern about performance.

If there are more than one clipping by that name, then the first clipping that is found via the IndexedDB lookup is used. If a clipping by that name doesn't exist, then the placeholder should be inserted as is.

Recursion won't be supported - i.e., a clipping contains a placeholder for inserting a clipping, which itself contains a placeholder for inserting another clipping, and so on. The clipping referenced by this placeholder should only be processed once. But any placeholders that exist in the inserted clipping will be processed along with any other placeholders in the containing clipping.

When processing placeholders, clipping in clipping placeholders should be processed first before any other presets and custom placeholders.

Clippings Manager UI:

aecreations commented 4 months ago

If a clipping is renamed, it would invalidate all its references in clipping-in-clipping placeholders, and it would be an annoyance for the user to have to hunt for all the clippings and fix them.

Consider adding ability to scan for clippings that references the renamed clipping and ask the user if they want to update them. This should happen when a clipping is renamed and the clipping is referenced in other clippings via the $[CLIPPING(...)] placeholder.

Alternatively, the automatic scan-and-fix could happen automatically, and could be turned on or off via a pref.

aecreations commented 4 months ago

Clippings Manager UI:

aecreations commented 4 months ago

When pasting a clipping containing a clipping-in-clipping placeholder, keep track of those that couldn't be expanded because the clipping references are invalid. Then show a popup window to the user listing the placeholders that couldn't be expanded, and give the option to open Clippings Manager, proceed with pasting the clipping, or cancel.

Future enhancement: Check Clipping In Clipping Placeholders - a Clippings Manager utility which processes all clippings for clipping-in-clipping placeholders, checking that their references are still valid.

aecreations commented 4 months ago

UI string: Name of clipping to insert Description in messages.json: Default argument for the clipping-in-clipping placeholder - appears as $[CLIPPING(Name of clipping to insert)]

aecreations commented 2 months ago

Remaining ideas for this feature will be pursued as enhancements for a future release: