reosimgs

1.0.31 • Public • Published

reosimgs

npm version

👀 中文文档

Feature

  • Tinymce Plugin - Format img tag src, background-image url

Description

  • Tinymce version support: 5.0.4+
  • Supported language: Simplified Chinese
  • Repo Author: Kori

Usage

  • Put this repo folder(reosimgs) in the plugins folder under the TinyMCE home directory

  • Example path: public/js/tinymce/plugins/reosimgs

  • In your component page:

    • fetch_new_src is get new src logic function

      • This function takes a url string
      • Need return this Promise response for example:
      {
        "code": 200,
        "msg": "OK",
        "data": {
          "url": "https://newimgrul-asdads21321321asxasx.png"
        }
      }

Init

 initTinymce() {
      window.tinymce.init({
        selector: `#tinymceId`,
        plugins: 'reosimgs',
        toolbar: [
          'reosimgs'
        ],
        width: '100%',
        fontsize_formats: '12px 14px 16px 18px 20px 22px 24px 26px 36px 48px 56px',
        statusbar: false,
        async fetch_new_src(src) {
          return fetch('http://xxxx.com/api/save/image', {
            body: JSON.stringify({ url: src }),
            method: 'POST',
            'Content-Type': 'application/json'
          })
            .then((response) => {
              return response.json()
            })
            .catch((error) => {
              console.error('Failed to fetch image:', error)
              throw error
            })
        },
      })
    },

Readme

Keywords

Package Sidebar

Install

npm i reosimgs

Weekly Downloads

0

Version

1.0.31

License

MIT

Unpacked Size

37.4 kB

Total Files

6

Last publish

Collaborators

  • shanekori