editor-material-parse
v1.0.9
Published
富文本编辑器外链资源解析
Downloads
4
Readme
富文本编辑器外链资源解析
安装
npm install editor-material-parse
使用说明
示例
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-02|1.0.1|支持富文本图片替换| |2022-12-02|1.0.2|去掉typescript依赖| |2022-12-05|1.0.3|降低cheerio版本,方便兼容vue 2.0| |2022-12-07|1.0.4|添加获取style样式里面的图片连接| |2022-12-22|1.0.5|处理undefined造成的bug| |2022-12-22|1.0.6|有些img因为懒加载原因将图片放入data-src中| |2022-12-23|1.0.7|新增video资源查找,替换| |2022-12-28|1.0.8|新增repalce 方法|