Should we add components instead of scoped slots?
See original GitHub issueCurrently we’re using scoped slots for content and menus.
<editor>
<!-- Content goes here -->
<div slot="content" slot-scope="props">
<p>some text</p>
</div>
<!-- Render menubar -->
<div slot="menubar" slot-scope="{ nodes }">
<div v-if="nodes">
<button @click="nodes.heading.command({ level: 1 })">
H1
</button>
</div>
</div>
<!-- Render menububble -->
<div slot="menububble" slot-scope="{ marks }">
<div v-if="marks">
<button @click="marks.bold.command()">
Bold
</button>
</div>
</div>
</editor>
There are two limitations for doing so:
- In the menububble slot we have to add a check for
marks
andnodes
like this<div v-if="marks">
. For one tick these values arenull
. It would be nice to render these slots only when these values are available but then we do not have access to the DOM element of this slot which is required for the menububble plugin. - Nested markup is not supported.
Maybe it would be nice to use components like this:
<editor>
<!-- Content goes here -->
<editor-content>
<p>some text</p>
</editor-content>
<!-- Render menubar -->
<editor-menubar>
<template slot-scope="{ nodes }">
<button @click="nodes.heading.command({ level: 1 })">
H1
</button>
</template>
</editor-menubar>
<!-- Render menububble -->
<editor-menububble>
<template slot-scope="{ marks }">
<button @click="marks.bold.command()">
Bold
</button>
</template>
</editor-menububble>
</editor>
But I’m not sure how these components will work together and sync its editor state. With provide
and inject
or an event bus or passing props? 🤷♂️
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
The Difference Between Props, Slots and Scoped Slots in Vue.js
We have seen many ways of passing data between components, it depends on your needs whether to use props or slots. With props,...
Read more >Reusing Logic with Scoped Slots - Michael Thiessen
Scoped slots let you push logic into a child component, so it can be reused across multiple components. But first we're going to...
Read more >Slots - Vue.js
We have learned that components can accept props, which can be JavaScript values of ... Slot content has access to the data scope...
Read more >A Guide to Vue Slots - LearnVue
Simply put, scoped slots allow our slot content in our parent component to have access to data that's only found in the child...
Read more >Getting Your Head Around Vue.js Scoped Slots
To allow us to do this, we'll use a scoped slot instead of a regular slot. Scoped slots allow you to pass a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@philippkuehn thanks! surely I plan to contribute something, because your work is remarkable and… enlightening 😉
@qyloxe Thanks for your input! I do not like to configure everything as long arrays via props. That‘s the way most of all editors are configurable and that‘s why I started creating tiptap 🙌 For me it‘s very important to have full control over markup because you can use text editors for so many different use cases today, that it differs to much.