@esportsplus/ui 0.57.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -39
- package/build/components/accordion/group.d.ts +14 -0
- package/build/components/accordion/group.js +21 -0
- package/build/components/accordion/index.d.ts +9 -0
- package/build/components/accordion/index.js +20 -3
- package/build/components/accordion/scss/index.scss +1 -1
- package/build/components/announcement/scss/index.scss +1 -1
- package/build/components/breadcrumb/scss/index.scss +1 -1
- package/build/components/button/scss/index.scss +1 -1
- package/build/components/button/sidebar.d.ts +3 -0
- package/build/components/button/sidebar.js +40 -10
- package/build/components/capslock/index.js +1 -1
- package/build/components/capslock/scss/index.scss +1 -1
- package/build/components/card/scss/index.scss +1 -1
- package/build/components/cc/scss/index.scss +1 -1
- package/build/components/chat-minimap/scss/index.scss +1 -1
- package/build/components/checkbox/scss/index.scss +1 -1
- package/build/components/color-picker/index.d.ts +1 -0
- package/build/components/color-picker/index.js +166 -136
- package/build/components/color-picker/scss/index.scss +1 -1
- package/build/components/command/index.d.ts +0 -1
- package/build/components/command/index.js +3 -2
- package/build/components/command/scss/index.scss +1 -1
- package/build/components/copy/scss/index.scss +1 -1
- package/build/components/counter/scss/index.scss +1 -1
- package/build/components/datalist/index.js +3 -3
- package/build/components/datalist/scss/index.scss +1 -1
- package/build/components/dock/scss/index.scss +1 -1
- package/build/components/editor/code/index.d.ts +0 -1
- package/build/components/editor/code/index.js +0 -1
- package/build/components/editor/code/minimap.d.ts +2 -1
- package/build/components/editor/code/minimap.js +5 -2
- package/build/components/editor/code/view.d.ts +3 -1
- package/build/components/editor/code/view.js +37 -26
- package/build/components/editor/diffs/index.d.ts +0 -1
- package/build/components/editor/diffs/index.js +0 -1
- package/build/components/editor/diffs/merge.js +7 -3
- package/build/components/editor/diffs/view.js +3 -1
- package/build/components/editor/index.d.ts +4 -1
- package/build/components/editor/index.js +2 -1
- package/build/components/editor/markdown/editing.js +22 -3
- package/build/components/editor/markdown/erase.d.ts +9 -0
- package/build/components/editor/markdown/erase.js +78 -0
- package/build/components/editor/markdown/index.d.ts +0 -1
- package/build/components/editor/markdown/index.js +0 -1
- package/build/components/editor/markdown/layout.d.ts +2 -9
- package/build/components/editor/markdown/layout.js +2 -7
- package/build/components/editor/markdown/render.d.ts +0 -1
- package/build/components/editor/markdown/render.js +287 -235
- package/build/components/editor/markdown/view.js +566 -667
- package/build/components/editor/viewer/index.d.ts +27 -0
- package/build/components/editor/viewer/index.js +250 -0
- package/build/components/editor/viewer/model.d.ts +15 -0
- package/build/components/editor/viewer/model.js +73 -0
- package/build/components/editor/workspace/index.d.ts +6 -2
- package/build/components/editor/workspace/index.js +243 -137
- package/build/components/editor/workspace/keybindings.d.ts +37 -0
- package/build/components/editor/workspace/keybindings.js +288 -0
- package/build/components/editor/workspace/model.d.ts +55 -2
- package/build/components/editor/workspace/model.js +141 -3
- package/build/components/editor/workspace/navigate.d.ts +19 -0
- package/build/components/editor/workspace/navigate.js +118 -0
- package/build/components/editor/workspace/session.d.ts +29 -0
- package/build/components/editor/workspace/session.js +373 -0
- package/build/components/editor/workspace/shortcuts.d.ts +19 -0
- package/build/components/editor/workspace/shortcuts.js +185 -0
- package/build/components/editor/workspace/status.d.ts +34 -0
- package/build/components/editor/workspace/status.js +193 -0
- package/build/components/editor/workspace/statusbar.d.ts +15 -0
- package/build/components/editor/workspace/statusbar.js +190 -0
- package/build/components/editor/workspace/strip.d.ts +27 -0
- package/build/components/editor/workspace/strip.js +239 -0
- package/build/components/editor/workspace/tabs.d.ts +15 -0
- package/build/components/editor/workspace/tabs.js +63 -0
- package/build/components/error/index.js +1 -1
- package/build/components/error/scss/index.scss +1 -1
- package/build/components/filter/index.js +5 -3
- package/build/components/filter/scss/index.scss +1 -1
- package/build/components/frame/scss/index.scss +1 -1
- package/build/components/heatmap/index.js +3 -3
- package/build/components/heatmap/scss/index.scss +1 -1
- package/build/components/highlight/scss/index.scss +1 -1
- package/build/components/icon/scss/index.scss +1 -1
- package/build/components/image/scss/index.scss +1 -1
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/components/inline-edit/scss/index.scss +1 -1
- package/build/components/input/scss/index.scss +1 -1
- package/build/components/link/scss/index.scss +1 -1
- package/build/components/loading/scss/index.scss +1 -1
- package/build/components/marquee/scss/index.scss +1 -1
- package/build/components/metric/scss/index.scss +1 -1
- package/build/components/nav/index.d.ts +1 -1
- package/build/components/nav/scss/index.scss +1 -1
- package/build/components/nav/tree.d.ts +3 -1
- package/build/components/nav/tree.js +30 -60
- package/build/components/notification/scss/index.scss +1 -1
- package/build/components/overlay/scss/index.scss +1 -1
- package/build/components/page/scss/index.scss +1 -1
- package/build/components/pagination/arrows.d.ts +15 -0
- package/build/components/pagination/arrows.js +65 -0
- package/build/components/pagination/cards.d.ts +23 -0
- package/build/components/pagination/cards.js +66 -0
- package/build/components/pagination/index.d.ts +5 -0
- package/build/components/pagination/index.js +3 -1
- package/build/components/pagination/scss/index.scss +1 -1
- package/build/components/progress/scss/index.scss +1 -1
- package/build/components/pull-to-refresh/scss/index.scss +1 -1
- package/build/components/range/index.js +1 -1
- package/build/components/range/scss/index.scss +1 -1
- package/build/components/relative-time/scss/index.scss +1 -1
- package/build/components/root/scss/index.scss +1 -1
- package/build/components/section/scss/index.scss +2 -0
- package/build/components/select/index.d.ts +1 -0
- package/build/components/select/index.js +16 -11
- package/build/components/select/scss/index.scss +1 -1
- package/build/components/shortcut-recorder/scss/index.scss +1 -1
- package/build/components/sortable/scss/index.scss +1 -1
- package/build/components/sticky-header/index.js +3 -3
- package/build/components/sticky-header/scss/index.scss +1 -1
- package/build/components/story/scss/index.scss +1 -1
- package/build/components/surface-field/scss/index.scss +1 -1
- package/build/components/tasklist/scss/index.scss +1 -1
- package/build/components/text/scss/index.scss +1 -1
- package/build/components/textarea/scss/index.scss +1 -1
- package/build/{css-utilities → components}/theme/index.d.ts +1 -1
- package/build/{css-utilities → components}/theme/index.js +15 -5
- package/build/components/theme/scss/index.scss +2 -0
- package/build/components/theme-picker/index.d.ts +52 -0
- package/build/components/theme-picker/index.js +167 -0
- package/build/components/theme-picker/scss/index.scss +2 -0
- package/build/components/toast/index.js +3 -5
- package/build/components/toast/scss/index.scss +1 -1
- package/build/components/tooltip/menu.js +3 -1
- package/build/components/tooltip/scss/index.scss +1 -1
- package/build/components/typewriter/scss/index.scss +1 -1
- package/build/components/uptime/scss/index.scss +1 -1
- package/build/components/usage-meter/scss/index.scss +1 -1
- package/build/{css-utilities → modifiers}/glass/index.d.ts +2 -2
- package/build/modifiers/glass/index.js +28 -0
- package/build/modifiers/glass/scss/index.scss +2 -0
- package/build/{css-utilities → modifiers}/index.d.ts +0 -1
- package/build/{css-utilities → modifiers}/index.js +0 -1
- package/build/modifiers/scrollbar/index.d.ts +72 -0
- package/build/{css-utilities → modifiers}/scrollbar/index.js +52 -19
- package/build/modifiers/scrollbar/scss/index.scss +2 -0
- package/build/normalize/scss/index.scss +1 -2
- package/layer.scss +1 -1
- package/package.json +11 -18
- package/scripts/code-editor-markdown.test.mjs +45 -14
- package/scripts/code-viewer.test.mjs +69 -0
- package/scripts/workspace-keybindings.test.mjs +273 -0
- package/scripts/workspace-session.test.mjs +349 -0
- package/scripts/workspace-status.test.mjs +229 -0
- package/scripts/workspace-tabs.test.mjs +142 -0
- package/src/components/accordion/group.ts +39 -0
- package/src/components/accordion/index.ts +32 -6
- package/src/components/accordion/scss/index.scss +12 -21
- package/src/components/accordion/scss/variables.scss +18 -3
- package/src/components/announcement/scss/index.scss +4 -4
- package/src/components/announcement/scss/variables.scss +6 -6
- package/src/components/banner/scss/index.scss +1 -1
- package/src/components/breadcrumb/scss/index.scss +35 -50
- package/src/components/breadcrumb/scss/variables.scss +23 -31
- package/src/components/button/scss/_fan.scss +39 -43
- package/src/components/button/scss/_morph.scss +66 -78
- package/src/components/button/scss/_sidebar.scss +41 -30
- package/src/components/button/scss/_split.scss +9 -9
- package/src/components/button/scss/index.scss +23 -19
- package/src/components/button/scss/variables.scss +94 -90
- package/src/components/button/sidebar.ts +36 -24
- package/src/components/capslock/index.ts +2 -2
- package/src/components/capslock/scss/index.scss +11 -6
- package/src/components/capslock/scss/variables.scss +3 -5
- package/src/components/card/scss/_expand.scss +58 -64
- package/src/components/card/scss/index.scss +40 -21
- package/src/components/card/scss/variables.scss +40 -31
- package/src/components/cc/scss/index.scss +68 -68
- package/src/components/cc/scss/variables.scss +13 -14
- package/src/components/chat-minimap/scss/index.scss +24 -16
- package/src/components/chat-minimap/scss/variables.scss +37 -37
- package/src/components/checkbox/scss/index.scss +54 -52
- package/src/components/checkbox/scss/variables.scss +37 -39
- package/src/components/color-picker/index.ts +157 -120
- package/src/components/color-picker/scss/index.scss +159 -96
- package/src/components/color-picker/scss/variables.scss +33 -15
- package/src/components/command/index.ts +3 -2
- package/src/components/command/scss/index.scss +10 -14
- package/src/components/command/scss/variables.scss +12 -35
- package/src/components/copy/scss/index.scss +6 -6
- package/src/components/copy/scss/variables.scss +12 -15
- package/src/components/counter/scss/index.scss +14 -14
- package/src/components/counter/scss/variables.scss +1 -1
- package/src/components/datalist/index.ts +3 -3
- package/src/components/datalist/scss/index.scss +7 -6
- package/src/components/datalist/scss/variables.scss +7 -3
- package/src/components/dock/scss/index.scss +10 -15
- package/src/components/dock/scss/variables.scss +29 -25
- package/src/components/editor/code/index.ts +0 -1
- package/src/components/editor/code/minimap.ts +13 -5
- package/src/components/editor/code/scss/_editor.scss +83 -81
- package/src/components/editor/code/scss/_features.scss +106 -97
- package/src/components/editor/code/scss/_services.scss +27 -25
- package/src/components/editor/code/scss/index.scss +0 -1
- package/src/components/editor/code/scss/variables.scss +30 -26
- package/src/components/editor/code/view.ts +14 -5
- package/src/components/editor/diffs/index.ts +0 -1
- package/src/components/editor/diffs/merge.ts +2 -1
- package/src/components/editor/diffs/scss/_diffs.scss +67 -57
- package/src/components/editor/diffs/scss/_merge.scss +17 -14
- package/src/components/editor/diffs/scss/index.scss +0 -1
- package/src/components/editor/diffs/scss/variables.scss +25 -18
- package/src/components/editor/diffs/view.ts +2 -1
- package/src/components/editor/index.ts +7 -1
- package/src/components/editor/markdown/editing.ts +38 -3
- package/src/components/editor/markdown/erase.ts +124 -0
- package/src/components/editor/markdown/index.ts +0 -1
- package/src/components/editor/markdown/layout.ts +3 -12
- package/src/components/editor/markdown/render.ts +65 -37
- package/src/components/editor/markdown/scss/index.scss +92 -124
- package/src/components/editor/markdown/scss/variables.scss +39 -19
- package/src/components/editor/markdown/view.ts +737 -786
- package/src/components/editor/tree/scss/index.scss +121 -110
- package/src/components/editor/tree/scss/variables.scss +48 -54
- package/src/components/editor/viewer/index.ts +321 -0
- package/src/components/editor/viewer/model.ts +130 -0
- package/src/components/editor/viewer/scss/_viewer.scss +302 -0
- package/src/components/editor/viewer/scss/index.scss +2 -0
- package/src/components/editor/viewer/scss/variables.scss +69 -0
- package/src/components/editor/workspace/index.ts +159 -31
- package/src/components/editor/workspace/keybindings.ts +447 -0
- package/src/components/editor/workspace/model.ts +233 -3
- package/src/components/editor/workspace/navigate.ts +194 -0
- package/src/components/editor/workspace/scss/index.scss +72 -59
- package/src/components/editor/workspace/scss/keybindings.scss +190 -0
- package/src/components/editor/workspace/scss/status.scss +122 -0
- package/src/components/editor/workspace/scss/tabs.scss +56 -0
- package/src/components/editor/workspace/session.ts +551 -0
- package/src/components/editor/workspace/shortcuts.ts +255 -0
- package/src/components/editor/workspace/status.ts +259 -0
- package/src/components/editor/workspace/statusbar.ts +255 -0
- package/src/components/editor/workspace/strip.ts +273 -0
- package/src/components/editor/workspace/tabs.ts +106 -0
- package/src/components/error/index.ts +1 -1
- package/src/components/error/scss/index.scss +19 -19
- package/src/components/error/scss/variables.scss +2 -2
- package/src/components/filter/index.ts +7 -2
- package/src/components/filter/scss/index.scss +1 -1
- package/src/components/filter/scss/variables.scss +11 -10
- package/src/components/frame/scss/index.scss +12 -12
- package/src/components/frame/scss/variables.scss +8 -8
- package/src/components/heatmap/index.ts +3 -3
- package/src/components/heatmap/scss/index.scss +28 -26
- package/src/components/heatmap/scss/variables.scss +18 -17
- package/src/components/highlight/scss/index.scss +17 -13
- package/src/components/highlight/scss/variables.scss +8 -10
- package/src/components/icon/scss/index.scss +10 -0
- package/src/components/icon/scss/variables.scss +5 -0
- package/src/components/image/scss/index.scss +9 -9
- package/src/components/image/scss/variables.scss +7 -2
- package/src/components/index.ts +2 -0
- package/src/components/inline-edit/scss/index.scss +99 -104
- package/src/components/inline-edit/scss/variables.scss +40 -39
- package/src/components/input/scss/_field.scss +6 -20
- package/src/components/input/scss/_scrub.scss +10 -8
- package/src/components/input/scss/_tag.scss +35 -37
- package/src/components/input/scss/variables.scss +100 -99
- package/src/components/link/scss/index.scss +4 -1
- package/src/components/loading/scss/index.scss +1 -1
- package/src/components/loading/scss/variables.scss +1 -1
- package/src/components/marquee/scss/index.scss +9 -5
- package/src/components/marquee/scss/variables.scss +3 -1
- package/src/components/metric/scss/_flash.scss +3 -1
- package/src/components/metric/scss/index.scss +8 -6
- package/src/components/metric/scss/variables.scss +26 -20
- package/src/components/nav/index.ts +1 -1
- package/src/components/nav/scss/index.scss +12 -40
- package/src/components/nav/scss/variables.scss +30 -11
- package/src/components/nav/tree.ts +19 -62
- package/src/components/notification/scss/index.scss +7 -7
- package/src/components/notification/scss/variables.scss +7 -9
- package/src/components/overlay/scss/index.scss +181 -170
- package/src/components/overlay/scss/variables.scss +26 -57
- package/src/components/page/scss/index.scss +12 -11
- package/src/components/page/scss/variables.scss +5 -0
- package/src/components/pagination/arrows.ts +58 -0
- package/src/components/pagination/cards.ts +57 -0
- package/src/components/pagination/index.ts +4 -1
- package/src/components/pagination/scss/_arrows.scss +69 -0
- package/src/components/pagination/scss/_cards.scss +121 -0
- package/src/components/pagination/scss/_dots.scss +2 -5
- package/src/components/pagination/scss/index.scss +8 -6
- package/src/components/pagination/scss/variables.scss +87 -37
- package/src/components/progress/scss/_text.scss +21 -18
- package/src/components/progress/scss/index.scss +1 -1
- package/src/components/progress/scss/variables.scss +12 -12
- package/src/components/pull-to-refresh/scss/index.scss +2 -1
- package/src/components/pull-to-refresh/scss/variables.scss +11 -6
- package/src/components/range/index.ts +1 -1
- package/src/components/range/scss/_filter.scss +62 -51
- package/src/components/range/scss/_slider.scss +78 -75
- package/src/components/range/scss/_vertical.scss +6 -6
- package/src/components/range/scss/index.scss +3 -2
- package/src/components/range/scss/variables.scss +26 -23
- package/src/components/relative-time/scss/index.scss +27 -27
- package/src/components/relative-time/scss/variables.scss +10 -12
- package/src/components/root/scss/index.scss +71 -43
- package/src/components/root/scss/variables.scss +35 -31
- package/src/components/section/scss/index.scss +31 -0
- package/src/components/section/scss/variables.scss +21 -0
- package/src/components/select/index.ts +11 -6
- package/src/components/select/scss/index.scss +21 -32
- package/src/components/select/scss/variables.scss +25 -18
- package/src/components/shortcut-recorder/scss/index.scss +13 -12
- package/src/components/shortcut-recorder/scss/variables.scss +12 -13
- package/src/components/sortable/scss/index.scss +47 -44
- package/src/components/sortable/scss/variables.scss +4 -5
- package/src/components/sticky-header/index.ts +4 -4
- package/src/components/sticky-header/scss/index.scss +14 -13
- package/src/components/sticky-header/scss/variables.scss +9 -9
- package/src/components/story/scss/index.scss +26 -30
- package/src/components/story/scss/variables.scss +16 -9
- package/src/components/surface-field/scss/index.scss +45 -40
- package/src/components/surface-field/scss/variables.scss +5 -6
- package/src/components/tasklist/scss/index.scss +19 -19
- package/src/components/tasklist/scss/variables.scss +26 -29
- package/src/components/text/scss/index.scss +2 -1
- package/src/components/textarea/scss/variables.scss +1 -1
- package/src/{css-utilities → components}/theme/index.ts +17 -3
- package/src/components/theme/scss/index.scss +1 -0
- package/src/components/theme/scss/variables.scss +78 -0
- package/src/components/theme-picker/index.ts +231 -0
- package/src/components/theme-picker/scss/index.scss +264 -0
- package/src/components/toast/index.ts +28 -30
- package/src/components/toast/scss/index.scss +87 -87
- package/src/components/toast/scss/variables.scss +39 -39
- package/src/components/tooltip/menu.ts +4 -1
- package/src/components/tooltip/scss/_east.scss +10 -10
- package/src/components/tooltip/scss/_menu.scss +284 -269
- package/src/components/tooltip/scss/_north.scss +10 -10
- package/src/components/tooltip/scss/_shared.scss +7 -7
- package/src/components/tooltip/scss/_south.scss +10 -10
- package/src/components/tooltip/scss/_west.scss +10 -10
- package/src/components/tooltip/scss/index.scss +21 -20
- package/src/components/tooltip/scss/variables.scss +104 -96
- package/src/components/typewriter/scss/_retype.scss +12 -11
- package/src/components/typewriter/scss/_rotate.scss +2 -1
- package/src/components/typewriter/scss/variables.scss +41 -39
- package/src/components/uptime/scss/index.scss +15 -15
- package/src/components/uptime/scss/variables.scss +8 -8
- package/src/components/usage-meter/scss/index.scss +3 -1
- package/src/components/usage-meter/scss/variables.scss +5 -5
- package/src/css-utilities/absolute.scss +64 -0
- package/src/css-utilities/background.scss +43 -0
- package/src/css-utilities/border.scss +45 -0
- package/src/css-utilities/box-shadow.scss +29 -0
- package/src/css-utilities/color.scss +41 -0
- package/src/css-utilities/flex.scss +64 -0
- package/src/css-utilities/font/geist/{scss/index.scss → index.scss} +12 -4
- package/src/css-utilities/font/montserrat/Montserrat-Italic-Variable.woff2 +0 -0
- package/src/css-utilities/font/montserrat/Montserrat-Variable.woff2 +0 -0
- package/src/css-utilities/font/montserrat/OFL.txt +93 -0
- package/src/css-utilities/font/montserrat/index.scss +38 -0
- package/src/{shared/scss → css-utilities}/icon.scss +1 -1
- package/src/css-utilities/{inline/scss/index.scss → inline.scss} +1 -1
- package/src/css-utilities/{skeleton/scss/index.scss → skeleton.scss} +11 -11
- package/src/css-utilities/surface.scss +266 -0
- package/src/css-utilities/text.scss +191 -0
- package/src/modifiers/glass/index.ts +44 -0
- package/src/{css-utilities → modifiers}/glass/scss/index.scss +6 -6
- package/src/{css-utilities → modifiers}/glass/scss/variables.scss +1 -1
- package/src/{css-utilities → modifiers}/index.ts +0 -1
- package/src/{css-utilities → modifiers}/scrollbar/index.ts +92 -17
- package/src/{css-utilities → modifiers}/scrollbar/scss/index.scss +178 -177
- package/src/{css-utilities → modifiers}/scrollbar/scss/variables.scss +28 -21
- package/src/normalize/scss/index.scss +4 -2
- package/src/shared/scss/color-weights.scss +19 -0
- package/src/shared/scss/index.scss +1 -12
- package/src/tokens/scss/blur.scss +5 -0
- package/src/tokens/scss/color.scss +74 -50
- package/src/tokens/scss/index.scss +1 -2
- package/src/tokens/scss/size.scss +0 -2
- package/src/tokens/scss/state.scss +3 -2
- package/src/tokens/scss/transition.scss +19 -2
- package/storage/svg/monitor.svg +1 -0
- package/storage/svg/moon.svg +1 -0
- package/storage/svg/pin.svg +1 -0
- package/storage/svg/sun.svg +1 -0
- package/vite.config.ts +33 -8
- package/build/css-utilities/background/scss/index.scss +0 -2
- package/build/css-utilities/border/scss/index.scss +0 -2
- package/build/css-utilities/color/scss/index.scss +0 -2
- package/build/css-utilities/flex/scss/index.scss +0 -2
- package/build/css-utilities/font/geist/index.d.ts +0 -1
- package/build/css-utilities/font/geist/index.js +0 -1
- package/build/css-utilities/font/geist/scss/index.scss +0 -2
- package/build/css-utilities/font/montserrat/index.d.ts +0 -1
- package/build/css-utilities/font/montserrat/index.js +0 -1
- package/build/css-utilities/font/montserrat/scss/Montserrat-Bold.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Italic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Medium.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Regular.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- package/build/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/build/css-utilities/font/montserrat/scss/index.scss +0 -2
- package/build/css-utilities/glass/index.js +0 -26
- package/build/css-utilities/glass/scss/index.scss +0 -2
- package/build/css-utilities/index.scss +0 -2
- package/build/css-utilities/inline/scss/index.scss +0 -2
- package/build/css-utilities/scrollbar/index.d.ts +0 -42
- package/build/css-utilities/scrollbar/scss/index.scss +0 -2
- package/build/css-utilities/skeleton/scss/index.scss +0 -2
- package/build/css-utilities/text/scss/index.scss +0 -2
- package/build/themes/dark/index.d.ts +0 -3
- package/build/themes/dark/index.js +0 -3
- package/build/themes/dark/input.d.ts +0 -3
- package/build/themes/dark/input.js +0 -12
- package/build/themes/dark/select.d.ts +0 -3
- package/build/themes/dark/select.js +0 -23
- package/build/themes/dark/textarea.d.ts +0 -2186
- package/build/themes/dark/textarea.js +0 -11
- package/src/css-utilities/background/scss/index.scss +0 -1
- package/src/css-utilities/background/scss/variables.scss +0 -18
- package/src/css-utilities/border/scss/index.scss +0 -1
- package/src/css-utilities/border/scss/variables.scss +0 -23
- package/src/css-utilities/color/scss/index.scss +0 -1
- package/src/css-utilities/color/scss/variables.scss +0 -17
- package/src/css-utilities/flex/scss/index.scss +0 -57
- package/src/css-utilities/flex/scss/variables.scss +0 -16
- package/src/css-utilities/font/geist/index.ts +0 -1
- package/src/css-utilities/font/montserrat/index.ts +0 -1
- package/src/css-utilities/font/montserrat/scss/Montserrat-Bold.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Italic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Medium.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Regular.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- package/src/css-utilities/font/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/src/css-utilities/font/montserrat/scss/index.scss +0 -94
- package/src/css-utilities/glass/index.ts +0 -42
- package/src/css-utilities/index.scss +0 -13
- package/src/css-utilities/skeleton/scss/variables.scss +0 -3
- package/src/css-utilities/text/scss/index.scss +0 -152
- package/src/css-utilities/text/scss/variables.scss +0 -22
- package/src/shared/scss/absolute.scss +0 -28
- package/src/shared/scss/background.scss +0 -21
- package/src/shared/scss/border.scss +0 -21
- package/src/shared/scss/color.scss +0 -21
- package/src/shared/scss/position.scss +0 -55
- package/src/shared/scss/text.scss +0 -31
- package/src/themes/dark/index.ts +0 -3
- package/src/themes/dark/input.ts +0 -16
- package/src/themes/dark/select.ts +0 -28
- package/src/themes/dark/textarea.ts +0 -13
- package/src/tokens/scss/box-shadow.scss +0 -23
- package/src/tokens/scss/font-family.scss +0 -5
- package/storage/code.md +0 -180
- package/storage/editor-features.md +0 -227
- package/build/css-utilities/font/geist/{scss/Geist-Italic-Variable.woff2 → Geist-Italic-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/Geist-Variable.woff2 → Geist-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/GeistMono-Italic-Variable.woff2 → GeistMono-Italic-Variable.woff2} +0 -0
- package/build/css-utilities/font/geist/{scss/GeistMono-Variable.woff2 → GeistMono-Variable.woff2} +0 -0
- package/src/{shared/scss → css-utilities}/anchor.scss +6 -6
- package/src/{shared/scss → css-utilities}/drag.scss +0 -0
- package/src/css-utilities/font/geist/{scss/Geist-Italic-Variable.woff2 → Geist-Italic-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/Geist-Variable.woff2 → Geist-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/GeistMono-Italic-Variable.woff2 → GeistMono-Italic-Variable.woff2} +0 -0
- package/src/css-utilities/font/geist/{scss/GeistMono-Variable.woff2 → GeistMono-Variable.woff2} +0 -0
- package/src/{shared/scss → css-utilities}/hidden.scss +11 -11
- /package/src/{shared/scss → css-utilities}/layer.scss +0 -0
- /package/src/{shared/scss → css-utilities}/reset.scss +0 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as reactivity_u0 from '@esportsplus/reactivity';
|
|
2
2
|
import { flush } from '@esportsplus/reactivity';
|
|
3
3
|
import * as template_u1 from '@esportsplus/template';
|
|
4
|
-
import
|
|
4
|
+
import scrollbar from '../../../modifiers/scrollbar/index.js';
|
|
5
5
|
import { clamp } from '../../../shared/clamp.js';
|
|
6
6
|
import { mac } from '../../../shared/platform.js';
|
|
7
7
|
import { observer, observeSize } from '../../../shared/resize.js';
|
|
8
8
|
import { copied, read, write } from '../code/clipboard.js';
|
|
9
9
|
import { addNextOccurrence, deleteCharacter, indent, insertText, lineCommand, toggleComment } from '../code/commands.js';
|
|
10
10
|
import { composition } from '../code/composition.js';
|
|
11
|
-
import { write as writeField } from '../code/field.js';
|
|
12
11
|
import { find } from '../code/find.js';
|
|
13
12
|
import { mapFolds, outerFolds } from '../code/folding.js';
|
|
14
13
|
import { goto } from '../code/goto.js';
|
|
@@ -17,139 +16,93 @@ import { EditorLayout } from '../code/layout.js';
|
|
|
17
16
|
import { minimap } from '../code/minimap.js';
|
|
18
17
|
import { move } from '../code/navigation.js';
|
|
19
18
|
import { pointer } from '../code/pointer.js';
|
|
20
|
-
import {
|
|
19
|
+
import { NativeText } from '../code/projection.js';
|
|
21
20
|
import { syntaxCache } from '../code/syntax.js';
|
|
22
21
|
import { markdownCommand } from './editing.js';
|
|
22
|
+
import { reach, widen } from './erase.js';
|
|
23
23
|
import { parseInline } from './inline.js';
|
|
24
|
-
import { arrange, cache,
|
|
25
|
-
import { blockAt, contentEnd, markdownBackspace, markdownReferences, parseMarkdown, reparse, toggleTask } from './model.js';
|
|
24
|
+
import { arrange, cache, MarkdownLayout, unitStart } from './layout.js';
|
|
25
|
+
import { blockAt, contentEnd, markdownBackspace, markdownReferences, parseMarkdown, quotePrefix, reparse, toggleTask } from './model.js';
|
|
26
26
|
import { renderer } from './render.js';
|
|
27
27
|
import { foldable, foldAt, markdownFolds } from './structure.js';
|
|
28
|
-
import
|
|
29
|
-
const
|
|
30
|
-
const
|
|
28
|
+
import tooltip from '../../tooltip/index.js';
|
|
29
|
+
const template_1ayo7z94 = template_u1.template(`<div class='markdown-editor'><!--$--><!--$--><div class='markdown-editor-body'><div class='markdown-editor-surface'><div aria-hidden='true' class='markdown-editor-overlay'></div><div></div></div><!--$--><span aria-hidden='true' class='markdown-editor-ruler'>0000000000000000000000000000000000000000000000000000000000000000</span></div><span class='markdown-editor-help'>Press Escape then Tab to move focus out of the editor.`);
|
|
30
|
+
const template_1ayo7z9g = template_u1.template(`<div>`);
|
|
31
|
+
const template_1ayo7z9j = template_u1.template(`<div aria-hidden='true' class='markdown-editor-spacer' contenteditable='false'>`);
|
|
31
32
|
class ReactiveObject_1ayo7z90 extends reactivity_u0.ReactiveObject {
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#editing = this[reactivity_u0.SIGNAL](false);
|
|
35
|
-
#foldable = this[reactivity_u0.SIGNAL](false);
|
|
36
|
-
#height = this[reactivity_u0.SIGNAL](20);
|
|
37
|
-
#input = this[reactivity_u0.SIGNAL]('');
|
|
33
|
+
#empty;
|
|
34
|
+
#fold = this[reactivity_u0.SIGNAL](false);
|
|
38
35
|
#label = this[reactivity_u0.SIGNAL]('Markdown editor');
|
|
36
|
+
#linking = this[reactivity_u0.SIGNAL](false);
|
|
39
37
|
#minimap = this[reactivity_u0.SIGNAL](false);
|
|
40
|
-
#name = this[reactivity_u0.SIGNAL]('');
|
|
41
|
-
#next = this[reactivity_u0.SIGNAL](0);
|
|
42
38
|
#placeholder = this[reactivity_u0.SIGNAL]('');
|
|
43
39
|
#readonly = this[reactivity_u0.SIGNAL](false);
|
|
44
40
|
#spellcheck = this[reactivity_u0.SIGNAL](true);
|
|
45
|
-
#style = this[reactivity_u0.SIGNAL]('');
|
|
46
41
|
#tabSize = this[reactivity_u0.SIGNAL](4);
|
|
47
|
-
#top = this[reactivity_u0.SIGNAL](0);
|
|
48
42
|
#wrap = this[reactivity_u0.SIGNAL](true);
|
|
49
|
-
constructor() {
|
|
43
|
+
constructor(_p0) {
|
|
50
44
|
super(null);
|
|
45
|
+
this.#empty = this[reactivity_u0.SIGNAL](_p0);
|
|
51
46
|
}
|
|
52
|
-
get
|
|
53
|
-
return reactivity_u0.read(this.#
|
|
54
|
-
}
|
|
55
|
-
set between(_v0) {
|
|
56
|
-
reactivity_u0.write(this.#between, _v0);
|
|
57
|
-
}
|
|
58
|
-
get bottom() {
|
|
59
|
-
return reactivity_u0.read(this.#bottom);
|
|
60
|
-
}
|
|
61
|
-
set bottom(_v1) {
|
|
62
|
-
reactivity_u0.write(this.#bottom, _v1);
|
|
63
|
-
}
|
|
64
|
-
get editing() {
|
|
65
|
-
return reactivity_u0.read(this.#editing);
|
|
66
|
-
}
|
|
67
|
-
set editing(_v2) {
|
|
68
|
-
reactivity_u0.write(this.#editing, _v2);
|
|
69
|
-
}
|
|
70
|
-
get foldable() {
|
|
71
|
-
return reactivity_u0.read(this.#foldable);
|
|
72
|
-
}
|
|
73
|
-
set foldable(_v3) {
|
|
74
|
-
reactivity_u0.write(this.#foldable, _v3);
|
|
75
|
-
}
|
|
76
|
-
get height() {
|
|
77
|
-
return reactivity_u0.read(this.#height);
|
|
47
|
+
get empty() {
|
|
48
|
+
return reactivity_u0.read(this.#empty);
|
|
78
49
|
}
|
|
79
|
-
set
|
|
80
|
-
reactivity_u0.write(this.#
|
|
50
|
+
set empty(_v0) {
|
|
51
|
+
reactivity_u0.write(this.#empty, _v0);
|
|
81
52
|
}
|
|
82
|
-
get
|
|
83
|
-
return reactivity_u0.read(this.#
|
|
53
|
+
get fold() {
|
|
54
|
+
return reactivity_u0.read(this.#fold);
|
|
84
55
|
}
|
|
85
|
-
set
|
|
86
|
-
reactivity_u0.write(this.#
|
|
56
|
+
set fold(_v1) {
|
|
57
|
+
reactivity_u0.write(this.#fold, _v1);
|
|
87
58
|
}
|
|
88
59
|
get label() {
|
|
89
60
|
return reactivity_u0.read(this.#label);
|
|
90
61
|
}
|
|
91
|
-
set label(
|
|
92
|
-
reactivity_u0.write(this.#label,
|
|
93
|
-
}
|
|
94
|
-
get minimap() {
|
|
95
|
-
return reactivity_u0.read(this.#minimap);
|
|
96
|
-
}
|
|
97
|
-
set minimap(_v7) {
|
|
98
|
-
reactivity_u0.write(this.#minimap, _v7);
|
|
62
|
+
set label(_v2) {
|
|
63
|
+
reactivity_u0.write(this.#label, _v2);
|
|
99
64
|
}
|
|
100
|
-
get
|
|
101
|
-
return reactivity_u0.read(this.#
|
|
65
|
+
get linking() {
|
|
66
|
+
return reactivity_u0.read(this.#linking);
|
|
102
67
|
}
|
|
103
|
-
set
|
|
104
|
-
reactivity_u0.write(this.#
|
|
68
|
+
set linking(_v3) {
|
|
69
|
+
reactivity_u0.write(this.#linking, _v3);
|
|
105
70
|
}
|
|
106
|
-
get
|
|
107
|
-
return reactivity_u0.read(this.#
|
|
71
|
+
get minimap() {
|
|
72
|
+
return reactivity_u0.read(this.#minimap);
|
|
108
73
|
}
|
|
109
|
-
set
|
|
110
|
-
reactivity_u0.write(this.#
|
|
74
|
+
set minimap(_v4) {
|
|
75
|
+
reactivity_u0.write(this.#minimap, _v4);
|
|
111
76
|
}
|
|
112
77
|
get placeholder() {
|
|
113
78
|
return reactivity_u0.read(this.#placeholder);
|
|
114
79
|
}
|
|
115
|
-
set placeholder(
|
|
116
|
-
reactivity_u0.write(this.#placeholder,
|
|
80
|
+
set placeholder(_v5) {
|
|
81
|
+
reactivity_u0.write(this.#placeholder, _v5);
|
|
117
82
|
}
|
|
118
83
|
get readonly() {
|
|
119
84
|
return reactivity_u0.read(this.#readonly);
|
|
120
85
|
}
|
|
121
|
-
set readonly(
|
|
122
|
-
reactivity_u0.write(this.#readonly,
|
|
86
|
+
set readonly(_v6) {
|
|
87
|
+
reactivity_u0.write(this.#readonly, _v6);
|
|
123
88
|
}
|
|
124
89
|
get spellcheck() {
|
|
125
90
|
return reactivity_u0.read(this.#spellcheck);
|
|
126
91
|
}
|
|
127
|
-
set spellcheck(
|
|
128
|
-
reactivity_u0.write(this.#spellcheck,
|
|
129
|
-
}
|
|
130
|
-
get style() {
|
|
131
|
-
return reactivity_u0.read(this.#style);
|
|
132
|
-
}
|
|
133
|
-
set style(_v13) {
|
|
134
|
-
reactivity_u0.write(this.#style, _v13);
|
|
92
|
+
set spellcheck(_v7) {
|
|
93
|
+
reactivity_u0.write(this.#spellcheck, _v7);
|
|
135
94
|
}
|
|
136
95
|
get tabSize() {
|
|
137
96
|
return reactivity_u0.read(this.#tabSize);
|
|
138
97
|
}
|
|
139
|
-
set tabSize(
|
|
140
|
-
reactivity_u0.write(this.#tabSize,
|
|
141
|
-
}
|
|
142
|
-
get top() {
|
|
143
|
-
return reactivity_u0.read(this.#top);
|
|
144
|
-
}
|
|
145
|
-
set top(_v15) {
|
|
146
|
-
reactivity_u0.write(this.#top, _v15);
|
|
98
|
+
set tabSize(_v8) {
|
|
99
|
+
reactivity_u0.write(this.#tabSize, _v8);
|
|
147
100
|
}
|
|
148
101
|
get wrap() {
|
|
149
102
|
return reactivity_u0.read(this.#wrap);
|
|
150
103
|
}
|
|
151
|
-
set wrap(
|
|
152
|
-
reactivity_u0.write(this.#wrap,
|
|
104
|
+
set wrap(_v9) {
|
|
105
|
+
reactivity_u0.write(this.#wrap, _v9);
|
|
153
106
|
}
|
|
154
107
|
}
|
|
155
108
|
class ReactiveObject_1ayo7z91 extends reactivity_u0.ReactiveObject {
|
|
@@ -171,10 +124,28 @@ class ReactiveObject_1ayo7z91 extends reactivity_u0.ReactiveObject {
|
|
|
171
124
|
reactivity_u0.write(this.#style, _v1);
|
|
172
125
|
}
|
|
173
126
|
}
|
|
127
|
+
class ReactiveObject_1ayo7z92 extends reactivity_u0.ReactiveObject {
|
|
128
|
+
#height = this[reactivity_u0.SIGNAL](0);
|
|
129
|
+
constructor() {
|
|
130
|
+
super(null);
|
|
131
|
+
}
|
|
132
|
+
get height() {
|
|
133
|
+
return reactivity_u0.read(this.#height);
|
|
134
|
+
}
|
|
135
|
+
set height(_v0) {
|
|
136
|
+
reactivity_u0.write(this.#height, _v0);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
174
139
|
const DECORATIONS = 1000;
|
|
140
|
+
const ITEM_TASK = /^[ \t]*(?:[-+*]|\d+[.)])[ \t]+\[ ?\]$/;
|
|
141
|
+
const JOINABLE = new Set(['heading', 'list', 'paragraph', 'quote']);
|
|
142
|
+
const LINE_BREAK = /[\r\n]/;
|
|
143
|
+
const LINK_DELAY = 700;
|
|
144
|
+
const LITERAL = new Set(['code', 'fence', 'frontmatter', 'html']);
|
|
175
145
|
const NAVIGATION = /^(ArrowDown|ArrowLeft|ArrowRight|ArrowUp|End|Home|PageDown|PageUp)$/;
|
|
176
146
|
const NONE = [];
|
|
177
147
|
const NO_TOKENS = [];
|
|
148
|
+
const TASK = /^\[ ?\]$/;
|
|
178
149
|
const TOKEN_COLORS = ['comment', 'keyword', 'operator', 'property', 'string', 'type', 'variable'];
|
|
179
150
|
const VERTICAL = /^(ArrowDown|ArrowUp|PageDown|PageUp)$/;
|
|
180
151
|
let uid = 0;
|
|
@@ -225,11 +196,8 @@ function assign(list, next) {
|
|
|
225
196
|
function pixels(value) {
|
|
226
197
|
return parseFloat(value) || 0;
|
|
227
198
|
}
|
|
228
|
-
function prevent(e) {
|
|
229
|
-
e.preventDefault();
|
|
230
|
-
}
|
|
231
199
|
const view = (model, callbacks, receive) => {
|
|
232
|
-
let
|
|
200
|
+
let apple = mac(), blocks = parseMarkdown(model), composed = '', composing = null, content, decorations = new reactivity_u0.ReactiveArray(), definitions = new Map(), disposed = false, drawn = 0, dropAt = null, elements = new Map(), escapeTab = false, folds = [], frame = 0, gaps = [], goals = [], help = `markdown-editor-help-${++uid}`, host, inlines = new WeakMap(), items = new reactivity_u0.ReactiveArray(), keys = keymap(apple), layout = new MarkdownLayout(), length = model.value.length, metrics = {
|
|
233
201
|
charWidth: 7.8,
|
|
234
202
|
clientHeight: 320,
|
|
235
203
|
fontSize: 13,
|
|
@@ -241,39 +209,31 @@ const view = (model, callbacks, receive) => {
|
|
|
241
209
|
scrollLeft: 0,
|
|
242
210
|
scrollTop: 0,
|
|
243
211
|
width: 600
|
|
244
|
-
}, options = { wrap: true }, palette = {}, parsed = model.revision, pendingValue,
|
|
212
|
+
}, options = { wrap: true }, palette = {}, parsed = model.revision, pendingValue, placed = null, rendered = [], resize = observer(resized), revealing = false, ruler, secondary = false, shown = new WeakMap(), state = reactivity_u0.reactive({
|
|
245
213
|
...model.state,
|
|
246
214
|
selection: { ...model.selection },
|
|
247
215
|
selections: model.selections.map((range) => ({ ...range }))
|
|
248
|
-
}), surface,
|
|
249
|
-
let activeUnit = {
|
|
250
|
-
active: true,
|
|
251
|
-
block: blocks[0],
|
|
252
|
-
continuation: false,
|
|
253
|
-
continues: false,
|
|
254
|
-
estimate: 0,
|
|
255
|
-
estimated: -1,
|
|
256
|
-
height: 0,
|
|
257
|
-
measured: -1,
|
|
258
|
-
raw: false
|
|
259
|
-
};
|
|
216
|
+
}), surface, ui = new ReactiveObject_1ayo7z90(!model.value), units = cache(), unitsDirty = true, unplaced = false, unsubscribe, visited = new WeakMap(), whole = null;
|
|
260
217
|
let draw = renderer({
|
|
261
218
|
fold: (unit) => {
|
|
262
219
|
controller.fold(model.lineAt(unit.block.from) + 1);
|
|
263
220
|
},
|
|
264
221
|
foldable: opens,
|
|
265
222
|
inline: inlineOf,
|
|
266
|
-
press,
|
|
267
223
|
readonly: () => ui.readonly,
|
|
268
224
|
shown: (element, unit) => {
|
|
269
225
|
if (unit) {
|
|
226
|
+
elements.set(unit, element);
|
|
270
227
|
shown.set(element, unit);
|
|
271
228
|
resize?.observe(element);
|
|
229
|
+
return;
|
|
272
230
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
231
|
+
let previous = shown.get(element);
|
|
232
|
+
if (previous && elements.get(previous) === element) {
|
|
233
|
+
elements.delete(previous);
|
|
276
234
|
}
|
|
235
|
+
shown.delete(element);
|
|
236
|
+
resize?.unobserve(element);
|
|
277
237
|
},
|
|
278
238
|
task: (block) => {
|
|
279
239
|
if (!disposed && !options.readonly && !ime.busy() && block.task) {
|
|
@@ -288,18 +248,21 @@ const view = (model, callbacks, receive) => {
|
|
|
288
248
|
let ime = composition({
|
|
289
249
|
begin: () => {
|
|
290
250
|
capture();
|
|
291
|
-
|
|
292
|
-
|
|
251
|
+
composed = '';
|
|
252
|
+
composing = { ...model.selection };
|
|
293
253
|
model.breakHistory();
|
|
294
254
|
},
|
|
295
255
|
commit: (conflict) => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
256
|
+
let range = composing;
|
|
257
|
+
composing = null;
|
|
258
|
+
if (range && !conflict && composed && !options.readonly) {
|
|
259
|
+
model.replace(range.start, range.end, composed, {
|
|
260
|
+
selection: { start: range.start + composed.length },
|
|
261
|
+
source: 'composition'
|
|
262
|
+
});
|
|
302
263
|
}
|
|
264
|
+
composed = '';
|
|
265
|
+
invalidate(range?.start ?? model.selection.start);
|
|
303
266
|
if (pendingValue !== undefined) {
|
|
304
267
|
let value = pendingValue;
|
|
305
268
|
pendingValue = undefined;
|
|
@@ -338,11 +301,7 @@ const view = (model, callbacks, receive) => {
|
|
|
338
301
|
go: (line, column) => controller.goToLine(line, column)
|
|
339
302
|
});
|
|
340
303
|
let map = minimap({
|
|
341
|
-
focus: () => {
|
|
342
|
-
if (editing) {
|
|
343
|
-
textarea?.focus({ preventScroll: true });
|
|
344
|
-
}
|
|
345
|
-
},
|
|
304
|
+
focus: () => content?.focus({ preventScroll: true }),
|
|
346
305
|
scroll: (top, relative) => {
|
|
347
306
|
scrollTo(relative ? metrics.scrollTop + top : top);
|
|
348
307
|
}
|
|
@@ -365,6 +324,7 @@ const view = (model, callbacks, receive) => {
|
|
|
365
324
|
update: schedule
|
|
366
325
|
});
|
|
367
326
|
let size = observeSize(() => measure());
|
|
327
|
+
let tip = tooltip.shared({ delay: { open: LINK_DELAY } });
|
|
368
328
|
let source = {
|
|
369
329
|
breaks: () => NONE,
|
|
370
330
|
get count() {
|
|
@@ -399,84 +359,25 @@ const view = (model, callbacks, receive) => {
|
|
|
399
359
|
return layout.top(at) + (Math.max(0, index - first) * layout.height(unit)) / (last - first + 1);
|
|
400
360
|
}
|
|
401
361
|
};
|
|
402
|
-
function accept(composed = false) {
|
|
403
|
-
if (disposed || !textarea || !active) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
if (options.readonly) {
|
|
407
|
-
reset();
|
|
408
|
-
resync();
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
let after = { end: textarea.selectionEnd, length: textarea.textLength, start: textarea.selectionStart }, base = active.from, direction = textarea.selectionDirection, native = before && !composed ? inputEdit(before, after, inputType, inputData) : null, ranges = beforeRanges.length ? beforeRanges : model.selections, value = textarea.value, edit;
|
|
412
|
-
if (native) {
|
|
413
|
-
edit = projection.toSourceEdit(model.value, native.from, native.to, native.insert);
|
|
414
|
-
}
|
|
415
|
-
else if (value === projection.value) {
|
|
416
|
-
reset();
|
|
417
|
-
capture();
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
let selection = beforeSelection
|
|
422
|
-
? { end: clamp(beforeSelection.end - base, 0, fieldSource.length), start: clamp(beforeSelection.start - base, 0, fieldSource.length) }
|
|
423
|
-
: undefined;
|
|
424
|
-
edit = projection.edit(model.value, value, selection, inputType);
|
|
425
|
-
}
|
|
426
|
-
if (edit.from === edit.to && !edit.insert) {
|
|
427
|
-
reset();
|
|
428
|
-
resync();
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
let group = !composed && /^(deleteContentBackward|deleteContentForward|insertText)$/.test(inputType) ? inputType : undefined, origin = composed ? 'composition' : 'input';
|
|
432
|
-
written = value;
|
|
433
|
-
if (ranges.length > 1) {
|
|
434
|
-
reset();
|
|
435
|
-
insertText(model, edit.insert, origin);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
let from = base + edit.from, caret = native
|
|
439
|
-
? { direction, end: from + edit.insert.length, start: from + edit.insert.length }
|
|
440
|
-
: caretAfter(edit, after, direction);
|
|
441
|
-
reset();
|
|
442
|
-
model.replace(from, base + edit.to, edit.insert, { group, selection: caret, source: origin });
|
|
443
|
-
}
|
|
444
|
-
function activate(focus) {
|
|
445
|
-
if (disposed) {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
editing = true;
|
|
449
|
-
ui.editing = true;
|
|
450
|
-
refresh();
|
|
451
|
-
schedule();
|
|
452
|
-
if (focus && textarea && host?.ownerDocument.activeElement !== textarea) {
|
|
453
|
-
flush();
|
|
454
|
-
textarea.focus({ preventScroll: true });
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
362
|
function adopt() {
|
|
458
363
|
let memo = visited.get(model), { selections, ...single } = model.state;
|
|
459
|
-
reset();
|
|
460
|
-
active = null;
|
|
461
|
-
activeIndex = -1;
|
|
462
364
|
blocks = parseMarkdown(model);
|
|
463
|
-
|
|
464
|
-
|
|
365
|
+
composed = '';
|
|
366
|
+
composing = null;
|
|
465
367
|
dropAt = null;
|
|
466
368
|
escapeTab = false;
|
|
467
|
-
fieldSource = '';
|
|
468
369
|
folds = memo?.revision === model.revision ? memo.folds : [];
|
|
469
|
-
geometry = null;
|
|
470
370
|
goals = [];
|
|
471
371
|
length = model.value.length;
|
|
472
372
|
metrics.scrollLeft = memo?.left ?? 0;
|
|
473
373
|
metrics.scrollTop = memo?.top ?? 0;
|
|
474
374
|
parsed = model.revision;
|
|
475
375
|
pendingValue = undefined;
|
|
476
|
-
|
|
376
|
+
placed = null;
|
|
477
377
|
secondary = selections.length > 1;
|
|
378
|
+
ui.empty = !model.value;
|
|
379
|
+
unitsDirty = true;
|
|
478
380
|
whole = null;
|
|
479
|
-
written = '';
|
|
480
381
|
state.selections.splice(0, state.selections.$length, ...selections.map((range) => ({ ...range })));
|
|
481
382
|
Object.assign(state, single, { selection: { ...single.selection } });
|
|
482
383
|
gestures.reset();
|
|
@@ -489,15 +390,29 @@ const view = (model, callbacks, receive) => {
|
|
|
489
390
|
search.result();
|
|
490
391
|
}
|
|
491
392
|
function capture() {
|
|
492
|
-
if (disposed || !
|
|
393
|
+
if (disposed || !content || ime.busy() || unplaced) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
let selection = content.ownerDocument.getSelection(), anchorNode = selection?.anchorNode, focusNode = selection?.focusNode;
|
|
397
|
+
if (!selection || !anchorNode || !focusNode || !content.contains(anchorNode) || !content.contains(focusNode)) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (placed &&
|
|
401
|
+
placed.anchor.node === anchorNode &&
|
|
402
|
+
placed.anchor.offset === selection.anchorOffset &&
|
|
403
|
+
placed.focus.node === focusNode &&
|
|
404
|
+
placed.focus.offset === selection.focusOffset) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
let anchor = sourceAt(anchorNode, selection.anchorOffset), head = sourceAt(focusNode, selection.focusOffset);
|
|
408
|
+
if (anchor === null || head === null) {
|
|
493
409
|
return;
|
|
494
410
|
}
|
|
495
|
-
let
|
|
496
|
-
direction:
|
|
497
|
-
end:
|
|
498
|
-
start:
|
|
411
|
+
let primary = model.selection, next = {
|
|
412
|
+
direction: head < anchor ? 'backward' : 'forward',
|
|
413
|
+
end: Math.max(anchor, head),
|
|
414
|
+
start: Math.min(anchor, head)
|
|
499
415
|
};
|
|
500
|
-
let primary = model.selection;
|
|
501
416
|
if (next.start === primary.start &&
|
|
502
417
|
next.end === primary.end &&
|
|
503
418
|
(next.start === next.end || next.direction === primary.direction || primary.direction === 'none')) {
|
|
@@ -505,25 +420,11 @@ const view = (model, callbacks, receive) => {
|
|
|
505
420
|
}
|
|
506
421
|
model.selectMany([next, ...model.selections.slice(1)]);
|
|
507
422
|
}
|
|
508
|
-
function caretAfter(edit, after, direction) {
|
|
509
|
-
let base = active.from, next = new NativeText(fieldSource.slice(0, edit.from) + edit.insert + fieldSource.slice(edit.to));
|
|
510
|
-
return { direction, end: base + next.toSource(after.end), start: base + next.toSource(after.start) };
|
|
511
|
-
}
|
|
512
423
|
function clientRect(offset) {
|
|
513
424
|
if (!surface) {
|
|
514
425
|
return null;
|
|
515
426
|
}
|
|
516
427
|
current();
|
|
517
|
-
let box = surface.getBoundingClientRect(), originX = box.left + surface.clientLeft - surface.scrollLeft, originY = box.top + surface.clientTop - surface.scrollTop;
|
|
518
|
-
if (active && editing && geometry && offset >= active.from && offset <= active.to) {
|
|
519
|
-
let rect = geometry.rect(projection.toNative(offset - active.from));
|
|
520
|
-
return {
|
|
521
|
-
height: rect.height,
|
|
522
|
-
left: originX + fieldLeft() + rect.left,
|
|
523
|
-
top: originY + metrics.padTop + layout.top(activeIndex) + rect.top,
|
|
524
|
-
width: rect.width
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
428
|
let index = layout.indexOf(offset), unit = layout.units[index];
|
|
528
429
|
if (!unit) {
|
|
529
430
|
return null;
|
|
@@ -532,7 +433,13 @@ const view = (model, callbacks, receive) => {
|
|
|
532
433
|
if (rects.length) {
|
|
533
434
|
return rects[0];
|
|
534
435
|
}
|
|
535
|
-
|
|
436
|
+
let box = surface.getBoundingClientRect();
|
|
437
|
+
return {
|
|
438
|
+
height: metrics.lineHeight,
|
|
439
|
+
left: box.left + surface.clientLeft - surface.scrollLeft + metrics.padLeft,
|
|
440
|
+
top: box.top + surface.clientTop - surface.scrollTop + metrics.padTop + layout.top(index),
|
|
441
|
+
width: 1
|
|
442
|
+
};
|
|
536
443
|
}
|
|
537
444
|
function clip(e, cut) {
|
|
538
445
|
if (disposed || ime.busy() || !e.clipboardData) {
|
|
@@ -548,12 +455,11 @@ const view = (model, callbacks, receive) => {
|
|
|
548
455
|
}
|
|
549
456
|
}
|
|
550
457
|
function connect() {
|
|
551
|
-
if (disposed || !
|
|
458
|
+
if (disposed || !content || !host || !ruler || !surface || unsubscribe) {
|
|
552
459
|
return;
|
|
553
460
|
}
|
|
554
461
|
measure();
|
|
555
462
|
subscribe();
|
|
556
|
-
refresh();
|
|
557
463
|
unitsDirty = true;
|
|
558
464
|
schedule();
|
|
559
465
|
void host.ownerDocument.fonts?.ready.then(() => {
|
|
@@ -571,21 +477,9 @@ const view = (model, callbacks, receive) => {
|
|
|
571
477
|
rebuild();
|
|
572
478
|
}
|
|
573
479
|
}
|
|
574
|
-
function deactivate() {
|
|
575
|
-
if (!editing) {
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
ime.flush();
|
|
579
|
-
editing = false;
|
|
580
|
-
drag = null;
|
|
581
|
-
ui.editing = false;
|
|
582
|
-
gestures.reset();
|
|
583
|
-
refresh();
|
|
584
|
-
schedule();
|
|
585
|
-
}
|
|
586
480
|
function decorate() {
|
|
587
481
|
let items = [], ranges = model.selections, matches = search.state.open || search.state.query ? search.result() : null;
|
|
588
|
-
if (ranges.length < 2 &&
|
|
482
|
+
if (ranges.length < 2 && dropAt === null && !matches?.matches.length) {
|
|
589
483
|
if (decorations.$length) {
|
|
590
484
|
decorations.splice(0, decorations.$length);
|
|
591
485
|
}
|
|
@@ -619,9 +513,6 @@ const view = (model, callbacks, receive) => {
|
|
|
619
513
|
let head = range.direction === 'backward' ? range.start : range.end;
|
|
620
514
|
mark(head, head, 'markdown-editor-mark markdown-editor-mark--caret');
|
|
621
515
|
}
|
|
622
|
-
if (drag) {
|
|
623
|
-
mark(Math.min(drag.anchor, drag.head), Math.max(drag.anchor, drag.head), 'markdown-editor-mark markdown-editor-mark--selection');
|
|
624
|
-
}
|
|
625
516
|
if (dropAt !== null) {
|
|
626
517
|
mark(dropAt, dropAt, 'markdown-editor-mark markdown-editor-mark--caret');
|
|
627
518
|
}
|
|
@@ -636,65 +527,101 @@ const view = (model, callbacks, receive) => {
|
|
|
636
527
|
decorations[i].style = items[i].style;
|
|
637
528
|
}
|
|
638
529
|
}
|
|
530
|
+
function domAt(offset) {
|
|
531
|
+
current();
|
|
532
|
+
let unit = layout.units[layout.indexOf(offset)];
|
|
533
|
+
if (!unit || !draw.segments(unit)) {
|
|
534
|
+
let first = rendered[0], last = rendered[rendered.length - 1];
|
|
535
|
+
if (!first || !last) {
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
if (offset < unitStart(first)) {
|
|
539
|
+
unit = first;
|
|
540
|
+
offset = contentStart(first);
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
unit = last;
|
|
544
|
+
offset = contentEnd(model.value, last.block);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
let element = elements.get(unit), segments = draw.segments(unit) ?? [], after = null, before = null;
|
|
548
|
+
for (let i = 0, n = segments.length; i < n; i++) {
|
|
549
|
+
let segment = segments[i], at = segment.block.from + segment.from, end = at + segment.node.length;
|
|
550
|
+
if (at <= offset && offset <= end) {
|
|
551
|
+
return { node: segment.node, offset: offset - at };
|
|
552
|
+
}
|
|
553
|
+
if (end < offset) {
|
|
554
|
+
before = { node: segment.node, offset: segment.node.length };
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
after = { node: segment.node, offset: 0 };
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (before || after) {
|
|
562
|
+
return before ?? after;
|
|
563
|
+
}
|
|
564
|
+
if (!element) {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
let children = element.childNodes;
|
|
568
|
+
for (let i = 0, n = children.length; i < n; i++) {
|
|
569
|
+
if (children[i].nodeName === 'BR') {
|
|
570
|
+
return { node: element, offset: i };
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return { node: element, offset: children.length };
|
|
574
|
+
}
|
|
575
|
+
function edgeAt(node, offset) {
|
|
576
|
+
if (!content) {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
let child = node === content ? content.childNodes[offset] ?? null : node;
|
|
580
|
+
while (child && child.parentNode !== content) {
|
|
581
|
+
child = child.parentNode;
|
|
582
|
+
}
|
|
583
|
+
for (let at = child; at; at = at.nextSibling) {
|
|
584
|
+
let unit = shown.get(at);
|
|
585
|
+
if (unit) {
|
|
586
|
+
return contentStart(unit);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
for (let at = child ? child.previousSibling : content.lastChild; at; at = at.previousSibling) {
|
|
590
|
+
let unit = shown.get(at);
|
|
591
|
+
if (unit) {
|
|
592
|
+
return contentEnd(model.value, unit.block);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
639
597
|
function editable(run) {
|
|
640
598
|
if (disposed || options.readonly || ime.busy()) {
|
|
641
599
|
return false;
|
|
642
600
|
}
|
|
643
601
|
capture();
|
|
644
602
|
revealFolds(true);
|
|
603
|
+
revealing = true;
|
|
645
604
|
let changed = run();
|
|
646
|
-
|
|
605
|
+
schedule();
|
|
647
606
|
return changed;
|
|
648
607
|
}
|
|
649
|
-
function
|
|
650
|
-
if (
|
|
651
|
-
|
|
652
|
-
return;
|
|
608
|
+
function erase(backward) {
|
|
609
|
+
if (model.selections.length > 1) {
|
|
610
|
+
return backward ? markdownCommand(model, 'backspace', kindAt) : deleteCharacter(model, false);
|
|
653
611
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
for (let i = 0, n = geometry.count; i < n && !estimated; i++) {
|
|
659
|
-
estimated = geometry.estimated(i);
|
|
660
|
-
}
|
|
612
|
+
current();
|
|
613
|
+
let { end, start } = model.selection;
|
|
614
|
+
if (start !== end) {
|
|
615
|
+
return remove({ from: start, to: end });
|
|
661
616
|
}
|
|
662
|
-
let
|
|
663
|
-
if (
|
|
664
|
-
|
|
665
|
-
|
|
617
|
+
let index = blockAt(blocks, start), block = blocks[index], unit = layout.units[layout.indexOf(start)], span = unit && draw.segments(unit) ? reach(model.value, spans(unit), start, backward) : null;
|
|
618
|
+
if (span) {
|
|
619
|
+
if ((block.kind === 'fence' || block.kind === 'frontmatter') && span.from < block.contentFrom && span.to >= block.contentFrom) {
|
|
620
|
+
return false;
|
|
666
621
|
}
|
|
622
|
+
return remove(span);
|
|
667
623
|
}
|
|
668
|
-
|
|
669
|
-
ui.input = `markdown-editor-input markdown-editor-input--${block.kind}${block.level ? ` markdown-editor-input--h${block.level}` : ''}${block.quoteDepth ? ' markdown-editor-input--quoted' : ''}`;
|
|
670
|
-
ui.style = `--depth: ${block.quoteDepth};${wrap ? '' : ` --field-width: ${Math.ceil((widest + 1) * metrics.charWidth * scale)}px;`}`;
|
|
671
|
-
layout.measure(activeUnit, height);
|
|
672
|
-
}
|
|
673
|
-
function fieldLeft() {
|
|
674
|
-
return metrics.padLeft + (active ? blocks[active.first].quoteDepth * metrics.quoteIndent : 0);
|
|
675
|
-
}
|
|
676
|
-
function fieldRects(from, to, out) {
|
|
677
|
-
if (!active || !geometry || !surface) {
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
let box = surface.getBoundingClientRect(), x = box.left + surface.clientLeft - surface.scrollLeft + fieldLeft(), y = box.top + surface.clientTop - surface.scrollTop + metrics.padTop + layout.top(activeIndex), end = geometry.rect(projection.toNative(clamp(to, active.from, active.to) - active.from)), start = geometry.rect(projection.toNative(clamp(from, active.from, active.to) - active.from)), lineHeight = geometry.lineHeight;
|
|
681
|
-
if (from === to) {
|
|
682
|
-
out.push({ height: lineHeight, left: x + start.left, top: y + start.top, width: 1 });
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
for (let top = start.top; top <= end.top && out.length < DECORATIONS; top += lineHeight) {
|
|
686
|
-
let left = top === start.top ? start.left : 0, right = top === end.top ? end.left : geometry.width;
|
|
687
|
-
out.push({ height: lineHeight, left: x + left, top: y + top, width: Math.max(1, right - left) });
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
function finish() {
|
|
691
|
-
if (!drag) {
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
let { anchor, head } = drag;
|
|
695
|
-
drag = null;
|
|
696
|
-
model.select({ direction: head < anchor ? 'backward' : 'forward', end: Math.max(anchor, head), start: Math.min(anchor, head) });
|
|
697
|
-
activate(true);
|
|
624
|
+
return backward ? joinBackward(index, start) : joinForward(index, start);
|
|
698
625
|
}
|
|
699
626
|
function inlineOf(block) {
|
|
700
627
|
let entry = inlines.get(block);
|
|
@@ -708,34 +635,69 @@ const view = (model, callbacks, receive) => {
|
|
|
708
635
|
}
|
|
709
636
|
return entry.tokens;
|
|
710
637
|
}
|
|
711
|
-
function
|
|
712
|
-
|
|
638
|
+
function invalidate(offset) {
|
|
639
|
+
let block = blocks[blockAt(blocks, offset)];
|
|
640
|
+
if (block) {
|
|
641
|
+
units.folded.delete(block);
|
|
642
|
+
units.plain.delete(block);
|
|
643
|
+
units.raw.delete(block);
|
|
644
|
+
}
|
|
645
|
+
unitsDirty = true;
|
|
646
|
+
schedule();
|
|
713
647
|
}
|
|
714
|
-
function
|
|
715
|
-
if (
|
|
648
|
+
function joinBackward(index, offset) {
|
|
649
|
+
if (markdownBackspace(model)) {
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
let block = blocks[index], previous = blocks[index - 1];
|
|
653
|
+
if (block.kind === 'heading' && block.contentFrom > block.from && offset <= block.contentFrom) {
|
|
654
|
+
let from = block.from + quotePrefix(model.lineText(model.lineAt(block.from))).length;
|
|
655
|
+
return model.replace(from, block.contentFrom, '', { selection: { start: from }, source: 'markdown-unwrap' });
|
|
656
|
+
}
|
|
657
|
+
if (!previous) {
|
|
716
658
|
return false;
|
|
717
659
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
660
|
+
if (previous.kind === 'blank' || previous.kind === 'rule') {
|
|
661
|
+
return model.replace(previous.from, previous.to, '', {
|
|
662
|
+
selection: { start: offset - (previous.to - previous.from) },
|
|
663
|
+
source: 'delete'
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
if (JOINABLE.has(previous.kind) && (JOINABLE.has(block.kind) || block.kind === 'blank')) {
|
|
667
|
+
return model.replace(previous.contentTo, offset, '', { selection: { start: previous.contentTo }, source: 'delete' });
|
|
721
668
|
}
|
|
722
|
-
|
|
723
|
-
|
|
669
|
+
model.select({ start: previous.contentTo });
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
function joinForward(index, offset) {
|
|
673
|
+
let block = blocks[index], next = blocks[index + 1];
|
|
674
|
+
if (!next) {
|
|
675
|
+
return false;
|
|
724
676
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return rect.top < geometry.lineHeight / 2 && active.from > 0;
|
|
677
|
+
if (next.kind === 'blank' || next.kind === 'rule') {
|
|
678
|
+
return model.replace(next.from, next.to, '', { selection: { start: offset }, source: 'delete' });
|
|
728
679
|
}
|
|
729
|
-
|
|
680
|
+
if (JOINABLE.has(next.kind) && (JOINABLE.has(block.kind) || block.kind === 'blank')) {
|
|
681
|
+
return model.replace(offset, next.contentFrom, '', { selection: { start: offset }, source: 'delete' });
|
|
682
|
+
}
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
function kindAt(offset) {
|
|
686
|
+
return blocks[blockAt(blocks, offset)]?.kind;
|
|
730
687
|
}
|
|
731
688
|
function linesOf(index) {
|
|
732
689
|
let units = layout.units, from = unitStart(units[index]), to = index + 1 < units.length ? unitStart(units[index + 1]) - 1 : model.value.length;
|
|
733
690
|
return { first: model.lineAt(from), last: model.lineAt(Math.max(from, to)) };
|
|
734
691
|
}
|
|
735
|
-
function
|
|
736
|
-
let
|
|
737
|
-
|
|
738
|
-
|
|
692
|
+
function linking(e) {
|
|
693
|
+
let next = apple ? e.metaKey : e.ctrlKey;
|
|
694
|
+
if (ui.linking !== next) {
|
|
695
|
+
ui.linking = next;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function markFoldable() {
|
|
699
|
+
for (let i = 0, n = rendered.length; i < n; i++) {
|
|
700
|
+
let unit = rendered[i], state = draw.state(unit);
|
|
739
701
|
if (!state) {
|
|
740
702
|
continue;
|
|
741
703
|
}
|
|
@@ -746,7 +708,7 @@ const view = (model, callbacks, receive) => {
|
|
|
746
708
|
}
|
|
747
709
|
}
|
|
748
710
|
function measure() {
|
|
749
|
-
if (disposed || !host || !ruler || !surface
|
|
711
|
+
if (disposed || !host || !ruler || !surface) {
|
|
750
712
|
return;
|
|
751
713
|
}
|
|
752
714
|
let computed = getComputedStyle(surface), style = getComputedStyle(host), fallback = style.getPropertyValue('--color').trim() || 'currentColor', colors = {}, padLeft = pixels(computed.paddingLeft), fontSize = pixels(computed.fontSize) || 13;
|
|
@@ -775,21 +737,32 @@ const view = (model, callbacks, receive) => {
|
|
|
775
737
|
width: metrics.width
|
|
776
738
|
})) {
|
|
777
739
|
whole = null;
|
|
778
|
-
fieldGeometry();
|
|
779
740
|
map.invalidate();
|
|
780
741
|
unitsDirty = true;
|
|
781
742
|
}
|
|
782
743
|
schedule();
|
|
783
744
|
}
|
|
784
745
|
function moveSelection(key, extend, word = false, add = false, boundary = false) {
|
|
746
|
+
let native = content?.ownerDocument.getSelection();
|
|
747
|
+
if (native &&
|
|
748
|
+
model.selections.length === 1 &&
|
|
749
|
+
!add &&
|
|
750
|
+
!key.startsWith('Page') &&
|
|
751
|
+
content?.ownerDocument.activeElement === content) {
|
|
752
|
+
let vertical = VERTICAL.test(key);
|
|
753
|
+
native.modify(extend ? 'extend' : 'move', key === 'ArrowLeft' || key === 'ArrowUp' || key === 'Home' ? 'backward' : 'forward', vertical ? 'line' : key === 'Home' || key === 'End' ? (boundary ? 'documentboundary' : 'lineboundary') : word ? 'word' : 'character');
|
|
754
|
+
capture();
|
|
755
|
+
start(true);
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
785
758
|
if (!VERTICAL.test(key) || boundary || add) {
|
|
786
759
|
goals = [];
|
|
787
760
|
}
|
|
788
761
|
if (!whole || whole.revision !== model.revision) {
|
|
789
|
-
let
|
|
762
|
+
let text = new NativeText(model.value);
|
|
790
763
|
whole = {
|
|
791
|
-
layout: new EditorLayout(
|
|
792
|
-
projection:
|
|
764
|
+
layout: new EditorLayout(text, model.value, Number.MAX_SAFE_INTEGER, metrics.lineHeight, metrics.charWidth, options.tabSize ?? 4, false),
|
|
765
|
+
projection: text,
|
|
793
766
|
revision: model.revision
|
|
794
767
|
};
|
|
795
768
|
}
|
|
@@ -805,7 +778,7 @@ const view = (model, callbacks, receive) => {
|
|
|
805
778
|
start(true);
|
|
806
779
|
}
|
|
807
780
|
function offsetAt(clientX, clientY) {
|
|
808
|
-
if (disposed || !surface) {
|
|
781
|
+
if (disposed || !surface || !host) {
|
|
809
782
|
return null;
|
|
810
783
|
}
|
|
811
784
|
current();
|
|
@@ -813,17 +786,14 @@ const view = (model, callbacks, receive) => {
|
|
|
813
786
|
if (box.width && (clientX < box.left || clientX > box.right || clientY < box.top || clientY > box.bottom)) {
|
|
814
787
|
return null;
|
|
815
788
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
789
|
+
let doc = host.ownerDocument, point = doc.caretPositionFromPoint?.(clientX, clientY), range = point ? null : doc.caretRangeFromPoint?.(clientX, clientY), node = point?.offsetNode ?? range?.startContainer ?? null;
|
|
790
|
+
if (node && content?.contains(node)) {
|
|
791
|
+
let offset = sourceAt(node, point?.offset ?? range?.startOffset ?? 0);
|
|
792
|
+
if (offset !== null) {
|
|
793
|
+
return offset;
|
|
820
794
|
}
|
|
821
795
|
}
|
|
822
|
-
let
|
|
823
|
-
if (point !== null) {
|
|
824
|
-
return point;
|
|
825
|
-
}
|
|
826
|
-
let under = host.ownerDocument.elementFromPoint(clientX, clientY)?.closest('.markdown-editor-block'), unit = under && shown.get(under);
|
|
796
|
+
let under = doc.elementFromPoint(clientX, clientY)?.closest('.markdown-editor-block'), unit = under && shown.get(under);
|
|
827
797
|
if (unit) {
|
|
828
798
|
return contentStart(unit);
|
|
829
799
|
}
|
|
@@ -831,7 +801,7 @@ const view = (model, callbacks, receive) => {
|
|
|
831
801
|
return layout.units[index] ? contentStart(layout.units[index]) : null;
|
|
832
802
|
}
|
|
833
803
|
function opens(unit) {
|
|
834
|
-
return options.fold
|
|
804
|
+
return !!options.fold && !unit.continuation && !unit.raw && !unit.fold && foldable(blocks, blockAt(blocks, unit.block.from), model.value);
|
|
835
805
|
}
|
|
836
806
|
function paint() {
|
|
837
807
|
frame = 0;
|
|
@@ -839,35 +809,14 @@ const view = (model, callbacks, receive) => {
|
|
|
839
809
|
return;
|
|
840
810
|
}
|
|
841
811
|
current();
|
|
842
|
-
if (estimated && textarea && editing) {
|
|
843
|
-
flush();
|
|
844
|
-
let height = textarea.scrollHeight;
|
|
845
|
-
if (height > ui.height + 0.5) {
|
|
846
|
-
ui.height = height;
|
|
847
|
-
layout.measure(activeUnit, height);
|
|
848
|
-
}
|
|
849
|
-
estimated = false;
|
|
850
|
-
}
|
|
851
812
|
if (revealing) {
|
|
852
813
|
revealing = false;
|
|
853
814
|
reveal();
|
|
854
815
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (view.start > split) {
|
|
860
|
-
s1 = e1 = split;
|
|
861
|
-
}
|
|
862
|
-
assign(listed.before, layout.units.slice(s1, e1));
|
|
863
|
-
assign(listed.after, layout.units.slice(s2, e2));
|
|
864
|
-
ui.top = layout.top(s1);
|
|
865
|
-
ui.between = a < 0 ? 0 : layout.top(split) - layout.top(e1);
|
|
866
|
-
ui.next = a < 0 ? 0 : layout.top(s2) - layout.top(a + 1);
|
|
867
|
-
ui.bottom = layout.total - layout.top(a < 0 ? e1 : e2);
|
|
868
|
-
ui.foldable = !!active && options.fold !== false && foldable(blocks, active.first, model.value);
|
|
869
|
-
markFoldable(s1, e1);
|
|
870
|
-
markFoldable(s2, e2);
|
|
816
|
+
if (!ime.busy()) {
|
|
817
|
+
present();
|
|
818
|
+
}
|
|
819
|
+
markFoldable();
|
|
871
820
|
queueMicrotask(() => {
|
|
872
821
|
if (!disposed) {
|
|
873
822
|
decorate();
|
|
@@ -881,57 +830,73 @@ const view = (model, callbacks, receive) => {
|
|
|
881
830
|
map.paint(source, { clientHeight: metrics.clientHeight, scrollHeight: layout.total + 2 * metrics.padTop, scrollTop: metrics.scrollTop }, palette, metrics.minimap);
|
|
882
831
|
}
|
|
883
832
|
}
|
|
884
|
-
function
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
function present() {
|
|
889
|
-
if (disposed || !surface) {
|
|
833
|
+
function place() {
|
|
834
|
+
unplaced = false;
|
|
835
|
+
if (disposed || !content || ime.busy() || content.ownerDocument.activeElement !== content) {
|
|
890
836
|
return;
|
|
891
837
|
}
|
|
892
|
-
|
|
893
|
-
|
|
838
|
+
let native = content.ownerDocument.getSelection();
|
|
839
|
+
if (!native) {
|
|
840
|
+
return;
|
|
894
841
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
842
|
+
let selection = model.selection, backward = selection.direction === 'backward', anchorAt = backward ? selection.end : selection.start, headAt = backward ? selection.start : selection.end;
|
|
843
|
+
if (native.anchorNode &&
|
|
844
|
+
native.focusNode &&
|
|
845
|
+
content.contains(native.anchorNode) &&
|
|
846
|
+
content.contains(native.focusNode) &&
|
|
847
|
+
sourceAt(native.anchorNode, native.anchorOffset) === anchorAt &&
|
|
848
|
+
sourceAt(native.focusNode, native.focusOffset) === headAt) {
|
|
902
849
|
return;
|
|
903
850
|
}
|
|
904
|
-
let
|
|
905
|
-
if (
|
|
851
|
+
let anchor = domAt(anchorAt), focus = anchorAt === headAt ? anchor : domAt(headAt);
|
|
852
|
+
if (!anchor || !focus) {
|
|
853
|
+
unplaced = true;
|
|
854
|
+
schedule();
|
|
906
855
|
return;
|
|
907
856
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
857
|
+
native.setBaseAndExtent(anchor.node, anchor.offset, focus.node, focus.offset);
|
|
858
|
+
placed = { anchor, focus };
|
|
859
|
+
unplaced = false;
|
|
860
|
+
}
|
|
861
|
+
function present() {
|
|
862
|
+
let n = layout.units.length, view = layout.window(metrics.scrollTop - metrics.padTop, metrics.clientHeight), selection = model.selection, runs = [];
|
|
863
|
+
if (n) {
|
|
864
|
+
let anchor = layout.indexOf(selection.direction === 'backward' ? selection.end : selection.start), head = layout.indexOf(selection.direction === 'backward' ? selection.start : selection.end);
|
|
865
|
+
runs.push({ from: anchor, to: anchor + 1 }, { from: head, to: head + 1 }, { from: view.start, to: view.end });
|
|
866
|
+
runs.sort((a, b) => a.from - b.from);
|
|
867
|
+
}
|
|
868
|
+
let cursor = 0, gap = 0, next = [];
|
|
869
|
+
let space = (height) => {
|
|
870
|
+
let item = gaps[gap++] ??= new ReactiveObject_1ayo7z92();
|
|
871
|
+
item.height = height;
|
|
872
|
+
next.push(item);
|
|
913
873
|
};
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
874
|
+
for (let i = 0, m = runs.length; i < m; i++) {
|
|
875
|
+
let { from, to } = runs[i];
|
|
876
|
+
from = Math.max(from, cursor);
|
|
877
|
+
if (to <= from) {
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
if (from > cursor || !next.length) {
|
|
881
|
+
space(layout.top(from) - layout.top(cursor));
|
|
917
882
|
}
|
|
918
|
-
|
|
883
|
+
for (let j = from; j < to; j++) {
|
|
884
|
+
next.push(layout.units[j]);
|
|
919
885
|
}
|
|
886
|
+
cursor = to;
|
|
920
887
|
}
|
|
921
|
-
|
|
888
|
+
space(layout.total - layout.top(cursor));
|
|
889
|
+
assign(items, next);
|
|
890
|
+
rendered = next.filter((item) => 'block' in item);
|
|
891
|
+
flush();
|
|
892
|
+
place();
|
|
922
893
|
}
|
|
923
894
|
function rangeRects(from, to) {
|
|
924
895
|
let out = [], units = layout.units, first = layout.indexOf(from), last = layout.indexOf(to);
|
|
925
896
|
for (let i = first; i <= last && out.length < DECORATIONS; i++) {
|
|
926
|
-
let
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}
|
|
930
|
-
else {
|
|
931
|
-
let rects = textRects(unit, from, to);
|
|
932
|
-
for (let j = 0, n = rects.length; j < n; j++) {
|
|
933
|
-
out.push(rects[j]);
|
|
934
|
-
}
|
|
897
|
+
let rects = textRects(units[i], from, to);
|
|
898
|
+
for (let j = 0, n = rects.length; j < n; j++) {
|
|
899
|
+
out.push(rects[j]);
|
|
935
900
|
}
|
|
936
901
|
}
|
|
937
902
|
return out;
|
|
@@ -946,16 +911,7 @@ const view = (model, callbacks, receive) => {
|
|
|
946
911
|
}
|
|
947
912
|
}
|
|
948
913
|
}
|
|
949
|
-
|
|
950
|
-
activeUnit.block = blocks[active.first];
|
|
951
|
-
}
|
|
952
|
-
let list = arrange(blocks, model.value, options.fold === false ? [] : folds, units, active && editing ? { first: active.first, last: active.last, unit: activeUnit } : null, raw ? (index) => raw.has(index) : null);
|
|
953
|
-
layout.set(list, model.value);
|
|
954
|
-
activeIndex = -1;
|
|
955
|
-
if (active && editing) {
|
|
956
|
-
let index = layout.indexOf(active.from);
|
|
957
|
-
activeIndex = list[index] === activeUnit ? index : list.indexOf(activeUnit);
|
|
958
|
-
}
|
|
914
|
+
layout.set(arrange(blocks, model.value, options.fold ? folds : [], units, raw ? (index) => raw.has(index) : null), model.value);
|
|
959
915
|
unitsDirty = false;
|
|
960
916
|
}
|
|
961
917
|
function references() {
|
|
@@ -975,56 +931,12 @@ const view = (model, callbacks, receive) => {
|
|
|
975
931
|
units = cache();
|
|
976
932
|
unitsDirty = true;
|
|
977
933
|
}
|
|
978
|
-
function
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
if (!editing || !blocks.length) {
|
|
983
|
-
if (active) {
|
|
984
|
-
active = null;
|
|
985
|
-
geometry = null;
|
|
986
|
-
unitsDirty = true;
|
|
987
|
-
}
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
let selection = model.selection, first = blockAt(blocks, selection.start), last = blockAt(blocks, selection.end) + 1;
|
|
991
|
-
if (pinned && active && active.last <= blocks.length) {
|
|
992
|
-
first = Math.min(first, active.first);
|
|
993
|
-
last = Math.max(last, active.last);
|
|
994
|
-
}
|
|
995
|
-
let from = blocks[first].from, to = Math.max(selection.end, contentEnd(model.value, blocks[last - 1]));
|
|
996
|
-
if (!active || active.first !== first || active.last !== last) {
|
|
997
|
-
unitsDirty = true;
|
|
998
|
-
}
|
|
999
|
-
active = { first, from, last, to };
|
|
1000
|
-
let text = model.value.slice(from, to), shaped = fieldSource !== text || !geometry;
|
|
1001
|
-
if (fieldSource !== text) {
|
|
1002
|
-
fieldSource = text;
|
|
1003
|
-
projection = new NativeText(text);
|
|
1004
|
-
}
|
|
1005
|
-
if (shaped || activeUnit.block !== blocks[first]) {
|
|
1006
|
-
activeUnit.block = blocks[first];
|
|
1007
|
-
fieldGeometry();
|
|
1008
|
-
}
|
|
1009
|
-
if (!textarea || ime.busy()) {
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
if (written !== projection.value) {
|
|
1013
|
-
writing = true;
|
|
1014
|
-
try {
|
|
1015
|
-
writeField(textarea, written, projection.value, null);
|
|
1016
|
-
}
|
|
1017
|
-
finally {
|
|
1018
|
-
writing = false;
|
|
1019
|
-
}
|
|
1020
|
-
written = projection.value;
|
|
1021
|
-
}
|
|
1022
|
-
let nativeEnd = projection.toNative(clamp(selection.end - from, 0, text.length)), nativeStart = projection.toNative(clamp(selection.start - from, 0, text.length));
|
|
1023
|
-
if (textarea.selectionStart !== nativeStart ||
|
|
1024
|
-
textarea.selectionEnd !== nativeEnd ||
|
|
1025
|
-
(nativeStart !== nativeEnd && selection.direction !== 'none' && textarea.selectionDirection !== selection.direction)) {
|
|
1026
|
-
textarea.setSelectionRange(nativeStart, nativeEnd, selection.direction);
|
|
934
|
+
function remove(span) {
|
|
935
|
+
let block = blocks[blockAt(blocks, span.from)];
|
|
936
|
+
if (block && JOINABLE.has(block.kind) && span.to <= block.to) {
|
|
937
|
+
span = widen(model.value, inlineOf(block), block.from, span);
|
|
1027
938
|
}
|
|
939
|
+
return model.replace(span.from, span.to, '', { group: 'delete', selection: { start: span.from }, source: 'delete' });
|
|
1028
940
|
}
|
|
1029
941
|
function reparseBlocks() {
|
|
1030
942
|
let deltas = model.deltas(parsed), previous = length;
|
|
@@ -1034,10 +946,10 @@ const view = (model, callbacks, receive) => {
|
|
|
1034
946
|
blocks = parseMarkdown(model);
|
|
1035
947
|
map.invalidate();
|
|
1036
948
|
references();
|
|
1037
|
-
return
|
|
949
|
+
return;
|
|
1038
950
|
}
|
|
1039
951
|
if (!deltas.length) {
|
|
1040
|
-
return
|
|
952
|
+
return;
|
|
1041
953
|
}
|
|
1042
954
|
let end = -1, moved = 0, start = Number.MAX_SAFE_INTEGER;
|
|
1043
955
|
for (let i = 0, n = deltas.length; i < n; i++) {
|
|
@@ -1067,7 +979,7 @@ const view = (model, callbacks, receive) => {
|
|
|
1067
979
|
if (changed) {
|
|
1068
980
|
map.invalidate();
|
|
1069
981
|
references();
|
|
1070
|
-
return
|
|
982
|
+
return;
|
|
1071
983
|
}
|
|
1072
984
|
if (moved) {
|
|
1073
985
|
map.invalidate();
|
|
@@ -1075,18 +987,6 @@ const view = (model, callbacks, receive) => {
|
|
|
1075
987
|
else {
|
|
1076
988
|
map.invalidate(start, end);
|
|
1077
989
|
}
|
|
1078
|
-
return !!active &&
|
|
1079
|
-
editing &&
|
|
1080
|
-
splice.dropped.length === splice.inserted &&
|
|
1081
|
-
splice.start >= active.first &&
|
|
1082
|
-
splice.start + splice.inserted <= active.last;
|
|
1083
|
-
}
|
|
1084
|
-
function reset() {
|
|
1085
|
-
before = null;
|
|
1086
|
-
beforeRanges = [];
|
|
1087
|
-
beforeSelection = undefined;
|
|
1088
|
-
inputData = null;
|
|
1089
|
-
inputType = '';
|
|
1090
990
|
}
|
|
1091
991
|
function resized(entries) {
|
|
1092
992
|
if (disposed) {
|
|
@@ -1114,19 +1014,18 @@ const view = (model, callbacks, receive) => {
|
|
|
1114
1014
|
schedule();
|
|
1115
1015
|
}
|
|
1116
1016
|
}
|
|
1117
|
-
function resync() {
|
|
1118
|
-
written = '';
|
|
1119
|
-
refresh();
|
|
1120
|
-
schedule();
|
|
1121
|
-
}
|
|
1122
1017
|
function reveal() {
|
|
1123
|
-
let selection = model.selection, head = selection.direction === 'backward' ? selection.start : selection.end,
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1018
|
+
let selection = model.selection, head = selection.direction === 'backward' ? selection.start : selection.end, index = layout.indexOf(head), unit = layout.units[index];
|
|
1019
|
+
if (!unit || !surface) {
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
let height = Math.min(layout.height(unit), metrics.clientHeight), y = metrics.padTop + layout.top(index), rect = draw.segments(unit) ? textRects(unit, head, head)[0] : undefined;
|
|
1023
|
+
if (rect) {
|
|
1024
|
+
let box = surface.getBoundingClientRect();
|
|
1126
1025
|
height = rect.height;
|
|
1127
|
-
y =
|
|
1128
|
-
if (options.wrap === false
|
|
1129
|
-
let x =
|
|
1026
|
+
y = rect.top - box.top - surface.clientTop + surface.scrollTop;
|
|
1027
|
+
if (options.wrap === false) {
|
|
1028
|
+
let x = rect.left - box.left - surface.clientLeft + surface.scrollLeft;
|
|
1130
1029
|
if (x < metrics.scrollLeft + metrics.padLeft) {
|
|
1131
1030
|
surface.scrollLeft = metrics.scrollLeft = Math.max(0, x - metrics.padLeft);
|
|
1132
1031
|
}
|
|
@@ -1135,14 +1034,6 @@ const view = (model, callbacks, receive) => {
|
|
|
1135
1034
|
}
|
|
1136
1035
|
}
|
|
1137
1036
|
}
|
|
1138
|
-
else {
|
|
1139
|
-
let index = layout.indexOf(head), unit = layout.units[index];
|
|
1140
|
-
if (!unit) {
|
|
1141
|
-
return;
|
|
1142
|
-
}
|
|
1143
|
-
y = metrics.padTop + layout.top(index);
|
|
1144
|
-
height = Math.min(layout.height(unit), metrics.clientHeight);
|
|
1145
|
-
}
|
|
1146
1037
|
if (y < metrics.scrollTop) {
|
|
1147
1038
|
scrollTo(y - metrics.padTop);
|
|
1148
1039
|
}
|
|
@@ -1192,10 +1083,57 @@ const view = (model, callbacks, receive) => {
|
|
|
1192
1083
|
metrics.scrollTop = surface.scrollTop;
|
|
1193
1084
|
schedule();
|
|
1194
1085
|
}
|
|
1195
|
-
function
|
|
1196
|
-
|
|
1197
|
-
|
|
1086
|
+
function shortcut(text) {
|
|
1087
|
+
let { end, start } = model.selection;
|
|
1088
|
+
if (text !== ' ' || start !== end || model.selections.length > 1 || LITERAL.has(kindAt(start))) {
|
|
1089
|
+
return false;
|
|
1090
|
+
}
|
|
1091
|
+
let from = model.lineStart(model.lineAt(start)), before = model.value.slice(from, start), at = from + quotePrefix(before).length, rest = model.value.slice(at, start);
|
|
1092
|
+
if (TASK.test(rest)) {
|
|
1093
|
+
return model.replace(at, start, '- [ ] ', { selection: { start: at + 6 }, source: 'markdown-task' });
|
|
1094
|
+
}
|
|
1095
|
+
if (ITEM_TASK.test(rest)) {
|
|
1096
|
+
let bracket = at + rest.lastIndexOf('[');
|
|
1097
|
+
return model.replace(bracket, start, '[ ] ', { selection: { start: bracket + 4 }, source: 'markdown-task' });
|
|
1098
|
+
}
|
|
1099
|
+
return false;
|
|
1100
|
+
}
|
|
1101
|
+
function sourceAt(node, offset) {
|
|
1102
|
+
let direct = draw.offset(node, offset);
|
|
1103
|
+
if (direct !== null) {
|
|
1104
|
+
return direct;
|
|
1105
|
+
}
|
|
1106
|
+
let element = (node.nodeType === 1 ? node : node.parentElement)?.closest('.markdown-editor-block'), unit = element ? shown.get(element) : undefined;
|
|
1107
|
+
if (!unit) {
|
|
1108
|
+
return edgeAt(node, offset);
|
|
1198
1109
|
}
|
|
1110
|
+
let range = node.ownerDocument.createRange(), segments = draw.segments(unit) ?? [], after = null, before = null;
|
|
1111
|
+
range.setStart(node, offset);
|
|
1112
|
+
for (let i = 0, n = segments.length; i < n; i++) {
|
|
1113
|
+
let segment = segments[i];
|
|
1114
|
+
if (range.comparePoint(segment.node, segment.node.length) <= 0) {
|
|
1115
|
+
before = segment.block.from + segment.from + segment.node.length;
|
|
1116
|
+
}
|
|
1117
|
+
else if (range.comparePoint(segment.node, 0) >= 0) {
|
|
1118
|
+
after = segment.block.from + segment.from;
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
let broken = node.nodeType === 3 && offset > 0 && LINE_BREAK.test(node.textContent[offset - 1]);
|
|
1123
|
+
if (after !== null && (broken || before === null)) {
|
|
1124
|
+
return after;
|
|
1125
|
+
}
|
|
1126
|
+
return before ?? contentStart(unit);
|
|
1127
|
+
}
|
|
1128
|
+
function spans(unit) {
|
|
1129
|
+
let out = [], segments = draw.segments(unit) ?? [];
|
|
1130
|
+
for (let i = 0, n = segments.length; i < n; i++) {
|
|
1131
|
+
let from = segments[i].block.from + segments[i].from;
|
|
1132
|
+
out.push({ from, to: from + segments[i].node.length });
|
|
1133
|
+
}
|
|
1134
|
+
return out;
|
|
1135
|
+
}
|
|
1136
|
+
function start(reveal) {
|
|
1199
1137
|
revealing ||= reveal;
|
|
1200
1138
|
schedule();
|
|
1201
1139
|
}
|
|
@@ -1211,14 +1149,17 @@ const view = (model, callbacks, receive) => {
|
|
|
1211
1149
|
if (change.textChanged) {
|
|
1212
1150
|
ime.conflict();
|
|
1213
1151
|
textChanged(change);
|
|
1152
|
+
ui.empty = !snapshot.value;
|
|
1214
1153
|
}
|
|
1215
1154
|
if (change.selectionChanged) {
|
|
1216
1155
|
revealFolds();
|
|
1217
1156
|
unitsDirty ||= secondary || selections.length > 1;
|
|
1218
1157
|
secondary = selections.length > 1;
|
|
1219
1158
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1159
|
+
if (frame) {
|
|
1160
|
+
cancelAnimationFrame(frame);
|
|
1161
|
+
}
|
|
1162
|
+
paint();
|
|
1222
1163
|
if (change.selectionChanged) {
|
|
1223
1164
|
callbacks.onSelection?.(snapshot.selection, model.position());
|
|
1224
1165
|
}
|
|
@@ -1228,13 +1169,12 @@ const view = (model, callbacks, receive) => {
|
|
|
1228
1169
|
});
|
|
1229
1170
|
}
|
|
1230
1171
|
function textChanged(change) {
|
|
1231
|
-
|
|
1172
|
+
reparseBlocks();
|
|
1232
1173
|
if (folds.length) {
|
|
1233
1174
|
folds = outerFolds(mapFolds(folds, change.editBatches ?? [], model));
|
|
1234
|
-
local = false;
|
|
1235
1175
|
}
|
|
1236
1176
|
whole = null;
|
|
1237
|
-
unitsDirty
|
|
1177
|
+
unitsDirty = true;
|
|
1238
1178
|
}
|
|
1239
1179
|
function textRects(unit, from, to) {
|
|
1240
1180
|
let out = [], segments = draw.segments(unit);
|
|
@@ -1259,6 +1199,9 @@ const view = (model, callbacks, receive) => {
|
|
|
1259
1199
|
}
|
|
1260
1200
|
return out;
|
|
1261
1201
|
}
|
|
1202
|
+
function typed(text) {
|
|
1203
|
+
return editable(() => shortcut(text) || insertText(model, text, 'input'));
|
|
1204
|
+
}
|
|
1262
1205
|
let controller = {
|
|
1263
1206
|
addNextOccurrence: (all = false) => {
|
|
1264
1207
|
if (disposed || ime.busy()) {
|
|
@@ -1299,12 +1242,15 @@ const view = (model, callbacks, receive) => {
|
|
|
1299
1242
|
findNext: () => search.next(),
|
|
1300
1243
|
findPrevious: () => search.previous(),
|
|
1301
1244
|
focus: () => {
|
|
1302
|
-
if (!
|
|
1303
|
-
|
|
1245
|
+
if (disposed || !content) {
|
|
1246
|
+
return;
|
|
1304
1247
|
}
|
|
1248
|
+
content.focus({ preventScroll: true });
|
|
1249
|
+
place();
|
|
1250
|
+
schedule();
|
|
1305
1251
|
},
|
|
1306
1252
|
fold: (line) => {
|
|
1307
|
-
if (disposed || ime.busy() || options.fold
|
|
1253
|
+
if (disposed || ime.busy() || !options.fold) {
|
|
1308
1254
|
return false;
|
|
1309
1255
|
}
|
|
1310
1256
|
let target = line === undefined ? model.position().line : line, index = blockAt(blocks, model.lineStart(target - 1)), range = line === undefined || blocks[index].from === model.lineStart(target - 1) ? foldAt(model, blocks, index) : null;
|
|
@@ -1315,22 +1261,16 @@ const view = (model, callbacks, receive) => {
|
|
|
1315
1261
|
if (model.selections.some((selection) => (selection.start >= range.from && selection.start < range.to) || (selection.end > range.from && selection.end <= range.to))) {
|
|
1316
1262
|
model.select({ start: range.open ?? range.from });
|
|
1317
1263
|
}
|
|
1318
|
-
if (active && range.from < blocks[active.last - 1].to && range.to > active.from) {
|
|
1319
|
-
deactivate();
|
|
1320
|
-
textarea?.blur();
|
|
1321
|
-
}
|
|
1322
1264
|
unitsDirty = true;
|
|
1323
1265
|
schedule();
|
|
1324
1266
|
return true;
|
|
1325
1267
|
},
|
|
1326
1268
|
foldAll: () => {
|
|
1327
|
-
if (disposed || ime.busy() || options.fold
|
|
1269
|
+
if (disposed || ime.busy() || !options.fold) {
|
|
1328
1270
|
return;
|
|
1329
1271
|
}
|
|
1330
1272
|
model.select({ start: 0 });
|
|
1331
1273
|
folds = outerFolds(markdownFolds(model, blocks));
|
|
1332
|
-
deactivate();
|
|
1333
|
-
textarea?.blur();
|
|
1334
1274
|
unitsDirty = true;
|
|
1335
1275
|
schedule();
|
|
1336
1276
|
},
|
|
@@ -1386,7 +1326,6 @@ const view = (model, callbacks, receive) => {
|
|
|
1386
1326
|
refresh: () => {
|
|
1387
1327
|
if (!disposed) {
|
|
1388
1328
|
measure();
|
|
1389
|
-
fieldGeometry();
|
|
1390
1329
|
unitsDirty = true;
|
|
1391
1330
|
schedule();
|
|
1392
1331
|
}
|
|
@@ -1420,17 +1359,24 @@ const view = (model, callbacks, receive) => {
|
|
|
1420
1359
|
controller.setOptions(settings ?? {}, !!settings);
|
|
1421
1360
|
return;
|
|
1422
1361
|
}
|
|
1423
|
-
let focused =
|
|
1424
|
-
|
|
1362
|
+
let focused = !!content && host?.ownerDocument.activeElement === content;
|
|
1363
|
+
ime.flush();
|
|
1425
1364
|
if (surface) {
|
|
1426
1365
|
visited.set(model, { folds, left: metrics.scrollLeft, revision: model.revision, top: metrics.scrollTop });
|
|
1427
1366
|
}
|
|
1428
1367
|
model = next;
|
|
1429
1368
|
adopt();
|
|
1430
1369
|
controller.setOptions(settings ?? {}, !!settings);
|
|
1431
|
-
|
|
1370
|
+
if (frame) {
|
|
1371
|
+
cancelAnimationFrame(frame);
|
|
1372
|
+
}
|
|
1373
|
+
paint();
|
|
1374
|
+
if (surface) {
|
|
1375
|
+
surface.scrollLeft = metrics.scrollLeft;
|
|
1376
|
+
surface.scrollTop = metrics.scrollTop;
|
|
1377
|
+
}
|
|
1432
1378
|
if (focused) {
|
|
1433
|
-
|
|
1379
|
+
controller.focus();
|
|
1434
1380
|
}
|
|
1435
1381
|
},
|
|
1436
1382
|
setOptions: (next, replace = false) => {
|
|
@@ -1442,20 +1388,19 @@ const view = (model, callbacks, receive) => {
|
|
|
1442
1388
|
if (!options.indent || !/^[\t ]+$/.test(options.indent)) {
|
|
1443
1389
|
options.indent = ' ';
|
|
1444
1390
|
}
|
|
1391
|
+
ui.fold = !!options.fold;
|
|
1445
1392
|
ui.label = options.label ?? 'Markdown editor';
|
|
1446
1393
|
ui.minimap = !!options.minimap;
|
|
1447
|
-
ui.name = options.name ?? '';
|
|
1448
1394
|
ui.placeholder = options.placeholder ?? '';
|
|
1449
1395
|
ui.readonly = !!options.readonly;
|
|
1450
1396
|
ui.spellcheck = options.spellcheck ?? true;
|
|
1451
1397
|
ui.tabSize = options.tabSize;
|
|
1452
1398
|
ui.wrap = options.wrap !== false;
|
|
1453
1399
|
search.status();
|
|
1454
|
-
if (options.fold
|
|
1400
|
+
if (!options.fold) {
|
|
1455
1401
|
folds = [];
|
|
1456
1402
|
}
|
|
1457
1403
|
whole = null;
|
|
1458
|
-
fieldGeometry();
|
|
1459
1404
|
map.invalidate();
|
|
1460
1405
|
unitsDirty = true;
|
|
1461
1406
|
schedule();
|
|
@@ -1476,9 +1421,6 @@ const view = (model, callbacks, receive) => {
|
|
|
1476
1421
|
get state() {
|
|
1477
1422
|
return state;
|
|
1478
1423
|
},
|
|
1479
|
-
get textarea() {
|
|
1480
|
-
return textarea;
|
|
1481
|
-
},
|
|
1482
1424
|
toggleComment: () => editable(() => toggleComment(model, options.lineComment ?? false, options.blockComment ?? ['<!--', '-->'])),
|
|
1483
1425
|
undo: () => editable(() => model.undo()),
|
|
1484
1426
|
undoSelection: () => {
|
|
@@ -1515,7 +1457,7 @@ const view = (model, callbacks, receive) => {
|
|
|
1515
1457
|
cache: () => syntaxCache(model, 'markdown'),
|
|
1516
1458
|
capture,
|
|
1517
1459
|
controller: controller,
|
|
1518
|
-
deleteVisible: (backwards, word) => deleteCharacter(model, backwards,
|
|
1460
|
+
deleteVisible: (backwards, word) => word ? deleteCharacter(model, backwards, true) : erase(backwards),
|
|
1519
1461
|
get document() {
|
|
1520
1462
|
return model;
|
|
1521
1463
|
},
|
|
@@ -1531,80 +1473,97 @@ const view = (model, callbacks, receive) => {
|
|
|
1531
1473
|
let field = {
|
|
1532
1474
|
'aria-describedby': help,
|
|
1533
1475
|
'aria-label': () => ui.label,
|
|
1534
|
-
|
|
1535
|
-
|
|
1476
|
+
'aria-multiline': 'true',
|
|
1477
|
+
'aria-placeholder': () => ui.placeholder,
|
|
1478
|
+
'aria-readonly': () => ui.readonly ? 'true' : 'false',
|
|
1479
|
+
autocapitalize: 'off',
|
|
1480
|
+
class: 'markdown-editor-content',
|
|
1481
|
+
contenteditable: () => ui.readonly ? 'false' : 'true',
|
|
1482
|
+
'data-placeholder': () => ui.placeholder,
|
|
1536
1483
|
onbeforeinput: (e) => {
|
|
1537
|
-
|
|
1484
|
+
let type = e.inputType;
|
|
1485
|
+
if (ime.busy() || e.isComposing || type === 'insertCompositionText' || type === 'deleteCompositionText' || type === 'insertFromComposition') {
|
|
1538
1486
|
return;
|
|
1539
1487
|
}
|
|
1540
|
-
|
|
1541
|
-
revealFolds(!e.inputType.startsWith('history') && !options.readonly);
|
|
1542
|
-
before = { end: textarea.selectionEnd, length: textarea.textLength, start: textarea.selectionStart };
|
|
1543
|
-
beforeRanges = model.selections;
|
|
1544
|
-
beforeSelection = model.selection;
|
|
1545
|
-
inputData = e.data;
|
|
1546
|
-
inputType = e.inputType;
|
|
1547
|
-
if (e.inputType === 'historyUndo' || e.inputType === 'historyRedo') {
|
|
1548
|
-
if (e.cancelable) {
|
|
1549
|
-
e.preventDefault();
|
|
1550
|
-
e.inputType === 'historyUndo' ? controller.undo() : controller.redo();
|
|
1551
|
-
}
|
|
1488
|
+
if (!e.cancelable) {
|
|
1552
1489
|
return;
|
|
1553
1490
|
}
|
|
1554
|
-
|
|
1491
|
+
e.preventDefault();
|
|
1492
|
+
if (options.readonly) {
|
|
1555
1493
|
return;
|
|
1556
1494
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1495
|
+
capture();
|
|
1496
|
+
revealFolds(!type.startsWith('history'));
|
|
1497
|
+
switch (type) {
|
|
1498
|
+
case 'deleteContentBackward':
|
|
1499
|
+
case 'deleteContentForward':
|
|
1500
|
+
editable(() => erase(type === 'deleteContentBackward'));
|
|
1561
1501
|
return;
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1502
|
+
case 'deleteWordBackward':
|
|
1503
|
+
case 'deleteWordForward':
|
|
1504
|
+
editable(() => deleteCharacter(model, type === 'deleteWordBackward', true));
|
|
1505
|
+
return;
|
|
1506
|
+
case 'formatBold':
|
|
1507
|
+
controller.bold();
|
|
1508
|
+
return;
|
|
1509
|
+
case 'formatItalic':
|
|
1510
|
+
controller.italic();
|
|
1511
|
+
return;
|
|
1512
|
+
case 'historyRedo':
|
|
1513
|
+
controller.redo();
|
|
1514
|
+
return;
|
|
1515
|
+
case 'historyUndo':
|
|
1516
|
+
controller.undo();
|
|
1517
|
+
return;
|
|
1518
|
+
case 'insertLineBreak':
|
|
1519
|
+
editable(() => insertText(model, model.eol, 'input'));
|
|
1568
1520
|
return;
|
|
1521
|
+
case 'insertParagraph':
|
|
1522
|
+
controller.newline();
|
|
1523
|
+
return;
|
|
1524
|
+
case 'insertReplacementText': {
|
|
1525
|
+
let range = e.getTargetRanges()[0], from = range ? sourceAt(range.startContainer, range.startOffset) : null, to = range ? sourceAt(range.endContainer, range.endOffset) : null;
|
|
1526
|
+
if (from !== null && to !== null) {
|
|
1527
|
+
model.select({ end: Math.max(from, to), start: Math.min(from, to) });
|
|
1528
|
+
}
|
|
1529
|
+
break;
|
|
1569
1530
|
}
|
|
1570
1531
|
}
|
|
1571
|
-
if (
|
|
1572
|
-
e.
|
|
1573
|
-
|
|
1532
|
+
if (type.startsWith('delete')) {
|
|
1533
|
+
let range = e.getTargetRanges()[0], from = range ? sourceAt(range.startContainer, range.startOffset) : null, to = range ? sourceAt(range.endContainer, range.endOffset) : null;
|
|
1534
|
+
if (from !== null && to !== null && from !== to) {
|
|
1535
|
+
editable(() => remove({ from: Math.min(from, to), to: Math.max(from, to) }));
|
|
1536
|
+
}
|
|
1537
|
+
return;
|
|
1574
1538
|
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1539
|
+
let text = e.data ?? e.dataTransfer?.getData('text/plain') ?? '';
|
|
1540
|
+
if (text) {
|
|
1541
|
+
typed(text);
|
|
1577
1542
|
}
|
|
1578
1543
|
},
|
|
1579
|
-
oncompositionend:
|
|
1544
|
+
oncompositionend: (e) => {
|
|
1545
|
+
composed = e.data ?? '';
|
|
1546
|
+
ime.attributes.oncompositionend();
|
|
1547
|
+
},
|
|
1580
1548
|
oncompositionstart: ime.attributes.oncompositionstart,
|
|
1581
1549
|
oncopy: (e) => clip(e, false),
|
|
1582
1550
|
oncut: (e) => clip(e, true),
|
|
1583
1551
|
ondragstart: gestures.ondragstart,
|
|
1584
1552
|
onfocus: () => {
|
|
1585
|
-
|
|
1586
|
-
|
|
1553
|
+
let native = content?.ownerDocument.getSelection();
|
|
1554
|
+
if (!native?.anchorNode || !content?.contains(native.anchorNode)) {
|
|
1555
|
+
place();
|
|
1587
1556
|
}
|
|
1588
|
-
capture();
|
|
1589
1557
|
},
|
|
1590
1558
|
oninput: (e) => {
|
|
1591
|
-
if (writing) {
|
|
1592
|
-
return;
|
|
1593
|
-
}
|
|
1594
1559
|
if (ime.input(e)) {
|
|
1595
|
-
if (textarea && textarea.scrollHeight > ui.height) {
|
|
1596
|
-
ui.height = textarea.scrollHeight;
|
|
1597
|
-
}
|
|
1598
1560
|
return;
|
|
1599
1561
|
}
|
|
1600
|
-
|
|
1601
|
-
e.inputType === 'historyUndo' ? controller.undo() : controller.redo();
|
|
1602
|
-
return;
|
|
1603
|
-
}
|
|
1604
|
-
accept();
|
|
1562
|
+
invalidate(model.selection.start);
|
|
1605
1563
|
},
|
|
1606
1564
|
onkeydown: (e) => {
|
|
1607
1565
|
gestures.alt(e);
|
|
1566
|
+
linking(e);
|
|
1608
1567
|
if (ime.busy() || e.isComposing || e.keyCode === 229) {
|
|
1609
1568
|
return;
|
|
1610
1569
|
}
|
|
@@ -1638,56 +1597,22 @@ const view = (model, callbacks, receive) => {
|
|
|
1638
1597
|
run(command, e);
|
|
1639
1598
|
return;
|
|
1640
1599
|
}
|
|
1641
|
-
if (
|
|
1642
|
-
if (e.altKey || !NAVIGATION.test(e.key)) {
|
|
1643
|
-
return;
|
|
1644
|
-
}
|
|
1645
|
-
if (/^(End|Home)$/.test(e.key) || (apple && /^Arrow(Down|Up)$/.test(e.key))) {
|
|
1646
|
-
e.preventDefault();
|
|
1647
|
-
moveSelection(e.key, e.shiftKey, false, false, true);
|
|
1648
|
-
}
|
|
1649
|
-
else if (model.selections.length > 1 || (/^Arrow(Left|Right)$/.test(e.key) && leaves(e.key))) {
|
|
1650
|
-
e.preventDefault();
|
|
1651
|
-
moveSelection(e.key, e.shiftKey, true);
|
|
1652
|
-
}
|
|
1653
|
-
return;
|
|
1654
|
-
}
|
|
1655
|
-
if (e.key === 'Tab' && !e.altKey && options.captureTab !== false && !options.readonly) {
|
|
1656
|
-
e.preventDefault();
|
|
1657
|
-
e.shiftKey ? controller.outdent() : controller.indent();
|
|
1658
|
-
}
|
|
1659
|
-
else if (e.key === 'Enter' && !e.altKey && !options.readonly) {
|
|
1660
|
-
e.preventDefault();
|
|
1661
|
-
controller.newline();
|
|
1662
|
-
}
|
|
1663
|
-
else if ((e.key === 'Backspace' || e.key === 'Delete') && !options.readonly && model.selections.length > 1) {
|
|
1600
|
+
if (NAVIGATION.test(e.key) && !e.altKey && model.selections.length > 1) {
|
|
1664
1601
|
e.preventDefault();
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
: deleteCharacter(model, e.key === 'Backspace', e.altKey));
|
|
1602
|
+
moveSelection(e.key, e.shiftKey, mod);
|
|
1603
|
+
return;
|
|
1668
1604
|
}
|
|
1669
|
-
|
|
1670
|
-
let
|
|
1671
|
-
if (
|
|
1672
|
-
e.preventDefault();
|
|
1673
|
-
}
|
|
1674
|
-
else if (e.key === 'Backspace' && collapsed && selection.start === active.from && active.from > 0) {
|
|
1675
|
-
e.preventDefault();
|
|
1676
|
-
editable(() => deleteCharacter(model, true, e.altKey));
|
|
1677
|
-
}
|
|
1678
|
-
else if (e.key === 'Delete' && collapsed && selection.end === active.to && active.to < model.value.length) {
|
|
1605
|
+
if (e.key === 'Tab' && !e.altKey && !mod && options.captureTab !== false && !options.readonly) {
|
|
1606
|
+
let kind = kindAt(model.selection.start);
|
|
1607
|
+
if (kind === 'code' || kind === 'fence' || kind === 'list') {
|
|
1679
1608
|
e.preventDefault();
|
|
1680
|
-
|
|
1609
|
+
e.shiftKey ? controller.outdent() : controller.indent();
|
|
1681
1610
|
}
|
|
1682
1611
|
}
|
|
1683
|
-
else if (NAVIGATION.test(e.key) && (model.selections.length > 1 || e.key.startsWith('Page') || leaves(e.key))) {
|
|
1684
|
-
e.preventDefault();
|
|
1685
|
-
moveSelection(e.key, e.shiftKey, e.altKey);
|
|
1686
|
-
}
|
|
1687
1612
|
},
|
|
1688
1613
|
onkeyup: (e) => {
|
|
1689
1614
|
gestures.alt(e);
|
|
1690
|
-
|
|
1615
|
+
linking(e);
|
|
1691
1616
|
},
|
|
1692
1617
|
onpaste: (e) => {
|
|
1693
1618
|
if (ime.busy() || options.readonly || !e.clipboardData) {
|
|
@@ -1697,27 +1622,19 @@ const view = (model, callbacks, receive) => {
|
|
|
1697
1622
|
let text = read(e.clipboardData, model.selections.length);
|
|
1698
1623
|
editable(() => insertText(model, text, 'paste'));
|
|
1699
1624
|
},
|
|
1700
|
-
|
|
1701
|
-
goals = [];
|
|
1702
|
-
pinned = true;
|
|
1703
|
-
},
|
|
1704
|
-
onpointerup: () => {
|
|
1705
|
-
pinned = false;
|
|
1706
|
-
capture();
|
|
1707
|
-
},
|
|
1708
|
-
onselect: capture,
|
|
1709
|
-
onselectionchange: capture,
|
|
1710
|
-
placeholder: () => ui.placeholder,
|
|
1711
|
-
readOnly: () => ui.readonly,
|
|
1625
|
+
role: 'textbox',
|
|
1712
1626
|
spellcheck: () => ui.spellcheck,
|
|
1713
|
-
|
|
1714
|
-
wrap: () => ui.wrap ? 'soft' : 'off'
|
|
1627
|
+
tabindex: '0'
|
|
1715
1628
|
};
|
|
1716
1629
|
let body = {
|
|
1717
|
-
'aria-label': () => ui.label,
|
|
1718
1630
|
onclick: (e) => {
|
|
1719
|
-
|
|
1720
|
-
|
|
1631
|
+
let link = e.target.closest('a');
|
|
1632
|
+
if (!link) {
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
e.preventDefault();
|
|
1636
|
+
if ((e.ctrlKey || e.metaKey) && link.href) {
|
|
1637
|
+
window.open(link.href, '_blank', 'noopener');
|
|
1721
1638
|
}
|
|
1722
1639
|
},
|
|
1723
1640
|
onconnect: (element) => {
|
|
@@ -1728,113 +1645,95 @@ const view = (model, callbacks, receive) => {
|
|
|
1728
1645
|
ondragleave: gestures.ondragleave,
|
|
1729
1646
|
ondragover: gestures.ondragover,
|
|
1730
1647
|
ondrop: gestures.ondrop,
|
|
1731
|
-
|
|
1732
|
-
if (e.target === surface) {
|
|
1733
|
-
controller.focus();
|
|
1734
|
-
}
|
|
1735
|
-
},
|
|
1736
|
-
onlostpointercapture: () => {
|
|
1737
|
-
gestures.end();
|
|
1738
|
-
finish();
|
|
1739
|
-
},
|
|
1648
|
+
onlostpointercapture: gestures.end,
|
|
1740
1649
|
onmousedown: (e) => {
|
|
1741
|
-
if (e.
|
|
1650
|
+
if (e.button !== 0 || ime.busy() || (e.target !== surface && !e.target.classList.contains('markdown-editor-spacer'))) {
|
|
1742
1651
|
return;
|
|
1743
1652
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
gestures.end();
|
|
1748
|
-
finish();
|
|
1653
|
+
e.preventDefault();
|
|
1654
|
+
controller.focus();
|
|
1655
|
+
model.select({ start: offsetAt(e.clientX, e.clientY) ?? model.value.length });
|
|
1749
1656
|
},
|
|
1657
|
+
onpointercancel: gestures.end,
|
|
1750
1658
|
onpointerdown: (e) => {
|
|
1751
|
-
|
|
1659
|
+
tip.release();
|
|
1752
1660
|
gestures.onpointerdown(e);
|
|
1753
1661
|
},
|
|
1662
|
+
onpointerleave: () => tip.release(),
|
|
1754
1663
|
onpointermove: (e) => {
|
|
1755
1664
|
gestures.onpointermove(e);
|
|
1756
|
-
|
|
1757
|
-
|
|
1665
|
+
linking(e);
|
|
1666
|
+
},
|
|
1667
|
+
onpointerover: (e) => {
|
|
1668
|
+
let link = e.target.closest('a.markdown-editor-link[href]');
|
|
1669
|
+
if (link && e.pointerType !== 'touch') {
|
|
1670
|
+
tip.request(link, apple ? '⌘+Click to open' : 'Ctrl+Click to open');
|
|
1758
1671
|
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
drag.head = offset;
|
|
1762
|
-
schedule();
|
|
1672
|
+
else {
|
|
1673
|
+
tip.release();
|
|
1763
1674
|
}
|
|
1764
1675
|
},
|
|
1765
|
-
onpointerup:
|
|
1766
|
-
pinned = false;
|
|
1767
|
-
pointerId = -1;
|
|
1768
|
-
gestures.end();
|
|
1769
|
-
finish();
|
|
1770
|
-
},
|
|
1676
|
+
onpointerup: gestures.end,
|
|
1771
1677
|
onscroll: () => {
|
|
1772
1678
|
metrics.scrollLeft = surface.scrollLeft;
|
|
1773
1679
|
metrics.scrollTop = surface.scrollTop;
|
|
1774
1680
|
schedule();
|
|
1775
|
-
}
|
|
1776
|
-
tabindex: () => ui.editing ? -1 : 0
|
|
1681
|
+
}
|
|
1777
1682
|
};
|
|
1778
1683
|
let template = (attributes) => {
|
|
1779
|
-
let
|
|
1780
|
-
template_u1.slot(
|
|
1781
|
-
template_u1.slot(
|
|
1782
|
-
|
|
1783
|
-
let
|
|
1784
|
-
template_u1.setList(
|
|
1785
|
-
template_u1.setList(
|
|
1786
|
-
return
|
|
1684
|
+
let root_1ayo7z93 = template_1ayo7z94(), element_1ayo7z95 = root_1ayo7z93.firstChild, element_1ayo7z96 = element_1ayo7z95.firstChild, element_1ayo7z97 = element_1ayo7z96.nextSibling, element_1ayo7z98 = element_1ayo7z95.firstElementChild, element_1ayo7z99 = element_1ayo7z98.firstElementChild, element_1ayo7z9a = element_1ayo7z99.firstElementChild, element_1ayo7z9b = element_1ayo7z9a.nextElementSibling, element_1ayo7z9c = element_1ayo7z98.firstChild.nextSibling, element_1ayo7z9d = element_1ayo7z99.nextElementSibling, element_1ayo7z9e = element_1ayo7z98.nextElementSibling;
|
|
1685
|
+
template_u1.slot(element_1ayo7z96, search.template());
|
|
1686
|
+
template_u1.slot(element_1ayo7z97, jump.template());
|
|
1687
|
+
element_1ayo7z9a.appendChild(new template_u1.ArraySlot(decorations, (decoration) => {
|
|
1688
|
+
let root_1ayo7z9f = template_1ayo7z9g(), element_1ayo7z9h = root_1ayo7z9f.firstChild;
|
|
1689
|
+
template_u1.setList(element_1ayo7z9h, 'class', () => decoration.kind);
|
|
1690
|
+
template_u1.setList(element_1ayo7z9h, 'style', () => decoration.style);
|
|
1691
|
+
return root_1ayo7z9f;
|
|
1787
1692
|
}, true).fragment);
|
|
1788
|
-
element_1ayo7z9b.
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1693
|
+
element_1ayo7z9b.appendChild(new template_u1.ArraySlot(items, (item) => 'block' in item
|
|
1694
|
+
? draw.template(item)
|
|
1695
|
+
: (() => {
|
|
1696
|
+
let root_1ayo7z9i = template_1ayo7z9j(), element_1ayo7z9k = root_1ayo7z9i.firstChild;
|
|
1697
|
+
template_u1.setList(element_1ayo7z9k, 'style', () => `height: ${item.height}px;`);
|
|
1698
|
+
return root_1ayo7z9i;
|
|
1699
|
+
})(), true).fragment);
|
|
1700
|
+
template_u1.slot(element_1ayo7z9c, map.template());
|
|
1701
|
+
template_u1.slot(element_1ayo7z95, tip.render(), 2);
|
|
1702
|
+
template_u1.setProperty(element_1ayo7z9e, 'id', help);
|
|
1703
|
+
template_u1.onconnect(element_1ayo7z9d, (element) => {
|
|
1794
1704
|
ruler = element;
|
|
1795
1705
|
connect();
|
|
1796
1706
|
});
|
|
1797
|
-
template_u1.
|
|
1798
|
-
template_u1.
|
|
1799
|
-
|
|
1800
|
-
template_u1.onconnect(element_1ayo7z9f, (element) => {
|
|
1801
|
-
textarea = element;
|
|
1707
|
+
template_u1.setProperties(element_1ayo7z9b, field);
|
|
1708
|
+
template_u1.onconnect(element_1ayo7z9b, (element) => {
|
|
1709
|
+
content = element;
|
|
1802
1710
|
connect();
|
|
1803
1711
|
});
|
|
1804
|
-
template_u1.
|
|
1805
|
-
template_u1.
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
});
|
|
1810
|
-
template_u1.delegate(element_1ayo7z9e, 'mousedown', prevent);
|
|
1811
|
-
template_u1.setList(element_1ayo7z9d, 'class', () => ui.editing && '--active');
|
|
1812
|
-
template_u1.setList(element_1ayo7z9c, 'style', () => `height: ${ui.between}px;`);
|
|
1813
|
-
template_u1.setList(element_1ayo7z9a, 'style', () => `height: ${ui.top}px;`);
|
|
1814
|
-
template_u1.setProperties(element_1ayo7z98, body);
|
|
1815
|
-
template_u1.setProperties(element_1ayo7z97, size);
|
|
1816
|
-
template_u1.setProperties(element_1ayo7z94, attributes);
|
|
1817
|
-
template_u1.setList(element_1ayo7z94, 'class', [
|
|
1712
|
+
template_u1.setProperties(element_1ayo7z99, body);
|
|
1713
|
+
template_u1.setProperties(element_1ayo7z99, scrollbar());
|
|
1714
|
+
template_u1.setProperties(element_1ayo7z98, size);
|
|
1715
|
+
template_u1.setProperties(element_1ayo7z95, attributes);
|
|
1716
|
+
template_u1.setList(element_1ayo7z95, 'class', [
|
|
1818
1717
|
() => ime.state.composing && 'markdown-editor--composing',
|
|
1819
1718
|
() => gestures.state.crosshair && 'markdown-editor--crosshair',
|
|
1719
|
+
() => ui.empty && 'markdown-editor--empty',
|
|
1720
|
+
() => ui.linking && 'markdown-editor--linking',
|
|
1721
|
+
() => ui.fold && 'markdown-editor--fold',
|
|
1820
1722
|
() => ui.minimap && 'markdown-editor--minimap',
|
|
1821
1723
|
() => !ui.wrap && 'markdown-editor--nowrap',
|
|
1822
1724
|
() => ui.readonly && 'markdown-editor--readonly'
|
|
1823
1725
|
]);
|
|
1824
|
-
template_u1.onconnect(
|
|
1726
|
+
template_u1.onconnect(element_1ayo7z95, (element) => {
|
|
1825
1727
|
host = element;
|
|
1826
1728
|
connect();
|
|
1827
1729
|
});
|
|
1828
|
-
template_u1.ondisconnect(
|
|
1829
|
-
template_u1.
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
capture();
|
|
1833
|
-
deactivate();
|
|
1834
|
-
}
|
|
1730
|
+
template_u1.ondisconnect(element_1ayo7z95, () => controller.dispose());
|
|
1731
|
+
template_u1.ondocument(element_1ayo7z95, 'selectionchange', capture);
|
|
1732
|
+
template_u1.onwindow(element_1ayo7z95, 'blur', () => {
|
|
1733
|
+
ui.linking = false;
|
|
1835
1734
|
});
|
|
1836
|
-
template_u1.setList(
|
|
1837
|
-
return
|
|
1735
|
+
template_u1.setList(element_1ayo7z95, 'style', () => `--tab-size: ${ui.tabSize};`);
|
|
1736
|
+
return root_1ayo7z93;
|
|
1838
1737
|
};
|
|
1839
1738
|
return { controller, template };
|
|
1840
1739
|
};
|