Enhancing Quill Editor with Unique Icons, Such as Undo and Redo Controls Using Vue.js

Currently, I have successfully implemented the functionality of buttons with Vue. However, I am facing an issue in changing their icon, which is currently not displaying anything. How can I resolve this problem?

https://codesandbox.io/s/8lnz3r2n12

<template>
  <div id="app">
    <div>Quill editor</div>
    <div ref="editor"></div>
  </div>
</template>

<script>
import "quill/dist/quill.bubble.css";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import undo_icon from "quill/assets/icons/undo.svg";
import redo_icon from "quill/assets/icons/redo.svg";
import Quill from "quill";

export default {
  name: "App",
  components: {},
  data() {
    let self = this;
    return {
      toolbar_settings: {
        container: [
          ["bold", "italic"],
          [
            {
              undo: undo_icon
            },
            {
              redo: redo_icon
            }
          ]
        ],
        handlers: {
          redo() {
            self.editor.history.redo();
          },
          undo() {
            self.editor.history.undo();
          }
        }
      }
    };
  },
  mounted() {
    const self = this;
    let options = {
      debug: this.debug,
      modules: {
        history: {
          delay: 1000,
          maxStack: 100,
          userOnly: false
        },
        toolbar: this.toolbar_settings
        // this.toolbar,
      },
      placeholder: "placeholder",
      readOnly: false,
      theme: "snow"
    };

    this.editor = new Quill(this.$refs.editor, options);
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

Answer №1

If you want to make it work, just remember to include these 3 lines before defining the options.

var icons = Quill.import("ui/icons");
icons["undo"] = undo_icon;
icons["redo"] = redo_icon;

You can also check out the codepen version here: https://codesandbox.io/s/m34vk57j3x

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

Avoiding code duplication in Angular: tips for optimizing functions

Is there a way to avoid repeating the same for loop for a second variable and use only one? I'm trying to apply the "Don't repeat yourself" method here. Should I consider using an array? JS: var app=angular.module('xpCalc', []); app.c ...

Retrieving all rows from a table using Laravel API and Vue.js

<template> <div class="container"> <div class="row mt-5 mb-3"> <div class="col-md-10"> <h3>Gallery</h3> </div> <div class="col-md-2"> <button class="btn btn-success" ...

What is the best way to check the state of an object using jest and enzyme?

When using jest to test the state of a component, I encountered an issue. The component contains an object and while there is a method in jest called .state(state property), it only returns the entire object in my scenario. Here is an example of how the st ...

Conceal the form after it has been submitted

I am working with the following JavaScript function: var form = $('#review-contact-form'); form.submit(function(event){ event.preventDefault(); var form_status = $('<div class="form_status center"></div>'); $.aj ...

Issue with vuex plugin functionality is not functioning as expected

Objective: I am striving to develop a plugin that configures the header with a token for all requests. Issue: The current plugin is not functioning as expected. Remarks: Consider including the plugin in the storage module. It could potentially impact ...

Displaying Vue v-for data in console.log

One interesting issue arises when printing a list in HTML and checking the output in HTML versus in console.log. It seems that the output is duplicated in the console. After some investigation, I made the following observations: Not showing the product ...

Retrieving information from a nested array transferred to Javascipt / Jquery through JSON from PHP / Cakephp

Apologies for the basic question, but after hours of research, the examples I've found don't seem to fit the context of my array. I've successfully passed data from my CakePHP server to my jQuery JavaScript, but I'm struggling to make s ...

What is the best way to run a series of basic commands in Node.js in sequence

Is there a way to execute 4 bash commands sequentially in nodejs? set +o history sed -i 's/&& !this.peekStartsWith('\/\/')/ /g' dist/vendor.bundle.js sed -i 's/&& !this.peekStartsWith('\/\/ ...

Is it possible to adjust the JavaScript slider effect to transition to a fade effect when the window width drops below 800 pixels?

Is there a way to make my JavaScript slider change its effect from normal to fade when the browser window is less than 800px wide? Any assistance would be greatly appreciated. <ul class="slider"> <li><img src="images/1" alt=" ...

What is the best way to conduct a conditional check across all subsequent visible rows of a table?

When a user clicks inside the text input field and presses either the down or up arrow keys, my JavaScript function is triggered. The purpose of this functionality is to search table values and allow the user to select one by pressing the arrow keys. Every ...

What purpose does process.env.NODE_ENV serve within my Vue.js custom component?

Struggling to develop a custom HTML element using vuejs and vite. Each time I build the element, process.env.NODE_ENV is inserted into the js, causing issues when trying to use the component outside of vuejs. My aim is to create an element that can be util ...

Storing information in a database using Phantomjs

My app is built on phantomjs and here's how it currently operates: 1. A php script retrieves data from my postgres database as an array, 2. The array of data is then passed as an argument to a shell_exec command running a phantomjs script, 3. Phantomj ...

Consistent user interface experience for both Electron and browser users

Can the same index.html file be used by both an Electron process and a browser like Chrome? I have created an app that has its own Hapi server to handle HTTP requests to a database, which is working fine. However, when I try to serve the index.html file f ...

Refresh the div by clicking it

$(window).load(function() { $("#Button").click(function() { alert('clicked') $("#div").load(" #div > *"); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script ...

Creating a script in JavaScript to execute a command or query after midnight

I have a query regarding MongoDB and JavaScript (Express.js). Here is the scenario: I am working on developing a backend service for movies and TV series. I have already set up basic routes and functions. One of my requirements is to select a movie from ...

Upon loading the page, a forward slash is automatically added to the end of the URL

My website has multiple pages of content, but I've noticed a strange issue with the URLs. When I navigate to example.com/guides, a forward slash is automatically added to the address bar, resulting in example.com/guides/. Surprisingly, the page still ...

Struggling to make the javascript function compatible with the drop-down menu

I'm encountering issues with making my JavaScript work properly alongside my HTML. Specifically, I want the "activity" drop-down box to function in conjunction with the "city" drop-down box. For instance, if I choose "Brisbane" and then select an acti ...

What are the reasons behind the lack of clarity in the cache for an ajax request

I am encountering an issue with my external JavaScript file that is supposed to run the home.php file using an Ajax request. Despite adding a random function to the URL to clear the cache, I am still facing issues with caching in my code. Below is the Ja ...

I'm struggling to figure out where I went wrong with the Mongoose unique pre-save validation. What could

I am in the process of developing a User model that requires a unique username. Below is the code snippet for the model: var mongoose = require("mongoose"); var Schema = mongoose.Schema; var UserSchema = new Schema({ username: String, password: ...

When the child state changes the parent state, useEffect may not be triggered for the first time

Component for children export const FlightRange = (props) => { const [value, setValue] = useState(props.value); return ( <> <input type='range' min={1000} max={50000} step="500&quo ...