Can't get last focused child element
rajat-madaan opened this issue · 1 comments
rajat-madaan commented
I want to get previously focused p element inside the medium editor. Below is the DOM node structure on the browser.
<div class="story-content medium-editor-element" contenteditable="true" spellcheck="true" data-medium-editor-element="true" role="textbox" aria-multiline="true" data-medium-editor-editor-index="1" medium-editor-index="13e73c5b-f038-619c-7913-8a15d4f5c7e6" data-medium-focused="true">
<p class="empty" data-placeholder="Your story...">1</p>
<p class="empty" data-placeholder="Your story...">2</p>
<p class="empty" data-placeholder="Your story...">3</p>
<p class="empty" data-placeholder="Your story...">4</p>
</div>
I have a button outside the editor that appends the image inside this editor. But I have to pass the reference of the previously focused element on which I was in the medium editor before I clicked the button to append the image. I mean, I need to get a paragraph tag with 4 values because that was the last element on which I focused before clicking the button.
Is there any function that can achieve the same?
rajat-madaan commented
I was able to get it by editor.getSelectedParentElement();
method.