Skip to content

Commit e3d5d84

Browse files
authored
(end) Export component individually (#11)
* Bump version in package-lock.json * Fix type file path Fix #7 * Upgrade to highlight.js 11 * Export component individually
1 parent 12a5769 commit e3d5d84

9 files changed

+72
-21
lines changed

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@ app.use(hljsVuePlugin)
6767
app.mount('#app')
6868
```
6969

70+
## Using component locally
71+
72+
```vue
73+
<template>
74+
<highlightjs
75+
language="js"
76+
code="console.log('Hello World');"
77+
/>
78+
</template>
79+
80+
<script>
81+
import hljs from 'highlight.js/lib/common';
82+
import hljsVuePlugin from "@highlightjs/vue-plugin";
83+
84+
export default {
85+
components: {
86+
highlightjs: hljsVuePlugin.component
87+
}
88+
}
89+
</script>
90+
```
91+
7092
## Building the pre-built library from source
7193

7294
We use rollup to build the `dist` distributable.

dist/highlightjs-vue.esm.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/highlightjs-vue.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue.d.ts

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
11
import { Plugin } from 'vue';
2-
declare const plugin: Plugin;
2+
declare const component: import("vue").DefineComponent<{
3+
code: {
4+
type: StringConstructor;
5+
required: true;
6+
};
7+
language: {
8+
type: StringConstructor;
9+
default: string;
10+
};
11+
autodetect: {
12+
type: BooleanConstructor;
13+
default: boolean;
14+
};
15+
ignoreIllegals: {
16+
type: BooleanConstructor;
17+
default: boolean;
18+
};
19+
}, {
20+
className: import("vue").ComputedRef<string>;
21+
highlightedCode: import("vue").ComputedRef<string>;
22+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
23+
code: string;
24+
language: string;
25+
autodetect: boolean;
26+
ignoreIllegals: boolean;
27+
} & {}>, {
28+
language: string;
29+
autodetect: boolean;
30+
ignoreIllegals: boolean;
31+
}>;
32+
declare const plugin: Plugin & {
33+
component: typeof component;
34+
};
335
export default plugin;
436
//# sourceMappingURL=vue.d.ts.map

dist/vue.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

package-lock.json

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Highlight.js Vue Plugin",
55
"main": "dist/highlightjs-vue.min.js",
66
"module": "dist/highlightjs-vue.esm.min.js",
7-
"types": "dist/highlightjs-vue.d.ts",
7+
"types": "dist/vue.d.ts",
88
"scripts": {
99
"build": "rollup -c",
1010
"test": "echo \"Error: no test specified\" && exit 1",
@@ -21,7 +21,7 @@
2121
"typescript": "^4.2.4"
2222
},
2323
"dependencies": {
24-
"highlight.js": "^10.7.2",
24+
"highlight.js": "^11.0.1",
2525
"vue": "^3"
2626
},
2727
"files": [

src/vue.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ const component = defineComponent({
7373
},
7474
})
7575

76-
const plugin: Plugin = {
76+
const plugin: Plugin & { component: typeof component } = {
7777
install(app) {
7878
app.component('highlightjs', component)
7979
},
80+
component,
8081
}
8182

8283
export default plugin

tsconfig.json

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"allowSyntheticDefaultImports": true,
99

1010
"outDir": "dist",
11-
12-
"paths": {
13-
"highlight.js/lib/core": ["./node_modules/highlight.js/types/index.d.ts"],
14-
}
1511
},
1612
"exclude": [
1713
"node_modules",

0 commit comments

Comments
 (0)