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.

How to customize toolbar handlers ?

See original GitHub issue

Can I set handlers like this via the option editorToolbar ?

I want to add a custom module and bind to toolbar button, but this option expects the type Array, so got warning.

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
lhoveecommented, Jul 20, 2018

Spent several hours struggling with how to implement a custom toolbar and sharing here in case it helps someone else.

  <!-- in the template -->
  <wysiwyg-toolbar /> <!-- created this seperate vue file -->
  <vue-editor
    id="some id"
    v-model="someEmptyDataString"
    :editorOptions="editorSettings"
  />
<script>
    import WysiwygToolbar from '../wysiwyg-toolbar.vue';

    components: 'WysiwygToolbar,
    data() {
      return {
        editorSettings: {
          modules: {
            history: { 
              delay: 2000,
              maxStack: 500,
              userOnly: true,
            },
            toolbar: {
              container: '#toolbar', // the top level div in WysiwygToolbar has an id="toolbar"
              handlers: {
                customBtn: () => { // just give your custom elements a class like "ql-customThingy" and the handlers will just work
                  console.log("undo button was clicked");
                },
                redo: () => {
                  console.log("redo button was clicked");
                },
              },
            },
          },
        },
       someEmptyDataString: 'this could be default placeholder text if you wanted.',
};
</script>

The part that took me a minute to figure out is that the toolbar component shouldn’t be nested inside the editor component.

6reactions
roberttoltoncommented, May 18, 2018

@halws Thanks for your reply.

I think that’s definitely the right direction, only step now is to get the quill instance from vue-editor?

greetingsEn: () => {
  console.log(this.quill); // undefined
  this.quill.insertText(this.quill.getSelection(true).index, "test");
}

Edit:

Got it using $refs: this.$refs.quillEditor.quill.insertText(this.$refs.quillEditor.quill.getSelection( true ).index, '%greetings-en%');

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toolbar Module - Quill Rich Text Editor
The Toolbar module allow users to easily format Quill's contents. It can be configured with a custom container and handlers.
Read more >
How to Customize Toolbars - Win32 apps | Microsoft Learn
The customization dialog box is provided by the toolbar control to give users a simple way to add, move, or delete tools. Users...
Read more >
Toolbar Customization - Keikai Tutorial
Steps to implement a Toolbarbutton Handler. 1. Create a handler class to implement io.keikai.ui.UserActionHandler; 2. Register our custom handlers via ...
Read more >
How to add custom handlers in react-quill modules when ...
In React-quill, the toolbar contains containers and handlers( see: https://quilljs.com/docs/modules/toolbar/). If you set the toolbar value ...
Read more >
Customizing the Toolbar - Flexmonster
The Toolbar can be customized using the beforetoolbarcreated event. Tabs and buttons can be removed from it and new ones can be easily...
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