v-code-diff 1.9.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)
@@ -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 |
@@ -160,13 +190,40 @@ If the language you need is not included, you can manually import the relevant l
160
190
  ```shell
161
191
  pnpm add highlight.js
162
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>
163
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
+ ```
219
+
220
+ #### Register globally
164
221
  ```typescript
165
- import CodeDiff from 'v-code-diff';
222
+ import CodeDiff from 'v-code-diff'
166
223
  // Extend C language
167
- import c from 'highlight.js/lib/languages/c';
224
+ import c from 'highlight.js/lib/languages/c'
168
225
 
169
- CodeDiff.hljs.registerLanguage('c', c);
226
+ CodeDiff.hljs.registerLanguage('c', c)
170
227
  ```
171
228
 
172
229
  ## Migrate from 0.x version