Insert Date extension

Hi everyone, I decided to have a play around with Craft X and made an “Insert Date” plugin. It shows a calendar in the extension sidebar and lets you insert the selected date. This date is linked to the daily note for that day. It’s how the /date command works but has more options than just today, tomorrow, yesterday.

Code repo:

You can download the .craftx file from https://github.com/deadlyhifi/craft-x-insert-date/releases/download/v1.0.0/insert-date-extension-tdb.craftx

Taken from the readme…

Note that it doesn’t really work on the web. Yes, it inserts a date, but it doesn’t link properly. This is a bug/ not yet implemented feature in Craft Web and the issue also exists with the official /date commands.

4 Likes

Useful extension. Thanks. Is there a way to have it insert at the cursor, rather than create a new block?

1 Like

Just installed it aswell!
Same here: it makes it way easier to insert a date-badge :star_struck:

Two remarks:

  • i support @shryn here: insert the date at the cursor would be (actually way more) useful for me aswell. :pray:
  • just a design thing: the colors in the head of the “insert date”-Extensions doesn’t suit well into to rest of the shades of grey design of craft.
    actually this is generally interesting. i also got an issue with the blue X. maybe pick one of the four colors of the craft icon?! however, this is your extension and so your choice. it was just my humble opinion if this is fine for you! if you need support (some concrete proposals), let me know.
    thanks!

Yes this date bug also affects iOS apps.

Thanks everyone for checking it out. It was definitely me just having a play around with the API. I agree completely about inserting the date at the cursor rather than adding a new block. I’ll see if I can figure out how to do it.

Also, the calendar itself, I used a web-component, and it was the first one that I found that worked. This also meant I wasn’t really able to amend the colours due to not being able to reach into the shadow DOM. I was hoping to use the browser default month picker but unfortunately the webview inside Craft doesn’t have any browser replacements for inputs. (Sorry if that got a bit techy).

Now that I know it’s of use to others I’ll spend some time rewriting it - probably in React so I have access to a bigger range of calendars. I’ve also got a few other ideas.

2 Likes

:heart_eyes: sounds great - looking forward to… :partying_face:

Cool :+1:. I look forward to trying what you come up with.

v1.1.0 Minor update available - the date is now inserted in a new block after the current cursor position. If there is no block selected it’ll be added to the end of the document. Not quite what was desired but a step in the right direction.

Cursor position isn’t available, only the current block, so it can’t be inserted where the cursor is. I’m thinking to develop it further I could copy the current block content, add the date at the end, and put the block back (using updateBlocks).

Get Version 1.1.0.

2 Likes

Thanks for the update! Works :partying_face:

1 Like

Well done! This is great.

1 Like

I’m after your opinion.

The current insert date behaviour is “click on the date you want”, followed by a click on the “Insert date” button. Would it be better if clicking on the date inserted the date - therefore removing a step?

Indeed it would if possible :slight_smile:

Version 2 is out.

  • New calendar that follows the design of Craft more closely.
  • Date is inserted by clicking on the date desired (no more selecting a date and then clicking insert)

Get Version 2.0.0.

1 Like

works perfectly smooth. thanks for the effort!

1 Like

this was exactly what I came here looking for! :heart_eyes_cat:
I was wondering if its possible to get it to where it will auto-fill over on the calendar side
the content that the date was added to in a Daily Note?
or does it already do that and I haven’t figured that out yet?
thank you for making this! this is sooo useful!

It won’t copy the text that you create in a normal into the daily note - if that’s what you mean - but on the daily note there will be a link back to the normal note under the Links to this page section.

That’s all part of the default Craft functionality - this plugin just allows you to insert a date beyond what Craft has let you do via the slash menu.