tiptap/examples/Components/Routes/CodeHighlighting/examples.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-10-14 00:43:59 +08:00
export const JavaScriptExample = `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;
}
}`
2018-10-14 00:43:59 +08:00
export const CSSExample = `@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)
}
}`
2018-10-14 00:43:59 +08:00
export const ExplicitImportExample = `import javascript from 'highlight.js/lib/languages/javascript'
2019-01-25 22:34:27 +08:00
import css from 'highlight.js/lib/languages/css'
import { Editor } from 'tiptap'
2019-01-25 22:28:28 +08:00
import {
CodeBlockHighlight,
} from 'tiptap-extensions'
export default {
components: {
2018-10-14 00:43:59 +08:00
Editor,
},
data() {
return {
extensions: [
2019-01-25 22:28:28 +08:00
new CodeBlockHighlight({
languages: {
javascript,
2018-10-14 00:43:59 +08:00
css,
},
})
]
}
}
}`;