craftdocs / craft-extension-api Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.