1.0.5 • Published 2 years ago

diff-html-content v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

diff-html-content

基于谷歌的 diff-match-patch 实现,node 环境下不支持

  • 默认 value 会过滤掉 非 img、video 标签
  • 默认 preValue 会过滤掉所有 html 标签
// npm 镜像资源引入
import { diffHtmlContent } from "diff-html-content"
const value = "111"
const preValue = "1111"
const renderHtml = diffHtmlContent(value, preValue)
<!-- cdn 资源引入 -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="./dist/js/index.js">
  </script>
  <script>
    const { diffHtmlContent } = window.diffHtmlContent
    // console.log(window.diffHtmlContent("11", "111"))
    var preValue = `
    <div id="articleContainer" style="height: auto; overflow: visible;">
      1234
    </div>`;
    var value = `
    <div id="articleContainer" style="height: auto; overflow: visible;">
      56789
    </div>`;
    const strHtml = diffHtmlContent(value, preValue)
    // console.log(JSON.stringify(strHtml))
    document.body.innerHTML = strHtml
  </script>
</body>

</html>
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago