I want to allow the user to paste the contents of one quill editor to another, and the pasted contents is block-quoted with a reference header. The code (typescript in angular) looks like this:
const header = new Delta().insert('The following is a quote from xxxx\n', 'blockquote');
const cursor = this.editor.getSelection();
const start = cursor ? cursor.index : 0;
const paste = wbe.editor.getContents(wbe.selection.index, wbe.selection.length);
const delta = new Delta().retain(cursor.index).concat(header).concat(paste);
this.editor.updateContents(delta, 'api');
const length = delta.length(); // this is not the right value
this.editor.setSelection(start, length);
this.editor.format('blockquote', 'true');
The length() function doesn't return what I want, which is the number of inserted characters. Is there a function that does this or do I have to iterate through the delta to count them?
I want to allow the user to paste the contents of one quill editor to another, and the pasted contents is block-quoted with a reference header. The code (typescript in angular) looks like this:
The length() function doesn't return what I want, which is the number of inserted characters. Is there a function that does this or do I have to iterate through the delta to count them?