@nectary/components 3.3.1 → 3.3.3
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/{lib/esm/dialog → dialog}/index.js +0 -2
- package/{lib/esm/input → input}/index.js +8 -0
- package/{lib/cjs/input → input}/types.d.ts +5 -0
- package/{lib/esm/input → input}/utils.d.ts +1 -1
- package/package.json +11 -38
- package/{lib/esm/persistent-overlay → persistent-overlay}/index.d.ts +0 -1
- package/{lib/esm/persistent-overlay → persistent-overlay}/index.js +0 -1
- package/standalone.ts +89 -0
- package/{lib/esm/utils → utils}/element.js +1 -1
- package/lib/cjs/accordion/index.js +0 -88
- package/lib/cjs/accordion/types.js +0 -1
- package/lib/cjs/accordion-item/index.js +0 -97
- package/lib/cjs/accordion-item/types.js +0 -1
- package/lib/cjs/accordion-item/utils.js +0 -7
- package/lib/cjs/action-menu/index.js +0 -197
- package/lib/cjs/action-menu/types.js +0 -1
- package/lib/cjs/action-menu-option/index.js +0 -84
- package/lib/cjs/action-menu-option/types.js +0 -1
- package/lib/cjs/action-menu-option/utils.js +0 -10
- package/lib/cjs/alert/index.js +0 -50
- package/lib/cjs/alert/types.js +0 -1
- package/lib/cjs/alert/utils.js +0 -7
- package/lib/cjs/avatar/index.js +0 -96
- package/lib/cjs/avatar/types.js +0 -1
- package/lib/cjs/avatar/utils.js +0 -15
- package/lib/cjs/badge/index.js +0 -116
- package/lib/cjs/badge/types.js +0 -1
- package/lib/cjs/badge/utils.js +0 -7
- package/lib/cjs/button/index.js +0 -184
- package/lib/cjs/button/types.js +0 -1
- package/lib/cjs/button/utils.js +0 -7
- package/lib/cjs/button-group/index.js +0 -51
- package/lib/cjs/button-group/types.js +0 -1
- package/lib/cjs/button-group-item/index.js +0 -81
- package/lib/cjs/button-group-item/types.js +0 -1
- package/lib/cjs/card/index.js +0 -135
- package/lib/cjs/card/types.js +0 -1
- package/lib/cjs/card-container/index.js +0 -13
- package/lib/cjs/card-container/types.js +0 -1
- package/lib/cjs/checkbox/index.js +0 -128
- package/lib/cjs/checkbox/types.js +0 -1
- package/lib/cjs/chip/index.js +0 -146
- package/lib/cjs/chip/types.js +0 -1
- package/lib/cjs/chip/utils.js +0 -14
- package/lib/cjs/code-tag/index.js +0 -33
- package/lib/cjs/code-tag/types.js +0 -1
- package/lib/cjs/color-menu/index.js +0 -310
- package/lib/cjs/color-menu/types.js +0 -1
- package/lib/cjs/color-menu/utils.js +0 -18
- package/lib/cjs/color-menu-option/index.js +0 -50
- package/lib/cjs/color-menu-option/types.js +0 -1
- package/lib/cjs/color-menu-option/utils.js +0 -18
- package/lib/cjs/color-swatch/index.js +0 -56
- package/lib/cjs/color-swatch/types.js +0 -1
- package/lib/cjs/color-swatch/utils.js +0 -14
- package/lib/cjs/date-picker/index.js +0 -382
- package/lib/cjs/date-picker/types.js +0 -1
- package/lib/cjs/date-picker/utils.js +0 -171
- package/lib/cjs/dialog/index.js +0 -152
- package/lib/cjs/dialog/types.js +0 -1
- package/lib/cjs/dialog/utils.js +0 -26
- package/lib/cjs/emoji/index.js +0 -48
- package/lib/cjs/emoji/types.js +0 -1
- package/lib/cjs/emoji/utils.js +0 -56
- package/lib/cjs/emoji-picker/index.js +0 -310
- package/lib/cjs/emoji-picker/types.js +0 -1
- package/lib/cjs/field/index.js +0 -122
- package/lib/cjs/field/types.js +0 -1
- package/lib/cjs/file-drop/index.js +0 -207
- package/lib/cjs/file-drop/types.js +0 -1
- package/lib/cjs/file-drop/utils.js +0 -39
- package/lib/cjs/file-picker/index.js +0 -105
- package/lib/cjs/file-picker/types.js +0 -1
- package/lib/cjs/file-picker/utils.js +0 -15
- package/lib/cjs/file-status/index.js +0 -63
- package/lib/cjs/file-status/types.js +0 -1
- package/lib/cjs/file-status/utils.js +0 -7
- package/lib/cjs/flag/index.js +0 -48
- package/lib/cjs/flag/types.js +0 -1
- package/lib/cjs/flag/utils.js +0 -24
- package/lib/cjs/grid/index.js +0 -13
- package/lib/cjs/grid/types.js +0 -1
- package/lib/cjs/grid-item/index.js +0 -37
- package/lib/cjs/grid-item/types.js +0 -1
- package/lib/cjs/help-tooltip/index.js +0 -76
- package/lib/cjs/help-tooltip/types.js +0 -1
- package/lib/cjs/horizontal-stepper/index.js +0 -63
- package/lib/cjs/horizontal-stepper/types.js +0 -1
- package/lib/cjs/horizontal-stepper-item/index.js +0 -63
- package/lib/cjs/horizontal-stepper-item/types.js +0 -1
- package/lib/cjs/horizontal-stepper-item/utils.js +0 -7
- package/lib/cjs/icon/index.js +0 -34
- package/lib/cjs/icon/types.js +0 -1
- package/lib/cjs/imports.d.js +0 -1
- package/lib/cjs/imports.d.ts +0 -9
- package/lib/cjs/inline-alert/index.js +0 -85
- package/lib/cjs/inline-alert/types.js +0 -1
- package/lib/cjs/inline-alert/utils.js +0 -7
- package/lib/cjs/input/index.js +0 -644
- package/lib/cjs/input/types.js +0 -1
- package/lib/cjs/input/utils.d.ts +0 -26
- package/lib/cjs/input/utils.js +0 -317
- package/lib/cjs/link/index.js +0 -152
- package/lib/cjs/link/types.js +0 -1
- package/lib/cjs/list/index.js +0 -16
- package/lib/cjs/list/types.js +0 -1
- package/lib/cjs/list-item/index.js +0 -16
- package/lib/cjs/list-item/types.js +0 -1
- package/lib/cjs/pagination/index.js +0 -149
- package/lib/cjs/pagination/types.js +0 -1
- package/lib/cjs/persistent-overlay/index.d.ts +0 -15
- package/lib/cjs/persistent-overlay/index.js +0 -106
- package/lib/cjs/persistent-overlay/types.js +0 -1
- package/lib/cjs/pop/index.js +0 -427
- package/lib/cjs/pop/types.js +0 -1
- package/lib/cjs/pop/utils.js +0 -24
- package/lib/cjs/popover/index.js +0 -148
- package/lib/cjs/popover/types.js +0 -1
- package/lib/cjs/popover/utils.js +0 -17
- package/lib/cjs/progress/index.js +0 -60
- package/lib/cjs/progress/types.js +0 -1
- package/lib/cjs/progress-stepper/index.js +0 -208
- package/lib/cjs/progress-stepper/types.js +0 -1
- package/lib/cjs/progress-stepper-item/index.js +0 -84
- package/lib/cjs/progress-stepper-item/types.js +0 -1
- package/lib/cjs/progress-stepper-item/utils.js +0 -25
- package/lib/cjs/radio/index.js +0 -156
- package/lib/cjs/radio/types.js +0 -1
- package/lib/cjs/radio-option/index.js +0 -81
- package/lib/cjs/radio-option/types.js +0 -1
- package/lib/cjs/rich-text/index.js +0 -77
- package/lib/cjs/rich-text/types.js +0 -1
- package/lib/cjs/rich-text/utils.js +0 -117
- package/lib/cjs/rich-textarea/index.js +0 -466
- package/lib/cjs/rich-textarea/types.js +0 -1
- package/lib/cjs/rich-textarea/utils.js +0 -1754
- package/lib/cjs/segment/index.js +0 -111
- package/lib/cjs/segment/types.js +0 -1
- package/lib/cjs/segment/utils.js +0 -23
- package/lib/cjs/segment-collapse/index.js +0 -61
- package/lib/cjs/segment-collapse/types.js +0 -1
- package/lib/cjs/segmented-control/index.js +0 -87
- package/lib/cjs/segmented-control/types.js +0 -1
- package/lib/cjs/segmented-control-option/index.js +0 -97
- package/lib/cjs/segmented-control-option/types.js +0 -1
- package/lib/cjs/segmented-icon-control/index.js +0 -103
- package/lib/cjs/segmented-icon-control/types.js +0 -1
- package/lib/cjs/segmented-icon-control-option/index.js +0 -84
- package/lib/cjs/segmented-icon-control-option/types.js +0 -1
- package/lib/cjs/select-button/index.js +0 -204
- package/lib/cjs/select-button/types.js +0 -1
- package/lib/cjs/select-menu/index.js +0 -366
- package/lib/cjs/select-menu/types.js +0 -1
- package/lib/cjs/select-menu-option/index.js +0 -72
- package/lib/cjs/select-menu-option/types.js +0 -1
- package/lib/cjs/skeleton/index.js +0 -110
- package/lib/cjs/skeleton/types.js +0 -1
- package/lib/cjs/skeleton-item/index.js +0 -13
- package/lib/cjs/skeleton-item/types.js +0 -1
- package/lib/cjs/spinner/index.js +0 -60
- package/lib/cjs/spinner/types.js +0 -1
- package/lib/cjs/standalone.js +0 -85
- package/lib/cjs/stop-events/index.js +0 -29
- package/lib/cjs/table/index.js +0 -16
- package/lib/cjs/table/types.js +0 -1
- package/lib/cjs/table-body/index.js +0 -16
- package/lib/cjs/table-body/types.js +0 -1
- package/lib/cjs/table-cell/index.js +0 -23
- package/lib/cjs/table-cell/types.js +0 -1
- package/lib/cjs/table-cell/utils.js +0 -7
- package/lib/cjs/table-head/index.js +0 -16
- package/lib/cjs/table-head/types.js +0 -1
- package/lib/cjs/table-head-cell/index.js +0 -59
- package/lib/cjs/table-head-cell/types.js +0 -1
- package/lib/cjs/table-row/index.js +0 -44
- package/lib/cjs/table-row/types.js +0 -1
- package/lib/cjs/tabs/index.js +0 -82
- package/lib/cjs/tabs/types.js +0 -1
- package/lib/cjs/tabs-icon-option/index.js +0 -81
- package/lib/cjs/tabs-icon-option/types.js +0 -1
- package/lib/cjs/tabs-option/index.js +0 -88
- package/lib/cjs/tabs-option/types.js +0 -1
- package/lib/cjs/tag/index.js +0 -86
- package/lib/cjs/tag/types.js +0 -1
- package/lib/cjs/tag/utils.js +0 -14
- package/lib/cjs/text/index.js +0 -66
- package/lib/cjs/text/types.js +0 -1
- package/lib/cjs/text/utils.js +0 -7
- package/lib/cjs/textarea/index.js +0 -324
- package/lib/cjs/textarea/types.js +0 -1
- package/lib/cjs/tile-control/index.js +0 -112
- package/lib/cjs/tile-control/types.js +0 -1
- package/lib/cjs/tile-control-option/index.js +0 -100
- package/lib/cjs/tile-control-option/types.js +0 -1
- package/lib/cjs/time-picker/index.js +0 -338
- package/lib/cjs/time-picker/types.js +0 -1
- package/lib/cjs/time-picker/utils.js +0 -89
- package/lib/cjs/title/index.js +0 -62
- package/lib/cjs/title/types.js +0 -1
- package/lib/cjs/title/utils.js +0 -24
- package/lib/cjs/toast/index.js +0 -88
- package/lib/cjs/toast/types.js +0 -1
- package/lib/cjs/toast/utils.js +0 -7
- package/lib/cjs/toast-manager/index.js +0 -172
- package/lib/cjs/toast-manager/types.js +0 -1
- package/lib/cjs/toast-manager/utils.js +0 -7
- package/lib/cjs/toggle/index.js +0 -143
- package/lib/cjs/toggle/types.js +0 -1
- package/lib/cjs/tooltip/index.js +0 -277
- package/lib/cjs/tooltip/tooltip-state.js +0 -133
- package/lib/cjs/tooltip/types.js +0 -1
- package/lib/cjs/tooltip/utils.js +0 -25
- package/lib/cjs/types.d.js +0 -1
- package/lib/cjs/utils/context.js +0 -92
- package/lib/cjs/utils/countries.js +0 -9
- package/lib/cjs/utils/csv.js +0 -32
- package/lib/cjs/utils/debounce.js +0 -29
- package/lib/cjs/utils/dom.js +0 -183
- package/lib/cjs/utils/element.js +0 -58
- package/lib/cjs/utils/event-target.js +0 -36
- package/lib/cjs/utils/get-react-event-handler.js +0 -15
- package/lib/cjs/utils/index.js +0 -137
- package/lib/cjs/utils/markdown.js +0 -151
- package/lib/cjs/utils/rect.js +0 -37
- package/lib/cjs/utils/size.js +0 -9
- package/lib/cjs/utils/slot.js +0 -47
- package/lib/cjs/utils/throttle.js +0 -26
- package/lib/cjs/utils/uid.js +0 -20
- package/lib/cjs/vertical-stepper/index.js +0 -59
- package/lib/cjs/vertical-stepper/types.js +0 -1
- package/lib/cjs/vertical-stepper-item/index.js +0 -63
- package/lib/cjs/vertical-stepper-item/types.js +0 -1
- package/lib/cjs/vertical-stepper-item/utils.js +0 -7
- package/lib/esm/accordion/index.d.ts +0 -11
- package/lib/esm/accordion/types.d.ts +0 -21
- package/lib/esm/accordion-item/index.d.ts +0 -14
- package/lib/esm/accordion-item/types.d.ts +0 -36
- package/lib/esm/accordion-item/utils.d.ts +0 -2
- package/lib/esm/action-menu/index.d.ts +0 -11
- package/lib/esm/action-menu/types.d.ts +0 -13
- package/lib/esm/action-menu-option/index.d.ts +0 -12
- package/lib/esm/action-menu-option/types.d.ts +0 -23
- package/lib/esm/action-menu-option/utils.d.ts +0 -2
- package/lib/esm/alert/index.d.ts +0 -14
- package/lib/esm/alert/types.d.ts +0 -18
- package/lib/esm/alert/utils.d.ts +0 -2
- package/lib/esm/avatar/index.d.ts +0 -11
- package/lib/esm/avatar/types.d.ts +0 -37
- package/lib/esm/avatar/utils.d.ts +0 -4
- package/lib/esm/badge/index.d.ts +0 -11
- package/lib/esm/badge/types.d.ts +0 -34
- package/lib/esm/badge/utils.d.ts +0 -2
- package/lib/esm/button/index.d.ts +0 -11
- package/lib/esm/button/types.d.ts +0 -53
- package/lib/esm/button/utils.d.ts +0 -2
- package/lib/esm/button-group/index.d.ts +0 -11
- package/lib/esm/button-group/types.d.ts +0 -11
- package/lib/esm/button-group-item/index.d.ts +0 -11
- package/lib/esm/button-group-item/types.d.ts +0 -18
- package/lib/esm/card/index.d.ts +0 -13
- package/lib/esm/card/types.d.ts +0 -28
- package/lib/esm/card-container/index.d.ts +0 -11
- package/lib/esm/card-container/types.d.ts +0 -3
- package/lib/esm/checkbox/index.d.ts +0 -11
- package/lib/esm/checkbox/types.d.ts +0 -49
- package/lib/esm/chip/index.d.ts +0 -13
- package/lib/esm/chip/types.d.ts +0 -37
- package/lib/esm/chip/utils.d.ts +0 -2
- package/lib/esm/code-tag/index.d.ts +0 -11
- package/lib/esm/code-tag/types.d.ts +0 -11
- package/lib/esm/color-menu/index.d.ts +0 -11
- package/lib/esm/color-menu/types.d.ts +0 -32
- package/lib/esm/color-menu/utils.d.ts +0 -1
- package/lib/esm/color-menu-option/index.d.ts +0 -13
- package/lib/esm/color-menu-option/types.d.ts +0 -11
- package/lib/esm/color-menu-option/utils.d.ts +0 -1
- package/lib/esm/color-swatch/index.d.ts +0 -12
- package/lib/esm/color-swatch/types.d.ts +0 -11
- package/lib/esm/color-swatch/utils.d.ts +0 -2
- package/lib/esm/colors.json +0 -88
- package/lib/esm/date-picker/index.d.ts +0 -13
- package/lib/esm/date-picker/types.d.ts +0 -70
- package/lib/esm/date-picker/utils.d.ts +0 -28
- package/lib/esm/dialog/index.d.ts +0 -14
- package/lib/esm/dialog/types.d.ts +0 -28
- package/lib/esm/dialog/utils.d.ts +0 -2
- package/lib/esm/emoji/index.d.ts +0 -11
- package/lib/esm/emoji/types.d.ts +0 -11
- package/lib/esm/emoji/utils.d.ts +0 -3
- package/lib/esm/emoji-picker/data.json +0 -1
- package/lib/esm/emoji-picker/index.d.ts +0 -21
- package/lib/esm/emoji-picker/types.d.ts +0 -26
- package/lib/esm/field/index.d.ts +0 -11
- package/lib/esm/field/types.d.ts +0 -35
- package/lib/esm/file-drop/index.d.ts +0 -13
- package/lib/esm/file-drop/types.d.ts +0 -50
- package/lib/esm/file-drop/utils.d.ts +0 -2
- package/lib/esm/file-picker/index.d.ts +0 -11
- package/lib/esm/file-picker/types.d.ts +0 -32
- package/lib/esm/file-picker/utils.d.ts +0 -1
- package/lib/esm/file-status/index.d.ts +0 -14
- package/lib/esm/file-status/types.d.ts +0 -18
- package/lib/esm/file-status/utils.d.ts +0 -2
- package/lib/esm/flag/index.d.ts +0 -11
- package/lib/esm/flag/types.d.ts +0 -11
- package/lib/esm/flag/utils.d.ts +0 -1
- package/lib/esm/grid/index.d.ts +0 -11
- package/lib/esm/grid/types.d.ts +0 -3
- package/lib/esm/grid-item/index.d.ts +0 -11
- package/lib/esm/grid-item/types.d.ts +0 -17
- package/lib/esm/help-tooltip/index.d.ts +0 -13
- package/lib/esm/help-tooltip/types.d.ts +0 -3
- package/lib/esm/horizontal-stepper/index.d.ts +0 -11
- package/lib/esm/horizontal-stepper/types.d.ts +0 -13
- package/lib/esm/horizontal-stepper-item/index.d.ts +0 -14
- package/lib/esm/horizontal-stepper-item/types.d.ts +0 -24
- package/lib/esm/horizontal-stepper-item/utils.d.ts +0 -2
- package/lib/esm/icon/index.d.ts +0 -11
- package/lib/esm/icon/types.d.ts +0 -11
- package/lib/esm/imports.d.js +0 -0
- package/lib/esm/imports.d.ts +0 -9
- package/lib/esm/inline-alert/index.d.ts +0 -15
- package/lib/esm/inline-alert/types.d.ts +0 -15
- package/lib/esm/inline-alert/utils.d.ts +0 -2
- package/lib/esm/input/index.d.ts +0 -11
- package/lib/esm/input/types.d.ts +0 -86
- package/lib/esm/link/index.d.ts +0 -12
- package/lib/esm/link/types.d.ts +0 -59
- package/lib/esm/list/index.d.ts +0 -11
- package/lib/esm/list/types.d.ts +0 -3
- package/lib/esm/list-item/index.d.ts +0 -11
- package/lib/esm/list-item/types.d.ts +0 -3
- package/lib/esm/pagination/index.d.ts +0 -12
- package/lib/esm/pagination/types.d.ts +0 -16
- package/lib/esm/persistent-overlay/types.d.ts +0 -22
- package/lib/esm/pop/index.d.ts +0 -11
- package/lib/esm/pop/types.d.ts +0 -35
- package/lib/esm/pop/utils.d.ts +0 -4
- package/lib/esm/popover/index.d.ts +0 -12
- package/lib/esm/popover/types.d.ts +0 -38
- package/lib/esm/popover/utils.d.ts +0 -4
- package/lib/esm/progress/index.d.ts +0 -12
- package/lib/esm/progress/types.d.ts +0 -12
- package/lib/esm/progress-stepper/index.d.ts +0 -11
- package/lib/esm/progress-stepper/types.d.ts +0 -22
- package/lib/esm/progress-stepper-item/index.d.ts +0 -12
- package/lib/esm/progress-stepper-item/types.d.ts +0 -23
- package/lib/esm/progress-stepper-item/utils.d.ts +0 -11
- package/lib/esm/radio/index.d.ts +0 -11
- package/lib/esm/radio/types.d.ts +0 -14
- package/lib/esm/radio-option/index.d.ts +0 -11
- package/lib/esm/radio-option/types.d.ts +0 -18
- package/lib/esm/rich-text/index.d.ts +0 -14
- package/lib/esm/rich-text/types.d.ts +0 -12
- package/lib/esm/rich-text/utils.d.ts +0 -7
- package/lib/esm/rich-textarea/index.d.ts +0 -11
- package/lib/esm/rich-textarea/types.d.ts +0 -48
- package/lib/esm/rich-textarea/utils.d.ts +0 -39
- package/lib/esm/segment/index.d.ts +0 -12
- package/lib/esm/segment/types.d.ts +0 -16
- package/lib/esm/segment/utils.d.ts +0 -3
- package/lib/esm/segment-collapse/index.d.ts +0 -12
- package/lib/esm/segment-collapse/types.d.ts +0 -11
- package/lib/esm/segmented-control/index.d.ts +0 -11
- package/lib/esm/segmented-control/types.d.ts +0 -11
- package/lib/esm/segmented-control-option/index.d.ts +0 -11
- package/lib/esm/segmented-control-option/types.d.ts +0 -19
- package/lib/esm/segmented-icon-control/index.d.ts +0 -11
- package/lib/esm/segmented-icon-control/types.d.ts +0 -14
- package/lib/esm/segmented-icon-control-option/index.d.ts +0 -11
- package/lib/esm/segmented-icon-control-option/types.d.ts +0 -16
- package/lib/esm/select-button/index.d.ts +0 -13
- package/lib/esm/select-button/types.d.ts +0 -50
- package/lib/esm/select-menu/index.d.ts +0 -14
- package/lib/esm/select-menu/types.d.ts +0 -45
- package/lib/esm/select-menu-option/index.d.ts +0 -28
- package/lib/esm/select-menu-option/types.d.ts +0 -26
- package/lib/esm/skeleton/index.d.ts +0 -11
- package/lib/esm/skeleton/types.d.ts +0 -9
- package/lib/esm/skeleton-item/index.d.ts +0 -11
- package/lib/esm/skeleton-item/types.d.ts +0 -13
- package/lib/esm/spinner/index.d.ts +0 -11
- package/lib/esm/spinner/types.d.ts +0 -12
- package/lib/esm/standalone.d.ts +0 -81
- package/lib/esm/stop-events/index.d.ts +0 -1
- package/lib/esm/table/index.d.ts +0 -11
- package/lib/esm/table/types.d.ts +0 -3
- package/lib/esm/table-body/index.d.ts +0 -11
- package/lib/esm/table-body/types.d.ts +0 -3
- package/lib/esm/table-cell/index.d.ts +0 -11
- package/lib/esm/table-cell/types.d.ts +0 -9
- package/lib/esm/table-cell/utils.d.ts +0 -2
- package/lib/esm/table-head/index.d.ts +0 -11
- package/lib/esm/table-head/types.d.ts +0 -3
- package/lib/esm/table-head-cell/index.d.ts +0 -12
- package/lib/esm/table-head-cell/types.d.ts +0 -15
- package/lib/esm/table-row/index.d.ts +0 -11
- package/lib/esm/table-row/types.d.ts +0 -11
- package/lib/esm/tabs/index.d.ts +0 -11
- package/lib/esm/tabs/types.d.ts +0 -18
- package/lib/esm/tabs-icon-option/index.d.ts +0 -11
- package/lib/esm/tabs-icon-option/types.d.ts +0 -19
- package/lib/esm/tabs-option/index.d.ts +0 -12
- package/lib/esm/tabs-option/types.d.ts +0 -25
- package/lib/esm/tag/index.d.ts +0 -12
- package/lib/esm/tag/types.d.ts +0 -23
- package/lib/esm/tag/utils.d.ts +0 -2
- package/lib/esm/text/index.d.ts +0 -11
- package/lib/esm/text/types.d.ts +0 -30
- package/lib/esm/text/utils.d.ts +0 -2
- package/lib/esm/textarea/index.d.ts +0 -11
- package/lib/esm/textarea/types.d.ts +0 -60
- package/lib/esm/tile-control/index.d.ts +0 -11
- package/lib/esm/tile-control/types.d.ts +0 -37
- package/lib/esm/tile-control-option/index.d.ts +0 -11
- package/lib/esm/tile-control-option/types.d.ts +0 -37
- package/lib/esm/time-picker/index.d.ts +0 -14
- package/lib/esm/time-picker/types.d.ts +0 -34
- package/lib/esm/time-picker/utils.d.ts +0 -11
- package/lib/esm/title/index.d.ts +0 -11
- package/lib/esm/title/types.d.ts +0 -31
- package/lib/esm/title/utils.d.ts +0 -3
- package/lib/esm/toast/index.d.ts +0 -13
- package/lib/esm/toast/types.d.ts +0 -28
- package/lib/esm/toast/utils.d.ts +0 -2
- package/lib/esm/toast-manager/index.d.ts +0 -13
- package/lib/esm/toast-manager/types.d.ts +0 -13
- package/lib/esm/toast-manager/utils.d.ts +0 -2
- package/lib/esm/toggle/index.d.ts +0 -11
- package/lib/esm/toggle/types.d.ts +0 -23
- package/lib/esm/tooltip/index.d.ts +0 -13
- package/lib/esm/tooltip/tooltip-state.d.ts +0 -19
- package/lib/esm/tooltip/types.d.ts +0 -42
- package/lib/esm/tooltip/utils.d.ts +0 -6
- package/lib/esm/types.d.js +0 -1
- package/lib/esm/types.d.ts +0 -14
- package/lib/esm/utils/context.d.ts +0 -20
- package/lib/esm/utils/countries.d.ts +0 -6
- package/lib/esm/utils/countries.json +0 -1217
- package/lib/esm/utils/csv.d.ts +0 -5
- package/lib/esm/utils/debounce.d.ts +0 -8
- package/lib/esm/utils/dom.d.ts +0 -34
- package/lib/esm/utils/element.d.ts +0 -16
- package/lib/esm/utils/event-target.d.ts +0 -4
- package/lib/esm/utils/get-react-event-handler.d.ts +0 -1
- package/lib/esm/utils/index.d.ts +0 -12
- package/lib/esm/utils/markdown.d.ts +0 -19
- package/lib/esm/utils/rect.d.ts +0 -4
- package/lib/esm/utils/size.d.ts +0 -5
- package/lib/esm/utils/slot.d.ts +0 -4
- package/lib/esm/utils/throttle.d.ts +0 -4
- package/lib/esm/utils/uid.d.ts +0 -1
- package/lib/esm/vertical-stepper/index.d.ts +0 -11
- package/lib/esm/vertical-stepper/types.d.ts +0 -13
- package/lib/esm/vertical-stepper-item/index.d.ts +0 -14
- package/lib/esm/vertical-stepper-item/types.d.ts +0 -24
- package/lib/esm/vertical-stepper-item/utils.d.ts +0 -2
- package/lib/package.json +0 -1
- /package/{lib/cjs/accordion → accordion}/index.d.ts +0 -0
- /package/{lib/esm/accordion → accordion}/index.js +0 -0
- /package/{lib/cjs/accordion → accordion}/types.d.ts +0 -0
- /package/{lib/esm/accordion → accordion}/types.js +0 -0
- /package/{lib/cjs/accordion-item → accordion-item}/index.d.ts +0 -0
- /package/{lib/esm/accordion-item → accordion-item}/index.js +0 -0
- /package/{lib/cjs/accordion-item → accordion-item}/types.d.ts +0 -0
- /package/{lib/esm/accordion-item → accordion-item}/types.js +0 -0
- /package/{lib/cjs/accordion-item → accordion-item}/utils.d.ts +0 -0
- /package/{lib/esm/accordion-item → accordion-item}/utils.js +0 -0
- /package/{lib/cjs/action-menu → action-menu}/index.d.ts +0 -0
- /package/{lib/esm/action-menu → action-menu}/index.js +0 -0
- /package/{lib/cjs/action-menu → action-menu}/types.d.ts +0 -0
- /package/{lib/esm/action-menu → action-menu}/types.js +0 -0
- /package/{lib/cjs/action-menu-option → action-menu-option}/index.d.ts +0 -0
- /package/{lib/esm/action-menu-option → action-menu-option}/index.js +0 -0
- /package/{lib/cjs/action-menu-option → action-menu-option}/types.d.ts +0 -0
- /package/{lib/esm/action-menu-option → action-menu-option}/types.js +0 -0
- /package/{lib/cjs/action-menu-option → action-menu-option}/utils.d.ts +0 -0
- /package/{lib/esm/action-menu-option → action-menu-option}/utils.js +0 -0
- /package/{lib/cjs/alert → alert}/index.d.ts +0 -0
- /package/{lib/esm/alert → alert}/index.js +0 -0
- /package/{lib/cjs/alert → alert}/types.d.ts +0 -0
- /package/{lib/esm/alert → alert}/types.js +0 -0
- /package/{lib/cjs/alert → alert}/utils.d.ts +0 -0
- /package/{lib/esm/alert → alert}/utils.js +0 -0
- /package/{lib/cjs/avatar → avatar}/index.d.ts +0 -0
- /package/{lib/esm/avatar → avatar}/index.js +0 -0
- /package/{lib/cjs/avatar → avatar}/types.d.ts +0 -0
- /package/{lib/esm/avatar → avatar}/types.js +0 -0
- /package/{lib/cjs/avatar → avatar}/utils.d.ts +0 -0
- /package/{lib/esm/avatar → avatar}/utils.js +0 -0
- /package/{lib/cjs/badge → badge}/index.d.ts +0 -0
- /package/{lib/esm/badge → badge}/index.js +0 -0
- /package/{lib/cjs/badge → badge}/types.d.ts +0 -0
- /package/{lib/esm/badge → badge}/types.js +0 -0
- /package/{lib/cjs/badge → badge}/utils.d.ts +0 -0
- /package/{lib/esm/badge → badge}/utils.js +0 -0
- /package/{lib/cjs/button → button}/index.d.ts +0 -0
- /package/{lib/esm/button → button}/index.js +0 -0
- /package/{lib/cjs/button → button}/types.d.ts +0 -0
- /package/{lib/esm/button → button}/types.js +0 -0
- /package/{lib/cjs/button → button}/utils.d.ts +0 -0
- /package/{lib/esm/button → button}/utils.js +0 -0
- /package/{lib/cjs/button-group → button-group}/index.d.ts +0 -0
- /package/{lib/esm/button-group → button-group}/index.js +0 -0
- /package/{lib/cjs/button-group → button-group}/types.d.ts +0 -0
- /package/{lib/esm/button-group → button-group}/types.js +0 -0
- /package/{lib/cjs/button-group-item → button-group-item}/index.d.ts +0 -0
- /package/{lib/esm/button-group-item → button-group-item}/index.js +0 -0
- /package/{lib/cjs/button-group-item → button-group-item}/types.d.ts +0 -0
- /package/{lib/esm/button-group-item → button-group-item}/types.js +0 -0
- /package/{lib/cjs/card → card}/index.d.ts +0 -0
- /package/{lib/esm/card → card}/index.js +0 -0
- /package/{lib/cjs/card → card}/types.d.ts +0 -0
- /package/{lib/esm/card → card}/types.js +0 -0
- /package/{lib/cjs/card-container → card-container}/index.d.ts +0 -0
- /package/{lib/esm/card-container → card-container}/index.js +0 -0
- /package/{lib/cjs/card-container → card-container}/types.d.ts +0 -0
- /package/{lib/esm/card-container → card-container}/types.js +0 -0
- /package/{lib/cjs/checkbox → checkbox}/index.d.ts +0 -0
- /package/{lib/esm/checkbox → checkbox}/index.js +0 -0
- /package/{lib/cjs/checkbox → checkbox}/types.d.ts +0 -0
- /package/{lib/esm/checkbox → checkbox}/types.js +0 -0
- /package/{lib/cjs/chip → chip}/index.d.ts +0 -0
- /package/{lib/esm/chip → chip}/index.js +0 -0
- /package/{lib/cjs/chip → chip}/types.d.ts +0 -0
- /package/{lib/esm/chip → chip}/types.js +0 -0
- /package/{lib/cjs/chip → chip}/utils.d.ts +0 -0
- /package/{lib/esm/chip → chip}/utils.js +0 -0
- /package/{lib/cjs/code-tag → code-tag}/index.d.ts +0 -0
- /package/{lib/esm/code-tag → code-tag}/index.js +0 -0
- /package/{lib/cjs/code-tag → code-tag}/types.d.ts +0 -0
- /package/{lib/esm/code-tag → code-tag}/types.js +0 -0
- /package/{lib/cjs/color-menu → color-menu}/index.d.ts +0 -0
- /package/{lib/esm/color-menu → color-menu}/index.js +0 -0
- /package/{lib/cjs/color-menu → color-menu}/types.d.ts +0 -0
- /package/{lib/esm/color-menu → color-menu}/types.js +0 -0
- /package/{lib/cjs/color-menu → color-menu}/utils.d.ts +0 -0
- /package/{lib/esm/color-menu → color-menu}/utils.js +0 -0
- /package/{lib/cjs/color-menu-option → color-menu-option}/index.d.ts +0 -0
- /package/{lib/esm/color-menu-option → color-menu-option}/index.js +0 -0
- /package/{lib/cjs/color-menu-option → color-menu-option}/types.d.ts +0 -0
- /package/{lib/esm/color-menu-option → color-menu-option}/types.js +0 -0
- /package/{lib/cjs/color-menu-option → color-menu-option}/utils.d.ts +0 -0
- /package/{lib/esm/color-menu-option → color-menu-option}/utils.js +0 -0
- /package/{lib/cjs/color-swatch → color-swatch}/index.d.ts +0 -0
- /package/{lib/esm/color-swatch → color-swatch}/index.js +0 -0
- /package/{lib/cjs/color-swatch → color-swatch}/types.d.ts +0 -0
- /package/{lib/esm/color-swatch → color-swatch}/types.js +0 -0
- /package/{lib/cjs/color-swatch → color-swatch}/utils.d.ts +0 -0
- /package/{lib/esm/color-swatch → color-swatch}/utils.js +0 -0
- /package/{lib/cjs/colors.json → colors.json} +0 -0
- /package/{lib/cjs/date-picker → date-picker}/index.d.ts +0 -0
- /package/{lib/esm/date-picker → date-picker}/index.js +0 -0
- /package/{lib/cjs/date-picker → date-picker}/types.d.ts +0 -0
- /package/{lib/esm/date-picker → date-picker}/types.js +0 -0
- /package/{lib/cjs/date-picker → date-picker}/utils.d.ts +0 -0
- /package/{lib/esm/date-picker → date-picker}/utils.js +0 -0
- /package/{lib/cjs/dialog → dialog}/index.d.ts +0 -0
- /package/{lib/cjs/dialog → dialog}/types.d.ts +0 -0
- /package/{lib/esm/dialog → dialog}/types.js +0 -0
- /package/{lib/cjs/dialog → dialog}/utils.d.ts +0 -0
- /package/{lib/esm/dialog → dialog}/utils.js +0 -0
- /package/{lib/cjs/emoji → emoji}/index.d.ts +0 -0
- /package/{lib/esm/emoji → emoji}/index.js +0 -0
- /package/{lib/cjs/emoji → emoji}/types.d.ts +0 -0
- /package/{lib/esm/emoji → emoji}/types.js +0 -0
- /package/{lib/cjs/emoji → emoji}/utils.d.ts +0 -0
- /package/{lib/esm/emoji → emoji}/utils.js +0 -0
- /package/{lib/cjs/emoji-picker → emoji-picker}/data.json +0 -0
- /package/{lib/cjs/emoji-picker → emoji-picker}/index.d.ts +0 -0
- /package/{lib/esm/emoji-picker → emoji-picker}/index.js +0 -0
- /package/{lib/cjs/emoji-picker → emoji-picker}/types.d.ts +0 -0
- /package/{lib/esm/emoji-picker → emoji-picker}/types.js +0 -0
- /package/{lib/cjs/field → field}/index.d.ts +0 -0
- /package/{lib/esm/field → field}/index.js +0 -0
- /package/{lib/cjs/field → field}/types.d.ts +0 -0
- /package/{lib/esm/field → field}/types.js +0 -0
- /package/{lib/cjs/file-drop → file-drop}/index.d.ts +0 -0
- /package/{lib/esm/file-drop → file-drop}/index.js +0 -0
- /package/{lib/cjs/file-drop → file-drop}/types.d.ts +0 -0
- /package/{lib/esm/file-drop → file-drop}/types.js +0 -0
- /package/{lib/cjs/file-drop → file-drop}/utils.d.ts +0 -0
- /package/{lib/esm/file-drop → file-drop}/utils.js +0 -0
- /package/{lib/cjs/file-picker → file-picker}/index.d.ts +0 -0
- /package/{lib/esm/file-picker → file-picker}/index.js +0 -0
- /package/{lib/cjs/file-picker → file-picker}/types.d.ts +0 -0
- /package/{lib/esm/file-picker → file-picker}/types.js +0 -0
- /package/{lib/cjs/file-picker → file-picker}/utils.d.ts +0 -0
- /package/{lib/esm/file-picker → file-picker}/utils.js +0 -0
- /package/{lib/cjs/file-status → file-status}/index.d.ts +0 -0
- /package/{lib/esm/file-status → file-status}/index.js +0 -0
- /package/{lib/cjs/file-status → file-status}/types.d.ts +0 -0
- /package/{lib/esm/file-status → file-status}/types.js +0 -0
- /package/{lib/cjs/file-status → file-status}/utils.d.ts +0 -0
- /package/{lib/esm/file-status → file-status}/utils.js +0 -0
- /package/{lib/cjs/flag → flag}/index.d.ts +0 -0
- /package/{lib/esm/flag → flag}/index.js +0 -0
- /package/{lib/cjs/flag → flag}/types.d.ts +0 -0
- /package/{lib/esm/flag → flag}/types.js +0 -0
- /package/{lib/cjs/flag → flag}/utils.d.ts +0 -0
- /package/{lib/esm/flag → flag}/utils.js +0 -0
- /package/{lib/cjs/grid → grid}/index.d.ts +0 -0
- /package/{lib/esm/grid → grid}/index.js +0 -0
- /package/{lib/cjs/grid → grid}/types.d.ts +0 -0
- /package/{lib/esm/grid → grid}/types.js +0 -0
- /package/{lib/cjs/grid-item → grid-item}/index.d.ts +0 -0
- /package/{lib/esm/grid-item → grid-item}/index.js +0 -0
- /package/{lib/cjs/grid-item → grid-item}/types.d.ts +0 -0
- /package/{lib/esm/grid-item → grid-item}/types.js +0 -0
- /package/{lib/cjs/help-tooltip → help-tooltip}/index.d.ts +0 -0
- /package/{lib/esm/help-tooltip → help-tooltip}/index.js +0 -0
- /package/{lib/cjs/help-tooltip → help-tooltip}/types.d.ts +0 -0
- /package/{lib/esm/help-tooltip → help-tooltip}/types.js +0 -0
- /package/{lib/cjs/horizontal-stepper → horizontal-stepper}/index.d.ts +0 -0
- /package/{lib/esm/horizontal-stepper → horizontal-stepper}/index.js +0 -0
- /package/{lib/cjs/horizontal-stepper → horizontal-stepper}/types.d.ts +0 -0
- /package/{lib/esm/horizontal-stepper → horizontal-stepper}/types.js +0 -0
- /package/{lib/cjs/horizontal-stepper-item → horizontal-stepper-item}/index.d.ts +0 -0
- /package/{lib/esm/horizontal-stepper-item → horizontal-stepper-item}/index.js +0 -0
- /package/{lib/cjs/horizontal-stepper-item → horizontal-stepper-item}/types.d.ts +0 -0
- /package/{lib/esm/horizontal-stepper-item → horizontal-stepper-item}/types.js +0 -0
- /package/{lib/cjs/horizontal-stepper-item → horizontal-stepper-item}/utils.d.ts +0 -0
- /package/{lib/esm/horizontal-stepper-item → horizontal-stepper-item}/utils.js +0 -0
- /package/{lib/cjs/icon → icon}/index.d.ts +0 -0
- /package/{lib/esm/icon → icon}/index.js +0 -0
- /package/{lib/cjs/icon → icon}/types.d.ts +0 -0
- /package/{lib/esm/icon → icon}/types.js +0 -0
- /package/{lib/cjs/inline-alert → inline-alert}/index.d.ts +0 -0
- /package/{lib/esm/inline-alert → inline-alert}/index.js +0 -0
- /package/{lib/cjs/inline-alert → inline-alert}/types.d.ts +0 -0
- /package/{lib/esm/inline-alert → inline-alert}/types.js +0 -0
- /package/{lib/cjs/inline-alert → inline-alert}/utils.d.ts +0 -0
- /package/{lib/esm/inline-alert → inline-alert}/utils.js +0 -0
- /package/{lib/cjs/input → input}/index.d.ts +0 -0
- /package/{lib/esm/input → input}/types.js +0 -0
- /package/{lib/esm/input → input}/utils.js +0 -0
- /package/{lib/cjs/link → link}/index.d.ts +0 -0
- /package/{lib/esm/link → link}/index.js +0 -0
- /package/{lib/cjs/link → link}/types.d.ts +0 -0
- /package/{lib/esm/link → link}/types.js +0 -0
- /package/{lib/cjs/list → list}/index.d.ts +0 -0
- /package/{lib/esm/list → list}/index.js +0 -0
- /package/{lib/cjs/list → list}/types.d.ts +0 -0
- /package/{lib/esm/list → list}/types.js +0 -0
- /package/{lib/cjs/list-item → list-item}/index.d.ts +0 -0
- /package/{lib/esm/list-item → list-item}/index.js +0 -0
- /package/{lib/cjs/list-item → list-item}/types.d.ts +0 -0
- /package/{lib/esm/list-item → list-item}/types.js +0 -0
- /package/{lib/cjs/pagination → pagination}/index.d.ts +0 -0
- /package/{lib/esm/pagination → pagination}/index.js +0 -0
- /package/{lib/cjs/pagination → pagination}/types.d.ts +0 -0
- /package/{lib/esm/pagination → pagination}/types.js +0 -0
- /package/{lib/cjs/persistent-overlay → persistent-overlay}/types.d.ts +0 -0
- /package/{lib/esm/persistent-overlay → persistent-overlay}/types.js +0 -0
- /package/{lib/cjs/pop → pop}/index.d.ts +0 -0
- /package/{lib/esm/pop → pop}/index.js +0 -0
- /package/{lib/cjs/pop → pop}/types.d.ts +0 -0
- /package/{lib/esm/pop → pop}/types.js +0 -0
- /package/{lib/cjs/pop → pop}/utils.d.ts +0 -0
- /package/{lib/esm/pop → pop}/utils.js +0 -0
- /package/{lib/cjs/popover → popover}/index.d.ts +0 -0
- /package/{lib/esm/popover → popover}/index.js +0 -0
- /package/{lib/cjs/popover → popover}/types.d.ts +0 -0
- /package/{lib/esm/popover → popover}/types.js +0 -0
- /package/{lib/cjs/popover → popover}/utils.d.ts +0 -0
- /package/{lib/esm/popover → popover}/utils.js +0 -0
- /package/{lib/cjs/progress → progress}/index.d.ts +0 -0
- /package/{lib/esm/progress → progress}/index.js +0 -0
- /package/{lib/cjs/progress → progress}/types.d.ts +0 -0
- /package/{lib/esm/progress → progress}/types.js +0 -0
- /package/{lib/cjs/progress-stepper → progress-stepper}/index.d.ts +0 -0
- /package/{lib/esm/progress-stepper → progress-stepper}/index.js +0 -0
- /package/{lib/cjs/progress-stepper → progress-stepper}/types.d.ts +0 -0
- /package/{lib/esm/progress-stepper → progress-stepper}/types.js +0 -0
- /package/{lib/cjs/progress-stepper-item → progress-stepper-item}/index.d.ts +0 -0
- /package/{lib/esm/progress-stepper-item → progress-stepper-item}/index.js +0 -0
- /package/{lib/cjs/progress-stepper-item → progress-stepper-item}/types.d.ts +0 -0
- /package/{lib/esm/progress-stepper-item → progress-stepper-item}/types.js +0 -0
- /package/{lib/cjs/progress-stepper-item → progress-stepper-item}/utils.d.ts +0 -0
- /package/{lib/esm/progress-stepper-item → progress-stepper-item}/utils.js +0 -0
- /package/{lib/cjs/radio → radio}/index.d.ts +0 -0
- /package/{lib/esm/radio → radio}/index.js +0 -0
- /package/{lib/cjs/radio → radio}/types.d.ts +0 -0
- /package/{lib/esm/radio → radio}/types.js +0 -0
- /package/{lib/cjs/radio-option → radio-option}/index.d.ts +0 -0
- /package/{lib/esm/radio-option → radio-option}/index.js +0 -0
- /package/{lib/cjs/radio-option → radio-option}/types.d.ts +0 -0
- /package/{lib/esm/radio-option → radio-option}/types.js +0 -0
- /package/{lib/cjs/rich-text → rich-text}/index.d.ts +0 -0
- /package/{lib/esm/rich-text → rich-text}/index.js +0 -0
- /package/{lib/cjs/rich-text → rich-text}/types.d.ts +0 -0
- /package/{lib/esm/rich-text → rich-text}/types.js +0 -0
- /package/{lib/cjs/rich-text → rich-text}/utils.d.ts +0 -0
- /package/{lib/esm/rich-text → rich-text}/utils.js +0 -0
- /package/{lib/cjs/rich-textarea → rich-textarea}/index.d.ts +0 -0
- /package/{lib/esm/rich-textarea → rich-textarea}/index.js +0 -0
- /package/{lib/cjs/rich-textarea → rich-textarea}/types.d.ts +0 -0
- /package/{lib/esm/rich-textarea → rich-textarea}/types.js +0 -0
- /package/{lib/cjs/rich-textarea → rich-textarea}/utils.d.ts +0 -0
- /package/{lib/esm/rich-textarea → rich-textarea}/utils.js +0 -0
- /package/{lib/cjs/segment → segment}/index.d.ts +0 -0
- /package/{lib/esm/segment → segment}/index.js +0 -0
- /package/{lib/cjs/segment → segment}/types.d.ts +0 -0
- /package/{lib/esm/segment → segment}/types.js +0 -0
- /package/{lib/cjs/segment → segment}/utils.d.ts +0 -0
- /package/{lib/esm/segment → segment}/utils.js +0 -0
- /package/{lib/cjs/segment-collapse → segment-collapse}/index.d.ts +0 -0
- /package/{lib/esm/segment-collapse → segment-collapse}/index.js +0 -0
- /package/{lib/cjs/segment-collapse → segment-collapse}/types.d.ts +0 -0
- /package/{lib/esm/segment-collapse → segment-collapse}/types.js +0 -0
- /package/{lib/cjs/segmented-control → segmented-control}/index.d.ts +0 -0
- /package/{lib/esm/segmented-control → segmented-control}/index.js +0 -0
- /package/{lib/cjs/segmented-control → segmented-control}/types.d.ts +0 -0
- /package/{lib/esm/segmented-control → segmented-control}/types.js +0 -0
- /package/{lib/cjs/segmented-control-option → segmented-control-option}/index.d.ts +0 -0
- /package/{lib/esm/segmented-control-option → segmented-control-option}/index.js +0 -0
- /package/{lib/cjs/segmented-control-option → segmented-control-option}/types.d.ts +0 -0
- /package/{lib/esm/segmented-control-option → segmented-control-option}/types.js +0 -0
- /package/{lib/cjs/segmented-icon-control → segmented-icon-control}/index.d.ts +0 -0
- /package/{lib/esm/segmented-icon-control → segmented-icon-control}/index.js +0 -0
- /package/{lib/cjs/segmented-icon-control → segmented-icon-control}/types.d.ts +0 -0
- /package/{lib/esm/segmented-icon-control → segmented-icon-control}/types.js +0 -0
- /package/{lib/cjs/segmented-icon-control-option → segmented-icon-control-option}/index.d.ts +0 -0
- /package/{lib/esm/segmented-icon-control-option → segmented-icon-control-option}/index.js +0 -0
- /package/{lib/cjs/segmented-icon-control-option → segmented-icon-control-option}/types.d.ts +0 -0
- /package/{lib/esm/segmented-icon-control-option → segmented-icon-control-option}/types.js +0 -0
- /package/{lib/cjs/select-button → select-button}/index.d.ts +0 -0
- /package/{lib/esm/select-button → select-button}/index.js +0 -0
- /package/{lib/cjs/select-button → select-button}/types.d.ts +0 -0
- /package/{lib/esm/select-button → select-button}/types.js +0 -0
- /package/{lib/cjs/select-menu → select-menu}/index.d.ts +0 -0
- /package/{lib/esm/select-menu → select-menu}/index.js +0 -0
- /package/{lib/cjs/select-menu → select-menu}/types.d.ts +0 -0
- /package/{lib/esm/select-menu → select-menu}/types.js +0 -0
- /package/{lib/cjs/select-menu-option → select-menu-option}/index.d.ts +0 -0
- /package/{lib/esm/select-menu-option → select-menu-option}/index.js +0 -0
- /package/{lib/cjs/select-menu-option → select-menu-option}/types.d.ts +0 -0
- /package/{lib/esm/select-menu-option → select-menu-option}/types.js +0 -0
- /package/{lib/cjs/skeleton → skeleton}/index.d.ts +0 -0
- /package/{lib/esm/skeleton → skeleton}/index.js +0 -0
- /package/{lib/cjs/skeleton → skeleton}/types.d.ts +0 -0
- /package/{lib/esm/skeleton → skeleton}/types.js +0 -0
- /package/{lib/cjs/skeleton-item → skeleton-item}/index.d.ts +0 -0
- /package/{lib/esm/skeleton-item → skeleton-item}/index.js +0 -0
- /package/{lib/cjs/skeleton-item → skeleton-item}/types.d.ts +0 -0
- /package/{lib/esm/skeleton-item → skeleton-item}/types.js +0 -0
- /package/{lib/cjs/spinner → spinner}/index.d.ts +0 -0
- /package/{lib/esm/spinner → spinner}/index.js +0 -0
- /package/{lib/cjs/spinner → spinner}/types.d.ts +0 -0
- /package/{lib/esm/spinner → spinner}/types.js +0 -0
- /package/{lib/cjs/standalone.d.ts → standalone.d.ts} +0 -0
- /package/{lib/esm/standalone.js → standalone.js} +0 -0
- /package/{lib/cjs/stop-events → stop-events}/index.d.ts +0 -0
- /package/{lib/esm/stop-events → stop-events}/index.js +0 -0
- /package/{lib/cjs/table → table}/index.d.ts +0 -0
- /package/{lib/esm/table → table}/index.js +0 -0
- /package/{lib/cjs/table → table}/types.d.ts +0 -0
- /package/{lib/esm/table → table}/types.js +0 -0
- /package/{lib/cjs/table-body → table-body}/index.d.ts +0 -0
- /package/{lib/esm/table-body → table-body}/index.js +0 -0
- /package/{lib/cjs/table-body → table-body}/types.d.ts +0 -0
- /package/{lib/esm/table-body → table-body}/types.js +0 -0
- /package/{lib/cjs/table-cell → table-cell}/index.d.ts +0 -0
- /package/{lib/esm/table-cell → table-cell}/index.js +0 -0
- /package/{lib/cjs/table-cell → table-cell}/types.d.ts +0 -0
- /package/{lib/esm/table-cell → table-cell}/types.js +0 -0
- /package/{lib/cjs/table-cell → table-cell}/utils.d.ts +0 -0
- /package/{lib/esm/table-cell → table-cell}/utils.js +0 -0
- /package/{lib/cjs/table-head → table-head}/index.d.ts +0 -0
- /package/{lib/esm/table-head → table-head}/index.js +0 -0
- /package/{lib/cjs/table-head → table-head}/types.d.ts +0 -0
- /package/{lib/esm/table-head → table-head}/types.js +0 -0
- /package/{lib/cjs/table-head-cell → table-head-cell}/index.d.ts +0 -0
- /package/{lib/esm/table-head-cell → table-head-cell}/index.js +0 -0
- /package/{lib/cjs/table-head-cell → table-head-cell}/types.d.ts +0 -0
- /package/{lib/esm/table-head-cell → table-head-cell}/types.js +0 -0
- /package/{lib/cjs/table-row → table-row}/index.d.ts +0 -0
- /package/{lib/esm/table-row → table-row}/index.js +0 -0
- /package/{lib/cjs/table-row → table-row}/types.d.ts +0 -0
- /package/{lib/esm/table-row → table-row}/types.js +0 -0
- /package/{lib/cjs/tabs → tabs}/index.d.ts +0 -0
- /package/{lib/esm/tabs → tabs}/index.js +0 -0
- /package/{lib/cjs/tabs → tabs}/types.d.ts +0 -0
- /package/{lib/esm/tabs → tabs}/types.js +0 -0
- /package/{lib/cjs/tabs-icon-option → tabs-icon-option}/index.d.ts +0 -0
- /package/{lib/esm/tabs-icon-option → tabs-icon-option}/index.js +0 -0
- /package/{lib/cjs/tabs-icon-option → tabs-icon-option}/types.d.ts +0 -0
- /package/{lib/esm/tabs-icon-option → tabs-icon-option}/types.js +0 -0
- /package/{lib/cjs/tabs-option → tabs-option}/index.d.ts +0 -0
- /package/{lib/esm/tabs-option → tabs-option}/index.js +0 -0
- /package/{lib/cjs/tabs-option → tabs-option}/types.d.ts +0 -0
- /package/{lib/esm/tabs-option → tabs-option}/types.js +0 -0
- /package/{lib/cjs/tag → tag}/index.d.ts +0 -0
- /package/{lib/esm/tag → tag}/index.js +0 -0
- /package/{lib/cjs/tag → tag}/types.d.ts +0 -0
- /package/{lib/esm/tag → tag}/types.js +0 -0
- /package/{lib/cjs/tag → tag}/utils.d.ts +0 -0
- /package/{lib/esm/tag → tag}/utils.js +0 -0
- /package/{lib/cjs/text → text}/index.d.ts +0 -0
- /package/{lib/esm/text → text}/index.js +0 -0
- /package/{lib/cjs/text → text}/types.d.ts +0 -0
- /package/{lib/esm/text → text}/types.js +0 -0
- /package/{lib/cjs/text → text}/utils.d.ts +0 -0
- /package/{lib/esm/text → text}/utils.js +0 -0
- /package/{lib/cjs/textarea → textarea}/index.d.ts +0 -0
- /package/{lib/esm/textarea → textarea}/index.js +0 -0
- /package/{lib/cjs/textarea → textarea}/types.d.ts +0 -0
- /package/{lib/esm/textarea → textarea}/types.js +0 -0
- /package/{lib/cjs/tile-control → tile-control}/index.d.ts +0 -0
- /package/{lib/esm/tile-control → tile-control}/index.js +0 -0
- /package/{lib/cjs/tile-control → tile-control}/types.d.ts +0 -0
- /package/{lib/esm/tile-control → tile-control}/types.js +0 -0
- /package/{lib/cjs/tile-control-option → tile-control-option}/index.d.ts +0 -0
- /package/{lib/esm/tile-control-option → tile-control-option}/index.js +0 -0
- /package/{lib/cjs/tile-control-option → tile-control-option}/types.d.ts +0 -0
- /package/{lib/esm/tile-control-option → tile-control-option}/types.js +0 -0
- /package/{lib/cjs/time-picker → time-picker}/index.d.ts +0 -0
- /package/{lib/esm/time-picker → time-picker}/index.js +0 -0
- /package/{lib/cjs/time-picker → time-picker}/types.d.ts +0 -0
- /package/{lib/esm/time-picker → time-picker}/types.js +0 -0
- /package/{lib/cjs/time-picker → time-picker}/utils.d.ts +0 -0
- /package/{lib/esm/time-picker → time-picker}/utils.js +0 -0
- /package/{lib/cjs/title → title}/index.d.ts +0 -0
- /package/{lib/esm/title → title}/index.js +0 -0
- /package/{lib/cjs/title → title}/types.d.ts +0 -0
- /package/{lib/esm/title → title}/types.js +0 -0
- /package/{lib/cjs/title → title}/utils.d.ts +0 -0
- /package/{lib/esm/title → title}/utils.js +0 -0
- /package/{lib/cjs/toast → toast}/index.d.ts +0 -0
- /package/{lib/esm/toast → toast}/index.js +0 -0
- /package/{lib/cjs/toast → toast}/types.d.ts +0 -0
- /package/{lib/esm/toast → toast}/types.js +0 -0
- /package/{lib/cjs/toast → toast}/utils.d.ts +0 -0
- /package/{lib/esm/toast → toast}/utils.js +0 -0
- /package/{lib/cjs/toast-manager → toast-manager}/index.d.ts +0 -0
- /package/{lib/esm/toast-manager → toast-manager}/index.js +0 -0
- /package/{lib/cjs/toast-manager → toast-manager}/types.d.ts +0 -0
- /package/{lib/esm/toast-manager → toast-manager}/types.js +0 -0
- /package/{lib/cjs/toast-manager → toast-manager}/utils.d.ts +0 -0
- /package/{lib/esm/toast-manager → toast-manager}/utils.js +0 -0
- /package/{lib/cjs/toggle → toggle}/index.d.ts +0 -0
- /package/{lib/esm/toggle → toggle}/index.js +0 -0
- /package/{lib/cjs/toggle → toggle}/types.d.ts +0 -0
- /package/{lib/esm/toggle → toggle}/types.js +0 -0
- /package/{lib/cjs/tooltip → tooltip}/index.d.ts +0 -0
- /package/{lib/esm/tooltip → tooltip}/index.js +0 -0
- /package/{lib/cjs/tooltip → tooltip}/tooltip-state.d.ts +0 -0
- /package/{lib/esm/tooltip → tooltip}/tooltip-state.js +0 -0
- /package/{lib/cjs/tooltip → tooltip}/types.d.ts +0 -0
- /package/{lib/esm/tooltip → tooltip}/types.js +0 -0
- /package/{lib/cjs/tooltip → tooltip}/utils.d.ts +0 -0
- /package/{lib/esm/tooltip → tooltip}/utils.js +0 -0
- /package/{lib/cjs/types.d.ts → types.d.ts} +0 -0
- /package/{lib/cjs/utils → utils}/context.d.ts +0 -0
- /package/{lib/esm/utils → utils}/context.js +0 -0
- /package/{lib/cjs/utils → utils}/countries.d.ts +0 -0
- /package/{lib/esm/utils → utils}/countries.js +0 -0
- /package/{lib/cjs/utils → utils}/countries.json +0 -0
- /package/{lib/cjs/utils → utils}/csv.d.ts +0 -0
- /package/{lib/esm/utils → utils}/csv.js +0 -0
- /package/{lib/cjs/utils → utils}/debounce.d.ts +0 -0
- /package/{lib/esm/utils → utils}/debounce.js +0 -0
- /package/{lib/cjs/utils → utils}/dom.d.ts +0 -0
- /package/{lib/esm/utils → utils}/dom.js +0 -0
- /package/{lib/cjs/utils → utils}/element.d.ts +0 -0
- /package/{lib/cjs/utils → utils}/event-target.d.ts +0 -0
- /package/{lib/esm/utils → utils}/event-target.js +0 -0
- /package/{lib/cjs/utils → utils}/get-react-event-handler.d.ts +0 -0
- /package/{lib/esm/utils → utils}/get-react-event-handler.js +0 -0
- /package/{lib/cjs/utils → utils}/index.d.ts +0 -0
- /package/{lib/esm/utils → utils}/index.js +0 -0
- /package/{lib/cjs/utils → utils}/markdown.d.ts +0 -0
- /package/{lib/esm/utils → utils}/markdown.js +0 -0
- /package/{lib/cjs/utils → utils}/rect.d.ts +0 -0
- /package/{lib/esm/utils → utils}/rect.js +0 -0
- /package/{lib/cjs/utils → utils}/size.d.ts +0 -0
- /package/{lib/esm/utils → utils}/size.js +0 -0
- /package/{lib/cjs/utils → utils}/slot.d.ts +0 -0
- /package/{lib/esm/utils → utils}/slot.js +0 -0
- /package/{lib/cjs/utils → utils}/throttle.d.ts +0 -0
- /package/{lib/esm/utils → utils}/throttle.js +0 -0
- /package/{lib/cjs/utils → utils}/uid.d.ts +0 -0
- /package/{lib/esm/utils → utils}/uid.js +0 -0
- /package/{lib/cjs/vertical-stepper → vertical-stepper}/index.d.ts +0 -0
- /package/{lib/esm/vertical-stepper → vertical-stepper}/index.js +0 -0
- /package/{lib/cjs/vertical-stepper → vertical-stepper}/types.d.ts +0 -0
- /package/{lib/esm/vertical-stepper → vertical-stepper}/types.js +0 -0
- /package/{lib/cjs/vertical-stepper-item → vertical-stepper-item}/index.d.ts +0 -0
- /package/{lib/esm/vertical-stepper-item → vertical-stepper-item}/index.js +0 -0
- /package/{lib/cjs/vertical-stepper-item → vertical-stepper-item}/types.d.ts +0 -0
- /package/{lib/esm/vertical-stepper-item → vertical-stepper-item}/types.js +0 -0
- /package/{lib/cjs/vertical-stepper-item → vertical-stepper-item}/utils.d.ts +0 -0
- /package/{lib/esm/vertical-stepper-item → vertical-stepper-item}/utils.js +0 -0
|
@@ -1,1754 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setBrowserCaret = exports.serializeMarkdown = exports.isSelectionEqual = exports.isEditorEmpty = exports.insertText = exports.insertLink = exports.insertLineBreak = exports.insertFromPaste = exports.handleEmojiMousedown = exports.getSelectionInfo = exports.getEndRange = exports.getBeginRange = exports.formatOutdent = exports.formatList = exports.formatInline = exports.formatIndent = exports.deleteContentBackward = exports.createParseVisitor = void 0;
|
|
7
|
-
var _utils = require('../emoji/utils');
|
|
8
|
-
var _utils2 = require('../utils');
|
|
9
|
-
const TEXT_EMPTY_DATA = '';
|
|
10
|
-
const TEXT_WHITESPACE = ' ';
|
|
11
|
-
const isTextNode = $n => $n !== null && $n.nodeType === Node.TEXT_NODE;
|
|
12
|
-
const isEmptyText = value => value === null || value.length === 0 || value === TEXT_EMPTY_DATA;
|
|
13
|
-
const isEmptyTextNode = $n => isTextNode($n) && isEmptyText($n.nodeValue);
|
|
14
|
-
const getTextValue = $n => isEmptyText($n.nodeValue) ? TEXT_EMPTY_DATA : $n.nodeValue;
|
|
15
|
-
const isParagraph = $n => {
|
|
16
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains('p');
|
|
17
|
-
};
|
|
18
|
-
const isListItem = $n => {
|
|
19
|
-
return isUnorderedListItem($n) || isOrderedListItem($n);
|
|
20
|
-
};
|
|
21
|
-
const isUnorderedListItem = $n => {
|
|
22
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains('uli');
|
|
23
|
-
};
|
|
24
|
-
const isOrderedListItem = $n => {
|
|
25
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains('oli');
|
|
26
|
-
};
|
|
27
|
-
const isTextBlock = $n => isParagraph($n) || isListItem($n);
|
|
28
|
-
const isEmoji = $n => {
|
|
29
|
-
return $n !== null && $n.nodeName === 'IMG';
|
|
30
|
-
};
|
|
31
|
-
const isInline = $n => $n !== null && $n.nodeName === 'SPAN';
|
|
32
|
-
const isRoot = $n => $n !== null && $n.nodeName === 'DIV';
|
|
33
|
-
const assertNonNull = $n => {
|
|
34
|
-
if ($n === null) {
|
|
35
|
-
throw new Error('Node is NULL');
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const assertEquals = (a, b) => {
|
|
39
|
-
if (a !== b) {
|
|
40
|
-
throw new Error(`"${a}" not equals "${b}"`);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const assertTextNode = $n => {
|
|
44
|
-
assertNonNull($n);
|
|
45
|
-
if (!isTextNode($n)) {
|
|
46
|
-
throw new Error(`Node is not a TextNode: ${$n?.nodeName}`);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const assertTextBlock = $n => {
|
|
50
|
-
assertNonNull($n);
|
|
51
|
-
if (!isTextBlock($n)) {
|
|
52
|
-
throw new Error(`Node is not a TextBlock: ${$n?.nodeName}`);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const assertListItem = $n => {
|
|
56
|
-
assertNonNull($n);
|
|
57
|
-
if (!isListItem($n)) {
|
|
58
|
-
throw new Error(`Node is not a ListItem: ${$n?.nodeName}`);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const markListItemAsBlock = $li => {
|
|
62
|
-
$li.classList.add('block');
|
|
63
|
-
};
|
|
64
|
-
const isListItemMarkedArBlock = $li => {
|
|
65
|
-
return $li.classList.contains('block');
|
|
66
|
-
};
|
|
67
|
-
const MAX_LISTITEM_LEVEL = 4;
|
|
68
|
-
const removeListItemLevel = $li => {
|
|
69
|
-
$li.classList.remove('l0', 'l1', 'l2', 'l3', 'l4');
|
|
70
|
-
};
|
|
71
|
-
const setListItemLevel = ($li, level) => {
|
|
72
|
-
removeListItemLevel($li);
|
|
73
|
-
const clampedLevel = Math.max(0, Math.min(level, MAX_LISTITEM_LEVEL));
|
|
74
|
-
$li.classList.add(`l${clampedLevel}`);
|
|
75
|
-
};
|
|
76
|
-
const getListItemLevel = $li => {
|
|
77
|
-
if ($li.classList.contains('l1')) {
|
|
78
|
-
return 1;
|
|
79
|
-
}
|
|
80
|
-
if ($li.classList.contains('l2')) {
|
|
81
|
-
return 2;
|
|
82
|
-
}
|
|
83
|
-
if ($li.classList.contains('l3')) {
|
|
84
|
-
return 3;
|
|
85
|
-
}
|
|
86
|
-
if ($li.classList.contains('l4')) {
|
|
87
|
-
return 4;
|
|
88
|
-
}
|
|
89
|
-
return 0;
|
|
90
|
-
};
|
|
91
|
-
const assertInline = $n => {
|
|
92
|
-
assertNonNull($n);
|
|
93
|
-
if (!isInline($n)) {
|
|
94
|
-
throw new Error(`Node is not an Inline: ${$n?.nodeName}`);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const isTextContent = $n => {
|
|
98
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && (isInline($n) || isEmoji($n));
|
|
99
|
-
};
|
|
100
|
-
const assertTextContent = $n => {
|
|
101
|
-
assertNonNull($n);
|
|
102
|
-
if (!isTextContent($n)) {
|
|
103
|
-
throw new Error(`Node is not TextContent: ${$n?.nodeName}`);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const createTextNode = (data, doc) => {
|
|
107
|
-
return doc.createTextNode(data);
|
|
108
|
-
};
|
|
109
|
-
const createEmptyTextNode = doc => {
|
|
110
|
-
return createTextNode(TEXT_EMPTY_DATA, doc);
|
|
111
|
-
};
|
|
112
|
-
const createEmptyInline = doc => {
|
|
113
|
-
const res = doc.createElement('SPAN');
|
|
114
|
-
res.append(createEmptyTextNode(doc));
|
|
115
|
-
return res;
|
|
116
|
-
};
|
|
117
|
-
const getParentInline = $n => {
|
|
118
|
-
const $p = $n.parentNode;
|
|
119
|
-
assertInline($p);
|
|
120
|
-
return $p;
|
|
121
|
-
};
|
|
122
|
-
const isInsideList = (isOrdered, $n) => {
|
|
123
|
-
const $block = getParentTextBlock($n);
|
|
124
|
-
return isOrdered ? isOrderedListItem($block) : isUnorderedListItem($block);
|
|
125
|
-
};
|
|
126
|
-
const isAllInsideList = (isOrdered, $a, $b) => {
|
|
127
|
-
return allSiblingsIncludingSatisfy(getParentTextBlock($a), getParentTextBlock($b), isOrdered ? isOrderedListItem : isUnorderedListItem);
|
|
128
|
-
};
|
|
129
|
-
const FORMAT_TYPE_TO_NAME = {
|
|
130
|
-
formatBold: 'b',
|
|
131
|
-
formatCodeTag: 'c',
|
|
132
|
-
formatItalic: 'i',
|
|
133
|
-
formatStrikeThrough: 's'
|
|
134
|
-
};
|
|
135
|
-
const isFormatName = ($n, inlineName) => {
|
|
136
|
-
return $n.classList.contains(inlineName);
|
|
137
|
-
};
|
|
138
|
-
const isFormatBold = $n => isFormatName($n, 'b');
|
|
139
|
-
const isFormatItalic = $n => isFormatName($n, 'i');
|
|
140
|
-
const isFormatStrikethrough = $n => isFormatName($n, 's');
|
|
141
|
-
const isFormatCodetag = $n => isFormatName($n, 'c');
|
|
142
|
-
const isFormatLink = $n => isFormatName($n, 'l');
|
|
143
|
-
const isAllInsideFormatName = ($a, $b, formatName) => {
|
|
144
|
-
const aBlock = getParentTextBlock($a);
|
|
145
|
-
const bBlock = getParentTextBlock($b);
|
|
146
|
-
let $currentBlock = aBlock;
|
|
147
|
-
let $prevBlock = null;
|
|
148
|
-
let hasTextNodes = false;
|
|
149
|
-
do {
|
|
150
|
-
let $n = $currentBlock === getParentTextBlock($a) ? $a : getFirstTextContent($currentBlock);
|
|
151
|
-
let $prev = $n;
|
|
152
|
-
do {
|
|
153
|
-
if (isInline($n)) {
|
|
154
|
-
hasTextNodes = true;
|
|
155
|
-
if (!isFormatName($n, formatName)) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
$prev = $n;
|
|
160
|
-
$n = getNextSiblingTextContent($n);
|
|
161
|
-
} while ($n !== null && $prev !== $b);
|
|
162
|
-
$prevBlock = $currentBlock;
|
|
163
|
-
$currentBlock = getNextSiblingTextBlock($currentBlock);
|
|
164
|
-
} while ($currentBlock !== null && $prevBlock !== bBlock);
|
|
165
|
-
return hasTextNodes;
|
|
166
|
-
};
|
|
167
|
-
const isAllInsideBold = ($a, $b) => isAllInsideFormatName($a, $b, 'b');
|
|
168
|
-
const isAllInsideItalic = ($a, $b) => isAllInsideFormatName($a, $b, 'i');
|
|
169
|
-
const isAllInsideStrikethrough = ($a, $b) => isAllInsideFormatName($a, $b, 's');
|
|
170
|
-
const isAllInsideCodetag = ($a, $b) => isAllInsideFormatName($a, $b, 'c');
|
|
171
|
-
const isAllInsideLink = ($a, $b) => isAllInsideFormatName($a, $b, 'l');
|
|
172
|
-
const LINK_HREF_ATTR_NAME = 'data-href';
|
|
173
|
-
const copyFormatName = ($source, $target) => {
|
|
174
|
-
const $inline = isTextNode($source) ? getParentInline($source) : $source;
|
|
175
|
-
$target.className = $inline.className;
|
|
176
|
-
if (isFormatLink($inline)) {
|
|
177
|
-
$target.setAttribute(LINK_HREF_ATTR_NAME, $inline.getAttribute(LINK_HREF_ATTR_NAME) ?? '');
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
const setInlineFormat = ($n, formatName, shouldEnable) => {
|
|
181
|
-
if (shouldEnable) {
|
|
182
|
-
if (formatName === 'c' || isFormatName($n, 'c')) {
|
|
183
|
-
$n.className = '';
|
|
184
|
-
}
|
|
185
|
-
if (formatName === 'l' || isFormatName($n, 'l')) {
|
|
186
|
-
$n.className = '';
|
|
187
|
-
$n.removeAttribute(LINK_HREF_ATTR_NAME);
|
|
188
|
-
}
|
|
189
|
-
$n.classList.add(formatName);
|
|
190
|
-
} else {
|
|
191
|
-
if (formatName === 'l') {
|
|
192
|
-
$n.removeAttribute(LINK_HREF_ATTR_NAME);
|
|
193
|
-
}
|
|
194
|
-
$n.classList.remove(formatName);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
const setAllInlineFormat = ($a, $b, formatName, shouldEnable) => {
|
|
198
|
-
const aBlock = getParentTextBlock($a);
|
|
199
|
-
const bBlock = getParentTextBlock($b);
|
|
200
|
-
let $currentBlock = aBlock;
|
|
201
|
-
let $prevBlock = null;
|
|
202
|
-
do {
|
|
203
|
-
let $n = $currentBlock === getParentTextBlock($a) ? $a : getFirstTextContent($currentBlock);
|
|
204
|
-
let $prev = $n;
|
|
205
|
-
do {
|
|
206
|
-
if (isInline($n)) {
|
|
207
|
-
setInlineFormat($n, formatName, shouldEnable);
|
|
208
|
-
}
|
|
209
|
-
$prev = $n;
|
|
210
|
-
$n = getNextSiblingTextContent($n);
|
|
211
|
-
} while ($n !== null && $prev !== $b);
|
|
212
|
-
$prevBlock = $currentBlock;
|
|
213
|
-
$currentBlock = getNextSiblingTextBlock($currentBlock);
|
|
214
|
-
} while ($currentBlock !== null && $prevBlock !== bBlock);
|
|
215
|
-
};
|
|
216
|
-
const toggleInlineFormat = ($n, formatName) => {
|
|
217
|
-
setInlineFormat($n, formatName, !isFormatName($n, formatName));
|
|
218
|
-
};
|
|
219
|
-
const areSameInlineFormat = ($a, $b) => {
|
|
220
|
-
if ($a.classList.length === 0 && $b.classList.length === 0) {
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
if ($a.classList.length !== $b.classList.length) {
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
if ($a.className === 'l') {
|
|
227
|
-
return $b.className === 'l' && $a.getAttribute(LINK_HREF_ATTR_NAME) === $b.getAttribute(LINK_HREF_ATTR_NAME);
|
|
228
|
-
}
|
|
229
|
-
for (let i = 0; i < $a.classList.length; i++) {
|
|
230
|
-
if (!$b.classList.contains($a.classList[i])) {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return true;
|
|
235
|
-
};
|
|
236
|
-
const createInlineWithText = (data, doc) => {
|
|
237
|
-
const $res = doc.createElement('SPAN');
|
|
238
|
-
$res.append(createTextNode(data, doc));
|
|
239
|
-
return $res;
|
|
240
|
-
};
|
|
241
|
-
const createInlineWithTextOfType = ($text, $source) => {
|
|
242
|
-
const $res = $source.ownerDocument.createElement($source.nodeName);
|
|
243
|
-
copyFormatName($source, $res);
|
|
244
|
-
$res.append($text);
|
|
245
|
-
return $res;
|
|
246
|
-
};
|
|
247
|
-
const createLink = (text, href, doc) => {
|
|
248
|
-
const $link = createInlineWithText(text, doc);
|
|
249
|
-
setInlineFormat($link, 'l', true);
|
|
250
|
-
$link.setAttribute(LINK_HREF_ATTR_NAME, href);
|
|
251
|
-
return $link;
|
|
252
|
-
};
|
|
253
|
-
const EMOJI_CHAR_ATTR_NAME = 'data-char';
|
|
254
|
-
const createEmoji = (emojiChar, baseUrl, doc) => {
|
|
255
|
-
const $emoji = doc.createElement('img');
|
|
256
|
-
$emoji.setAttribute(EMOJI_CHAR_ATTR_NAME, emojiChar);
|
|
257
|
-
$emoji.setAttribute('src', (0, _utils.getEmojiUrl)(baseUrl, emojiChar));
|
|
258
|
-
$emoji.classList.add('e');
|
|
259
|
-
return $emoji;
|
|
260
|
-
};
|
|
261
|
-
const PARAGRAPH_CLASSNAME = 'p';
|
|
262
|
-
const createActuallyEmptyParagraph = doc => {
|
|
263
|
-
const $p = doc.createElement('p');
|
|
264
|
-
$p.classList.add(PARAGRAPH_CLASSNAME);
|
|
265
|
-
return $p;
|
|
266
|
-
};
|
|
267
|
-
const createEmptyParagraph = doc => {
|
|
268
|
-
const res = createActuallyEmptyParagraph(doc);
|
|
269
|
-
res.append(createEmptyInline(doc));
|
|
270
|
-
return res;
|
|
271
|
-
};
|
|
272
|
-
const createParagraphWithChildren = (children, doc) => {
|
|
273
|
-
if (children.length === 0) {
|
|
274
|
-
return createEmptyParagraph(doc);
|
|
275
|
-
}
|
|
276
|
-
const $p = createActuallyEmptyParagraph(doc);
|
|
277
|
-
$p.append(...children);
|
|
278
|
-
return $p;
|
|
279
|
-
};
|
|
280
|
-
const ULI_CLASSNAME = 'uli';
|
|
281
|
-
const OLI_CLASSNAME = 'oli';
|
|
282
|
-
const createActuallyEmptyListItem = (isOrdered, listLevel, doc) => {
|
|
283
|
-
const $li = doc.createElement('p');
|
|
284
|
-
$li.className = isOrdered ? OLI_CLASSNAME : ULI_CLASSNAME;
|
|
285
|
-
setListItemLevel($li, listLevel);
|
|
286
|
-
return $li;
|
|
287
|
-
};
|
|
288
|
-
const createEmptyListItem = (isOrdered, listLevel, doc) => {
|
|
289
|
-
const $li = createActuallyEmptyListItem(isOrdered, listLevel, doc);
|
|
290
|
-
$li.append(createEmptyInline(doc));
|
|
291
|
-
return $li;
|
|
292
|
-
};
|
|
293
|
-
const setListItemOrderedType = ($li, isOrdered) => {
|
|
294
|
-
if (isOrdered) {
|
|
295
|
-
$li.classList.remove(ULI_CLASSNAME);
|
|
296
|
-
$li.classList.add(OLI_CLASSNAME);
|
|
297
|
-
} else {
|
|
298
|
-
$li.classList.remove(OLI_CLASSNAME);
|
|
299
|
-
$li.classList.add(ULI_CLASSNAME);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
const convertToListItem = ($p, isOrdered) => {
|
|
303
|
-
$p.classList.remove(PARAGRAPH_CLASSNAME);
|
|
304
|
-
if (isOrdered) {
|
|
305
|
-
$p.classList.add(OLI_CLASSNAME);
|
|
306
|
-
} else {
|
|
307
|
-
$p.classList.add(ULI_CLASSNAME);
|
|
308
|
-
}
|
|
309
|
-
const $li = $p;
|
|
310
|
-
setListItemLevel($li, 0);
|
|
311
|
-
return $li;
|
|
312
|
-
};
|
|
313
|
-
const convertToParagraph = $li => {
|
|
314
|
-
removeListItemLevel($li);
|
|
315
|
-
$li.classList.remove(ULI_CLASSNAME, OLI_CLASSNAME);
|
|
316
|
-
$li.classList.add(PARAGRAPH_CLASSNAME);
|
|
317
|
-
ensureListItemLevelsAreCorrect($li);
|
|
318
|
-
return $li;
|
|
319
|
-
};
|
|
320
|
-
const createListItemWithChildren = (children, isOrdered, listLevel, doc) => {
|
|
321
|
-
if (children.length === 0) {
|
|
322
|
-
return createEmptyListItem(isOrdered, listLevel, doc);
|
|
323
|
-
}
|
|
324
|
-
const $li = createActuallyEmptyListItem(isOrdered, listLevel, doc);
|
|
325
|
-
$li.append(...children);
|
|
326
|
-
return $li;
|
|
327
|
-
};
|
|
328
|
-
const getParentTextBlock = $node => {
|
|
329
|
-
const $inline = isTextNode($node) ? getParentInline($node) : $node;
|
|
330
|
-
const $p = $inline.parentNode;
|
|
331
|
-
assertTextBlock($p);
|
|
332
|
-
return $p;
|
|
333
|
-
};
|
|
334
|
-
const childIndexOf = ($parent, $child) => {
|
|
335
|
-
return Array.prototype.indexOf.call($parent.childNodes, $child);
|
|
336
|
-
};
|
|
337
|
-
const getChildByIndex = ($parent, index) => {
|
|
338
|
-
const children = $parent.childNodes;
|
|
339
|
-
if (index < 0 || index >= children.length) {
|
|
340
|
-
throw new Error('Invalid index');
|
|
341
|
-
}
|
|
342
|
-
const $ch = index >= children.length ? children[children.length - 1] : children[index];
|
|
343
|
-
return $ch;
|
|
344
|
-
};
|
|
345
|
-
const afterLastChildIndex = $parent => {
|
|
346
|
-
return $parent.childNodes.length;
|
|
347
|
-
};
|
|
348
|
-
const isAfterLastChildIndex = ($parent, index) => {
|
|
349
|
-
return index >= $parent.childNodes.length;
|
|
350
|
-
};
|
|
351
|
-
const getLastChild = n => n.lastChild;
|
|
352
|
-
const getFirstChild = n => n.firstChild;
|
|
353
|
-
const getPrevSibling = n => n.previousSibling;
|
|
354
|
-
const getNextSibling = n => n.nextSibling;
|
|
355
|
-
const getSiblingTextBlock = getSibling => $node => {
|
|
356
|
-
const $sib = getSibling($node);
|
|
357
|
-
if ($sib !== null) {
|
|
358
|
-
assertTextBlock($sib);
|
|
359
|
-
return $sib;
|
|
360
|
-
}
|
|
361
|
-
return null;
|
|
362
|
-
};
|
|
363
|
-
const getPrevSiblingTextBlock = getSiblingTextBlock(getPrevSibling);
|
|
364
|
-
const getNextSiblingTextBlock = getSiblingTextBlock(getNextSibling);
|
|
365
|
-
const getPrevSiblingTextContent = ($node, ensureValid) => {
|
|
366
|
-
const $sib = $node.previousSibling;
|
|
367
|
-
if ($sib === null && ensureValid === true) {
|
|
368
|
-
const $currentBlock = getParentTextBlock($node);
|
|
369
|
-
const $prevBlock = getPrevSiblingTextBlock($currentBlock);
|
|
370
|
-
if ($prevBlock === null) {
|
|
371
|
-
$currentBlock.prepend(createEmptyInline($node.ownerDocument));
|
|
372
|
-
return getFirstTextContent($currentBlock);
|
|
373
|
-
}
|
|
374
|
-
return getLastTextContent($prevBlock);
|
|
375
|
-
}
|
|
376
|
-
if ($sib !== null) {
|
|
377
|
-
assertTextContent($sib);
|
|
378
|
-
}
|
|
379
|
-
return $sib;
|
|
380
|
-
};
|
|
381
|
-
const getNextSiblingTextContent = ($node, ensureValid) => {
|
|
382
|
-
const $sib = $node.nextSibling;
|
|
383
|
-
if ($sib === null && ensureValid === true) {
|
|
384
|
-
const $currentBlock = getParentTextBlock($node);
|
|
385
|
-
const $nextBlock = getNextSiblingTextBlock($currentBlock);
|
|
386
|
-
if ($nextBlock === null) {
|
|
387
|
-
$currentBlock.append(createEmptyInline($node.ownerDocument));
|
|
388
|
-
return getLastTextContent($currentBlock);
|
|
389
|
-
}
|
|
390
|
-
return getFirstTextContent($nextBlock);
|
|
391
|
-
}
|
|
392
|
-
if ($sib !== null) {
|
|
393
|
-
assertTextContent($sib);
|
|
394
|
-
}
|
|
395
|
-
return $sib;
|
|
396
|
-
};
|
|
397
|
-
const createCollapsedRange = cursor => {
|
|
398
|
-
const {
|
|
399
|
-
node,
|
|
400
|
-
offset
|
|
401
|
-
} = cursorToNodeWithOffset(cursor);
|
|
402
|
-
return {
|
|
403
|
-
startContainer: node,
|
|
404
|
-
startOffset: offset,
|
|
405
|
-
endContainer: node,
|
|
406
|
-
endOffset: offset
|
|
407
|
-
};
|
|
408
|
-
};
|
|
409
|
-
const createSpanningRange = (aCursor, bCursor) => {
|
|
410
|
-
const {
|
|
411
|
-
node: startContainer,
|
|
412
|
-
offset: startOffset
|
|
413
|
-
} = cursorToNodeWithOffset(aCursor);
|
|
414
|
-
const {
|
|
415
|
-
node: endContainer,
|
|
416
|
-
offset: endOffset
|
|
417
|
-
} = cursorToNodeWithOffset(bCursor);
|
|
418
|
-
return {
|
|
419
|
-
startContainer,
|
|
420
|
-
startOffset,
|
|
421
|
-
endContainer,
|
|
422
|
-
endOffset
|
|
423
|
-
};
|
|
424
|
-
};
|
|
425
|
-
const removePrevSiblings = $node => {
|
|
426
|
-
let $n;
|
|
427
|
-
while (($n = $node.previousSibling) !== null) {
|
|
428
|
-
$n.remove();
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
const removeNextSiblings = $node => {
|
|
432
|
-
let $n;
|
|
433
|
-
while (($n = $node.nextSibling) !== null) {
|
|
434
|
-
$n.remove();
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
const removeSiblingsBetween = ($a, $b) => {
|
|
438
|
-
let $n;
|
|
439
|
-
while (($n = $a.nextSibling) !== $b) {
|
|
440
|
-
assertNonNull($n);
|
|
441
|
-
$n.remove();
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
const getCommonParent = ($n0, $n1) => {
|
|
445
|
-
let $n = $n0;
|
|
446
|
-
while (!$n.contains($n1)) {
|
|
447
|
-
$n = $n.parentNode;
|
|
448
|
-
}
|
|
449
|
-
return $n;
|
|
450
|
-
};
|
|
451
|
-
const removeNodesBetween = (aCursor, bCursor) => {
|
|
452
|
-
if (aCursor.$inline === bCursor.$inline) {
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
const commonParent = getCommonParent(aCursor.$inline, bCursor.$inline);
|
|
456
|
-
let $cpChildA = aCursor.$inline;
|
|
457
|
-
let $cpChildB = bCursor.$inline;
|
|
458
|
-
while ($cpChildA.parentNode !== commonParent) {
|
|
459
|
-
removeNextSiblings($cpChildA);
|
|
460
|
-
$cpChildA = $cpChildA.parentNode;
|
|
461
|
-
}
|
|
462
|
-
while ($cpChildB.parentNode !== commonParent) {
|
|
463
|
-
removePrevSiblings($cpChildB);
|
|
464
|
-
$cpChildB = $cpChildB.parentNode;
|
|
465
|
-
}
|
|
466
|
-
removeSiblingsBetween($cpChildA, $cpChildB);
|
|
467
|
-
};
|
|
468
|
-
const ensureCorrectTextBlockIfEmpty = $node => {
|
|
469
|
-
if (!$node.hasChildNodes()) {
|
|
470
|
-
$node.append(createEmptyInline($node.ownerDocument));
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
const children = $node.childNodes;
|
|
474
|
-
if (children.length === 1) {
|
|
475
|
-
const $firstChild = children[0];
|
|
476
|
-
assertTextContent($firstChild);
|
|
477
|
-
if (isInline($firstChild)) {
|
|
478
|
-
if ($firstChild.childNodes.length > 1 || !isTextNode($firstChild.firstChild)) {
|
|
479
|
-
$node.replaceChildren(createEmptyInline($node.ownerDocument));
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
const getChildText = $node => {
|
|
485
|
-
if ($node.childNodes.length !== 1) {
|
|
486
|
-
throw new Error('Should have exact 1 child');
|
|
487
|
-
}
|
|
488
|
-
const $child = $node.firstChild;
|
|
489
|
-
assertTextNode($child);
|
|
490
|
-
return $child;
|
|
491
|
-
};
|
|
492
|
-
const getChildTextContent = getFirstOrLastChild => $node => {
|
|
493
|
-
ensureCorrectTextBlockIfEmpty($node);
|
|
494
|
-
const $child = getFirstOrLastChild($node);
|
|
495
|
-
assertTextContent($child);
|
|
496
|
-
return $child;
|
|
497
|
-
};
|
|
498
|
-
const getLastTextContent = getChildTextContent(getLastChild);
|
|
499
|
-
const getFirstTextContent = getChildTextContent(getFirstChild);
|
|
500
|
-
const getFirstOrLastTextBlock = getFirstOrLastChild => $root => {
|
|
501
|
-
let $lc = getFirstOrLastChild($root);
|
|
502
|
-
if ($lc === null) {
|
|
503
|
-
$lc = createEmptyParagraph($root.ownerDocument);
|
|
504
|
-
$root.append($lc);
|
|
505
|
-
}
|
|
506
|
-
assertTextBlock($lc);
|
|
507
|
-
return $lc;
|
|
508
|
-
};
|
|
509
|
-
const getFirstTextBlock = getFirstOrLastTextBlock(getFirstChild);
|
|
510
|
-
const getLastTextBlock = getFirstOrLastTextBlock(getLastChild);
|
|
511
|
-
const mergeSiblingTextNodes = ($a, aCursor, bCursor) => {
|
|
512
|
-
const $b = $a.nextSibling;
|
|
513
|
-
if ($b === null) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
assertTextNode($b);
|
|
517
|
-
const aContent = getTextValue($a);
|
|
518
|
-
const bContent = getTextValue($b);
|
|
519
|
-
const aContentLength = isEmptyText(aContent) ? 0 : aContent.length;
|
|
520
|
-
const bContentLength = isEmptyText(bContent) ? 0 : bContent.length;
|
|
521
|
-
let resultText = (isEmptyText(aContent) ? '' : aContent) + (isEmptyText(bContent) ? '' : bContent);
|
|
522
|
-
const isEmptyResultText = resultText.length === 0;
|
|
523
|
-
if (aCursor.$text === $a) {
|
|
524
|
-
aCursor.offset = isEmptyResultText ? 1 : aCursor.offset;
|
|
525
|
-
}
|
|
526
|
-
if (aCursor.$text === $b) {
|
|
527
|
-
aCursor.$text = $a;
|
|
528
|
-
aCursor.offset = isEmptyResultText ? 1 : aContentLength + (bContentLength === 0 ? 0 : aCursor.offset);
|
|
529
|
-
}
|
|
530
|
-
if (bCursor != null) {
|
|
531
|
-
if (bCursor.$text === $a) {
|
|
532
|
-
bCursor.offset = isEmptyResultText ? 1 : bCursor.offset;
|
|
533
|
-
}
|
|
534
|
-
if (bCursor.$text === $b) {
|
|
535
|
-
bCursor.$text = $a;
|
|
536
|
-
bCursor.offset = isEmptyResultText ? 1 : aContentLength + (bContentLength === 0 ? 0 : bCursor.offset);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
if (isEmptyResultText) {
|
|
540
|
-
resultText = TEXT_EMPTY_DATA;
|
|
541
|
-
}
|
|
542
|
-
$a.nodeValue = resultText;
|
|
543
|
-
$b.remove();
|
|
544
|
-
mergeSiblingTextNodes($a, aCursor);
|
|
545
|
-
};
|
|
546
|
-
const mergeNextTextContentSibling = ($a, aCursor, bCursor) => {
|
|
547
|
-
const $b = $a.nextSibling;
|
|
548
|
-
if ($b === null) {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
assertTextContent($b);
|
|
552
|
-
if (isInline($a) && isInline($b)) {
|
|
553
|
-
const $aText = getChildText($a);
|
|
554
|
-
const $bText = getChildText($b);
|
|
555
|
-
if (areSameInlineFormat($a, $b) || isEmptyTextNode($aText) || isEmptyTextNode($bText)) {
|
|
556
|
-
$a.append($bText);
|
|
557
|
-
$b.remove();
|
|
558
|
-
mergeSiblingTextNodes($aText, aCursor, bCursor);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
const mergePrevTextContentSibling = ($b, aCursor, bCursor) => {
|
|
563
|
-
const $a = $b.previousSibling;
|
|
564
|
-
if ($a === null) {
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
assertTextContent($a);
|
|
568
|
-
if (isInline($a) && isInline($b)) {
|
|
569
|
-
const $aText = getChildText($a);
|
|
570
|
-
const $bText = getChildText($b);
|
|
571
|
-
if (areSameInlineFormat($a, $b) || isEmptyTextNode($aText) || isEmptyTextNode($bText)) {
|
|
572
|
-
$a.append($bText);
|
|
573
|
-
$b.remove();
|
|
574
|
-
mergeSiblingTextNodes($aText, aCursor, bCursor);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
const mergeTextContentBetween = ($a, $b, aCursor, bCursor) => {
|
|
579
|
-
const $sib = getNextSiblingTextContent($a);
|
|
580
|
-
if ($sib === null) {
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
if ($a === $b || $sib === $b) {
|
|
584
|
-
mergeNextTextContentSibling($b, aCursor, bCursor);
|
|
585
|
-
mergeNextTextContentSibling($a, aCursor, bCursor);
|
|
586
|
-
mergePrevTextContentSibling($a, aCursor, bCursor);
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
mergeNextTextContentSibling($a, aCursor, bCursor);
|
|
590
|
-
const $newSib = getNextSiblingTextContent($a);
|
|
591
|
-
assertNonNull($newSib);
|
|
592
|
-
if ($newSib === $sib) {
|
|
593
|
-
mergePrevTextContentSibling($a, aCursor, bCursor);
|
|
594
|
-
mergeTextContentBetween($sib, $b, aCursor, bCursor);
|
|
595
|
-
} else {
|
|
596
|
-
mergeTextContentBetween($a, $b, aCursor, bCursor);
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
const mergeNextTextBlock = ($a, aCursor, bCursor) => {
|
|
600
|
-
const $b = $a.nextSibling;
|
|
601
|
-
if ($b === null) {
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
assertTextBlock($b);
|
|
605
|
-
const $lastChild = getLastChild($a);
|
|
606
|
-
if ($b.hasChildNodes()) {
|
|
607
|
-
$a.append(...Array.from($b.childNodes));
|
|
608
|
-
}
|
|
609
|
-
$b.remove();
|
|
610
|
-
if ($lastChild !== null) {
|
|
611
|
-
assertTextContent($lastChild);
|
|
612
|
-
mergeNextTextContentSibling($lastChild, aCursor, bCursor);
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
const sliceChildren = ($parent, index) => {
|
|
616
|
-
if (index < 0) {
|
|
617
|
-
throw new Error('Not found');
|
|
618
|
-
}
|
|
619
|
-
const children = Array.from($parent.childNodes);
|
|
620
|
-
if (index === 0) {
|
|
621
|
-
return children;
|
|
622
|
-
}
|
|
623
|
-
return children.slice(index);
|
|
624
|
-
};
|
|
625
|
-
const splitTextBlock = ($a, childIndex) => {
|
|
626
|
-
const bChildren = sliceChildren($a, childIndex);
|
|
627
|
-
const $b = isListItem($a) ? createListItemWithChildren(bChildren, isOrderedListItem($a), getListItemLevel($a), $a.ownerDocument) : createParagraphWithChildren(bChildren, $a.ownerDocument);
|
|
628
|
-
ensureCorrectTextBlockIfEmpty($a);
|
|
629
|
-
ensureCorrectTextBlockIfEmpty($b);
|
|
630
|
-
$a.after($b);
|
|
631
|
-
return [$a, $b];
|
|
632
|
-
};
|
|
633
|
-
const splitTextNode = ($aText, offset) => {
|
|
634
|
-
const content = getTextValue($aText);
|
|
635
|
-
const aContent = content.substring(0, offset);
|
|
636
|
-
const bContent = content.substring(offset);
|
|
637
|
-
let $bText = null;
|
|
638
|
-
if (aContent.length > 0 && bContent.length > 0) {
|
|
639
|
-
$bText = createTextNode(bContent, $aText.ownerDocument);
|
|
640
|
-
$aText.nodeValue = aContent;
|
|
641
|
-
}
|
|
642
|
-
const $aInline = getParentInline($aText);
|
|
643
|
-
let $bInline = null;
|
|
644
|
-
if ($bText !== null) {
|
|
645
|
-
$bInline = createInlineWithTextOfType($bText, $aInline);
|
|
646
|
-
$aInline.after($bInline);
|
|
647
|
-
}
|
|
648
|
-
const $before = aContent.length === 0 ? getPrevSiblingTextContent($aInline) : $aInline;
|
|
649
|
-
const $after = $bInline ?? (aContent.length === 0 ? $aInline : getNextSiblingTextContent($aInline));
|
|
650
|
-
return [$before, $after];
|
|
651
|
-
};
|
|
652
|
-
const sliceTextNode = ($n, startOffset, endOffset) => {
|
|
653
|
-
const $after = splitTextNode($n, startOffset)[1];
|
|
654
|
-
assertInline($after);
|
|
655
|
-
const $before = splitTextNode(getChildText($after), endOffset - startOffset)[0];
|
|
656
|
-
assertEquals($before, $after);
|
|
657
|
-
return $after;
|
|
658
|
-
};
|
|
659
|
-
const splitTextNodeAndInsertEmptyInline = ($n, offset) => {
|
|
660
|
-
const [$before, $after] = splitTextNode($n, offset);
|
|
661
|
-
const $inline = createEmptyInline($n.ownerDocument);
|
|
662
|
-
copyFormatName($n, $inline);
|
|
663
|
-
if ($before !== null) {
|
|
664
|
-
$before.after($inline);
|
|
665
|
-
} else {
|
|
666
|
-
assertNonNull($after);
|
|
667
|
-
$after.before($inline);
|
|
668
|
-
}
|
|
669
|
-
return $inline;
|
|
670
|
-
};
|
|
671
|
-
const formatInline = (formatType, range) => {
|
|
672
|
-
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
673
|
-
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
674
|
-
const formatName = FORMAT_TYPE_TO_NAME[formatType];
|
|
675
|
-
if (aCursor.$inline === bCursor.$inline && isTextNode(aCursor.$text)) {
|
|
676
|
-
const {
|
|
677
|
-
$text,
|
|
678
|
-
$inline,
|
|
679
|
-
offset: startOffset
|
|
680
|
-
} = aCursor;
|
|
681
|
-
const {
|
|
682
|
-
offset: endOffset
|
|
683
|
-
} = bCursor;
|
|
684
|
-
if (isEmptyText($text.nodeValue)) {
|
|
685
|
-
assertInline($inline);
|
|
686
|
-
toggleInlineFormat($inline, formatName);
|
|
687
|
-
return {
|
|
688
|
-
prevent: true,
|
|
689
|
-
range: createCollapsedRange(createEndCursorFromTextContent($inline))
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
if (startOffset === endOffset) {
|
|
693
|
-
const $newinline = splitTextNodeAndInsertEmptyInline($text, startOffset);
|
|
694
|
-
toggleInlineFormat($newinline, formatName);
|
|
695
|
-
return {
|
|
696
|
-
prevent: true,
|
|
697
|
-
range: createCollapsedRange(createEndCursorFromTextContent($newinline))
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
const $newinline = sliceTextNode($text, startOffset, endOffset);
|
|
701
|
-
toggleInlineFormat($newinline, formatName);
|
|
702
|
-
const aTrackingCursor = createBeginCursorFromTextContent($newinline);
|
|
703
|
-
const bTrackingCursor = createEndCursorFromTextContent($newinline);
|
|
704
|
-
mergeNextTextContentSibling($newinline, aTrackingCursor, bTrackingCursor);
|
|
705
|
-
mergePrevTextContentSibling($newinline, aTrackingCursor, bTrackingCursor);
|
|
706
|
-
return {
|
|
707
|
-
prevent: true,
|
|
708
|
-
range: createSpanningRange(aTrackingCursor, bTrackingCursor)
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
const areAllInline = isAllInsideFormatName(aCursor.$inline, bCursor.$inline, formatName);
|
|
712
|
-
let $aInline = aCursor.$inline;
|
|
713
|
-
let $bInline = bCursor.$inline;
|
|
714
|
-
if (isTextNode(aCursor.$text)) {
|
|
715
|
-
$aInline = splitTextNode(aCursor.$text, aCursor.offset)[1];
|
|
716
|
-
}
|
|
717
|
-
if (isTextNode(bCursor.$text)) {
|
|
718
|
-
$bInline = splitTextNode(bCursor.$text, bCursor.offset)[0];
|
|
719
|
-
}
|
|
720
|
-
if ($aInline === null) {
|
|
721
|
-
const aBlock = getNextSiblingTextBlock(getParentTextBlock(aCursor.$inline));
|
|
722
|
-
assertNonNull(aBlock);
|
|
723
|
-
$aInline = getFirstTextContent(aBlock);
|
|
724
|
-
}
|
|
725
|
-
if ($bInline === null) {
|
|
726
|
-
const bBlock = getPrevSiblingTextBlock(getParentTextBlock(bCursor.$inline));
|
|
727
|
-
assertNonNull(bBlock);
|
|
728
|
-
$bInline = getLastTextContent(bBlock);
|
|
729
|
-
}
|
|
730
|
-
setAllInlineFormat($aInline, $bInline, formatName, !areAllInline);
|
|
731
|
-
const aTrackingCursor = createBeginCursorFromTextContent($aInline);
|
|
732
|
-
const bTrackingCursor = createEndCursorFromTextContent($bInline);
|
|
733
|
-
mergeTextContentBetween($aInline, $bInline, aTrackingCursor, bTrackingCursor);
|
|
734
|
-
return {
|
|
735
|
-
prevent: true,
|
|
736
|
-
range: createSpanningRange(aTrackingCursor, bTrackingCursor)
|
|
737
|
-
};
|
|
738
|
-
};
|
|
739
|
-
exports.formatInline = formatInline;
|
|
740
|
-
const allSiblingsIncludingSatisfy = (aNode, bNode, func) => {
|
|
741
|
-
let currentNode = aNode;
|
|
742
|
-
const nextSib = bNode.nextSibling;
|
|
743
|
-
while (currentNode !== null && currentNode !== nextSib) {
|
|
744
|
-
const tempNext = currentNode.nextSibling;
|
|
745
|
-
if (!func(currentNode)) {
|
|
746
|
-
return false;
|
|
747
|
-
}
|
|
748
|
-
currentNode = tempNext;
|
|
749
|
-
}
|
|
750
|
-
return true;
|
|
751
|
-
};
|
|
752
|
-
const formatIndent = range => {
|
|
753
|
-
if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && range.startOffset !== 0) {
|
|
754
|
-
return {
|
|
755
|
-
prevent: false
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
759
|
-
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
760
|
-
const aBlock = getParentTextBlock(aCursor.$inline);
|
|
761
|
-
const bBlock = getParentTextBlock(bCursor.$inline);
|
|
762
|
-
const $iterateUpToNode = getNextSiblingTextBlock(bBlock);
|
|
763
|
-
let $block = aBlock;
|
|
764
|
-
let $prevBlock = null;
|
|
765
|
-
while ($block !== null && $block !== $iterateUpToNode) {
|
|
766
|
-
if (isListItem($block) && !isListItemMarkedArBlock($block)) {
|
|
767
|
-
const $prev = $prevBlock ?? getPrevSiblingTextBlock($block);
|
|
768
|
-
const currentLevel = getListItemLevel($block);
|
|
769
|
-
if (isListItem($prev) && currentLevel <= getListItemLevel($prev)) {
|
|
770
|
-
setListItemLevel($block, currentLevel + 1);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
$prevBlock = $block;
|
|
774
|
-
$block = getNextSiblingTextBlock($block);
|
|
775
|
-
}
|
|
776
|
-
return {
|
|
777
|
-
prevent: true,
|
|
778
|
-
range
|
|
779
|
-
};
|
|
780
|
-
};
|
|
781
|
-
exports.formatIndent = formatIndent;
|
|
782
|
-
const ensureListItemLevelsAreCorrect = $li => {
|
|
783
|
-
if ($li === null) {
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
let $block = getNextSiblingTextBlock($li);
|
|
787
|
-
let prevLevel = isListItem($li) ? getListItemLevel($li) : -1;
|
|
788
|
-
while ($block !== null && isListItem($block)) {
|
|
789
|
-
let currentLevel = getListItemLevel($block);
|
|
790
|
-
if (currentLevel <= prevLevel + 1) {
|
|
791
|
-
break;
|
|
792
|
-
}
|
|
793
|
-
currentLevel = prevLevel + 1;
|
|
794
|
-
setListItemLevel($block, currentLevel);
|
|
795
|
-
prevLevel = currentLevel;
|
|
796
|
-
$block = getNextSiblingTextBlock($block);
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
const formatOutdent = range => {
|
|
800
|
-
if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && range.startOffset !== 0) {
|
|
801
|
-
return {
|
|
802
|
-
prevent: false
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
806
|
-
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
807
|
-
const aBlock = getParentTextBlock(aCursor.$inline);
|
|
808
|
-
const bBlock = getParentTextBlock(bCursor.$inline);
|
|
809
|
-
const $iterateUpToNode = getNextSiblingTextBlock(bBlock);
|
|
810
|
-
let $block = aBlock;
|
|
811
|
-
let $lastListItem = null;
|
|
812
|
-
while ($block !== null && $block !== $iterateUpToNode) {
|
|
813
|
-
if (isListItem($block)) {
|
|
814
|
-
setListItemLevel($block, getListItemLevel($block) - 1);
|
|
815
|
-
$lastListItem = $block;
|
|
816
|
-
}
|
|
817
|
-
$block = getNextSiblingTextBlock($block);
|
|
818
|
-
}
|
|
819
|
-
if ($lastListItem !== null) {
|
|
820
|
-
ensureListItemLevelsAreCorrect($lastListItem);
|
|
821
|
-
}
|
|
822
|
-
return {
|
|
823
|
-
prevent: true,
|
|
824
|
-
range
|
|
825
|
-
};
|
|
826
|
-
};
|
|
827
|
-
exports.formatOutdent = formatOutdent;
|
|
828
|
-
const formatList = (isOrdered, range) => {
|
|
829
|
-
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
830
|
-
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
831
|
-
const aBlock = getParentTextBlock(aCursor.$inline);
|
|
832
|
-
const bBlock = getParentTextBlock(bCursor.$inline);
|
|
833
|
-
const isInsideSameListType = isAllInsideList(isOrdered, aCursor.$inline, bCursor.$inline);
|
|
834
|
-
if (isInsideSameListType) {
|
|
835
|
-
assertListItem(aBlock);
|
|
836
|
-
assertListItem(bBlock);
|
|
837
|
-
const $iterateUpToNode = getNextSiblingTextBlock(bBlock);
|
|
838
|
-
let $block = aBlock;
|
|
839
|
-
while ($block !== null && $block !== $iterateUpToNode) {
|
|
840
|
-
convertToParagraph($block);
|
|
841
|
-
$block = getNextSiblingTextBlock($block);
|
|
842
|
-
}
|
|
843
|
-
return {
|
|
844
|
-
prevent: true,
|
|
845
|
-
range: createCollapsedRange(bCursor)
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
const $iterateUpToNode = getNextSiblingTextBlock(bBlock);
|
|
849
|
-
let $block = aBlock;
|
|
850
|
-
while ($block !== null && $block !== $iterateUpToNode) {
|
|
851
|
-
if (isParagraph($block)) {
|
|
852
|
-
convertToListItem($block, isOrdered);
|
|
853
|
-
} else {
|
|
854
|
-
assertListItem($block);
|
|
855
|
-
setListItemOrderedType($block, isOrdered);
|
|
856
|
-
}
|
|
857
|
-
$block = getNextSiblingTextBlock($block);
|
|
858
|
-
}
|
|
859
|
-
return {
|
|
860
|
-
prevent: true,
|
|
861
|
-
range: createCollapsedRange(bCursor)
|
|
862
|
-
};
|
|
863
|
-
};
|
|
864
|
-
exports.formatList = formatList;
|
|
865
|
-
const createCursorFromTextNode = (node, offset) => {
|
|
866
|
-
return {
|
|
867
|
-
$text: node,
|
|
868
|
-
$inline: getParentInline(node),
|
|
869
|
-
offset: Math.min(node.length, offset)
|
|
870
|
-
};
|
|
871
|
-
};
|
|
872
|
-
const createBeginCursorFromTextContent = node => {
|
|
873
|
-
if (isInline(node)) {
|
|
874
|
-
const $text = getChildText(node);
|
|
875
|
-
const content = getTextValue($text);
|
|
876
|
-
return {
|
|
877
|
-
$inline: node,
|
|
878
|
-
$text,
|
|
879
|
-
offset: isEmptyText(content) ? content.length : 0
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
return {
|
|
883
|
-
$text: null,
|
|
884
|
-
$inline: node,
|
|
885
|
-
offset: 0
|
|
886
|
-
};
|
|
887
|
-
};
|
|
888
|
-
const createEndCursorFromTextContent = node => {
|
|
889
|
-
if (isInline(node)) {
|
|
890
|
-
const $text = getChildText(node);
|
|
891
|
-
return {
|
|
892
|
-
$inline: node,
|
|
893
|
-
$text,
|
|
894
|
-
offset: $text.length
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
return {
|
|
898
|
-
$text: null,
|
|
899
|
-
$inline: node,
|
|
900
|
-
offset: 0,
|
|
901
|
-
isAfterInline: true
|
|
902
|
-
};
|
|
903
|
-
};
|
|
904
|
-
const createIncomingCursorFromNodeWithOffset = (node, offset) => {
|
|
905
|
-
if (isTextNode(node)) {
|
|
906
|
-
return createCursorFromTextNode(node, offset);
|
|
907
|
-
}
|
|
908
|
-
if (isEmoji(node)) {
|
|
909
|
-
return {
|
|
910
|
-
$text: null,
|
|
911
|
-
$inline: node,
|
|
912
|
-
offset: 0
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
if (isTextBlock(node)) {
|
|
916
|
-
if (isAfterLastChildIndex(node, offset)) {
|
|
917
|
-
return createEndCursorFromTextContent(getLastTextContent(node));
|
|
918
|
-
}
|
|
919
|
-
return createIncomingCursorFromNodeWithOffset(getChildByIndex(node, offset), 0);
|
|
920
|
-
}
|
|
921
|
-
if (isInline(node)) {
|
|
922
|
-
return {
|
|
923
|
-
$inline: node,
|
|
924
|
-
$text: getChildText(node),
|
|
925
|
-
offset: 0
|
|
926
|
-
};
|
|
927
|
-
}
|
|
928
|
-
if (isRoot(node)) {
|
|
929
|
-
if (isAfterLastChildIndex(node, offset)) {
|
|
930
|
-
const $block = getLastTextBlock(node);
|
|
931
|
-
return createIncomingCursorFromNodeWithOffset($block, $block.childNodes.length);
|
|
932
|
-
}
|
|
933
|
-
return createIncomingCursorFromNodeWithOffset(getChildByIndex(node, offset), 0);
|
|
934
|
-
}
|
|
935
|
-
throw new Error('Should not happen');
|
|
936
|
-
};
|
|
937
|
-
const cursorToNodeWithOffset = _ref => {
|
|
938
|
-
let {
|
|
939
|
-
$text,
|
|
940
|
-
$inline,
|
|
941
|
-
offset,
|
|
942
|
-
isAfterInline
|
|
943
|
-
} = _ref;
|
|
944
|
-
if (isTextNode($text)) {
|
|
945
|
-
return {
|
|
946
|
-
node: $text,
|
|
947
|
-
offset
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
const $block = getParentTextBlock($inline);
|
|
951
|
-
const childIndex = childIndexOf($block, $inline) + (isAfterInline === true ? 1 : 0);
|
|
952
|
-
return {
|
|
953
|
-
node: $block,
|
|
954
|
-
offset: childIndex
|
|
955
|
-
};
|
|
956
|
-
};
|
|
957
|
-
const removeContentInRange = range => {
|
|
958
|
-
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
959
|
-
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
960
|
-
if (aCursor.$inline === bCursor.$inline && aCursor.offset === bCursor.offset && aCursor.isAfterInline === bCursor.isAfterInline) {
|
|
961
|
-
return aCursor;
|
|
962
|
-
}
|
|
963
|
-
if (aCursor.$text === bCursor.$text && isTextNode(aCursor.$text)) {
|
|
964
|
-
const {
|
|
965
|
-
$text,
|
|
966
|
-
$inline,
|
|
967
|
-
offset: startOffset
|
|
968
|
-
} = aCursor;
|
|
969
|
-
const {
|
|
970
|
-
offset: endOffset
|
|
971
|
-
} = bCursor;
|
|
972
|
-
const content = getTextValue($text);
|
|
973
|
-
const nextContent = content.substring(0, startOffset) + content.substring(endOffset);
|
|
974
|
-
$text.nodeValue = nextContent;
|
|
975
|
-
if (isEmptyText(nextContent)) {
|
|
976
|
-
const $nextSib = getNextSiblingTextContent($inline);
|
|
977
|
-
const $prevSib = getPrevSiblingTextContent($inline);
|
|
978
|
-
if ($prevSib === null && $nextSib === null) {
|
|
979
|
-
$text.nodeValue = TEXT_EMPTY_DATA;
|
|
980
|
-
return createEndCursorFromTextContent($inline);
|
|
981
|
-
}
|
|
982
|
-
$inline.remove();
|
|
983
|
-
if ($nextSib === null) {
|
|
984
|
-
assertNonNull($prevSib);
|
|
985
|
-
return createEndCursorFromTextContent($prevSib);
|
|
986
|
-
}
|
|
987
|
-
return createBeginCursorFromTextContent($nextSib);
|
|
988
|
-
}
|
|
989
|
-
return createCursorFromTextNode($text, startOffset);
|
|
990
|
-
}
|
|
991
|
-
removeNodesBetween(aCursor, bCursor);
|
|
992
|
-
if (isTextNode(aCursor.$text)) {
|
|
993
|
-
aCursor.$text.nodeValue = getTextValue(aCursor.$text).substring(0, aCursor.offset);
|
|
994
|
-
}
|
|
995
|
-
if (isTextNode(bCursor.$text)) {
|
|
996
|
-
bCursor.$text.nodeValue = getTextValue(bCursor.$text).substring(bCursor.offset);
|
|
997
|
-
}
|
|
998
|
-
const aBlock = getParentTextBlock(aCursor.$inline);
|
|
999
|
-
const bBlock = getParentTextBlock(bCursor.$inline);
|
|
1000
|
-
if (aCursor.$inline !== bCursor.$inline && (isEmptyTextNode(bCursor.$text) || bCursor.$text === null && bCursor.isAfterInline === true)) {
|
|
1001
|
-
bCursor.$inline.remove();
|
|
1002
|
-
}
|
|
1003
|
-
let trackingCursor;
|
|
1004
|
-
if (isEmptyTextNode(aCursor.$text) || aCursor.$text === null && aCursor.isAfterInline !== true) {
|
|
1005
|
-
const $sib = getNextSiblingTextContent(aCursor.$inline);
|
|
1006
|
-
aCursor.$inline.remove();
|
|
1007
|
-
if ($sib === null) {
|
|
1008
|
-
trackingCursor = createEndCursorFromTextContent(getLastTextContent(aBlock));
|
|
1009
|
-
} else {
|
|
1010
|
-
trackingCursor = createBeginCursorFromTextContent($sib);
|
|
1011
|
-
}
|
|
1012
|
-
} else {
|
|
1013
|
-
trackingCursor = createEndCursorFromTextContent(aCursor.$inline);
|
|
1014
|
-
}
|
|
1015
|
-
if (aBlock === bBlock) {
|
|
1016
|
-
mergeNextTextContentSibling(trackingCursor.$inline, trackingCursor);
|
|
1017
|
-
mergePrevTextContentSibling(trackingCursor.$inline, trackingCursor);
|
|
1018
|
-
} else if (getNextSiblingTextBlock(aBlock) === bBlock) {
|
|
1019
|
-
mergeNextTextBlock(aBlock, trackingCursor);
|
|
1020
|
-
}
|
|
1021
|
-
return trackingCursor;
|
|
1022
|
-
};
|
|
1023
|
-
const deleteContentBackward = ($root, range) => {
|
|
1024
|
-
const {
|
|
1025
|
-
startContainer,
|
|
1026
|
-
endContainer,
|
|
1027
|
-
startOffset,
|
|
1028
|
-
endOffset
|
|
1029
|
-
} = range;
|
|
1030
|
-
if (startContainer === endContainer && startOffset + 1 === endOffset && isTextNode(startContainer)) {
|
|
1031
|
-
if (startContainer.length > 1) {
|
|
1032
|
-
return DEFAULT_ACTION_RESULT;
|
|
1033
|
-
}
|
|
1034
|
-
if (startContainer.length === 1 && startContainer.nodeValue !== TEXT_EMPTY_DATA) {
|
|
1035
|
-
startContainer.nodeValue = TEXT_EMPTY_DATA;
|
|
1036
|
-
return {
|
|
1037
|
-
prevent: true,
|
|
1038
|
-
range: {
|
|
1039
|
-
startContainer,
|
|
1040
|
-
startOffset: 1,
|
|
1041
|
-
endContainer: startContainer,
|
|
1042
|
-
endOffset: 1
|
|
1043
|
-
}
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
const $inline = getParentInline(startContainer);
|
|
1047
|
-
const $block = getParentTextBlock($inline);
|
|
1048
|
-
const childIndex = childIndexOf($block, $inline);
|
|
1049
|
-
if (childIndex > 0) {
|
|
1050
|
-
const $prevSib = getChildByIndex($block, childIndex - 1);
|
|
1051
|
-
if (isInline($prevSib)) {
|
|
1052
|
-
const $text = getChildText($prevSib);
|
|
1053
|
-
return deleteContentBackward($root, {
|
|
1054
|
-
startContainer: $text,
|
|
1055
|
-
startOffset: $text.length - 1,
|
|
1056
|
-
endContainer,
|
|
1057
|
-
endOffset
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
return deleteContentBackward($root, {
|
|
1061
|
-
startContainer: $block,
|
|
1062
|
-
startOffset: childIndex - 1,
|
|
1063
|
-
endContainer,
|
|
1064
|
-
endOffset
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
|
-
const $prevBlock = getPrevSiblingTextBlock($block);
|
|
1068
|
-
if ($prevBlock !== null) {
|
|
1069
|
-
return deleteContentBackward($root, {
|
|
1070
|
-
startContainer: $prevBlock,
|
|
1071
|
-
startOffset: afterLastChildIndex($prevBlock),
|
|
1072
|
-
endContainer,
|
|
1073
|
-
endOffset
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
return {
|
|
1078
|
-
prevent: true,
|
|
1079
|
-
range: createCollapsedRange(removeContentInRange(range))
|
|
1080
|
-
};
|
|
1081
|
-
};
|
|
1082
|
-
exports.deleteContentBackward = deleteContentBackward;
|
|
1083
|
-
const insertLink = ($root, text, href, range) => {
|
|
1084
|
-
const cursor = removeContentInRange(range);
|
|
1085
|
-
const {
|
|
1086
|
-
$text,
|
|
1087
|
-
$inline,
|
|
1088
|
-
offset,
|
|
1089
|
-
isAfterInline: isAfterLastChild
|
|
1090
|
-
} = cursor;
|
|
1091
|
-
const $link = createLink(text, href, $root.ownerDocument);
|
|
1092
|
-
if (isTextNode($text)) {
|
|
1093
|
-
if (isEmptyText($text.nodeValue)) {
|
|
1094
|
-
getParentTextBlock($inline).replaceChild($link, $inline);
|
|
1095
|
-
} else {
|
|
1096
|
-
const [$before, $after] = splitTextNode($text, offset);
|
|
1097
|
-
if ($before === null) {
|
|
1098
|
-
assertNonNull($after);
|
|
1099
|
-
$after.before($link);
|
|
1100
|
-
} else {
|
|
1101
|
-
$before.after($link);
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
} else if (isAfterLastChild === true) {
|
|
1105
|
-
$inline.after($link);
|
|
1106
|
-
} else {
|
|
1107
|
-
$inline.before($link);
|
|
1108
|
-
}
|
|
1109
|
-
return {
|
|
1110
|
-
prevent: true,
|
|
1111
|
-
range: createCollapsedRange(createEndCursorFromTextContent($link))
|
|
1112
|
-
};
|
|
1113
|
-
};
|
|
1114
|
-
exports.insertLink = insertLink;
|
|
1115
|
-
const insertLineBreak = range => {
|
|
1116
|
-
const cursor = removeContentInRange(range);
|
|
1117
|
-
const {
|
|
1118
|
-
$text,
|
|
1119
|
-
$inline,
|
|
1120
|
-
offset,
|
|
1121
|
-
isAfterInline: isAfterLastChild
|
|
1122
|
-
} = cursor;
|
|
1123
|
-
const $block = getParentTextBlock($inline);
|
|
1124
|
-
if (isListItem($block)) {
|
|
1125
|
-
if (isEmptyTextBlock($block)) {
|
|
1126
|
-
convertToParagraph($block);
|
|
1127
|
-
return {
|
|
1128
|
-
prevent: true,
|
|
1129
|
-
range: createCollapsedRange(createEndCursorFromTextContent(getLastTextContent($block)))
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
let splitIndex = 0;
|
|
1134
|
-
if (isTextNode($text)) {
|
|
1135
|
-
const [$before] = splitTextNode($text, offset);
|
|
1136
|
-
splitIndex = $before !== null ? childIndexOf($block, $before) + 1 : 0;
|
|
1137
|
-
} else {
|
|
1138
|
-
splitIndex = childIndexOf($block, $inline) + (isAfterLastChild === true ? 1 : 0);
|
|
1139
|
-
}
|
|
1140
|
-
const [_, $bBlock] = splitTextBlock($block, splitIndex);
|
|
1141
|
-
return {
|
|
1142
|
-
prevent: true,
|
|
1143
|
-
range: createCollapsedRange(createBeginCursorFromTextContent(getFirstTextContent($bBlock)))
|
|
1144
|
-
};
|
|
1145
|
-
};
|
|
1146
|
-
exports.insertLineBreak = insertLineBreak;
|
|
1147
|
-
const insertEmoji = ($root, emojiChar, range) => {
|
|
1148
|
-
const cursor = removeContentInRange(range);
|
|
1149
|
-
const {
|
|
1150
|
-
$text,
|
|
1151
|
-
$inline,
|
|
1152
|
-
offset,
|
|
1153
|
-
isAfterInline
|
|
1154
|
-
} = cursor;
|
|
1155
|
-
const baseUrl = (0, _utils.getEmojiBaseUrl)($root);
|
|
1156
|
-
const $emoji = createEmoji(emojiChar, baseUrl, $root.ownerDocument);
|
|
1157
|
-
if (isTextNode($text)) {
|
|
1158
|
-
if (isEmptyText($text.nodeValue)) {
|
|
1159
|
-
getParentTextBlock($inline).replaceChild($emoji, $inline);
|
|
1160
|
-
} else {
|
|
1161
|
-
const [$before, $after] = splitTextNode($text, offset);
|
|
1162
|
-
if ($before === null) {
|
|
1163
|
-
assertNonNull($after);
|
|
1164
|
-
$after.before($emoji);
|
|
1165
|
-
} else {
|
|
1166
|
-
$before.after($emoji);
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
} else if (isAfterInline === true) {
|
|
1170
|
-
$inline.after($emoji);
|
|
1171
|
-
} else {
|
|
1172
|
-
$inline.before($emoji);
|
|
1173
|
-
}
|
|
1174
|
-
return {
|
|
1175
|
-
prevent: true,
|
|
1176
|
-
range: createCollapsedRange(createEndCursorFromTextContent($emoji))
|
|
1177
|
-
};
|
|
1178
|
-
};
|
|
1179
|
-
const insertText = ($root, data, range) => {
|
|
1180
|
-
if (data !== null && (0, _utils2.isEmojiString)(data)) {
|
|
1181
|
-
return insertEmoji($root, data, range);
|
|
1182
|
-
}
|
|
1183
|
-
if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && isTextNode(range.startContainer) && !isEmptyText(range.startContainer.nodeValue)) {
|
|
1184
|
-
const $inline = getParentInline(range.startContainer);
|
|
1185
|
-
const isHotTextWhitespace = range.startOffset === range.startContainer.length && data === TEXT_WHITESPACE && (isFormatCodetag($inline) || isFormatLink($inline));
|
|
1186
|
-
if (!isHotTextWhitespace) {
|
|
1187
|
-
return DEFAULT_ACTION_RESULT;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
const cursor = removeContentInRange(range);
|
|
1191
|
-
if (data === null) {
|
|
1192
|
-
return {
|
|
1193
|
-
prevent: true,
|
|
1194
|
-
range: createCollapsedRange(cursor)
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
const {
|
|
1198
|
-
$text,
|
|
1199
|
-
$inline,
|
|
1200
|
-
offset,
|
|
1201
|
-
isAfterInline
|
|
1202
|
-
} = cursor;
|
|
1203
|
-
if ($text === null && isEmoji($inline)) {
|
|
1204
|
-
const $newInline = createInlineWithText(data, $root.ownerDocument);
|
|
1205
|
-
if (isAfterInline === true) {
|
|
1206
|
-
$inline.after($newInline);
|
|
1207
|
-
} else {
|
|
1208
|
-
$inline.before($newInline);
|
|
1209
|
-
}
|
|
1210
|
-
return {
|
|
1211
|
-
prevent: true,
|
|
1212
|
-
range: createCollapsedRange(createEndCursorFromTextContent($newInline))
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
if (isTextNode($text)) {
|
|
1216
|
-
assertInline($inline);
|
|
1217
|
-
if (isEmptyText($text.nodeValue)) {
|
|
1218
|
-
$text.nodeValue = data;
|
|
1219
|
-
return {
|
|
1220
|
-
prevent: true,
|
|
1221
|
-
range: createCollapsedRange(createCursorFromTextNode($text, data.length))
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
|
-
if (offset === $text.length && data === TEXT_WHITESPACE) {
|
|
1225
|
-
if (isFormatLink($inline) || isFormatCodetag($inline)) {
|
|
1226
|
-
const $newinline = createInlineWithText(data, $root.ownerDocument);
|
|
1227
|
-
$inline.after($newinline);
|
|
1228
|
-
return {
|
|
1229
|
-
prevent: true,
|
|
1230
|
-
range: createCollapsedRange(createEndCursorFromTextContent($newinline))
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
const content = $text.nodeValue;
|
|
1235
|
-
$text.nodeValue = content.substring(0, offset) + data + content.substring(offset);
|
|
1236
|
-
return {
|
|
1237
|
-
prevent: true,
|
|
1238
|
-
range: createCollapsedRange(createCursorFromTextNode($text, offset + data.length))
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
return {
|
|
1242
|
-
prevent: true,
|
|
1243
|
-
range: createCollapsedRange(cursor)
|
|
1244
|
-
};
|
|
1245
|
-
};
|
|
1246
|
-
exports.insertText = insertText;
|
|
1247
|
-
const insertFromPaste = (data, range, visitor) => {
|
|
1248
|
-
const cursor = removeContentInRange(range);
|
|
1249
|
-
const {
|
|
1250
|
-
$text,
|
|
1251
|
-
$inline,
|
|
1252
|
-
offset,
|
|
1253
|
-
isAfterInline
|
|
1254
|
-
} = cursor;
|
|
1255
|
-
const $mdFragment = (0, _utils2.parseMarkdown)(data, visitor);
|
|
1256
|
-
if ($mdFragment.childNodes.length === 0) {
|
|
1257
|
-
return {
|
|
1258
|
-
prevent: true,
|
|
1259
|
-
range
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
const shouldSpreadNodesIntoBlock = $mdFragment.childNodes.length === 1;
|
|
1263
|
-
if (shouldSpreadNodesIntoBlock) {
|
|
1264
|
-
const $block = getParentTextBlock($inline);
|
|
1265
|
-
const $fragment = document.createDocumentFragment();
|
|
1266
|
-
$fragment.append(...Array.from($mdFragment.childNodes[0].childNodes));
|
|
1267
|
-
const $pasteLastChild = $fragment.lastChild;
|
|
1268
|
-
if ($pasteLastChild !== null) {
|
|
1269
|
-
assertTextContent($pasteLastChild);
|
|
1270
|
-
}
|
|
1271
|
-
if (isTextNode($text)) {
|
|
1272
|
-
if (isEmptyText($text.nodeValue)) {
|
|
1273
|
-
$block.replaceChild($fragment, $inline);
|
|
1274
|
-
} else {
|
|
1275
|
-
const [$before, $after] = splitTextNode($text, offset);
|
|
1276
|
-
if ($before === null) {
|
|
1277
|
-
assertNonNull($after);
|
|
1278
|
-
$after.before($fragment);
|
|
1279
|
-
} else {
|
|
1280
|
-
$before.after($fragment);
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
} else if (isAfterInline === true) {
|
|
1284
|
-
$inline.after($fragment);
|
|
1285
|
-
} else {
|
|
1286
|
-
$inline.before($fragment);
|
|
1287
|
-
}
|
|
1288
|
-
return {
|
|
1289
|
-
prevent: true,
|
|
1290
|
-
range: createCollapsedRange(createEndCursorFromTextContent($pasteLastChild ?? getLastTextContent($block)))
|
|
1291
|
-
};
|
|
1292
|
-
}
|
|
1293
|
-
const $block = getParentTextBlock($inline);
|
|
1294
|
-
let splitIndex = childIndexOf($block, $inline) + (isAfterInline === true ? 1 : 0);
|
|
1295
|
-
if (isTextNode($text)) {
|
|
1296
|
-
if (isEmptyText($text.nodeValue)) {
|
|
1297
|
-
$inline.remove();
|
|
1298
|
-
} else {
|
|
1299
|
-
const [$before] = splitTextNode($text, offset);
|
|
1300
|
-
if ($before !== null) {
|
|
1301
|
-
splitIndex++;
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
const [$aBlock, $bBlock] = splitTextBlock($block, splitIndex);
|
|
1306
|
-
const $root = $aBlock.parentElement;
|
|
1307
|
-
const $lastBlock = $mdFragment.lastChild;
|
|
1308
|
-
assertTextBlock($lastBlock);
|
|
1309
|
-
if (isEmptyTextBlock($aBlock)) {
|
|
1310
|
-
$root.replaceChild($mdFragment, $aBlock);
|
|
1311
|
-
if (isEmptyTextBlock($bBlock)) {
|
|
1312
|
-
$bBlock.remove();
|
|
1313
|
-
}
|
|
1314
|
-
} else if (isEmptyTextBlock($bBlock)) {
|
|
1315
|
-
$root.replaceChild($mdFragment, $bBlock);
|
|
1316
|
-
} else {
|
|
1317
|
-
$aBlock.after($mdFragment);
|
|
1318
|
-
}
|
|
1319
|
-
return {
|
|
1320
|
-
prevent: true,
|
|
1321
|
-
range: createCollapsedRange(createEndCursorFromTextContent(getLastTextContent($lastBlock)))
|
|
1322
|
-
};
|
|
1323
|
-
};
|
|
1324
|
-
exports.insertFromPaste = insertFromPaste;
|
|
1325
|
-
const DEFAULT_ACTION_RESULT = {
|
|
1326
|
-
prevent: false
|
|
1327
|
-
};
|
|
1328
|
-
const handleEmojiMousedown = $n => {
|
|
1329
|
-
if (isEmoji($n)) {
|
|
1330
|
-
return {
|
|
1331
|
-
prevent: true,
|
|
1332
|
-
range: createCollapsedRange(createEndCursorFromTextContent($n))
|
|
1333
|
-
};
|
|
1334
|
-
}
|
|
1335
|
-
return DEFAULT_ACTION_RESULT;
|
|
1336
|
-
};
|
|
1337
|
-
exports.handleEmojiMousedown = handleEmojiMousedown;
|
|
1338
|
-
const getBeginRange = $root => {
|
|
1339
|
-
const $block = getFirstTextBlock($root);
|
|
1340
|
-
const $inline = getFirstTextContent($block);
|
|
1341
|
-
return createCollapsedRange(createBeginCursorFromTextContent($inline));
|
|
1342
|
-
};
|
|
1343
|
-
exports.getBeginRange = getBeginRange;
|
|
1344
|
-
const getEndRange = $root => {
|
|
1345
|
-
const $block = getLastTextBlock($root);
|
|
1346
|
-
const $inline = getLastTextContent($block);
|
|
1347
|
-
return createCollapsedRange(createEndCursorFromTextContent($inline));
|
|
1348
|
-
};
|
|
1349
|
-
exports.getEndRange = getEndRange;
|
|
1350
|
-
const getSelectionInfo = range => {
|
|
1351
|
-
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
1352
|
-
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
1353
|
-
if (aCursor.$inline === bCursor.$inline) {
|
|
1354
|
-
const {
|
|
1355
|
-
$text,
|
|
1356
|
-
$inline
|
|
1357
|
-
} = aCursor;
|
|
1358
|
-
if ($text !== null || isInline($inline)) {
|
|
1359
|
-
assertInline($inline);
|
|
1360
|
-
return {
|
|
1361
|
-
bold: isFormatBold($inline),
|
|
1362
|
-
italic: isFormatItalic($inline),
|
|
1363
|
-
strikethrough: isFormatStrikethrough($inline),
|
|
1364
|
-
codetag: isFormatCodetag($inline),
|
|
1365
|
-
link: isFormatLink($inline),
|
|
1366
|
-
olist: isInsideList(true, $inline),
|
|
1367
|
-
ulist: isInsideList(false, $inline)
|
|
1368
|
-
};
|
|
1369
|
-
}
|
|
1370
|
-
return {
|
|
1371
|
-
italic: false,
|
|
1372
|
-
bold: false,
|
|
1373
|
-
strikethrough: false,
|
|
1374
|
-
codetag: false,
|
|
1375
|
-
link: false,
|
|
1376
|
-
olist: false,
|
|
1377
|
-
ulist: false
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
return {
|
|
1381
|
-
bold: isAllInsideBold(aCursor.$inline, bCursor.$inline),
|
|
1382
|
-
italic: isAllInsideItalic(aCursor.$inline, bCursor.$inline),
|
|
1383
|
-
strikethrough: isAllInsideStrikethrough(aCursor.$inline, bCursor.$inline),
|
|
1384
|
-
codetag: isAllInsideCodetag(aCursor.$inline, bCursor.$inline),
|
|
1385
|
-
link: isAllInsideLink(aCursor.$inline, bCursor.$inline),
|
|
1386
|
-
olist: isAllInsideList(true, aCursor.$inline, bCursor.$inline),
|
|
1387
|
-
ulist: isAllInsideList(false, aCursor.$inline, bCursor.$inline)
|
|
1388
|
-
};
|
|
1389
|
-
};
|
|
1390
|
-
exports.getSelectionInfo = getSelectionInfo;
|
|
1391
|
-
const isSelectionEqual = (a, b) => {
|
|
1392
|
-
return a === b || a !== null && b !== null && a.bold === b.bold && a.codetag === b.codetag && a.italic === b.italic && a.link === b.link && a.strikethrough === b.strikethrough && a.olist === b.olist && a.ulist === b.ulist;
|
|
1393
|
-
};
|
|
1394
|
-
exports.isSelectionEqual = isSelectionEqual;
|
|
1395
|
-
const isEmptyTextBlock = $block => {
|
|
1396
|
-
const blockChildren = $block.childNodes;
|
|
1397
|
-
if (blockChildren.length > 1) {
|
|
1398
|
-
return false;
|
|
1399
|
-
}
|
|
1400
|
-
const $inline = blockChildren[0];
|
|
1401
|
-
const isEmptyText = isInline($inline) && !isFormatCodetag($inline) && isEmptyTextNode(getChildText($inline));
|
|
1402
|
-
return isEmptyText;
|
|
1403
|
-
};
|
|
1404
|
-
const isEditorEmpty = $root => {
|
|
1405
|
-
const rootChildren = $root.childNodes;
|
|
1406
|
-
if (rootChildren.length > 1) {
|
|
1407
|
-
return false;
|
|
1408
|
-
}
|
|
1409
|
-
const $block = rootChildren[0];
|
|
1410
|
-
assertTextBlock($block);
|
|
1411
|
-
return isEmptyTextBlock($block);
|
|
1412
|
-
};
|
|
1413
|
-
exports.isEditorEmpty = isEditorEmpty;
|
|
1414
|
-
const serializeDescriptorReducer = range => (state, $n) => {
|
|
1415
|
-
if (isEmoji($n)) {
|
|
1416
|
-
const text = $n.getAttribute(EMOJI_CHAR_ATTR_NAME) ?? '';
|
|
1417
|
-
if (text.length > 0) {
|
|
1418
|
-
state.push({
|
|
1419
|
-
isEmoji: true,
|
|
1420
|
-
text
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
return state;
|
|
1424
|
-
}
|
|
1425
|
-
let text = getTextValue(getChildText($n));
|
|
1426
|
-
let trailingSpaces = '';
|
|
1427
|
-
if (range !== null) {
|
|
1428
|
-
const [aCursor, bCursor] = range;
|
|
1429
|
-
const isACursorPointingHere = aCursor.$inline === $n;
|
|
1430
|
-
const isBCursorPointingHere = bCursor.$inline === $n;
|
|
1431
|
-
if (isACursorPointingHere && isBCursorPointingHere) {
|
|
1432
|
-
text = text.substring(aCursor.offset, bCursor.offset);
|
|
1433
|
-
} else if (isACursorPointingHere) {
|
|
1434
|
-
text = text.substring(aCursor.offset);
|
|
1435
|
-
} else if (isBCursorPointingHere) {
|
|
1436
|
-
text = text.substring(0, bCursor.offset);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
if (isEmptyText(text)) {
|
|
1440
|
-
return state;
|
|
1441
|
-
}
|
|
1442
|
-
if (isFormatCodetag($n)) {
|
|
1443
|
-
state.push({
|
|
1444
|
-
isCodetag: true,
|
|
1445
|
-
text
|
|
1446
|
-
});
|
|
1447
|
-
return state;
|
|
1448
|
-
}
|
|
1449
|
-
if (isFormatLink($n)) {
|
|
1450
|
-
const href = $n.getAttribute(LINK_HREF_ATTR_NAME) ?? '#';
|
|
1451
|
-
state.push({
|
|
1452
|
-
isLink: true,
|
|
1453
|
-
text,
|
|
1454
|
-
href
|
|
1455
|
-
});
|
|
1456
|
-
return state;
|
|
1457
|
-
}
|
|
1458
|
-
const leadingNonSpaceIndex = text.search(/\S/);
|
|
1459
|
-
if (leadingNonSpaceIndex < 0) {
|
|
1460
|
-
state.push({
|
|
1461
|
-
isWhitespace: true,
|
|
1462
|
-
text
|
|
1463
|
-
});
|
|
1464
|
-
return state;
|
|
1465
|
-
}
|
|
1466
|
-
if (leadingNonSpaceIndex > 0) {
|
|
1467
|
-
state.push({
|
|
1468
|
-
isWhitespace: true,
|
|
1469
|
-
text: text.substring(0, leadingNonSpaceIndex)
|
|
1470
|
-
});
|
|
1471
|
-
text = text.substring(leadingNonSpaceIndex);
|
|
1472
|
-
}
|
|
1473
|
-
const trailingSpaceIndex = text.search(/\s+$/);
|
|
1474
|
-
if (trailingSpaceIndex >= 0) {
|
|
1475
|
-
trailingSpaces = text.substring(trailingSpaceIndex);
|
|
1476
|
-
text = text.substring(0, trailingSpaceIndex);
|
|
1477
|
-
}
|
|
1478
|
-
state.push({
|
|
1479
|
-
isBold: isFormatBold($n),
|
|
1480
|
-
isItalic: isFormatItalic($n),
|
|
1481
|
-
isStrikethrough: isFormatStrikethrough($n),
|
|
1482
|
-
text
|
|
1483
|
-
});
|
|
1484
|
-
if (trailingSpaces.length > 0) {
|
|
1485
|
-
state.push({
|
|
1486
|
-
isWhitespace: true,
|
|
1487
|
-
text: trailingSpaces
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
return state;
|
|
1491
|
-
};
|
|
1492
|
-
const MD_STRIKE_TOKEN = '~~';
|
|
1493
|
-
const MD_EM3_STAR_TOKEN = '***';
|
|
1494
|
-
const MD_EM2_STAR_TOKEN = '**';
|
|
1495
|
-
const MD_EM1_STAR_TOKEN = '*';
|
|
1496
|
-
const MD_EM3_UNDERSCORE_TOKEN = '___';
|
|
1497
|
-
const MD_EM2_UNDERSCORE_TOKEN = '__';
|
|
1498
|
-
const MD_EM1_UNDERSCORE_TOKEN = '_';
|
|
1499
|
-
const MD_LINEBREAK_TOKEN = ' \n';
|
|
1500
|
-
const MD_CODETAG_TOKEN = '`';
|
|
1501
|
-
const MD_ULISTITEM_TOKEN = '*';
|
|
1502
|
-
const MD_OLISTITEM_TOKEN = '1.';
|
|
1503
|
-
const MD_LISTITEM_JOIN = '\n';
|
|
1504
|
-
const MD_PARAGRAPH_JOIN = '\n\n';
|
|
1505
|
-
const serializeTextReducer = (state, desc, i, descArray) => {
|
|
1506
|
-
const {
|
|
1507
|
-
chunks
|
|
1508
|
-
} = state;
|
|
1509
|
-
if (desc.isLink === true) {
|
|
1510
|
-
chunks.push(`[${desc.text}](${desc.href})`);
|
|
1511
|
-
return state;
|
|
1512
|
-
}
|
|
1513
|
-
if (desc.isEmoji === true) {
|
|
1514
|
-
chunks.push(desc.text);
|
|
1515
|
-
return state;
|
|
1516
|
-
}
|
|
1517
|
-
if (desc.isCodetag === true) {
|
|
1518
|
-
chunks.push(`${MD_CODETAG_TOKEN}${desc.text}${MD_CODETAG_TOKEN}`);
|
|
1519
|
-
return state;
|
|
1520
|
-
}
|
|
1521
|
-
if (desc.isWhitespace === true) {
|
|
1522
|
-
chunks.push(desc.text);
|
|
1523
|
-
return state;
|
|
1524
|
-
}
|
|
1525
|
-
const prev = i === 0 ? null : descArray[i - 1];
|
|
1526
|
-
const next = i >= descArray.length - 1 ? null : descArray[i + 1];
|
|
1527
|
-
const shouldUseUnderscores = (i - state.lastUnderscoreIndex) % 2 === 0 && (prev === null || prev.isBold === true || prev.isItalic === true || prev.isWhitespace === true || prev.isCodetag === true) && (next === null || next.isBold === true || next.isItalic === true || next.isWhitespace === true || next.isCodetag === true);
|
|
1528
|
-
const {
|
|
1529
|
-
isBold,
|
|
1530
|
-
isItalic,
|
|
1531
|
-
isStrikethrough
|
|
1532
|
-
} = desc;
|
|
1533
|
-
if (shouldUseUnderscores) {
|
|
1534
|
-
state.lastUnderscoreIndex = i;
|
|
1535
|
-
}
|
|
1536
|
-
if (isStrikethrough === true && (prev === null || prev.isStrikethrough !== true)) {
|
|
1537
|
-
chunks.push(MD_STRIKE_TOKEN);
|
|
1538
|
-
}
|
|
1539
|
-
if (isBold === true && isItalic === true) {
|
|
1540
|
-
chunks.push(shouldUseUnderscores ? MD_EM3_UNDERSCORE_TOKEN : MD_EM3_STAR_TOKEN);
|
|
1541
|
-
} else if (isBold === true) {
|
|
1542
|
-
chunks.push(shouldUseUnderscores ? MD_EM2_UNDERSCORE_TOKEN : MD_EM2_STAR_TOKEN);
|
|
1543
|
-
} else if (isItalic === true) {
|
|
1544
|
-
chunks.push(shouldUseUnderscores ? MD_EM1_UNDERSCORE_TOKEN : MD_EM1_STAR_TOKEN);
|
|
1545
|
-
}
|
|
1546
|
-
chunks.push(desc.text);
|
|
1547
|
-
if (isBold === true && isItalic === true) {
|
|
1548
|
-
chunks.push(shouldUseUnderscores ? MD_EM3_UNDERSCORE_TOKEN : MD_EM3_STAR_TOKEN);
|
|
1549
|
-
} else if (isBold === true) {
|
|
1550
|
-
chunks.push(shouldUseUnderscores ? MD_EM2_UNDERSCORE_TOKEN : MD_EM2_STAR_TOKEN);
|
|
1551
|
-
} else if (isItalic === true) {
|
|
1552
|
-
chunks.push(shouldUseUnderscores ? MD_EM1_UNDERSCORE_TOKEN : MD_EM1_STAR_TOKEN);
|
|
1553
|
-
}
|
|
1554
|
-
if (isStrikethrough === true && (next === null || next.isStrikethrough !== true)) {
|
|
1555
|
-
chunks.push(MD_STRIKE_TOKEN);
|
|
1556
|
-
}
|
|
1557
|
-
return state;
|
|
1558
|
-
};
|
|
1559
|
-
const serializeTextBlock = ($n, range) => {
|
|
1560
|
-
let children;
|
|
1561
|
-
if (range !== null) {
|
|
1562
|
-
const [aCursor, bCursor] = range;
|
|
1563
|
-
const aBlock = getParentTextBlock(aCursor.$inline);
|
|
1564
|
-
const bBlock = getParentTextBlock(bCursor.$inline);
|
|
1565
|
-
const startIndex = aBlock === $n ? childIndexOf($n, aCursor.$inline) : 0;
|
|
1566
|
-
const endIndex = bBlock === $n ? childIndexOf($n, bCursor.$inline) + 1 : $n.childNodes.length;
|
|
1567
|
-
children = Array.prototype.slice.call($n.childNodes, startIndex, endIndex);
|
|
1568
|
-
} else {
|
|
1569
|
-
children = Array.from($n.childNodes);
|
|
1570
|
-
}
|
|
1571
|
-
const result = children.reduce(serializeDescriptorReducer(range), []).reduce(serializeTextReducer, {
|
|
1572
|
-
lastUnderscoreIndex: 0,
|
|
1573
|
-
chunks: []
|
|
1574
|
-
});
|
|
1575
|
-
return result.chunks.join('');
|
|
1576
|
-
};
|
|
1577
|
-
const serializeListItemIndent = (level, isOrderedStack) => {
|
|
1578
|
-
let res = '';
|
|
1579
|
-
for (let i = 0; i < level; i++) {
|
|
1580
|
-
res = res.concat(isOrderedStack[i] ? ' ' : ' ', ' ');
|
|
1581
|
-
}
|
|
1582
|
-
return res;
|
|
1583
|
-
};
|
|
1584
|
-
const serializeListItem = ($li, isOrderedStack, range) => {
|
|
1585
|
-
const isOrdered = isOrderedListItem($li);
|
|
1586
|
-
const listMdToken = isOrdered ? MD_OLISTITEM_TOKEN : MD_ULISTITEM_TOKEN;
|
|
1587
|
-
const level = getListItemLevel($li);
|
|
1588
|
-
isOrderedStack[level] = isOrdered;
|
|
1589
|
-
return `${serializeListItemIndent(level, isOrderedStack)}${listMdToken} ${serializeTextBlock($li, range)}`;
|
|
1590
|
-
};
|
|
1591
|
-
const serializeRoot = ($root, range) => {
|
|
1592
|
-
let children;
|
|
1593
|
-
if (range !== null) {
|
|
1594
|
-
const [aCursor, bCursor] = range;
|
|
1595
|
-
const aBlock = getParentTextBlock(aCursor.$inline);
|
|
1596
|
-
const bBlock = getParentTextBlock(bCursor.$inline);
|
|
1597
|
-
const startIndex = childIndexOf($root, aBlock);
|
|
1598
|
-
const endIndex = childIndexOf($root, bBlock) + 1;
|
|
1599
|
-
children = Array.prototype.slice.call($root.childNodes, startIndex, endIndex);
|
|
1600
|
-
} else {
|
|
1601
|
-
children = Array.from($root.childNodes);
|
|
1602
|
-
}
|
|
1603
|
-
const chunks = [];
|
|
1604
|
-
const listChunks = [];
|
|
1605
|
-
const listIsOrderedStack = [];
|
|
1606
|
-
const paragraphChunks = [];
|
|
1607
|
-
const flushListChunks = () => {
|
|
1608
|
-
if (listChunks.length > 0) {
|
|
1609
|
-
chunks.push(listChunks.join(MD_LISTITEM_JOIN));
|
|
1610
|
-
listChunks.length = 0;
|
|
1611
|
-
}
|
|
1612
|
-
};
|
|
1613
|
-
const flushParagraphChunks = () => {
|
|
1614
|
-
if (paragraphChunks.length > 0) {
|
|
1615
|
-
chunks.push(paragraphChunks.reduce((a, b) => {
|
|
1616
|
-
return b.length > 0 ? a.concat(MD_LINEBREAK_TOKEN, b) : a.concat('<br>');
|
|
1617
|
-
}));
|
|
1618
|
-
paragraphChunks.length = 0;
|
|
1619
|
-
}
|
|
1620
|
-
};
|
|
1621
|
-
for (let i = 0; i < children.length; i++) {
|
|
1622
|
-
const $child = children[i];
|
|
1623
|
-
if (isListItem($child)) {
|
|
1624
|
-
flushParagraphChunks();
|
|
1625
|
-
const isMainList = i === 0 || !isListItem(children[i - 1]) || isListItemMarkedArBlock($child);
|
|
1626
|
-
if (isMainList) {
|
|
1627
|
-
flushListChunks();
|
|
1628
|
-
}
|
|
1629
|
-
listChunks.push(serializeListItem($child, listIsOrderedStack, range));
|
|
1630
|
-
} else {
|
|
1631
|
-
assertTextBlock($child);
|
|
1632
|
-
flushListChunks();
|
|
1633
|
-
paragraphChunks.push(serializeTextBlock($child, range));
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
flushListChunks();
|
|
1637
|
-
flushParagraphChunks();
|
|
1638
|
-
return chunks.join(MD_PARAGRAPH_JOIN);
|
|
1639
|
-
};
|
|
1640
|
-
const serializeMarkdown = ($root, range) => {
|
|
1641
|
-
if (range !== null) {
|
|
1642
|
-
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
1643
|
-
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
1644
|
-
return serializeRoot($root, [aCursor, bCursor]);
|
|
1645
|
-
}
|
|
1646
|
-
return serializeRoot($root, null);
|
|
1647
|
-
};
|
|
1648
|
-
exports.serializeMarkdown = serializeMarkdown;
|
|
1649
|
-
const createParseVisitor = doc => {
|
|
1650
|
-
let emojiBaseUrl = null;
|
|
1651
|
-
return {
|
|
1652
|
-
updateEmojiBaseUrl(url) {
|
|
1653
|
-
emojiBaseUrl = url;
|
|
1654
|
-
},
|
|
1655
|
-
createVisitor() {
|
|
1656
|
-
const $root = doc.createDocumentFragment();
|
|
1657
|
-
let $currentBlock = null;
|
|
1658
|
-
const listsStack = [];
|
|
1659
|
-
let isFirstListItem = false;
|
|
1660
|
-
return {
|
|
1661
|
-
emoji(emojiChar) {
|
|
1662
|
-
const $emoji = createEmoji(emojiChar, emojiBaseUrl, doc);
|
|
1663
|
-
$currentBlock.appendChild($emoji);
|
|
1664
|
-
},
|
|
1665
|
-
codetag(text) {
|
|
1666
|
-
const $inline = createInlineWithText(text, doc);
|
|
1667
|
-
setInlineFormat($inline, 'c', true);
|
|
1668
|
-
$currentBlock.appendChild($inline);
|
|
1669
|
-
},
|
|
1670
|
-
inline(text, _ref2) {
|
|
1671
|
-
let {
|
|
1672
|
-
isBold,
|
|
1673
|
-
isItalic,
|
|
1674
|
-
isStrikethrough
|
|
1675
|
-
} = _ref2;
|
|
1676
|
-
const $inline = createInlineWithText(text, doc);
|
|
1677
|
-
setInlineFormat($inline, 'b', isBold === true);
|
|
1678
|
-
setInlineFormat($inline, 'i', isItalic === true);
|
|
1679
|
-
setInlineFormat($inline, 's', isStrikethrough === true);
|
|
1680
|
-
$currentBlock.appendChild($inline);
|
|
1681
|
-
},
|
|
1682
|
-
linebreak() {
|
|
1683
|
-
if (listsStack.length === 0) {
|
|
1684
|
-
$currentBlock = createActuallyEmptyParagraph(doc);
|
|
1685
|
-
$root.appendChild($currentBlock);
|
|
1686
|
-
}
|
|
1687
|
-
},
|
|
1688
|
-
link(text, href) {
|
|
1689
|
-
const $link = createLink(text, href, doc);
|
|
1690
|
-
$currentBlock.appendChild($link);
|
|
1691
|
-
},
|
|
1692
|
-
list(isOrdered) {
|
|
1693
|
-
listsStack.push({
|
|
1694
|
-
isOrdered
|
|
1695
|
-
});
|
|
1696
|
-
isFirstListItem = true;
|
|
1697
|
-
$currentBlock = null;
|
|
1698
|
-
},
|
|
1699
|
-
endList() {
|
|
1700
|
-
listsStack.length = listsStack.length - 1;
|
|
1701
|
-
isFirstListItem = false;
|
|
1702
|
-
$currentBlock = null;
|
|
1703
|
-
},
|
|
1704
|
-
listItem() {
|
|
1705
|
-
const listLevel = listsStack.length - 1;
|
|
1706
|
-
const {
|
|
1707
|
-
isOrdered
|
|
1708
|
-
} = listsStack.at(-1);
|
|
1709
|
-
const $li = createActuallyEmptyListItem(isOrdered, listLevel, doc);
|
|
1710
|
-
if (listsStack.length === 1 && isFirstListItem) {
|
|
1711
|
-
markListItemAsBlock($li);
|
|
1712
|
-
isFirstListItem = false;
|
|
1713
|
-
}
|
|
1714
|
-
$root.appendChild($li);
|
|
1715
|
-
$currentBlock = $li;
|
|
1716
|
-
},
|
|
1717
|
-
paragraph() {
|
|
1718
|
-
if (listsStack.length === 0) {
|
|
1719
|
-
$currentBlock = createActuallyEmptyParagraph(doc);
|
|
1720
|
-
$root.appendChild($currentBlock);
|
|
1721
|
-
}
|
|
1722
|
-
},
|
|
1723
|
-
end() {
|
|
1724
|
-
const children = $root.childNodes;
|
|
1725
|
-
for (let i = 0; i < children.length; i++) {
|
|
1726
|
-
const child = children[i];
|
|
1727
|
-
assertTextBlock(child);
|
|
1728
|
-
ensureCorrectTextBlockIfEmpty(child);
|
|
1729
|
-
}
|
|
1730
|
-
return $root;
|
|
1731
|
-
}
|
|
1732
|
-
};
|
|
1733
|
-
}
|
|
1734
|
-
};
|
|
1735
|
-
};
|
|
1736
|
-
exports.createParseVisitor = createParseVisitor;
|
|
1737
|
-
const setBrowserCaret = _ref3 => {
|
|
1738
|
-
let {
|
|
1739
|
-
startContainer,
|
|
1740
|
-
startOffset,
|
|
1741
|
-
endContainer,
|
|
1742
|
-
endOffset
|
|
1743
|
-
} = _ref3;
|
|
1744
|
-
const selection = document.getSelection();
|
|
1745
|
-
if (selection === null) {
|
|
1746
|
-
return;
|
|
1747
|
-
}
|
|
1748
|
-
selection.removeAllRanges();
|
|
1749
|
-
const range = document.createRange();
|
|
1750
|
-
range.setStart(startContainer, startOffset);
|
|
1751
|
-
range.setEnd(endContainer, endOffset);
|
|
1752
|
-
selection.addRange(range);
|
|
1753
|
-
};
|
|
1754
|
-
exports.setBrowserCaret = setBrowserCaret;
|