@esportsplus/ui 0.61.0 → 0.63.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 +4 -132
- package/.audit/check-scss.mjs +2 -2
- package/.audit/rules-audit.md +3 -28
- 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/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 -4
- package/build/components/index.js +0 -4
- 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 +13 -14
- 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/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 -4
- 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 +3 -9
- package/src/components/pagination/scss/index.scss +12 -12
- package/src/components/pagination/scss/variables.scss +39 -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/cc/index.d.ts +0 -30
- package/build/components/cc/index.js +0 -561
- package/build/components/cc/scss/index.scss +0 -2
- 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/cc/index.ts +0 -563
- package/src/components/cc/scss/index.scss +0 -386
- package/src/components/cc/scss/variables.scss +0 -254
- 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
|
@@ -1,485 +0,0 @@
|
|
|
1
|
-
import { block, list, nest, sort, text, type Block, type Doc, type Kind, type Mark, type Run, type Tree } from './model';
|
|
2
|
-
import { INLINE_LINE_BREAKS, NON_BREAKING_SPACES, safe } from './utilities';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type Feature = Group | Mark | 'clear' | 'copy';
|
|
6
|
-
|
|
7
|
-
type Group = 'bullet' | 'codeblock' | 'heading' | 'ordered' | 'quote' | 'task';
|
|
8
|
-
|
|
9
|
-
type Rule = {
|
|
10
|
-
mark: Mark;
|
|
11
|
-
pattern: RegExp;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const BACKSLASHES = /\\/g;
|
|
16
|
-
|
|
17
|
-
const EMPHASIS_DELIMITERS = /[*_]/g;
|
|
18
|
-
|
|
19
|
-
const NON_WHITESPACE = /\S/;
|
|
20
|
-
|
|
21
|
-
const WORD_CHARACTER = /\w/;
|
|
22
|
-
|
|
23
|
-
const BACKTICKS = /`/g;
|
|
24
|
-
|
|
25
|
-
const BRACKETS = /[[\]]/g;
|
|
26
|
-
|
|
27
|
-
const NEWLINES = /\n/g;
|
|
28
|
-
|
|
29
|
-
const LINK_CHARACTERS = /[()\s]/g;
|
|
30
|
-
|
|
31
|
-
const HEADING_PREFIX = /^#{1,6}\s/;
|
|
32
|
-
|
|
33
|
-
const BULLET_PREFIX = /^[-*+]\s/;
|
|
34
|
-
|
|
35
|
-
const ORDERED_PREFIX = /^\d+[.)]\s/;
|
|
36
|
-
|
|
37
|
-
const ORDERED_NUMBER = /^(\d+)/;
|
|
38
|
-
|
|
39
|
-
const SURROUNDING_NEWLINES = /^\n+|\n+$/g;
|
|
40
|
-
|
|
41
|
-
const ESCAPED_PUNCTUATION = /\\([!-/:-@[-`{-~])/g;
|
|
42
|
-
|
|
43
|
-
const TRAILING_NEWLINES = /\n+$/;
|
|
44
|
-
|
|
45
|
-
const WHITESPACE = /\s+/g;
|
|
46
|
-
|
|
47
|
-
const LINE_BREAKS = /\r\n?/g;
|
|
48
|
-
|
|
49
|
-
const SUPPORTED_HEADING_PREFIX = /^#{1,3}\s/;
|
|
50
|
-
|
|
51
|
-
const QUOTE_PREFIX = /^>/;
|
|
52
|
-
|
|
53
|
-
const CODEBLOCK_PREFIX = /^```/;
|
|
54
|
-
|
|
55
|
-
const HEADING = /^(#{1,3})\s+(.*)$/;
|
|
56
|
-
|
|
57
|
-
const QUOTE_MARKER = /^>\s?/;
|
|
58
|
-
|
|
59
|
-
const TASK_PREFIX = /^[-*+]\s+\[[ xX]\]\s/;
|
|
60
|
-
|
|
61
|
-
const TASK_ITEM = /^[-*+]\s+\[([ xX])\]\s+(.*)$/;
|
|
62
|
-
|
|
63
|
-
const BULLET_ITEM = /^[-*+]\s+()(.*)$/;
|
|
64
|
-
|
|
65
|
-
const ORDERED_ITEM = /^\d+[.)]\s+()(.*)$/;
|
|
66
|
-
|
|
67
|
-
const MARK_PAIRS = {
|
|
68
|
-
'=': /==/g,
|
|
69
|
-
'~': /~~/g
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Keyed by the runs array, which the model never changes in place: the dirty check serializes the whole document
|
|
74
|
-
// on every keystroke, and this leaves only the edited block to write again.
|
|
75
|
-
const PARAGRAPHS = new WeakMap<Set<Feature>, WeakMap<Run[], string>>();
|
|
76
|
-
|
|
77
|
-
// Escaped ASCII punctuation is parked on the private use area while marks are matched, so it can't delimit one.
|
|
78
|
-
const PARKED = /[-]/g;
|
|
79
|
-
|
|
80
|
-
// Earliest match wins; on a tie the rule listed first does, so '**' is read as bold before italic sees a '*'.
|
|
81
|
-
const RULES: Rule[] = [
|
|
82
|
-
{ mark: 'code', pattern: /`([^`\n]+)`/ },
|
|
83
|
-
// Addresses may hold one level of balanced parentheses.
|
|
84
|
-
{ mark: 'link', pattern: /\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/ },
|
|
85
|
-
{ mark: 'bold', pattern: /\*\*(?=\S)([^\n]*?\S)\*\*/ },
|
|
86
|
-
{ mark: 'strike', pattern: /~~(?=\S)([^\n]*?\S)~~/ },
|
|
87
|
-
{ mark: 'highlight', pattern: /==(?=\S)([^\n]*?\S)==/ },
|
|
88
|
-
// '_' only between non-word characters (so snake_case stays text), '*' anywhere, including inside a word.
|
|
89
|
-
{ mark: 'italic', pattern: /(?<![\w\\])_(?=\S)([^\n]*?\S)_(?!\w)|(?<!\*)\*(?=[^\s*])([^\n]*?[^\s*])\*(?!\*)/ }
|
|
90
|
-
];
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// Only characters that could open or close enabled formatting are escaped, so prose like 'snake_case' or 'a == b'
|
|
94
|
-
// stays readable in the saved markdown.
|
|
95
|
-
function escape(text: string, features: Set<Feature>) {
|
|
96
|
-
text = text.replace(BACKSLASHES, '\\\\');
|
|
97
|
-
|
|
98
|
-
if (features.has('bold') || features.has('italic')) {
|
|
99
|
-
text = text.replace(EMPHASIS_DELIMITERS, (c: string, i: number, s: string) => {
|
|
100
|
-
let after = s[i + 1] ?? '',
|
|
101
|
-
before = s[i - 1] ?? '';
|
|
102
|
-
|
|
103
|
-
// '_' only delimits at a word boundary; '*' anywhere it touches text.
|
|
104
|
-
let delimits = c === '*'
|
|
105
|
-
? NON_WHITESPACE.test(before) || NON_WHITESPACE.test(after)
|
|
106
|
-
: (!WORD_CHARACTER.test(before) && NON_WHITESPACE.test(after)) || (NON_WHITESPACE.test(before) && !WORD_CHARACTER.test(after));
|
|
107
|
-
|
|
108
|
-
return delimits ? `\\${c}` : c;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (features.has('code')) {
|
|
113
|
-
text = text.replace(BACKTICKS, '\\`');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (features.has('highlight')) {
|
|
117
|
-
text = pairs(text, '=');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (features.has('link')) {
|
|
121
|
-
text = text.replace(BRACKETS, '\\$&');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (features.has('strike')) {
|
|
125
|
-
text = pairs(text, '~');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return text;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// The first character a tree writes, to choose an italic delimiter that can't join the text after it.
|
|
132
|
-
function first(tree: Tree | undefined): string {
|
|
133
|
-
if (!tree) {
|
|
134
|
-
return '';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return 'text' in tree ? tree.text[0] ?? '' : first(tree.children[0]);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function inline(trees: Tree[], features: Set<Feature>): string {
|
|
141
|
-
let out = '';
|
|
142
|
-
|
|
143
|
-
for (let i = 0, n = trees.length; i < n; i++) {
|
|
144
|
-
let tree = trees[i];
|
|
145
|
-
|
|
146
|
-
if ('text' in tree) {
|
|
147
|
-
out += escape(tree.text.replace(NON_BREAKING_SPACES, ' '), features);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (!features.has(tree.mark)) {
|
|
152
|
-
out += inline(tree.children, features);
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (tree.mark === 'code') {
|
|
157
|
-
let value = plain(tree).replace(NEWLINES, ' ');
|
|
158
|
-
|
|
159
|
-
out += value.includes('`') ? `\`\` ${value} \`\`` : `\`${value}\``;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
let value = inline(tree.children, features),
|
|
164
|
-
core = value.trim();
|
|
165
|
-
|
|
166
|
-
if (!core) {
|
|
167
|
-
out += value;
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Delimiters only bind to text, so surrounding spaces move outside them.
|
|
172
|
-
let lead = value.slice(0, value.indexOf(core)),
|
|
173
|
-
trail = value.slice(value.indexOf(core) + core.length);
|
|
174
|
-
|
|
175
|
-
if (tree.mark === 'link') {
|
|
176
|
-
// encodeURIComponent leaves parentheses alone, and an unbalanced one would end the address early.
|
|
177
|
-
out += lead + (safe(tree.href) ? `[${core}](${tree.href.replace(LINK_CHARACTERS, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase().padStart(2, '0')}`)})` : core) + trail;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
out += lead + wrap(tree.mark, core, (out + lead).slice(-1), trail[0] ?? first(trees[i + 1])) + trail;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return out;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Inline markdown as runs styled on top of 'style'.
|
|
188
|
-
function marks(value: string, features: Set<Feature>, style: Run, out: Run[]) {
|
|
189
|
-
while (value) {
|
|
190
|
-
let found: { match: RegExpExecArray, rule: Rule } | null = null;
|
|
191
|
-
|
|
192
|
-
for (let i = 0, n = RULES.length; i < n; i++) {
|
|
193
|
-
let rule = RULES[i];
|
|
194
|
-
|
|
195
|
-
if (!features.has(rule.mark)) {
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
let match = rule.pattern.exec(value);
|
|
200
|
-
|
|
201
|
-
if (match && (!found || match.index < found.match.index)) {
|
|
202
|
-
found = { match, rule };
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (!found) {
|
|
207
|
-
out.push({ ...style, text: unpark(value) });
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
let { match, rule } = found;
|
|
212
|
-
|
|
213
|
-
if (match.index > 0) {
|
|
214
|
-
out.push({ ...style, text: unpark(value.slice(0, match.index)) });
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
value = value.slice(match.index + match[0].length);
|
|
218
|
-
|
|
219
|
-
if (rule.mark === 'code') {
|
|
220
|
-
out.push({ href: style.href, marks: sort([...style.marks, 'code']), text: unpark(match[1], true) });
|
|
221
|
-
}
|
|
222
|
-
else if (rule.mark === 'link') {
|
|
223
|
-
let href = unpark(match[2]);
|
|
224
|
-
|
|
225
|
-
marks(match[1], features, safe(href) ? { ...style, href } : style, out);
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
marks(match[1] ?? match[2], features, { ...style, marks: sort([...style.marks, rule.mark]) }, out);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// A doubled '=' or '~' delimits only when it touches text on one side.
|
|
234
|
-
function pairs(text: string, c: keyof typeof MARK_PAIRS) {
|
|
235
|
-
return text.replace(MARK_PAIRS[c], (pair: string, i: number, s: string) =>
|
|
236
|
-
NON_WHITESPACE.test(s[i - 1] ?? '') || NON_WHITESPACE.test(s[i + 2] ?? '') ? `\\${c}\\${c}` : pair
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Paragraph text, with a line that would open an enabled block escaped so it reads back as text.
|
|
241
|
-
function paragraph(runs: Run[], features: Set<Feature>) {
|
|
242
|
-
let memo = PARAGRAPHS.get(features);
|
|
243
|
-
|
|
244
|
-
if (!memo) {
|
|
245
|
-
PARAGRAPHS.set(features, memo = new WeakMap());
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
let out = memo.get(runs);
|
|
249
|
-
|
|
250
|
-
if (out === undefined) {
|
|
251
|
-
memo.set(runs, out = prose(runs, features));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return out;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function park(text: string) {
|
|
258
|
-
return text.replace(ESCAPED_PUNCTUATION, (_, c: string) => String.fromCharCode(0xE000 + c.charCodeAt(0)));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function plain(tree: Tree): string {
|
|
262
|
-
return 'text' in tree ? tree.text : tree.children.map(plain).join('');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function prose(runs: Run[], features: Set<Feature>) {
|
|
266
|
-
return inline(nest(runs), features)
|
|
267
|
-
.split('\n')
|
|
268
|
-
.map((line) => {
|
|
269
|
-
line = line.trim();
|
|
270
|
-
|
|
271
|
-
if (
|
|
272
|
-
(features.has('heading') && HEADING_PREFIX.test(line)) ||
|
|
273
|
-
(features.has('quote') && line[0] === '>') ||
|
|
274
|
-
((features.has('bullet') || features.has('task')) && BULLET_PREFIX.test(line))
|
|
275
|
-
) {
|
|
276
|
-
return `\\${line}`;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (features.has('ordered') && ORDERED_PREFIX.test(line)) {
|
|
280
|
-
return line.replace(ORDERED_NUMBER, '$1\\');
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (features.has('codeblock') && line.startsWith('```')) {
|
|
284
|
-
return `\\${line}`;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return line;
|
|
288
|
-
})
|
|
289
|
-
.join('\n')
|
|
290
|
-
.replace(SURROUNDING_NEWLINES, '');
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function runs(value: string, features: Set<Feature>) {
|
|
294
|
-
let out: Run[] = [];
|
|
295
|
-
|
|
296
|
-
marks(park(value), features, { href: '', marks: [], text: '' }, out);
|
|
297
|
-
|
|
298
|
-
return out;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Code keeps its backslashes; everywhere else an escape reads as the character itself.
|
|
302
|
-
function unpark(text: string, code = false) {
|
|
303
|
-
return text.replace(PARKED, (c) => (code ? '\\' : '') + String.fromCharCode(c.charCodeAt(0) - 0xE000));
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function wrap(mark: Mark, text: string, before: string, after: string) {
|
|
307
|
-
switch (mark) {
|
|
308
|
-
case 'bold':
|
|
309
|
-
return `**${text}**`;
|
|
310
|
-
case 'highlight':
|
|
311
|
-
return `==${text}==`;
|
|
312
|
-
case 'italic':
|
|
313
|
-
// '_' can't sit inside a word, so an emphasised part of one uses '*'.
|
|
314
|
-
return WORD_CHARACTER.test(before) || WORD_CHARACTER.test(after) ? `*${text}*` : `_${text}_`;
|
|
315
|
-
default:
|
|
316
|
-
return `~~${text}~~`;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function write(group: Block[], features: Set<Feature>): string {
|
|
321
|
-
let { kind, runs } = group[0];
|
|
322
|
-
|
|
323
|
-
if (list(kind)) {
|
|
324
|
-
let enabled = features.has(kind as Group),
|
|
325
|
-
lines: string[] = [];
|
|
326
|
-
|
|
327
|
-
for (let i = 0, n = group.length; i < n; i++) {
|
|
328
|
-
let value = paragraph(group[i].runs, features).replace(NEWLINES, ' ');
|
|
329
|
-
|
|
330
|
-
if (!enabled) {
|
|
331
|
-
lines.push(value);
|
|
332
|
-
}
|
|
333
|
-
else if (kind === 'ordered') {
|
|
334
|
-
lines.push(`${i + 1}. ${value}`);
|
|
335
|
-
}
|
|
336
|
-
else if (kind === 'task') {
|
|
337
|
-
lines.push(`- [${group[i].checked ? 'x' : ' '}] ${value}`);
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
lines.push(`- ${value}`);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return lines.filter(Boolean).join(enabled ? '\n' : '\n\n');
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (kind === 'codeblock') {
|
|
348
|
-
let value = text(runs).replace(TRAILING_NEWLINES, '');
|
|
349
|
-
|
|
350
|
-
return features.has('codeblock') ? `\`\`\`\n${value}\n\`\`\`` : prose([{ href: '', marks: [], text: value }], features);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
let value = paragraph(runs, features);
|
|
354
|
-
|
|
355
|
-
if (kind === 'quote') {
|
|
356
|
-
return features.has('quote') && value ? value.split('\n').map((line) => `> ${line}`).join('\n') : value;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (kind[0] === 'h') {
|
|
360
|
-
return features.has('heading') && value ? `${'#'.repeat(Number(kind[1]))} ${value.replace(NEWLINES, ' ')}` : value;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return value;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// Always at least one block, so there is a line to put the caret on.
|
|
368
|
-
const parse = (markdown: string, features: Set<Feature>, multiline: boolean): Doc => {
|
|
369
|
-
if (!multiline) {
|
|
370
|
-
return [block('paragraph', runs(markdown.replace(WHITESPACE, ' ').trim(), features))];
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
let doc: Doc = [],
|
|
374
|
-
lines = markdown.replace(LINE_BREAKS, '\n').split('\n'),
|
|
375
|
-
n = lines.length;
|
|
376
|
-
|
|
377
|
-
let opens = (line: string) =>
|
|
378
|
-
(features.has('heading') && SUPPORTED_HEADING_PREFIX.test(line)) ||
|
|
379
|
-
(features.has('quote') && QUOTE_PREFIX.test(line)) ||
|
|
380
|
-
(features.has('codeblock') && CODEBLOCK_PREFIX.test(line)) ||
|
|
381
|
-
((features.has('bullet') || features.has('task')) && BULLET_PREFIX.test(line)) ||
|
|
382
|
-
(features.has('ordered') && ORDERED_PREFIX.test(line));
|
|
383
|
-
|
|
384
|
-
for (let i = 0; i < n;) {
|
|
385
|
-
let line = lines[i],
|
|
386
|
-
match: RegExpMatchArray | null;
|
|
387
|
-
|
|
388
|
-
if (!line.trim()) {
|
|
389
|
-
i++;
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (features.has('codeblock') && line.startsWith('```')) {
|
|
394
|
-
let body: string[] = [];
|
|
395
|
-
|
|
396
|
-
for (i++; i < n && !lines[i].startsWith('```'); i++) {
|
|
397
|
-
body.push(lines[i]);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
doc.push(block('codeblock', body.length && body.join('\n') ? [{ href: '', marks: [], text: body.join('\n') }] : []));
|
|
401
|
-
i++;
|
|
402
|
-
continue;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (features.has('heading') && (match = line.match(HEADING))) {
|
|
406
|
-
doc.push(block(`h${match[1].length}` as Kind, runs(match[2].trim(), features)));
|
|
407
|
-
i++;
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (features.has('quote') && line.startsWith('>')) {
|
|
412
|
-
let body: string[] = [];
|
|
413
|
-
|
|
414
|
-
for (; i < n && lines[i].startsWith('>'); i++) {
|
|
415
|
-
body.push(lines[i].replace(QUOTE_MARKER, ''));
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
doc.push(block('quote', runs(body.join('\n'), features)));
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
let kind = (
|
|
423
|
-
(features.has('task') && TASK_PREFIX.test(line) && 'task') ||
|
|
424
|
-
(features.has('bullet') && BULLET_PREFIX.test(line) && 'bullet') ||
|
|
425
|
-
(features.has('ordered') && ORDERED_PREFIX.test(line) && 'ordered')
|
|
426
|
-
) as Kind | false;
|
|
427
|
-
|
|
428
|
-
if (kind) {
|
|
429
|
-
let pattern = kind === 'task' ? TASK_ITEM : kind === 'bullet' ? BULLET_ITEM : ORDERED_ITEM;
|
|
430
|
-
|
|
431
|
-
for (; i < n && (match = lines[i].match(pattern)); i++) {
|
|
432
|
-
doc.push(block(kind, runs(match[2].trim(), features), kind === 'task' && match[1] !== ' '));
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
continue;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
let body: string[] = [];
|
|
439
|
-
|
|
440
|
-
for (; i < n && lines[i].trim() && (!body.length || !opens(lines[i])); i++) {
|
|
441
|
-
body.push(lines[i].trim());
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
doc.push(block('paragraph', runs(body.join('\n'), features)));
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (!doc.length) {
|
|
448
|
-
doc.push(block('paragraph', []));
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return doc;
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
const serialize = (doc: Doc, features: Set<Feature>, multiline: boolean) => {
|
|
455
|
-
if (!multiline) {
|
|
456
|
-
return doc.map((b) => inline(nest(b.runs), features)).join(' ').replace(INLINE_LINE_BREAKS, ' ').trim();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
let out: string[] = [];
|
|
460
|
-
|
|
461
|
-
// Consecutive items of one kind of list are one list.
|
|
462
|
-
for (let i = 0, n = doc.length; i < n;) {
|
|
463
|
-
let j = i + 1;
|
|
464
|
-
|
|
465
|
-
if (list(doc[i].kind)) {
|
|
466
|
-
while (j < n && doc[j].kind === doc[i].kind) {
|
|
467
|
-
j++;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
let value = write(doc.slice(i, j), features);
|
|
472
|
-
|
|
473
|
-
if (value) {
|
|
474
|
-
out.push(value);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
i = j;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
return out.join('\n\n').trim();
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
export { parse, serialize };
|
|
485
|
-
export type { Feature, Group };
|