I am trying to add a custom piece of functionality ("module") to quill.js and cannot do this. This is what I need:
If you want to add a button that inserts a template replacement variable ... let's say something like {{company}} at the cursor location in the editor, this is what is currently possible with the API - I thought I could do it using insertText, but I can't get it to work.
thank
You should be able to do this with insertText, but you may need to use getSelection to get the cursor location. The object returned by getSelection will have an index key and a length. Adding a button and the necessary click handler depends on the developer. Note that focus must be returned back to the editor before calling getSelection using focus or just passing true to getSelection.
What I ended up in a very similar setting:
let mergeFieldText = '{{company}}'; var selection = this._quill.getSelection(true); this._quill.insertText(selection.index, mergeFieldText);
Quill.js.
quill:
var quill = new Quill('.editor', { theme: 'snow' });
.
$('.symbols').click(function(){ quill.focus(); var symbol = $(this).html(); var caretPosition = quill.getSelection(true); quill.insertText(caretPosition, symbol); });
Source: https://habr.com/ru/post/1540567/More articles:How to open / endpoint token from Startup.Auth.cs with Identity v2 - c #Pack of consecutive duplicates of list items in sublogs in Prolog - lambdaIn this case, sendto () on a UDP socket returns 0? - c ++app.UseOAuthBearerTokens with ASP.NET Identity 2.0 DbContext middleware? - visual-studio-2013Initializing "final" instance variables - javaWhy the Laravel trashed () method was not found> - phpKnow cache programs - linux'NoMethodError: undefined ΠΌΠ΅ΡΠΎΠ΄ `scan' Π΄Π»Ρ nil: NilClass 'ΠΏΡΠΈ ΡΡΠ½ΠΊΡΠΈΠΎΠ½Π°Π»ΡΠ½ΠΎΠΌ ΡΠ΅ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ Ρ ΡΠ΅Π»ΡΡΠ°ΠΌΠΈ - rubypacman -Syu does not work: invalid pgp key - pacmanΠΠ°ΠΌΠ΅Π½ΠΈΡΡ ΠΏΡΠΎΠΏΠΈΡΠ½ΡΡ Π±ΡΠΊΠ²Ρ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠΌ ΠΏΠΎΠ΄ΡΠ΅ΡΠΊΠΈΠ²Π°Π½ΠΈΡ + ΡΡΡΠΎΡΠ½ΠΎΠΉ Π±ΡΠΊΠ²Ρ Π½Π° Java? - javaAll Articles