57
57
import { escapeHtml } from ' docc-render/utils/strings' ;
58
58
import Language from ' docc-render/constants/Language' ;
59
59
import CodeBlock from ' docc-render/components/CodeBlock.vue' ;
60
- import CopyIcon from ' docc-render /components/Icons/CopyIcon.vue' ;
61
- import CheckmarkIcon from ' docc-render /components/Icons/CheckmarkIcon.vue' ;
62
- import CrossIcon from ' docc-render /components/Icons/CrossIcon.vue' ;
60
+ import CopyIcon from ' theme /components/Icons/CopyIcon.vue' ;
61
+ import CheckmarkIcon from ' theme /components/Icons/CheckmarkIcon.vue' ;
62
+ import CrossIcon from ' theme /components/Icons/CrossIcon.vue' ;
63
63
import { highlightContent , registerHighlightLanguage } from ' docc-render/utils/syntax-highlight' ;
64
64
65
65
import CodeListingFilename from ' ./CodeListingFilename.vue' ;
66
66
67
+ const CopyState = {
68
+ idle: ' idle' ,
69
+ success: ' success' ,
70
+ failure: ' failure' ,
71
+ };
72
+
67
73
export default {
68
74
name: ' CodeListing' ,
69
75
components: {
@@ -76,7 +82,7 @@ export default {
76
82
data () {
77
83
return {
78
84
syntaxHighlightedLines: [],
79
- copyState: ' idle' ,
85
+ copyState: CopyState . idle ,
80
86
};
81
87
},
82
88
props: {
@@ -154,15 +160,15 @@ export default {
154
160
copyCodeToClipboard () {
155
161
navigator .clipboard .writeText (this .copyableText )
156
162
.then (() => {
157
- this .copyState = ' success' ;
163
+ this .copyState = CopyState . success ;
158
164
})
159
165
.catch ((err ) => {
160
166
console .error (' Failed to copy text: ' , err);
161
- this .copyState = ' failure' ;
167
+ this .copyState = CopyState . failure ;
162
168
})
163
169
.finally (() => {
164
170
setTimeout (() => {
165
- this .copyState = ' idle' ;
171
+ this .copyState = CopyState . idle ;
166
172
}, 1000 );
167
173
});
168
174
},
0 commit comments