admin管理员组文章数量:1323200
As you can see, the cursor is within bold characters, so the next character would be bold too. The editor noticed it and activated the bold button on the toolbar.
How can I check the style under cursor in draft.js, just like the above one?
As you can see, the cursor is within bold characters, so the next character would be bold too. The editor noticed it and activated the bold button on the toolbar.
How can I check the style under cursor in draft.js, just like the above one?
Share Improve this question asked Feb 21, 2018 at 13:11 SeareneSearene 27.7k40 gold badges146 silver badges198 bronze badges2 Answers
Reset to default 9I just found out that I could check the style using a one-liner. It works whether there's a selection or not.
editorState.getCurrentInlineStyle().has(style);
function getInlineStylesForCollapsedSelection(editorState, selection) {
if (selection.isCollapsed() === false) {
throw new Error('Selection must be collapsed');
}
return editorState
.getCurrentContent()
.getBlockForKey(selection.getStartKey())
.getInlineStyleAt(selection.getStartOffset());
}
本文标签: javascriptIs there any way to get the style under cusor in draftjsStack Overflow
版权声明:本文标题:javascript - Is there any way to get the style under cusor in draft.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742092511a2420350.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论