@esportsplus/ui 0.61.0 → 0.62.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/.audit/audit.json +2 -42
- package/.audit/check-scss.mjs +2 -2
- package/.audit/rules-audit.md +1 -12
- package/README.md +18 -17
- package/RULES.md +30 -0
- package/build/components/accordion/index.d.ts +5 -1
- package/build/components/accordion/index.js +29 -27
- package/build/components/accordion/scss/index.scss +1 -1
- package/build/components/announcement/index.d.ts +720 -2164
- package/build/components/announcement/index.js +12 -9
- package/build/components/announcement/scss/index.scss +1 -1
- package/build/components/breadcrumb/index.d.ts +4 -1
- package/build/components/breadcrumb/index.js +54 -49
- package/build/components/breadcrumb/scss/index.scss +1 -1
- package/build/components/button/copy.d.ts +1 -10
- package/build/components/button/copy.js +14 -11
- package/build/components/button/faces.d.ts +2 -1
- package/build/components/button/faces.js +9 -10
- package/build/components/button/kbd.d.ts +2 -10
- package/build/components/button/kbd.js +17 -15
- package/build/components/button/morph/index.d.ts +1443 -2165
- package/build/components/button/morph/save.d.ts +1 -10
- package/build/components/button/morph/save.js +5 -5
- package/build/components/button/morph/template.d.ts +2 -1
- package/build/components/button/morph/template.js +49 -29
- package/build/components/button/scss/index.scss +1 -1
- package/build/components/button/sidebar.d.ts +1 -10
- package/build/components/button/sidebar.js +14 -12
- package/build/components/button/split.d.ts +6 -1
- package/build/components/button/split.js +16 -11
- package/build/components/capslock/index.d.ts +1 -10
- package/build/components/capslock/index.js +16 -13
- package/build/components/capslock/scss/index.scss +1 -1
- package/build/components/card/scss/index.scss +1 -1
- package/build/components/cc/index.d.ts +4 -1
- package/build/components/cc/index.js +203 -161
- package/build/components/cc/scss/index.scss +1 -1
- package/build/components/chat/minimap/index.d.ts +12 -1
- package/build/components/chat/minimap/index.js +98 -74
- package/build/components/checkbox/group.d.ts +2 -10
- package/build/components/checkbox/group.js +39 -29
- package/build/components/checkbox/options.d.ts +5005 -6440
- package/build/components/checkbox/options.js +72 -44
- package/build/components/checkbox/scss/index.scss +1 -1
- package/build/components/color-picker/index.d.ts +10 -1
- package/build/components/color-picker/index.js +99 -82
- package/build/components/color-picker/scss/index.scss +1 -1
- package/build/components/command/palette.d.ts +13 -5
- package/build/components/command/palette.js +141 -130
- package/build/components/command/scss/index.scss +1 -1
- package/build/components/command/search.d.ts +2 -20
- package/build/components/command/search.js +17 -16
- package/build/components/container/scss/index.scss +1 -1
- package/build/components/counter/index.d.ts +1 -10
- package/build/components/counter/index.js +34 -31
- package/build/components/counter/scss/index.scss +1 -1
- package/build/components/dock/index.d.ts +4 -1
- package/build/components/dock/index.js +154 -114
- package/build/components/dock/scss/index.scss +1 -1
- package/build/components/editor/code/editor.d.ts +1 -10
- package/build/components/editor/code/features.d.ts +3 -3
- package/build/components/editor/code/features.js +65 -52
- package/build/components/editor/code/field.d.ts +1 -1
- package/build/components/editor/code/find.d.ts +4 -4
- package/build/components/editor/code/find.js +39 -37
- package/build/components/editor/code/folding.d.ts +1 -1
- package/build/components/editor/code/goto.d.ts +2 -1
- package/build/components/editor/code/goto.js +7 -7
- package/build/components/editor/code/gutter.js +12 -12
- package/build/components/editor/code/html.d.ts +4 -0
- package/build/components/editor/code/html.js +8 -0
- package/build/components/editor/code/minimap.d.ts +4 -10
- package/build/components/editor/code/minimap.js +18 -13
- package/build/components/editor/code/rows.js +6 -12
- package/build/components/editor/code/search.d.ts +1 -2
- package/build/components/editor/code/search.js +1 -1
- package/build/components/editor/code/services/index.d.ts +1 -1
- package/build/components/editor/code/services/index.js +27 -23
- package/build/components/editor/code/services/model.d.ts +1 -5
- package/build/components/editor/code/services/model.js +1 -1
- package/build/components/editor/code/services/session.d.ts +3 -2
- package/build/components/editor/code/services/session.js +1 -4
- package/build/components/editor/code/syntax.d.ts +1 -1
- package/build/components/editor/code/view.d.ts +2 -1
- package/build/components/editor/code/view.js +50 -39
- package/build/components/editor/diffs/merge.d.ts +1 -10
- package/build/components/editor/diffs/merge.js +126 -102
- package/build/components/editor/diffs/render.d.ts +1 -2
- package/build/components/editor/diffs/render.js +2 -8
- package/build/components/editor/diffs/view.d.ts +1 -10
- package/build/components/editor/diffs/view.js +112 -105
- package/build/components/editor/markdown/editing.d.ts +1 -1
- package/build/components/editor/markdown/erase.js +1 -1
- package/build/components/editor/markdown/format.d.ts +23 -0
- package/build/components/editor/markdown/format.js +319 -0
- package/build/components/editor/markdown/html.d.ts +1 -1
- package/build/components/editor/markdown/inline.d.ts +1 -1
- package/build/components/editor/markdown/inline.js +6 -5
- package/build/components/editor/markdown/layout.d.ts +1 -3
- package/build/components/editor/markdown/layout.js +1 -1
- package/build/components/editor/markdown/model.d.ts +3 -9
- package/build/components/editor/markdown/model.js +1 -8
- package/build/components/editor/markdown/render.d.ts +2 -1
- package/build/components/editor/markdown/render.js +278 -247
- package/build/components/editor/markdown/template.d.ts +1 -10
- package/build/components/editor/markdown/toolbar.d.ts +32 -0
- package/build/components/editor/markdown/toolbar.js +556 -0
- package/build/components/editor/markdown/view.d.ts +12 -1
- package/build/components/editor/markdown/view.js +154 -60
- package/build/components/editor/tree/compact.d.ts +2 -1
- package/build/components/editor/tree/compact.js +12 -11
- package/build/components/editor/tree/drag.d.ts +3 -2
- package/build/components/editor/tree/drag.js +29 -26
- package/build/components/editor/tree/edit.d.ts +1 -1
- package/build/components/editor/tree/edit.js +10 -9
- package/build/components/editor/tree/find.d.ts +1 -1
- package/build/components/editor/tree/find.js +10 -6
- package/build/components/editor/tree/icons.d.ts +1 -1
- package/build/components/editor/tree/icons.js +1 -1
- package/build/components/editor/tree/lazy.d.ts +2 -1
- package/build/components/editor/tree/lazy.js +17 -16
- package/build/components/editor/tree/sticky.d.ts +3 -2
- package/build/components/editor/tree/sticky.js +7 -6
- package/build/components/editor/tree/template.d.ts +2 -1
- package/build/components/editor/tree/template.js +144 -157
- package/build/components/editor/viewer/model.js +1 -7
- package/build/components/editor/viewer/template.d.ts +1 -10
- package/build/components/editor/viewer/template.js +74 -65
- package/build/components/editor/workspace/navigate.d.ts +2 -1
- package/build/components/editor/workspace/navigate.js +2 -4
- package/build/components/editor/workspace/session.d.ts +2 -1
- package/build/components/editor/workspace/session.js +14 -9
- package/build/components/editor/workspace/shortcuts.js +39 -33
- package/build/components/editor/workspace/status.js +2 -2
- package/build/components/editor/workspace/statusbar.d.ts +2 -1
- package/build/components/editor/workspace/statusbar.js +49 -48
- package/build/components/editor/workspace/strip.js +6 -5
- package/build/components/editor/workspace/template.d.ts +2 -10
- package/build/components/editor/workspace/template.js +149 -144
- package/build/components/error/index.d.ts +1 -10
- package/build/components/error/index.js +64 -32
- package/build/components/error/scss/index.scss +1 -1
- package/build/components/filter/index.js +138 -74
- package/build/components/filter/scss/index.scss +1 -1
- package/build/components/form/action.d.ts +2 -2
- package/build/components/form/action.js +12 -9
- package/build/components/frame/scss/index.scss +1 -1
- package/build/components/group/index.d.ts +3 -1
- package/build/components/group/index.js +10 -7
- package/build/components/group/scss/index.scss +1 -1
- package/build/components/heatmap/index.d.ts +5 -2
- package/build/components/heatmap/index.js +72 -59
- package/build/components/heatmap/scss/index.scss +1 -1
- package/build/components/highlight/index.d.ts +1 -10
- package/build/components/highlight/index.js +21 -19
- package/build/components/highlight/scss/index.scss +1 -1
- package/build/components/icon/index.d.ts +1 -10
- package/build/components/icon/index.js +11 -10
- package/build/components/image/lazyload.d.ts +2 -1
- package/build/components/image/lazyload.js +29 -26
- package/build/components/image/scss/index.scss +1 -1
- package/build/components/index.d.ts +0 -3
- package/build/components/index.js +0 -3
- package/build/components/inline-edit/index.d.ts +5 -1
- package/build/components/inline-edit/index.js +34 -27
- package/build/components/inline-edit/rich.d.ts +10 -15
- package/build/components/inline-edit/rich.js +81 -1193
- package/build/components/inline-edit/scss/index.scss +1 -1
- package/build/components/inline-edit/status.d.ts +3 -2
- package/build/components/inline-edit/status.js +22 -18
- package/build/components/input/field.d.ts +2 -1
- package/build/components/input/field.js +12 -9
- package/build/components/input/scrub.d.ts +4 -1
- package/build/components/input/scrub.js +25 -20
- package/build/components/input/scss/index.scss +1 -1
- package/build/components/input/tag.d.ts +4 -2
- package/build/components/input/tag.js +58 -53
- package/build/components/link/scss/index.scss +1 -1
- package/build/components/loading/index.d.ts +2 -1
- package/build/components/loading/index.js +6 -3
- package/build/components/loading/scss/index.scss +1 -1
- package/build/components/marquee/index.d.ts +2 -1
- package/build/components/marquee/index.js +77 -72
- package/build/components/marquee/scss/index.scss +1 -1
- package/build/components/marquee/velocity.js +4 -3
- package/build/components/metric/flash.d.ts +2 -1
- package/build/components/metric/flash.js +25 -25
- package/build/components/metric/index.d.ts +13 -2
- package/build/components/metric/index.js +60 -56
- package/build/components/metric/scss/index.scss +1 -1
- package/build/components/nav/scss/index.scss +1 -1
- package/build/components/nav/spy.js +9 -6
- package/build/components/nav/toc.d.ts +1 -10
- package/build/components/nav/tree.d.ts +3 -1
- package/build/components/nav/tree.js +60 -58
- package/build/components/notification/index.d.ts +1 -10
- package/build/components/notification/index.js +26 -36
- package/build/components/notification/scss/index.scss +1 -1
- package/build/components/overlay/index.d.ts +4 -5
- package/build/components/overlay/index.js +399 -196
- package/build/components/overlay/popup.d.ts +5 -6
- package/build/components/overlay/popup.js +80 -39
- package/build/components/overlay/scss/index.scss +1 -1
- package/build/components/pagination/arrows.d.ts +2 -1
- package/build/components/pagination/arrows.js +48 -45
- package/build/components/pagination/cards.d.ts +5 -2
- package/build/components/pagination/cards.js +70 -45
- package/build/components/pagination/dots.d.ts +3 -1
- package/build/components/pagination/dots.js +29 -24
- package/build/components/pagination/index.d.ts +2 -1
- package/build/components/pagination/index.js +27 -28
- package/build/components/pagination/scss/index.scss +1 -1
- package/build/components/panels/dnd.js +30 -22
- package/build/components/panels/group.d.ts +3 -2
- package/build/components/panels/group.js +134 -131
- package/build/components/panels/index.d.ts +2 -10
- package/build/components/panels/index.js +84 -80
- package/build/components/panels/resize.js +39 -3
- package/build/components/panels/scss/index.scss +1 -1
- package/build/components/panels/subtree.d.ts +2 -1
- package/build/components/panels/subtree.js +8 -7
- package/build/components/preview/buttons.d.ts +2 -10
- package/build/components/preview/buttons.js +6 -6
- package/build/components/preview/code.d.ts +1 -10
- package/build/components/preview/code.js +6 -6
- package/build/components/preview/header.d.ts +2 -10
- package/build/components/preview/header.js +15 -12
- package/build/components/preview/index.d.ts +13 -8680
- package/build/components/preview/index.js +22 -22
- package/build/components/preview/scss/index.scss +1 -1
- package/build/components/preview/source.d.ts +1 -10
- package/build/components/preview/source.js +18 -15
- package/build/components/preview/stage.d.ts +2 -10
- package/build/components/preview/stage.js +19 -15
- package/build/components/progress/index.d.ts +2 -1
- package/build/components/progress/index.js +30 -26
- package/build/components/progress/scss/index.scss +1 -1
- package/build/components/progress/text.d.ts +2 -1
- package/build/components/progress/text.js +27 -25
- package/build/components/range/filter.d.ts +2 -1
- package/build/components/range/filter.js +126 -127
- package/build/components/range/index.d.ts +2 -1
- package/build/components/range/index.js +17 -22
- package/build/components/range/scss/index.scss +1 -1
- package/build/components/relative-time/index.d.ts +3 -1
- package/build/components/relative-time/index.js +56 -41
- package/build/components/relative-time/scss/index.scss +1 -1
- package/build/components/root/scss/index.scss +1 -1
- package/build/components/select/expand.d.ts +44 -0
- package/build/components/select/expand.js +215 -0
- package/build/components/select/index.d.ts +18 -9
- package/build/components/select/index.js +108 -81
- package/build/components/select/scss/index.scss +1 -1
- package/build/components/shell/index.d.ts +2 -1
- package/build/components/shell/index.js +127 -109
- package/build/components/shell/scss/index.scss +1 -1
- package/build/components/shortcut-recorder/index.js +46 -43
- package/build/components/shortcut-recorder/scss/index.scss +1 -1
- package/build/components/sortable/index.d.ts +2 -714
- package/build/components/sortable/index.js +75 -64
- package/build/components/sortable/scss/index.scss +1 -1
- package/build/components/story/index.d.ts +4 -10
- package/build/components/story/index.js +121 -63
- package/build/components/story/scss/index.scss +1 -1
- package/build/components/surface-field/engine.js +51 -53
- package/build/components/surface-field/index.d.ts +2180 -2921
- package/build/components/surface-field/index.js +42 -38
- package/build/components/surface-field/scss/index.scss +1 -1
- package/build/components/surface-field/surface.d.ts +1 -10
- package/build/components/surface-field/surface.js +42 -36
- package/build/components/tasklist/index.d.ts +8 -1
- package/build/components/tasklist/index.js +63 -46
- package/build/components/tasklist/scss/index.scss +1 -1
- package/build/components/textarea/index.d.ts +722 -2170
- package/build/components/textarea/index.js +67 -91
- package/build/components/textarea/scss/index.scss +1 -1
- package/build/components/theme/cards.d.ts +4 -0
- package/build/components/theme/cards.js +21 -0
- package/build/components/theme/index.d.ts +12 -3
- package/build/components/theme/index.js +38 -14
- package/build/components/theme/reveal.d.ts +6 -0
- package/build/components/theme/reveal.js +100 -0
- package/build/components/theme/scss/index.scss +1 -1
- package/build/components/{theme-picker → theme}/shared.d.ts +4 -4
- package/build/components/{theme-picker → theme}/shared.js +5 -3
- package/build/components/theme/swatches.d.ts +4 -0
- package/build/components/theme/swatches.js +21 -0
- package/build/components/theme/toggle.d.ts +15 -0
- package/build/components/theme/toggle.js +33 -0
- package/build/components/toast/index.d.ts +6 -2
- package/build/components/toast/index.js +62 -50
- package/build/components/toast/scss/index.scss +1 -1
- package/build/components/tooltip/menu.d.ts +10 -2
- package/build/components/tooltip/menu.js +194 -179
- package/build/components/tooltip/onclick.d.ts +1 -10
- package/build/components/tooltip/onclick.js +25 -27
- package/build/components/tooltip/onhover.d.ts +8 -709
- package/build/components/tooltip/onhover.js +60 -60
- package/build/components/tooltip/scss/index.scss +1 -1
- package/build/components/tooltip/shared.d.ts +5 -3
- package/build/components/tooltip/shared.js +201 -91
- package/build/components/tooltip/utilities.d.ts +10 -4
- package/build/components/tooltip/utilities.js +95 -18
- package/build/components/typewriter/index.d.ts +2855 -1413
- package/build/components/typewriter/index.js +17 -18
- package/build/components/typewriter/retype.d.ts +2 -1
- package/build/components/typewriter/retype.js +21 -18
- package/build/components/typewriter/rotate.d.ts +2 -1
- package/build/components/typewriter/rotate.js +34 -29
- package/build/components/typewriter/scss/index.scss +1 -1
- package/build/components/uptime/index.d.ts +2 -1
- package/build/components/uptime/index.js +51 -47
- package/build/components/uptime/scss/index.scss +1 -1
- package/build/components/usage-meter/index.d.ts +719 -2161
- package/build/components/usage-meter/index.js +23 -20
- package/build/components/usage-meter/scss/index.scss +1 -1
- package/build/modifiers/border/scss/index.scss +1 -1
- package/build/modifiers/box-shadow/scss/index.scss +1 -1
- package/build/modifiers/color/scss/index.scss +1 -1
- package/build/modifiers/disabled/scss/index.scss +2 -0
- package/build/modifiers/glass/index.d.ts +3 -2
- package/build/modifiers/glass/index.js +7 -7
- package/build/modifiers/glass/scss/index.scss +1 -1
- package/build/modifiers/scrollbar/index.d.ts +13 -13
- package/build/modifiers/scrollbar/index.js +74 -90
- package/build/modifiers/scrollbar/scss/index.scss +1 -1
- package/build/shared/animation.d.ts +1 -1
- package/build/shared/animation.js +5 -3
- package/build/shared/dispatch.d.ts +7 -0
- package/build/shared/dispatch.js +25 -0
- package/build/shared/drag.d.ts +2 -4
- package/build/shared/press.d.ts +1 -1
- package/build/shared/press.js +5 -3
- package/build/shared/resize.js +2 -25
- package/build/shared/transition.d.ts +1 -1
- package/build/shared/transition.js +2 -2
- package/build/shared/visible.js +1 -24
- package/package.json +10 -11
- package/src/components/accordion/index.ts +2 -4
- package/src/components/accordion/scss/index.scss +17 -14
- package/src/components/accordion/scss/variables.scss +6 -7
- package/src/components/announcement/scss/index.scss +8 -13
- package/src/components/announcement/scss/variables.scss +12 -8
- package/src/components/breadcrumb/index.ts +4 -4
- package/src/components/breadcrumb/scss/index.scss +12 -12
- package/src/components/breadcrumb/scss/variables.scss +5 -12
- package/src/components/button/copy.ts +1 -1
- package/src/components/button/kbd.ts +8 -7
- package/src/components/button/morph/save.ts +2 -2
- package/src/components/button/morph/template.ts +18 -20
- package/src/components/button/scss/index.scss +84 -59
- package/src/components/button/scss/variables.scss +44 -29
- package/src/components/button/sidebar.ts +2 -2
- package/src/components/button/split.ts +7 -8
- package/src/components/capslock/index.ts +4 -4
- package/src/components/capslock/scss/index.scss +4 -2
- package/src/components/capslock/scss/variables.scss +14 -15
- package/src/components/card/scss/index.scss +10 -19
- package/src/components/card/scss/variables.scss +6 -2
- package/src/components/cc/index.ts +32 -33
- package/src/components/cc/scss/index.scss +37 -7
- package/src/components/cc/scss/variables.scss +13 -10
- package/src/components/chat/minimap/index.ts +14 -13
- package/src/components/chat/minimap/scss/index.scss +19 -28
- package/src/components/chat/minimap/scss/variables.scss +33 -29
- package/src/components/checkbox/group.ts +5 -5
- package/src/components/checkbox/options.ts +2 -2
- package/src/components/checkbox/scss/index.scss +10 -6
- package/src/components/checkbox/scss/variables.scss +59 -44
- package/src/components/clipboard/write.ts +2 -1
- package/src/components/color-picker/index.ts +9 -11
- package/src/components/color-picker/scss/index.scss +2 -2
- package/src/components/color-picker/scss/variables.scss +26 -41
- package/src/components/command/palette.ts +15 -29
- package/src/components/command/scss/index.scss +8 -13
- package/src/components/command/scss/variables.scss +8 -8
- package/src/components/command/search.ts +3 -8
- package/src/components/container/scss/index.scss +2 -4
- package/src/components/container/scss/variables.scss +0 -2
- package/src/components/counter/index.ts +2 -1
- package/src/components/counter/scss/index.scss +2 -1
- package/src/components/counter/scss/variables.scss +3 -9
- package/src/components/dock/index.ts +17 -8
- package/src/components/dock/scss/index.scss +26 -56
- package/src/components/dock/scss/variables.scss +11 -20
- package/src/components/editor/code/features.ts +4 -5
- package/src/components/editor/code/field.ts +1 -1
- package/src/components/editor/code/find.ts +1 -1
- package/src/components/editor/code/folding.ts +1 -1
- package/src/components/editor/code/html.ts +17 -0
- package/src/components/editor/code/minimap.ts +7 -5
- package/src/components/editor/code/rows.ts +1 -14
- package/src/components/editor/code/scss/_editor.scss +10 -23
- package/src/components/editor/code/scss/_features.scss +17 -26
- package/src/components/editor/code/scss/_minimap.scss +29 -0
- package/src/components/editor/code/scss/_services.scss +4 -7
- package/src/components/editor/code/scss/index.scss +0 -1
- package/src/components/editor/code/scss/variables.scss +22 -14
- package/src/components/editor/code/search.ts +1 -1
- package/src/components/editor/code/services/completion.ts +1 -0
- package/src/components/editor/code/services/hover.ts +1 -0
- package/src/components/editor/code/services/index.ts +1 -1
- package/src/components/editor/code/services/model.ts +1 -1
- package/src/components/editor/code/services/session.ts +1 -4
- package/src/components/editor/code/syntax.ts +1 -1
- package/src/components/editor/diffs/merge.ts +3 -3
- package/src/components/editor/diffs/render.ts +2 -17
- package/src/components/editor/diffs/scss/_diffs.scss +22 -57
- package/src/components/editor/diffs/scss/_merge.scss +8 -29
- package/src/components/editor/diffs/scss/variables.scss +1 -10
- package/src/components/editor/diffs/view.ts +4 -5
- package/src/components/editor/markdown/editing.ts +1 -1
- package/src/components/editor/markdown/erase.ts +3 -3
- package/src/components/editor/markdown/format.ts +517 -0
- package/src/components/editor/markdown/html.ts +1 -1
- package/src/components/editor/markdown/inline.ts +9 -6
- package/src/components/editor/markdown/layout.ts +1 -1
- package/src/components/editor/markdown/model.ts +2 -17
- package/src/components/editor/markdown/render.ts +3 -2
- package/src/components/editor/markdown/scss/index.scss +132 -57
- package/src/components/editor/markdown/scss/variables.scss +124 -4
- package/src/components/editor/markdown/toolbar.ts +628 -0
- package/src/components/editor/markdown/view.ts +121 -10
- package/src/components/editor/tree/drag.ts +16 -15
- package/src/components/editor/tree/icons.ts +1 -1
- package/src/components/editor/tree/scss/index.scss +69 -44
- package/src/components/editor/tree/scss/variables.scss +75 -44
- package/src/components/editor/tree/sticky.ts +1 -1
- package/src/components/editor/tree/template.ts +2 -2
- package/src/components/editor/viewer/model.ts +1 -14
- package/src/components/editor/viewer/scss/_viewer.scss +22 -72
- package/src/components/editor/viewer/scss/index.scss +1 -1
- package/src/components/editor/viewer/scss/variables.scss +1 -3
- package/src/components/editor/viewer/template.ts +4 -2
- package/src/components/editor/workspace/navigate.ts +3 -6
- package/src/components/editor/workspace/scss/_keybindings.scss +9 -7
- package/src/components/editor/workspace/scss/_status.scss +14 -38
- package/src/components/editor/workspace/scss/_tabs.scss +6 -3
- package/src/components/editor/workspace/scss/index.scss +38 -33
- package/src/components/editor/workspace/scss/variables.scss +57 -53
- package/src/components/editor/workspace/session.ts +20 -13
- package/src/components/editor/workspace/status.ts +2 -2
- package/src/components/editor/workspace/template.ts +12 -21
- package/src/components/error/index.ts +36 -18
- package/src/components/error/scss/index.scss +3 -1
- package/src/components/error/scss/variables.scss +1 -0
- package/src/components/filter/index.ts +146 -99
- package/src/components/filter/scss/variables.scss +1 -1
- package/src/components/form/action.ts +1 -1
- package/src/components/frame/scss/index.scss +10 -6
- package/src/components/frame/scss/variables.scss +11 -6
- package/src/components/grid/scss/index.scss +1 -1
- package/src/components/grid/scss/variables.scss +1 -1
- package/src/components/heatmap/index.ts +2 -2
- package/src/components/heatmap/scss/index.scss +22 -17
- package/src/components/heatmap/scss/variables.scss +16 -34
- package/src/components/highlight/index.ts +0 -1
- package/src/components/highlight/scss/index.scss +13 -21
- package/src/components/highlight/scss/variables.scss +12 -14
- package/src/components/icon/index.ts +0 -4
- package/src/components/icon/scss/index.scss +2 -0
- package/src/components/image/lazyload.ts +1 -1
- package/src/components/image/scss/index.scss +14 -13
- package/src/components/image/scss/variables.scss +16 -12
- package/src/components/index.ts +0 -3
- package/src/components/inline-edit/index.ts +6 -5
- package/src/components/inline-edit/rich.ts +85 -1400
- package/src/components/inline-edit/scss/index.scss +24 -191
- package/src/components/inline-edit/scss/variables.scss +24 -191
- package/src/components/inline-edit/status.ts +6 -3
- package/src/components/input/field.ts +2 -2
- package/src/components/input/scrub.ts +1 -5
- package/src/components/input/scss/_scrub.scss +7 -0
- package/src/components/input/scss/_tag.scss +4 -2
- package/src/components/input/scss/index.scss +1 -2
- package/src/components/input/scss/variables.scss +14 -21
- package/src/components/input/tag.ts +6 -7
- package/src/components/json/download.ts +2 -1
- package/src/components/link/scss/index.scss +0 -1
- package/src/components/loading/index.ts +1 -1
- package/src/components/loading/scss/index.scss +4 -4
- package/src/components/loading/scss/variables.scss +4 -4
- package/src/components/marquee/index.ts +5 -5
- package/src/components/marquee/scss/index.scss +6 -4
- package/src/components/marquee/scss/variables.scss +3 -4
- package/src/components/marquee/velocity.ts +7 -3
- package/src/components/metric/flash.ts +1 -1
- package/src/components/metric/index.ts +5 -13
- package/src/components/metric/scss/_flash.scss +9 -4
- package/src/components/metric/scss/index.scss +11 -9
- package/src/components/metric/scss/variables.scss +73 -73
- package/src/components/nav/scss/index.scss +2 -1
- package/src/components/nav/scss/variables.scss +9 -11
- package/src/components/nav/spy.ts +15 -8
- package/src/components/nav/tree.ts +28 -30
- package/src/components/notification/index.ts +37 -16
- package/src/components/notification/scss/index.scss +32 -17
- package/src/components/notification/scss/variables.scss +12 -12
- package/src/components/overlay/index.ts +212 -142
- package/src/components/overlay/popup.ts +89 -52
- package/src/components/overlay/scss/index.scss +68 -85
- package/src/components/overlay/scss/variables.scss +15 -12
- package/src/components/pagination/cards.ts +1 -2
- package/src/components/pagination/index.ts +1 -7
- package/src/components/pagination/scss/index.scss +12 -12
- package/src/components/pagination/scss/variables.scss +33 -21
- package/src/components/panels/dnd.ts +35 -29
- package/src/components/panels/group.ts +5 -13
- package/src/components/panels/index.ts +4 -6
- package/src/components/panels/resize.ts +30 -4
- package/src/components/panels/scss/index.scss +13 -28
- package/src/components/panels/scss/variables.scss +3 -3
- package/src/components/preview/code.ts +1 -1
- package/src/components/preview/index.ts +12 -7
- package/src/components/preview/scss/index.scss +30 -15
- package/src/components/preview/scss/variables.scss +56 -34
- package/src/components/progress/scss/index.scss +14 -11
- package/src/components/progress/scss/variables.scss +34 -31
- package/src/components/progress/text.ts +9 -8
- package/src/components/range/filter.ts +9 -11
- package/src/components/range/index.ts +2 -9
- package/src/components/range/scss/_filter.scss +4 -3
- package/src/components/range/scss/_slider.scss +2 -1
- package/src/components/range/scss/variables.scss +2 -16
- package/src/components/relative-time/index.ts +15 -16
- package/src/components/relative-time/scss/index.scss +8 -4
- package/src/components/relative-time/scss/variables.scss +7 -3
- package/src/components/root/scss/index.scss +3 -0
- package/src/components/root/scss/variables.scss +11 -11
- package/src/components/select/expand.ts +272 -0
- package/src/components/select/index.ts +142 -119
- package/src/components/select/scss/index.scss +79 -7
- package/src/components/select/scss/variables.scss +67 -3
- package/src/components/shell/index.ts +73 -50
- package/src/components/shell/scss/index.scss +34 -47
- package/src/components/shell/scss/variables.scss +16 -16
- package/src/components/shortcut-recorder/index.ts +14 -17
- package/src/components/shortcut-recorder/scss/index.scss +15 -10
- package/src/components/shortcut-recorder/scss/variables.scss +4 -7
- package/src/components/sortable/index.ts +25 -28
- package/src/components/sortable/scss/index.scss +28 -27
- package/src/components/sortable/scss/variables.scss +12 -7
- package/src/components/story/index.ts +110 -47
- package/src/components/story/scss/index.scss +13 -18
- package/src/components/story/scss/variables.scss +4 -16
- package/src/components/surface-field/engine.ts +71 -72
- package/src/components/surface-field/index.ts +17 -20
- package/src/components/surface-field/scss/index.scss +9 -11
- package/src/components/surface-field/scss/variables.scss +20 -23
- package/src/components/surface-field/surface.ts +4 -3
- package/src/components/tasklist/index.ts +1 -6
- package/src/components/tasklist/scss/index.scss +22 -26
- package/src/components/tasklist/scss/variables.scss +14 -20
- package/src/components/textarea/index.ts +49 -91
- package/src/components/textarea/scss/index.scss +20 -15
- package/src/components/textarea/scss/variables.scss +15 -0
- package/src/components/theme/cards.ts +19 -0
- package/src/components/theme/index.ts +58 -17
- package/src/components/theme/reveal.ts +190 -0
- package/src/components/theme/scss/index.scss +109 -0
- package/src/components/theme/scss/variables.scss +153 -3
- package/src/components/{theme-picker → theme}/shared.ts +9 -6
- package/src/components/theme/swatches.ts +15 -0
- package/src/components/theme/toggle.ts +47 -0
- package/src/components/toast/index.ts +2 -3
- package/src/components/toast/scss/index.scss +63 -0
- package/src/components/toast/scss/variables.scss +121 -16
- package/src/components/tooltip/menu.ts +141 -131
- package/src/components/tooltip/onclick.ts +16 -21
- package/src/components/tooltip/onhover.ts +5 -8
- package/src/components/tooltip/scss/index.scss +534 -56
- package/src/components/tooltip/scss/variables.scss +64 -13
- package/src/components/tooltip/shared.ts +129 -87
- package/src/components/tooltip/utilities.ts +75 -24
- package/src/components/typewriter/index.ts +7 -10
- package/src/components/typewriter/rotate.ts +11 -7
- package/src/components/typewriter/scss/index.scss +2 -0
- package/src/components/typewriter/scss/variables.scss +1 -1
- package/src/components/uptime/index.ts +12 -6
- package/src/components/uptime/scss/index.scss +86 -75
- package/src/components/uptime/scss/variables.scss +82 -51
- package/src/components/usage-meter/index.ts +1 -1
- package/src/components/usage-meter/scss/index.scss +0 -3
- package/src/components/usage-meter/scss/variables.scss +13 -14
- package/src/css-utilities/background.scss +9 -1
- package/src/css-utilities/border.scss +3 -0
- package/src/css-utilities/box-shadow.scss +3 -2
- package/src/css-utilities/color.scss +13 -3
- package/src/css-utilities/disabled.scss +12 -0
- package/src/css-utilities/font/geist/index.scss +2 -1
- package/src/css-utilities/font/montserrat/index.scss +1 -1
- package/src/css-utilities/group.scss +1 -2
- package/src/css-utilities/icon.scss +1 -0
- package/src/css-utilities/layer.scss +2 -1
- package/src/css-utilities/skeleton.scss +4 -1
- package/src/css-utilities/surface.scss +97 -108
- package/src/css-utilities/text.scss +13 -13
- package/src/modifiers/background/scss/variables.scss +2 -4
- package/src/modifiers/border/scss/variables.scss +6 -8
- package/src/modifiers/disabled/scss/index.scss +5 -0
- package/src/modifiers/glass/index.ts +2 -1
- package/src/modifiers/glass/scss/index.scss +8 -11
- package/src/modifiers/glass/scss/variables.scss +1 -0
- package/src/modifiers/scrollbar/index.ts +94 -113
- package/src/modifiers/scrollbar/scss/index.scss +20 -2
- package/src/modifiers/scrollbar/scss/variables.scss +2 -2
- package/src/normalize/scss/index.scss +1 -0
- package/src/shared/anchor.ts +1 -1
- package/src/shared/animation.ts +6 -4
- package/src/shared/dispatch.ts +42 -0
- package/src/shared/drag.ts +2 -1
- package/src/shared/press.ts +7 -5
- package/src/shared/resize.ts +4 -35
- package/src/shared/scss/list.scss +1 -2
- package/src/shared/transition.ts +2 -2
- package/src/shared/visible.ts +3 -35
- package/src/tokens/scss/color.scss +16 -20
- package/src/tokens/scss/focus.scss +5 -0
- package/src/tokens/scss/font-size.scss +1 -2
- package/src/tokens/scss/index.scss +1 -0
- package/src/tokens/scss/scale.scss +4 -8
- package/src/tokens/scss/size.scss +3 -3
- package/src/tokens/scss/spacer.scss +1 -1
- package/src/tokens/scss/state.scss +11 -30
- package/vite-env.d.ts +1 -1
- package/vite.config.ts +10 -8
- package/build/components/datalist/index.d.ts +0 -42
- package/build/components/datalist/index.js +0 -186
- package/build/components/datalist/scss/index.scss +0 -2
- package/build/components/inline-edit/format.d.ts +0 -29
- package/build/components/inline-edit/format.js +0 -112
- package/build/components/inline-edit/history.d.ts +0 -14
- package/build/components/inline-edit/history.js +0 -40
- package/build/components/inline-edit/markdown.d.ts +0 -7
- package/build/components/inline-edit/markdown.js +0 -314
- package/build/components/inline-edit/model.d.ts +0 -61
- package/build/components/inline-edit/model.js +0 -192
- package/build/components/inline-edit/selection.d.ts +0 -7
- package/build/components/inline-edit/selection.js +0 -114
- package/build/components/inline-edit/utilities.d.ts +0 -4
- package/build/components/inline-edit/utilities.js +0 -12
- package/build/components/sticky-header/index.d.ts +0 -2166
- package/build/components/sticky-header/index.js +0 -58
- package/build/components/sticky-header/scss/index.scss +0 -2
- package/build/components/theme-picker/cards.d.ts +0 -13
- package/build/components/theme-picker/cards.js +0 -17
- package/build/components/theme-picker/index.d.ts +0 -12
- package/build/components/theme-picker/index.js +0 -7
- package/build/components/theme-picker/scss/index.scss +0 -2
- package/build/components/theme-picker/swatches.d.ts +0 -13
- package/build/components/theme-picker/swatches.js +0 -17
- package/build/components/theme-picker/toggle.d.ts +0 -19
- package/build/components/theme-picker/toggle.js +0 -109
- package/src/components/datalist/index.ts +0 -256
- package/src/components/datalist/scss/index.scss +0 -104
- package/src/components/datalist/scss/variables.scss +0 -43
- package/src/components/inline-edit/format.ts +0 -183
- package/src/components/inline-edit/history.ts +0 -71
- package/src/components/inline-edit/markdown.ts +0 -485
- package/src/components/inline-edit/model.ts +0 -366
- package/src/components/inline-edit/selection.ts +0 -188
- package/src/components/inline-edit/utilities.ts +0 -18
- package/src/components/sticky-header/index.ts +0 -78
- package/src/components/sticky-header/scss/index.scss +0 -141
- package/src/components/sticky-header/scss/variables.scss +0 -78
- package/src/components/theme-picker/cards.ts +0 -19
- package/src/components/theme-picker/index.ts +0 -12
- package/src/components/theme-picker/scss/index.scss +0 -174
- package/src/components/theme-picker/scss/variables.scss +0 -220
- package/src/components/theme-picker/swatches.ts +0 -15
- package/src/components/theme-picker/toggle.ts +0 -150
- package/src/components/tooltip/scss/_center.scss +0 -9
- package/src/components/tooltip/scss/_east.scss +0 -33
- package/src/components/tooltip/scss/_menu.scss +0 -325
- package/src/components/tooltip/scss/_north.scss +0 -33
- package/src/components/tooltip/scss/_shared.scss +0 -112
- package/src/components/tooltip/scss/_south.scss +0 -33
- package/src/components/tooltip/scss/_west.scss +0 -33
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import { blockAt, contentEnd, quotePrefix, type MarkdownBlock } from './model';
|
|
2
|
+
import type { Edit, EditorDocument, Selection } from '../code/document';
|
|
3
|
+
import type { Inline } from './inline';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// The kinds of block the toolbar turns lines into.
|
|
7
|
+
type BlockKind = 'bullet' | 'codeblock' | 'h1' | 'h2' | 'h3' | 'ordered' | 'paragraph' | 'quote' | 'task';
|
|
8
|
+
|
|
9
|
+
type Context = {
|
|
10
|
+
blocks: readonly MarkdownBlock[];
|
|
11
|
+
document: EditorDocument;
|
|
12
|
+
// A block's inline markup, its offsets relative to the block's start.
|
|
13
|
+
tokens: (block: MarkdownBlock) => readonly Inline[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type Formats = {
|
|
17
|
+
block: BlockKind | null;
|
|
18
|
+
// The link the selection sits in, as written.
|
|
19
|
+
link: string | null;
|
|
20
|
+
marks: Record<Mark, boolean>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Mark = 'bold' | 'code' | 'highlight' | 'italic' | 'strike';
|
|
24
|
+
|
|
25
|
+
// A run of a block's text the selection covers, absolute, with the block's markup.
|
|
26
|
+
type Slice = { base: number; from: number; to: number; tokens: readonly Inline[] };
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const DELIMITERS: Record<Exclude<Mark, 'code'>, string> = {
|
|
30
|
+
bold: '**',
|
|
31
|
+
highlight: '==',
|
|
32
|
+
italic: '*',
|
|
33
|
+
strike: '~~'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const FENCE_LINE = /^ {0,3}(?:`{3,}|~{3,})/;
|
|
37
|
+
|
|
38
|
+
const HEADING_PREFIX = /^ {0,3}#{1,6}(?:[ \t]+|$)/;
|
|
39
|
+
|
|
40
|
+
const KINDS: Record<Mark, Inline['kind']> = {
|
|
41
|
+
bold: 'strong',
|
|
42
|
+
code: 'code',
|
|
43
|
+
highlight: 'highlight',
|
|
44
|
+
italic: 'em',
|
|
45
|
+
strike: 'strike'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Characters a link destination can't hold bare.
|
|
49
|
+
const LINK_UNSAFE = /[()<>\s]/g;
|
|
50
|
+
|
|
51
|
+
const LIST_PREFIX = /^[ \t]*(?:[-+*]|\d+[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/;
|
|
52
|
+
|
|
53
|
+
const MARKS: Mark[] = ['bold', 'code', 'highlight', 'italic', 'strike'];
|
|
54
|
+
|
|
55
|
+
// Blocks whose text takes inline markup.
|
|
56
|
+
const PROSE = new Set<MarkdownBlock['kind']>(['heading', 'list', 'paragraph', 'quote']);
|
|
57
|
+
|
|
58
|
+
const SPACE = /\s/;
|
|
59
|
+
|
|
60
|
+
const WORD = /[\p{L}\p{N}_]/u;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// The opening and closing delimiters around a token, as source ranges; null for plain text.
|
|
64
|
+
function delimiters(text: string, token: Inline, base: number): [Edit, Edit] | null {
|
|
65
|
+
let from = base + token.from,
|
|
66
|
+
to = base + token.to;
|
|
67
|
+
|
|
68
|
+
if (token.kind === 'code') {
|
|
69
|
+
let width = 0;
|
|
70
|
+
|
|
71
|
+
while (text[from - width - 1] === '`') {
|
|
72
|
+
width++;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return [{ from: from - width, insert: '', to: from }, { from: to, insert: '', to: to + width }];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (token.kind === 'link') {
|
|
79
|
+
if (token.reference) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let close = destinationEnd(text, to);
|
|
84
|
+
|
|
85
|
+
return close < 0 ? null : [{ from: from - 1, insert: '', to: from }, { from: to, insert: '', to: close }];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let width = token.kind === 'em' ? 1 : token.kind === 'text' ? 0 : 2;
|
|
89
|
+
|
|
90
|
+
return width ? [{ from: from - width, insert: '', to: from }, { from: to, insert: '', to: to + width }] : null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// The offset after a link's '(destination)', from the ']' at 'at'; -1 when it isn't one.
|
|
94
|
+
function destinationEnd(text: string, at: number) {
|
|
95
|
+
if (text[at] !== ']' || text[at + 1] !== '(') {
|
|
96
|
+
return -1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let depth = 0;
|
|
100
|
+
|
|
101
|
+
for (let i = at + 1, n = text.length; i < n; i++) {
|
|
102
|
+
if (text[i] === '\\') {
|
|
103
|
+
i++;
|
|
104
|
+
}
|
|
105
|
+
else if (text[i] === '(') {
|
|
106
|
+
depth++;
|
|
107
|
+
}
|
|
108
|
+
else if (text[i] === ')' && --depth === 0) {
|
|
109
|
+
return i + 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return -1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// The innermost token of 'kind' holding [from, to], with the base its offsets add to.
|
|
117
|
+
function enclosing(tokens: readonly Inline[], base: number, kind: Inline['kind'], from: number, to: number): Inline | null {
|
|
118
|
+
let found: Inline | null = null;
|
|
119
|
+
|
|
120
|
+
for (let i = 0, n = tokens.length; i < n; i++) {
|
|
121
|
+
let token = tokens[i];
|
|
122
|
+
|
|
123
|
+
if (base + token.from > from || base + token.to < to) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (token.kind === kind) {
|
|
128
|
+
found = token;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (token.children) {
|
|
132
|
+
found = enclosing(token.children, base, kind, from, to) ?? found;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return found;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Every token of 'kind' (or of any formatting kind when null) touching [from, to].
|
|
140
|
+
function inside(tokens: readonly Inline[], base: number, kind: Inline['kind'] | null, from: number, to: number, out: Inline[] = []) {
|
|
141
|
+
for (let i = 0, n = tokens.length; i < n; i++) {
|
|
142
|
+
let token = tokens[i];
|
|
143
|
+
|
|
144
|
+
if (base + token.to < from || base + token.from > to) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (token.kind !== 'text' && (kind === null || token.kind === kind)) {
|
|
149
|
+
out.push(token);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (token.children) {
|
|
153
|
+
inside(token.children, base, kind, from, to, out);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Where an offset lands once 'edits' apply; 'after' moves it past text inserted exactly there.
|
|
161
|
+
function map(offset: number, edits: readonly Edit[], after: boolean) {
|
|
162
|
+
let shift = 0;
|
|
163
|
+
|
|
164
|
+
for (let i = 0, n = edits.length; i < n; i++) {
|
|
165
|
+
let { from, insert, to } = edits[i];
|
|
166
|
+
|
|
167
|
+
if (to < offset || (to === offset && (from < to || after))) {
|
|
168
|
+
shift += insert.length - (to - from);
|
|
169
|
+
}
|
|
170
|
+
else if (from < offset) {
|
|
171
|
+
shift += from - offset;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return offset + shift;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Applies 'edits' as one step, the selection following the text it held.
|
|
179
|
+
function commit(context: Context, edits: Edit[], source: string) {
|
|
180
|
+
let { direction, end, start } = context.document.selection;
|
|
181
|
+
|
|
182
|
+
if (!edits.length) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
edits.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
187
|
+
|
|
188
|
+
let next: Selection = {
|
|
189
|
+
direction,
|
|
190
|
+
end: map(end, edits, start === end),
|
|
191
|
+
start: map(start, edits, true)
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
return context.document.transact(edits, { selection: next, source }).changed;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// The selection's runs of prose, a row at a time, trimmed of the spaces markup can't start or end on.
|
|
198
|
+
function slices(context: Context, from: number, to: number) {
|
|
199
|
+
let { blocks, document } = context,
|
|
200
|
+
out: Slice[] = [],
|
|
201
|
+
text = document.value;
|
|
202
|
+
|
|
203
|
+
for (let i = blockAt(blocks, from), n = blocks.length; i < n && blocks[i].from <= to; i++) {
|
|
204
|
+
let block = blocks[i];
|
|
205
|
+
|
|
206
|
+
if (!PROSE.has(block.kind)) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let rows = block.lines ?? [block];
|
|
211
|
+
|
|
212
|
+
for (let j = 0, m = rows.length; j < m; j++) {
|
|
213
|
+
let a = Math.max(from, rows[j].contentFrom),
|
|
214
|
+
b = Math.min(to, rows[j].contentTo);
|
|
215
|
+
|
|
216
|
+
while (a < b && SPACE.test(text[a])) {
|
|
217
|
+
a++;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
while (b > a && SPACE.test(text[b - 1])) {
|
|
221
|
+
b--;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (a < b || (from === to && a === b && rows[j].contentFrom <= a && a <= rows[j].contentTo)) {
|
|
225
|
+
out.push({ base: block.from, from: a, to: b, tokens: context.tokens(block) });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return out;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// The word around a caret, or the caret itself between words.
|
|
234
|
+
function word(text: string, offset: number) {
|
|
235
|
+
let from = offset,
|
|
236
|
+
to = offset;
|
|
237
|
+
|
|
238
|
+
while (from > 0 && WORD.test(text[from - 1])) {
|
|
239
|
+
from--;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
while (to < text.length && WORD.test(text[to])) {
|
|
243
|
+
to++;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return { from, to };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
// The kind of block at a source offset, as the toolbar names it; null for blocks it can't turn into.
|
|
251
|
+
const blockKindAt = (context: Context, offset: number): BlockKind | null => {
|
|
252
|
+
let block = context.blocks[blockAt(context.blocks, offset)];
|
|
253
|
+
|
|
254
|
+
switch (block?.kind) {
|
|
255
|
+
case 'code':
|
|
256
|
+
case 'fence':
|
|
257
|
+
return 'codeblock';
|
|
258
|
+
case 'heading':
|
|
259
|
+
return (block.level ?? 1) <= 3 ? (`h${block.level ?? 1}` as BlockKind) : null;
|
|
260
|
+
case 'list':
|
|
261
|
+
return block.task ? 'task' : /\d/.test(block.marker ?? '') ? 'ordered' : 'bullet';
|
|
262
|
+
case 'quote':
|
|
263
|
+
return 'quote';
|
|
264
|
+
case 'blank':
|
|
265
|
+
case 'paragraph':
|
|
266
|
+
return block.quoteDepth ? 'quote' : 'paragraph';
|
|
267
|
+
default:
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// Removes every inline format in the selection: emphasis, highlights, code and links keep only their text.
|
|
273
|
+
const clearFormats = (context: Context) => {
|
|
274
|
+
let { end, start } = context.document.selection,
|
|
275
|
+
edits: Edit[] = [],
|
|
276
|
+
seen = new Set<number>(),
|
|
277
|
+
text = context.document.value;
|
|
278
|
+
|
|
279
|
+
for (let slice of slices(context, start, end)) {
|
|
280
|
+
for (let token of inside(slice.tokens, slice.base, null, slice.from, slice.to)) {
|
|
281
|
+
let pair = delimiters(text, token, slice.base);
|
|
282
|
+
|
|
283
|
+
if (pair && !seen.has(pair[0].from)) {
|
|
284
|
+
seen.add(pair[0].from);
|
|
285
|
+
edits.push(...pair);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return commit(context, edits, 'markdown-format');
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const formatsAt = (context: Context): Formats => {
|
|
294
|
+
let { end, start } = context.document.selection,
|
|
295
|
+
parts = slices(context, start, end),
|
|
296
|
+
marks = {} as Record<Mark, boolean>,
|
|
297
|
+
link: string | null = null;
|
|
298
|
+
|
|
299
|
+
for (let i = 0, n = MARKS.length; i < n; i++) {
|
|
300
|
+
let kind = KINDS[MARKS[i]];
|
|
301
|
+
|
|
302
|
+
marks[MARKS[i]] = parts.length > 0 && parts.every((part) => !!enclosing(part.tokens, part.base, kind, part.from, part.to));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (parts.length === 1) {
|
|
306
|
+
link = enclosing(parts[0].tokens, parts[0].base, 'link', parts[0].from, parts[0].to)?.href ?? null;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return { block: blockKindAt(context, start), link, marks };
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// Sets or replaces the link over the selection; a null address takes the link off and keeps its text.
|
|
313
|
+
const setLink = (context: Context, href: string | null) => {
|
|
314
|
+
let { end, start } = context.document.selection,
|
|
315
|
+
text = context.document.value,
|
|
316
|
+
parts = slices(context, start, end),
|
|
317
|
+
part = parts[0];
|
|
318
|
+
|
|
319
|
+
if (parts.length !== 1) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
let existing = enclosing(part.tokens, part.base, 'link', part.from, part.to),
|
|
324
|
+
destination = href?.replace(LINK_UNSAFE, encodeURIComponent);
|
|
325
|
+
|
|
326
|
+
if (existing && !existing.reference) {
|
|
327
|
+
let to = part.base + existing.to,
|
|
328
|
+
close = destinationEnd(text, to);
|
|
329
|
+
|
|
330
|
+
if (close < 0) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (destination === undefined) {
|
|
335
|
+
return commit(context, [...delimiters(text, existing, part.base)!], 'markdown-link');
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return commit(context, [{ from: to + 2, insert: destination, to: close - 1 }], 'markdown-link');
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (destination === undefined || part.from === part.to) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return commit(context, [
|
|
346
|
+
{ from: part.from, insert: '[', to: part.from },
|
|
347
|
+
{ from: part.to, insert: `](${destination})`, to: part.to }
|
|
348
|
+
], 'markdown-link');
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// Turns the lines the selection touches into one kind of block: their own markers go and the new one takes their place.
|
|
352
|
+
// A paragraph left after a list or quote, or a list or quote before a paragraph, is set apart by a blank line so it
|
|
353
|
+
// doesn't run on into it.
|
|
354
|
+
const setBlockKind = (context: Context, kind: BlockKind) => {
|
|
355
|
+
let { document } = context,
|
|
356
|
+
{ end, start } = document.selection,
|
|
357
|
+
first = document.lineAt(start),
|
|
358
|
+
last = document.lineAt(end),
|
|
359
|
+
current = blockKindAt(context, start),
|
|
360
|
+
edits: Edit[] = [],
|
|
361
|
+
eol = document.eol;
|
|
362
|
+
|
|
363
|
+
if (end > start && end === document.lineStart(last) && last > first) {
|
|
364
|
+
last--;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// A code block's fences go before its lines take the new kind.
|
|
368
|
+
if (current === 'codeblock') {
|
|
369
|
+
let block = context.blocks[blockAt(context.blocks, start)];
|
|
370
|
+
|
|
371
|
+
if (block.kind === 'fence') {
|
|
372
|
+
let open = document.lineAt(block.from),
|
|
373
|
+
close = document.lineAt(Math.max(block.from, contentEnd(document.value, block)));
|
|
374
|
+
|
|
375
|
+
if (FENCE_LINE.test(document.lineText(close)) && close > open) {
|
|
376
|
+
edits.push({ from: document.lineStart(close) - eol.length, insert: '', to: document.lineEnd(close) });
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
edits.push({ from: document.lineStart(open), insert: '', to: document.lineStart(open + 1) });
|
|
380
|
+
first = Math.max(first, open + 1);
|
|
381
|
+
last = Math.min(Math.max(last, first), close - 1);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (kind === 'codeblock') {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
let number = 1;
|
|
390
|
+
|
|
391
|
+
for (let line = first; line <= last; line++) {
|
|
392
|
+
let value = document.lineText(line),
|
|
393
|
+
quote = quotePrefix(value).length,
|
|
394
|
+
rest = value.slice(quote),
|
|
395
|
+
marker = HEADING_PREFIX.exec(rest)?.[0] ?? LIST_PREFIX.exec(rest)?.[0] ?? '',
|
|
396
|
+
from = document.lineStart(line),
|
|
397
|
+
prefix = '';
|
|
398
|
+
|
|
399
|
+
switch (kind) {
|
|
400
|
+
case 'bullet':
|
|
401
|
+
prefix = '- ';
|
|
402
|
+
break;
|
|
403
|
+
case 'h1':
|
|
404
|
+
case 'h2':
|
|
405
|
+
case 'h3':
|
|
406
|
+
prefix = '#'.repeat(Number(kind[1])) + ' ';
|
|
407
|
+
break;
|
|
408
|
+
case 'ordered':
|
|
409
|
+
prefix = `${number++}. `;
|
|
410
|
+
break;
|
|
411
|
+
case 'quote':
|
|
412
|
+
prefix = '> ';
|
|
413
|
+
break;
|
|
414
|
+
case 'task':
|
|
415
|
+
prefix = '- [ ] ';
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
edits.push({ from, insert: prefix, to: from + quote + marker.length });
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (kind === 'codeblock') {
|
|
423
|
+
edits.push(
|
|
424
|
+
{ from: document.lineStart(first), insert: '```' + eol, to: document.lineStart(first) },
|
|
425
|
+
{ from: document.lineEnd(last), insert: eol + '```', to: document.lineEnd(last) }
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
let container = (line: number) => {
|
|
430
|
+
let value = document.lineText(line);
|
|
431
|
+
|
|
432
|
+
return !!value.trim() && (quotePrefix(value).length > 0 || LIST_PREFIX.test(value));
|
|
433
|
+
},
|
|
434
|
+
prose = (line: number) => {
|
|
435
|
+
let value = document.lineText(line);
|
|
436
|
+
|
|
437
|
+
return !!value.trim()
|
|
438
|
+
&& !quotePrefix(value).length
|
|
439
|
+
&& !FENCE_LINE.test(value)
|
|
440
|
+
&& !HEADING_PREFIX.test(value)
|
|
441
|
+
&& !LIST_PREFIX.test(value);
|
|
442
|
+
},
|
|
443
|
+
nested = kind === 'bullet' || kind === 'ordered' || kind === 'quote' || kind === 'task';
|
|
444
|
+
|
|
445
|
+
if (kind === 'paragraph' && first > 0 && container(first - 1)) {
|
|
446
|
+
edits.push({ from: document.lineStart(first), insert: eol, to: document.lineStart(first) });
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (nested && last + 1 < document.lineCount && prose(last + 1)) {
|
|
450
|
+
edits.push({ from: document.lineEnd(last), insert: eol, to: document.lineEnd(last) });
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return commit(context, edits, 'markdown-block');
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
// Wraps the selection in a mark, or takes the mark off when all of it already carries one. A caret takes the word
|
|
457
|
+
// around it; between words it gets an empty pair to type into.
|
|
458
|
+
const toggleMark = (context: Context, mark: Mark) => {
|
|
459
|
+
let { document } = context,
|
|
460
|
+
{ end, start } = document.selection,
|
|
461
|
+
text = document.value,
|
|
462
|
+
kind = KINDS[mark],
|
|
463
|
+
edits: Edit[] = [];
|
|
464
|
+
|
|
465
|
+
if (start === end) {
|
|
466
|
+
let around = word(text, start);
|
|
467
|
+
|
|
468
|
+
start = around.from;
|
|
469
|
+
end = around.to;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
let open = mark === 'code' ? '`' : DELIMITERS[mark],
|
|
473
|
+
parts = slices(context, start, end),
|
|
474
|
+
active = parts.length > 0 && parts.every((part) => !!enclosing(part.tokens, part.base, kind, part.from, part.to));
|
|
475
|
+
|
|
476
|
+
if (!parts.length) {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (start === end && !active) {
|
|
481
|
+
return document.replace(start, end, open + open, { selection: { start: start + open.length }, source: 'markdown-format' });
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
let seen = new Set<number>(),
|
|
485
|
+
strip = (part: Slice, token: Inline) => {
|
|
486
|
+
let pair = delimiters(text, token, part.base);
|
|
487
|
+
|
|
488
|
+
if (pair && !seen.has(pair[0].from)) {
|
|
489
|
+
seen.add(pair[0].from);
|
|
490
|
+
edits.push(...pair);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
for (let i = 0, n = parts.length; i < n; i++) {
|
|
495
|
+
let part = parts[i];
|
|
496
|
+
|
|
497
|
+
if (active) {
|
|
498
|
+
strip(part, enclosing(part.tokens, part.base, kind, part.from, part.to)!);
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Marks of the same kind inside the run merge into the one around it.
|
|
503
|
+
for (let token of inside(part.tokens, part.base, kind, part.from, part.to)) {
|
|
504
|
+
if (part.base + token.from >= part.from && part.base + token.to <= part.to) {
|
|
505
|
+
strip(part, token);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
edits.push({ from: part.from, insert: open, to: part.from }, { from: part.to, insert: open, to: part.to });
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return commit(context, edits, 'markdown-format');
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
export { blockKindAt, clearFormats, formatsAt, setBlockKind, setLink, toggleMark };
|
|
517
|
+
export type { BlockKind, Context, Formats, Mark };
|
|
@@ -2,7 +2,7 @@ type Inline = {
|
|
|
2
2
|
children?: Inline[];
|
|
3
3
|
from: number;
|
|
4
4
|
href?: string;
|
|
5
|
-
kind: 'code' | 'em' | 'link' | 'strike' | 'strong' | 'text';
|
|
5
|
+
kind: 'code' | 'em' | 'highlight' | 'link' | 'strike' | 'strong' | 'text';
|
|
6
6
|
reference?: boolean;
|
|
7
7
|
text: string;
|
|
8
8
|
to: number;
|
|
@@ -34,6 +34,9 @@ const NOT_SPACE = /[^ ]/;
|
|
|
34
34
|
|
|
35
35
|
const NO_IMAGE = /^(?:mailto:|tel:)/i;
|
|
36
36
|
|
|
37
|
+
// Delimiters that only ever pair two at a time: '~~' strikes text through and '==' highlights it.
|
|
38
|
+
const PAIRED = new Set(['=', '~']);
|
|
39
|
+
|
|
37
40
|
const PUNCTUATION = /[\p{P}\p{S}]/u;
|
|
38
41
|
|
|
39
42
|
const SAFE_SCHEME = /^(?:https?:|mailto:|tel:)/i;
|
|
@@ -155,7 +158,7 @@ function delimiterEnd(text: string, at: number, length: number, width: number) {
|
|
|
155
158
|
|
|
156
159
|
// CommonMark's rule of three: a run that both opens and closes can't pair with one whose total is a
|
|
157
160
|
// multiple of three unless both are.
|
|
158
|
-
let odd = character
|
|
161
|
+
let odd = !PAIRED.has(character) &&
|
|
159
162
|
(flank.open || flanking(text, at, length).close) &&
|
|
160
163
|
(length + count) % 3 === 0 &&
|
|
161
164
|
(length % 3 !== 0 || count % 3 !== 0);
|
|
@@ -166,7 +169,7 @@ function delimiterEnd(text: string, at: number, length: number, width: number) {
|
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
if (flank.open && (!flank.close || nested.length || remaining < width)) {
|
|
169
|
-
nested.push(character
|
|
172
|
+
nested.push(PAIRED.has(character) ? 2 : count);
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
i += count - 1;
|
|
@@ -340,10 +343,10 @@ const parseInline = (source: string, origin = 0, depth = 0, references: Referenc
|
|
|
340
343
|
}
|
|
341
344
|
}
|
|
342
345
|
|
|
343
|
-
if (source[i] === '*' || source[i] === '_' || source.startsWith('~~', i)) {
|
|
346
|
+
if (source[i] === '*' || source[i] === '_' || source.startsWith('~~', i) || source.startsWith('==', i)) {
|
|
344
347
|
let character = source[i],
|
|
345
348
|
count = run(source, i),
|
|
346
|
-
width = character
|
|
349
|
+
width = PAIRED.has(character) ? 2 : count % 2 === 1 ? 1 : 2,
|
|
347
350
|
end = flanking(source, i, count).open ? delimiterEnd(source, i, count, width) : -1;
|
|
348
351
|
|
|
349
352
|
if (end > i + width) {
|
|
@@ -353,7 +356,7 @@ const parseInline = (source: string, origin = 0, depth = 0, references: Referenc
|
|
|
353
356
|
result.push({
|
|
354
357
|
children: parseInline(text, origin + i + width, depth + 1, references),
|
|
355
358
|
from: origin + i + width,
|
|
356
|
-
kind: character === '~' ? 'strike' : width === 2 ? 'strong' : 'em',
|
|
359
|
+
kind: character === '~' ? 'strike' : character === '=' ? 'highlight' : width === 2 ? 'strong' : 'em',
|
|
357
360
|
text,
|
|
358
361
|
to: origin + end
|
|
359
362
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { preferredEol, type Edit, type EditorDocument
|
|
1
|
+
import { preferredEol, type Edit, type EditorDocument } from '../code/document';
|
|
2
2
|
import { referenceLabel } from './inline';
|
|
3
3
|
|
|
4
4
|
|
|
@@ -391,18 +391,6 @@ const blockAt = (blocks: readonly MarkdownBlock[], offset: number) => {
|
|
|
391
391
|
return Math.max(0, lo - 1);
|
|
392
392
|
};
|
|
393
393
|
|
|
394
|
-
// The blocks [first, last) a selection touches; a caret at the very end belongs to the last block.
|
|
395
|
-
const blocksAt = (blocks: readonly MarkdownBlock[], selection: Pick<Selection, 'end' | 'start'>) => {
|
|
396
|
-
if (!blocks.length) {
|
|
397
|
-
return { first: 0, last: 0 };
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
let first = blockAt(blocks, selection.start),
|
|
401
|
-
last = selection.end > selection.start ? blockAt(blocks, selection.end - 1) : first;
|
|
402
|
-
|
|
403
|
-
return { first, last: last + 1 };
|
|
404
|
-
};
|
|
405
|
-
|
|
406
394
|
// The block's source without its final line break.
|
|
407
395
|
const contentEnd = (text: string, block: MarkdownBlock) => {
|
|
408
396
|
return block.to - (TRAILING_EOL.exec(text.slice(Math.max(block.from, block.to - 2), block.to))?.[0].length ?? 0);
|
|
@@ -721,17 +709,14 @@ const toggleTask = (document: EditorDocument, task: Task) => {
|
|
|
721
709
|
|
|
722
710
|
export {
|
|
723
711
|
blockAt,
|
|
724
|
-
blocksAt,
|
|
725
712
|
contentEnd,
|
|
726
|
-
indentColumns,
|
|
727
713
|
markdownBackspace,
|
|
728
714
|
markdownEnter,
|
|
729
715
|
markdownReferences,
|
|
730
716
|
parseMarkdown,
|
|
731
717
|
quotePrefix,
|
|
732
718
|
reparse,
|
|
733
|
-
shiftBlock,
|
|
734
719
|
toggleMarkdown,
|
|
735
720
|
toggleTask
|
|
736
721
|
};
|
|
737
|
-
export type { Kind, MarkdownBlock, Row,
|
|
722
|
+
export type { Kind, MarkdownBlock, Row, Task };
|
|
@@ -280,6 +280,9 @@ const renderer = (host: Host) => {
|
|
|
280
280
|
case 'em':
|
|
281
281
|
out.push(html`<em class='markdown-editor-em'>${content}</em>`);
|
|
282
282
|
break;
|
|
283
|
+
case 'highlight':
|
|
284
|
+
out.push(html`<mark class='markdown-editor-highlight'>${content}</mark>`);
|
|
285
|
+
break;
|
|
283
286
|
case 'link':
|
|
284
287
|
out.push(
|
|
285
288
|
token.href
|
|
@@ -444,8 +447,6 @@ const renderer = (host: Host) => {
|
|
|
444
447
|
class: [
|
|
445
448
|
block.level ? `markdown-editor-block--h${block.level}` : '',
|
|
446
449
|
block.quoteDepth ? 'markdown-editor-block--quoted' : '',
|
|
447
|
-
unit.continuation ? 'markdown-editor-block--continuation' : '',
|
|
448
|
-
unit.continues ? 'markdown-editor-block--continues' : '',
|
|
449
450
|
block.task && !unit.continuation ? 'markdown-editor-block--task' : '',
|
|
450
451
|
unit.raw || unit.fold ? 'markdown-editor-block--raw' : ''
|
|
451
452
|
],
|