Applying Vue Quill CSS to the initial Quill Editor component exclusively and tips for personalizing the toolbar

I have encountered an odd CSS issue while using the vue-quill package in my project. Each comment has its own quill editor for replying, and I temporarily set the isOpen prop to true for debugging purposes. This results in a quill editor being displayed underneath every comment by default.

However, I noticed that the snow theme CSS is only applied to the first quill editor, and all subsequent ones are left unstyled.

Let's take a look at my CommentList.vue component:

<template>
  <div id="comments">
    <p class="font-semibold mb-3">Comments</p>
    <div v-if="comments" v-for="comment in comments">
      <CommentListItem :comment="comment" :key="comment.id" />
    </div>
  </div>
</template>

Here's the CommentListItem.vue component structure:

<template>
  <div :id="'comment-' + props.comment.id">
    <div>
      {{ props.comment.content }}
    </div>
    <util-quill v-model:is-open="isOpen" :comment-id="props.comment.id"></util-quill>
  </div>
</template>

And now, let's dive into the UtilQuill.vue component details:

<template>
  <div v-if="isOpen" class="quill-editor-wrapper">
    <QuillEditor toolbar="#toolbar" theme="snow">
      <template #toolbar>
        <div id="toolbar">
          <button class="ql-image"></button>
          <button class="ql-link"></button>
        </div>
      </template>
    </QuillEditor>
  </div>
</template>

<script>
import { QuillEditor } from '@vueup/vue-quill'

// CSS styles
import 'quill/dist/quill.snow.css'

export default {
  props: ['isOpen'],
  setup: (props, { emit }) => {
    return { isOpen: props.isOpen };
  },
  components: {
    QuillEditor,
  },
};
</script>

I attempted importing the snow theme in my main.scss file within my Nuxt 3 project but the issue remains unresolved. Only the first quill editor appears styled. What could be causing this behavior?

In an effort to troubleshoot, I removed my UtilQuill.vue component and placed the QuillEditor directly inside the v-for loop of my CommentListItem.vue component. Unfortunately, the outcome was unchanged.

It's worth noting that the snow theme CSS should apply universally to all quill editors based on classes, not IDs, which implies that styling should propagate to each instance.

If you have any insights or suggestions on how to rectify this issue, please share them. I've created a playground to demonstrate the problem – feel free to check it out.

Answer №1

It appears that the theme is working well based on my observations. I'm unsure if it would be better to use `import '@vueup/vue-quill/dist/vue-quill.snow.css';`, as it bears a striking resemblance to the theme showcased here.

Regarding the main issue, it seems that the plugins are targeting only #toolbar, but HTML can only have one unique id per page. One potential solution could involve incorporating an offset id for each iteration.

Everything seems to be functioning correctly.

util-quil.vue

<script setup>
import { QuillEditor } from '@vueup/vue-quill';
import '@vueup/vue-quill/dist/vue-quill.snow.css';

const props = defineProps(['value']);
</script>

<template>
  <div>Value index >> {{ props.value }}</div>
  <div class="quill-editor-wrapper">
    <QuillEditor :toolbar="`#toolbar-${props.value}`"></QuillEditor>

    <div :id="`toolbar-${props.value}`">
      <!-- Add buttons as you would before -->
      <button class="ql-bold"></button>
      <button class="ql-italic"></button>

      <button id="custom-button">custom</button>
    </div>
  </div>
</template>

app.vue

<template>
  <div v-for="n in 10">
    <p>I am the random comment text...</p>
    <util-quill :value="n" />
  </div>
</template>

For an updated repro, visit this functional link.

While I lack experience with Quill, it seems like the approach taken is quite functional and robust.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing CSS to Implement a Background Image

