@bagelink/vue 1.15.200 → 1.15.202
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/package.json
CHANGED
|
@@ -53,6 +53,20 @@ const maxHeight = computed(() => {
|
|
|
53
53
|
return h.match(/^\d+$/) ? `${h}px` : h
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
+
/** Light hljs themes need a dark caret + light color-scheme for native scrollbars. */
|
|
57
|
+
const isLightTheme = computed(() => {
|
|
58
|
+
const t = String(props.theme).toLowerCase()
|
|
59
|
+
if (t === 'light') return true
|
|
60
|
+
if (t === 'dark') return false
|
|
61
|
+
if (t.includes('dark')) return false
|
|
62
|
+
if (t.includes('light') || t.includes('dawn')) return true
|
|
63
|
+
return [
|
|
64
|
+
'github', 'xcode', 'vs', 'docco', 'default', 'foundation', 'googlecode',
|
|
65
|
+
'idea', 'magula', 'ascetic', 'brown-paper', 'color-brewer', 'grayscale',
|
|
66
|
+
'school-book', 'routeros', 'purebasic',
|
|
67
|
+
].includes(t)
|
|
68
|
+
})
|
|
69
|
+
|
|
56
70
|
const formattedCode = computed(() => {
|
|
57
71
|
return highlightCode(
|
|
58
72
|
code.value,
|
|
@@ -144,10 +158,15 @@ watch(() => props.modelValue, () => {
|
|
|
144
158
|
:style="[{ height: maxHeight }, shellStyle]"
|
|
145
159
|
>
|
|
146
160
|
<label v-if="label" class="label">{{ label }}</label>
|
|
147
|
-
<div
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
161
|
+
<div
|
|
162
|
+
v-if="loaded"
|
|
163
|
+
ref="editorRef"
|
|
164
|
+
class="code-editor-grandpa hljs"
|
|
165
|
+
:class="isLightTheme ? 'theme-light' : 'theme-dark'"
|
|
166
|
+
>
|
|
167
|
+
<div class="editor-content-papa">
|
|
168
|
+
<pre class="code-display"><code v-html="formattedCode" /></pre>
|
|
169
|
+
<pre v-if="placeholder && !hasCodeValue" class="code-placeholder">{{ placeholder }}</pre>
|
|
151
170
|
<textarea
|
|
152
171
|
v-if="!readonly && !disabled" :value="code" class="code-input" spellcheck="false"
|
|
153
172
|
autocomplete="off" autocorrect="off" autocapitalize="off" @input="handleInput"
|
|
@@ -161,105 +180,116 @@ watch(() => props.modelValue, () => {
|
|
|
161
180
|
</template>
|
|
162
181
|
|
|
163
182
|
<style scoped>
|
|
164
|
-
|
|
165
183
|
.code-editor-container {
|
|
166
|
-
margin-bottom: 0.5rem;
|
|
167
|
-
height: 100%;
|
|
184
|
+
margin-bottom: 0.5rem;
|
|
185
|
+
height: 100%;
|
|
168
186
|
}
|
|
169
187
|
|
|
170
188
|
.label {
|
|
171
|
-
display: block;
|
|
172
|
-
text-align: left;
|
|
173
|
-
margin-bottom: 0.25rem;
|
|
189
|
+
display: block;
|
|
190
|
+
text-align: left;
|
|
191
|
+
margin-bottom: 0.25rem;
|
|
174
192
|
}
|
|
175
193
|
|
|
176
194
|
.code-editor-grandpa {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
195
|
+
--code-caret-color: #fff;
|
|
196
|
+
border-radius: var(--code-border-radius, 0.25rem);
|
|
197
|
+
width: 100%;
|
|
198
|
+
height: 100%;
|
|
199
|
+
overflow: auto;
|
|
200
|
+
overscroll-behavior: contain;
|
|
201
|
+
padding: 1ch;
|
|
202
|
+
padding-inline-start: 2ch;
|
|
203
|
+
color-scheme: dark;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.code-editor-grandpa.theme-light {
|
|
207
|
+
--code-caret-color: #1b1f23;
|
|
208
|
+
color-scheme: light;
|
|
183
209
|
}
|
|
184
210
|
|
|
185
211
|
.code-editor-grandpa:focus-within {
|
|
186
|
-
outline: solid 1px var(--bgl-border-color, #4f575f);
|
|
187
|
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.13);
|
|
212
|
+
outline: solid 1px var(--bgl-border-color, #4f575f);
|
|
213
|
+
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.13);
|
|
188
214
|
}
|
|
189
215
|
|
|
190
216
|
.editor-content-papa {
|
|
191
|
-
|
|
192
|
-
|
|
217
|
+
/* Stack pre + textarea in one cell so both share the content-sized box */
|
|
218
|
+
display: grid;
|
|
219
|
+
min-width: 100%;
|
|
220
|
+
width: max-content;
|
|
193
221
|
min-height: 100%;
|
|
222
|
+
/* Cover the scrollable overflow area (grandpa bg doesn't paint past its box) */
|
|
223
|
+
background: inherit;
|
|
194
224
|
}
|
|
195
225
|
|
|
196
226
|
.code-display,
|
|
197
|
-
.code-input
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
.code-input,
|
|
228
|
+
.code-placeholder {
|
|
229
|
+
grid-area: 1 / 1;
|
|
230
|
+
box-sizing: border-box;
|
|
231
|
+
margin: 0;
|
|
232
|
+
/* Extra line so caret can sit on a trailing empty line */
|
|
233
|
+
padding: 0 0 1.5em;
|
|
234
|
+
min-width: 100%;
|
|
235
|
+
width: auto;
|
|
236
|
+
height: auto;
|
|
237
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
238
|
+
font-size: 1em;
|
|
239
|
+
font-variant-ligatures: none;
|
|
240
|
+
letter-spacing: normal;
|
|
241
|
+
line-height: 1.5;
|
|
242
|
+
tab-size: 2;
|
|
243
|
+
/* Match wrapping: pre defaults to `pre`, textarea to `pre-wrap` */
|
|
244
|
+
white-space: pre;
|
|
245
|
+
overflow-wrap: normal;
|
|
246
|
+
word-break: normal;
|
|
247
|
+
text-align: left;
|
|
248
|
+
border: none;
|
|
209
249
|
}
|
|
210
250
|
|
|
211
251
|
.code-display {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
z-index: 1;
|
|
252
|
+
pointer-events: none;
|
|
253
|
+
z-index: 1;
|
|
215
254
|
}
|
|
216
255
|
|
|
217
256
|
.code-placeholder {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
padding: 0;
|
|
222
|
-
width: 100%;
|
|
223
|
-
height: 100%;
|
|
224
|
-
font-family: monospace;
|
|
225
|
-
font-size: 1em;
|
|
226
|
-
line-height: 1.5;
|
|
227
|
-
text-align: left;
|
|
228
|
-
pointer-events: none;
|
|
229
|
-
opacity: 0.4;
|
|
230
|
-
z-index: 1;
|
|
257
|
+
pointer-events: none;
|
|
258
|
+
opacity: 0.4;
|
|
259
|
+
z-index: 1;
|
|
231
260
|
}
|
|
232
261
|
|
|
233
262
|
.code-display code {
|
|
234
|
-
display: block;
|
|
235
|
-
background: transparent !important;
|
|
236
|
-
padding: 0 !important;
|
|
263
|
+
display: block;
|
|
264
|
+
background: transparent !important;
|
|
265
|
+
padding: 0 !important;
|
|
237
266
|
}
|
|
238
267
|
|
|
239
268
|
.code-input {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
269
|
+
width: 100%;
|
|
270
|
+
height: 100%;
|
|
271
|
+
background: transparent;
|
|
272
|
+
color: transparent;
|
|
273
|
+
-webkit-text-fill-color: transparent;
|
|
274
|
+
caret-color: var(--code-caret-color);
|
|
275
|
+
resize: none;
|
|
276
|
+
outline: none;
|
|
277
|
+
/* Grandpa handles scrolling — avoid a second scrollbar */
|
|
278
|
+
overflow: hidden;
|
|
279
|
+
z-index: 2;
|
|
248
280
|
}
|
|
249
281
|
|
|
250
282
|
.code-input::selection {
|
|
251
|
-
background-color: rgba(36, 102, 188, 0.3);
|
|
252
|
-
color: transparent;
|
|
283
|
+
background-color: rgba(36, 102, 188, 0.3);
|
|
284
|
+
color: transparent;
|
|
285
|
+
-webkit-text-fill-color: transparent;
|
|
253
286
|
}
|
|
254
|
-
|
|
255
287
|
</style>
|
|
256
288
|
|
|
257
289
|
<style>
|
|
258
|
-
|
|
259
290
|
/* Global styles */
|
|
260
291
|
pre code.hljs {
|
|
261
|
-
padding: 0 !important;
|
|
262
|
-
background: transparent !important;
|
|
292
|
+
padding: 0 !important;
|
|
293
|
+
background: transparent !important;
|
|
263
294
|
}
|
|
264
|
-
|
|
265
295
|
</style>
|