storyblok-rich-text-renderer icon indicating copy to clipboard operation
storyblok-rich-text-renderer copied to clipboard

How to change the `attrs` prop name

Open avaldevilap opened this issue 2 years ago • 6 comments

In my current project, we're already using the prop name of blok. There's any way in the configuration for changing the prop attrs by blok?

<template>
  <div v-editable="blok" class="divider" />
</template>

<script>
export default {
  props: {
    blok: {
      type: Object,
      required: true,
    },
  },
};
</script>

avaldevilap avatar Jun 21 '22 09:06 avaldevilap

Hi. Did you create this issue in the wrong repo? This is specifically for the rich-text-renderer that @m4rvr has created. From your comment, it looks like you are talking about the storyblok components rather than the renderer?

SebbeJohansson avatar Jun 21 '22 16:06 SebbeJohansson

I'm having trouble rendering components inside of rich text renderer

avaldevilap avatar Jun 22 '22 14:06 avaldevilap

@avaldevilap Wouldnt that be related to these? https://github.com/m4rvr/storyblok-rich-text-renderer/pull/15 https://github.com/m4rvr/storyblok-rich-text-renderer/issues/6

SebbeJohansson avatar Jun 22 '22 19:06 SebbeJohansson

I'm having the same issue.

The problem is the prop is passed as attrs described in the first part of https://storyblok-rich-text-renderer.netlify.app/vue-plugin/resolvers/: (Every component gets an attrs prop value which contains the attributes (if there are any) from Storyblok like the level of your HEADING or the src of your IMAGE. ✌️)

so if your accepts a prop blok instead of a prop named attrs, you get an error that the component expects a prop named blok

We're wondering if there's a way to change the prop name passed to components that wouldn't require a rewrite to adhere to just this plugin.

DEV-ONI avatar Jun 23 '22 02:06 DEV-ONI

We're having the same issue. Has anyone already found a workaround? :)

jony1993 avatar Oct 27 '22 19:10 jony1993

@jony1993 i managed to work around the issue of rendering components in richtext with this solution: https://gist.github.com/SebbeJohansson/31b64c5c4f914abfec2660210ec7795a

SebbeJohansson avatar Oct 28 '22 14:10 SebbeJohansson