利用 Quil Detail处理,核心原理在内存中模拟 Quill.js 的使用
const { convertHtmlToDelta } = require('node-quill-converter'); let htmlString = '<p>hello, <strong>world</strong></p>'; let delta = convertHtmlToDelta(htmlString); console.log(JSON.stringify(delta); // {"ops":[{"insert":"hello, "},{"insert":"world","attributes":{"bold":true}}]}