2024-06-26 07:46:26 +00:00
|
|
|
import { isClient } from '@primeuix/utils/dom';
|
2020-09-22 09:32:14 +00:00
|
|
|
|
2020-09-24 11:14:55 +00:00
|
|
|
const CodeHighlight = {
|
2022-12-20 17:29:41 +00:00
|
|
|
mounted(el, binding) {
|
2021-03-17 11:29:01 +00:00
|
|
|
const modifiers = binding.modifiers;
|
|
|
|
const value = binding.value;
|
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
if (modifiers.script || value === 'script') el.className = 'language-javascript';
|
|
|
|
else if (modifiers.css || value === 'css') el.className = 'language-css';
|
|
|
|
else el.className = 'language-markup';
|
2020-09-22 09:32:14 +00:00
|
|
|
|
2024-06-26 07:46:26 +00:00
|
|
|
if (isClient()) {
|
2023-10-03 22:28:52 +00:00
|
|
|
window.Prism.highlightElement(el.children[0]);
|
|
|
|
el.children[0].parentElement.setAttribute('tabindex', '-1');
|
|
|
|
}
|
2020-09-22 09:32:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-17 11:29:01 +00:00
|
|
|
export default CodeHighlight;
|