Skip to content

How to: Draggable widgets / blocks #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cp-bwg opened this issue Apr 4, 2025 · 3 comments
Open

How to: Draggable widgets / blocks #360

cp-bwg opened this issue Apr 4, 2025 · 3 comments

Comments

@cp-bwg
Copy link

cp-bwg commented Apr 4, 2025

Thanks for building this @kyoshino - I found you after being disappointed in the media handling of keystatic.

I have been searching but cant find it here in issues. I see that the list widget can be added and dragged around. I was hoping to be able to insert widgets, reorder them. Those widget could be placeholder for my [...page].astro to parse and build into vue components at build time.

Think of it like wanting to insert a toc block, or a cta. I want to put that between two markdown sections.

Short of a draggable widgets, I thought to look at your 0.64 release with the registereditorcomponent. I guess I just dont understand - does this give us items to pick from, in the insert drop down menu in the markdown, where we could put something like "CTA 1", which outputs a string into the markdown? I don't care right now about rendering in the preview, I just want to give shortcuts to my editors to input a CTA element, for example.

It would be even better if adding those custom editor widgets gives me the ability to collect an object of data, with options like color, etc. Similar to how keystatic does it. But I would need to not have this be a single field on the editor, but in a drag/drop and add/remove block type arrangement.

I just wanted to see if this is available and get some context.

@kyoshino
Copy link
Member

kyoshino commented Apr 5, 2025

Glad you found Sveltia CMS! Yes, custom editor components allow you to insert any string into Markdown. And it would be possible to implement draggable components. Sveltia uses the Lexical framework, and when I see the playground, paragraphs and components are draggable/rearrangeable. I’ll check out Keystatic and figure out what’s needed in our Lexical implementation.

@cp-bwg
Copy link
Author

cp-bwg commented Apr 5, 2025

Awesome, I appreciate that. In keystatic, we can create components that can be inserted with the "+" button. When inserting, there are fields configured in that which will configure the output, and that provides the context the component during build.

If you have any example of how to do something like this with the custom editor component, I would really appreciate seeing one. Just something basic like a way to drop in something that lets me set 2-3 fields, and it ends up with those fields output in the markdown (mdx) as a component.

Here's a vid: https://app.screencast.com/Y8B4pzfySkaoE

Dropping in that CTA results in this:

---
title: Test Blog Entry
---
Blah Blah Blah

<CtaCard variant="secondary" heading="Find your stuff" text="Enter your ZIP code">

</CtaCard>


@kyoshino
Copy link
Member

kyoshino commented Apr 5, 2025

Not really MDX, but the Decap CMS doc has an example, and my client site has a few more use cases.

MDX (preview) support is actually the most-voted feature of Netlify/Decap CMS. Will dive into it after Sveltia CMS 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants