v-code-diff 1.8.0 → 1.10.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.
package/README.md CHANGED
@@ -22,7 +22,6 @@ This project references the following projects, and I would like to express my g
22
22
  - Github Code Diff
23
23
 
24
24
  ## Contents
25
-
26
25
  - [Install](#Install)
27
26
  - [Getting started](#Getting-started)
28
27
  - [Vue3](#Vue3)
@@ -48,7 +47,7 @@ yarn add v-code-diff
48
47
  pnpm add v-code-diff
49
48
  ```
50
49
 
51
- Vue2 developers need install composition-api
50
+ Vue2.6 developers need install composition-api
52
51
 
53
52
  ```shell
54
53
  pnpm add @vue/composition-api
@@ -58,6 +57,24 @@ pnpm add @vue/composition-api
58
57
 
59
58
  ### Vue3
60
59
 
60
+ #### Register locally
61
+ > Recommend using local registration for better tree-shaking support.
62
+ ```vue
63
+ <script setup>
64
+ import { CodeDiff } from 'v-code-diff'
65
+ </script>
66
+
67
+ <template>
68
+ <div>
69
+ <CodeDiff
70
+ old-string="12345"
71
+ new-string="3456"
72
+ output-format="side-by-side"
73
+ />
74
+ </div>
75
+ </template>
76
+ ```
77
+
61
78
  #### Register globally
62
79
 
63
80
  ```ts
@@ -81,14 +98,31 @@ then
81
98
  </template>
82
99
  ```
83
100
 
84
- #### Register locally
85
-
86
- Not recommended, but the relevant capabilities are retained to facilitate migration for 0.x users.
87
-
88
101
  ### Vue2
89
102
 
90
- #### Register globally
103
+ #### Register locally
104
+ > > Recommend using local registration for better tree-shaking support.
105
+ ```vue
106
+ <script>
107
+ import { CodeDiff } from 'v-code-diff'
108
+ export default {
109
+ components: {
110
+ CodeDiff
111
+ }
112
+ }
113
+ </script>
91
114
 
115
+ <template>
116
+ <div>
117
+ <CodeDiff
118
+ old-string="12345"
119
+ new-string="3456"
120
+ output-format="side-by-side"
121
+ />
122
+ </div>
123
+ </template>
124
+ ```
125
+ #### Register globally
92
126
  ```ts
93
127
  import Vue from 'vue'
94
128
  import CodeDiff from 'v-code-diff'
@@ -96,10 +130,6 @@ import CodeDiff from 'v-code-diff'
96
130
  Vue.use(CodeDiff)
97
131
  ```
98
132
 
99
- #### Register locally
100
-
101
- Not recommended, but the relevant capabilities are retained to facilitate migration for 0.x users.
102
-
103
133
  ## Demo
104
134
 
105
135
  | | npm | cdn |
@@ -123,7 +153,10 @@ Not recommended, but the relevant capabilities are retained to facilitate migrat
123
153
  | maxHeight | Maximum height of component, for example: 300px | string | - | undefined |
124
154
  | filename | Filename | string | - | undefined |
125
155
  | newFilename | New filename | string | - | undefined |
126
- | theme | Add dark mode | ThemeType | light , dark | 'light' |
156
+ | hideHeader | Hide header bar | boolean | - | false |
157
+ | hideStat | Hide statistical part in the header bar | boolean | - | false |
158
+ | theme | Add dark mode | ThemeType | light , dark | light |
159
+ | ignoreMatchingLines | Give a pattern to ignore matching lines eg: '(time\|token)' | string | - | undefined |
127
160
 
128
161
  ## Events
129
162
 
@@ -131,6 +164,12 @@ Not recommended, but the relevant capabilities are retained to facilitate migrat
131
164
  | ---- | --------------------------- | ------------------------------------------------------------------------------- |
132
165
  | diff | triggers when diff finished | (result: {stat: { isChanged: boolean, addNum: number, delNum: number}}) => void |
133
166
 
167
+ ## Slot
168
+
169
+ | Name | Description |
170
+ | ---- | ----------------------------------------------------------- |
171
+ | stat | Custom statistical content, The scope parameter is { stat } |
172
+
134
173
  ## Extend languages
135
174
 
136
175
  In order to reduce the size of the packaged file, the system only supports the following commonly used languages by
@@ -151,13 +190,40 @@ If the language you need is not included, you can manually import the relevant l
151
190
  ```shell
152
191
  pnpm add highlight.js
153
192
  ```
193
+ #### Register locally
194
+ > Recommend using local registration for better tree-shaking support.
195
+ ```vue
196
+ <script>
197
+ import { CodeDiff, hljs } from 'v-code-diff'
198
+ import c from 'highlight.js/lib/languages/c'
199
+ // Extend C language
200
+ hljs.registerLanguage('c', c)
201
+ export default {
202
+ components: {
203
+ CodeDiff,
204
+ }
205
+ }
206
+ </script>
207
+
208
+ <template>
209
+ <div>
210
+ <CodeDiff
211
+ old-string="#include <stdio.h>"
212
+ new-string="#include <stdio.h>\nint a = 1;"
213
+ output-format="side-by-side"
214
+ language="c"
215
+ />
216
+ </div>
217
+ </template>
218
+ ```
154
219
 
220
+ #### Register globally
155
221
  ```typescript
156
- import CodeDiff from 'v-code-diff';
222
+ import CodeDiff from 'v-code-diff'
157
223
  // Extend C language
158
- import c from 'highlight.js/lib/languages/c';
224
+ import c from 'highlight.js/lib/languages/c'
159
225
 
160
- CodeDiff.hljs.registerLanguage('c', c);
226
+ CodeDiff.hljs.registerLanguage('c', c)
161
227
  ```
162
228
 
163
229
  ## Migrate from 0.x version