@esportsplus/ui 0.57.0 → 0.58.0
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/README.md +123 -39
- package/build/components/accordion/group.d.ts +14 -0
- package/build/components/accordion/group.js +21 -0
- package/build/components/accordion/index.d.ts +9 -0
- package/build/components/accordion/index.js +20 -3
- package/build/components/accordion/scss/index.scss +1 -1
- package/build/components/announcement/scss/index.scss +1 -1
- package/build/components/breadcrumb/scss/index.scss +1 -1
- package/build/components/button/scss/index.scss +1 -1
- package/build/components/button/sidebar.d.ts +3 -0
- package/build/components/button/sidebar.js +40 -10
- package/build/components/capslock/index.js +1 -1
- package/build/components/capslock/scss/index.scss +1 -1
- package/build/components/card/scss/index.scss +1 -1
- package/build/components/cc/scss/index.scss +1 -1
- package/build/components/chat-minimap/scss/index.scss +1 -1
- package/build/components/checkbox/scss/index.scss +1 -1
- package/build/components/color-picker/index.d.ts +1 -0
- package/build/components/color-picker/index.js +166 -136
- package/build/components/color-picker/scss/index.scss +1 -1
- package/build/components/command/index.d.ts +0 -1
- package/build/components/command/index.js +3 -2
- package/build/components/command/scss/index.scss +1 -1
- package/build/components/copy/scss/index.scss +1 -1
- package/build/components/counter/scss/index.scss +1 -1
- package/build/components/datalist/index.js +3 -3
- package/build/components/datalist/scss/index.scss +1 -1
- package/build/components/dock/scss/index.scss +1 -1
- package/build/components/editor/code/index.d.ts +0 -1
- package/build/components/editor/code/index.js +0 -1
- package/build/components/editor/code/minimap.d.ts +2 -1
- package/build/components/editor/code/minimap.js +5 -2
- package/build/components/editor/code/view.d.ts +3 -1
- package/build/components/editor/code/view.js +37 -26
- package/build/components/editor/diffs/index.d.ts +0 -1
- package/build/components/editor/diffs/index.js +0 -1
- package/build/components/editor/diffs/merge.js +7 -3
- package/build/components/editor/diffs/view.js +3 -1
- package/build/components/editor/index.d.ts +4 -1
- package/build/components/editor/index.js +2 -1
- package/build/components/editor/markdown/editing.js +22 -3
- package/build/components/editor/markdown/erase.d.ts +9 -0
- package/build/components/editor/markdown/erase.js +78 -0
- package/build/components/editor/markdown/index.d.ts +0 -1
- package/build/components/editor/markdown/index.js +0 -1
- package/build/components/editor/markdown/layout.d.ts +2 -9
- package/build/components/editor/markdown/layout.js +2 -7
- package/build/components/editor/markdown/render.d.ts +0 -1
- package/build/components/editor/markdown/render.js +287 -235
- package/build/components/editor/markdown/view.js +566 -667
- package/build/components/editor/viewer/index.d.ts +27 -0
- package/build/components/editor/viewer/index.js +250 -0
- package/build/components/editor/viewer/model.d.ts +15 -0
- package/build/components/editor/viewer/model.js +73 -0
- package/build/components/editor/workspace/index.d.ts +6 -2
- package/build/components/editor/workspace/index.js +243 -137
- package/build/components/editor/workspace/keybindings.d.ts +37 -0
- package/build/components/editor/workspace/keybindings.js +288 -0
- package/build/components/editor/workspace/model.d.ts +55 -2
- package/build/components/editor/workspace/model.js +141 -3
- package/build/components/editor/workspace/navigate.d.ts +19 -0
- package/build/components/editor/workspace/navigate.js +118 -0
- package/build/components/editor/workspace/session.d.ts +29 -0
- package/build/components/editor/workspace/session.js +373 -0
- package/build/components/editor/workspace/shortcuts.d.ts +19 -0
- package/build/components/editor/workspace/shortcuts.js +185 -0
- package/build/components/editor/workspace/status.d.ts +34 -0
- package/build/components/editor/workspace/status.js +193 -0
- package/build/components/editor/workspace/statusbar.d.ts +15 -0
- package/build/components/editor/workspace/statusbar.js +190 -0
- package/build/components/editor/workspace/strip.d.ts +27 -0
- package/build/components/editor/workspace/strip.js +239 -0
- package/build/components/editor/workspace/tabs.d.ts +15 -0
- package/build/components/editor/workspace/tabs.js +63 -0
- package/build/components/error/index.js +1 -1
- package/build/components/error/scss/index.scss +1 -1
- package/build/components/filter/index.js +5 -3
- package/build/components/filter/scss/index.scss +1 -1
- package/build/components/frame/scss/index.scss +1 -1
- package/build/components/heatmap/index.js +3 -3
- package/build/components/heatmap/scss/index.scss +1 -1
- package/build/components/highlight/scss/index.scss +1 -1
- package/build/components/icon/scss/index.scss +1 -1
- package/build/components/image/scss/index.scss +1 -1
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/components/inline-edit/scss/index.scss +1 -1
- package/build/components/input/scss/index.scss +1 -1
- package/build/components/link/scss/index.scss +1 -1
- package/build/components/loading/scss/index.scss +1 -1
- package/build/components/marquee/scss/index.scss +1 -1
- package/build/components/metric/scss/index.scss +1 -1
- package/build/components/nav/index.d.ts +1 -1
- package/build/components/nav/scss/index.scss +1 -1
- package/build/components/nav/tree.d.ts +3 -1
- package/build/components/nav/tree.js +30 -60
- package/build/components/notification/scss/index.scss +1 -1
- package/build/components/overlay/scss/index.scss +1 -1
- package/build/components/page/scss/index.scss +1 -1
- package/build/components/pagination/arrows.d.ts +15 -0
- package/build/components/pagination/arrows.js +65 -0
- package/build/components/pagination/cards.d.ts +23 -0
- package/build/components/pagination/cards.js +66 -0
- package/build/components/pagination/index.d.ts +5 -0
- package/build/components/pagination/index.js +3 -1
- package/build/components/pagination/scss/index.scss +1 -1
- package/build/components/progress/scss/index.scss +1 -1
- package/build/components/pull-to-refresh/scss/index.scss +1 -1
- package/build/components/range/index.js +1 -1
- package/build/components/range/scss/index.scss +1 -1
- package/build/components/relative-time/scss/index.scss +1 -1
- package/build/components/root/scss/index.scss +1 -1
- package/build/components/section/scss/index.scss +2 -0
- package/build/components/select/index.d.ts +1 -0
- package/build/components/select/index.js +16 -11
- package/build/components/select/scss/index.scss +1 -1
- package/build/components/shortcut-recorder/scss/index.scss +1 -1
- package/build/components/sortable/scss/index.scss +1 -1
- package/build/components/sticky-header/index.js +3 -3
- package/build/components/sticky-header/scss/index.scss +1 -1
- package/build/components/story/scss/index.scss +1 -1
- package/build/components/surface-field/scss/index.scss +1 -1
- package/build/components/tasklist/scss/index.scss +1 -1
- package/build/components/text/scss/index.scss +1 -1
- package/build/components/textarea/scss/index.scss +1 -1
- package/build/{css-utilities → components}/theme/index.d.ts +1 -1
- package/build/{css-utilities → components}/theme/index.js +15 -5
- package/build/components/theme/scss/index.scss +2 -0
- package/build/components/theme-picker/index.d.ts +52 -0
- package/build/components/theme-picker/index.js +167 -0
- package/build/components/theme-picker/scss/index.scss +2 -0
- package/build/components/toast/index.js +3 -5
- package/build/components/toast/scss/index.scss +1 -1
- package/build/components/tooltip/menu.js +3 -1
- package/build/components/tooltip/scss/index.scss +1 -1
- package/build/components/typewriter/scss/index.scss +1 -1
- package/build/components/uptime/scss/index.scss +1 -1
- package/build/components/usage-meter/scss/index.scss +1 -1
- package/build/{css-utilities → modifiers}/glass/index.d.ts +2 -2
- package/build/modifiers/glass/index.js +28 -0
- package/build/modifiers/glass/scss/index.scss +2 -0
- package/build/{css-utilities → modifiers}/index.d.ts +0 -1
- package/build/{css-utilities → modifiers}/index.js +0 -1
- package/build/modifiers/scrollbar/index.d.ts +72 -0
- package/build/{css-utilities → modifiers}/scrollbar/index.js +52 -19
- package/build/modifiers/scrollbar/scss/index.scss +2 -0
- package/build/normalize/scss/index.scss +1 -2
- package/layer.scss +1 -1
- package/package.json +11 -18
- package/scripts/code-editor-markdown.test.mjs +45 -14
- package/scripts/code-viewer.test.mjs +69 -0
- package/scripts/workspace-keybindings.test.mjs +273 -0
- package/scripts/workspace-session.test.mjs +349 -0
- package/scripts/workspace-status.test.mjs +229 -0
- package/scripts/workspace-tabs.test.mjs +142 -0
- package/src/components/accordion/group.ts +39 -0
- package/src/components/accordion/index.ts +32 -6
- package/src/components/accordion/scss/index.scss +12 -21
- package/src/components/accordion/scss/variables.scss +18 -3
- package/src/components/announcement/scss/index.scss +4 -4
- package/src/components/announcement/scss/variables.scss +6 -6
- package/src/components/banner/scss/index.scss +1 -1
- package/src/components/breadcrumb/scss/index.scss +35 -50
- package/src/components/breadcrumb/scss/variables.scss +23 -31
- package/src/components/button/scss/_fan.scss +39 -43
- package/src/components/button/scss/_morph.scss +66 -78
- package/src/components/button/scss/_sidebar.scss +41 -30
- package/src/components/button/scss/_split.scss +9 -9
- package/src/components/button/scss/index.scss +23 -19
- package/src/components/button/scss/variables.scss +94 -90
- package/src/components/button/sidebar.ts +36 -24
- package/src/components/capslock/index.ts +2 -2
- package/src/components/capslock/scss/index.scss +11 -6
- package/src/components/capslock/scss/variables.scss +3 -5
- package/src/components/card/scss/_expand.scss +58 -64
- package/src/components/card/scss/index.scss +40 -21
- package/src/components/card/scss/variables.scss +40 -31
- package/src/components/cc/scss/index.scss +68 -68
- package/src/components/cc/scss/variables.scss +13 -14
- package/src/components/chat-minimap/scss/index.scss +24 -16
- package/src/components/chat-minimap/scss/variables.scss +37 -37
- package/src/components/checkbox/scss/index.scss +54 -52
- package/src/components/checkbox/scss/variables.scss +37 -39
- package/src/components/color-picker/index.ts +157 -120
- package/src/components/color-picker/scss/index.scss +159 -96
- package/src/components/color-picker/scss/variables.scss +33 -15
- package/src/components/command/index.ts +3 -2
- package/src/components/command/scss/index.scss +10 -14
- package/src/components/command/scss/variables.scss +12 -35
- package/src/components/copy/scss/index.scss +6 -6
- package/src/components/copy/scss/variables.scss +12 -15
- package/src/components/counter/scss/index.scss +14 -14
- package/src/components/counter/scss/variables.scss +1 -1
- package/src/components/datalist/index.ts +3 -3
- package/src/components/datalist/scss/index.scss +7 -6
- package/src/components/datalist/scss/variables.scss +7 -3
- package/src/components/dock/scss/index.scss +10 -15
- package/src/components/dock/scss/variables.scss +29 -25
- package/src/components/editor/code/index.ts +0 -1
- package/src/components/editor/code/minimap.ts +13 -5
- package/src/components/editor/code/scss/_editor.scss +83 -81
- package/src/components/editor/code/scss/_features.scss +106 -97
- package/src/components/editor/code/scss/_services.scss +27 -25
- package/src/components/editor/code/scss/index.scss +0 -1
- package/src/components/editor/code/scss/variables.scss +30 -26
- package/src/components/editor/code/view.ts +14 -5
- package/src/components/editor/diffs/index.ts +0 -1
- package/src/components/editor/diffs/merge.ts +2 -1
- package/src/components/editor/diffs/scss/_diffs.scss +67 -57
- package/src/components/editor/diffs/scss/_merge.scss +17 -14
- package/src/components/editor/diffs/scss/index.scss +0 -1
- package/src/components/editor/diffs/scss/variables.scss +25 -18
- package/src/components/editor/diffs/view.ts +2 -1
- package/src/components/editor/index.ts +7 -1
- package/src/components/editor/markdown/editing.ts +38 -3
- package/src/components/editor/markdown/erase.ts +124 -0
- package/src/components/editor/markdown/index.ts +0 -1
- package/src/components/editor/markdown/layout.ts +3 -12
- package/src/components/editor/markdown/render.ts +65 -37
- package/src/components/editor/markdown/scss/index.scss +92 -124
- package/src/components/editor/markdown/scss/variables.scss +39 -19
- package/src/components/editor/markdown/view.ts +737 -786
- package/src/components/editor/tree/scss/index.scss +121 -110
- package/src/components/editor/tree/scss/variables.scss +48 -54
- package/src/components/editor/viewer/index.ts +321 -0
- package/src/components/editor/viewer/model.ts +130 -0
- package/src/components/editor/viewer/scss/_viewer.scss +302 -0
- package/src/components/editor/viewer/scss/index.scss +2 -0
- package/src/components/editor/viewer/scss/variables.scss +69 -0
- package/src/components/editor/workspace/index.ts +159 -31
- package/src/components/editor/workspace/keybindings.ts +447 -0
- package/src/components/editor/workspace/model.ts +233 -3
- package/src/components/editor/workspace/navigate.ts +194 -0
- package/src/components/editor/workspace/scss/index.scss +72 -59
- package/src/components/editor/workspace/scss/keybindings.scss +190 -0
- package/src/components/editor/workspace/scss/status.scss +122 -0
- package/src/components/editor/workspace/scss/tabs.scss +56 -0
- package/src/components/editor/workspace/session.ts +551 -0
- package/src/components/editor/workspace/shortcuts.ts +255 -0
- package/src/components/editor/workspace/status.ts +259 -0
- package/src/components/editor/workspace/statusbar.ts +255 -0
- package/src/components/editor/workspace/strip.ts +273 -0
- package/src/components/editor/workspace/tabs.ts +106 -0
- package/src/components/error/index.ts +1 -1
- package/src/components/error/scss/index.scss +19 -19
- package/src/components/error/scss/variables.scss +2 -2
- package/src/components/filter/index.ts +7 -2
- package/src/components/filter/scss/index.scss +1 -1
- package/src/components/filter/scss/variables.scss +11 -10
- package/src/components/frame/scss/index.scss +12 -12
- package/src/components/frame/scss/variables.scss +8 -8
- package/src/components/heatmap/index.ts +3 -3
- package/src/components/heatmap/scss/index.scss +28 -26
- package/src/components/heatmap/scss/variables.scss +18 -17
- package/src/components/highlight/scss/index.scss +17 -13
- package/src/components/highlight/scss/variables.scss +8 -10
- package/src/components/icon/scss/index.scss +10 -0
- package/src/components/icon/scss/variables.scss +5 -0
- package/src/components/image/scss/index.scss +9 -9
- package/src/components/image/scss/variables.scss +7 -2
- package/src/components/index.ts +2 -0
- package/src/components/inline-edit/scss/index.scss +99 -104
- package/src/components/inline-edit/scss/variables.scss +40 -39
- package/src/components/input/scss/_field.scss +6 -20
- package/src/components/input/scss/_scrub.scss +10 -8
- package/src/components/input/scss/_tag.scss +35 -37
- package/src/components/input/scss/variables.scss +100 -99
- package/src/components/link/scss/index.scss +4 -1
- package/src/components/loading/scss/index.scss +1 -1
- package/src/components/loading/scss/variables.scss +1 -1
- package/src/components/marquee/scss/index.scss +9 -5
- package/src/components/marquee/scss/variables.scss +3 -1
- package/src/components/metric/scss/_flash.scss +3 -1
- package/src/components/metric/scss/index.scss +8 -6
- package/src/components/metric/scss/variables.scss +26 -20
- package/src/components/nav/index.ts +1 -1
- package/src/components/nav/scss/index.scss +12 -40
- package/src/components/nav/scss/variables.scss +30 -11
- package/src/components/nav/tree.ts +19 -62
- package/src/components/notification/scss/index.scss +7 -7
- package/src/components/notification/scss/variables.scss +7 -9
- package/src/components/overlay/scss/index.scss +181 -170
- package/src/components/overlay/scss/variables.scss +26 -57
- package/src/components/page/scss/index.scss +12 -11
- package/src/components/page/scss/variables.scss +5 -0
- package/src/components/pagination/arrows.ts +58 -0
- package/src/components/pagination/cards.ts +57 -0
- package/src/components/pagination/index.ts +4 -1
- package/src/components/pagination/scss/_arrows.scss +69 -0
- package/src/components/pagination/scss/_cards.scss +121 -0
- package/src/components/pagination/scss/_dots.scss +2 -5
- package/src/components/pagination/scss/index.scss +8 -6
- package/src/components/pagination/scss/variables.scss +87 -37
- package/src/components/progress/scss/_text.scss +21 -18
- package/src/components/progress/scss/index.scss +1 -1
- package/src/components/progress/scss/variables.scss +12 -12
- package/src/components/pull-to-refresh/scss/index.scss +2 -1
- package/src/components/pull-to-refresh/scss/variables.scss +11 -6
- package/src/components/range/index.ts +1 -1
- package/src/components/range/scss/_filter.scss +62 -51
- package/src/components/range/scss/_slider.scss +78 -75
- package/src/components/range/scss/_vertical.scss +6 -6
- package/src/components/range/scss/index.scss +3 -2
- package/src/components/range/scss/variables.scss +26 -23
- package/src/components/relative-time/scss/index.scss +27 -27
- package/src/components/relative-time/scss/variables.scss +10 -12
- package/src/components/root/scss/index.scss +71 -43
- package/src/components/root/scss/variables.scss +35 -31
- package/src/components/section/scss/index.scss +31 -0
- package/src/components/section/scss/variables.scss +21 -0
- package/src/components/select/index.ts +11 -6
- package/src/components/select/scss/index.scss +21 -32
- package/src/components/select/scss/variables.scss +25 -18
- package/src/components/shortcut-recorder/scss/index.scss +13 -12
- package/src/components/shortcut-recorder/scss/variables.scss +12 -13
- package/src/components/sortable/scss/index.scss +47 -44
- package/src/components/sortable/scss/variables.scss +4 -5
- package/src/components/sticky-header/index.ts +4 -4
- package/src/components/sticky-header/scss/index.scss +14 -13
- package/src/components/sticky-header/scss/variables.scss +9 -9
- package/src/components/story/scss/index.scss +26 -30
- package/src/components/story/scss/variables.scss +16 -9
- package/src/components/surface-field/scss/index.scss +45 -40
- package/src/components/surface-field/scss/variables.scss +5 -6
- package/src/components/tasklist/scss/index.scss +19 -19
- package/src/components/tasklist/scss/variables.scss +26 -29
- package/src/components/text/scss/index.scss +2 -1
- package/src/components/textarea/scss/variables.scss +1 -1
- package/src/{css-utilities → components}/theme/index.ts +17 -3
- package/src/components/theme/scss/index.scss +1 -0
- package/src/components/theme/scss/variables.scss +78 -0
- package/src/components/theme-picker/index.ts +231 -0
- package/src/components/theme-picker/scss/index.scss +264 -0
- package/src/components/toast/index.ts +28 -30
- package/src/components/toast/scss/index.scss +87 -87
- package/src/components/toast/scss/variables.scss +39 -39
- package/src/components/tooltip/menu.ts +4 -1
- package/src/components/tooltip/scss/_east.scss +10 -10
- package/src/components/tooltip/scss/_menu.scss +284 -269
- package/src/components/tooltip/scss/_north.scss +10 -10
- package/src/components/tooltip/scss/_shared.scss +7 -7
- package/src/components/tooltip/scss/_south.scss +10 -10
- package/src/components/tooltip/scss/_west.scss +10 -10
- package/src/components/tooltip/scss/index.scss +21 -20
- package/src/components/tooltip/scss/variables.scss +104 -96
- package/src/components/typewriter/scss/_retype.scss +12 -11
- package/src/components/typewriter/scss/_rotate.scss +2 -1
- package/src/components/typewriter/scss/variables.scss +41 -39
- package/src/components/uptime/scss/index.scss +15 -15
- package/src/components/uptime/scss/variables.scss +8 -8
- package/src/components/usage-meter/scss/index.scss +3 -1
- package/src/components/usage-meter/scss/variables.scss +5 -5
- package/src/css-utilities/absolute.scss +64 -0
- package/src/css-utilities/background.scss +43 -0
- package/src/css-utilities/border.scss +45 -0
- package/src/css-utilities/box-shadow.scss +29 -0
- package/src/css-utilities/color.scss +41 -0
- package/src/css-utilities/flex.scss +64 -0
- package/src/css-utilities/font/geist/{scss/index.scss → index.scss} +12 -4
- package/src/css-utilities/font/montserrat/Montserrat-Italic-Variable.woff2 +0 -0
- package/src/css-utilities/font/montserrat/Montserrat-Variable.woff2 +0 -0
- package/src/css-utilities/font/montserrat/OFL.txt +93 -0
- package/src/css-utilities/font/montserrat/index.scss +38 -0
- package/src/{shared/scss → css-utilities}/icon.scss +1 -1
- package/src/css-utilities/{inline/scss/index.scss → inline.scss} +1 -1
- package/src/css-utilities/{skeleton/scss/index.scss → skeleton.scss} +11 -11
- package/src/css-utilities/surface.scss +266 -0
- package/src/css-utilities/text.scss +191 -0
- package/src/modifiers/glass/index.ts +44 -0
- package/src/{css-utilities → modifiers}/glass/scss/index.scss +6 -6
- package/src/{css-utilities → modifiers}/glass/scss/variables.scss +1 -1
- package/src/{css-utilities → modifiers}/index.ts +0 -1
- package/src/{css-utilities → modifiers}/scrollbar/index.ts +92 -17
- package/src/{css-utilities → modifiers}/scrollbar/scss/index.scss +178 -177
- package/src/{css-utilities → modifiers}/scrollbar/scss/variables.scss +28 -21
- package/src/normalize/scss/index.scss +4 -2
- package/src/shared/scss/color-weights.scss +19 -0
- package/src/shared/scss/index.scss +1 -12
- package/src/tokens/scss/blur.scss +5 -0
- package/src/tokens/scss/color.scss +74 -50
- package/src/tokens/scss/index.scss +1 -2
- package/src/tokens/scss/size.scss +0 -2
- package/src/tokens/scss/state.scss +3 -2
- package/src/tokens/scss/transition.scss +19 -2
- package/storage/svg/monitor.svg +1 -0
- package/storage/svg/moon.svg +1 -0
- package/storage/svg/pin.svg +1 -0
- package/storage/svg/sun.svg +1 -0
- package/vite.config.ts +33 -8
- package/build/css-utilities/background/scss/index.scss +0 -2
- package/build/css-utilities/border/scss/index.scss +0 -2
- package/build/css-utilities/color/scss/index.scss +0 -2
- package/build/css-utilities/flex/scss/index.scss +0 -2
- package/build/css-utilities/font/geist/index.d.ts +0 -1
- package/build/css-utilities/font/geist/index.js +0 -1
- package/build/css-utilities/font/geist/scss/index.scss +0 -2
- package/build/css-utilities/font/montserrat/index.d.ts +0 -1
- package/build/css-utilities/font/montserrat/index.js +0 -1
- package/build/css-utilities/font/montserrat/scss/Montserrat-Bold.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Italic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Medium.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Regular.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/index.scss +0 -2
- package/build/css-utilities/glass/index.js +0 -26
- package/build/css-utilities/glass/scss/index.scss +0 -2
- package/build/css-utilities/index.scss +0 -2
- package/build/css-utilities/inline/scss/index.scss +0 -2
- package/build/css-utilities/scrollbar/index.d.ts +0 -42
- package/build/css-utilities/scrollbar/scss/index.scss +0 -2
- package/build/css-utilities/skeleton/scss/index.scss +0 -2
- package/build/css-utilities/text/scss/index.scss +0 -2
- package/build/themes/dark/index.d.ts +0 -3
- package/build/themes/dark/index.js +0 -3
- package/build/themes/dark/input.d.ts +0 -3
- package/build/themes/dark/input.js +0 -12
- package/build/themes/dark/select.d.ts +0 -3
- package/build/themes/dark/select.js +0 -23
- package/build/themes/dark/textarea.d.ts +0 -2186
- package/build/themes/dark/textarea.js +0 -11
- package/src/css-utilities/background/scss/index.scss +0 -1
- package/src/css-utilities/background/scss/variables.scss +0 -18
- package/src/css-utilities/border/scss/index.scss +0 -1
- package/src/css-utilities/border/scss/variables.scss +0 -23
- package/src/css-utilities/color/scss/index.scss +0 -1
- package/src/css-utilities/color/scss/variables.scss +0 -17
- package/src/css-utilities/flex/scss/index.scss +0 -57
- package/src/css-utilities/flex/scss/variables.scss +0 -16
- package/src/css-utilities/font/geist/index.ts +0 -1
- package/src/css-utilities/font/montserrat/index.ts +0 -1
- package/src/css-utilities/font/montserrat/scss/Montserrat-Bold.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Italic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Medium.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Regular.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/index.scss +0 -94
- package/src/css-utilities/glass/index.ts +0 -42
- package/src/css-utilities/index.scss +0 -13
- package/src/css-utilities/skeleton/scss/variables.scss +0 -3
- package/src/css-utilities/text/scss/index.scss +0 -152
- package/src/css-utilities/text/scss/variables.scss +0 -22
- package/src/shared/scss/absolute.scss +0 -28
- package/src/shared/scss/background.scss +0 -21
- package/src/shared/scss/border.scss +0 -21
- package/src/shared/scss/color.scss +0 -21
- package/src/shared/scss/position.scss +0 -55
- package/src/shared/scss/text.scss +0 -31
- package/src/themes/dark/index.ts +0 -3
- package/src/themes/dark/input.ts +0 -16
- package/src/themes/dark/select.ts +0 -28
- package/src/themes/dark/textarea.ts +0 -13
- package/src/tokens/scss/box-shadow.scss +0 -23
- package/src/tokens/scss/font-family.scss +0 -5
- package/storage/code.md +0 -180
- package/storage/editor-features.md +0 -227
- package/build/css-utilities/font/geist/{scss/Geist-Italic-Variable.woff2 → Geist-Italic-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/Geist-Variable.woff2 → Geist-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/GeistMono-Italic-Variable.woff2 → GeistMono-Italic-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/GeistMono-Variable.woff2 → GeistMono-Variable.woff2} +0 -0
- package/src/{shared/scss → css-utilities}/anchor.scss +6 -6
- package/src/{shared/scss → css-utilities}/drag.scss +0 -0
- package/src/css-utilities/font/geist/{scss/Geist-Italic-Variable.woff2 → Geist-Italic-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/Geist-Variable.woff2 → Geist-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/GeistMono-Italic-Variable.woff2 → GeistMono-Italic-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/GeistMono-Variable.woff2 → GeistMono-Variable.woff2} +0 -0
- package/src/{shared/scss → css-utilities}/hidden.scss +11 -11
- /package/src/{shared/scss → css-utilities}/layer.scss +0 -0
- /package/src/{shared/scss → css-utilities}/reset.scss +0 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { reactive, untrack } from '@esportsplus/reactivity';
|
|
2
|
+
import { component, html, type Attributes } from '@esportsplus/template';
|
|
3
|
+
import copy from '~/components/copy';
|
|
4
|
+
import icon from '~/components/icon';
|
|
5
|
+
import scrollbar from '~/modifiers/scrollbar';
|
|
6
|
+
import { observeSize } from '~/shared/resize';
|
|
7
|
+
import { minimap, type Source } from '../code/minimap';
|
|
8
|
+
import { languageFor, type Language, type Token } from '../code/syntax';
|
|
9
|
+
import { hidden, outline, type Line } from './model';
|
|
10
|
+
import chevron from '@esportsplus/ui/svg/chevron-down.svg';
|
|
11
|
+
import './scss/index.scss';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
type CodeViewerAttributes = Attributes & {
|
|
15
|
+
// A copy button in the header, writing the exact source.
|
|
16
|
+
copy?: boolean;
|
|
17
|
+
// Shown in the header; picks the language when 'language' is left out.
|
|
18
|
+
filename?: string;
|
|
19
|
+
fold?: boolean;
|
|
20
|
+
language?: Language;
|
|
21
|
+
lineNumbers?: boolean;
|
|
22
|
+
// An overview of the whole source beside it; click, drag or scroll it to move through the code.
|
|
23
|
+
minimap?: boolean;
|
|
24
|
+
// Exact source text; a getter keeps following it.
|
|
25
|
+
value: string | (() => string);
|
|
26
|
+
// Marks each space and tab.
|
|
27
|
+
whitespace?: boolean;
|
|
28
|
+
wrap?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const NO_BREAKS: readonly number[] = [];
|
|
33
|
+
|
|
34
|
+
const TOKEN_COLORS: readonly Token['kind'][] = [
|
|
35
|
+
'color',
|
|
36
|
+
'comment',
|
|
37
|
+
'function',
|
|
38
|
+
'keyword',
|
|
39
|
+
'number',
|
|
40
|
+
'operator',
|
|
41
|
+
'property',
|
|
42
|
+
'regexp',
|
|
43
|
+
'selector',
|
|
44
|
+
'string',
|
|
45
|
+
'tag',
|
|
46
|
+
'type',
|
|
47
|
+
'variable'
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
function pixels(value: string) {
|
|
52
|
+
return parseFloat(value) || 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function range(index: number, end: number) {
|
|
56
|
+
return end - index === 2 ? `line ${end}` : `lines ${index + 2}–${end}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export default component(
|
|
61
|
+
function(this: { attributes?: Partial<CodeViewerAttributes> } | void, input: CodeViewerAttributes) {
|
|
62
|
+
let {
|
|
63
|
+
copy: copyable = false,
|
|
64
|
+
filename,
|
|
65
|
+
fold = true,
|
|
66
|
+
language,
|
|
67
|
+
lineNumbers = true,
|
|
68
|
+
minimap: overview = false,
|
|
69
|
+
value,
|
|
70
|
+
whitespace = false,
|
|
71
|
+
wrap = false,
|
|
72
|
+
...attributes
|
|
73
|
+
} = untrack(() => ({ ...this?.attributes, ...input })) as CodeViewerAttributes,
|
|
74
|
+
current = () => {
|
|
75
|
+
let next = input.value ?? this?.attributes?.value;
|
|
76
|
+
|
|
77
|
+
return (typeof next === 'function' ? next() : next) ?? '';
|
|
78
|
+
},
|
|
79
|
+
frame = 0,
|
|
80
|
+
lexer = language ?? languageFor(filename),
|
|
81
|
+
lines: Line[] = [],
|
|
82
|
+
palette: Record<string, string> = {},
|
|
83
|
+
rail: HTMLElement | undefined,
|
|
84
|
+
scroller: HTMLElement | undefined,
|
|
85
|
+
source: Source | null = null,
|
|
86
|
+
stale = false;
|
|
87
|
+
|
|
88
|
+
let map = overview && minimap({
|
|
89
|
+
focus: () => scroller?.focus({ preventScroll: true }),
|
|
90
|
+
name: 'code-viewer',
|
|
91
|
+
scroll: (top, relative) => {
|
|
92
|
+
if (scroller) {
|
|
93
|
+
scroller.scrollTop = relative ? scroller.scrollTop + top : top;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
let size = observeSize((_, element) => {
|
|
99
|
+
scroller = element;
|
|
100
|
+
update(true);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Line geometry and token colors, read from the rendered lines; folded lines take no height.
|
|
104
|
+
function measure() {
|
|
105
|
+
let content = scroller?.firstElementChild as HTMLElement | null,
|
|
106
|
+
elements = content?.children;
|
|
107
|
+
|
|
108
|
+
if (!map || !content || !elements?.length) {
|
|
109
|
+
source = null;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let computed = getComputedStyle(content),
|
|
114
|
+
fallback = computed.getPropertyValue('--color').trim() || 'currentColor',
|
|
115
|
+
heights: number[] = [],
|
|
116
|
+
lineHeight = pixels(getComputedStyle(elements[0]).lineHeight) || 20,
|
|
117
|
+
tops: number[] = [];
|
|
118
|
+
|
|
119
|
+
for (let i = 0, n = elements.length; i < n; i++) {
|
|
120
|
+
let element = elements[i] as HTMLElement;
|
|
121
|
+
|
|
122
|
+
if (element.hidden) {
|
|
123
|
+
heights.push(0);
|
|
124
|
+
tops.push(i ? tops[i - 1] + heights[i - 1] : 0);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
heights.push(element.offsetHeight);
|
|
128
|
+
tops.push(element.offsetTop);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
palette = {};
|
|
133
|
+
|
|
134
|
+
for (let i = 0, n = TOKEN_COLORS.length; i < n; i++) {
|
|
135
|
+
let kind = TOKEN_COLORS[i];
|
|
136
|
+
|
|
137
|
+
palette[kind] = computed.getPropertyValue(`--${kind === 'color' ? 'literal' : kind}-color`).trim() || fallback;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
source = {
|
|
141
|
+
breaks: () => NO_BREAKS,
|
|
142
|
+
count: tops.length,
|
|
143
|
+
height: content.offsetHeight,
|
|
144
|
+
indexAt: (y) => {
|
|
145
|
+
let hi = tops.length - 1,
|
|
146
|
+
lo = 0;
|
|
147
|
+
|
|
148
|
+
while (lo < hi) {
|
|
149
|
+
let mid = (lo + hi + 1) >>> 1;
|
|
150
|
+
|
|
151
|
+
if (tops[mid] <= y) {
|
|
152
|
+
lo = mid;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
hi = mid - 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return lo;
|
|
160
|
+
},
|
|
161
|
+
lineHeight,
|
|
162
|
+
rows: (index) => Math.max(1, Math.round(heights[index] / lineHeight)),
|
|
163
|
+
tabSize: pixels(computed.tabSize) || 4,
|
|
164
|
+
text: (index) => heights[index] ? lines[index].text : '',
|
|
165
|
+
tokens: (index) => lines[index].tokens,
|
|
166
|
+
top: (index) => tops[index]
|
|
167
|
+
};
|
|
168
|
+
map.invalidate();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function render(text: string) {
|
|
172
|
+
let folded = new Set<number>(),
|
|
173
|
+
rows: { folded: boolean; hidden: boolean }[];
|
|
174
|
+
|
|
175
|
+
lines = outline(text, lexer, { fold, whitespace });
|
|
176
|
+
rows = lines.map(() => reactive({ folded: false, hidden: false }));
|
|
177
|
+
|
|
178
|
+
let foldable = lines.some((line) => line.end !== -1);
|
|
179
|
+
|
|
180
|
+
function toggle(index: number) {
|
|
181
|
+
if (folded.has(index)) {
|
|
182
|
+
folded.delete(index);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
folded.add(index);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let next = hidden(lines, folded);
|
|
189
|
+
|
|
190
|
+
for (let i = 0, n = rows.length; i < n; i++) {
|
|
191
|
+
rows[i].folded = folded.has(i);
|
|
192
|
+
rows[i].hidden = next[i];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
update(true);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
update(true);
|
|
199
|
+
|
|
200
|
+
return html`
|
|
201
|
+
<div class='code-viewer-lines' style='--digits: ${Math.max(3, String(lines.length).length)};'>
|
|
202
|
+
${lines.map((line, index) => html`
|
|
203
|
+
<div class='code-viewer-line' hidden='${() => rows[index].hidden}'>
|
|
204
|
+
${(lineNumbers || foldable) && html`
|
|
205
|
+
<span class='code-viewer-gutter'>
|
|
206
|
+
${lineNumbers && html`<span class='code-viewer-number'>${index + 1}</span>`}
|
|
207
|
+
${line.end > index
|
|
208
|
+
? html`
|
|
209
|
+
<button
|
|
210
|
+
class='code-viewer-fold'
|
|
211
|
+
type='button'
|
|
212
|
+
${{
|
|
213
|
+
'aria-expanded': () => String(!rows[index].folded),
|
|
214
|
+
'aria-label': () => `${rows[index].folded ? 'Unfold' : 'Fold'} ${range(index, line.end)}`,
|
|
215
|
+
onclick: () => toggle(index)
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
${icon({ 'aria-hidden': 'true', class: 'code-viewer-fold-icon' }, chevron)}
|
|
219
|
+
</button>
|
|
220
|
+
`
|
|
221
|
+
: html`<span class='code-viewer-fold'></span>`}
|
|
222
|
+
</span>
|
|
223
|
+
`}
|
|
224
|
+
<code class='code-viewer-code' ${{ innerHTML: line.html }}></code>
|
|
225
|
+
${line.end > index && html`
|
|
226
|
+
<button
|
|
227
|
+
aria-label='Unfold ${range(index, line.end)}'
|
|
228
|
+
class='code-viewer-placeholder'
|
|
229
|
+
hidden='${() => !rows[index].folded}'
|
|
230
|
+
type='button'
|
|
231
|
+
${{ onclick: () => toggle(index) }}
|
|
232
|
+
>…</button>
|
|
233
|
+
`}
|
|
234
|
+
</div>
|
|
235
|
+
`)}
|
|
236
|
+
</div>
|
|
237
|
+
`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Draws the minimap in the next frame; 'remeasure' rereads the lines first, after a render, fold or resize.
|
|
241
|
+
function update(remeasure = false) {
|
|
242
|
+
if (!map) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
stale ||= remeasure;
|
|
247
|
+
|
|
248
|
+
if (frame) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
frame = requestAnimationFrame(() => {
|
|
253
|
+
frame = 0;
|
|
254
|
+
|
|
255
|
+
if (stale) {
|
|
256
|
+
stale = false;
|
|
257
|
+
measure();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (map && rail && scroller && source) {
|
|
261
|
+
map.paint(
|
|
262
|
+
source,
|
|
263
|
+
{ clientHeight: scroller.clientHeight, scrollHeight: scroller.scrollHeight, scrollTop: scroller.scrollTop },
|
|
264
|
+
palette,
|
|
265
|
+
rail.clientWidth
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return html`
|
|
272
|
+
<div
|
|
273
|
+
class='code-viewer ${wrap ? 'code-viewer--wrap' : ''}'
|
|
274
|
+
${attributes}
|
|
275
|
+
${{
|
|
276
|
+
ondisconnect: () => {
|
|
277
|
+
cancelAnimationFrame(frame);
|
|
278
|
+
frame = 0;
|
|
279
|
+
}
|
|
280
|
+
}}
|
|
281
|
+
>
|
|
282
|
+
${(filename || copyable) && html`
|
|
283
|
+
<div class='code-viewer-header'>
|
|
284
|
+
${filename && html`<span class='code-viewer-filename' title='${filename}'>${filename}</span>`}
|
|
285
|
+
${copyable && copy({
|
|
286
|
+
class: 'code-viewer-copy',
|
|
287
|
+
error: 'Copy unavailable. Select and copy the code.',
|
|
288
|
+
label: 'Copy code',
|
|
289
|
+
success: 'Code copied',
|
|
290
|
+
value: current
|
|
291
|
+
})}
|
|
292
|
+
</div>
|
|
293
|
+
`}
|
|
294
|
+
<div class='code-viewer-body'>
|
|
295
|
+
<div
|
|
296
|
+
aria-label='${filename ?? 'Code'}'
|
|
297
|
+
class='code-viewer-scroller'
|
|
298
|
+
role='region'
|
|
299
|
+
tabindex='0'
|
|
300
|
+
${scrollbar({ hover: true })}
|
|
301
|
+
${size}
|
|
302
|
+
${{ onscroll: () => update() }}
|
|
303
|
+
>
|
|
304
|
+
${() => {
|
|
305
|
+
let text = current();
|
|
306
|
+
|
|
307
|
+
return untrack(() => render(text));
|
|
308
|
+
}}
|
|
309
|
+
</div>
|
|
310
|
+
${map && map.template({
|
|
311
|
+
onconnect: (element: HTMLElement) => {
|
|
312
|
+
rail = element;
|
|
313
|
+
update(true);
|
|
314
|
+
}
|
|
315
|
+
})}
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
`;
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
export type { CodeViewerAttributes };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { EditorDocument } from '../code/document';
|
|
2
|
+
import { structureOf } from '../code/folding';
|
|
3
|
+
import { SyntaxCache, type Language, type Token } from '../code/syntax';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// One source line: its markup, text and tokens, and the end (exclusive) of the lines its fold hides, or -1 when it
|
|
7
|
+
// starts none.
|
|
8
|
+
type Line = { end: number; html: string; text: string; tokens: readonly Token[] };
|
|
9
|
+
|
|
10
|
+
type Options = { fold?: boolean; whitespace?: boolean };
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
// Runs one line may split into before it renders as plain text.
|
|
14
|
+
const BUDGET = 3000;
|
|
15
|
+
|
|
16
|
+
const ESCAPE = /[&<>"]/;
|
|
17
|
+
|
|
18
|
+
const ESCAPES: Record<string, string> = { '"': '"', '&': '&', '<': '<', '>': '>' };
|
|
19
|
+
|
|
20
|
+
// Longer lines skip highlighting.
|
|
21
|
+
const LONG = 10000;
|
|
22
|
+
|
|
23
|
+
const NO_TOKENS: readonly Token[] = [];
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function escape(text: string) {
|
|
27
|
+
return ESCAPE.test(text) ? text.replace(/[&<>"]/g, (character) => ESCAPES[character]) : text;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function markup(text: string, tokens: readonly Token[], whitespace: boolean) {
|
|
31
|
+
if (text.length > LONG || tokens.length > BUDGET) {
|
|
32
|
+
return escape(text);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let at = 0,
|
|
36
|
+
out = '';
|
|
37
|
+
|
|
38
|
+
for (let i = 0, n = tokens.length; i < n; i++) {
|
|
39
|
+
let { from, kind, to } = tokens[i];
|
|
40
|
+
|
|
41
|
+
if (to <= at) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
from = Math.max(from, at);
|
|
46
|
+
|
|
47
|
+
if (from > at) {
|
|
48
|
+
out += piece(text.slice(at, from), whitespace);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
out += `<span class="code-viewer-token--${kind}">${piece(text.slice(from, to), whitespace)}</span>`;
|
|
52
|
+
at = to;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return at < text.length ? out + piece(text.slice(at), whitespace) : out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Text as markup; visible whitespace marks each space and tab, keeping the character itself for selection and copy.
|
|
59
|
+
function piece(text: string, whitespace: boolean) {
|
|
60
|
+
if (!whitespace) {
|
|
61
|
+
return escape(text);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let out = '',
|
|
65
|
+
start = 0;
|
|
66
|
+
|
|
67
|
+
for (let i = 0, n = text.length; i < n; i++) {
|
|
68
|
+
let code = text.charCodeAt(i);
|
|
69
|
+
|
|
70
|
+
if (code !== 32 && code !== 9) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
out += escape(text.slice(start, i)) + (code === 9 ? '<span class="code-viewer-tab">\t</span>' : '<span class="code-viewer-space"> </span>');
|
|
75
|
+
start = i + 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return out + escape(text.slice(start));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
// Lines with their markup and folds. A line's fold is its largest; bracket folds leave the closing line shown, and a
|
|
83
|
+
// section running to the end of the document hides through the last line.
|
|
84
|
+
const outline = (source: string, language: Language, { fold = true, whitespace = false }: Options = {}): Line[] => {
|
|
85
|
+
let cache = new SyntaxCache(new EditorDocument(source), language),
|
|
86
|
+
document = cache.document,
|
|
87
|
+
lines: Line[] = [];
|
|
88
|
+
|
|
89
|
+
for (let i = 0, n = document.lineCount; i < n; i++) {
|
|
90
|
+
let text = document.lineText(i),
|
|
91
|
+
tokens = language === 'plain' ? NO_TOKENS : cache.lineTokens(i);
|
|
92
|
+
|
|
93
|
+
lines.push({ end: -1, html: markup(text, tokens, whitespace), text, tokens });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!fold) {
|
|
97
|
+
return lines;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let folds = structureOf(cache).folds;
|
|
101
|
+
|
|
102
|
+
for (let i = 0, n = folds.length; i < n; i++) {
|
|
103
|
+
let range = folds[i],
|
|
104
|
+
end = range.close === undefined && range.to === document.value.length ? range.endLine : range.endLine - 1,
|
|
105
|
+
line = lines[range.line - 1];
|
|
106
|
+
|
|
107
|
+
if (line.end === -1 && end > range.line) {
|
|
108
|
+
line.end = end;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return lines;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Which lines the folded ones hide; a fold inside a folded one stays folded underneath.
|
|
116
|
+
const hidden = (lines: readonly Line[], folded: ReadonlySet<number>) => {
|
|
117
|
+
let out = new Array<boolean>(lines.length).fill(false);
|
|
118
|
+
|
|
119
|
+
for (let i = 0, n = lines.length; i < n; i++) {
|
|
120
|
+
if (!out[i] && folded.has(i) && lines[i].end > i) {
|
|
121
|
+
out.fill(true, i + 1, lines[i].end);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return out;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
export { hidden, outline };
|
|
130
|
+
export type { Line, Options };
|