Skip to content

Commit

Permalink
(end) Export component individually (#11)
Browse files Browse the repository at this point in the history
* Bump version in package-lock.json

* Fix type file path

Fix #7

* Upgrade to highlight.js 11

* Export component individually
  • Loading branch information
Trinovantes authored Jun 22, 2021
1 parent 12a5769 commit e3d5d84
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 21 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ app.use(hljsVuePlugin)
app.mount('#app')
```

## Using component locally

```vue
<template>
<highlightjs
language="js"
code="console.log('Hello World');"
/>
</template>
<script>
import hljs from 'highlight.js/lib/common';
import hljsVuePlugin from "@highlightjs/vue-plugin";
export default {
components: {
highlightjs: hljsVuePlugin.component
}
}
</script>
```

## Building the pre-built library from source

We use rollup to build the `dist` distributable.
Expand Down
2 changes: 1 addition & 1 deletion dist/highlightjs-vue.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/highlightjs-vue.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion dist/vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
import { Plugin } from 'vue';
declare const plugin: Plugin;
declare const component: import("vue").DefineComponent<{
code: {
type: StringConstructor;
required: true;
};
language: {
type: StringConstructor;
default: string;
};
autodetect: {
type: BooleanConstructor;
default: boolean;
};
ignoreIllegals: {
type: BooleanConstructor;
default: boolean;
};
}, {
className: import("vue").ComputedRef<string>;
highlightedCode: import("vue").ComputedRef<string>;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
code: string;
language: string;
autodetect: boolean;
ignoreIllegals: boolean;
} & {}>, {
language: string;
autodetect: boolean;
ignoreIllegals: boolean;
}>;
declare const plugin: Plugin & {
component: typeof component;
};
export default plugin;
//# sourceMappingURL=vue.d.ts.map
2 changes: 1 addition & 1 deletion dist/vue.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Highlight.js Vue Plugin",
"main": "dist/highlightjs-vue.min.js",
"module": "dist/highlightjs-vue.esm.min.js",
"types": "dist/highlightjs-vue.d.ts",
"types": "dist/vue.d.ts",
"scripts": {
"build": "rollup -c",
"test": "echo \"Error: no test specified\" && exit 1",
Expand All @@ -21,7 +21,7 @@
"typescript": "^4.2.4"
},
"dependencies": {
"highlight.js": "^10.7.2",
"highlight.js": "^11.0.1",
"vue": "^3"
},
"files": [
Expand Down
3 changes: 2 additions & 1 deletion src/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ const component = defineComponent({
},
})

const plugin: Plugin = {
const plugin: Plugin & { component: typeof component } = {
install(app) {
app.component('highlightjs', component)
},
component,
}

export default plugin
4 changes: 0 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
"allowSyntheticDefaultImports": true,

"outDir": "dist",

"paths": {
"highlight.js/lib/core": ["./node_modules/highlight.js/types/index.d.ts"],
}
},
"exclude": [
"node_modules",
Expand Down

0 comments on commit e3d5d84

Please sign in to comment.