-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Like craftdocs/craft-extension-inspirations#6, I am also getting behaviour (macOS app 2.1.6) where getTextSelection seemingly succeeds but returns the empty string.
const selection = async () => {
const response = await craft.editorApi.getTextSelection();
if (response.status !== "success") throw new Error(response.message);
let selectedText = response.data;
if (selectedText.length === 0) selectedText = "Text selection is of len 0.";
const block = craft.blockFactory.textBlock({
content: selectedText
});
craft.dataApi.addBlocks([block]);
}
Consistently creates a block with Text selection is of len 0., regardless of I have text selected (which I would assume would give me the selected text) or if I don't have any selection. The latter seems like an API oversight, as I would have intuitively assumed that status fails on no selection.
I wanted to build a small capitalisation utility, but I don't see how you can do that without something as granular as getTextSelection.
NaanProphet
Metadata
Metadata
Assignees
Labels
No labels