
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@alkhipce/editorjs-aitext
Advanced tools
AI suggestion text Tool for the Editor.js based on the default Paragraph Tool and OpenAI Node.js library.
While writing with this tool you will get some OpenAI suggestion after 2 seconds delay. You can accept or decline it.
Accept suggestion: 'Right or Left ALT buttons'
Decline suggestion: 'Backspace or ESC buttons'
Get the package
npm i @alkhipce/editorjs-aitext
Include module at your application
import AIText from '@alkhipce/editorjs-aitext'
Add a new Tool to the tools
property of the Editor.js initial config.
var editor = EditorJS({
...
tools: {
...
aiText: {
// if you do not use TypeScript you need to remove "as unknown as ToolConstructable" construction
// type ToolConstructable imported from @editorjs/editorjs package
class: AIText as unknown as ToolConstructable,
config: {
// here you need to provide your own suggestion provider (e.g., request to your backend)
// this callback function must accept a string and return a Promise<string>
callback: (text: string) => {
return new Promise(resolve => {
setTimeout(() => {
resolve('AI: ' + text)
}, 1000)
})
},
}
},
}
...
});
Add a new Tool to the tools
property of the Editor.js initial config.
var editor = EditorJS({
...
tools: {
...
aiText: {
// if you do not use TypeScript you need to remove "as unknown as ToolConstructable" construction
class: AIText as unknown as ToolConstructable,
config: {
openaiKey: 'YOUR_OPEN_AI_KEY'
}
},
}
...
});
The AI Text Tool supports these configuration parameters:
Field | Type | Description |
---|---|---|
placeholder | string | The placeholder. Will be shown only in the first paragraph when the whole editor is empty. |
preserveBlank | boolean | (default: false ) Whether or not to keep blank paragraphs when saving editor data |
(DEPRECATED) openaiKey | string | Required parameter |
callback | function | Required parameter. This callback function has to accept a string and return Promise |
Field | Type | Description |
---|---|---|
text | string | paragraph's text |
{
"type": "aiText",
"data": {
"text": "Check out our projects on a <a href=\"https://github.com/codex-team\">GitHub page</a>."
}
}
FAQs
Open AI text tool for Editor.js
The npm package @alkhipce/editorjs-aitext receives a total of 291 weekly downloads. As such, @alkhipce/editorjs-aitext popularity was classified as not popular.
We found that @alkhipce/editorjs-aitext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.