-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Germey <[email protected]>
- Loading branch information
Germey
and
Germey
authored
May 26, 2024
1 parent
27c6668
commit beb12ae
Showing
9 changed files
with
92 additions
and
33 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@acedatacloud-nexior-238289af-bd05-4247-898b-5fc673c99e3d.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "optimize loading speed", | ||
"packageName": "@acedatacloud/nexior", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import i18n from '@/i18n'; | ||
import copyToClipboard from 'copy-to-clipboard'; | ||
|
||
export const highlight = async (el: HTMLElement) => { | ||
const hl = (await import('highlight.js')).default; | ||
console.debug('highlight.js loaded'); | ||
const blocks = el.querySelectorAll('pre code'); | ||
blocks.forEach((block) => { | ||
// create the copy button | ||
const copy = document.createElement('button'); | ||
copy.innerHTML = i18n.global.t('common.button.copy').toString(); | ||
// add the event listener to each click | ||
copy.addEventListener('click', () => { | ||
// @ts-ignore | ||
copyToClipboard(block.innerText); | ||
}); | ||
// append the copy button to each code block | ||
// check already has copy button | ||
if (!block.parentElement?.querySelector('button')) { | ||
block.parentElement?.prepend(copy); | ||
} | ||
// @ts-ignore | ||
hl.highlightBlock(block); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './baseUrl'; | ||
export * from './mode'; | ||
export * from './log'; | ||
export * from './initializer'; | ||
export * from './highlight'; | ||
export * from './is'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters