(2) issues compiling prismjs for PrismEditor component
See original GitHub issueIf I add these tags to my html index file, it works!
<link rel="stylesheet" href="<%= BASE_URL %>js/prismjs/prism.css" />
<script src="<%= BASE_URL %>js/prismjs/prism.js"></script>
However css is broken for lineNumbers="true"
just like this user experienced:
Issue #18 relevant
Like the README suggests, I should import the js and css into the global namespace for Vue. The previous user did this and said it would work. It doesn’t for me. I get these compile errors for prism:
Failed to compile.
./src/js/prismjs/prism.js
Module Error (from ./node_modules/eslint-loader/index.js):
C:\Users\Proto\Code\OpenNetBattleWebDashboard\open_net_battle_dashboard\src\js\prismjs\prism.js
3:100 error 'WorkerGlobalScope' is not defined no-undef
3:771 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
3:1040 error Unexpected comma in middle of array no-sparse-arrays
3:1589 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
3:1633 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
3:1666 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
3:1865 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
3:2457 error Expected a conditional expression and instead saw an assignment no-cond-assign
3:3819 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
3:4660 error 'w' is already defined no-redeclare
3:4708 error 'A' is already defined no-redeclare
3:4720 error 'w' is already defined no-redeclare
3:4736 error 'P' is already defined no-redeclare
3:5206 error Expected a conditional expression and instead saw an assignment no-cond-assign
5:1376 error Unnecessary escape character: \[ no-useless-escape
6:572 error Unnecessary escape character: \[ no-useless-escape
9:469 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
9:508 error 'e' is already defined no-redeclare
9:517 error Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins
11:1542 error Empty block statement no-empty
12:294 error Expected a conditional expression and instead saw an assignment no-cond-assign
Here’s the .vue
file where I try to import the vanilla js
<template>
<PrismEditor language="lua" code="blah blah blah" lineNumbers/>
</template>
<script>
import '@/js/prismjs/prism'
import '@/js/prismjs/prism.css'
import PrismEditor from 'vue-prism-editor'
export default {
name: "CodeEditPage",
components: { PrismEditor }
}
Issue 2. If I use a data variable for code
property that is empty
then it also crashes:
property `code` expected type String. code="[Object object]" expected code=[Object object]
Here’s the .vue
file where this happens
<template>
<PrismEditor language="lua" :code="source" lineNumbers/>
</template>
<script>
import '@/js/prismjs/prism'
import '@/js/prismjs/prism.css'
import PrismEditor from 'vue-prism-editor'
export default {
name: "CodeEditPage",
components: { PrismEditor },
data() {
return { source: { type: String, default: "" } }
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Prism.js
Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It's used in millions of websites, including some of...
Read more >Prism not working inside Vue component - Stack Overflow
New answer: There is now a library dedicated to use Prism.js with Vue, check it: https://github.com/egoist/vue-prism-component
Read more >vue-prism-editor - npm Package Health Analysis - Snyk
The npm package vue-prism-editor was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as...
Read more >Angular: Syntax Highlighting with Prism | by Allen Kim - Medium
Here are the steps needed to use prism component in your app. Install prismjs; Add prism theme style to your style.css; Add prismjs...
Read more >Highlight Code Using Prism.js and Vue Component - Morioh
import 'prismjs/components/prism-rust' <Prism language="rust" code={ ... #units are pixels; for example, a value of 2.4 at 600 dpi = .0004 inch, 2 at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to use npm. And you should learn vue. Good luck!
Please read the readme. Im afraid you did everything wrong 😕