@bagelink/vue 1.20.76 → 1.20.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StructuredEditor-B-Vp4pa2.cjs +2 -0
- package/dist/StructuredEditor-DWfRtYZa.js +2431 -0
- package/dist/StructuredEditor.css +1 -0
- package/dist/babel-BVvTH0ev.js +10053 -0
- package/dist/babel-BzIDwrmk.cjs +16 -0
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts +45 -28
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/SearchPanel.vue.d.ts +10 -0
- package/dist/components/form/inputs/CodeEditor/SearchPanel.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/CodeEditor/StructuredEditor.vue.d.ts +27 -0
- package/dist/components/form/inputs/CodeEditor/StructuredEditor.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/CodeEditor/formatCode.d.ts +4 -0
- package/dist/components/form/inputs/CodeEditor/formatCode.d.ts.map +1 -0
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/OTP.vue.d.ts +2 -2
- package/dist/components/form/inputs/OTP.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/core.css +3 -1
- package/dist/dist-B-MCiFKR.cjs +10 -0
- package/dist/dist-B0uc2InW.js +6 -0
- package/dist/dist-BIAEQGHn.cjs +1 -0
- package/dist/dist-BLxHnfU6.js +1071 -0
- package/dist/dist-BRA2DQF2.cjs +1 -0
- package/dist/dist-BnLdfA7w.js +69 -0
- package/dist/dist-CL50Ff42.cjs +1 -0
- package/dist/dist-CwUttjIh.js +1100 -0
- package/dist/dist-CzY35u4H.cjs +1 -0
- package/dist/dist-D8OWrPLr.js +1336 -0
- package/dist/dist-DSCI9g6w.cjs +13 -0
- package/dist/dist-DsBgijLf.cjs +1 -0
- package/dist/dist-GbVY_Jpv.cjs +1 -0
- package/dist/dist-IV7z-zur.js +11909 -0
- package/dist/dist-Mr0UMyoK.js +1063 -0
- package/dist/dist-jq7acmcZ.js +6 -0
- package/dist/estree-CKgw47OZ.js +8211 -0
- package/dist/estree-HqeJuE3g.cjs +44 -0
- package/dist/html-B-hsQYII.js +7289 -0
- package/dist/html-BrqW5pT-.cjs +25 -0
- package/dist/index.cjs +1 -764
- package/dist/index.mjs +308 -65621
- package/dist/postcss-Bk65KKdh.js +6703 -0
- package/dist/postcss-BxY0xtVZ.cjs +61 -0
- package/dist/src-DwJEyASG.js +65571 -0
- package/dist/src-Uy-ww1Nz.cjs +764 -0
- package/dist/src.css +1 -0
- package/dist/standalone-CAcRm_h6.cjs +29 -0
- package/dist/standalone-D-HcbQmf.js +3549 -0
- package/dist/style.css +3 -1
- package/dist/utils/calendarDate.d.ts +6 -0
- package/dist/utils/calendarDate.d.ts.map +1 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/package.json +13 -2
- package/src/components/form/inputs/CodeEditor/Index.vue +70 -310
- package/src/components/form/inputs/CodeEditor/SearchPanel.vue +124 -0
- package/src/components/form/inputs/CodeEditor/StructuredEditor.vue +266 -0
- package/src/components/form/inputs/CodeEditor/formatCode.ts +34 -0
- package/src/components/form/inputs/DatePicker.vue +4 -1
- package/src/components/form/inputs/OTP.vue +42 -19
- package/src/components/form/inputs/RichText/index.vue +2 -1
- package/src/utils/calendarDate.ts +16 -0
- package/src/utils/date.ts +2 -1
- package/vite.config.ts +5 -3
- package/dist/components/form/inputs/CodeEditor/useHighlight.d.ts +0 -33
- package/dist/components/form/inputs/CodeEditor/useHighlight.d.ts.map +0 -1
- package/dist/index.css +0 -1
- package/src/components/form/inputs/CodeEditor/useHighlight.ts +0 -123
- /package/dist/{page-flip.browser-BXnk8BM6.js → page-flip.browser-0kqlwcC8.js} +0 -0
- /package/dist/{page-flip.browser-ByKQXhqK.cjs → page-flip.browser-Dfy5mAgM.cjs} +0 -0
- /package/dist/{pdf-CV7M2d0x.cjs → pdf-BBd7GH-5.cjs} +0 -0
- /package/dist/{pdf-DuN3_wNN.js → pdf-scP2ZqGZ.js} +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { HighlightJS, HighlightTheme } from './CodeTypes'
|
|
2
|
-
import { appendStyle, appendScript, awaitGlobal } from '../../../../index'
|
|
3
|
-
import { ref } from 'vue'
|
|
4
|
-
|
|
5
|
-
// Extend the Window interface
|
|
6
|
-
interface CustomWindow extends Window {
|
|
7
|
-
hljs: HighlightJS
|
|
8
|
-
}
|
|
9
|
-
declare const window: CustomWindow
|
|
10
|
-
|
|
11
|
-
export function useHighlight(theme: HighlightTheme = 'dark') {
|
|
12
|
-
const hljs = ref<HighlightJS | null>(null)
|
|
13
|
-
const loaded = ref(false)
|
|
14
|
-
const currentTheme = ref<HighlightTheme>(theme)
|
|
15
|
-
|
|
16
|
-
const normalizeTheme = (t: HighlightTheme): HighlightTheme => {
|
|
17
|
-
if (t === 'dark') { return 'atom-one-dark' }
|
|
18
|
-
if (t === 'light') { return 'atom-one-light' }
|
|
19
|
-
return t
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const getThemeCssUrl = (t: HighlightTheme) => `https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.0/styles/${t}.min.css`
|
|
23
|
-
|
|
24
|
-
// Remove highlight.js theme links EXCEPT the one we're about to keep.
|
|
25
|
-
// Removing a <link> that is still loading prevents its onload from ever
|
|
26
|
-
// firing, which would leave `appendStyle` hanging forever. When multiple
|
|
27
|
-
// editors mount at once this caused one editor to get stuck on `loaded=false`.
|
|
28
|
-
const removeOtherThemeLinks = (keepUrl: string) => {
|
|
29
|
-
document.querySelectorAll('link[rel="stylesheet"]').forEach((link) => {
|
|
30
|
-
if (link instanceof HTMLLinkElement && link.href.includes('/styles/') && link.href.includes('highlight.js')) {
|
|
31
|
-
if (link.href !== keepUrl) { link.parentElement?.removeChild(link) }
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const loadTheme = async (theme: HighlightTheme) => {
|
|
37
|
-
const next = normalizeTheme(theme)
|
|
38
|
-
try {
|
|
39
|
-
const url = getThemeCssUrl(next)
|
|
40
|
-
// Append first (idempotent: appendStyle resolves immediately if the
|
|
41
|
-
// link already exists), then remove only the *other* theme links.
|
|
42
|
-
await appendStyle(url)
|
|
43
|
-
removeOtherThemeLinks(url)
|
|
44
|
-
currentTheme.value = next
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error('Failed to apply theme. Falling back to atom-one-dark:', error)
|
|
47
|
-
currentTheme.value = 'atom-one-dark'
|
|
48
|
-
const url = getThemeCssUrl(currentTheme.value)
|
|
49
|
-
await appendStyle(url)
|
|
50
|
-
removeOtherThemeLinks(url)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const setTheme = async (theme: HighlightTheme) => {
|
|
55
|
-
const next = normalizeTheme(theme)
|
|
56
|
-
if (next === currentTheme.value) { return }
|
|
57
|
-
await loadTheme(next)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const loadHighlight = async () => {
|
|
61
|
-
if (loaded.value) { return }
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
// Load highlight.js
|
|
65
|
-
await appendScript('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.0/highlight.min.js', { id: 'hljs-cdn' })
|
|
66
|
-
// `appendScript` may resolve before the script has finished executing when
|
|
67
|
-
// multiple editors mount at once (a duplicate <script id> is detected in the
|
|
68
|
-
// DOM and resolves immediately). Wait for the actual global to appear.
|
|
69
|
-
const lib = await awaitGlobal<HighlightJS>('hljs')
|
|
70
|
-
await loadTheme(currentTheme.value)
|
|
71
|
-
|
|
72
|
-
hljs.value = lib
|
|
73
|
-
loaded.value = true
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.error('Error loading highlight.js:', error)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const escapeHtml = (unsafe: string) => {
|
|
80
|
-
return unsafe.replace(/[&<>"']/g, (m) => {
|
|
81
|
-
const replacements: { [key: string]: string } = {
|
|
82
|
-
'&': '&',
|
|
83
|
-
'<': '<',
|
|
84
|
-
'>': '>',
|
|
85
|
-
'"': '"',
|
|
86
|
-
'\'': '''
|
|
87
|
-
}
|
|
88
|
-
return replacements[m] || ''
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const highlightCode = (code: string, language?: string, autodetect = true, ignoreIllegals = true) => {
|
|
93
|
-
if (!hljs.value) { return escapeHtml(code) }
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const lang = language || ''
|
|
97
|
-
|
|
98
|
-
if (lang && !autodetect && !hljs.value.getLanguage(lang)) {
|
|
99
|
-
console.warn(`The language "${lang}" is not available.`)
|
|
100
|
-
return escapeHtml(code)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const result = autodetect
|
|
104
|
-
? hljs.value.highlightAuto(code)
|
|
105
|
-
: hljs.value.highlight(code, { language: lang, ignoreIllegals })
|
|
106
|
-
|
|
107
|
-
return result.value || escapeHtml(code)
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error('Highlighting error:', error)
|
|
110
|
-
return escapeHtml(code)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
hljs,
|
|
116
|
-
loaded,
|
|
117
|
-
loadHighlight,
|
|
118
|
-
setTheme,
|
|
119
|
-
currentTheme,
|
|
120
|
-
escapeHtml,
|
|
121
|
-
highlightCode
|
|
122
|
-
}
|
|
123
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|