npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

strapi-plugin-prompt-editor

v1.0.3

Published

This editor is capable of integrating with AI, enhancing your writing and editing experience.

Downloads

7

Readme

strapi-plugin-prompt-editor

Stylish editor that works with ChatGPT and Gemini

Demo

demo ss1 ss2

Setup

install

npm i strapi-plugin-prompt-editor

edit config

# config/plugins.js
...
 'prompt-editor': {
    enabled: true,
    config: {
      openai_api_key: process.env.OPENAI_API_KEY,
      gemini_api_key: process.env.GEMINI_API_KEY
    }
  },
...

add Custom Field

upload role

required role permission

To generate images or upload them to a folder other than the root folder, the following permissions are required.

  • Access the Media Library
  • Create (upload)

upload role

Setting the admin panel

You can change the default settings for model and image size. admin_setting

Change the model you can select

Selectable models can be changed from config.

// example
'prompt-editor': {
  enabled: true,
  config: {
    openai_api_key: process.env.OPENAI_API_KEY,
    gemini_api_key: process.env.GEMINI_API_KEY,
    chatGPTTextModels: [
      'gpt-4o',
      'gpt-4o-mini',
      'gpt-4',
      'gpt-3.5-turbo'
    ],
    chatGPTImageModels: [
      {
        name: 'dall-e-2',
        size: [
          '256x256',
          '512x512',
          '1024x1024'
        ]
      },
      {
        name: 'dall-e-3',
        size: [
          '1024x1024',
          '1792x1024',
          '1024x1792'
        ]
      }
    ],
    geminiTextModels: [
      'gemini-1.5-flash',
      'gemini-1.5-pro',
      'gemini-1.0-pro',
    ]
  }
}

Customize API response

The fields of prompt-editor are in JSON format by default when retrieved through the API.

Therefore, we recommend implementing middlewares and converting them to HTML.

npm i @blocknote/server-util

ex) src/api/article/middlewares/content-converter.ts


import {Strapi} from '@strapi/strapi';
import {ServerBlockNoteEditor} from "@blocknote/server-util";

export default (config, {strapi}: { strapi: Strapi }) => {
  return async (ctx, next) => {
    await next()

    const editor = ServerBlockNoteEditor.create();
    const data = structuredClone(ctx.response.body.data)
    const convertToHTML = async (item: any) => {
      if (item.attributes.content === null) {
        item.attributes.content = ''
      } else {
        try {
          const block = JSON.parse(item.attributes.content)
          item.attributes.content = await editor.blocksToHTMLLossy(block)
        } catch (e) {
          console.error(e)
        }
      }
      return item
    }
    ctx.response.body.data = await Promise.all(data.map(item => convertToHTML(item)))
  }
}

Thanks

The editor of this plugin is based on BlockNote.

https://www.blocknotejs.org/