create-basicjs 0.1.3 → 0.1.5
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 +2 -2
- package/bin/create-basicjs.js +31 -4
- package/bin/verify-package.js +1 -1
- package/package.json +2 -2
- package/payload/starter/AGENTS.md +11 -6
- package/payload/starter/README.md +1 -1
- package/payload/starter/_basic/VERSION +1 -1
- package/payload/starter/_basic/assets/cards/almond-blossom.png +0 -0
- package/payload/starter/_basic/assets/cards/blackberry.png +0 -0
- package/payload/starter/_basic/assets/cards/borage.png +0 -0
- package/payload/starter/_basic/assets/cards/chamomile.png +0 -0
- package/payload/starter/_basic/assets/cards/dill.png +0 -0
- package/payload/starter/_basic/assets/cards/eucalyptus.png +0 -0
- package/payload/starter/_basic/assets/cards/fennel.png +0 -0
- package/payload/starter/_basic/assets/cards/fig.png +0 -0
- package/payload/starter/_basic/assets/cards/juniper.png +0 -0
- package/payload/starter/_basic/assets/cards/lavender.png +0 -0
- package/payload/starter/_basic/assets/cards/lemon.png +0 -0
- package/payload/starter/_basic/assets/cards/olives.png +0 -0
- package/payload/starter/_basic/assets/cards/oregano.png +0 -0
- package/payload/starter/_basic/assets/cards/pepper.png +0 -0
- package/payload/starter/_basic/assets/cards/physalis.png +0 -0
- package/payload/starter/_basic/assets/cards/pomegranate.png +0 -0
- package/payload/starter/_basic/assets/cards/poppy.png +0 -0
- package/payload/starter/_basic/assets/cards/rosehip.png +0 -0
- package/payload/starter/_basic/assets/cards/saffron.png +0 -0
- package/payload/starter/_basic/assets/categories/cappuccino.png +0 -0
- package/payload/starter/_basic/assets/categories/chocolate-milk.png +0 -0
- package/payload/starter/_basic/assets/categories/coffee.png +0 -0
- package/payload/starter/_basic/assets/categories/frappe.png +0 -0
- package/payload/starter/_basic/assets/categories/iced-caffee.png +0 -0
- package/payload/starter/_basic/assets/categories/milkshake.png +0 -0
- package/payload/starter/_basic/assets/categories/orange-juice.png +0 -0
- package/payload/starter/_basic/assets/categories/tea.png +0 -0
- package/payload/starter/_basic/assets/fruids/brokoli.png +0 -0
- package/payload/starter/_basic/assets/fruids/cilek.png +0 -0
- package/payload/starter/_basic/assets/fruids/domates.png +0 -0
- package/payload/starter/_basic/assets/fruids/elma.png +0 -0
- package/payload/starter/_basic/assets/fruids/havuc.png +0 -0
- package/payload/starter/_basic/assets/fruids/karpuz.png +0 -0
- package/payload/starter/_basic/assets/fruids/limon.png +0 -0
- package/payload/starter/_basic/assets/fruids/muz.png +0 -0
- package/payload/starter/_basic/assets/fruids/nar.png +0 -0
- package/payload/starter/_basic/assets/fruids/patlican.png +0 -0
- package/payload/starter/_basic/assets/fruids/yabanmersini.png +0 -0
- package/payload/starter/_basic/assets/fruids/yesilbiber.png +0 -0
- package/payload/starter/_basic/basic/LICENSE +1 -1
- package/payload/starter/_basic/basic/basic.css +3 -6
- package/payload/starter/_basic/basic/basic.js +154 -60
- package/payload/starter/_basic/basic/basic.min.js +19 -6
- package/payload/starter/_basic/basic/scroll-bar.js +4 -2
- package/payload/starter/_basic/basic/scroll-bar.min.js +1 -0
- package/payload/starter/_basic/comp/accordion.js +659 -0
- package/payload/starter/_basic/comp/action-button.js +22 -23
- package/payload/starter/_basic/comp/action-tab-bar.js +8 -8
- package/payload/starter/_basic/comp/app-bar.js +12 -11
- package/payload/starter/_basic/comp/{badge-v2.js → badge.js} +51 -5
- package/payload/starter/_basic/comp/bottom-bar.js +31 -23
- package/payload/starter/_basic/comp/breadcrumbs.js +4 -2
- package/payload/starter/_basic/comp/canvas.js +652 -0
- package/payload/starter/_basic/comp/chat-view.js +827 -0
- package/payload/starter/_basic/comp/check-box.js +137 -21
- package/payload/starter/_basic/comp/code-editor.js +953 -0
- package/payload/starter/_basic/comp/{select-color.js → color-picker.js} +62 -29
- package/payload/starter/_basic/comp/context-menu.js +342 -30
- package/payload/starter/_basic/comp/{currency-input-b.js → currency-field.js} +48 -29
- package/payload/starter/_basic/comp/data-table.js +114 -42
- package/payload/starter/_basic/comp/{select-date.js → date-picker.js} +104 -52
- package/payload/starter/_basic/comp/dialog.js +214 -76
- package/payload/starter/_basic/comp/email-field.js +65 -0
- package/payload/starter/_basic/comp/{select-file.js → file-picker.js} +245 -57
- package/payload/starter/_basic/comp/filters.js +374 -60
- package/payload/starter/_basic/comp/form.js +38 -26
- package/payload/starter/_basic/comp/full-screen-select.js +36 -33
- package/payload/starter/_basic/comp/gauge.js +12 -8
- package/payload/starter/_basic/comp/graph-box.js +3911 -0
- package/payload/starter/_basic/comp/grid-group.js +185 -0
- package/payload/starter/_basic/comp/hold-to-confirm-button.js +16 -7
- package/payload/starter/_basic/comp/image-view.js +598 -0
- package/payload/starter/_basic/comp/item-list.js +507 -163
- package/payload/starter/_basic/comp/json-editor.js +3221 -0
- package/payload/starter/_basic/comp/json-view.js +597 -0
- package/payload/starter/_basic/comp/label-editor.js +22 -19
- package/payload/starter/_basic/comp/left-menu.js +97 -25
- package/payload/starter/_basic/comp/line-progress-bar.js +196 -45
- package/payload/starter/_basic/comp/loading-screen.js +49 -18
- package/payload/starter/_basic/comp/log-view.js +530 -0
- package/payload/starter/_basic/comp/{login-page-v2.js → login-page.js} +205 -106
- package/payload/starter/_basic/comp/markdown-view.js +1044 -0
- package/payload/starter/_basic/comp/menu-bar.js +624 -0
- package/payload/starter/_basic/comp/mini-graph-box.js +20 -11
- package/payload/starter/_basic/comp/minimal-accent.js +208 -0
- package/payload/starter/_basic/comp/notice.js +15 -13
- package/payload/starter/_basic/comp/{number-input-b.js → number-field.js} +26 -19
- package/payload/starter/_basic/comp/numeric-keyboard.js +15 -13
- package/payload/starter/_basic/comp/page-control.js +21 -4
- package/payload/starter/_basic/comp/page-header.js +7 -6
- package/payload/starter/_basic/comp/password-field.js +192 -0
- package/payload/starter/_basic/comp/period-bar.js +8 -7
- package/payload/starter/_basic/comp/{phone-input-b.js → phone-field.js} +80 -45
- package/payload/starter/_basic/comp/progress-bar.js +401 -85
- package/payload/starter/_basic/comp/property-panel.js +1022 -123
- package/payload/starter/_basic/comp/radio-button.js +79 -19
- package/payload/starter/_basic/comp/range-slider.js +569 -0
- package/payload/starter/_basic/comp/rich-text-editor.js +33 -30
- package/payload/starter/_basic/comp/scroll-area.js +308 -0
- package/payload/starter/_basic/comp/scrolling-text.js +10 -9
- package/payload/starter/_basic/comp/search-input.js +725 -0
- package/payload/starter/_basic/comp/search-results.js +60 -24
- package/payload/starter/_basic/comp/select-box.js +229 -107
- package/payload/starter/_basic/comp/settings-row.js +20 -19
- package/payload/starter/_basic/comp/side-panel.js +53 -10
- package/payload/starter/_basic/comp/slider-field.js +264 -88
- package/payload/starter/_basic/comp/slider.js +541 -86
- package/payload/starter/_basic/comp/smart-button.js +433 -352
- package/payload/starter/_basic/comp/smart-table.js +740 -185
- package/payload/starter/_basic/comp/sortable-list.js +47 -38
- package/payload/starter/_basic/comp/spark-line-box.js +25 -16
- package/payload/starter/_basic/comp/splitter.js +411 -0
- package/payload/starter/_basic/comp/status-bar.js +408 -0
- package/payload/starter/_basic/comp/step-bar.js +345 -0
- package/payload/starter/_basic/comp/stepper.js +77 -49
- package/payload/starter/_basic/comp/tabs.js +67 -18
- package/payload/starter/_basic/comp/tag-input.js +50 -10
- package/payload/starter/_basic/comp/tap-effect.js +6 -4
- package/payload/starter/_basic/comp/text-area-field.js +233 -0
- package/payload/starter/_basic/comp/text-field.js +1006 -0
- package/payload/starter/_basic/comp/time-line.js +102 -28
- package/payload/starter/_basic/comp/{select-time.js → time-picker.js} +104 -51
- package/payload/starter/_basic/comp/tiny-select.js +79 -39
- package/payload/starter/_basic/comp/tiny-table.js +12 -8
- package/payload/starter/_basic/comp/toast.js +87 -34
- package/payload/starter/_basic/comp/toggle.js +147 -27
- package/payload/starter/_basic/comp/tool-bar.js +760 -0
- package/payload/starter/_basic/comp/tooltip.js +80 -17
- package/payload/starter/_basic/comp/tree-view.js +124 -41
- package/payload/starter/_basic/comp/ui-effects.js +17 -11
- package/payload/starter/_basic/comp/ui-standards.js +5 -4
- package/payload/starter/_basic/comp/url-field.js +190 -0
- package/payload/starter/_basic/comp/web-view.js +70 -16
- package/payload/starter/_basic/docs/basic-js-animated-rules.md +15 -9
- package/payload/starter/_basic/docs/basic-js-code-rules.md +42 -5
- package/payload/starter/_basic/docs/basic-js-components.md +12 -17
- package/payload/starter/_basic/docs/basic-js-core.md +5 -4
- package/payload/starter/_basic/docs/component-index.md +245 -104
- package/payload/starter/_basic/docs/component-template.js +28 -24
- package/payload/starter/_basic/docs/handbook/00-introduction.md +6 -2
- package/payload/starter/_basic/docs/handbook/00-what-is-new.md +21 -0
- package/payload/starter/_basic/docs/handbook/01-label.md +4 -4
- package/payload/starter/_basic/docs/handbook/02-box.md +7 -7
- package/payload/starter/_basic/docs/handbook/03-image.md +4 -4
- package/payload/starter/_basic/docs/handbook/04-common-properties.md +6 -5
- package/payload/starter/_basic/docs/handbook/05-autolayout.md +8 -7
- package/payload/starter/_basic/docs/handbook/06-button.md +3 -3
- package/payload/starter/_basic/docs/handbook/07-input.md +3 -3
- package/payload/starter/_basic/docs/handbook/08-page.md +3 -3
- package/payload/starter/_basic/docs/handbook/09-useful-examples.md +39 -58
- package/payload/starter/_basic/docs/handbook/10-motion.md +6 -6
- package/payload/starter/_basic/docs/handbook/11-other-functions.md +1 -0
- package/payload/starter/_basic/docs/handbook/13-sound.md +3 -3
- package/payload/starter/_basic/docs/handbook/14-using-components.md +180 -0
- package/payload/starter/_basic/docs/handbook/15-making-a-component.md +338 -0
- package/payload/starter/_basic/docs/what-is-new.md +106 -0
- package/payload/starter/_basic/examples/accordion.htm +174 -0
- package/payload/starter/_basic/examples/action-button.htm +74 -32
- package/payload/starter/_basic/examples/action-tab-bar.htm +5 -6
- package/payload/starter/_basic/examples/app-bar.htm +63 -41
- package/payload/starter/_basic/examples/badge.htm +96 -0
- package/payload/starter/_basic/examples/bottom-bar-2.htm +61 -48
- package/payload/starter/_basic/examples/bottom-bar.htm +74 -16
- package/payload/starter/_basic/examples/breadcrumbs.htm +160 -150
- package/payload/starter/_basic/examples/canvas.htm +190 -0
- package/payload/starter/_basic/examples/chat-view.htm +143 -0
- package/payload/starter/_basic/examples/check-box-2.htm +71 -82
- package/payload/starter/_basic/examples/check-box-3.htm +72 -83
- package/payload/starter/_basic/examples/check-box.htm +207 -0
- package/payload/starter/_basic/examples/code-editor-2.htm +259 -0
- package/payload/starter/_basic/examples/code-editor.htm +225 -0
- package/payload/starter/_basic/examples/color-picker.htm +206 -0
- package/payload/starter/_basic/examples/context-menu.htm +180 -139
- package/payload/starter/_basic/examples/currency-field.htm +105 -0
- package/payload/starter/_basic/examples/data-table-2.htm +2 -1
- package/payload/starter/_basic/examples/data-table-3.htm +1 -1
- package/payload/starter/_basic/examples/data-table-4.htm +15 -12
- package/payload/starter/_basic/examples/data-table-5.htm +11 -3
- package/payload/starter/_basic/examples/data-table.htm +90 -40
- package/payload/starter/_basic/examples/date-picker.htm +239 -0
- package/payload/starter/_basic/examples/dialog-centered.htm +394 -40
- package/payload/starter/_basic/examples/dialog.htm +267 -46
- package/payload/starter/_basic/examples/email-field.htm +102 -0
- package/payload/starter/_basic/examples/file-picker.htm +296 -0
- package/payload/starter/_basic/examples/filters.htm +33 -22
- package/payload/starter/_basic/examples/{form-1.htm → form.htm} +18 -19
- package/payload/starter/_basic/examples/full-screen-select.htm +81 -58
- package/payload/starter/_basic/examples/gauge.htm +95 -81
- package/payload/starter/_basic/examples/graph-box.htm +365 -0
- package/payload/starter/_basic/examples/grid-group.htm +179 -0
- package/payload/starter/_basic/examples/hold-to-confirm-button.htm +102 -113
- package/payload/starter/_basic/examples/image-view.htm +195 -0
- package/payload/starter/_basic/examples/item-list-2.htm +138 -94
- package/payload/starter/_basic/examples/item-list.htm +191 -86
- package/payload/starter/_basic/examples/json-editor.htm +206 -0
- package/payload/starter/_basic/examples/json-view.htm +153 -0
- package/payload/starter/_basic/examples/label-editor.htm +85 -89
- package/payload/starter/_basic/examples/left-menu-2.htm +93 -0
- package/payload/starter/_basic/examples/left-menu.htm +42 -37
- package/payload/starter/_basic/examples/line-progress-bar.htm +155 -114
- package/payload/starter/_basic/examples/loading-screen.htm +149 -125
- package/payload/starter/_basic/examples/log-view.htm +175 -0
- package/payload/starter/_basic/examples/{login-page-dark-v2.htm → login-page-dark.htm} +265 -267
- package/payload/starter/_basic/examples/{login-page-v2.htm → login-page.htm} +266 -267
- package/payload/starter/_basic/examples/markdown-view.htm +220 -0
- package/payload/starter/_basic/examples/menu-bar-2.htm +225 -0
- package/payload/starter/_basic/examples/menu-bar.htm +145 -0
- package/payload/starter/_basic/examples/mini-graph-box.htm +98 -109
- package/payload/starter/_basic/examples/minimal-accent.htm +196 -0
- package/payload/starter/_basic/examples/minimal-theme.htm +432 -0
- package/payload/starter/_basic/examples/notice.htm +13 -4
- package/payload/starter/_basic/examples/number-field.htm +103 -0
- package/payload/starter/_basic/examples/numeric-keyboard.htm +44 -42
- package/payload/starter/_basic/examples/page-control.htm +181 -130
- package/payload/starter/_basic/examples/page-header.htm +57 -30
- package/payload/starter/_basic/examples/password-field.htm +117 -0
- package/payload/starter/_basic/examples/period-bar.htm +43 -29
- package/payload/starter/_basic/examples/phone-field-select-country.htm +292 -0
- package/payload/starter/_basic/examples/phone-field.htm +104 -0
- package/payload/starter/_basic/examples/progress-bar-ozden.htm +229 -92
- package/payload/starter/_basic/examples/progress-bar.htm +222 -174
- package/payload/starter/_basic/examples/property-panel.htm +152 -52
- package/payload/starter/_basic/examples/radio-button-2.htm +101 -109
- package/payload/starter/_basic/examples/radio-button-3.htm +81 -71
- package/payload/starter/_basic/examples/radio-button.htm +289 -0
- package/payload/starter/_basic/examples/range-slider.htm +171 -0
- package/payload/starter/_basic/examples/rich-text-editor.htm +115 -110
- package/payload/starter/_basic/examples/scroll-area.htm +293 -0
- package/payload/starter/_basic/examples/scrolling-text.htm +27 -6
- package/payload/starter/_basic/examples/search-input-2-light.htm +112 -0
- package/payload/starter/_basic/examples/search-input-3-dark.htm +105 -0
- package/payload/starter/_basic/examples/{search-input-v2-place.htm → search-input-place.htm} +25 -26
- package/payload/starter/_basic/examples/search-input.htm +159 -0
- package/payload/starter/_basic/examples/search-results.htm +85 -88
- package/payload/starter/_basic/examples/select-box-ozden-dark-text.htm +70 -0
- package/payload/starter/_basic/examples/select-box-ozden-item.htm +6 -5
- package/payload/starter/_basic/examples/select-box-ozden-text.htm +5 -3
- package/payload/starter/_basic/examples/select-box.htm +190 -159
- package/payload/starter/_basic/examples/settings-row.htm +92 -43
- package/payload/starter/_basic/examples/side-panel-2.htm +63 -25
- package/payload/starter/_basic/examples/side-panel.htm +84 -70
- package/payload/starter/_basic/examples/slider-2-classic.htm +152 -0
- package/payload/starter/_basic/examples/slider-field-ozden.htm +286 -0
- package/payload/starter/_basic/examples/slider-field.htm +174 -134
- package/payload/starter/_basic/examples/slider.htm +257 -180
- package/payload/starter/_basic/examples/smart-button-3-ozden.htm +170 -257
- package/payload/starter/_basic/examples/smart-button-4-dark.htm +86 -47
- package/payload/starter/_basic/examples/smart-button-5-features.htm +130 -125
- package/payload/starter/_basic/examples/smart-button-alternatif.htm +266 -0
- package/payload/starter/_basic/examples/smart-button.htm +207 -174
- package/payload/starter/_basic/examples/smart-table-2.htm +43 -56
- package/payload/starter/_basic/examples/smart-table-3.htm +148 -113
- package/payload/starter/_basic/examples/smart-table-4.htm +37 -50
- package/payload/starter/_basic/examples/{smart-table-1.htm → smart-table-5.htm} +37 -48
- package/payload/starter/_basic/examples/smart-table.htm +183 -0
- package/payload/starter/_basic/examples/sortable-list.htm +191 -142
- package/payload/starter/_basic/examples/spark-line-box.htm +149 -161
- package/payload/starter/_basic/examples/splitter.htm +164 -0
- package/payload/starter/_basic/examples/status-bar.htm +166 -0
- package/payload/starter/_basic/examples/step-bar.htm +129 -0
- package/payload/starter/_basic/examples/stepper-2.htm +71 -59
- package/payload/starter/_basic/examples/stepper.htm +146 -135
- package/payload/starter/_basic/examples/tabs-2.htm +58 -67
- package/payload/starter/_basic/examples/tabs.htm +197 -180
- package/payload/starter/_basic/examples/tag-input.htm +150 -153
- package/payload/starter/_basic/examples/tap-effect.htm +23 -19
- package/payload/starter/_basic/examples/text-area-field.htm +104 -0
- package/payload/starter/_basic/examples/text-field-2.htm +113 -0
- package/payload/starter/_basic/examples/text-field-3-style.htm +105 -0
- package/payload/starter/_basic/examples/text-field-4-custom-unit.htm +96 -0
- package/payload/starter/_basic/examples/{input-b-ex5-warning-icon.htm → text-field-5-warning-icon.htm} +19 -19
- package/payload/starter/_basic/examples/text-field-6-modern-dark.htm +114 -0
- package/payload/starter/_basic/examples/text-field-7-modern.htm +106 -0
- package/payload/starter/_basic/examples/text-field-8-light-dark.htm +159 -0
- package/payload/starter/_basic/examples/text-field.htm +163 -0
- package/payload/starter/_basic/examples/time-line.htm +180 -116
- package/payload/starter/_basic/examples/time-picker.htm +240 -0
- package/payload/starter/_basic/examples/tiny-select.htm +118 -86
- package/payload/starter/_basic/examples/tiny-table.htm +40 -34
- package/payload/starter/_basic/examples/toast.htm +145 -147
- package/payload/starter/_basic/examples/toggle-2.htm +99 -68
- package/payload/starter/_basic/examples/toggle-3.htm +104 -101
- package/payload/starter/_basic/examples/toggle.htm +161 -93
- package/payload/starter/_basic/examples/tool-bar.htm +172 -0
- package/payload/starter/_basic/examples/tooltip-2.htm +110 -60
- package/payload/starter/_basic/examples/tooltip-3.htm +124 -65
- package/payload/starter/_basic/examples/tooltip-4.htm +218 -0
- package/payload/starter/_basic/examples/tooltip.htm +206 -124
- package/payload/starter/_basic/examples/tree-view.htm +210 -182
- package/payload/starter/_basic/examples/ui-effects.htm +207 -185
- package/payload/starter/_basic/examples/ui-standards.htm +200 -139
- package/payload/starter/_basic/examples/url-field.htm +120 -0
- package/payload/starter/_basic/examples/web-view.htm +109 -110
- package/payload/starter/_basic/min/accordion.min.js +2 -0
- package/payload/starter/_basic/min/action-button.min.js +1 -1
- package/payload/starter/_basic/min/app-bar.min.js +1 -1
- package/payload/starter/_basic/min/badge.min.js +2 -0
- package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
- package/payload/starter/_basic/min/canvas.min.js +2 -0
- package/payload/starter/_basic/min/chat-view.min.js +2 -0
- package/payload/starter/_basic/min/check-box.min.js +1 -1
- package/payload/starter/_basic/min/code-editor.min.js +2 -0
- package/payload/starter/_basic/min/color-picker.min.js +2 -0
- package/payload/starter/_basic/min/context-menu.min.js +1 -1
- package/payload/starter/_basic/min/currency-field.min.js +2 -0
- package/payload/starter/_basic/min/data-table.min.js +1 -1
- package/payload/starter/_basic/min/date-picker.min.js +2 -0
- package/payload/starter/_basic/min/dialog.min.js +1 -1
- package/payload/starter/_basic/min/email-field.min.js +2 -0
- package/payload/starter/_basic/min/file-picker.min.js +2 -0
- package/payload/starter/_basic/min/filters.min.js +1 -1
- package/payload/starter/_basic/min/form.min.js +1 -1
- package/payload/starter/_basic/min/full-screen-select.min.js +1 -1
- package/payload/starter/_basic/min/gauge.min.js +1 -1
- package/payload/starter/_basic/min/graph-box.min.js +2 -0
- package/payload/starter/_basic/min/grid-group.min.js +2 -0
- package/payload/starter/_basic/min/hold-to-confirm-button.min.js +1 -1
- package/payload/starter/_basic/min/image-view.min.js +2 -0
- package/payload/starter/_basic/min/item-list.min.js +1 -1
- package/payload/starter/_basic/min/json-editor.min.js +2 -0
- package/payload/starter/_basic/min/json-view.min.js +2 -0
- package/payload/starter/_basic/min/label-editor.min.js +1 -1
- package/payload/starter/_basic/min/left-menu.min.js +1 -1
- package/payload/starter/_basic/min/line-progress-bar.min.js +1 -1
- package/payload/starter/_basic/min/loading-screen.min.js +1 -1
- package/payload/starter/_basic/min/log-view.min.js +2 -0
- package/payload/starter/_basic/min/login-page.min.js +2 -0
- package/payload/starter/_basic/min/markdown-view.min.js +2 -0
- package/payload/starter/_basic/min/menu-bar.min.js +2 -0
- package/payload/starter/_basic/min/mini-graph-box.min.js +1 -1
- package/payload/starter/_basic/min/minimal-accent.min.js +2 -0
- package/payload/starter/_basic/min/notice.min.js +1 -1
- package/payload/starter/_basic/min/number-field.min.js +2 -0
- package/payload/starter/_basic/min/numeric-keyboard.min.js +1 -1
- package/payload/starter/_basic/min/page-control.min.js +1 -1
- package/payload/starter/_basic/min/password-field.min.js +2 -0
- package/payload/starter/_basic/min/phone-field.min.js +2 -0
- package/payload/starter/_basic/min/progress-bar.min.js +1 -1
- package/payload/starter/_basic/min/property-panel.min.js +1 -1
- package/payload/starter/_basic/min/radio-button.min.js +1 -1
- package/payload/starter/_basic/min/range-slider.min.js +2 -0
- package/payload/starter/_basic/min/rich-text-editor.min.js +1 -1
- package/payload/starter/_basic/min/scroll-area.min.js +2 -0
- package/payload/starter/_basic/min/scrolling-text.min.js +1 -1
- package/payload/starter/_basic/min/search-input.min.js +2 -0
- package/payload/starter/_basic/min/search-results.min.js +1 -1
- package/payload/starter/_basic/min/select-box.min.js +1 -1
- package/payload/starter/_basic/min/settings-row.min.js +1 -1
- package/payload/starter/_basic/min/side-panel.min.js +1 -1
- package/payload/starter/_basic/min/slider-field.min.js +1 -1
- package/payload/starter/_basic/min/slider.min.js +1 -1
- package/payload/starter/_basic/min/smart-button.min.js +1 -1
- package/payload/starter/_basic/min/smart-table.min.js +1 -1
- package/payload/starter/_basic/min/sortable-list.min.js +1 -1
- package/payload/starter/_basic/min/spark-line-box.min.js +1 -1
- package/payload/starter/_basic/min/splitter.min.js +2 -0
- package/payload/starter/_basic/min/status-bar.min.js +2 -0
- package/payload/starter/_basic/min/step-bar.min.js +2 -0
- package/payload/starter/_basic/min/stepper.min.js +1 -1
- package/payload/starter/_basic/min/tabs.min.js +1 -1
- package/payload/starter/_basic/min/tag-input.min.js +1 -1
- package/payload/starter/_basic/min/text-area-field.min.js +2 -0
- package/payload/starter/_basic/min/text-field.min.js +2 -0
- package/payload/starter/_basic/min/time-line.min.js +1 -1
- package/payload/starter/_basic/min/time-picker.min.js +2 -0
- package/payload/starter/_basic/min/tiny-select.min.js +1 -1
- package/payload/starter/_basic/min/toast.min.js +1 -1
- package/payload/starter/_basic/min/toggle.min.js +1 -1
- package/payload/starter/_basic/min/tool-bar.min.js +2 -0
- package/payload/starter/_basic/min/tooltip.min.js +1 -1
- package/payload/starter/_basic/min/tree-view.min.js +1 -1
- package/payload/starter/_basic/min/ui-effects.min.js +1 -1
- package/payload/starter/_basic/min/url-field.min.js +2 -0
- package/payload/starter/_basic/min/web-view.min.js +1 -1
- package/payload/templates/booking/app/app.js +11 -8
- package/payload/templates/booking/app/settings.js +4 -4
- package/payload/templates/booking/index.htm +3 -3
- package/payload/templates/booking/pages/account.js +6 -6
- package/payload/templates/booking/pages/book.js +1 -1
- package/payload/templates/booking/pages/services.js +5 -4
- package/payload/templates/classic/app/app.js +15 -11
- package/payload/templates/classic/app/settings.js +22 -20
- package/payload/templates/classic/assets/_attribute.txt +2 -0
- package/payload/templates/classic/assets/cards/dill.png +0 -0
- package/payload/templates/classic/assets/cards/fennel.png +0 -0
- package/payload/templates/classic/assets/cards/juniper.png +0 -0
- package/payload/templates/classic/assets/cards/olives.png +0 -0
- package/payload/templates/classic/assets/cards/oregano.png +0 -0
- package/payload/templates/classic/assets/cards/pepper.png +0 -0
- package/payload/templates/classic/assets/cards/rosehip.png +0 -0
- package/payload/templates/classic/assets/categories/cappuccino.png +0 -0
- package/payload/templates/classic/assets/categories/chocolate-milk.png +0 -0
- package/payload/templates/classic/assets/categories/coffee.png +0 -0
- package/payload/templates/classic/assets/categories/frappe.png +0 -0
- package/payload/templates/classic/assets/categories/iced-caffee.png +0 -0
- package/payload/templates/classic/assets/categories/milkshake.png +0 -0
- package/payload/templates/classic/assets/categories/orange-juice.png +0 -0
- package/payload/templates/classic/assets/categories/tea.png +0 -0
- package/payload/templates/classic/index.htm +2 -2
- package/payload/templates/classic/pages/example.js +10 -10
- package/payload/templates/classic/pages/examples.js +44 -43
- package/payload/templates/classic/pages/home.js +16 -15
- package/payload/templates/classic/pages/info-pages.js +5 -5
- package/payload/templates/classic/pages/search.js +8 -7
- package/payload/templates/classic/pages/settings.js +13 -13
- package/payload/templates/classic/pages/tasks.js +1 -0
- package/payload/templates/classic/pages/template-pages.js +12 -11
- package/payload/templates/coffee-shop/app/app.js +12 -8
- package/payload/templates/coffee-shop/app/settings.js +4 -4
- package/payload/templates/coffee-shop/index.htm +3 -3
- package/payload/templates/coffee-shop/pages/drink.js +1 -1
- package/payload/templates/coffee-shop/pages/menu.js +5 -4
- package/payload/templates/forms/TEMPLATE.md +1 -1
- package/payload/templates/forms/appointment-form.htm +55 -53
- package/payload/templates/forms/contact-form-to-mail.htm +38 -37
- package/payload/templates/forms/contact-form-to-supabase.htm +47 -46
- package/payload/templates/forms/dark-contact-form.htm +43 -40
- package/payload/templates/forms/event-registration-form.htm +80 -77
- package/payload/templates/forms/feedback-form.htm +54 -54
- package/payload/templates/forms/order-form.htm +88 -84
- package/payload/templates/forms/recruitment-form.htm +60 -60
- package/payload/templates/forms/service/readme.md +9 -8
- package/payload/templates/forms/service/send-form-mail.php +38 -21
- package/payload/templates/forms/support-ticket-form.htm +67 -65
- package/payload/templates/panel/common/module-page.js +2 -2
- package/payload/templates/panel/common/theme.js +37 -10
- package/payload/templates/panel/common/top-bar.js +45 -40
- package/payload/templates/panel/index.htm +63 -60
- package/payload/templates/panel/module10/greenhouse.htm +98 -113
- package/payload/templates/panel/module11/arduino-projects.htm +47 -58
- package/payload/templates/panel/module6/energy-hub.htm +71 -103
- package/payload/templates/panel/module7/3d-printers.htm +58 -81
- package/payload/templates/panel/module8/cold-rooms.htm +58 -79
- package/payload/templates/panel/module9/elevator-fleet.htm +72 -93
- package/payload/templates/panel/pages/activity.js +134 -152
- package/payload/templates/panel/pages/contents.js +291 -308
- package/payload/templates/panel/pages/customers.js +250 -267
- package/payload/templates/panel/pages/edit-user.js +31 -30
- package/payload/templates/panel/pages/home.js +39 -70
- package/payload/templates/panel/pages/media.js +166 -183
- package/payload/templates/panel/pages/notifications.js +7 -7
- package/payload/templates/panel/pages/orders.js +200 -217
- package/payload/templates/panel/pages/products.js +259 -278
- package/payload/templates/panel/pages/reports.js +74 -123
- package/payload/templates/panel/pages/roles.js +57 -60
- package/payload/templates/panel/pages/settings.js +127 -143
- package/payload/templates/panel/pages/user-actions.js +106 -110
- package/payload/templates/panel/pages/user-list.js +221 -238
- package/payload/templates/panel/pages/users.js +14 -29
- package/payload/templates/shop/TEMPLATE.md +1 -1
- package/payload/templates/shop/app/app.js +11 -8
- package/payload/templates/shop/app/settings.js +4 -4
- package/payload/templates/shop/index.htm +3 -3
- package/payload/templates/shop/pages/account.js +7 -7
- package/payload/templates/shop/pages/cart.js +1 -1
- package/payload/templates/shop/pages/checkout.js +2 -2
- package/payload/templates/shop/pages/product.js +2 -2
- package/payload/templates/shop/pages/shop.js +6 -5
- package/payload/templates/starter/TEMPLATE.md +1 -1
- package/payload/templates/starter/app/app.js +12 -8
- package/payload/templates/starter/app/settings.js +14 -11
- package/payload/templates/starter/index.htm +3 -3
- package/payload/templates/starter/pages/about.js +1 -1
- package/payload/templates/starter/pages/home.js +2 -2
- package/payload/templates/starter/pages/product.js +1 -1
- package/payload/templates/starter/pages/products.js +5 -5
- package/payload/templates/starter/pages/settings.js +1 -1
- package/payload/templates/starter/pages/tasks.js +8 -8
- package/payload/templates/starter/pages/website.js +1 -1
- package/payload/starter/_basic/comp/chart-box/chart-4.5.1.umd.min.js +0 -13
- package/payload/starter/_basic/comp/chart-box/chart-js-LICENSE.md +0 -9
- package/payload/starter/_basic/comp/chart-box.js +0 -868
- package/payload/starter/_basic/comp/email-input-b.js +0 -57
- package/payload/starter/_basic/comp/input-b.js +0 -759
- package/payload/starter/_basic/comp/password-input-b.js +0 -164
- package/payload/starter/_basic/comp/search-input-v2.js +0 -427
- package/payload/starter/_basic/comp/textarea-b.js +0 -184
- package/payload/starter/_basic/comp/url-input-b.js +0 -145
- package/payload/starter/_basic/examples/badgeV2.htm +0 -68
- package/payload/starter/_basic/examples/chart-box.htm +0 -287
- package/payload/starter/_basic/examples/check-box-1.htm +0 -220
- package/payload/starter/_basic/examples/currency-input-b.htm +0 -71
- package/payload/starter/_basic/examples/email-input-b.htm +0 -67
- package/payload/starter/_basic/examples/input-b-ex1.htm +0 -132
- package/payload/starter/_basic/examples/input-b-ex2.htm +0 -136
- package/payload/starter/_basic/examples/input-b-ex3-style.htm +0 -113
- package/payload/starter/_basic/examples/input-b-ex4-custom-unit.htm +0 -112
- package/payload/starter/_basic/examples/input-b-ex6-dark.htm +0 -108
- package/payload/starter/_basic/examples/input-b-ex7-ozden.htm +0 -153
- package/payload/starter/_basic/examples/number-input-b.htm +0 -68
- package/payload/starter/_basic/examples/password-input-b.htm +0 -70
- package/payload/starter/_basic/examples/phone-input-b-select-country.htm +0 -298
- package/payload/starter/_basic/examples/phone-input-b.htm +0 -72
- package/payload/starter/_basic/examples/radio-button-1.htm +0 -264
- package/payload/starter/_basic/examples/search-input-v2-ozden.htm +0 -128
- package/payload/starter/_basic/examples/search-input-v2.htm +0 -65
- package/payload/starter/_basic/examples/select-color.htm +0 -215
- package/payload/starter/_basic/examples/select-date.htm +0 -244
- package/payload/starter/_basic/examples/select-file.htm +0 -268
- package/payload/starter/_basic/examples/select-time.htm +0 -249
- package/payload/starter/_basic/examples/smart-button-2.htm +0 -220
- package/payload/starter/_basic/examples/textarea-b.htm +0 -76
- package/payload/starter/_basic/examples/unfinished-login-page-dark-supabase.htm +0 -221
- package/payload/starter/_basic/examples/unfinished-login-page-supabase.htm +0 -221
- package/payload/starter/_basic/examples/url-input-b.htm +0 -85
- package/payload/starter/_basic/min/badge-v2.min.js +0 -2
- package/payload/starter/_basic/min/chart-box.min.js +0 -2
- package/payload/starter/_basic/min/currency-input-b.min.js +0 -2
- package/payload/starter/_basic/min/email-input-b.min.js +0 -2
- package/payload/starter/_basic/min/input-b.min.js +0 -2
- package/payload/starter/_basic/min/login-page-v2.min.js +0 -2
- package/payload/starter/_basic/min/number-input-b.min.js +0 -2
- package/payload/starter/_basic/min/password-input-b.min.js +0 -2
- package/payload/starter/_basic/min/phone-input-b.min.js +0 -2
- package/payload/starter/_basic/min/search-input-v2.min.js +0 -2
- package/payload/starter/_basic/min/select-color.min.js +0 -2
- package/payload/starter/_basic/min/select-date.min.js +0 -2
- package/payload/starter/_basic/min/select-file.min.js +0 -2
- package/payload/starter/_basic/min/select-time.min.js +0 -2
- package/payload/starter/_basic/min/textarea-b.min.js +0 -2
- package/payload/starter/_basic/min/url-input-b.min.js +0 -2
- package/payload/templates/panel/common/bridge.min.js +0 -0
- package/payload/templates/panel/common/full-view.min.js +0 -1
- package/payload/templates/panel/common/main-view.min.js +0 -1
- package/payload/templates/panel/common/module-page.min.js +0 -1
- package/payload/templates/panel/common/right-view.min.js +0 -1
- package/payload/templates/panel/common/start-page.min.js +0 -1
- package/payload/templates/panel/common/top-bar-v25-07-29-1.js +0 -330
- package/payload/templates/panel/common/top-bar-v25-07-29-2.js +0 -265
- package/payload/templates/panel/common/top-bar.min.js +0 -1
- package/payload/templates/panel/common/ui-standards.min.js +0 -1
- package/payload/templates/panel/managers/database.min.js +0 -1
- package/payload/templates/panel/managers/login.min.js +0 -1
- package/payload/templates/panel/pages/_page-template.min.js +0 -1
- package/payload/templates/panel/pages/contents.min.js +0 -1
- package/payload/templates/panel/pages/edit-user.min.js +0 -1
- package/payload/templates/panel/pages/edit-users-table.min.js +0 -1
- package/payload/templates/panel/pages/home.min.js +0 -1
- package/payload/templates/panel/pages/notifications.min.js +0 -1
- package/payload/templates/panel/pages/reports.min.js +0 -1
- package/payload/templates/panel/pages/settings.min.js +0 -1
- package/payload/templates/panel/pages/user-actions.min.js +0 -2
- package/payload/templates/panel/pages/users.min.js +0 -1
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn2.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn2.png +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear-round.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.png +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/search.svg +0 -0
|
@@ -0,0 +1,1044 @@
|
|
|
1
|
+
/* Bismillah */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
|
|
5
|
+
MarkdownView - v26.11
|
|
6
|
+
|
|
7
|
+
UI COMPONENT
|
|
8
|
+
- A text written in Markdown, drawn on the page: a report, the notes of a program, the answer of an AI.
|
|
9
|
+
- Headings, lists (in lists, with numbers, with check marks), quotes, code, tables, lines, links, pictures, **bold**, *italic*,
|
|
10
|
+
~~deleted~~, `code`.
|
|
11
|
+
- A text is never read as HTML: "<b>" is shown as it is, and a link or a picture with an address like "javascript:..." stays
|
|
12
|
+
a text. No script of a text runs. A picture with a remote address stays a link: a browser loads a picture by itself, so its
|
|
13
|
+
server would learn that the text was opened, and its address can carry data (the answer of an AI). A text you trust:
|
|
14
|
+
remotePictures: 1. A picture of the page and a data: address are always drawn.
|
|
15
|
+
- A text that comes piece by piece: appendText(). Only the blocks that changed are drawn again, and the view follows the end
|
|
16
|
+
until the reader scrolls up.
|
|
17
|
+
- Code: a button copies it. comp/code-editor.js, when it is loaded, gives it colors: "python", "javascript", "json", "html",
|
|
18
|
+
"css", "sql", "bash" (and "py", "js", "sh"...).
|
|
19
|
+
- height: a number or "100%": the text scrolls inside it (basic/scroll-bar.js when it is loaded). "auto": it grows with its text.
|
|
20
|
+
- A click on a link: onLinkClick when it is given, else a new tab. A link to "#a-heading" goes to that heading of the text.
|
|
21
|
+
- Style packages: "light" (default), "dark". Select with styleName (MarkdownView.styles), or later with setTheme().
|
|
22
|
+
|
|
23
|
+
USAGE:
|
|
24
|
+
const view = MarkdownView({
|
|
25
|
+
height: 400,
|
|
26
|
+
markdownText: "# A report\n\nSome **bold** words and a [link](https://example.com).",
|
|
27
|
+
onLinkClick: function (self, address) { println(address); },
|
|
28
|
+
});
|
|
29
|
+
view.setMarkdownText("# Another text");
|
|
30
|
+
view.appendText("\n\nThe next words");
|
|
31
|
+
view.getMarkdownText();
|
|
32
|
+
view.getHeadings(); // [{ id: "another-text", level: 1, text: "Another text" }]
|
|
33
|
+
view.scrollToHeading("another-text");
|
|
34
|
+
view.setTheme("dark");
|
|
35
|
+
|
|
36
|
+
MarkdownView.parse("# Hi").title; // "Hi": the text without a view
|
|
37
|
+
|
|
38
|
+
Started Date: November 2026
|
|
39
|
+
Webpage: https://bug7a.github.io/js-components/
|
|
40
|
+
|
|
41
|
+
Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
|
|
42
|
+
Licensed under the Apache License, Version 2.0
|
|
43
|
+
SPDX-License-Identifier: Apache-2.0
|
|
44
|
+
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
"use strict";
|
|
48
|
+
|
|
49
|
+
// Default values:
|
|
50
|
+
const MarkdownViewDefaults = {
|
|
51
|
+
key: "0", // Your name for this object: read it in a callback (self.key)
|
|
52
|
+
left: 0,
|
|
53
|
+
top: 0,
|
|
54
|
+
width: "100%",
|
|
55
|
+
height: "100%", // A number or "100%": the text scrolls inside it. "auto": it grows with its text.
|
|
56
|
+
markdownText: "", // The text. setMarkdownText(), appendText()
|
|
57
|
+
emptyText: "", // Shown when there is no text
|
|
58
|
+
autoScroll: 1, // 1: with appendText() the view follows the end, until the reader scrolls up
|
|
59
|
+
remotePictures: 0, // 1: a picture with an http address is drawn, not a link (See the note at the top)
|
|
60
|
+
useScrollBar: 1, // basic/scroll-bar.js (when it is loaded), with a height that is not "auto". 0: the scrollbar of the browser
|
|
61
|
+
ariaLabel: "Document",
|
|
62
|
+
copyText: "Copy", // The button of a code
|
|
63
|
+
copiedText: "Copied",
|
|
64
|
+
onLinkClick: null, // function (self, address) {}: a link comes to you, not to the browser. null: it opens in a new tab.
|
|
65
|
+
styleName: "light", // "light", "dark" or a name added to MarkdownView.styles
|
|
66
|
+
style: { // Light style package (default)
|
|
67
|
+
box: { color: "white" },
|
|
68
|
+
page: { padding: [22, 18], gap: 12, maxWidth: 820 }, // WHY maxWidth: A line as wide as a big window is hard to read.
|
|
69
|
+
text: { fontSize: 15, lineRatio: 1.6, textColor: Black(0.8), softColor: Black(0.5), strongColor: Black(0.92) },
|
|
70
|
+
// The sizes and the space above, for the levels 1 to 6. The line under the levels 1 and 2.
|
|
71
|
+
heading: { fontSizes: [27, 22, 18, 16, 15, 14], spaces: [16, 14, 10, 8, 6, 6], lineRatio: 1.3, textColor: Black(0.92), lineColor: Black(0.1), linePadding: 6 },
|
|
72
|
+
link: { color: "#1F7A83", lineColor: "rgba(31, 122, 131, 0.35)" },
|
|
73
|
+
inlineCode: { color: Black(0.06) },
|
|
74
|
+
quote: { textColor: Black(0.62), lineColor: Black(0.16), lineSize: 3, padding: 14 },
|
|
75
|
+
table: { lineColor: Black(0.14), headColor: Black(0.04) },
|
|
76
|
+
line: { color: Black(0.12), space: 6 },
|
|
77
|
+
check: { color: Black(0.3), onColor: "#1F7A83", markColor: "white" },
|
|
78
|
+
code: {
|
|
79
|
+
color: "#F6F6F4",
|
|
80
|
+
border: 1,
|
|
81
|
+
borderColor: Black(0.08),
|
|
82
|
+
round: 8,
|
|
83
|
+
fontSize: 13,
|
|
84
|
+
lineHeight: 20,
|
|
85
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
|
|
86
|
+
textColor: "#2B2B2A",
|
|
87
|
+
padding: [14, 2],
|
|
88
|
+
bottomPadding: 12,
|
|
89
|
+
bar: { height: 34, paddingRight: 6, fontSize: 12, textColor: Black(0.5) }, // WHY no left: its text stands over the code.
|
|
90
|
+
button: { height: 26, padding: 8, gap: 5, round: 6, fontSize: 12, iconSize: 14, textColor: Black(0.6), hoverColor: Black(0.07) },
|
|
91
|
+
},
|
|
92
|
+
codeStyleName: "light", // The package of CodeEditor whose colors the code takes
|
|
93
|
+
empty: { fontSize: 14, textColor: Black(0.45) },
|
|
94
|
+
focus: { ringColor: "rgba(63, 141, 148, 0.8)" },
|
|
95
|
+
scrollBar: { bar_color: "#9A9A98", bar_mouseOverColor: "#6A6A68", bar_width: 4, bar_round: 3 },
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const MarkdownView = function (params = {}) {
|
|
100
|
+
|
|
101
|
+
// Merge style package: params.style > MarkdownView.styles[styleName] > MarkdownViewDefaults.style (light)
|
|
102
|
+
const pageStyle = params.style; // WHY: setTheme() puts it over another package.
|
|
103
|
+
basic.applyStylePackage(params, MarkdownView.styles, MarkdownViewDefaults);
|
|
104
|
+
|
|
105
|
+
// Merge params:
|
|
106
|
+
mergeIntoIfMissing(params, MarkdownViewDefaults);
|
|
107
|
+
|
|
108
|
+
// WHY before startObject: box.height never reads "auto".
|
|
109
|
+
const isAutoHeight = (String(params.height) === "auto");
|
|
110
|
+
|
|
111
|
+
// BOX: Component container
|
|
112
|
+
const box = startObject(params);
|
|
113
|
+
|
|
114
|
+
// *** PRIVATE VARIABLES:
|
|
115
|
+
let _s = box.style;
|
|
116
|
+
let entries = []; // { key, object }: the blocks on the view, in order
|
|
117
|
+
const headingLabels = new Map(); // id -> the label of a heading
|
|
118
|
+
let cancelDraw = null;
|
|
119
|
+
let isFollowing = 1; // 1: the reader is at the end, and the view follows it
|
|
120
|
+
let lastScrollTop = 0;
|
|
121
|
+
const DRAW_DELAY = 33; // ms: pieces of a text that come faster are drawn together
|
|
122
|
+
const BOTTOM_SPACE = 30; // px: this near to the end is at the end
|
|
123
|
+
const HEADING_SPACE = 12; // px: above a heading the view goes to
|
|
124
|
+
const COPIED_TIME = 1500; // ms: how long the button says it is copied
|
|
125
|
+
|
|
126
|
+
// *** PUBLIC VARIABLES:
|
|
127
|
+
// NOTE: Default values are also public variables. (box.markdownText, box.emptyText...)
|
|
128
|
+
|
|
129
|
+
// *** PRIVATE FUNCTIONS:
|
|
130
|
+
|
|
131
|
+
// The style of a package, with the style of the page over it. (setTheme)
|
|
132
|
+
const styleOfPackage = function (styleName) {
|
|
133
|
+
const fresh = { styleName: styleName, style: pageStyle };
|
|
134
|
+
basic.applyStylePackage(fresh, MarkdownView.styles, MarkdownViewDefaults);
|
|
135
|
+
mergeIntoIfMissing(fresh, MarkdownViewDefaults);
|
|
136
|
+
return fresh.style;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const parseText = function () {
|
|
140
|
+
return MarkdownView.parse(box.markdownText, { remotePictures: box.remotePictures });
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// BLOCKS: each kind of block as objects
|
|
144
|
+
|
|
145
|
+
const createTextLabel = function (html, look) {
|
|
146
|
+
const label = Label(Object.assign({ width: "100%", text: html, selectable: 1 }, look));
|
|
147
|
+
label.elem.classList.add("markdown-view-text");
|
|
148
|
+
return label;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const createParagraph = function (block, index, textColor) {
|
|
152
|
+
return createTextLabel(block.html, {
|
|
153
|
+
fontSize: _s.text.fontSize,
|
|
154
|
+
lineHeight: Math.round(_s.text.fontSize * _s.text.lineRatio),
|
|
155
|
+
textColor: textColor,
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const createHeading = function (block, index) {
|
|
160
|
+
const look = _s.heading;
|
|
161
|
+
const fontSize = look.fontSizes[block.level - 1];
|
|
162
|
+
const label = createTextLabel(block.html, {
|
|
163
|
+
fontSize: fontSize,
|
|
164
|
+
lineHeight: Math.round(fontSize * look.lineRatio),
|
|
165
|
+
bold: 1,
|
|
166
|
+
textColor: look.textColor,
|
|
167
|
+
role: "heading",
|
|
168
|
+
aria: { level: block.level },
|
|
169
|
+
});
|
|
170
|
+
if (index > 0) label.css.marginTop = look.spaces[block.level - 1] + "px";
|
|
171
|
+
if (block.level <= 2) {
|
|
172
|
+
label.css.borderBottom = "1px solid " + look.lineColor;
|
|
173
|
+
label.css.paddingBottom = look.linePadding + "px";
|
|
174
|
+
}
|
|
175
|
+
headingLabels.set(block.id, label);
|
|
176
|
+
return label;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const createQuote = function (block) {
|
|
180
|
+
const look = _s.quote;
|
|
181
|
+
// GROUP: A line on its left, its blocks in it
|
|
182
|
+
const group = VGroup({ width: "100%", height: "auto", align: "left top", gap: _s.page.gap, clipContent: 0 });
|
|
183
|
+
group.css.borderLeft = look.lineSize + "px solid " + look.lineColor;
|
|
184
|
+
group.css.paddingLeft = look.padding + "px";
|
|
185
|
+
group.css.boxSizing = "border-box";
|
|
186
|
+
block.blocks.forEach(function (innerBlock, index) { createBlock(innerBlock, index, look.textColor); });
|
|
187
|
+
endGroup();
|
|
188
|
+
return group;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const createLine = function () {
|
|
192
|
+
// BOX: A line across the text
|
|
193
|
+
const line = Box({ width: "100%", height: 1, color: _s.line.color });
|
|
194
|
+
line.css.margin = _s.line.space + "px 0";
|
|
195
|
+
return line;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const showCopyState = function (button, isCopied) {
|
|
199
|
+
const text = (isCopied) ? box.copiedText : box.copyText;
|
|
200
|
+
button.text = MarkdownView.copyButtonHtml(text, isCopied);
|
|
201
|
+
button.aria = { label: text };
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const copyCode = function (button, code) {
|
|
205
|
+
MarkdownView.copyToClipboard(code).then(function () {
|
|
206
|
+
if (button.isRemoved) return;
|
|
207
|
+
showCopyState(button, 1);
|
|
208
|
+
box.after(COPIED_TIME, function () {
|
|
209
|
+
if (!button.isRemoved) showCopyState(button, 0);
|
|
210
|
+
});
|
|
211
|
+
}).catch(function (error) {
|
|
212
|
+
console.warn("MarkdownView: The code could not be copied. " + error);
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const createCopyButton = function (code) {
|
|
217
|
+
const look = _s.code.button;
|
|
218
|
+
// BUTTON: Copies the code
|
|
219
|
+
const button = Button({
|
|
220
|
+
width: "auto",
|
|
221
|
+
height: look.height,
|
|
222
|
+
color: "transparent",
|
|
223
|
+
round: look.round,
|
|
224
|
+
fontSize: look.fontSize,
|
|
225
|
+
textColor: look.textColor,
|
|
226
|
+
shrink: 0,
|
|
227
|
+
css: { display: "flex", alignItems: "center", gap: look.gap + "px", padding: "0 " + look.padding + "px", whiteSpace: "nowrap" },
|
|
228
|
+
});
|
|
229
|
+
button.minimal = 1;
|
|
230
|
+
button.elem.style.setProperty("--markdown-view-copy-icon", look.iconSize + "px");
|
|
231
|
+
button.setFocusRing(_s.focus.ringColor);
|
|
232
|
+
showCopyState(button, 0);
|
|
233
|
+
button.onHoverChange(function (self, isOver) { self.color = (isOver) ? look.hoverColor : "transparent"; });
|
|
234
|
+
button.on("click", function () { copyCode(button, code); });
|
|
235
|
+
return button;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const createCode = function (block) {
|
|
239
|
+
const look = _s.code;
|
|
240
|
+
const card = VGroup({ width: "100%", height: "auto", align: "left top", color: look.color, border: look.border, borderColor: look.borderColor, round: look.round });
|
|
241
|
+
// GROUP: Its language and its button
|
|
242
|
+
const bar = HGroup({ width: "100%", height: look.bar.height, align: "left center", shrink: 0 });
|
|
243
|
+
bar.css.padding = "0 " + look.bar.paddingRight + "px 0 " + look.padding[0] + "px";
|
|
244
|
+
bar.css.boxSizing = "border-box";
|
|
245
|
+
Label({ plainText: block.language, fontSize: look.bar.fontSize, textColor: look.bar.textColor, grow: 1, ellipsis: 1 });
|
|
246
|
+
createCopyButton(block.code);
|
|
247
|
+
endGroup();
|
|
248
|
+
// GROUP: Its lines. WHY scrollX: a line of code is not wrapped.
|
|
249
|
+
const lines = VGroup({ width: "100%", height: "auto", align: "left top", padding: look.padding, clipContent: 0 });
|
|
250
|
+
lines.scrollX = 1;
|
|
251
|
+
lines.css.paddingBottom = look.bottomPadding + "px";
|
|
252
|
+
const label = Label({
|
|
253
|
+
text: MarkdownView.codeHtml(block.code, block.language),
|
|
254
|
+
fontSize: look.fontSize,
|
|
255
|
+
lineHeight: look.lineHeight,
|
|
256
|
+
textColor: look.textColor,
|
|
257
|
+
selectable: 1,
|
|
258
|
+
css: { fontFamily: look.fontFamily, whiteSpace: "pre", width: "max-content", minWidth: "100%", overflow: "visible" },
|
|
259
|
+
});
|
|
260
|
+
label.elem.classList.add("markdown-view-code");
|
|
261
|
+
endGroup();
|
|
262
|
+
endGroup();
|
|
263
|
+
return card;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const createBlock = function (block, index, textColor) {
|
|
267
|
+
if (block.type === "heading") return createHeading(block, index);
|
|
268
|
+
if (block.type === "quote") return createQuote(block);
|
|
269
|
+
if (block.type === "code") return createCode(block);
|
|
270
|
+
if (block.type === "line") return createLine();
|
|
271
|
+
return createParagraph(block, index, textColor);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// What stayed the same stays on the page, with its selection. WHY: a text that comes piece by piece changes only at its end.
|
|
275
|
+
const drawText = function () {
|
|
276
|
+
cancelDraw = null;
|
|
277
|
+
const blocks = parseText().blocks;
|
|
278
|
+
const keys = blocks.map(function (block) { return JSON.stringify(block); });
|
|
279
|
+
let sameCount = 0;
|
|
280
|
+
while (sameCount < entries.length && entries[sameCount].key === keys[sameCount]) sameCount++;
|
|
281
|
+
entries.splice(sameCount).forEach(function (entry) { entry.object.remove(); });
|
|
282
|
+
createIn(box.blockGroup, function () {
|
|
283
|
+
for (let index = sameCount; index < blocks.length; index++) {
|
|
284
|
+
entries.push({ key: keys[index], object: createBlock(blocks[index], index, _s.text.textColor) });
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
paintEmpty();
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const drawAgain = function () {
|
|
291
|
+
const scrollTop = (box.scrollArea) ? box.scrollArea.elem.scrollTop : 0;
|
|
292
|
+
entries.forEach(function (entry) { entry.object.remove(); });
|
|
293
|
+
entries = [];
|
|
294
|
+
drawText();
|
|
295
|
+
if (box.scrollArea) box.scrollArea.elem.scrollTop = scrollTop;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// PAINT: the text of an empty view
|
|
299
|
+
const paintEmpty = function () {
|
|
300
|
+
const isEmpty = (entries.length === 0 && box.emptyText !== "");
|
|
301
|
+
box.lblEmpty.plainText = box.emptyText;
|
|
302
|
+
box.lblEmpty.visible = (isEmpty) ? 1 : 0;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const isSelectingText = function () {
|
|
306
|
+
const selection = window.getSelection();
|
|
307
|
+
return !!(selection && !selection.isCollapsed && box.elem.contains(selection.anchorNode));
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const isAtEnd = function () {
|
|
311
|
+
if (!box.scrollArea) return true;
|
|
312
|
+
const elem = box.scrollArea.elem;
|
|
313
|
+
return (elem.scrollHeight - elem.scrollTop - elem.clientHeight <= BOTTOM_SPACE);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const goToEnd = function () {
|
|
317
|
+
const elem = box.scrollArea.elem;
|
|
318
|
+
elem.scrollTop = elem.scrollHeight;
|
|
319
|
+
lastScrollTop = elem.scrollTop; // WHY: Its scroll event comes a frame late, when more text may have come: not a scroll up.
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const followEnd = function () {
|
|
323
|
+
if (!box.scrollArea || box.autoScroll != 1 || !isFollowing || isSelectingText()) return;
|
|
324
|
+
goToEnd();
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const drawNewPieces = function () {
|
|
328
|
+
drawText();
|
|
329
|
+
followEnd();
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// The reader moved: at the end the view follows again, above it the view stays.
|
|
333
|
+
const onScroll = function () {
|
|
334
|
+
const scrollTop = box.scrollArea.elem.scrollTop;
|
|
335
|
+
if (scrollTop === lastScrollTop) return;
|
|
336
|
+
lastScrollTop = scrollTop;
|
|
337
|
+
isFollowing = isAtEnd() ? 1 : 0;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const onBlockClick = function (self, event) {
|
|
341
|
+
const link = event.target.closest("a");
|
|
342
|
+
if (!link) return;
|
|
343
|
+
const address = link.getAttribute("href");
|
|
344
|
+
if (address.charAt(0) === "#") {
|
|
345
|
+
event.preventDefault(); // WHY: The address of the page stays: a site can have its own pages after a "#".
|
|
346
|
+
box.scrollToHeading(address.slice(1));
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (typeof box.onLinkClick !== "function") return;
|
|
350
|
+
event.preventDefault();
|
|
351
|
+
box.onLinkClick(box, address);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const applyScrollBarLook = function () {
|
|
355
|
+
if (!box.scrollBar) return;
|
|
356
|
+
Object.assign(box.scrollBar, _s.scrollBar);
|
|
357
|
+
box.scrollBar.boxScrollBarTop.color = _s.scrollBar.bar_color;
|
|
358
|
+
box.scrollBar.boxScrollBarLeft.color = _s.scrollBar.bar_color;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const refreshScroll = function () {
|
|
362
|
+
if (box.scrollBar && box.scrollBar.refreshScroll) box.scrollBar.refreshScroll();
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// WHY variables: the parts of a text are HTML in a Label, and only a style sheet reaches them.
|
|
366
|
+
const applyTextColors = function () {
|
|
367
|
+
const variables = {
|
|
368
|
+
"--markdown-view-soft": _s.text.softColor,
|
|
369
|
+
"--markdown-view-strong": _s.text.strongColor,
|
|
370
|
+
"--markdown-view-link": _s.link.color,
|
|
371
|
+
"--markdown-view-link-line": _s.link.lineColor,
|
|
372
|
+
"--markdown-view-inline-code": _s.inlineCode.color,
|
|
373
|
+
"--markdown-view-table-line": _s.table.lineColor,
|
|
374
|
+
"--markdown-view-table-head": _s.table.headColor,
|
|
375
|
+
"--markdown-view-check": _s.check.color,
|
|
376
|
+
"--markdown-view-check-on": _s.check.onColor,
|
|
377
|
+
"--markdown-view-check-mark": _s.check.markColor,
|
|
378
|
+
"--markdown-view-ring": _s.focus.ringColor,
|
|
379
|
+
"--markdown-view-mono": _s.code.fontFamily,
|
|
380
|
+
};
|
|
381
|
+
Object.assign(variables, MarkdownView.codeColors(_s.codeStyleName));
|
|
382
|
+
Object.keys(variables).forEach(function (name) { box.elem.style.setProperty(name, variables[name]); });
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const applyLook = function () {
|
|
386
|
+
box.props(_s.box);
|
|
387
|
+
box.blockGroup.gap = _s.page.gap;
|
|
388
|
+
box.blockGroup.padding = _s.page.padding;
|
|
389
|
+
box.blockGroup.css.maxWidth = _s.page.maxWidth + "px";
|
|
390
|
+
box.lblEmpty.props({ fontSize: _s.empty.fontSize, textColor: _s.empty.textColor });
|
|
391
|
+
if (box.scrollArea) box.scrollArea.setFocusRing(_s.focus.ringColor);
|
|
392
|
+
applyTextColors();
|
|
393
|
+
applyScrollBarLook();
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// *** PUBLIC FUNCTIONS:
|
|
397
|
+
|
|
398
|
+
// The scroll stays where it is. A new document: scrollToTop() after it.
|
|
399
|
+
box.setMarkdownText = function (text) {
|
|
400
|
+
box.markdownText = (text === null || text === undefined) ? "" : String(text);
|
|
401
|
+
drawText();
|
|
402
|
+
isFollowing = isAtEnd() ? 1 : 0;
|
|
403
|
+
};
|
|
404
|
+
// USAGE: view.setMarkdownText("# A title")
|
|
405
|
+
|
|
406
|
+
// The next piece of the text. WHY later: a stream brings many small pieces, and they are drawn together.
|
|
407
|
+
box.appendText = function (text) {
|
|
408
|
+
if (text === null || text === undefined) return;
|
|
409
|
+
box.markdownText += String(text);
|
|
410
|
+
if (!cancelDraw) cancelDraw = box.after(DRAW_DELAY, drawNewPieces);
|
|
411
|
+
};
|
|
412
|
+
// USAGE: view.appendText(" and the next words")
|
|
413
|
+
|
|
414
|
+
box.getMarkdownText = function () {
|
|
415
|
+
return box.markdownText;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
box.clear = function () {
|
|
419
|
+
box.setMarkdownText("");
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
box.setEmptyText = function (text) {
|
|
423
|
+
box.emptyText = (text === null || text === undefined) ? "" : String(text);
|
|
424
|
+
paintEmpty();
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
box.setAutoScroll = function (value) {
|
|
428
|
+
box.autoScroll = basic.isOn(value) ? 1 : 0;
|
|
429
|
+
if (box.autoScroll == 1) box.scrollToEnd();
|
|
430
|
+
};
|
|
431
|
+
// USAGE: get: view.autoScroll, set: view.setAutoScroll(0)
|
|
432
|
+
|
|
433
|
+
// [{ id, level, text }]: for a list of the headings next to the text. A heading in a quote too.
|
|
434
|
+
box.getHeadings = function () {
|
|
435
|
+
return MarkdownView.headingsOf(parseText().blocks);
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
// id: as in getHeadings(), or its text as it is written in a link ("#a-heading").
|
|
439
|
+
box.scrollToHeading = function (id) {
|
|
440
|
+
const label = headingLabels.get(MarkdownView.slug(id));
|
|
441
|
+
if (!label || label.isRemoved) return;
|
|
442
|
+
if (!box.scrollArea) {
|
|
443
|
+
label.elem.scrollIntoView({ block: "start" });
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const area = box.scrollArea.elem;
|
|
447
|
+
const distance = label.elem.getBoundingClientRect().top - area.getBoundingClientRect().top;
|
|
448
|
+
area.scrollTop = Math.max(0, area.scrollTop + distance - HEADING_SPACE);
|
|
449
|
+
};
|
|
450
|
+
// USAGE: view.scrollToHeading("a-heading")
|
|
451
|
+
|
|
452
|
+
box.scrollToTop = function () {
|
|
453
|
+
if (box.scrollArea) box.scrollArea.elem.scrollTop = 0;
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
// It goes to the end, and follows again.
|
|
457
|
+
box.scrollToEnd = function () {
|
|
458
|
+
if (!box.scrollArea) return;
|
|
459
|
+
isFollowing = 1;
|
|
460
|
+
goToEnd();
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// Another style package while it is on the page. A style given by the page stays over it.
|
|
464
|
+
box.setTheme = function (styleName) {
|
|
465
|
+
box.styleName = styleName;
|
|
466
|
+
_s = styleOfPackage(styleName);
|
|
467
|
+
box.style = _s;
|
|
468
|
+
applyLook();
|
|
469
|
+
drawAgain();
|
|
470
|
+
};
|
|
471
|
+
// USAGE: view.setTheme("dark")
|
|
472
|
+
|
|
473
|
+
// *** OBJECT VIEW:
|
|
474
|
+
|
|
475
|
+
const createBlockGroup = function () {
|
|
476
|
+
// GROUP: The blocks. WHY position: a relative group makes a box of height "auto" wrap it.
|
|
477
|
+
box.blockGroup = VGroup({ width: "100%", height: "auto", align: "left top", position: "relative", clipContent: 0 });
|
|
478
|
+
box.blockGroup.css.margin = "0 auto"; // WHY: In a wide window the text stands in the middle.
|
|
479
|
+
box.blockGroup.css.boxSizing = "border-box";
|
|
480
|
+
box.lblEmpty = Label({ width: "100%", textAlign: "center", visible: 0 });
|
|
481
|
+
endGroup();
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
if (isAutoHeight) {
|
|
485
|
+
createBlockGroup();
|
|
486
|
+
} else {
|
|
487
|
+
// BOX: The place that scrolls
|
|
488
|
+
box.scrollArea = startBox({ left: 0, top: 0, width: "100%", height: "100%", color: "transparent" });
|
|
489
|
+
box.scrollArea.scrollY = 1;
|
|
490
|
+
box.scrollArea.role = "document";
|
|
491
|
+
box.scrollArea.aria = { label: box.ariaLabel };
|
|
492
|
+
box.scrollArea.tabIndex = 0; // WHY: The keys of a focused box scroll it (arrows, Page Up, Home, End).
|
|
493
|
+
createBlockGroup();
|
|
494
|
+
endBox();
|
|
495
|
+
if (box.useScrollBar == 1 && typeof ScrollBar !== "undefined") {
|
|
496
|
+
box.scrollBar = ScrollBar(Object.assign({ scrollableBox: box.scrollArea, neverHide: 0, showDots: 0 }, _s.scrollBar));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// *** OBJECT INIT CODE:
|
|
501
|
+
|
|
502
|
+
MarkdownView.addCss();
|
|
503
|
+
applyLook();
|
|
504
|
+
box.listenTo(box.blockGroup.elem, "click", onBlockClick);
|
|
505
|
+
if (box.scrollArea) {
|
|
506
|
+
box.scrollArea.on("scroll", onScroll);
|
|
507
|
+
box.blockGroup.onResize(refreshScroll);
|
|
508
|
+
}
|
|
509
|
+
box.setMarkdownText(box.markdownText);
|
|
510
|
+
|
|
511
|
+
return endObject(box);
|
|
512
|
+
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// *** STATIC VARIABLES AND FUNCTIONS: THE LOOK OF THE PARTS OF A TEXT
|
|
516
|
+
|
|
517
|
+
MarkdownView.addCss = function () {
|
|
518
|
+
basic.addCss("markdown-view",
|
|
519
|
+
".markdown-view-text { overflow-wrap: break-word; }" +
|
|
520
|
+
".markdown-view-text strong { font-family: opensans-bold; font-weight: normal; color: var(--markdown-view-strong); }" +
|
|
521
|
+
'.markdown-view-text[role="heading"] strong { color: inherit; }' +
|
|
522
|
+
".markdown-view-text em { font-style: italic; }" +
|
|
523
|
+
".markdown-view-text del { opacity: 0.7; }" +
|
|
524
|
+
".markdown-view-text code { font-family: var(--markdown-view-mono); font-size: 0.87em; padding: 0.12em 0.36em; border-radius: 4px;" +
|
|
525
|
+
" background: var(--markdown-view-inline-code); }" +
|
|
526
|
+
".markdown-view-text a { color: var(--markdown-view-link); text-decoration: none; border-bottom: 1px solid var(--markdown-view-link-line); }" +
|
|
527
|
+
".markdown-view-text a:hover { border-bottom-color: var(--markdown-view-link); }" +
|
|
528
|
+
".markdown-view-text a:focus-visible { outline: 2px solid var(--markdown-view-ring); outline-offset: 2px; border-radius: 2px; }" +
|
|
529
|
+
".markdown-view-text img { max-width: 100%; height: auto; border-radius: 6px; vertical-align: top; }" +
|
|
530
|
+
".markdown-view-text ul, .markdown-view-text ol { margin: 0; padding-left: 24px; }" +
|
|
531
|
+
".markdown-view-text li { margin: 4px 0; padding-left: 2px; }" +
|
|
532
|
+
".markdown-view-text li::marker { color: var(--markdown-view-soft); }" +
|
|
533
|
+
".markdown-view-text li.markdown-view-task { list-style: none; margin-left: -20px; }" +
|
|
534
|
+
".markdown-view-check { display: inline-block; box-sizing: border-box; width: 15px; height: 15px; margin-right: 8px; vertical-align: -2px;" +
|
|
535
|
+
" border: 1.5px solid var(--markdown-view-check); border-radius: 4px; }" +
|
|
536
|
+
".markdown-view-check-on { background: var(--markdown-view-check-on); border-color: var(--markdown-view-check-on); position: relative; }" +
|
|
537
|
+
// WHY a turned corner: a check mark with no icon file, in the color of the package.
|
|
538
|
+
".markdown-view-check-on::after { content: ''; position: absolute; left: 3.5px; top: 0.5px; width: 3px; height: 7px;" +
|
|
539
|
+
" border: solid var(--markdown-view-check-mark); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }" +
|
|
540
|
+
".markdown-view-table { overflow-x: auto; }" +
|
|
541
|
+
".markdown-view-table table { border-collapse: collapse; font-size: 0.93em; }" +
|
|
542
|
+
".markdown-view-table th, .markdown-view-table td { border: 1px solid var(--markdown-view-table-line); padding: 7px 10px; text-align: left; vertical-align: top; }" +
|
|
543
|
+
".markdown-view-table th { font-family: opensans-bold; font-weight: normal; background: var(--markdown-view-table-head); }" +
|
|
544
|
+
".markdown-view-copy-icon { display: block; flex-shrink: 0; width: var(--markdown-view-copy-icon); height: var(--markdown-view-copy-icon); pointer-events: none; }" +
|
|
545
|
+
".markdown-view-copy-icon svg { display: block; width: 100%; height: 100%; }" +
|
|
546
|
+
MarkdownView.CODE_KINDS.map(function (kind) {
|
|
547
|
+
return ".markdown-view-code .code-editor-" + kind + " { color: var(--markdown-view-kind-" + kind + "); }";
|
|
548
|
+
}).join(""));
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
MarkdownView.CODE_KINDS = ["keyword", "string", "number", "comment", "builtin", "function", "property", "tag", "attribute", "variable"];
|
|
552
|
+
|
|
553
|
+
// The colors of the code as style variables. WHY from CodeEditor: one list of colors for the code of the kit.
|
|
554
|
+
MarkdownView.codeColors = function (styleName) {
|
|
555
|
+
const variables = {};
|
|
556
|
+
if (typeof CodeEditor === "undefined") return variables;
|
|
557
|
+
const kinds = Object.assign({}, CodeEditor.styles.light.kinds, (CodeEditor.styles[styleName] || {}).kinds);
|
|
558
|
+
MarkdownView.CODE_KINDS.forEach(function (kind) { variables["--markdown-view-kind-" + kind] = kinds[kind]; });
|
|
559
|
+
return variables;
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
MarkdownView.ICONS = {
|
|
563
|
+
copy: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">' +
|
|
564
|
+
'<rect x="9" y="9" width="12" height="12" rx="2"/><path d="M5 15h-.5A1.5 1.5 0 0 1 3 13.5v-9A1.5 1.5 0 0 1 4.5 3h9A1.5 1.5 0 0 1 15 4.5V5"/></svg>',
|
|
565
|
+
check: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">' +
|
|
566
|
+
'<path d="M5 13l4.5 4.5L19 7"/></svg>',
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
MarkdownView.copyButtonHtml = function (text, isCopied) {
|
|
570
|
+
const icon = (isCopied) ? MarkdownView.ICONS.check : MarkdownView.ICONS.copy;
|
|
571
|
+
return '<span class="markdown-view-copy-icon">' + icon + "</span><span>" + basic.escapeHtml(text) + "</span>";
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
// Returns a Promise.
|
|
575
|
+
MarkdownView.copyToClipboard = function (text) {
|
|
576
|
+
if (navigator.clipboard && window.isSecureContext) return navigator.clipboard.writeText(text);
|
|
577
|
+
// WHY: A page opened from a file (the window of a program) has no navigator.clipboard.
|
|
578
|
+
const area = document.createElement("textarea");
|
|
579
|
+
area.value = text;
|
|
580
|
+
area.style.cssText = "position: fixed; left: -9999px; top: 0;";
|
|
581
|
+
document.body.appendChild(area);
|
|
582
|
+
area.select();
|
|
583
|
+
const isCopied = document.execCommand("copy");
|
|
584
|
+
area.remove();
|
|
585
|
+
return (isCopied) ? Promise.resolve() : Promise.reject(new Error("The browser refused it."));
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
// *** THE COLORS OF THE CODE:
|
|
589
|
+
|
|
590
|
+
MarkdownView.LANGUAGE_NAMES = {
|
|
591
|
+
py: "python", python3: "python",
|
|
592
|
+
js: "javascript", jsx: "javascript", ts: "javascript", tsx: "javascript", typescript: "javascript", node: "javascript",
|
|
593
|
+
sh: "bash", shell: "bash", zsh: "bash", console: "bash",
|
|
594
|
+
htm: "html", xml: "html", svg: "html",
|
|
595
|
+
};
|
|
596
|
+
MarkdownView.MAX_COLORED_LETTERS = 200000; // WHY: A longer code stays plain: a stream must not wait for the colors.
|
|
597
|
+
|
|
598
|
+
// A code as HTML: colored when comp/code-editor.js is loaded and knows the language.
|
|
599
|
+
MarkdownView.codeHtml = function (code, language) {
|
|
600
|
+
const name = MarkdownView.LANGUAGE_NAMES[language] || language;
|
|
601
|
+
const definition = (typeof CodeEditor !== "undefined") ? CodeEditor.languages[name] : null;
|
|
602
|
+
if (!definition || code.length > MarkdownView.MAX_COLORED_LETTERS) return basic.escapeHtml(code);
|
|
603
|
+
let state = null;
|
|
604
|
+
return code.split("\n").map(function (line) {
|
|
605
|
+
const result = CodeEditor.tokenizeLine(line, state, definition);
|
|
606
|
+
state = result.state;
|
|
607
|
+
return result.parts.map(CodeEditor.partHtml).join("");
|
|
608
|
+
}).join("\n");
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// *** THE PARSER: a text -> blocks, with no view. Every text in a block is safe HTML.
|
|
612
|
+
// { type: "heading", level, html, text, id }, { type: "p", html }, { type: "list", html }, { type: "table", html },
|
|
613
|
+
// { type: "quote", blocks }, { type: "code", language, code }, { type: "line" }
|
|
614
|
+
|
|
615
|
+
// options: { remotePictures: 1 }. Returns { blocks, title }.
|
|
616
|
+
MarkdownView.parse = function (text, options = {}) {
|
|
617
|
+
const context = { usedIds: Object.create(null), remotePictures: basic.isOn(options.remotePictures) }; // WHY null: a heading can be named "constructor".
|
|
618
|
+
const lines = String((text === null || text === undefined) ? "" : text).replace(/\r\n?/g, "\n").split("\n");
|
|
619
|
+
const blocks = MarkdownView.parseBlocks(lines, context);
|
|
620
|
+
const firstHeading = MarkdownView.headingsOf(blocks).find(function (heading) { return heading.level === 1; });
|
|
621
|
+
return { blocks: blocks, title: (firstHeading) ? firstHeading.text : "" };
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
MarkdownView.headingsOf = function (blocks) {
|
|
625
|
+
const headings = [];
|
|
626
|
+
blocks.forEach(function (block) {
|
|
627
|
+
if (block.type === "heading") headings.push({ id: block.id, level: block.level, text: block.text });
|
|
628
|
+
if (block.type === "quote") headings.push.apply(headings, MarkdownView.headingsOf(block.blocks));
|
|
629
|
+
});
|
|
630
|
+
return headings;
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
MarkdownView.RE = {
|
|
634
|
+
fence: /^(\s*)(`{3,}|~{3,})\s*([^\s`]*)[^`]*$/,
|
|
635
|
+
heading: /^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,
|
|
636
|
+
underline: /^\s{0,3}(=+|-{2,})\s*$/,
|
|
637
|
+
line: /^\s{0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,
|
|
638
|
+
quote: /^\s*>/,
|
|
639
|
+
listItem: /^(\s*)([-*+]|\d+[.)])\s+(.*)$/,
|
|
640
|
+
listNextLine: /^\s{2,}\S/,
|
|
641
|
+
task: /^\[( |x|X)\]\s+(.*)$/,
|
|
642
|
+
tableDivider: /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/,
|
|
643
|
+
hardBreak: / {2,}$|\\$/,
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
MarkdownView.parseBlocks = function (lines, context) {
|
|
647
|
+
const reader = { lines: lines, at: 0, blocks: [], context: context };
|
|
648
|
+
while (reader.at < lines.length) {
|
|
649
|
+
if (lines[reader.at].trim()) {
|
|
650
|
+
MarkdownView.BLOCK_READERS.find(function (read) { return read(reader); });
|
|
651
|
+
} else {
|
|
652
|
+
reader.at++;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return reader.blocks;
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
MarkdownView.isTableStart = function (lines, at) {
|
|
659
|
+
if (lines[at].indexOf("|") === -1 || at + 1 >= lines.length) return false;
|
|
660
|
+
if (!MarkdownView.RE.tableDivider.test(lines[at + 1])) return false;
|
|
661
|
+
return (MarkdownView.tableCells(lines[at]).length === MarkdownView.tableCells(lines[at + 1]).length);
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
// A line that ends a paragraph.
|
|
665
|
+
MarkdownView.isBlockStart = function (lines, at) {
|
|
666
|
+
const RE = MarkdownView.RE;
|
|
667
|
+
const line = lines[at];
|
|
668
|
+
return (RE.fence.test(line) || RE.heading.test(line) || RE.line.test(line) || RE.quote.test(line) || RE.listItem.test(line) || MarkdownView.isTableStart(lines, at));
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
MarkdownView.uniqueId = function (text, usedIds) {
|
|
672
|
+
const id = MarkdownView.slug(text) || "section";
|
|
673
|
+
usedIds[id] = (usedIds[id] || 0) + 1;
|
|
674
|
+
return (usedIds[id] > 1) ? id + "-" + usedIds[id] : id;
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
MarkdownView.headingBlock = function (level, raw, context) {
|
|
678
|
+
const text = MarkdownView.plainText(raw);
|
|
679
|
+
return { type: "heading", level: level, html: MarkdownView.inlineHtml(raw, context), text: text, id: MarkdownView.uniqueId(text, context.usedIds) };
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
// *** Each reader reads one block at reader.at and returns true, or leaves it and returns false.
|
|
683
|
+
|
|
684
|
+
MarkdownView.readCode = function (reader) {
|
|
685
|
+
const open = MarkdownView.RE.fence.exec(reader.lines[reader.at]);
|
|
686
|
+
if (!open) return false;
|
|
687
|
+
const indentOfLine = new RegExp("^ {0," + open[1].length + "}"); // WHY: A code in a list is written further in.
|
|
688
|
+
const closing = new RegExp("^\\s*" + open[2].charAt(0) + "{" + open[2].length + ",}\\s*$");
|
|
689
|
+
const code = [];
|
|
690
|
+
reader.at++;
|
|
691
|
+
// WHY no error at the end of the text: a code without its last line is a code that is still coming.
|
|
692
|
+
while (reader.at < reader.lines.length && !closing.test(reader.lines[reader.at])) {
|
|
693
|
+
code.push(reader.lines[reader.at].replace(indentOfLine, ""));
|
|
694
|
+
reader.at++;
|
|
695
|
+
}
|
|
696
|
+
reader.at++;
|
|
697
|
+
reader.blocks.push({ type: "code", language: open[3].toLowerCase(), code: code.join("\n") });
|
|
698
|
+
return true;
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
MarkdownView.readHeading = function (reader) {
|
|
702
|
+
const match = MarkdownView.RE.heading.exec(reader.lines[reader.at]);
|
|
703
|
+
if (!match) return false;
|
|
704
|
+
reader.blocks.push(MarkdownView.headingBlock(match[1].length, match[2], reader.context));
|
|
705
|
+
reader.at++;
|
|
706
|
+
return true;
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// A title, and a line of === or --- under it.
|
|
710
|
+
MarkdownView.readUnderlinedHeading = function (reader) {
|
|
711
|
+
const next = reader.lines[reader.at + 1];
|
|
712
|
+
const match = (next === undefined) ? null : MarkdownView.RE.underline.exec(next);
|
|
713
|
+
if (!match || MarkdownView.isBlockStart(reader.lines, reader.at)) return false;
|
|
714
|
+
const level = (match[1].charAt(0) === "=") ? 1 : 2;
|
|
715
|
+
reader.blocks.push(MarkdownView.headingBlock(level, reader.lines[reader.at].trim(), reader.context));
|
|
716
|
+
reader.at += 2;
|
|
717
|
+
return true;
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
MarkdownView.readLine = function (reader) {
|
|
721
|
+
if (!MarkdownView.RE.line.test(reader.lines[reader.at])) return false;
|
|
722
|
+
reader.blocks.push({ type: "line" });
|
|
723
|
+
reader.at++;
|
|
724
|
+
return true;
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
MarkdownView.readQuote = function (reader) {
|
|
728
|
+
const RE = MarkdownView.RE;
|
|
729
|
+
if (!RE.quote.test(reader.lines[reader.at])) return false;
|
|
730
|
+
const inner = [];
|
|
731
|
+
while (reader.at < reader.lines.length && RE.quote.test(reader.lines[reader.at])) {
|
|
732
|
+
inner.push(reader.lines[reader.at].replace(/^\s*>\s?/, ""));
|
|
733
|
+
reader.at++;
|
|
734
|
+
}
|
|
735
|
+
reader.blocks.push({ type: "quote", blocks: MarkdownView.parseBlocks(inner, reader.context) });
|
|
736
|
+
return true;
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
MarkdownView.isLineOfList = function (line) {
|
|
740
|
+
const RE = MarkdownView.RE;
|
|
741
|
+
if (!line.trim() || RE.fence.test(line) || RE.line.test(line)) return false;
|
|
742
|
+
return (RE.listItem.test(line) || RE.listNextLine.test(line));
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
MarkdownView.readList = function (reader) {
|
|
746
|
+
if (!MarkdownView.RE.listItem.test(reader.lines[reader.at])) return false;
|
|
747
|
+
const lines = [];
|
|
748
|
+
while (reader.at < reader.lines.length && MarkdownView.isLineOfList(reader.lines[reader.at])) {
|
|
749
|
+
lines.push(reader.lines[reader.at]);
|
|
750
|
+
reader.at++;
|
|
751
|
+
}
|
|
752
|
+
reader.blocks.push({ type: "list", html: MarkdownView.listHtml(lines, reader.context) });
|
|
753
|
+
return true;
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
MarkdownView.readTable = function (reader) {
|
|
757
|
+
if (!MarkdownView.isTableStart(reader.lines, reader.at)) return false;
|
|
758
|
+
const head = reader.lines[reader.at];
|
|
759
|
+
const divider = reader.lines[reader.at + 1];
|
|
760
|
+
const rows = [];
|
|
761
|
+
reader.at += 2;
|
|
762
|
+
while (reader.at < reader.lines.length && reader.lines[reader.at].indexOf("|") > -1 && reader.lines[reader.at].trim()) {
|
|
763
|
+
rows.push(reader.lines[reader.at]);
|
|
764
|
+
reader.at++;
|
|
765
|
+
}
|
|
766
|
+
reader.blocks.push({ type: "table", html: MarkdownView.tableHtml(head, divider, rows, reader.context) });
|
|
767
|
+
return true;
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
// WHY last: every other line is a paragraph. It always takes a line, so the parser always goes on.
|
|
771
|
+
MarkdownView.readParagraph = function (reader) {
|
|
772
|
+
const lines = [];
|
|
773
|
+
while (reader.at < reader.lines.length && reader.lines[reader.at].trim()) {
|
|
774
|
+
if (lines.length && MarkdownView.isBlockStart(reader.lines, reader.at)) break;
|
|
775
|
+
lines.push(reader.lines[reader.at]);
|
|
776
|
+
reader.at++;
|
|
777
|
+
}
|
|
778
|
+
const html = lines.map(function (line, index) {
|
|
779
|
+
const hasBreak = (MarkdownView.RE.hardBreak.test(line) && index < lines.length - 1);
|
|
780
|
+
const text = line.trim().replace(/\\$/, "");
|
|
781
|
+
return MarkdownView.inlineHtml(text, reader.context) + ((hasBreak) ? "<br>" : " ");
|
|
782
|
+
}).join("");
|
|
783
|
+
reader.blocks.push({ type: "p", html: html.trim() });
|
|
784
|
+
return true;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
MarkdownView.BLOCK_READERS = [
|
|
788
|
+
MarkdownView.readCode,
|
|
789
|
+
MarkdownView.readHeading,
|
|
790
|
+
MarkdownView.readUnderlinedHeading,
|
|
791
|
+
MarkdownView.readLine,
|
|
792
|
+
MarkdownView.readQuote,
|
|
793
|
+
MarkdownView.readList,
|
|
794
|
+
MarkdownView.readTable,
|
|
795
|
+
MarkdownView.readParagraph,
|
|
796
|
+
];
|
|
797
|
+
|
|
798
|
+
// *** A LIST:
|
|
799
|
+
|
|
800
|
+
MarkdownView.readListItems = function (lines) {
|
|
801
|
+
const items = [];
|
|
802
|
+
lines.forEach(function (line) {
|
|
803
|
+
const match = MarkdownView.RE.listItem.exec(line);
|
|
804
|
+
if (match) {
|
|
805
|
+
const isOrdered = /\d/.test(match[2]);
|
|
806
|
+
items.push({ indent: match[1].replace(/\t/g, " ").length, isOrdered: isOrdered, start: parseInt(match[2], 10), text: match[3] });
|
|
807
|
+
} else if (items.length) {
|
|
808
|
+
items[items.length - 1].text += " " + line.trim();
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
return items;
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
MarkdownView.listItemHtml = function (item, context) {
|
|
815
|
+
const task = MarkdownView.RE.task.exec(item.text);
|
|
816
|
+
if (!task) return "<li>" + MarkdownView.inlineHtml(item.text, context);
|
|
817
|
+
const checkClass = (task[1] === " ") ? "markdown-view-check" : "markdown-view-check markdown-view-check-on";
|
|
818
|
+
return '<li class="markdown-view-task"><span class="' + checkClass + '"></span>' + MarkdownView.inlineHtml(task[2], context);
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
// WHY start: a text between the items of a list makes two lists, and the numbers must go on.
|
|
822
|
+
MarkdownView.listStartHtml = function (item) {
|
|
823
|
+
if (!item.isOrdered) return "<ul>";
|
|
824
|
+
return (item.start === 1) ? "<ol>" : '<ol start="' + item.start + '">';
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// By the spaces in front of the items: further in is a list in the item above.
|
|
828
|
+
MarkdownView.listHtml = function (lines, context) {
|
|
829
|
+
const items = MarkdownView.readListItems(lines);
|
|
830
|
+
let position = 0;
|
|
831
|
+
const drawLevel = function (indent) {
|
|
832
|
+
const first = items[position];
|
|
833
|
+
let html = MarkdownView.listStartHtml(first);
|
|
834
|
+
while (position < items.length && items[position].indent === indent) {
|
|
835
|
+
html += MarkdownView.listItemHtml(items[position], context);
|
|
836
|
+
position++;
|
|
837
|
+
if (position < items.length && items[position].indent > indent) html += drawLevel(items[position].indent);
|
|
838
|
+
html += "</li>";
|
|
839
|
+
}
|
|
840
|
+
return html + ((first.isOrdered) ? "</ol>" : "</ul>");
|
|
841
|
+
};
|
|
842
|
+
let html = "";
|
|
843
|
+
while (position < items.length) html += drawLevel(items[position].indent);
|
|
844
|
+
return html;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
// *** A TABLE:
|
|
848
|
+
|
|
849
|
+
// WHY the mark: a "\|" is a letter of a cell, not its end.
|
|
850
|
+
MarkdownView.tableCells = function (row) {
|
|
851
|
+
const PIPE_MARK = "\u0001";
|
|
852
|
+
return row.trim().replace(/\\\|/g, PIPE_MARK).replace(/^\|/, "").replace(/\|$/, "").split("|").map(function (cell) {
|
|
853
|
+
return cell.split(PIPE_MARK).join("|").trim();
|
|
854
|
+
});
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
// ":--" left, ":--:" center, "--:" right
|
|
858
|
+
MarkdownView.tableAlign = function (dividerCell) {
|
|
859
|
+
const isLeft = dividerCell.startsWith(":");
|
|
860
|
+
const isRight = dividerCell.endsWith(":");
|
|
861
|
+
if (isLeft && isRight) return "center";
|
|
862
|
+
return (isRight) ? "right" : "";
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
MarkdownView.tableRowHtml = function (cells, tag, aligns, context) {
|
|
866
|
+
let html = "<tr>";
|
|
867
|
+
aligns.forEach(function (align, index) {
|
|
868
|
+
const style = (align) ? ' style="text-align: ' + align + '"' : "";
|
|
869
|
+
const text = (index < cells.length) ? cells[index] : "";
|
|
870
|
+
html += "<" + tag + style + ">" + MarkdownView.inlineHtml(text, context) + "</" + tag + ">";
|
|
871
|
+
});
|
|
872
|
+
return html + "</tr>";
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
// WHY the box around it: a wide table scrolls in itself, the text stays where it is.
|
|
876
|
+
MarkdownView.tableHtml = function (head, divider, rows, context) {
|
|
877
|
+
const aligns = MarkdownView.tableCells(divider).map(MarkdownView.tableAlign);
|
|
878
|
+
const bodyHtml = rows.map(function (row) {
|
|
879
|
+
return MarkdownView.tableRowHtml(MarkdownView.tableCells(row), "td", aligns, context);
|
|
880
|
+
}).join("");
|
|
881
|
+
return '<div class="markdown-view-table"><table><thead>' + MarkdownView.tableRowHtml(MarkdownView.tableCells(head), "th", aligns, context) +
|
|
882
|
+
"</thead><tbody>" + bodyHtml + "</tbody></table></div>";
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// *** IN A LINE:
|
|
886
|
+
|
|
887
|
+
MarkdownView.KEEP_MARK = "\u0000"; // Around the number of a part that is ready
|
|
888
|
+
|
|
889
|
+
MarkdownView.INLINE_RE = {
|
|
890
|
+
code: /(`+)\s?([^`]|[^`].*?[^`])\s?\1(?!`)/g,
|
|
891
|
+
letter: /\\([!-/:-@[-`{-~])/g, // A "\" before any mark of ASCII
|
|
892
|
+
picture: /!\[((?:\\.|[^\]\\])*)\]\(\s*<?((?:[^()\s<>]|\([^()\s]*\))+)>?(?:\s+"[^"]*")?\s*\)/g,
|
|
893
|
+
link: /\[((?:\\.|[^[\]\\]|\[[^\]]*\])*)\]\(\s*<?((?:[^()\s<>]|\([^()\s]*\))+)>?(?:\s+"[^"]*")?\s*\)/g,
|
|
894
|
+
bareAddress: /(^|[\s(*_~])(https?:\/\/[^\s<>]+[^\s<>.,;:)!?'"*_~])/g,
|
|
895
|
+
lineBreak: /<br\s*\/?>/gi,
|
|
896
|
+
strong: /\*\*([^\s*](?:.*?[^\s*])?)\*\*/g,
|
|
897
|
+
strongLine: /(^|[^\w])__([^\s_](?:.*?[^\s_])?)__(?!\w)/g,
|
|
898
|
+
emphasis: /(^|[^*\w])\*([^\s*](?:.*?[^\s*])?)\*(?!\*)/g,
|
|
899
|
+
emphasisLine: /(^|[^\w])_([^\s_](?:.*?[^\s_])?)_(?!\w)/g,
|
|
900
|
+
deleted: /~~([^\s~](?:.*?[^\s~])?)~~/g,
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
// A text of a line as safe HTML. WHY the kept parts: what is inside a code or an address is not read as Markdown again.
|
|
904
|
+
MarkdownView.inlineHtml = function (text, context) {
|
|
905
|
+
const kept = [];
|
|
906
|
+
const keep = function (html) {
|
|
907
|
+
kept.push(html);
|
|
908
|
+
return MarkdownView.KEEP_MARK + (kept.length - 1) + MarkdownView.KEEP_MARK;
|
|
909
|
+
};
|
|
910
|
+
const html = MarkdownView.formatLine(String(text).split(MarkdownView.KEEP_MARK).join(""), keep, context);
|
|
911
|
+
return MarkdownView.putKeptParts(html, kept);
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
MarkdownView.putKeptParts = function (html, kept) {
|
|
915
|
+
const keptPart = new RegExp(MarkdownView.KEEP_MARK + "(\\d+)" + MarkdownView.KEEP_MARK, "g");
|
|
916
|
+
let result = html;
|
|
917
|
+
// WHY again: the label of a link holds kept parts too.
|
|
918
|
+
while (result.indexOf(MarkdownView.KEEP_MARK) > -1) {
|
|
919
|
+
result = result.replace(keptPart, function (all, number) { return kept[Number(number)]; });
|
|
920
|
+
}
|
|
921
|
+
return result;
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
MarkdownView.formatLine = function (text, keep, context) {
|
|
925
|
+
const RE = MarkdownView.INLINE_RE;
|
|
926
|
+
let html = text.replace(RE.code, function (all, marks, code) {
|
|
927
|
+
return keep("<code>" + basic.escapeHtml(code) + "</code>");
|
|
928
|
+
});
|
|
929
|
+
// WHY the addresses before the "\*" letters: a letter that is kept can not be checked, and "a\_b" is an address too.
|
|
930
|
+
html = html.replace(RE.picture, function (all, description, address) {
|
|
931
|
+
return keep(MarkdownView.pictureHtml(MarkdownView.removeEscapes(address), MarkdownView.removeEscapes(description), context));
|
|
932
|
+
});
|
|
933
|
+
html = html.replace(RE.link, function (all, label, address) {
|
|
934
|
+
return keep(MarkdownView.linkHtml(MarkdownView.removeEscapes(address), MarkdownView.formatLine(label, keep, context)));
|
|
935
|
+
});
|
|
936
|
+
html = html.replace(RE.letter, function (all, letter) { return keep(basic.escapeHtml(letter)); });
|
|
937
|
+
html = html.replace(RE.bareAddress, function (all, before, address) {
|
|
938
|
+
return before + keep(MarkdownView.linkHtml(address, basic.escapeHtml(address)));
|
|
939
|
+
});
|
|
940
|
+
return MarkdownView.formatWords(basic.escapeHtml(html));
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
MarkdownView.removeEscapes = function (text) {
|
|
944
|
+
return text.replace(MarkdownView.INLINE_RE.letter, "$1");
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
MarkdownView.formatWords = function (html) {
|
|
948
|
+
const RE = MarkdownView.INLINE_RE;
|
|
949
|
+
return html
|
|
950
|
+
.replace(RE.lineBreak, "<br>")
|
|
951
|
+
.replace(RE.strong, "<strong>$1</strong>")
|
|
952
|
+
.replace(RE.strongLine, "$1<strong>$2</strong>")
|
|
953
|
+
.replace(RE.emphasis, "$1<em>$2</em>")
|
|
954
|
+
.replace(RE.emphasisLine, "$1<em>$2</em>")
|
|
955
|
+
.replace(RE.deleted, "<del>$1</del>");
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// *** ADDRESSES:
|
|
959
|
+
|
|
960
|
+
MarkdownView.LINK_SCHEMES = /^(https?|mailto|tel):/i;
|
|
961
|
+
MarkdownView.PICTURE_SCHEMES = /^(https?:|data:image\/)/i;
|
|
962
|
+
MarkdownView.REMOTE_ADDRESS = /^(https?:)?\/\//i;
|
|
963
|
+
MarkdownView.ANY_SCHEME = /^[a-z][a-z0-9+.-]*:/i;
|
|
964
|
+
|
|
965
|
+
// WHY the clean text: a browser leaves out these letters in an address, so "java	script:" and "java\tscript:" run as "javascript:".
|
|
966
|
+
MarkdownView.isSafeAddress = function (address, safeSchemes) {
|
|
967
|
+
if (address.indexOf(MarkdownView.KEEP_MARK) > -1) return false; // WHY: A part that comes back later could hide its scheme.
|
|
968
|
+
const clean = address.replace(/[\p{C}\p{Z}]/gu, "");
|
|
969
|
+
return (!MarkdownView.ANY_SCHEME.test(clean) || safeSchemes.test(clean));
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
// A safe address is a link; any other one stays its text.
|
|
973
|
+
MarkdownView.linkHtml = function (address, labelHtml) {
|
|
974
|
+
if (!MarkdownView.isSafeAddress(address, MarkdownView.LINK_SCHEMES)) return labelHtml;
|
|
975
|
+
const newTab = (address.charAt(0) === "#") ? "" : ' target="_blank" rel="noopener noreferrer"';
|
|
976
|
+
return '<a href="' + basic.escapeHtml(address) + '"' + newTab + ">" + labelHtml + "</a>";
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
MarkdownView.pictureHtml = function (address, description, context) {
|
|
980
|
+
const text = basic.escapeHtml(description);
|
|
981
|
+
if (!MarkdownView.isSafeAddress(address, MarkdownView.PICTURE_SCHEMES)) return text;
|
|
982
|
+
if (!context.remotePictures && MarkdownView.REMOTE_ADDRESS.test(address)) return MarkdownView.linkHtml(address, text || basic.escapeHtml(address));
|
|
983
|
+
return '<img src="' + basic.escapeHtml(address) + '" alt="' + text + '">';
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
// *** TEXTS:
|
|
987
|
+
|
|
988
|
+
// A text without the marks of Markdown (a heading in a list of headings).
|
|
989
|
+
MarkdownView.plainText = function (text) {
|
|
990
|
+
return String(text)
|
|
991
|
+
.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1")
|
|
992
|
+
.replace(/[`*~]/g, "")
|
|
993
|
+
.replace(/(^|\s)_+|_+(\s|$)/g, "$1$2")
|
|
994
|
+
.replace(/\s+/g, " ")
|
|
995
|
+
.trim();
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
// "Çalışma Özeti" -> "calisma-ozeti". WHY ı apart: it has no accent to take off.
|
|
999
|
+
MarkdownView.slug = function (text) {
|
|
1000
|
+
return String(text)
|
|
1001
|
+
.replace(/[ıİ]/g, "i")
|
|
1002
|
+
.normalize("NFD")
|
|
1003
|
+
.replace(/\p{M}/gu, "")
|
|
1004
|
+
.toLowerCase()
|
|
1005
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
1006
|
+
.replace(/^-+|-+$/g, "")
|
|
1007
|
+
.slice(0, 60);
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
// *** STYLE PACKAGES:
|
|
1011
|
+
// USAGE: MarkdownView({ styleName: "dark" })
|
|
1012
|
+
// USAGE: MarkdownView({ style: { text: { fontSize: 16 } } }) // Change only some keys.
|
|
1013
|
+
// NOTE: A new package needs only the keys that differ from the default (light) style.
|
|
1014
|
+
// USAGE: MarkdownView.styles.myStyle = { box: { color: "#FFFDF5" } };
|
|
1015
|
+
MarkdownView.styles = {
|
|
1016
|
+
|
|
1017
|
+
// A white page.
|
|
1018
|
+
light: MarkdownViewDefaults.style,
|
|
1019
|
+
|
|
1020
|
+
// For a dark window; the code takes the dark colors of CodeEditor.
|
|
1021
|
+
dark: {
|
|
1022
|
+
box: { color: "#1C1C1B" },
|
|
1023
|
+
text: { textColor: White(0.8), softColor: White(0.5), strongColor: White(0.94) },
|
|
1024
|
+
heading: { textColor: White(0.94), lineColor: White(0.12) },
|
|
1025
|
+
link: { color: "#6FC6CD", lineColor: "rgba(111, 198, 205, 0.35)" },
|
|
1026
|
+
inlineCode: { color: White(0.1) },
|
|
1027
|
+
quote: { textColor: White(0.62), lineColor: White(0.2) },
|
|
1028
|
+
table: { lineColor: White(0.16), headColor: White(0.06) },
|
|
1029
|
+
line: { color: White(0.14) },
|
|
1030
|
+
check: { color: White(0.35), onColor: "#6FC6CD", markColor: "#1C1C1B" },
|
|
1031
|
+
code: {
|
|
1032
|
+
color: "#232322",
|
|
1033
|
+
borderColor: White(0.08),
|
|
1034
|
+
textColor: "#E6E6E3",
|
|
1035
|
+
bar: { textColor: White(0.5) },
|
|
1036
|
+
button: { textColor: White(0.65), hoverColor: White(0.09) },
|
|
1037
|
+
},
|
|
1038
|
+
codeStyleName: "dark",
|
|
1039
|
+
empty: { textColor: White(0.5) },
|
|
1040
|
+
focus: { ringColor: "rgba(111, 198, 205, 0.8)" },
|
|
1041
|
+
scrollBar: { bar_color: "#8A8A88", bar_mouseOverColor: "#BFBFBD" },
|
|
1042
|
+
},
|
|
1043
|
+
|
|
1044
|
+
};
|