Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious: What makes this no longer necessary with v11?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think v11 fixed the file paths. I couldn't get this to compile once I upgraded to v11 without removing this alias

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