@bagelink/vue 1.20.72 → 1.20.78
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-HFOfODf9.cjs +2 -0
- package/dist/StructuredEditor-w0UY60b7.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/RichText/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Upload/AssetUploadInput.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/form-flow/form-flow.d.ts.map +1 -1
- 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 -65600
- package/dist/postcss-Bk65KKdh.js +6703 -0
- package/dist/postcss-BxY0xtVZ.cjs +61 -0
- package/dist/src-BACj3hjY.cjs +764 -0
- package/dist/src-SwfYbKT-.js +65571 -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/RichText/index.vue +2 -1
- package/src/components/form/inputs/Upload/AssetUploadInput.vue +28 -5
- package/src/form-flow/form-flow.ts +2 -0
- 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
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, getCurrentInstance, h, onBeforeUnmount, onMounted, ref, render, shallowRef, watch } from 'vue'
|
|
3
|
+
import { Annotation, Compartment, EditorState, type Extension } from '@codemirror/state'
|
|
4
|
+
import { EditorView, keymap, lineNumbers as numberGutter, placeholder as editorPlaceholder } from '@codemirror/view'
|
|
5
|
+
import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands'
|
|
6
|
+
import { bracketMatching, foldGutter, foldKeymap, indentOnInput, indentUnit } from '@codemirror/language'
|
|
7
|
+
import { atomone, atomoneInit } from '@uiw/codemirror-theme-atomone'
|
|
8
|
+
import { getSearchQuery, search, searchKeymap } from '@codemirror/search'
|
|
9
|
+
import SearchPanel from './SearchPanel.vue'
|
|
10
|
+
import Btn from '../../../Btn.vue'
|
|
11
|
+
import { copyText } from '../../../../utils'
|
|
12
|
+
import { formatCode, supportsFormatting } from './formatCode'
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
modelValue: string
|
|
16
|
+
language: string
|
|
17
|
+
lineNumbers: boolean
|
|
18
|
+
folding: boolean
|
|
19
|
+
formatting: boolean
|
|
20
|
+
readonly: boolean
|
|
21
|
+
disabled: boolean
|
|
22
|
+
wrap: boolean
|
|
23
|
+
singleLine: boolean
|
|
24
|
+
placeholder: string
|
|
25
|
+
label: string
|
|
26
|
+
dark: boolean
|
|
27
|
+
}>()
|
|
28
|
+
const emit = defineEmits<{
|
|
29
|
+
'update:modelValue': [value: string]
|
|
30
|
+
focus: []
|
|
31
|
+
blur: []
|
|
32
|
+
}>()
|
|
33
|
+
|
|
34
|
+
const host = ref<HTMLDivElement>()
|
|
35
|
+
const formattingBusy = ref(false)
|
|
36
|
+
const formatError = ref('')
|
|
37
|
+
const copied = ref(false)
|
|
38
|
+
const copyError = ref('')
|
|
39
|
+
let copyTimer: ReturnType<typeof setTimeout> | undefined
|
|
40
|
+
const languageNames: Record<string, string> = { javascript: 'JS', typescript: 'TS' }
|
|
41
|
+
const languageLabel = computed(() => languageNames[props.language] || props.language.toUpperCase())
|
|
42
|
+
const canFormat = computed(() => props.formatting && !props.singleLine && supportsFormatting(props.language))
|
|
43
|
+
const config = new Compartment()
|
|
44
|
+
const languageConfig = new Compartment()
|
|
45
|
+
const externalUpdate = Annotation.define<boolean>()
|
|
46
|
+
let view: EditorView | undefined
|
|
47
|
+
let languageRequest = 0
|
|
48
|
+
let disposed = false
|
|
49
|
+
async function copy() {
|
|
50
|
+
copyError.value = ''
|
|
51
|
+
try {
|
|
52
|
+
await copyText(view?.state.doc.toString() ?? props.modelValue)
|
|
53
|
+
copied.value = true
|
|
54
|
+
clearTimeout(copyTimer)
|
|
55
|
+
copyTimer = setTimeout(() => { copied.value = false }, 2000)
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
copyError.value = 'Could not copy. Check clipboard permissions and try again.'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const appContext = getCurrentInstance()!.appContext
|
|
62
|
+
const atomLight = atomoneInit({
|
|
63
|
+
theme: 'light',
|
|
64
|
+
settings: {
|
|
65
|
+
background: '#fafafa',
|
|
66
|
+
foreground: '#383a42',
|
|
67
|
+
caret: '#526fff',
|
|
68
|
+
selection: '#d7d7d7',
|
|
69
|
+
selectionMatch: '#e5e5e6',
|
|
70
|
+
lineHighlight: '#f0f0f0',
|
|
71
|
+
gutterBackground: '#fafafa',
|
|
72
|
+
gutterForeground: '#9d9d9f',
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
function createSearchPanel(editor: EditorView) {
|
|
77
|
+
const dom = document.createElement('div')
|
|
78
|
+
const query = shallowRef(getSearchQuery(editor.state))
|
|
79
|
+
const readonly = ref(editor.state.readOnly)
|
|
80
|
+
const vnode = h({
|
|
81
|
+
setup: () => () => h(SearchPanel, { view: editor, query: query.value, readonly: readonly.value }),
|
|
82
|
+
})
|
|
83
|
+
vnode.appContext = appContext
|
|
84
|
+
render(vnode, dom)
|
|
85
|
+
return {
|
|
86
|
+
dom,
|
|
87
|
+
top: true,
|
|
88
|
+
update() {
|
|
89
|
+
query.value = getSearchQuery(editor.state)
|
|
90
|
+
readonly.value = editor.state.readOnly
|
|
91
|
+
},
|
|
92
|
+
destroy() { render(null, dom) },
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function extensions(): Extension[] {
|
|
97
|
+
return [
|
|
98
|
+
props.dark ? atomone : atomLight,
|
|
99
|
+
props.lineNumbers && !props.singleLine ? numberGutter() : [],
|
|
100
|
+
props.folding && !props.singleLine ? [foldGutter(), keymap.of(foldKeymap)] : [],
|
|
101
|
+
props.wrap ? EditorView.lineWrapping : [],
|
|
102
|
+
EditorState.readOnly.of(props.readonly || props.disabled),
|
|
103
|
+
EditorView.editable.of(!props.readonly && !props.disabled),
|
|
104
|
+
EditorView.contentAttributes.of({
|
|
105
|
+
'aria-label': props.label || 'Code editor',
|
|
106
|
+
'aria-disabled': String(props.disabled),
|
|
107
|
+
}),
|
|
108
|
+
editorPlaceholder(props.placeholder),
|
|
109
|
+
EditorView.theme({
|
|
110
|
+
'&': { height: '100%' },
|
|
111
|
+
'.cm-scroller': { overflow: 'auto', fontFamily: 'inherit', lineHeight: '1.5' },
|
|
112
|
+
'.cm-content': { padding: '8px 0' },
|
|
113
|
+
'&.cm-focused': { outline: 'none' },
|
|
114
|
+
}, { dark: props.dark }),
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function loadLanguage() {
|
|
119
|
+
const request = ++languageRequest
|
|
120
|
+
let extension: Extension = []
|
|
121
|
+
switch (props.language) {
|
|
122
|
+
case 'html':
|
|
123
|
+
case 'xml':
|
|
124
|
+
extension = (await import('@codemirror/lang-html')).html()
|
|
125
|
+
break
|
|
126
|
+
case 'javascript':
|
|
127
|
+
case 'js':
|
|
128
|
+
case 'typescript':
|
|
129
|
+
case 'ts':
|
|
130
|
+
extension = (await import('@codemirror/lang-javascript')).javascript({ typescript: ['typescript', 'ts'].includes(props.language) })
|
|
131
|
+
break
|
|
132
|
+
case 'json':
|
|
133
|
+
extension = (await import('@codemirror/lang-json')).json()
|
|
134
|
+
break
|
|
135
|
+
case 'css':
|
|
136
|
+
extension = (await import('@codemirror/lang-css')).css()
|
|
137
|
+
break
|
|
138
|
+
}
|
|
139
|
+
if (!disposed && request === languageRequest)
|
|
140
|
+
view?.dispatch({ effects: languageConfig.reconfigure(extension) })
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function requestLanguage() {
|
|
144
|
+
void loadLanguage().catch(() => {
|
|
145
|
+
if (!disposed) formatError.value = 'Could not load syntax support. Plain-text editing is still available.'
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function format() {
|
|
150
|
+
if (!view || !canFormat.value || props.readonly || props.disabled || formattingBusy.value) return
|
|
151
|
+
const original = view.state.doc
|
|
152
|
+
const language = props.language
|
|
153
|
+
formattingBusy.value = true
|
|
154
|
+
formatError.value = ''
|
|
155
|
+
try {
|
|
156
|
+
const formatted = await formatCode(original.toString(), language)
|
|
157
|
+
// Don't replace edits or a newly supplied value while the formatter downloads.
|
|
158
|
+
if (view && view.state.doc === original && props.language === language && !props.readonly && !props.disabled) {
|
|
159
|
+
view.dispatch({
|
|
160
|
+
changes: { from: 0, to: original.length, insert: formatted },
|
|
161
|
+
userEvent: 'input.format',
|
|
162
|
+
})
|
|
163
|
+
view.focus()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
formatError.value = 'Could not format this code. Check its syntax and try again.'
|
|
168
|
+
}
|
|
169
|
+
finally {
|
|
170
|
+
formattingBusy.value = false
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
onMounted(() => {
|
|
175
|
+
view = new EditorView({
|
|
176
|
+
parent: host.value,
|
|
177
|
+
state: EditorState.create({
|
|
178
|
+
doc: props.modelValue,
|
|
179
|
+
extensions: [
|
|
180
|
+
config.of(extensions()),
|
|
181
|
+
languageConfig.of([]),
|
|
182
|
+
history(),
|
|
183
|
+
indentUnit.of(' '),
|
|
184
|
+
indentOnInput(),
|
|
185
|
+
bracketMatching(),
|
|
186
|
+
search({ createPanel: createSearchPanel }),
|
|
187
|
+
keymap.of([
|
|
188
|
+
{ key: 'Enter', run: () => props.singleLine },
|
|
189
|
+
...defaultKeymap, ...historyKeymap, ...searchKeymap,
|
|
190
|
+
indentWithTab,
|
|
191
|
+
]),
|
|
192
|
+
EditorState.transactionFilter.of(transaction => {
|
|
193
|
+
if (props.singleLine && transaction.docChanged && transaction.newDoc.lines > 1) return []
|
|
194
|
+
return transaction
|
|
195
|
+
}),
|
|
196
|
+
EditorView.updateListener.of(update => {
|
|
197
|
+
if (update.docChanged && !update.transactions.some(transaction => transaction.annotation(externalUpdate)))
|
|
198
|
+
emit('update:modelValue', update.state.doc.toString())
|
|
199
|
+
if (update.focusChanged) {
|
|
200
|
+
if (update.view.hasFocus) emit('focus')
|
|
201
|
+
else emit('blur')
|
|
202
|
+
}
|
|
203
|
+
}),
|
|
204
|
+
],
|
|
205
|
+
}),
|
|
206
|
+
})
|
|
207
|
+
requestLanguage()
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
watch(() => props.modelValue, value => {
|
|
211
|
+
if (view && value !== view.state.doc.toString())
|
|
212
|
+
view.dispatch({
|
|
213
|
+
changes: { from: 0, to: view.state.doc.length, insert: value },
|
|
214
|
+
annotations: externalUpdate.of(true),
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
watch(() => props.language, requestLanguage)
|
|
218
|
+
watch(() => [props.lineNumbers, props.folding, props.readonly, props.disabled, props.wrap, props.singleLine, props.placeholder, props.label, props.dark], () => {
|
|
219
|
+
view?.dispatch({ effects: config.reconfigure(extensions()) })
|
|
220
|
+
})
|
|
221
|
+
onBeforeUnmount(() => {
|
|
222
|
+
disposed = true
|
|
223
|
+
clearTimeout(copyTimer)
|
|
224
|
+
view?.destroy()
|
|
225
|
+
view = undefined
|
|
226
|
+
})
|
|
227
|
+
</script>
|
|
228
|
+
|
|
229
|
+
<template>
|
|
230
|
+
<div class="structured-editor monospace">
|
|
231
|
+
<div v-if="!singleLine" class="flex flex-shrink-0 align-items-center space-between gap-05 px-075 py-025">
|
|
232
|
+
<span class="txt11 opacity-5" aria-label="Code language">{{ languageLabel }}</span>
|
|
233
|
+
<div class="flex align-items-center gap-025">
|
|
234
|
+
<Btn
|
|
235
|
+
v-if="canFormat" v-tooltip="formattingBusy ? 'Formatting…' : 'Format code'" thin flat
|
|
236
|
+
icon="format_align_left" aria-label="Format code" :aria-busy="formattingBusy"
|
|
237
|
+
:disabled="readonly || disabled || formattingBusy" @click="format"
|
|
238
|
+
/>
|
|
239
|
+
<Btn
|
|
240
|
+
v-tooltip="copied ? 'Copied!' : 'Copy code'" thin flat
|
|
241
|
+
:icon="copied ? 'check' : 'content_copy'" :aria-label="copied ? 'Copied!' : 'Copy code'"
|
|
242
|
+
@click="copy"
|
|
243
|
+
/>
|
|
244
|
+
<span class="hide" role="status">{{ copied ? 'Copied to clipboard' : '' }}</span>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
<span v-if="formatError || copyError" role="alert" class="txt12 color-red px-075">{{ formatError || copyError }}</span>
|
|
248
|
+
<div ref="host" class="structured-editor-host" />
|
|
249
|
+
</div>
|
|
250
|
+
</template>
|
|
251
|
+
|
|
252
|
+
<style scoped>
|
|
253
|
+
.structured-editor {
|
|
254
|
+
display: flex;
|
|
255
|
+
flex-direction: column;
|
|
256
|
+
height: 100%;
|
|
257
|
+
min-height: 0;
|
|
258
|
+
max-height: var(--code-max-height, none);
|
|
259
|
+
overflow: hidden;
|
|
260
|
+
}
|
|
261
|
+
.structured-editor-host {
|
|
262
|
+
flex: 1;
|
|
263
|
+
min-height: 0;
|
|
264
|
+
overflow: auto;
|
|
265
|
+
}
|
|
266
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Formatter code and parsers are downloaded only after an explicit format action. */
|
|
2
|
+
export function supportsFormatting(language: string): boolean {
|
|
3
|
+
return ['html', 'xml', 'javascript', 'js', 'typescript', 'ts', 'json', 'css'].includes(language)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export async function formatCode(source: string, language: string): Promise<string> {
|
|
7
|
+
const { format } = await import('prettier/standalone')
|
|
8
|
+
const options = { tabWidth: 2, useTabs: false }
|
|
9
|
+
switch (language) {
|
|
10
|
+
case 'html':
|
|
11
|
+
case 'xml': {
|
|
12
|
+
const html = await import('prettier/plugins/html')
|
|
13
|
+
return format(source, { ...options, parser: 'html', plugins: [html], htmlWhitespaceSensitivity: 'strict' })
|
|
14
|
+
}
|
|
15
|
+
case 'css': {
|
|
16
|
+
const postcss = await import('prettier/plugins/postcss')
|
|
17
|
+
return format(source, { ...options, parser: 'css', plugins: [postcss] })
|
|
18
|
+
}
|
|
19
|
+
case 'json':
|
|
20
|
+
case 'javascript':
|
|
21
|
+
case 'js':
|
|
22
|
+
case 'typescript':
|
|
23
|
+
case 'ts': {
|
|
24
|
+
const [babel, estree] = await Promise.all([
|
|
25
|
+
import('prettier/plugins/babel'),
|
|
26
|
+
import('prettier/plugins/estree'),
|
|
27
|
+
])
|
|
28
|
+
const parser = language === 'json' ? 'json' : ['typescript', 'ts'].includes(language) ? 'babel-ts' : 'babel'
|
|
29
|
+
return format(source, { ...options, parser, plugins: [babel, estree] })
|
|
30
|
+
}
|
|
31
|
+
default:
|
|
32
|
+
return source
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -4,6 +4,7 @@ import type { ModeType } from '../../../utils/calendar/typings'
|
|
|
4
4
|
import { Btn, NumberInput, local } from '../../../index'
|
|
5
5
|
import { computed, ref, toValue } from 'vue'
|
|
6
6
|
import Time, { WEEK_START_DAY } from '../../../utils/calendar/time'
|
|
7
|
+
import { parseCalendarDate } from '../../../utils/calendarDate'
|
|
7
8
|
|
|
8
9
|
export interface DateRangeValue {
|
|
9
10
|
start?: string
|
|
@@ -58,7 +59,9 @@ const time = new Time(props.firstDayOfWeek, props.locale)
|
|
|
58
59
|
// Parse a date string or object into a Date object
|
|
59
60
|
function parseDate(value: string | Date | undefined): Date | null {
|
|
60
61
|
if (!value) { return null }
|
|
61
|
-
const date = typeof value === 'string'
|
|
62
|
+
const date = typeof value === 'string'
|
|
63
|
+
? (props.enableTime ? new Date(value) : parseCalendarDate(value))
|
|
64
|
+
: value
|
|
62
65
|
return Number.isNaN(date.getTime()) ? null : date
|
|
63
66
|
}
|
|
64
67
|
|
|
@@ -3956,7 +3956,8 @@ const imgTransform = computed({
|
|
|
3956
3956
|
/>
|
|
3957
3957
|
</div>
|
|
3958
3958
|
<CodeEditor
|
|
3959
|
-
v-if="editor.state.isSplitView" v-model="splitViewHtml" language="html"
|
|
3959
|
+
v-if="editor.state.isSplitView" v-model="splitViewHtml" language="html" wrap
|
|
3960
|
+
line-numbers folding formatting
|
|
3960
3961
|
:height="editor.state.isFullscreen ? 'calc(100vh - 4rem)' : editorHeight"
|
|
3961
3962
|
/>
|
|
3962
3963
|
</div>
|
|
@@ -17,6 +17,8 @@ interface Row {
|
|
|
17
17
|
type: string
|
|
18
18
|
asset?: AssetReference
|
|
19
19
|
thumb?: string
|
|
20
|
+
/** A previously saved URL string, shown until the editor replaces it with an asset. */
|
|
21
|
+
legacy?: boolean
|
|
20
22
|
progress?: number
|
|
21
23
|
success: boolean
|
|
22
24
|
downloadUrl?: string
|
|
@@ -324,7 +326,19 @@ const previewQueue = computed<Row[]>(() => {
|
|
|
324
326
|
/** Lab-only: hold the success check on every stored row instead of flashing it. */
|
|
325
327
|
const previewSuccess = computed(() => props.previewState?.state === 'success')
|
|
326
328
|
|
|
329
|
+
function savedUrls(value: unknown): string[] {
|
|
330
|
+
return [value].flat().filter((item): item is string => typeof item === 'string' && item.trim() !== '')
|
|
331
|
+
}
|
|
332
|
+
|
|
327
333
|
const rows = computed<Row[]>(() => [
|
|
334
|
+
...savedUrls(props.modelValue).map((url): Row => ({
|
|
335
|
+
key: url,
|
|
336
|
+
label: decodeURIComponent(url.split('/').pop()?.split('?')[0] || 'Image'),
|
|
337
|
+
type: 'image',
|
|
338
|
+
thumb: url,
|
|
339
|
+
success: false,
|
|
340
|
+
legacy: true,
|
|
341
|
+
})),
|
|
328
342
|
...values.value.map((value, index): Row => ({
|
|
329
343
|
key: value.asset_id,
|
|
330
344
|
label: labelFor(value),
|
|
@@ -370,6 +384,15 @@ function srcFor(row: Row) {
|
|
|
370
384
|
}
|
|
371
385
|
|
|
372
386
|
function removeRow(row: Row) {
|
|
387
|
+
if (row.legacy) {
|
|
388
|
+
if (!props.multiple) {
|
|
389
|
+
emit('update:modelValue', undefined)
|
|
390
|
+
return
|
|
391
|
+
}
|
|
392
|
+
const next = savedUrls(props.modelValue).filter(url => url !== row.thumb)
|
|
393
|
+
emit('update:modelValue', next.length ? next as unknown as AssetReference[] : undefined)
|
|
394
|
+
return
|
|
395
|
+
}
|
|
373
396
|
if (row.asset) {
|
|
374
397
|
const index = row.index
|
|
375
398
|
?? values.value.findIndex(value => value.asset_id === row.asset?.asset_id)
|
|
@@ -464,7 +487,7 @@ const listStyle = computed<CSSProperties | undefined>(() => {
|
|
|
464
487
|
v-for="row in rows" :key="row.key" :label="row.label" :type="row.type"
|
|
465
488
|
:asset="row.asset" :thumb="row.thumb" :progress="row.progress" :success="row.success"
|
|
466
489
|
:download-url="row.downloadUrl" :readonly="readonly" :disabled="disabled"
|
|
467
|
-
:crop="cropAfterUpload" :icon-weight="iconWeight"
|
|
490
|
+
:crop="cropAfterUpload && !!row.asset" :icon-weight="iconWeight"
|
|
468
491
|
@remove="removeRow(row)" @replace="pick(row.index)" @crop="cropUploaded(row)"
|
|
469
492
|
/>
|
|
470
493
|
<span v-if="!rows.length" class="txt-gray txt-12">
|
|
@@ -531,7 +554,7 @@ const listStyle = computed<CSSProperties | undefined>(() => {
|
|
|
531
554
|
:aria-label="$t('upload.replace')" @click.stop="pick(single.index)"
|
|
532
555
|
/>
|
|
533
556
|
<Btn
|
|
534
|
-
v-if="!disabled && cropAfterUpload && single.type === 'image'"
|
|
557
|
+
v-if="!disabled && cropAfterUpload && single.asset && single.type === 'image'"
|
|
535
558
|
color="white" frame thin icon="crop"
|
|
536
559
|
:icon-size="actionIconSize" :icon-mobile-size="actionIconMobileSize"
|
|
537
560
|
:aria-label="$t('upload.cropExisting')" @click.stop="cropUploaded(single)"
|
|
@@ -615,7 +638,7 @@ const listStyle = computed<CSSProperties | undefined>(() => {
|
|
|
615
638
|
@click.stop="pick(row.index)"
|
|
616
639
|
/>
|
|
617
640
|
<Btn
|
|
618
|
-
v-if="cropAfterUpload && row.type === 'image'" color="white" frame thin
|
|
641
|
+
v-if="cropAfterUpload && row.asset && row.type === 'image'" color="white" frame thin
|
|
619
642
|
icon="crop" :aria-label="$t('upload.cropExisting')"
|
|
620
643
|
:icon-size="actionIconSize" :icon-mobile-size="actionIconMobileSize"
|
|
621
644
|
@click.stop="cropUploaded(row)"
|
|
@@ -646,7 +669,7 @@ const listStyle = computed<CSSProperties | undefined>(() => {
|
|
|
646
669
|
v-for="row in rows" :key="row.key" :label="row.label" :type="row.type"
|
|
647
670
|
:asset="row.asset" :thumb="row.thumb" :progress="row.progress" :success="row.success"
|
|
648
671
|
:readonly="readonly" :disabled="disabled" :download-url="row.downloadUrl"
|
|
649
|
-
:crop="cropAfterUpload" :icon-weight="iconWeight"
|
|
672
|
+
:crop="cropAfterUpload && !!row.asset" :icon-weight="iconWeight"
|
|
650
673
|
@remove="removeRow(row)" @replace="pick(row.index)" @crop="cropUploaded(row)"
|
|
651
674
|
/>
|
|
652
675
|
<div v-if="!locked" class="bgl-add-more">
|
|
@@ -693,7 +716,7 @@ const listStyle = computed<CSSProperties | undefined>(() => {
|
|
|
693
716
|
v-for="row in rows" :key="row.key" :label="row.label" :type="row.type"
|
|
694
717
|
:asset="row.asset" :thumb="row.thumb" :progress="row.progress" :success="row.success"
|
|
695
718
|
:readonly="readonly" :disabled="disabled" :download-url="row.downloadUrl"
|
|
696
|
-
:crop="cropAfterUpload" :icon-weight="iconWeight"
|
|
719
|
+
:crop="cropAfterUpload && !!row.asset" :icon-weight="iconWeight"
|
|
697
720
|
@remove="removeRow(row)" @replace="pick(row.index)" @crop="cropUploaded(row)"
|
|
698
721
|
/>
|
|
699
722
|
</div>
|
|
@@ -1267,6 +1267,8 @@ function createFieldFromProperty(
|
|
|
1267
1267
|
const arrayConfig: Record<string, any> = { ...config }
|
|
1268
1268
|
if (xUi.allowAdd !== undefined) arrayConfig.allowAdd = xUi.allowAdd
|
|
1269
1269
|
if (xUi.allowDelete !== undefined) arrayConfig.allowDelete = xUi.allowDelete
|
|
1270
|
+
if (xUi.allowReorder !== undefined) arrayConfig.allowReorder = xUi.allowReorder
|
|
1271
|
+
if (xUi.collapsible !== undefined) arrayConfig.collapsible = xUi.collapsible
|
|
1270
1272
|
if (xUi.sortOrder !== undefined) arrayConfig.sortOrder = xUi.sortOrder
|
|
1271
1273
|
const itemSchema = resolvedProp.items?.type === 'object'
|
|
1272
1274
|
? fromJSONSchema(resolvedProp.items as JSONSchemaObject, { loadOptionsSource })
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse date-only ISO values as local calendar days, not midnight UTC.
|
|
3
|
+
* Datetimes retain JavaScript's existing timezone/offset handling.
|
|
4
|
+
*/
|
|
5
|
+
export function parseCalendarDate(value: string | number | Date): Date {
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value)
|
|
8
|
+
if (match) {
|
|
9
|
+
const date = new Date(0)
|
|
10
|
+
date.setFullYear(Number(match[1]), Number(match[2]) - 1, Number(match[3]))
|
|
11
|
+
date.setHours(0, 0, 0, 0)
|
|
12
|
+
return date
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return new Date(value)
|
|
16
|
+
}
|
package/src/utils/date.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getI18n } from '../i18n'
|
|
2
|
+
import { parseCalendarDate } from './calendarDate'
|
|
2
3
|
|
|
3
4
|
function getLocale(): string {
|
|
4
5
|
try {
|
|
@@ -436,7 +437,7 @@ export function formatDate(
|
|
|
436
437
|
locale = locale || getLocale()
|
|
437
438
|
|
|
438
439
|
try {
|
|
439
|
-
let parsed =
|
|
440
|
+
let parsed = parseCalendarDate(date)
|
|
440
441
|
|
|
441
442
|
// Handle DD.MM.YY(YY) and DD/MM/YY(YY) strings that new Date() can't parse
|
|
442
443
|
if (typeof date === 'string' && Number.isNaN(parsed.getTime())) {
|
package/vite.config.ts
CHANGED
|
@@ -37,7 +37,9 @@ function composeCssEntries(): Plugin {
|
|
|
37
37
|
: new TextDecoder().decode(asset.source)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// Async component sharing can change the main CSS chunk's name.
|
|
41
|
+
const components = css(bundle['index.css'] ? 'index.css' : 'src.css')
|
|
42
|
+
const editor = bundle['StructuredEditor.css'] ? css('StructuredEditor.css') : ''
|
|
41
43
|
const core = css('core.css')
|
|
42
44
|
const adminFonts = css('admin.css')
|
|
43
45
|
const coreAsset = bundle['core.css']
|
|
@@ -48,8 +50,8 @@ function composeCssEntries(): Plugin {
|
|
|
48
50
|
|
|
49
51
|
// Component styles load first; core utilities intentionally load last.
|
|
50
52
|
// External imports must be deduplicated and hoisted before all rules.
|
|
51
|
-
coreAsset.source = composeCss(components, core)
|
|
52
|
-
styleAsset.source = composeCss(components, core, adminFonts)
|
|
53
|
+
coreAsset.source = composeCss(components, editor, core)
|
|
54
|
+
styleAsset.source = composeCss(components, editor, core, adminFonts)
|
|
53
55
|
},
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { HighlightJS, HighlightTheme } from './CodeTypes';
|
|
2
|
-
export declare function useHighlight(theme?: HighlightTheme): {
|
|
3
|
-
hljs: import('vue').Ref<{
|
|
4
|
-
highlight: (code: string, options: {
|
|
5
|
-
language: string;
|
|
6
|
-
ignoreIllegals: boolean;
|
|
7
|
-
}) => {
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
highlightAuto: (code: string) => {
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
13
|
-
getLanguage: (name: string) => any;
|
|
14
|
-
} | null, HighlightJS | {
|
|
15
|
-
highlight: (code: string, options: {
|
|
16
|
-
language: string;
|
|
17
|
-
ignoreIllegals: boolean;
|
|
18
|
-
}) => {
|
|
19
|
-
value: string;
|
|
20
|
-
};
|
|
21
|
-
highlightAuto: (code: string) => {
|
|
22
|
-
value: string;
|
|
23
|
-
};
|
|
24
|
-
getLanguage: (name: string) => any;
|
|
25
|
-
} | null>;
|
|
26
|
-
loaded: import('vue').Ref<boolean, boolean>;
|
|
27
|
-
loadHighlight: () => Promise<void>;
|
|
28
|
-
setTheme: (theme: HighlightTheme) => Promise<void>;
|
|
29
|
-
currentTheme: import('vue').Ref<HighlightTheme, HighlightTheme>;
|
|
30
|
-
escapeHtml: (unsafe: string) => string;
|
|
31
|
-
highlightCode: (code: string, language?: string, autodetect?: boolean, ignoreIllegals?: boolean) => string;
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=useHighlight.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/inputs/CodeEditor/useHighlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAU9D,wBAAgB,YAAY,CAAC,KAAK,GAAE,cAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;sBA2C3B,cAAc;;yBAyBjB,MAAM;0BAaL,MAAM,aAAa,MAAM;EA+BtD"}
|