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.

Insert delta where the cursor is

See original GitHub issue

Hi there, I am using updateContents to insert the delta for an iframe for a video, and would like to enter the iframe delta where the cursor is. However, right now the iframe is always inserted at the top of the editor using updateContents.

Steps for Reproduction

Here is the code for it -

                  const addVideoRange = this.editor.getSelection();
                  const newRange = addVideoRange !== null ? addVideoRange.index : 0;
                  // get the iFrame
                  const safeHtml = this.embedService.embed(url, {
                    attr: { width: 600, height: 400 },
                  });
                  // converting safeHTML to Delta to insert into the Quill editor
                  const delta = this.editor.clipboard.convert(safeHtml.changingThisBreaksApplicationSecurity);
                  // "silent" source so selection-change event is not emitted
                  this.editor.updateContents(delta, 'silent');
                  this.editor.setSelection(1 + newRange);

Here is how I want it to work (insertEmbed embeds the video where the cursor is) -

                  const addVideoRange = this.editor.getSelection();
                  const newRange = addVideoRange !== null ? addVideoRange.index : 0;
                  this.editor.insertEmbed(newRange, 'video', url);
                  this.editor.setSelection(1 + newRange);

Expected behavior: For the video iFrame to be embedded where the cursor is, the way insertEmbed works.

Actual behavior: The iFrame is embedded in the beginning of the document.

Note that I cannot use insertEmbed because I have to insert html/delta.

Version: 1.3.7

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
anis8commented, Jan 26, 2022

quill.updateContents(new Delta().retain(cursorIndex).concat(myDeltas))

0reactions
OMartinez-NeTcommented, Nov 8, 2022

@anis8 how do you know this? it is not in the docs from what I can see?

https://quilljs.com/docs/api/#api

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Insert or Type the Delta Symbol in Word (Δ or δ)
Position the cursor in the document where you want to insert the Delta symbol. Click the Insert tab in the Ribbon. In the...
Read more >
How to Insert Delta Symbol in Excel & Google Sheets
Hold down the Alt key, then type ALT + 30, to insert the delta (Δ) symbol into Excel. For lowercase delta, type ALT...
Read more >
Setting the cursor position after setting a new delta in Quill
I'm trying insert a new sentence to a Quill's delta when an edit is made to the Quill, all the while retaining the...
Read more >
Cannot add delta marker between horizontal cursor just as ...
If you click on the arrow between the two lines and drag in a horizontal direction (to the right), you should see the...
Read more >
Using Mouse Cursor + Delta To Play a Game ... - YouTube
It started as a silly meme but I wanted to see if I COULD actually get something working through move mouse cursor and...
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