I'm creating a pluging to put all the words in uppercase.
const items = [
{
type: 'menuitem',
text: 'uppercase',
onAction: () => {
const uppercaseContent = editor.dom
.decode(editor.selection.getContent())
.toUpperCase();
editor.insertContent(uppercaseContent);
},
},
];
callback(items);
},
I'm having some issues with this code:
Am I missing something in this code?
Thanks
Whether you lose styles depends on what you have selected. editor.insertContent
will replace the selection completely, which can have undesired side effects with inline styles.
You probably want to dig down to all of the child text nodes in the selection and uppercase those . This isn't easy either, however, as your selection may cover part of a text node (such complexities are the things insertContent
deals with for you).
The development process to achieve changing case reliably is so complex we decided to charge for our solution: https://apps.tiny.cloud/products/case-change/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.