Skip to content
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

How to use visual editor with custom components? #901

Open
1 task done
abranhe opened this issue Mar 25, 2024 · 4 comments
Open
1 task done

How to use visual editor with custom components? #901

abranhe opened this issue Mar 25, 2024 · 4 comments
Labels
enhancement [Issue][PR] New feature pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

Comments

@abranhe
Copy link

abranhe commented Mar 25, 2024

Description

The library has the storyblokEditable action which allow the component to be used in the visual editor by adding this:

node.setAttribute("data-blok-c", options["data-blok-c"]);
node.setAttribute("data-blok-uid", options["data-blok-uid"]);
node.classList.add("storyblok__outline");

to the HTML element.

If the person wants to use a custom UI library, storyblokEditable won't work because actions cannot be used on components. There for something like this won't work:

<script lang="ts">
import { storyblokEditable } from '@storyblok/svelte';
import { Button } from 'my-reusable-ui-library';

export let block;
</script>

<Button use:storyblokEditable={blok} title={blok.title}/>

Is there a workaround for this, or another way to implement it on custom components?

Additional context

No response

Validations

@abranhe abranhe added enhancement [Issue][PR] New feature pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Mar 25, 2024
@josefineschaefer
Copy link
Collaborator

Hi @abranhe, Thank you for your message and sorry for the delay. We will get back to you shortly.

@HalCodes
Copy link

HalCodes commented Apr 30, 2024

My workaround is using a wrapper div

<div use:storyblokEditable={blok}>
  <Button title={blok.title}/>
</div>

@josefineschaefer
Copy link
Collaborator

Thanks for sharing @HalCodes!

@roberto-butti
Copy link
Contributor

Hi @abranhe , I see your question here, I just had the same problem with another framework (not Svelte, but the concept is the same), I solved it as shown by @HalCodes (super!), putting a div wrapper.
The problem here is that the custom component provided by the library doesn't pass and render in the HTML element the extra parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [Issue][PR] New feature pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

4 participants