yabwe / medium-editor

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.
https://yabwe.github.io/medium-editor/
Other
16.03k stars 1.85k forks source link

I want to retrieve currently selected text after clicking a button #1579

Closed ct1735x closed 3 years ago

ct1735x commented 3 years ago

Description

I want to retrieve currently selected text after clicking a button. Example when I click on the "bold" button, I want to get the text that has been bolded

I don't know which object or which accessor use I tried MediumEditor.getFocusedElement() , editor.getFocusedElement() , both of them return like my whole html code which is not what I want to do. After clicking, the MouseEvent object has a lot of attributes and I cant seem to find the right one

Any help?