Here is where I am looking to upload the image. Ideally, I would like to position my image to the left side of the text related to Food and Travel. You can view the image here. .block-title h3 { color: #151515; font-family: 'Montserrat', s ...

What is the best way to apply box shadow to a particular region using CSS?

I am looking to add a box shadow using CSS, but I only want it in a certain area of the box. https://i.sstatic.net/dcFZu.png In the screenshot above, you can see that I have a blue header on my website. I would like to add a shadow to this header, specifi ...

JavaScript: what is the method to add a paragraph when the condition is not met?

I am currently working on a project that involves checking if a student is actively engaged in an online journal. This is done by tracking the student's progress using a unique userId. If the student's userId is not found in the JSON data returne ...

Tips for retrieving the output from an Azure Function

Just getting started with Azure Functions and I have this code snippet: module.exports = function (context, req) { context.log('JavaScript HTTP trigger function processed a request.'); context.log(context.req.body.videoId) ...

Is there a way to deactivate other dropdown options?

To simplify the selection process, I would like to disable the options for "Province", "City", and "Barangay". When the user clicks on the "Region" field, the corresponding "Province" options should be enabled. Then, when a specific province is selected, t ...

What is the reason for the index.html file not connecting to the local .css files and .js file?

I'm currently using node.js to send an .html file that includes the following tags: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="This is my personal profile website" /> <link r ...

Interactions with the mouse while using the window.alert and window.confirm features

Currently, I have developed a custom drag method that utilizes mousedown, mouseup, and mousemove events. This method is defined as move(). $(document).on('mousedown', function() {drag = true }); $(document).on('mouseup', function() {dr ...

Web scraping with Cheerio in Node.js sometimes yields undefined results

When attempting to extract data from NSE website, I initially tried using the inspect element console: (Edited the question) https://i.sstatic.net/Xq8mZ.png objs = $('div[class="table-wrap"] > table > tbody > tr > td').slic ...

Directive customization through comprehension expressions

Python is where I spend a lot of my time, so I'm really drawn to the comprehension_expression syntax within Angular's ngOptions. However, I would love to see this syntax extend to other inputs, such as with an ng-list. For instance, let's s ...

Leveraging anonymous functions within an IF statement in JavaScript

Can you explain how to implement an anonymous function within an if statement? Feel free to use the provided example. Thank you if(function(){return false;} || false) {alert('true');} For more information, visit https://jsfiddle.net/san22xhp/ ...

Is there a way to verify if all the values in an array of objects are identical?

In this scenario, my array consists of entries with identical address IDs but different phone types and numbers. I am in need of assistance with iterating through the array to extract the phone type and number when the address ID matches. I seem to encount ...

Update the class information using jQuery after performing an action and serialize the button's ID for AJAX requests

I'm facing an issue with two buttons on my page: <td> <button id="1" class="green-button">Publish</button> <button id="1" class="yellow-button">Delete</button> </td> The green-button and red-button have different ...

Is it possible to locate and eliminate the apostrophe along with the preceding letter?

My objective is to tidy up a character string by removing elements that are not essential for the user and SEO, specifically the (letter before the apostrophes) in this case. I am looking for a regex solution or explanation of how to achieve this in PHP, a ...

What could be causing the lack of change in direction for the initial function call?

There appears to be an issue with image(0) and image(1) in this array that I can't quite understand. The console output shows: i=5; div class="five" id="slides" i=0; div class="one" id="slides" i=1; div class= ...

Improvement in Select2 Change Event: Update the subsequent select2 box options based on the value change in the preceding select2 box

I need assistance with two select boxes, namely Category and Sub-category. My objective is to dynamically alter the available options in the subcategory box based upon the value selected in the category box. Additionally, I would like to load data for the ...

Is there a substitute for bootstrap select in Rails?

In order to style select tags with Bootstrap, we had to utilize the gem: bootstrap-select However, due to the high volume of options in our data-heavy application, the select dropdowns are causing significant slowdown (loading times, drop down performance ...

Ways to evaluate two sentences based solely on the spacing in their dynamic sections

I am tasked with comparing two sentences. The first sentence is stored in a database and looks like this: var text1 = "Dear {#dynamic#} {#dynamic#} Welcome to MAX private ltd" The second sentence, which comes from the customer, is as follows: &q ...

Sharing environment variables between a React app and an Express.js server that hosts it as a static site can be achieved by setting

My static site react app is hosted under an express server project in a folder called client/build. The oauth redirect uris point to the express server for token retrieval. The react app redirects users to the oauth endpoint, which is also referenced by th ...

Utilizing jQuery for displaying or hiding list elements

To view all the code, click on this link: http://jsfiddle.net/yrgK8/ A section titled "news" is included in the code snippet below: <ul id="news"> <li><p>asfdsadfdsafdsafdsafdsafdsafdsafdsa</p></li> <li>&l ...

How can I stop my browser from recalling text field data?

Similar Question: Is there a W3C compliant method to disable autocomplete in an HTML form? How can I stop a browser from remembering the text field's content? The issue arises when the field has a value like 100, followed by a currency symbol suc ...