tiptap/examples/Components/Routes/CodeHighlighting/examples.js
Erick Wilder 27e473c2a4 refactor(tiptap-extensions): Do not import the full lowlight library.
BREAKING CHANGE: `CodeBlockHighlight` was importing the full `lowlight` libraries, including _all_
syntax highlightning definitions from `highlight.js`. The new behavior changes the signature of
`CodeBlockHighlight` to accept an object with all syntax highlightning definitions. This means that
now the user of the library __MUST__ import languages themselves and tiptap will no longer
bundle the full `highlight.js` in itself.
2018-10-13 16:22:33 +02:00

51 lines
1.0 KiB
JavaScript

export const javascript = `function $initHighlight(block, flags) {
try {
if (block.className.search(/\bno\-highlight\b/) != -1)
return processBlock(block, true, 0x0F) + ' class=""';
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) { // "0 / 2" should not be parsed as regexp
if (checkCondition(classes[i]) === undefined)
return /\d+/g;
}
}`
export const css = `@font-face {
font-family: Chunkfive; src: url('Chunkfive.otf');
}
body, .usertext {
color: #F0F0F0; background: #600;
font-family: Chunkfive, sans;
}
@import url(print.css);
@media print {
a[href^=http]::after {
content: attr(href)
}
}`
export const explicitImportExample = `import javascript from 'highlight.js/lib/languages/javascript'
import { Editor } from 'tiptap'
export default {
components: {
Editor
},
data() {
return {
extensions: [
new CodeBlockHighlightNode({
languages: {
javascript,
css
}
})
]
}
}
}`;