origam 2.38.0 → 2.38.2
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/CHANGELOG.md +34 -0
- package/dist/src/assets/locales/en.json +1 -1
- package/dist/src/assets/locales/fr.json +2 -2
- package/dist/src/components/Alert/OrigamAlert.vue +739 -165
- package/dist/src/components/App/OrigamApp.vue +95 -19
- package/dist/src/components/App/OrigamAppBar.vue +751 -158
- package/dist/src/components/Audio/OrigamAudio.vue +1288 -346
- package/dist/src/components/Audio/OrigamAudioWaveform.vue +63 -7
- package/dist/src/components/Avatar/OrigamAvatar.vue +678 -126
- package/dist/src/components/Avatar/OrigamAvatarGroup.vue +700 -153
- package/dist/src/components/Badge/OrigamBadge.vue +548 -135
- package/dist/src/components/Blockquote/OrigamBlockquote.vue +698 -140
- package/dist/src/components/BottomNav/OrigamBottomNav.vue +864 -156
- package/dist/src/components/Bracket/OrigamBracket.vue +1013 -380
- package/dist/src/components/Bracket/OrigamBracketCompetitor.vue +674 -154
- package/dist/src/components/Bracket/OrigamBracketMatch.vue +663 -163
- package/dist/src/components/Bracket/OrigamBracketRound.vue +116 -34
- package/dist/src/components/Breadcrumb/OrigamBreadcrumb.vue +654 -119
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbDivider.vue +292 -54
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbItem.vue +657 -126
- package/dist/src/components/Btn/OrigamBtn.vue +928 -249
- package/dist/src/components/Btn/OrigamBtnGroup.vue +658 -141
- package/dist/src/components/Btn/OrigamBtnToggle.vue +578 -91
- package/dist/src/components/Calendar/OrigamCalendar.vue +1142 -484
- package/dist/src/components/Card/OrigamCard.vue +938 -194
- package/dist/src/components/Card/OrigamCardHeader.vue +593 -104
- package/dist/src/components/Card/OrigamCardText.vue +536 -84
- package/dist/src/components/Carousel/OrigamCarousel.vue +778 -202
- package/dist/src/components/Carousel/OrigamCarouselItem.vue +660 -109
- package/dist/src/components/Chart/OrigamChart.vue +942 -452
- package/dist/src/components/Chart/OrigamChartAxis.vue +111 -19
- package/dist/src/components/Chart/OrigamChartBoxPlot.vue +713 -297
- package/dist/src/components/Chart/OrigamChartBullet.vue +701 -286
- package/dist/src/components/Chart/OrigamChartCandlestick.vue +663 -243
- package/dist/src/components/Chart/OrigamChartCartesian.vue +1055 -487
- package/dist/src/components/Chart/OrigamChartGauge.vue +563 -164
- package/dist/src/components/Chart/OrigamChartHeatmap.vue +677 -251
- package/dist/src/components/Chart/OrigamChartHoneycomb.vue +700 -288
- package/dist/src/components/Chart/OrigamChartLegend.vue +108 -16
- package/dist/src/components/Chart/OrigamChartMap.vue +723 -299
- package/dist/src/components/Chart/OrigamChartPareto.vue +721 -276
- package/dist/src/components/Chart/OrigamChartPictorial.vue +777 -355
- package/dist/src/components/Chart/OrigamChartPolar.vue +603 -210
- package/dist/src/components/Chart/OrigamChartPolarBar.vue +674 -271
- package/dist/src/components/Chart/OrigamChartPyramid.vue +685 -250
- package/dist/src/components/Chart/OrigamChartRadar.vue +515 -165
- package/dist/src/components/Chart/OrigamChartRangeSelector.vue +50 -25
- package/dist/src/components/Chart/OrigamChartSankey.vue +913 -467
- package/dist/src/components/Chart/OrigamChartSparkline.vue +711 -268
- package/dist/src/components/Chart/OrigamChartStreamgraph.vue +810 -368
- package/dist/src/components/Chart/OrigamChartSunburst.vue +779 -368
- package/dist/src/components/Chart/OrigamChartTooltip.vue +78 -19
- package/dist/src/components/Chart/OrigamChartTreemap.vue +750 -288
- package/dist/src/components/Chart/OrigamChartVariwide.vue +679 -251
- package/dist/src/components/Chart/OrigamChartWordCloud.vue +674 -265
- package/dist/src/components/Checkbox/OrigamCheckbox.vue +781 -136
- package/dist/src/components/Checkbox/OrigamCheckboxBtn.vue +465 -81
- package/dist/src/components/Checkbox/OrigamCheckboxGroup.vue +824 -137
- package/dist/src/components/Chip/OrigamChip.vue +867 -202
- package/dist/src/components/Chip/OrigamChipGroup.vue +633 -121
- package/dist/src/components/ClientOnly/OrigamClientOnly.vue +30 -4
- package/dist/src/components/Clipboard/OrigamClipboard.vue +624 -105
- package/dist/src/components/Code/OrigamCode.vue +844 -206
- package/dist/src/components/CodeGroup/OrigamCodeGroup.vue +494 -83
- package/dist/src/components/ColorPicker/OrigamColorPicker.vue +777 -159
- package/dist/src/components/ColorPicker/OrigamColorPickerCanvas.vue +295 -181
- package/dist/src/components/ColorPicker/OrigamColorPickerEdit.vue +108 -45
- package/dist/src/components/ColorPicker/OrigamColorPickerPreview.vue +131 -46
- package/dist/src/components/ColorPicker/OrigamColorPickerSwatches.vue +128 -39
- package/dist/src/components/ColorPickerField/OrigamColorPickerField.vue +1123 -258
- package/dist/src/components/CommandPalette/OrigamCommandPalette.vue +415 -162
- package/dist/src/components/ConfirmWrapper/OrigamConfirmWrapper.vue +389 -145
- package/dist/src/components/ContextualMenu/OrigamContextualMenu.vue +852 -147
- package/dist/src/components/Counter/OrigamCounter.vue +588 -96
- package/dist/src/components/DataList/OrigamDataList.vue +619 -113
- package/dist/src/components/DataList/OrigamDataText.vue +295 -65
- package/dist/src/components/DataList/OrigamDataTitle.vue +295 -65
- package/dist/src/components/DataTable/OrigamDataTable.vue +934 -222
- package/dist/src/components/DataTable/OrigamDataTableColumnCell.vue +196 -51
- package/dist/src/components/DataTable/OrigamDataTableFooter.vue +319 -78
- package/dist/src/components/DataTable/OrigamDataTableGroupHeaderRow.vue +124 -44
- package/dist/src/components/DataTable/OrigamDataTableHeaderCell.vue +181 -70
- package/dist/src/components/DataTable/OrigamDataTableHeaders.vue +155 -46
- package/dist/src/components/DataTable/OrigamDataTableHeadersCell.vue +145 -27
- package/dist/src/components/DataTable/OrigamDataTableHeadersCellMobile.vue +126 -43
- package/dist/src/components/DataTable/OrigamDataTableRow.vue +151 -73
- package/dist/src/components/DataTable/OrigamDataTableRows.vue +261 -106
- package/dist/src/components/DatePicker/OrigamDatePicker.vue +1048 -261
- package/dist/src/components/DatePicker/OrigamDatePickerControls.vue +155 -51
- package/dist/src/components/DatePicker/OrigamDatePickerHeader.vue +147 -46
- package/dist/src/components/DatePicker/OrigamDatePickerMonth.vue +312 -134
- package/dist/src/components/DatePicker/OrigamDatePickerMonths.vue +151 -61
- package/dist/src/components/DatePicker/OrigamDatePickerYears.vue +154 -67
- package/dist/src/components/DatePickerField/OrigamDatePickerField.vue +1147 -306
- package/dist/src/components/DefaultsProvider/OrigamDefaultsProvider.vue +74 -14
- package/dist/src/components/Dialog/OrigamDialog.vue +953 -196
- package/dist/src/components/Dialog/OrigamDialogConfirmation.vue +886 -148
- package/dist/src/components/Divider/OrigamDivider.vue +210 -50
- package/dist/src/components/Drawer/OrigamDrawer.vue +909 -207
- package/dist/src/components/EmptyState/OrigamEmptyState.vue +146 -35
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanel.vue +746 -159
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelContent.vue +591 -95
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelHeader.vue +663 -143
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanels.vue +675 -134
- package/dist/src/components/Field/OrigamField.vue +1118 -306
- package/dist/src/components/FileField/OrigamFileField.vue +1188 -311
- package/dist/src/components/FileField/OrigamFileFieldDragNDropItem.vue +155 -36
- package/dist/src/components/FileField/OrigamFileFieldListItem.vue +155 -36
- package/dist/src/components/Form/OrigamForm.vue +197 -74
- package/dist/src/components/Grid/OrigamGrid.vue +707 -147
- package/dist/src/components/Grid/OrigamGridItem.vue +110 -37
- package/dist/src/components/Grids/OrigamCol.vue +593 -110
- package/dist/src/components/Grids/OrigamContainer.vue +461 -80
- package/dist/src/components/Grids/OrigamRow.vue +573 -112
- package/dist/src/components/Grids/OrigamSpacer.vue +54 -17
- package/dist/src/components/Icon/OrigamClassIcon.vue +573 -98
- package/dist/src/components/Icon/OrigamComponentIcon.vue +561 -101
- package/dist/src/components/Icon/OrigamIcon.vue +561 -98
- package/dist/src/components/Icon/OrigamLigatureIcon.vue +558 -98
- package/dist/src/components/Icon/OrigamSvgIcon.vue +593 -100
- package/dist/src/components/Img/OrigamImg.vue +869 -228
- package/dist/src/components/InfiniteScroll/OrigamInfiniteScroll.vue +319 -111
- package/dist/src/components/InfiniteScroll/OrigamInfiniteScrollIntersect.vue +80 -17
- package/dist/src/components/InlineEdit/OrigamInlineEdit.vue +476 -140
- package/dist/src/components/Input/OrigamInput.vue +747 -180
- package/dist/src/components/ItemGroup/OrigamItemGroup.vue +112 -36
- package/dist/src/components/ItemGroup/OrigamItemGroupItem.vue +80 -29
- package/dist/src/components/Kbd/OrigamKbd.vue +450 -75
- package/dist/src/components/Label/OrigamLabel.vue +584 -95
- package/dist/src/components/Layout/OrigamLayout.vue +563 -94
- package/dist/src/components/Lazy/OrigamLazy.vue +131 -34
- package/dist/src/components/List/OrigamList.vue +755 -170
- package/dist/src/components/List/OrigamListChildren.vue +59 -19
- package/dist/src/components/List/OrigamListGroup.vue +631 -134
- package/dist/src/components/List/OrigamListGroupActivator.vue +45 -17
- package/dist/src/components/List/OrigamListItem.vue +890 -224
- package/dist/src/components/List/OrigamListItemWrapper.vue +20 -10
- package/dist/src/components/List/OrigamListSubheader.vue +542 -93
- package/dist/src/components/Loader/OrigamLoader.vue +110 -25
- package/dist/src/components/Main/OrigamMain.vue +565 -96
- package/dist/src/components/Masonry/OrigamMasonry.vue +799 -187
- package/dist/src/components/Media/OrigamMediaController.vue +465 -182
- package/dist/src/components/Media/OrigamMediaScrubber.vue +389 -152
- package/dist/src/components/Media/OrigamMediaVolumeControl.vue +174 -44
- package/dist/src/components/Menu/OrigamMenu.vue +1079 -255
- package/dist/src/components/Messages/OrigamMessages.vue +606 -97
- package/dist/src/components/NumberField/OrigamNumberField.vue +1208 -333
- package/dist/src/components/NumberFormat/OrigamNumberFormat.vue +177 -57
- package/dist/src/components/OtpInputField/OrigamOtpInputField.vue +1016 -272
- package/dist/src/components/Overlay/OrigamOverlay.vue +446 -158
- package/dist/src/components/Overlay/OrigamOverlayScrim.vue +122 -30
- package/dist/src/components/Pagination/OrigamPagination.vue +982 -313
- package/dist/src/components/Parallax/OrigamParallax.vue +800 -259
- package/dist/src/components/Parallax/OrigamParallaxElement.vue +694 -178
- package/dist/src/components/Parallax/OrigamParallaxLayer.vue +132 -47
- package/dist/src/components/PasswordField/OrigamPasswordField.vue +1098 -265
- package/dist/src/components/Picker/OrigamPicker.vue +655 -108
- package/dist/src/components/Picker/OrigamPickerTitle.vue +108 -26
- package/dist/src/components/Progress/OrigamProgress.vue +436 -70
- package/dist/src/components/Progress/OrigamProgressCircular.vue +399 -82
- package/dist/src/components/Progress/OrigamProgressLinear.vue +468 -115
- package/dist/src/components/QrCode/OrigamQrCode.vue +642 -126
- package/dist/src/components/Radio/OrigamRadio.vue +772 -132
- package/dist/src/components/Radio/OrigamRadioBtn.vue +446 -71
- package/dist/src/components/Radio/OrigamRadioGroup.vue +808 -135
- package/dist/src/components/RatingField/OrigamRatingField.vue +963 -194
- package/dist/src/components/RatingField/OrigamRatingFieldItem.vue +657 -106
- package/dist/src/components/Responsive/OrigamResponsive.vue +548 -91
- package/dist/src/components/Select/OrigamSelect.vue +1639 -567
- package/dist/src/components/SelectionControl/OrigamSelectionControl.vue +564 -151
- package/dist/src/components/SelectionControl/OrigamSelectionControlGroup.vue +178 -62
- package/dist/src/components/Sheet/OrigamSheet.vue +773 -199
- package/dist/src/components/Skeleton/OrigamSkeleton.vue +249 -46
- package/dist/src/components/Skeleton/OrigamSkeletonGroup.vue +66 -11
- package/dist/src/components/Slide/OrigamSlideGroup.vue +772 -257
- package/dist/src/components/SliderField/OrigamSliderField.vue +1157 -335
- package/dist/src/components/SliderField/OrigamSliderFieldTrack.vue +236 -112
- package/dist/src/components/Snackbar/OrigamSnackbar.vue +871 -214
- package/dist/src/components/Snackbar/OrigamSnackbarGroup.vue +218 -51
- package/dist/src/components/Snackbar/OrigamSnackbarItem.vue +175 -43
- package/dist/src/components/Stepper/OrigamStepper.vue +618 -126
- package/dist/src/components/Stepper/OrigamStepperItem.vue +98 -37
- package/dist/src/components/Switch/OrigamSwitch.vue +879 -156
- package/dist/src/components/Switch/OrigamSwitchTrack.vue +431 -78
- package/dist/src/components/SystemBar/OrigamSystemBar.vue +517 -87
- package/dist/src/components/Table/OrigamTable.vue +585 -124
- package/dist/src/components/Tabs/OrigamTab.vue +239 -73
- package/dist/src/components/Tabs/OrigamTabPanel.vue +125 -39
- package/dist/src/components/Tabs/OrigamTabPanels.vue +148 -57
- package/dist/src/components/Tabs/OrigamTabs.vue +381 -109
- package/dist/src/components/TextField/OrigamTextField.vue +1077 -258
- package/dist/src/components/TextMask/OrigamTextMask.vue +150 -43
- package/dist/src/components/TextareaField/OrigamTextareaField.vue +1162 -310
- package/dist/src/components/TextareaField/OrigamTextareaFieldRichToolbar.vue +77 -79
- package/dist/src/components/ThemeProvider/OrigamThemeProvider.vue +44 -9
- package/dist/src/components/Timeline/OrigamTimeline.vue +113 -43
- package/dist/src/components/Timeline/OrigamTimelineItem.vue +163 -76
- package/dist/src/components/Title/OrigamTitle.vue +505 -82
- package/dist/src/components/Toolbar/OrigamToolbar.vue +679 -142
- package/dist/src/components/Tooltip/OrigamTooltip.vue +288 -72
- package/dist/src/components/Transition/OrigamExpandX.vue +219 -106
- package/dist/src/components/Transition/OrigamExpandY.vue +219 -106
- package/dist/src/components/Transition/OrigamFade.vue +47 -9
- package/dist/src/components/Transition/OrigamReverseTranslatePicker.vue +52 -10
- package/dist/src/components/Transition/OrigamScaleRotate.vue +52 -10
- package/dist/src/components/Transition/OrigamSlideX.vue +52 -10
- package/dist/src/components/Transition/OrigamSlideY.vue +52 -10
- package/dist/src/components/Transition/OrigamSnack.vue +52 -10
- package/dist/src/components/Transition/OrigamTransition.vue +40 -12
- package/dist/src/components/Transition/OrigamTranslateBottom.vue +52 -10
- package/dist/src/components/Transition/OrigamTranslatePicker.vue +52 -10
- package/dist/src/components/Transition/OrigamTranslateScale.vue +209 -97
- package/dist/src/components/Transition/OrigamWindowXReverseTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowXTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowYReverseTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowYTranslate.vue +40 -7
- package/dist/src/components/Treeview/OrigamTreeview.vue +258 -118
- package/dist/src/components/Treeview/OrigamTreeviewNode.vue +126 -88
- package/dist/src/components/Video/OrigamVideo.vue +1178 -331
- package/dist/src/components/VirtualScroll/OrigamVirtualScroll.vue +147 -55
- package/dist/src/components/VirtualScroll/OrigamVirtualScrollItem.vue +94 -19
- package/dist/src/components/Watermark/OrigamWatermark.vue +224 -124
- package/dist/src/components/Window/OrigamWindow.vue +745 -175
- package/dist/src/components/Window/OrigamWindowItem.vue +162 -69
- package/dist/src/composables/Commons/display.composable.cjs +2 -0
- package/dist/src/composables/Commons/display.composable.js +1 -1
- package/dist/src/interfaces/Pagination/pagination.interface.d.ts +1 -1
- package/package.json +8 -8
|
@@ -113,92 +113,623 @@ import vContrast from "../../directives/Contrast/contrast.directive";
|
|
|
113
113
|
import { CODE_DEFAULTS } from "../../consts/Code/code.const";
|
|
114
114
|
import { CODE_LANG } from "../../enums/Code/code.enum";
|
|
115
115
|
import { parseHighlightLines } from "../../utils/Code/parse-highlight-lines.util";
|
|
116
|
+
/*********************************************************
|
|
117
|
+
* Global
|
|
118
|
+
*
|
|
119
|
+
* @description
|
|
120
|
+
* Props + defaults for `<OrigamCode>`. The component is a thin wrapper
|
|
121
|
+
* around shiki: it owns the DOM (header / copy button / line gutter /
|
|
122
|
+
* scroller) while the highlighted HTML is produced by the `useCode`
|
|
123
|
+
* singleton and injected via `innerHTML` on a `<code>` ref. We do NOT
|
|
124
|
+
* use `v-html` because we need to post-process shiki's output to add
|
|
125
|
+
* row-level classes for line-numbers + highlight-lines.
|
|
126
|
+
*
|
|
127
|
+
* Theme integration:
|
|
128
|
+
* shiki v4.3.1 no longer ships a `css-variables` built-in theme (the
|
|
129
|
+
* mechanism this comment used to describe, and that the now-removed
|
|
130
|
+
* `--origam-code__syntax---*` tokens targeted — see #661/C2). Syntax
|
|
131
|
+
* colouring is therefore NOT themeable via origam design tokens: it
|
|
132
|
+
* comes from TWO real shiki themes (light + dark) highlighted once,
|
|
133
|
+
* each span carrying both colours via `--shiki-light` / `--shiki-dark`
|
|
134
|
+
* inline custom properties (shiki's own `defaultColor: false` dual-theme
|
|
135
|
+
* output). The scoped `<style>` block below just picks whichever of
|
|
136
|
+
* the two the active `data-theme`/`data-mode` calls for — see the
|
|
137
|
+
* "Dual-theme shiki" block further down. Still no JS re-render on
|
|
138
|
+
* theme switch, just a different `var()` resolving.
|
|
139
|
+
********************************************************/
|
|
116
140
|
const props = defineProps({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
141
|
+
code: {
|
|
142
|
+
type: String,
|
|
143
|
+
required: false,
|
|
144
|
+
default: undefined
|
|
145
|
+
},
|
|
146
|
+
lang: {
|
|
147
|
+
type: null,
|
|
148
|
+
required: false,
|
|
149
|
+
default: CODE_LANG.PLAINTEXT
|
|
150
|
+
},
|
|
151
|
+
lineNumbers: {
|
|
152
|
+
type: Boolean,
|
|
153
|
+
required: false,
|
|
154
|
+
default: false
|
|
155
|
+
},
|
|
156
|
+
highlightLines: {
|
|
157
|
+
type: [
|
|
158
|
+
Array,
|
|
159
|
+
String,
|
|
160
|
+
null
|
|
161
|
+
],
|
|
162
|
+
required: false,
|
|
163
|
+
default: null
|
|
164
|
+
},
|
|
165
|
+
copyable: {
|
|
166
|
+
type: Boolean,
|
|
167
|
+
required: false,
|
|
168
|
+
default: true
|
|
169
|
+
},
|
|
170
|
+
format: {
|
|
171
|
+
type: Boolean,
|
|
172
|
+
required: false,
|
|
173
|
+
default: false
|
|
174
|
+
},
|
|
175
|
+
wrap: {
|
|
176
|
+
type: Boolean,
|
|
177
|
+
required: false,
|
|
178
|
+
default: false
|
|
179
|
+
},
|
|
180
|
+
filename: {
|
|
181
|
+
type: String,
|
|
182
|
+
required: false,
|
|
183
|
+
default: undefined
|
|
184
|
+
},
|
|
185
|
+
compact: {
|
|
186
|
+
type: Boolean,
|
|
187
|
+
required: false,
|
|
188
|
+
default: false
|
|
189
|
+
},
|
|
190
|
+
prompt: {
|
|
191
|
+
type: String,
|
|
192
|
+
required: false,
|
|
193
|
+
default: undefined
|
|
194
|
+
},
|
|
195
|
+
hideHeader: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
required: false,
|
|
198
|
+
default: false
|
|
199
|
+
},
|
|
200
|
+
flat: {
|
|
201
|
+
type: Boolean,
|
|
202
|
+
required: false,
|
|
203
|
+
default: false
|
|
204
|
+
},
|
|
205
|
+
scrollerAriaLabel: {
|
|
206
|
+
type: String,
|
|
207
|
+
required: false,
|
|
208
|
+
default: undefined
|
|
209
|
+
},
|
|
210
|
+
id: {
|
|
211
|
+
type: String,
|
|
212
|
+
required: false
|
|
213
|
+
},
|
|
214
|
+
class: {
|
|
215
|
+
type: [
|
|
216
|
+
String,
|
|
217
|
+
Array,
|
|
218
|
+
Object
|
|
219
|
+
],
|
|
220
|
+
required: false
|
|
221
|
+
},
|
|
222
|
+
style: {
|
|
223
|
+
type: [
|
|
224
|
+
String,
|
|
225
|
+
Array,
|
|
226
|
+
Object,
|
|
227
|
+
Boolean,
|
|
228
|
+
null
|
|
229
|
+
],
|
|
230
|
+
required: false,
|
|
231
|
+
skipCheck: true
|
|
232
|
+
},
|
|
233
|
+
tag: {
|
|
234
|
+
type: String,
|
|
235
|
+
required: false,
|
|
236
|
+
default: "figure"
|
|
237
|
+
},
|
|
238
|
+
border: {
|
|
239
|
+
type: [
|
|
240
|
+
Boolean,
|
|
241
|
+
Number,
|
|
242
|
+
String,
|
|
243
|
+
Array
|
|
244
|
+
],
|
|
245
|
+
required: false,
|
|
246
|
+
skipCheck: true
|
|
247
|
+
},
|
|
248
|
+
borderTop: {
|
|
249
|
+
type: [
|
|
250
|
+
Boolean,
|
|
251
|
+
Number,
|
|
252
|
+
String
|
|
253
|
+
],
|
|
254
|
+
required: false
|
|
255
|
+
},
|
|
256
|
+
borderLeft: {
|
|
257
|
+
type: [
|
|
258
|
+
Boolean,
|
|
259
|
+
Number,
|
|
260
|
+
String
|
|
261
|
+
],
|
|
262
|
+
required: false
|
|
263
|
+
},
|
|
264
|
+
borderBottom: {
|
|
265
|
+
type: [
|
|
266
|
+
Boolean,
|
|
267
|
+
Number,
|
|
268
|
+
String
|
|
269
|
+
],
|
|
270
|
+
required: false
|
|
271
|
+
},
|
|
272
|
+
borderRight: {
|
|
273
|
+
type: [
|
|
274
|
+
Boolean,
|
|
275
|
+
Number,
|
|
276
|
+
String
|
|
277
|
+
],
|
|
278
|
+
required: false
|
|
279
|
+
},
|
|
280
|
+
borderBlock: {
|
|
281
|
+
type: [
|
|
282
|
+
Boolean,
|
|
283
|
+
Number,
|
|
284
|
+
String
|
|
285
|
+
],
|
|
286
|
+
required: false
|
|
287
|
+
},
|
|
288
|
+
borderInline: {
|
|
289
|
+
type: [
|
|
290
|
+
Boolean,
|
|
291
|
+
Number,
|
|
292
|
+
String
|
|
293
|
+
],
|
|
294
|
+
required: false
|
|
295
|
+
},
|
|
296
|
+
borderInlineStart: {
|
|
297
|
+
type: [
|
|
298
|
+
Boolean,
|
|
299
|
+
Number,
|
|
300
|
+
String
|
|
301
|
+
],
|
|
302
|
+
required: false
|
|
303
|
+
},
|
|
304
|
+
borderInlineEnd: {
|
|
305
|
+
type: [
|
|
306
|
+
Boolean,
|
|
307
|
+
Number,
|
|
308
|
+
String
|
|
309
|
+
],
|
|
310
|
+
required: false
|
|
311
|
+
},
|
|
312
|
+
borderBlockStart: {
|
|
313
|
+
type: [
|
|
314
|
+
Boolean,
|
|
315
|
+
Number,
|
|
316
|
+
String
|
|
317
|
+
],
|
|
318
|
+
required: false
|
|
319
|
+
},
|
|
320
|
+
borderBlockEnd: {
|
|
321
|
+
type: [
|
|
322
|
+
Boolean,
|
|
323
|
+
Number,
|
|
324
|
+
String
|
|
325
|
+
],
|
|
326
|
+
required: false
|
|
327
|
+
},
|
|
328
|
+
borderColor: {
|
|
329
|
+
type: String,
|
|
330
|
+
required: false
|
|
331
|
+
},
|
|
332
|
+
borderStyle: {
|
|
333
|
+
type: String,
|
|
334
|
+
required: false
|
|
335
|
+
},
|
|
336
|
+
borderTopColor: {
|
|
337
|
+
type: [
|
|
338
|
+
String,
|
|
339
|
+
Object,
|
|
340
|
+
Boolean,
|
|
341
|
+
null
|
|
342
|
+
],
|
|
343
|
+
required: false,
|
|
344
|
+
skipCheck: true
|
|
345
|
+
},
|
|
346
|
+
borderRightColor: {
|
|
347
|
+
type: [
|
|
348
|
+
String,
|
|
349
|
+
Object,
|
|
350
|
+
Boolean,
|
|
351
|
+
null
|
|
352
|
+
],
|
|
353
|
+
required: false,
|
|
354
|
+
skipCheck: true
|
|
355
|
+
},
|
|
356
|
+
borderBottomColor: {
|
|
357
|
+
type: [
|
|
358
|
+
String,
|
|
359
|
+
Object,
|
|
360
|
+
Boolean,
|
|
361
|
+
null
|
|
362
|
+
],
|
|
363
|
+
required: false,
|
|
364
|
+
skipCheck: true
|
|
365
|
+
},
|
|
366
|
+
borderLeftColor: {
|
|
367
|
+
type: [
|
|
368
|
+
String,
|
|
369
|
+
Object,
|
|
370
|
+
Boolean,
|
|
371
|
+
null
|
|
372
|
+
],
|
|
373
|
+
required: false,
|
|
374
|
+
skipCheck: true
|
|
375
|
+
},
|
|
376
|
+
borderInlineStartColor: {
|
|
377
|
+
type: [
|
|
378
|
+
String,
|
|
379
|
+
Object,
|
|
380
|
+
Boolean,
|
|
381
|
+
null
|
|
382
|
+
],
|
|
383
|
+
required: false,
|
|
384
|
+
skipCheck: true
|
|
385
|
+
},
|
|
386
|
+
borderInlineEndColor: {
|
|
387
|
+
type: [
|
|
388
|
+
String,
|
|
389
|
+
Object,
|
|
390
|
+
Boolean,
|
|
391
|
+
null
|
|
392
|
+
],
|
|
393
|
+
required: false,
|
|
394
|
+
skipCheck: true
|
|
395
|
+
},
|
|
396
|
+
borderBlockStartColor: {
|
|
397
|
+
type: [
|
|
398
|
+
String,
|
|
399
|
+
Object,
|
|
400
|
+
Boolean,
|
|
401
|
+
null
|
|
402
|
+
],
|
|
403
|
+
required: false,
|
|
404
|
+
skipCheck: true
|
|
405
|
+
},
|
|
406
|
+
borderBlockEndColor: {
|
|
407
|
+
type: [
|
|
408
|
+
String,
|
|
409
|
+
Object,
|
|
410
|
+
Boolean,
|
|
411
|
+
null
|
|
412
|
+
],
|
|
413
|
+
required: false,
|
|
414
|
+
skipCheck: true
|
|
415
|
+
},
|
|
416
|
+
rounded: {
|
|
417
|
+
type: [
|
|
418
|
+
Boolean,
|
|
419
|
+
Number,
|
|
420
|
+
String,
|
|
421
|
+
null
|
|
422
|
+
],
|
|
423
|
+
required: false,
|
|
424
|
+
skipCheck: true
|
|
425
|
+
},
|
|
426
|
+
roundedTopRight: {
|
|
427
|
+
type: [
|
|
428
|
+
Boolean,
|
|
429
|
+
Number,
|
|
430
|
+
String
|
|
431
|
+
],
|
|
432
|
+
required: false
|
|
433
|
+
},
|
|
434
|
+
roundedTopLeft: {
|
|
435
|
+
type: [
|
|
436
|
+
Boolean,
|
|
437
|
+
Number,
|
|
438
|
+
String
|
|
439
|
+
],
|
|
440
|
+
required: false
|
|
441
|
+
},
|
|
442
|
+
roundedBottomLeft: {
|
|
443
|
+
type: [
|
|
444
|
+
Boolean,
|
|
445
|
+
Number,
|
|
446
|
+
String
|
|
447
|
+
],
|
|
448
|
+
required: false
|
|
449
|
+
},
|
|
450
|
+
roundedBottomRight: {
|
|
451
|
+
type: [
|
|
452
|
+
Boolean,
|
|
453
|
+
Number,
|
|
454
|
+
String
|
|
455
|
+
],
|
|
456
|
+
required: false
|
|
457
|
+
},
|
|
458
|
+
roundedStartStart: {
|
|
459
|
+
type: [
|
|
460
|
+
Boolean,
|
|
461
|
+
Number,
|
|
462
|
+
String
|
|
463
|
+
],
|
|
464
|
+
required: false
|
|
465
|
+
},
|
|
466
|
+
roundedStartEnd: {
|
|
467
|
+
type: [
|
|
468
|
+
Boolean,
|
|
469
|
+
Number,
|
|
470
|
+
String
|
|
471
|
+
],
|
|
472
|
+
required: false
|
|
473
|
+
},
|
|
474
|
+
roundedEndStart: {
|
|
475
|
+
type: [
|
|
476
|
+
Boolean,
|
|
477
|
+
Number,
|
|
478
|
+
String
|
|
479
|
+
],
|
|
480
|
+
required: false
|
|
481
|
+
},
|
|
482
|
+
roundedEndEnd: {
|
|
483
|
+
type: [
|
|
484
|
+
Boolean,
|
|
485
|
+
Number,
|
|
486
|
+
String
|
|
487
|
+
],
|
|
488
|
+
required: false
|
|
489
|
+
},
|
|
490
|
+
elevation: {
|
|
491
|
+
type: [Number, String],
|
|
492
|
+
required: false
|
|
493
|
+
},
|
|
494
|
+
padding: {
|
|
495
|
+
type: [
|
|
496
|
+
Boolean,
|
|
497
|
+
Number,
|
|
498
|
+
String
|
|
499
|
+
],
|
|
500
|
+
required: false
|
|
501
|
+
},
|
|
502
|
+
paddingTop: {
|
|
503
|
+
type: [
|
|
504
|
+
Boolean,
|
|
505
|
+
Number,
|
|
506
|
+
String
|
|
507
|
+
],
|
|
508
|
+
required: false
|
|
509
|
+
},
|
|
510
|
+
paddingLeft: {
|
|
511
|
+
type: [
|
|
512
|
+
Boolean,
|
|
513
|
+
Number,
|
|
514
|
+
String
|
|
515
|
+
],
|
|
516
|
+
required: false
|
|
517
|
+
},
|
|
518
|
+
paddingBottom: {
|
|
519
|
+
type: [
|
|
520
|
+
Boolean,
|
|
521
|
+
Number,
|
|
522
|
+
String
|
|
523
|
+
],
|
|
524
|
+
required: false
|
|
525
|
+
},
|
|
526
|
+
paddingRight: {
|
|
527
|
+
type: [
|
|
528
|
+
Boolean,
|
|
529
|
+
Number,
|
|
530
|
+
String
|
|
531
|
+
],
|
|
532
|
+
required: false
|
|
533
|
+
},
|
|
534
|
+
paddingBlock: {
|
|
535
|
+
type: [
|
|
536
|
+
Boolean,
|
|
537
|
+
Number,
|
|
538
|
+
String
|
|
539
|
+
],
|
|
540
|
+
required: false
|
|
541
|
+
},
|
|
542
|
+
paddingInline: {
|
|
543
|
+
type: [
|
|
544
|
+
Boolean,
|
|
545
|
+
Number,
|
|
546
|
+
String
|
|
547
|
+
],
|
|
548
|
+
required: false
|
|
549
|
+
},
|
|
550
|
+
paddingInlineStart: {
|
|
551
|
+
type: [
|
|
552
|
+
Boolean,
|
|
553
|
+
Number,
|
|
554
|
+
String
|
|
555
|
+
],
|
|
556
|
+
required: false
|
|
557
|
+
},
|
|
558
|
+
paddingInlineEnd: {
|
|
559
|
+
type: [
|
|
560
|
+
Boolean,
|
|
561
|
+
Number,
|
|
562
|
+
String
|
|
563
|
+
],
|
|
564
|
+
required: false
|
|
565
|
+
},
|
|
566
|
+
paddingBlockStart: {
|
|
567
|
+
type: [
|
|
568
|
+
Boolean,
|
|
569
|
+
Number,
|
|
570
|
+
String
|
|
571
|
+
],
|
|
572
|
+
required: false
|
|
573
|
+
},
|
|
574
|
+
paddingBlockEnd: {
|
|
575
|
+
type: [
|
|
576
|
+
Boolean,
|
|
577
|
+
Number,
|
|
578
|
+
String
|
|
579
|
+
],
|
|
580
|
+
required: false
|
|
581
|
+
},
|
|
582
|
+
margin: {
|
|
583
|
+
type: [
|
|
584
|
+
Boolean,
|
|
585
|
+
Number,
|
|
586
|
+
String
|
|
587
|
+
],
|
|
588
|
+
required: false
|
|
589
|
+
},
|
|
590
|
+
marginTop: {
|
|
591
|
+
type: [
|
|
592
|
+
Boolean,
|
|
593
|
+
Number,
|
|
594
|
+
String
|
|
595
|
+
],
|
|
596
|
+
required: false
|
|
597
|
+
},
|
|
598
|
+
marginLeft: {
|
|
599
|
+
type: [
|
|
600
|
+
Boolean,
|
|
601
|
+
Number,
|
|
602
|
+
String
|
|
603
|
+
],
|
|
604
|
+
required: false
|
|
605
|
+
},
|
|
606
|
+
marginBottom: {
|
|
607
|
+
type: [
|
|
608
|
+
Boolean,
|
|
609
|
+
Number,
|
|
610
|
+
String
|
|
611
|
+
],
|
|
612
|
+
required: false
|
|
613
|
+
},
|
|
614
|
+
marginRight: {
|
|
615
|
+
type: [
|
|
616
|
+
Boolean,
|
|
617
|
+
Number,
|
|
618
|
+
String
|
|
619
|
+
],
|
|
620
|
+
required: false
|
|
621
|
+
},
|
|
622
|
+
marginBlock: {
|
|
623
|
+
type: [
|
|
624
|
+
Boolean,
|
|
625
|
+
Number,
|
|
626
|
+
String
|
|
627
|
+
],
|
|
628
|
+
required: false
|
|
629
|
+
},
|
|
630
|
+
marginInline: {
|
|
631
|
+
type: [
|
|
632
|
+
Boolean,
|
|
633
|
+
Number,
|
|
634
|
+
String
|
|
635
|
+
],
|
|
636
|
+
required: false
|
|
637
|
+
},
|
|
638
|
+
marginInlineStart: {
|
|
639
|
+
type: [
|
|
640
|
+
Boolean,
|
|
641
|
+
Number,
|
|
642
|
+
String
|
|
643
|
+
],
|
|
644
|
+
required: false
|
|
645
|
+
},
|
|
646
|
+
marginInlineEnd: {
|
|
647
|
+
type: [
|
|
648
|
+
Boolean,
|
|
649
|
+
Number,
|
|
650
|
+
String
|
|
651
|
+
],
|
|
652
|
+
required: false
|
|
653
|
+
},
|
|
654
|
+
marginBlockStart: {
|
|
655
|
+
type: [
|
|
656
|
+
Boolean,
|
|
657
|
+
Number,
|
|
658
|
+
String
|
|
659
|
+
],
|
|
660
|
+
required: false
|
|
661
|
+
},
|
|
662
|
+
marginBlockEnd: {
|
|
663
|
+
type: [
|
|
664
|
+
Boolean,
|
|
665
|
+
Number,
|
|
666
|
+
String
|
|
667
|
+
],
|
|
668
|
+
required: false
|
|
669
|
+
},
|
|
670
|
+
height: {
|
|
671
|
+
type: [Number, String],
|
|
672
|
+
required: false
|
|
673
|
+
},
|
|
674
|
+
maxHeight: {
|
|
675
|
+
type: [Number, String],
|
|
676
|
+
required: false
|
|
677
|
+
},
|
|
678
|
+
maxWidth: {
|
|
679
|
+
type: [Number, String],
|
|
680
|
+
required: false
|
|
681
|
+
},
|
|
682
|
+
minHeight: {
|
|
683
|
+
type: [Number, String],
|
|
684
|
+
required: false
|
|
685
|
+
},
|
|
686
|
+
minWidth: {
|
|
687
|
+
type: [Number, String],
|
|
688
|
+
required: false
|
|
689
|
+
},
|
|
690
|
+
width: {
|
|
691
|
+
type: [Number, String],
|
|
692
|
+
required: false
|
|
693
|
+
},
|
|
694
|
+
color: {
|
|
695
|
+
type: [
|
|
696
|
+
String,
|
|
697
|
+
Object,
|
|
698
|
+
Boolean,
|
|
699
|
+
null
|
|
700
|
+
],
|
|
701
|
+
required: false,
|
|
702
|
+
skipCheck: true
|
|
703
|
+
},
|
|
704
|
+
bgColor: {
|
|
705
|
+
type: [
|
|
706
|
+
String,
|
|
707
|
+
Object,
|
|
708
|
+
Boolean,
|
|
709
|
+
null
|
|
710
|
+
],
|
|
711
|
+
required: false,
|
|
712
|
+
skipCheck: true
|
|
713
|
+
},
|
|
714
|
+
fontFamily: {
|
|
715
|
+
type: null,
|
|
716
|
+
required: false
|
|
717
|
+
},
|
|
718
|
+
fontSize: {
|
|
719
|
+
type: null,
|
|
720
|
+
required: false
|
|
721
|
+
},
|
|
722
|
+
lineHeight: {
|
|
723
|
+
type: null,
|
|
724
|
+
required: false
|
|
725
|
+
}
|
|
198
726
|
});
|
|
199
727
|
const emit = defineEmits(["copy"]);
|
|
200
728
|
defineSlots();
|
|
201
729
|
const slots = useSlots();
|
|
730
|
+
/*********************************************************
|
|
731
|
+
* Composables (chrome)
|
|
732
|
+
********************************************************/
|
|
202
733
|
const { borderClasses, borderStyles } = useBorder(props);
|
|
203
734
|
const { roundedClasses, roundedStyles } = useRounded(props);
|
|
204
735
|
const { elevationClasses } = useElevation(props);
|
|
@@ -209,167 +740,274 @@ const { dimensionStyles } = useDimension(props);
|
|
|
209
740
|
const { typographyStyles } = useTypography(props, "code");
|
|
210
741
|
const { highlight } = useCode();
|
|
211
742
|
const { t } = useLocale();
|
|
743
|
+
/*********************************************************
|
|
744
|
+
* Zone defilante — accessibilite (#535)
|
|
745
|
+
*
|
|
746
|
+
* @description
|
|
747
|
+
* ⛔ Un conteneur qui defile doit etre atteignable au clavier : sans
|
|
748
|
+
* `tabindex`, un utilisateur qui ne se sert pas d'une souris ne peut pas
|
|
749
|
+
* lire un bloc de code plus large que sa colonne. C'est la regle axe
|
|
750
|
+
* `scrollable-region-focusable`, et c'etait la seconde violation relevee
|
|
751
|
+
* par la suite a11y marketing du 2026-08-31.
|
|
752
|
+
*
|
|
753
|
+
* @description
|
|
754
|
+
* `role="region"` accompagne le `tabindex` : une zone focusable sans nom
|
|
755
|
+
* accessible est annoncee « groupe, vide » par un lecteur d'ecran. Le
|
|
756
|
+
* couple role + `aria-label` la nomme.
|
|
757
|
+
********************************************************/
|
|
758
|
+
/*********************************************************
|
|
759
|
+
* @description
|
|
760
|
+
* ⛔ Le nom etait la chaine statique « Code block, scrollable region »
|
|
761
|
+
* pour TOUTES les instances. Une page qui en aligne cinq presentait donc
|
|
762
|
+
* cinq regions rigoureusement homonymes dans la liste des reperes d'un
|
|
763
|
+
* lecteur d'ecran — un nom qui ne distingue rien ne nomme rien. La doc
|
|
764
|
+
* annoncait deja « an `aria-label` that includes the filename (or
|
|
765
|
+
* language fallback) » ; c'est cette promesse qui est ici tenue.
|
|
766
|
+
*
|
|
767
|
+
* @description
|
|
768
|
+
* Ordre de resolution : `filename` s'il est fourni (c'est ce que
|
|
769
|
+
* l'auteur a choisi de montrer dans l'en-tete), sinon `lang` tant qu'il
|
|
770
|
+
* n'est pas `plaintext` (qui ne distingue rien non plus), sinon le nom
|
|
771
|
+
* generique d'origine.
|
|
772
|
+
********************************************************/
|
|
212
773
|
const scrollerLabel = computed(() => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
774
|
+
if (props.scrollerAriaLabel) return props.scrollerAriaLabel;
|
|
775
|
+
if (props.filename) return t("origam.code.scroller_aria_label_filename", { filename: props.filename });
|
|
776
|
+
if (props.lang && props.lang !== CODE_LANG.PLAINTEXT) return t("origam.code.scroller_aria_label_lang", { lang: props.lang });
|
|
777
|
+
return t("origam.code.scroller_aria_label");
|
|
217
778
|
});
|
|
779
|
+
/*********************************************************
|
|
780
|
+
* Source extraction — prop wins over slot, slot used as fallback.
|
|
781
|
+
*
|
|
782
|
+
* The slot path is what authors usually want for multi-line snippets
|
|
783
|
+
* that read better in the template. We re-extract every time the
|
|
784
|
+
* default slot changes (rare, but possible with v-if), so the
|
|
785
|
+
* computed depends on `slots.default?.()` length.
|
|
786
|
+
********************************************************/
|
|
218
787
|
function extractSlotText() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
788
|
+
const nodes = slots.default?.();
|
|
789
|
+
if (!nodes || nodes.length === 0) return "";
|
|
790
|
+
const parts = [];
|
|
791
|
+
const visit = (vnode) => {
|
|
792
|
+
if (vnode == null) return;
|
|
793
|
+
if (typeof vnode === "string") {
|
|
794
|
+
parts.push(vnode);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
if (typeof vnode === "number" || typeof vnode === "boolean") {
|
|
798
|
+
parts.push(String(vnode));
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (Array.isArray(vnode)) {
|
|
802
|
+
vnode.forEach(visit);
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
const obj = vnode;
|
|
806
|
+
if (obj && "children" in obj) visit(obj.children);
|
|
807
|
+
};
|
|
808
|
+
visit(nodes);
|
|
809
|
+
return parts.join("");
|
|
241
810
|
}
|
|
242
811
|
const sourceCode = computed(() => {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
812
|
+
if (typeof props.code === "string") return props.code;
|
|
813
|
+
const fromSlot = extractSlotText();
|
|
814
|
+
return fromSlot.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
246
815
|
});
|
|
816
|
+
/*********************************************************
|
|
817
|
+
* Format — currently a no-op past whitespace normalisation.
|
|
818
|
+
*
|
|
819
|
+
* Prettier weighs ~600 KB and we don't want to bundle it at runtime
|
|
820
|
+
* for a niche convenience. When `format` is true we collapse Windows
|
|
821
|
+
* line endings + strip trailing whitespace, which is enough for the
|
|
822
|
+
* 90 % of cases where the input came from a copy-paste.
|
|
823
|
+
********************************************************/
|
|
247
824
|
let _formatWarned = false;
|
|
248
825
|
const formattedCode = computed(() => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
return raw.replace(/\r\n/g, "\n").split("\n").map((l) => l.replace(/[ \t]+$/, "")).join("\n");
|
|
826
|
+
const raw = sourceCode.value;
|
|
827
|
+
if (!props.format) return raw;
|
|
828
|
+
if (!_formatWarned) {
|
|
829
|
+
_formatWarned = true;
|
|
830
|
+
console.warn("[origam] OrigamCode: the `format` prop is a stub in v2.x. " + "Prettier is intentionally not bundled at runtime; the current " + "implementation normalises whitespace only. Full formatting is planned for v3.");
|
|
831
|
+
}
|
|
832
|
+
return raw.replace(/\r\n/g, "\n").split("\n").map((l) => l.replace(/[ \t]+$/, "")).join("\n");
|
|
258
833
|
});
|
|
834
|
+
/*********************************************************
|
|
835
|
+
* Highlight pipeline.
|
|
836
|
+
*
|
|
837
|
+
* We track:
|
|
838
|
+
* - `renderedHtml`: shiki's raw `<pre class="shiki"><code>...</code></pre>`
|
|
839
|
+
*
|
|
840
|
+
* The watcher re-runs on source / lang changes. We swallow stale promise
|
|
841
|
+
* results so a fast lang-switch doesn't paint the wrong tokens.
|
|
842
|
+
*
|
|
843
|
+
* Theme changes are handled entirely by CSS, NOT origam design tokens
|
|
844
|
+
* (#661/C2 — see the "Global" block's doc-comment above): each span
|
|
845
|
+
* shiki emits already carries both `--shiki-light` and `--shiki-dark`
|
|
846
|
+
* inline, and the scoped `<style>` block picks whichever one the
|
|
847
|
+
* current `data-theme`/`data-mode` calls for.
|
|
848
|
+
********************************************************/
|
|
259
849
|
const codeRef = ref(null);
|
|
260
850
|
const isHighlighting = ref(false);
|
|
261
851
|
let _renderToken = 0;
|
|
262
852
|
const highlightedLines = computed(() => {
|
|
263
|
-
|
|
264
|
-
|
|
853
|
+
const arr = parseHighlightLines(props.highlightLines);
|
|
854
|
+
return new Set(arr);
|
|
265
855
|
});
|
|
266
856
|
async function rebuild() {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
857
|
+
const token = ++_renderToken;
|
|
858
|
+
isHighlighting.value = true;
|
|
859
|
+
try {
|
|
860
|
+
const html = await highlight(formattedCode.value, props.lang);
|
|
861
|
+
if (token !== _renderToken) return;
|
|
862
|
+
paintIntoDom(html);
|
|
863
|
+
} catch (err) {
|
|
864
|
+
/*********************************************************
|
|
865
|
+
* #1189 — safety net
|
|
866
|
+
*
|
|
867
|
+
* @description
|
|
868
|
+
* Whatever rejects upstream, the block must never stay empty:
|
|
869
|
+
* paint the code as plain escaped rows, same path as the `null`
|
|
870
|
+
* highlighter fallback.
|
|
871
|
+
********************************************************/
|
|
872
|
+
console.warn("[origam] OrigamCode: highlighting failed — rendering plain code.", err);
|
|
873
|
+
if (token === _renderToken) {
|
|
874
|
+
const plain = document.createElement("div");
|
|
875
|
+
plain.textContent = formattedCode.value;
|
|
876
|
+
paintIntoDom(plain.innerHTML);
|
|
877
|
+
}
|
|
878
|
+
} finally {
|
|
879
|
+
if (token === _renderToken) isHighlighting.value = false;
|
|
880
|
+
}
|
|
283
881
|
}
|
|
882
|
+
/**
|
|
883
|
+
* Post-process shiki's HTML to expose per-row hooks for line numbers +
|
|
884
|
+
* line-highlighting. shiki emits `<pre class="shiki ...">\n<code>\n<span class="line">…</span>\n…</code>\n</pre>`.
|
|
885
|
+
* We extract only the inner `<code>...</code>` and wrap each `.line`
|
|
886
|
+
* span with a `.origam-code__row` element that carries our data-* hooks.
|
|
887
|
+
*/
|
|
284
888
|
function paintIntoDom(rawHtml) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
889
|
+
const target = codeRef.value;
|
|
890
|
+
if (!target) return;
|
|
891
|
+
// Strip outer <pre>... </pre> — we already render our own.
|
|
892
|
+
const innerMatch = rawHtml.match(/<code[^>]*>([\s\S]*?)<\/code>/);
|
|
893
|
+
const inner = innerMatch ? innerMatch[1] : rawHtml;
|
|
894
|
+
// Split on line spans. shiki emits `<span class="line">…</span>\n`
|
|
895
|
+
// per logical line; the regex preserves the order and lets us wrap
|
|
896
|
+
// each one with our own row container.
|
|
897
|
+
/*********************************************************
|
|
898
|
+
* Trailing newline (#1216)
|
|
899
|
+
*
|
|
900
|
+
* @description
|
|
901
|
+
* A source ending in a newline makes shiki emit a last EMPTY `.line`
|
|
902
|
+
* span: drop it so the trailing newline gets no line number.
|
|
903
|
+
********************************************************/
|
|
904
|
+
const lines = inner.split(/\n/).filter((l, idx, arr) => !(idx === arr.length - 1 && l.replace(/<span class="line"><\/span>/, "").trim() === ""));
|
|
905
|
+
const highlightSet = highlightedLines.value;
|
|
906
|
+
const rows = lines.map((line, i) => {
|
|
907
|
+
const lineNo = i + 1;
|
|
908
|
+
const isHl = highlightSet.has(lineNo) ? " origam-code__row--highlighted" : "";
|
|
909
|
+
return `<span class="origam-code__row${isHl}" data-line="${lineNo}">${line || " "}</span>`;
|
|
910
|
+
}).join("");
|
|
911
|
+
// Background colour comes from origam tokens via SCSS — we ignore
|
|
912
|
+
// any background colour shiki would emit because our surface is
|
|
913
|
+
// always themed by the design system tokens.
|
|
914
|
+
target.innerHTML = rows;
|
|
297
915
|
}
|
|
298
|
-
watch(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
{ immediate: false }
|
|
304
|
-
);
|
|
916
|
+
watch([formattedCode, () => props.lang], () => {
|
|
917
|
+
void rebuild();
|
|
918
|
+
}, { immediate: false });
|
|
919
|
+
// Highlight-lines is purely a class swap on already-rendered rows — no
|
|
920
|
+
// shiki re-render needed.
|
|
305
921
|
watch(highlightedLines, () => {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
922
|
+
const target = codeRef.value;
|
|
923
|
+
if (!target) return;
|
|
924
|
+
target.querySelectorAll(".origam-code__row").forEach((row) => {
|
|
925
|
+
const lineNo = Number(row.dataset.line);
|
|
926
|
+
row.classList.toggle("origam-code__row--highlighted", highlightedLines.value.has(lineNo));
|
|
927
|
+
});
|
|
312
928
|
});
|
|
313
929
|
onMounted(() => {
|
|
314
|
-
|
|
930
|
+
void rebuild();
|
|
315
931
|
});
|
|
932
|
+
/*********************************************************
|
|
933
|
+
* Copy-to-clipboard with feedback.
|
|
934
|
+
********************************************************/
|
|
316
935
|
const { copy, copied } = useClipboard({ feedbackDuration: CODE_DEFAULTS.copyFeedbackDurationMs });
|
|
317
936
|
async function handleCopy() {
|
|
318
|
-
|
|
319
|
-
|
|
937
|
+
const text = formattedCode.value;
|
|
938
|
+
if (await copy(text)) emit("copy", text);
|
|
320
939
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
);
|
|
327
|
-
const copyBtnStyle = {
|
|
328
|
-
|
|
329
|
-
|
|
940
|
+
/*********************************************************
|
|
941
|
+
* Labels — localised through the DS i18n provider (`useLocale`).
|
|
942
|
+
* Keys live under `origam.code.*` in the shipped locale messages.
|
|
943
|
+
********************************************************/
|
|
944
|
+
const copyButtonLabel = computed(() => copied.value ? t("origam.code.copied") : t("origam.code.copy"));
|
|
945
|
+
const copyAriaLabel = computed(() => copied.value ? t("origam.code.copied_aria_label") : t("origam.code.copy_aria_label"));
|
|
946
|
+
const copyBtnStyle = { padding: "var(--origam-code__copy---padding-block) var(--origam-code__copy---padding-inline)" };
|
|
947
|
+
/*********************************************************
|
|
948
|
+
* Class & Style.
|
|
949
|
+
********************************************************/
|
|
330
950
|
const showHeader = computed(() => !props.compact && !props.hideHeader && (!!props.filename || !!slots.header || props.copyable));
|
|
951
|
+
/**
|
|
952
|
+
* Compact-mode copy control is an icon button, not a text "Copy". It swaps
|
|
953
|
+
* to a check mark while the "copied" feedback window is open so the inline
|
|
954
|
+
* pill never grows / reflows (a text label would).
|
|
955
|
+
*/
|
|
331
956
|
const compactCopyIcon = computed(() => copied.value ? "mdi-check" : "mdi-content-copy");
|
|
957
|
+
/**
|
|
958
|
+
* `<figcaption>` is only valid as a child of `<figure>` (W3C HTML5 Living
|
|
959
|
+
* Standard). When the consumer overrides `tag` to something other than
|
|
960
|
+
* `'figure'` (back-compat usage with `tag="div"`) we fall back to a
|
|
961
|
+
* plain `<div>` for the header so the rendered markup stays W3C-correct.
|
|
962
|
+
*/
|
|
332
963
|
const headerTag = computed(() => props.tag === "figure" ? "figcaption" : "div");
|
|
333
964
|
const codeClasses = computed(() => [
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
965
|
+
"origam-code",
|
|
966
|
+
`origam-code--lang-${props.lang}`,
|
|
967
|
+
{
|
|
968
|
+
"origam-code--compact": props.compact,
|
|
969
|
+
"origam-code--line-numbers": props.lineNumbers && !props.compact,
|
|
970
|
+
"origam-code--wrap": props.wrap,
|
|
971
|
+
"origam-code--has-header": showHeader.value,
|
|
972
|
+
"origam-code--copyable": props.copyable,
|
|
973
|
+
"origam-code--max-height": props.maxHeight != null,
|
|
974
|
+
"origam-code--flat": props.flat
|
|
975
|
+
},
|
|
976
|
+
props.flat ? [] : borderClasses.value,
|
|
977
|
+
props.flat ? [] : roundedClasses.value,
|
|
978
|
+
props.flat ? [] : elevationClasses.value,
|
|
979
|
+
paddingClasses.value,
|
|
980
|
+
props.flat ? [] : marginClasses.value,
|
|
981
|
+
colorClasses.value,
|
|
982
|
+
props.class
|
|
352
983
|
]);
|
|
353
984
|
const codeStyles = computed(() => [
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
985
|
+
props.flat ? {} : borderStyles.value,
|
|
986
|
+
props.flat ? {} : roundedStyles.value,
|
|
987
|
+
paddingStyles.value,
|
|
988
|
+
props.flat ? {} : marginStyles.value,
|
|
989
|
+
colorStyles.value,
|
|
990
|
+
dimensionStyles.value,
|
|
991
|
+
typographyStyles.value,
|
|
992
|
+
props.style
|
|
362
993
|
]);
|
|
363
994
|
const preClasses = computed(() => ({
|
|
364
|
-
|
|
365
|
-
|
|
995
|
+
"origam-code__pre--line-numbers": props.lineNumbers,
|
|
996
|
+
"origam-code__pre--wrap": props.wrap
|
|
366
997
|
}));
|
|
367
998
|
const scrollerStyles = computed(() => {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
999
|
+
if (props.maxHeight == null) return {};
|
|
1000
|
+
const value = typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight;
|
|
1001
|
+
return {
|
|
1002
|
+
"--origam-code---max-height": value,
|
|
1003
|
+
maxHeight: value
|
|
1004
|
+
};
|
|
1005
|
+
});
|
|
1006
|
+
defineExpose({
|
|
1007
|
+
rebuild,
|
|
1008
|
+
copied,
|
|
1009
|
+
codeRef
|
|
371
1010
|
});
|
|
372
|
-
defineExpose({ rebuild, copied, codeRef });
|
|
373
1011
|
</script>
|
|
374
1012
|
|
|
375
1013
|
<style lang="scss">
|