question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should we add components instead of scoped slots?

See original GitHub issue

Currently 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:

  1. In the menububble slot we have to add a check for marks and nodes like this <div v-if="marks">. For one tick these values are null. 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.
  2. 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:closed
  • Created 5 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
qyloxecommented, Sep 26, 2018

@philippkuehn thanks! surely I plan to contribute something, because your work is remarkable and… enlightening 😉

4reactions
philippkuehncommented, Sep 26, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found