1.0.9 • Published 1 year ago

editor-material-parse v1.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

富文本编辑器外链资源解析

安装

    npm install editor-material-parse

使用说明

  1. 示例

        const d = require('./dist/Index')
        const editorMaterial = d.editorMaterial
        const fs = require('fs')
    
        const html = fs.readFileSync('./tests/test.html', 'utf-8');
        const handler = new editorMaterial(html)
        let img = handler.uniqueImgs()
        let data = []
        img.forEach((v,k) =>{
            const tmp = { 'newUrl': k, 'oldUrl': v }
            data.push(tmp)
        })
        const h = handler.replaceAll(data)
        console.log(new editorMaterial(h).allImgs(),img)
        console.log(new editorMaterial(h).uniqueImgs(false))
        import { editorMaterial, replaceData } from './dist/Index'
        import * as fs from 'fs'
    
        const html = fs.readFileSync('./tests/test.html', 'utf-8');
        const handler = new editorMaterial(html)
        let img = handler.uniqueImgs()
        let data:replaceData[] = []
        img.forEach((v,k) => {
            const tmp = { 'newUrl': k, 'oldUrl': v } as never
            data.push(tmp)
        })
        const h = handler.replaceAll(data)
        console.log(new editorMaterial(h).allImgs(),img)
        console.log(new editorMaterial(h).uniqueImgs(false))
        //视频查找替换
        import { editorMaterial, replaceData } from '../src/Index'
        import * as fs from 'fs'
    
        const html = fs.readFileSync('./tests/test.html', 'utf-8');
        const handler = new editorMaterial(html)
        let video = handler.uniqueVideo()
    
        let data:replaceData[] = []
        video.forEach((v,k) =>{
            const tmp = { 'newUrl': k, 'oldUrl': v } as never
            data.push(tmp)
        })
        const h = handler.replaceAll(data)
        console.log('获取到的所有视频',video.length,img)
        console.log('替换后去重',new editorMaterial(h).uniqueVideo(false))

命令解释

版本说明

日期版本说明
2022-12-021.0.1支持富文本图片替换
2022-12-021.0.2去掉typescript依赖
2022-12-051.0.3降低cheerio版本,方便兼容vue 2.0
2022-12-071.0.4添加获取style样式里面的图片连接|
2022-12-221.0.5处理undefined造成的bug
2022-12-221.0.6有些img因为懒加载原因将图片放入data-src中
2022-12-231.0.7新增video资源查找,替换
2022-12-281.0.8新增repalce 方法
1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago