@x-oasis/diff-match-patch 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+
2
+ > diff-match-patch-example@0.1.0 build /home/runner/work/x-oasis/x-oasis/packages/diff/diff-match-patch/examples
3
+ > vite build
4
+
5
+ vite v4.1.4 building for production...
6
+ transforming...
7
+ ✓ 266 modules transformed.
8
+ rendering chunks...
9
+ computing gzip size...
10
+ dist/index.html  0.52 kB
11
+ dist/assets/index-2c456c5a.css  21.67 kB │ gzip: 3.94 kB
12
+ dist/assets/index-188207e4.js 1,242.18 kB │ gzip: 391.97 kB
13
+ 
14
+ (!) Some chunks are larger than 500 kBs after minification. Consider:
15
+ - Using dynamic import() to code-split the application
16
+ - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
17
+ - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
@@ -0,0 +1,86 @@
1
+ # Examples
2
+
3
+ 这个目录包含 `@x-oasis/diff-match-patch` 的交互式示例。
4
+
5
+ ## 运行示例
6
+
7
+ 这是一个基于 Vite + React 的项目。
8
+
9
+ ### 安装依赖
10
+
11
+ 在项目根目录运行:
12
+
13
+ ```bash
14
+ pnpm install
15
+ ```
16
+
17
+ ### 启动开发服务器
18
+
19
+ 在 `examples` 目录下运行:
20
+
21
+ ```bash
22
+ cd packages/diff/diff-match-patch/examples
23
+ pnpm install
24
+ pnpm dev
25
+ ```
26
+
27
+ 或者从项目根目录运行:
28
+
29
+ ```bash
30
+ pnpm install
31
+ cd packages/diff/diff-match-patch/examples
32
+ pnpm dev
33
+ ```
34
+
35
+ 开发服务器将在 `http://localhost:3000` 启动,并自动在浏览器中打开。
36
+
37
+ ### 构建生产版本
38
+
39
+ ```bash
40
+ pnpm build
41
+ ```
42
+
43
+ ### 预览生产构建
44
+
45
+ ```bash
46
+ pnpm preview
47
+ ```
48
+
49
+ ## 功能说明
50
+
51
+ 示例页面包含以下功能:
52
+
53
+ 1. **文件对比**: 并排显示原始文件和修改后的文件
54
+ 2. **差异可视化**: 使用颜色编码显示差异
55
+ - 绿色: 新增的内容 (INSERT)
56
+ - 红色: 删除的内容 (DELETE)
57
+ - 灰色: 相同的内容 (EQUAL)
58
+ 3. **恢复操作**:
59
+ - 输入 offset range (startOffset, endOffset)
60
+ - 点击"恢复"按钮将指定范围恢复到原始版本
61
+ - 显示详细的调试信息
62
+ 4. **快速示例**: 提供预设的 offset range 按钮,快速测试不同场景
63
+
64
+ ## 示例场景
65
+
66
+ ### 场景 1: 恢复 "禁用" → "禁用按钮"
67
+
68
+ - startOffset: 1512
69
+ - endOffset: 1514
70
+ - 说明: 将 codev2.vue 中的 "禁用" 恢复为 code.vue 中的 "禁用按钮"
71
+
72
+ ### 场景 2: 恢复整个按钮区域
73
+
74
+ - startOffset: 1416
75
+ - endOffset: 1512
76
+ - 说明: 恢复包含按钮的整个区域
77
+
78
+ ## 技术实现
79
+
80
+ 示例使用:
81
+ - **Vite**: 快速的前端构建工具
82
+ - **React**: UI 框架
83
+ - **TypeScript**: 类型安全
84
+ - **@x-oasis/diff-match-patch**: 核心库,提供 `FileRestoreManager` 类
85
+ - **diff-match-patch**: 差异计算库
86
+ - **@git-diff-view/react**: 差异可视化组件(样式)
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Diff Match Patch - Restore Range Example</title>
7
+ <link rel="stylesheet" href="https://esm.sh/@git-diff-view/react@latest/styles/diff-view.css">
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "diff-match-patch-example",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "react": "^18.2.0",
13
+ "react-dom": "^18.2.0",
14
+ "@git-diff-view/react": "latest",
15
+ "@git-diff-view/file": "latest",
16
+ "diff-match-patch": "^1.0.5"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^18.2.0",
20
+ "@types/react-dom": "^18.2.0",
21
+ "@vitejs/plugin-react": "^4.2.1",
22
+ "vite": "^4.1.4",
23
+ "typescript": "^4.8.3"
24
+ }
25
+ }