@nectary/components 4.11.1 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/global/index.d.ts +1 -0
- package/accordion/global/index.js +2 -0
- package/accordion/index.d.ts +1 -22
- package/accordion/index.js +41 -39
- package/accordion/types.d.ts +21 -1
- package/accordion/types.js +1 -1
- package/accordion-item/global/index.d.ts +1 -0
- package/accordion-item/global/index.js +2 -0
- package/accordion-item/index.d.ts +2 -22
- package/accordion-item/index.js +53 -49
- package/accordion-item/types.d.ts +21 -1
- package/accordion-item/types.js +1 -1
- package/accordion-item/utils.js +4 -1
- package/action-menu/global/index.d.ts +1 -0
- package/action-menu/global/index.js +2 -0
- package/action-menu/index.d.ts +1 -22
- package/action-menu/index.js +83 -75
- package/action-menu/types.d.ts +21 -1
- package/action-menu/types.js +1 -1
- package/action-menu-option/global/index.d.ts +1 -0
- package/action-menu-option/global/index.js +2 -0
- package/action-menu-option/index.d.ts +1 -22
- package/action-menu-option/index.js +39 -41
- package/action-menu-option/types.d.ts +21 -1
- package/action-menu-option/types.js +1 -1
- package/action-menu-option/utils.js +6 -3
- package/alert/global/index.d.ts +1 -0
- package/alert/global/index.js +2 -0
- package/alert/index.d.ts +2 -22
- package/alert/index.js +24 -21
- package/alert/types.d.ts +21 -1
- package/alert/types.js +1 -1
- package/alert/utils.js +4 -1
- package/avatar/colors.js +1 -1
- package/avatar/global/index.d.ts +1 -0
- package/avatar/global/index.js +2 -0
- package/avatar/index.d.ts +2 -22
- package/avatar/index.js +42 -41
- package/avatar/types.d.ts +21 -1
- package/avatar/types.js +1 -1
- package/avatar/utils.js +9 -4
- package/badge/global/index.d.ts +1 -0
- package/badge/global/index.js +2 -0
- package/badge/index.d.ts +3 -22
- package/badge/index.js +52 -51
- package/badge/types.d.ts +21 -1
- package/badge/types.js +1 -1
- package/badge/utils.js +4 -1
- package/bundle.d.ts +78 -0
- package/bundle.js +13033 -0
- package/bundle.ts +80 -0
- package/button/global/index.d.ts +1 -0
- package/button/global/index.js +2 -0
- package/button/index.d.ts +2 -22
- package/button/index.js +101 -111
- package/button/types.d.ts +21 -1
- package/button/types.js +1 -1
- package/button/utils.js +18 -2
- package/button-group/global/index.d.ts +1 -0
- package/button-group/global/index.js +2 -0
- package/button-group/index.d.ts +1 -22
- package/button-group/index.js +20 -18
- package/button-group/types.d.ts +22 -3
- package/button-group/types.js +1 -1
- package/button-group-item/global/index.d.ts +1 -0
- package/button-group-item/global/index.js +2 -0
- package/button-group-item/index.d.ts +2 -22
- package/button-group-item/index.js +31 -42
- package/button-group-item/types.d.ts +22 -3
- package/button-group-item/types.js +1 -1
- package/card-container/global/index.d.ts +1 -0
- package/card-container/global/index.js +2 -0
- package/card-container/index.d.ts +1 -21
- package/card-container/index.js +8 -5
- package/card-container/types.d.ts +21 -1
- package/card-container/types.js +1 -1
- package/card-v2/global/index.d.ts +1 -0
- package/card-v2/global/index.js +2 -0
- package/card-v2/index.d.ts +1 -22
- package/card-v2/index.js +59 -57
- package/card-v2/types.d.ts +21 -1
- package/card-v2/types.js +1 -1
- package/card-v2-title/global/index.d.ts +1 -0
- package/card-v2-title/global/index.js +2 -0
- package/card-v2-title/index.d.ts +2 -22
- package/card-v2-title/index.js +28 -26
- package/card-v2-title/types.d.ts +21 -1
- package/card-v2-title/types.js +1 -1
- package/checkbox/global/index.d.ts +1 -0
- package/checkbox/global/index.js +2 -0
- package/checkbox/index.d.ts +1 -22
- package/checkbox/index.js +88 -81
- package/checkbox/types.d.ts +21 -1
- package/checkbox/types.js +1 -1
- package/chip/colors.js +1 -1
- package/chip/global/index.d.ts +1 -0
- package/chip/global/index.js +2 -0
- package/chip/index.d.ts +1 -22
- package/chip/index.js +62 -75
- package/chip/types.d.ts +21 -1
- package/chip/types.js +1 -1
- package/chip/utils.js +7 -3
- package/code-tag/global/index.d.ts +1 -0
- package/code-tag/global/index.js +2 -0
- package/code-tag/index.d.ts +1 -22
- package/code-tag/index.js +17 -14
- package/code-tag/types.d.ts +21 -1
- package/code-tag/types.js +1 -1
- package/color-menu/global/index.d.ts +1 -0
- package/color-menu/global/index.js +2 -0
- package/color-menu/index.d.ts +2 -22
- package/color-menu/index.js +115 -115
- package/color-menu/types.d.ts +21 -1
- package/color-menu/types.js +1 -1
- package/color-menu/utils.js +6 -3
- package/color-menu-option/global/index.d.ts +1 -0
- package/color-menu-option/global/index.js +2 -0
- package/color-menu-option/index.d.ts +1 -22
- package/color-menu-option/index.js +30 -26
- package/color-menu-option/types.d.ts +21 -1
- package/color-menu-option/types.js +1 -1
- package/color-menu-option/utils.js +6 -3
- package/color-swatch/global/index.d.ts +1 -0
- package/color-swatch/global/index.js +2 -0
- package/color-swatch/index.d.ts +1 -22
- package/color-swatch/index.js +23 -20
- package/color-swatch/types.d.ts +21 -1
- package/color-swatch/types.js +1 -1
- package/color-swatch/utils.js +7 -3
- package/date-picker/global/index.d.ts +1 -0
- package/date-picker/global/index.js +2 -0
- package/date-picker/index.d.ts +2 -22
- package/date-picker/index.js +157 -150
- package/date-picker/types.d.ts +21 -1
- package/date-picker/types.js +1 -1
- package/date-picker/utils.js +59 -42
- package/dialog/global/index.d.ts +1 -0
- package/dialog/global/index.js +2 -0
- package/dialog/index.d.ts +1 -22
- package/dialog/index.js +71 -58
- package/dialog/types.d.ts +21 -1
- package/dialog/types.js +1 -1
- package/dialog/utils.js +11 -7
- package/emoji/global/index.d.ts +1 -0
- package/emoji/global/index.js +2 -0
- package/emoji/index.d.ts +1 -22
- package/emoji/index.js +19 -16
- package/emoji/types.d.ts +21 -1
- package/emoji/types.js +1 -1
- package/emoji/utils.js +22 -17
- package/emoji-picker/global/index.d.ts +1 -0
- package/emoji-picker/global/index.js +2 -0
- package/emoji-picker/index.d.ts +2 -22
- package/emoji-picker/index.js +138 -118
- package/emoji-picker/types.d.ts +21 -1
- package/emoji-picker/types.js +1 -1
- package/field/global/index.d.ts +1 -0
- package/field/global/index.js +2 -0
- package/field/index.d.ts +1 -22
- package/field/index.js +63 -60
- package/field/types.d.ts +21 -1
- package/field/types.js +1 -1
- package/file-drop/global/index.d.ts +1 -0
- package/file-drop/global/index.js +2 -0
- package/file-drop/index.d.ts +1 -22
- package/file-drop/index.js +103 -98
- package/file-drop/types.d.ts +21 -1
- package/file-drop/types.js +1 -1
- package/file-drop/utils.js +27 -22
- package/file-picker/global/index.d.ts +1 -0
- package/file-picker/global/index.js +2 -0
- package/file-picker/index.d.ts +1 -22
- package/file-picker/index.js +53 -48
- package/file-picker/types.d.ts +21 -1
- package/file-picker/types.js +1 -1
- package/file-picker/utils.js +6 -3
- package/file-status/global/index.d.ts +1 -0
- package/file-status/global/index.js +2 -0
- package/file-status/index.d.ts +2 -22
- package/file-status/index.js +33 -22
- package/file-status/types.d.ts +21 -1
- package/file-status/types.js +1 -1
- package/file-status/utils.js +4 -1
- package/flag/global/index.d.ts +1 -0
- package/flag/global/index.js +2 -0
- package/flag/index.d.ts +1 -22
- package/flag/index.js +19 -16
- package/flag/types.d.ts +21 -1
- package/flag/types.js +1 -1
- package/flag/utils.js +11 -8
- package/grid/global/index.d.ts +1 -0
- package/grid/global/index.js +2 -0
- package/grid/index.d.ts +1 -22
- package/grid/index.js +8 -5
- package/grid/types.d.ts +21 -1
- package/grid/types.js +1 -1
- package/grid-item/global/index.d.ts +1 -0
- package/grid-item/global/index.js +2 -0
- package/grid-item/index.d.ts +1 -22
- package/grid-item/index.js +17 -13
- package/grid-item/types.d.ts +21 -1
- package/grid-item/types.js +1 -1
- package/help-tooltip/global/index.d.ts +1 -0
- package/help-tooltip/global/index.js +2 -0
- package/help-tooltip/index.d.ts +1 -22
- package/help-tooltip/index.js +29 -26
- package/help-tooltip/types.d.ts +21 -1
- package/help-tooltip/types.js +1 -1
- package/icon/generated-icon-type.js +1 -1
- package/icon/global/index.d.ts +1 -0
- package/icon/global/index.js +2 -0
- package/icon/index.d.ts +1 -22
- package/icon/index.js +30 -28
- package/icon/types.d.ts +21 -1
- package/icon/types.js +1 -1
- package/inline-alert/global/index.d.ts +1 -0
- package/inline-alert/global/index.js +2 -0
- package/inline-alert/index.d.ts +2 -22
- package/inline-alert/index.js +58 -39
- package/inline-alert/types.d.ts +21 -1
- package/inline-alert/types.js +1 -1
- package/inline-alert/utils.js +4 -1
- package/input/global/index.d.ts +1 -0
- package/input/global/index.js +2 -0
- package/input/index.d.ts +2 -22
- package/input/index.js +295 -317
- package/input/types.d.ts +21 -1
- package/input/types.js +1 -1
- package/input/utils.js +56 -46
- package/link/global/index.d.ts +1 -0
- package/link/global/index.js +2 -0
- package/link/index.d.ts +1 -22
- package/link/index.js +88 -79
- package/link/types.d.ts +21 -1
- package/link/types.js +1 -1
- package/list/global/index.d.ts +1 -0
- package/list/global/index.js +2 -0
- package/list/index.d.ts +1 -21
- package/list/index.js +9 -6
- package/list/types.d.ts +21 -1
- package/list/types.js +1 -1
- package/list-item/global/index.d.ts +1 -0
- package/list-item/global/index.js +2 -0
- package/list-item/index.d.ts +1 -22
- package/list-item/index.js +9 -6
- package/list-item/types.d.ts +21 -1
- package/list-item/types.js +1 -1
- package/package.json +12 -6
- package/pagination/global/index.d.ts +1 -0
- package/pagination/global/index.js +2 -0
- package/pagination/index.d.ts +2 -22
- package/pagination/index.js +64 -46
- package/pagination/types.d.ts +21 -1
- package/pagination/types.js +1 -1
- package/persistent-overlay/global/index.d.ts +1 -0
- package/persistent-overlay/global/index.js +2 -0
- package/persistent-overlay/index.d.ts +1 -22
- package/persistent-overlay/index.js +42 -44
- package/persistent-overlay/types.d.ts +21 -1
- package/persistent-overlay/types.js +1 -1
- package/pop/global/index.d.ts +1 -0
- package/pop/global/index.js +2 -0
- package/pop/index.d.ts +3 -22
- package/pop/index.js +149 -150
- package/pop/types.d.ts +21 -1
- package/pop/types.js +1 -1
- package/pop/utils.js +24 -8
- package/popover/global/index.d.ts +1 -0
- package/popover/global/index.js +2 -0
- package/popover/index.d.ts +2 -22
- package/popover/index.js +75 -68
- package/popover/types.d.ts +21 -1
- package/popover/types.js +1 -1
- package/popover/utils.js +18 -7
- package/progress/global/index.d.ts +1 -0
- package/progress/global/index.js +2 -0
- package/progress/index.d.ts +1 -22
- package/progress/index.js +30 -33
- package/progress/types.d.ts +21 -1
- package/progress/types.js +1 -1
- package/progress-stepper/global/index.d.ts +1 -0
- package/progress-stepper/global/index.js +2 -0
- package/progress-stepper/index.d.ts +2 -22
- package/progress-stepper/index.js +64 -66
- package/progress-stepper/types.d.ts +21 -1
- package/progress-stepper/types.js +1 -1
- package/progress-stepper-item/global/index.d.ts +1 -0
- package/progress-stepper-item/global/index.js +2 -0
- package/progress-stepper-item/index.d.ts +1 -22
- package/progress-stepper-item/index.js +58 -50
- package/progress-stepper-item/types.d.ts +21 -1
- package/progress-stepper-item/types.js +1 -1
- package/progress-stepper-item/utils.js +22 -11
- package/radio/global/index.d.ts +1 -0
- package/radio/global/index.js +2 -0
- package/radio/index.d.ts +1 -22
- package/radio/index.js +79 -83
- package/radio/types.d.ts +21 -1
- package/radio/types.js +1 -1
- package/radio-option/global/index.d.ts +1 -0
- package/radio-option/global/index.js +2 -0
- package/radio-option/index.d.ts +1 -22
- package/radio-option/index.js +47 -41
- package/radio-option/types.d.ts +21 -1
- package/radio-option/types.js +1 -1
- package/rich-text/global/index.d.ts +1 -0
- package/rich-text/global/index.js +2 -0
- package/rich-text/index.d.ts +1 -22
- package/rich-text/index.js +45 -46
- package/rich-text/types.d.ts +21 -1
- package/rich-text/types.js +1 -1
- package/rich-text/utils.js +31 -33
- package/rich-textarea/global/index.d.ts +1 -0
- package/rich-textarea/global/index.js +2 -0
- package/rich-textarea/index.d.ts +1 -22
- package/rich-textarea/index.js +201 -194
- package/rich-textarea/types.d.ts +21 -1
- package/rich-textarea/types.js +1 -1
- package/rich-textarea/utils.js +313 -340
- package/segment-collapse/global/index.d.ts +1 -0
- package/segment-collapse/global/index.js +2 -0
- package/segment-collapse/index.d.ts +1 -22
- package/segment-collapse/index.js +31 -25
- package/segment-collapse/types.d.ts +21 -1
- package/segment-collapse/types.js +1 -1
- package/segmented-control/global/index.d.ts +1 -0
- package/segmented-control/global/index.js +2 -0
- package/segmented-control/index.d.ts +1 -22
- package/segmented-control/index.js +45 -45
- package/segmented-control/types.d.ts +21 -1
- package/segmented-control/types.js +1 -1
- package/segmented-control-option/global/index.d.ts +1 -0
- package/segmented-control-option/global/index.js +2 -0
- package/segmented-control-option/index.d.ts +1 -22
- package/segmented-control-option/index.js +44 -46
- package/segmented-control-option/types.d.ts +21 -1
- package/segmented-control-option/types.js +1 -1
- package/segmented-icon-control/global/index.d.ts +1 -0
- package/segmented-icon-control/global/index.js +2 -0
- package/segmented-icon-control/index.d.ts +1 -22
- package/segmented-icon-control/index.js +51 -50
- package/segmented-icon-control/types.d.ts +21 -1
- package/segmented-icon-control/types.js +1 -1
- package/segmented-icon-control-option/global/index.d.ts +1 -0
- package/segmented-icon-control-option/global/index.js +2 -0
- package/segmented-icon-control-option/index.d.ts +1 -22
- package/segmented-icon-control-option/index.js +36 -37
- package/segmented-icon-control-option/types.d.ts +21 -1
- package/segmented-icon-control-option/types.js +1 -1
- package/select-button/global/index.d.ts +1 -0
- package/select-button/global/index.js +2 -0
- package/select-button/index.d.ts +1 -26
- package/select-button/index.js +104 -112
- package/select-button/types.d.ts +25 -1
- package/select-button/types.js +1 -1
- package/select-menu/global/index.d.ts +1 -0
- package/select-menu/global/index.js +2 -0
- package/select-menu/index.d.ts +1 -22
- package/select-menu/index.js +201 -164
- package/select-menu/types.d.ts +21 -1
- package/select-menu/types.js +1 -1
- package/select-menu-option/global/index.d.ts +1 -0
- package/select-menu-option/global/index.js +2 -0
- package/select-menu-option/index.d.ts +1 -22
- package/select-menu-option/index.js +41 -33
- package/select-menu-option/types.d.ts +21 -1
- package/select-menu-option/types.js +1 -1
- package/select-menu-option/utils.js +4 -1
- package/skeleton/global/index.d.ts +1 -0
- package/skeleton/global/index.js +2 -0
- package/skeleton/index.d.ts +1 -22
- package/skeleton/index.js +35 -38
- package/skeleton/types.d.ts +21 -1
- package/skeleton/types.js +1 -1
- package/skeleton-item/global/index.d.ts +1 -0
- package/skeleton-item/global/index.js +2 -0
- package/skeleton-item/index.d.ts +1 -22
- package/skeleton-item/index.js +8 -5
- package/skeleton-item/types.d.ts +21 -1
- package/skeleton-item/types.js +1 -1
- package/spinner/global/index.d.ts +1 -0
- package/spinner/global/index.js +2 -0
- package/spinner/index.d.ts +1 -22
- package/spinner/index.js +31 -29
- package/spinner/types.d.ts +21 -1
- package/spinner/types.js +1 -1
- package/standalone.d.ts +0 -8
- package/standalone.js +79 -87
- package/standalone.ts +0 -8
- package/stop-events/index.js +12 -12
- package/table/global/index.d.ts +1 -0
- package/table/global/index.js +2 -0
- package/table/index.d.ts +1 -21
- package/table/index.js +9 -6
- package/table/types.d.ts +21 -1
- package/table/types.js +1 -1
- package/table-body/global/index.d.ts +1 -0
- package/table-body/global/index.js +2 -0
- package/table-body/index.d.ts +1 -21
- package/table-body/index.js +9 -6
- package/table-body/types.d.ts +21 -1
- package/table-body/types.js +1 -1
- package/table-cell/global/index.d.ts +1 -0
- package/table-cell/global/index.js +2 -0
- package/table-cell/index.d.ts +2 -22
- package/table-cell/index.js +13 -9
- package/table-cell/types.d.ts +21 -1
- package/table-cell/types.js +1 -1
- package/table-cell/utils.js +4 -1
- package/table-head/global/index.d.ts +1 -0
- package/table-head/global/index.js +2 -0
- package/table-head/index.d.ts +1 -21
- package/table-head/index.js +9 -6
- package/table-head/types.d.ts +21 -1
- package/table-head/types.js +1 -1
- package/table-head-cell/global/index.d.ts +1 -0
- package/table-head-cell/global/index.js +2 -0
- package/table-head-cell/index.d.ts +1 -22
- package/table-head-cell/index.js +29 -27
- package/table-head-cell/types.d.ts +21 -1
- package/table-head-cell/types.js +1 -1
- package/table-row/global/index.d.ts +1 -0
- package/table-row/global/index.js +2 -0
- package/table-row/index.d.ts +1 -22
- package/table-row/index.js +20 -17
- package/table-row/types.d.ts +21 -1
- package/table-row/types.js +1 -1
- package/tabs/global/index.d.ts +1 -0
- package/tabs/global/index.js +2 -0
- package/tabs/index.d.ts +2 -22
- package/tabs/index.js +32 -35
- package/tabs/types.d.ts +21 -1
- package/tabs/types.js +1 -1
- package/tabs-icon-option/global/index.d.ts +1 -0
- package/tabs-icon-option/global/index.js +2 -0
- package/tabs-icon-option/index.d.ts +1 -22
- package/tabs-icon-option/index.js +38 -40
- package/tabs-icon-option/types.d.ts +21 -1
- package/tabs-icon-option/types.js +1 -1
- package/tabs-option/global/index.d.ts +1 -0
- package/tabs-option/global/index.js +2 -0
- package/tabs-option/index.d.ts +1 -22
- package/tabs-option/index.js +41 -43
- package/tabs-option/types.d.ts +21 -1
- package/tabs-option/types.js +1 -1
- package/tag/colors.js +1 -1
- package/tag/global/index.d.ts +1 -0
- package/tag/global/index.js +2 -0
- package/tag/index.d.ts +1 -22
- package/tag/index.js +45 -44
- package/tag/types.d.ts +21 -1
- package/tag/types.js +1 -1
- package/tag/utils.js +7 -3
- package/text/global/index.d.ts +1 -0
- package/text/global/index.js +2 -0
- package/text/index.d.ts +2 -22
- package/text/index.js +33 -28
- package/text/types.d.ts +21 -1
- package/text/types.js +1 -1
- package/text/utils.js +4 -1
- package/textarea/global/index.d.ts +1 -0
- package/textarea/global/index.js +2 -0
- package/textarea/index.d.ts +1 -22
- package/textarea/index.js +147 -152
- package/textarea/types.d.ts +21 -1
- package/textarea/types.js +1 -1
- package/time-picker/global/index.d.ts +1 -0
- package/time-picker/global/index.js +2 -0
- package/time-picker/index.d.ts +2 -22
- package/time-picker/index.js +119 -123
- package/time-picker/types.d.ts +21 -1
- package/time-picker/types.js +1 -1
- package/time-picker/utils.js +31 -33
- package/title/global/index.d.ts +1 -0
- package/title/global/index.js +2 -0
- package/title/index.d.ts +2 -22
- package/title/index.js +32 -31
- package/title/types.d.ts +21 -1
- package/title/types.js +1 -1
- package/title/utils.js +18 -14
- package/toast/global/index.d.ts +1 -0
- package/toast/global/index.js +2 -0
- package/toast/index.d.ts +2 -22
- package/toast/index.js +37 -34
- package/toast/types.d.ts +21 -1
- package/toast/types.js +1 -1
- package/toast/utils.js +4 -1
- package/toast-manager/global/index.d.ts +1 -0
- package/toast-manager/global/index.js +2 -0
- package/toast-manager/index.d.ts +3 -22
- package/toast-manager/index.js +77 -63
- package/toast-manager/types.d.ts +21 -1
- package/toast-manager/types.js +1 -1
- package/toast-manager/utils.js +4 -1
- package/toggle/global/index.d.ts +1 -0
- package/toggle/global/index.js +2 -0
- package/toggle/index.d.ts +1 -22
- package/toggle/index.js +81 -75
- package/toggle/types.d.ts +21 -1
- package/toggle/types.js +1 -1
- package/tooltip/global/index.d.ts +1 -0
- package/tooltip/global/index.js +2 -0
- package/tooltip/index.d.ts +3 -22
- package/tooltip/index.js +105 -93
- package/tooltip/tooltip-state.js +56 -64
- package/tooltip/types.d.ts +21 -1
- package/tooltip/types.js +1 -1
- package/tooltip/utils.js +32 -13
- package/types.d.ts +12 -29
- package/utils/adapters.js +1 -1
- package/utils/component-names.d.ts +3 -0
- package/utils/component-names.js +85 -0
- package/utils/context.js +32 -42
- package/utils/countries.js +490 -2
- package/utils/csv.js +13 -6
- package/utils/debounce.js +10 -3
- package/utils/dom.js +60 -53
- package/utils/element.d.ts +107 -15
- package/utils/element.js +100 -19
- package/utils/event-target.js +11 -5
- package/utils/form.js +17 -12
- package/utils/get-react-event-handler.js +6 -3
- package/utils/global-components-constants.d.ts +3 -0
- package/utils/global-components-constants.js +8 -0
- package/utils/global-components-manager.d.ts +71 -0
- package/utils/global-components-manager.js +24 -0
- package/utils/index.js +65 -12
- package/utils/markdown.js +56 -43
- package/utils/rect.js +13 -18
- package/utils/shared/global-elements-manager.d.js +1 -0
- package/utils/shared/global-elements-manager.d.ts +62 -0
- package/utils/shared/global-elements-manager.js +163 -0
- package/utils/shared/global-elements-store.d.js +1 -0
- package/utils/shared/global-elements-store.d.ts +12 -0
- package/utils/shared/global-elements-store.js +31 -0
- package/utils/shared/index.d.js +11 -0
- package/utils/shared/index.d.ts +3 -0
- package/utils/shared/index.js +11 -0
- package/utils/shared/nectary-element-base.d.js +1 -0
- package/utils/shared/nectary-element-base.d.ts +9 -0
- package/utils/shared/nectary-element-base.js +25 -0
- package/utils/shared/package.json +9 -0
- package/utils/shared/tsconfig.json +20 -0
- package/utils/size.js +8 -3
- package/utils/slot.js +13 -9
- package/utils/throttle.js +5 -2
- package/utils/uid.js +5 -2
- package/card/index.d.ts +0 -40
- package/card/index.js +0 -134
- package/card/types.d.ts +0 -17
- package/card/types.js +0 -1
- package/horizontal-stepper/index.d.ts +0 -33
- package/horizontal-stepper/index.js +0 -62
- package/horizontal-stepper/types.d.ts +0 -42
- package/horizontal-stepper/types.js +0 -1
- package/horizontal-stepper-item/index.d.ts +0 -38
- package/horizontal-stepper-item/index.js +0 -62
- package/horizontal-stepper-item/types.d.ts +0 -38
- package/horizontal-stepper-item/types.js +0 -1
- package/horizontal-stepper-item/utils.d.ts +0 -2
- package/horizontal-stepper-item/utils.js +0 -1
- package/segment/index.d.ts +0 -40
- package/segment/index.js +0 -110
- package/segment/types.d.ts +0 -23
- package/segment/types.js +0 -1
- package/segment/utils.d.ts +0 -3
- package/segment/utils.js +0 -16
- package/tile-control/index.d.ts +0 -39
- package/tile-control/index.js +0 -111
- package/tile-control/types.d.ts +0 -29
- package/tile-control/types.js +0 -1
- package/tile-control-option/index.d.ts +0 -40
- package/tile-control-option/index.js +0 -99
- package/tile-control-option/types.d.ts +0 -52
- package/tile-control-option/types.js +0 -1
- package/vertical-stepper/index.d.ts +0 -33
- package/vertical-stepper/index.js +0 -58
- package/vertical-stepper/types.d.ts +0 -34
- package/vertical-stepper/types.js +0 -1
- package/vertical-stepper-item/index.d.ts +0 -38
- package/vertical-stepper-item/index.js +0 -62
- package/vertical-stepper-item/types.d.ts +0 -42
- package/vertical-stepper-item/types.js +0 -1
- package/vertical-stepper-item/utils.d.ts +0 -2
- package/vertical-stepper-item/utils.js +0 -1
package/rich-textarea/utils.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isEmojiString, parseMarkdown } from
|
|
3
|
-
const TEXT_EMPTY_DATA =
|
|
4
|
-
const TEXT_WHITESPACE =
|
|
5
|
-
const isTextNode = $n => $n !== null && $n.nodeType === Node.TEXT_NODE;
|
|
6
|
-
const isEmptyText = value => value === null || value.length === 0 || value === TEXT_EMPTY_DATA;
|
|
7
|
-
const isEmptyTextNode = $n => isTextNode($n) && isEmptyText($n.nodeValue);
|
|
8
|
-
const getTextValue = $n => isEmptyText($n.nodeValue) ? TEXT_EMPTY_DATA : $n.nodeValue;
|
|
9
|
-
const isParagraph = $n => {
|
|
10
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains(
|
|
11
|
-
};
|
|
12
|
-
const isListItem = $n => {
|
|
1
|
+
import { getEmojiUrl, getEmojiBaseUrl } from "../emoji/utils.js";
|
|
2
|
+
import { isEmojiString, parseMarkdown } from "../utils/markdown.js";
|
|
3
|
+
const TEXT_EMPTY_DATA = "";
|
|
4
|
+
const TEXT_WHITESPACE = " ";
|
|
5
|
+
const isTextNode = ($n) => $n !== null && $n.nodeType === Node.TEXT_NODE;
|
|
6
|
+
const isEmptyText = (value) => value === null || value.length === 0 || value === TEXT_EMPTY_DATA;
|
|
7
|
+
const isEmptyTextNode = ($n) => isTextNode($n) && isEmptyText($n.nodeValue);
|
|
8
|
+
const getTextValue = ($n) => isEmptyText($n.nodeValue) ? TEXT_EMPTY_DATA : $n.nodeValue;
|
|
9
|
+
const isParagraph = ($n) => {
|
|
10
|
+
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains("p");
|
|
11
|
+
};
|
|
12
|
+
const isListItem = ($n) => {
|
|
13
13
|
return isUnorderedListItem($n) || isOrderedListItem($n);
|
|
14
14
|
};
|
|
15
|
-
const isUnorderedListItem = $n => {
|
|
16
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains(
|
|
15
|
+
const isUnorderedListItem = ($n) => {
|
|
16
|
+
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains("uli");
|
|
17
17
|
};
|
|
18
|
-
const isOrderedListItem = $n => {
|
|
19
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains(
|
|
18
|
+
const isOrderedListItem = ($n) => {
|
|
19
|
+
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains("oli");
|
|
20
20
|
};
|
|
21
|
-
const isTextBlock = $n => isParagraph($n) || isListItem($n);
|
|
22
|
-
const isEmoji = $n => {
|
|
23
|
-
return $n !== null && $n.nodeName ===
|
|
21
|
+
const isTextBlock = ($n) => isParagraph($n) || isListItem($n);
|
|
22
|
+
const isEmoji = ($n) => {
|
|
23
|
+
return $n !== null && $n.nodeName === "IMG";
|
|
24
24
|
};
|
|
25
|
-
const isInline = $n => $n !== null && $n.nodeName ===
|
|
26
|
-
const isRoot = $n => $n !== null && $n.nodeName ===
|
|
27
|
-
const assertNonNull = $n => {
|
|
25
|
+
const isInline = ($n) => $n !== null && $n.nodeName === "SPAN";
|
|
26
|
+
const isRoot = ($n) => $n !== null && $n.nodeName === "DIV";
|
|
27
|
+
const assertNonNull = ($n) => {
|
|
28
28
|
if ($n === null) {
|
|
29
|
-
throw new Error(
|
|
29
|
+
throw new Error("Node is NULL");
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
const assertEquals = (a, b) => {
|
|
@@ -34,64 +34,64 @@ const assertEquals = (a, b) => {
|
|
|
34
34
|
throw new Error(`"${a}" not equals "${b}"`);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
const assertTextNode = $n => {
|
|
37
|
+
const assertTextNode = ($n) => {
|
|
38
38
|
assertNonNull($n);
|
|
39
39
|
if (!isTextNode($n)) {
|
|
40
40
|
throw new Error(`Node is not a TextNode: ${$n?.nodeName}`);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
const assertTextBlock = $n => {
|
|
43
|
+
const assertTextBlock = ($n) => {
|
|
44
44
|
assertNonNull($n);
|
|
45
45
|
if (!isTextBlock($n)) {
|
|
46
46
|
throw new Error(`Node is not a TextBlock: ${$n?.nodeName}`);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
const assertListItem = $n => {
|
|
49
|
+
const assertListItem = ($n) => {
|
|
50
50
|
assertNonNull($n);
|
|
51
51
|
if (!isListItem($n)) {
|
|
52
52
|
throw new Error(`Node is not a ListItem: ${$n?.nodeName}`);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
const markListItemAsBlock = $li => {
|
|
56
|
-
$li.classList.add(
|
|
55
|
+
const markListItemAsBlock = ($li) => {
|
|
56
|
+
$li.classList.add("block");
|
|
57
57
|
};
|
|
58
|
-
const isListItemMarkedArBlock = $li => {
|
|
59
|
-
return $li.classList.contains(
|
|
58
|
+
const isListItemMarkedArBlock = ($li) => {
|
|
59
|
+
return $li.classList.contains("block");
|
|
60
60
|
};
|
|
61
61
|
const MAX_LISTITEM_LEVEL = 4;
|
|
62
|
-
const removeListItemLevel = $li => {
|
|
63
|
-
$li.classList.remove(
|
|
62
|
+
const removeListItemLevel = ($li) => {
|
|
63
|
+
$li.classList.remove("l0", "l1", "l2", "l3", "l4");
|
|
64
64
|
};
|
|
65
65
|
const setListItemLevel = ($li, level) => {
|
|
66
66
|
removeListItemLevel($li);
|
|
67
67
|
const clampedLevel = Math.max(0, Math.min(level, MAX_LISTITEM_LEVEL));
|
|
68
68
|
$li.classList.add(`l${clampedLevel}`);
|
|
69
69
|
};
|
|
70
|
-
const getListItemLevel = $li => {
|
|
71
|
-
if ($li.classList.contains(
|
|
70
|
+
const getListItemLevel = ($li) => {
|
|
71
|
+
if ($li.classList.contains("l1")) {
|
|
72
72
|
return 1;
|
|
73
73
|
}
|
|
74
|
-
if ($li.classList.contains(
|
|
74
|
+
if ($li.classList.contains("l2")) {
|
|
75
75
|
return 2;
|
|
76
76
|
}
|
|
77
|
-
if ($li.classList.contains(
|
|
77
|
+
if ($li.classList.contains("l3")) {
|
|
78
78
|
return 3;
|
|
79
79
|
}
|
|
80
|
-
if ($li.classList.contains(
|
|
80
|
+
if ($li.classList.contains("l4")) {
|
|
81
81
|
return 4;
|
|
82
82
|
}
|
|
83
83
|
return 0;
|
|
84
84
|
};
|
|
85
|
-
const assertInline = $n => {
|
|
85
|
+
const assertInline = ($n) => {
|
|
86
86
|
assertNonNull($n);
|
|
87
87
|
if (!isInline($n)) {
|
|
88
88
|
throw new Error(`Node is not an Inline: ${$n?.nodeName}`);
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
|
-
const isTextContent = $n => {
|
|
91
|
+
const isTextContent = ($n) => {
|
|
92
92
|
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && (isInline($n) || isEmoji($n));
|
|
93
93
|
};
|
|
94
|
-
const assertTextContent = $n => {
|
|
94
|
+
const assertTextContent = ($n) => {
|
|
95
95
|
assertNonNull($n);
|
|
96
96
|
if (!isTextContent($n)) {
|
|
97
97
|
throw new Error(`Node is not TextContent: ${$n?.nodeName}`);
|
|
@@ -100,15 +100,15 @@ const assertTextContent = $n => {
|
|
|
100
100
|
const createTextNode = (data, doc) => {
|
|
101
101
|
return doc.createTextNode(data);
|
|
102
102
|
};
|
|
103
|
-
const createEmptyTextNode = doc => {
|
|
103
|
+
const createEmptyTextNode = (doc) => {
|
|
104
104
|
return createTextNode(TEXT_EMPTY_DATA, doc);
|
|
105
105
|
};
|
|
106
|
-
const createEmptyInline = doc => {
|
|
107
|
-
const res = doc.createElement(
|
|
106
|
+
const createEmptyInline = (doc) => {
|
|
107
|
+
const res = doc.createElement("SPAN");
|
|
108
108
|
res.append(createEmptyTextNode(doc));
|
|
109
109
|
return res;
|
|
110
110
|
};
|
|
111
|
-
const getParentInline = $n => {
|
|
111
|
+
const getParentInline = ($n) => {
|
|
112
112
|
const $p = $n.parentNode;
|
|
113
113
|
assertInline($p);
|
|
114
114
|
return $p;
|
|
@@ -118,22 +118,26 @@ const isInsideList = (isOrdered, $n) => {
|
|
|
118
118
|
return isOrdered ? isOrderedListItem($block) : isUnorderedListItem($block);
|
|
119
119
|
};
|
|
120
120
|
const isAllInsideList = (isOrdered, $a, $b) => {
|
|
121
|
-
return allSiblingsIncludingSatisfy(
|
|
121
|
+
return allSiblingsIncludingSatisfy(
|
|
122
|
+
getParentTextBlock($a),
|
|
123
|
+
getParentTextBlock($b),
|
|
124
|
+
isOrdered ? isOrderedListItem : isUnorderedListItem
|
|
125
|
+
);
|
|
122
126
|
};
|
|
123
127
|
const FORMAT_TYPE_TO_NAME = {
|
|
124
|
-
formatBold:
|
|
125
|
-
formatCodeTag:
|
|
126
|
-
formatItalic:
|
|
127
|
-
formatStrikeThrough:
|
|
128
|
+
formatBold: "b",
|
|
129
|
+
formatCodeTag: "c",
|
|
130
|
+
formatItalic: "i",
|
|
131
|
+
formatStrikeThrough: "s"
|
|
128
132
|
};
|
|
129
133
|
const isFormatName = ($n, inlineName) => {
|
|
130
134
|
return $n.classList.contains(inlineName);
|
|
131
135
|
};
|
|
132
|
-
const isFormatBold = $n => isFormatName($n,
|
|
133
|
-
const isFormatItalic = $n => isFormatName($n,
|
|
134
|
-
const isFormatStrikethrough = $n => isFormatName($n,
|
|
135
|
-
const isFormatCodetag = $n => isFormatName($n,
|
|
136
|
-
const isFormatLink = $n => isFormatName($n,
|
|
136
|
+
const isFormatBold = ($n) => isFormatName($n, "b");
|
|
137
|
+
const isFormatItalic = ($n) => isFormatName($n, "i");
|
|
138
|
+
const isFormatStrikethrough = ($n) => isFormatName($n, "s");
|
|
139
|
+
const isFormatCodetag = ($n) => isFormatName($n, "c");
|
|
140
|
+
const isFormatLink = ($n) => isFormatName($n, "l");
|
|
137
141
|
const isAllInsideFormatName = ($a, $b, formatName) => {
|
|
138
142
|
const aBlock = getParentTextBlock($a);
|
|
139
143
|
const bBlock = getParentTextBlock($b);
|
|
@@ -158,31 +162,31 @@ const isAllInsideFormatName = ($a, $b, formatName) => {
|
|
|
158
162
|
} while ($currentBlock !== null && $prevBlock !== bBlock);
|
|
159
163
|
return hasTextNodes;
|
|
160
164
|
};
|
|
161
|
-
const isAllInsideBold = ($a, $b) => isAllInsideFormatName($a, $b,
|
|
162
|
-
const isAllInsideItalic = ($a, $b) => isAllInsideFormatName($a, $b,
|
|
163
|
-
const isAllInsideStrikethrough = ($a, $b) => isAllInsideFormatName($a, $b,
|
|
164
|
-
const isAllInsideCodetag = ($a, $b) => isAllInsideFormatName($a, $b,
|
|
165
|
-
const isAllInsideLink = ($a, $b) => isAllInsideFormatName($a, $b,
|
|
166
|
-
const LINK_HREF_ATTR_NAME =
|
|
165
|
+
const isAllInsideBold = ($a, $b) => isAllInsideFormatName($a, $b, "b");
|
|
166
|
+
const isAllInsideItalic = ($a, $b) => isAllInsideFormatName($a, $b, "i");
|
|
167
|
+
const isAllInsideStrikethrough = ($a, $b) => isAllInsideFormatName($a, $b, "s");
|
|
168
|
+
const isAllInsideCodetag = ($a, $b) => isAllInsideFormatName($a, $b, "c");
|
|
169
|
+
const isAllInsideLink = ($a, $b) => isAllInsideFormatName($a, $b, "l");
|
|
170
|
+
const LINK_HREF_ATTR_NAME = "data-href";
|
|
167
171
|
const copyFormatName = ($source, $target) => {
|
|
168
172
|
const $inline = isTextNode($source) ? getParentInline($source) : $source;
|
|
169
173
|
$target.className = $inline.className;
|
|
170
174
|
if (isFormatLink($inline)) {
|
|
171
|
-
$target.setAttribute(LINK_HREF_ATTR_NAME, $inline.getAttribute(LINK_HREF_ATTR_NAME) ??
|
|
175
|
+
$target.setAttribute(LINK_HREF_ATTR_NAME, $inline.getAttribute(LINK_HREF_ATTR_NAME) ?? "");
|
|
172
176
|
}
|
|
173
177
|
};
|
|
174
178
|
const setInlineFormat = ($n, formatName, shouldEnable) => {
|
|
175
179
|
if (shouldEnable) {
|
|
176
|
-
if (formatName ===
|
|
177
|
-
$n.className =
|
|
180
|
+
if (formatName === "c" || isFormatName($n, "c")) {
|
|
181
|
+
$n.className = "";
|
|
178
182
|
}
|
|
179
|
-
if (formatName ===
|
|
180
|
-
$n.className =
|
|
183
|
+
if (formatName === "l" || isFormatName($n, "l")) {
|
|
184
|
+
$n.className = "";
|
|
181
185
|
$n.removeAttribute(LINK_HREF_ATTR_NAME);
|
|
182
186
|
}
|
|
183
187
|
$n.classList.add(formatName);
|
|
184
188
|
} else {
|
|
185
|
-
if (formatName ===
|
|
189
|
+
if (formatName === "l") {
|
|
186
190
|
$n.removeAttribute(LINK_HREF_ATTR_NAME);
|
|
187
191
|
}
|
|
188
192
|
$n.classList.remove(formatName);
|
|
@@ -217,8 +221,8 @@ const areSameInlineFormat = ($a, $b) => {
|
|
|
217
221
|
if ($a.classList.length !== $b.classList.length) {
|
|
218
222
|
return false;
|
|
219
223
|
}
|
|
220
|
-
if ($a.className ===
|
|
221
|
-
return $b.className ===
|
|
224
|
+
if ($a.className === "l") {
|
|
225
|
+
return $b.className === "l" && $a.getAttribute(LINK_HREF_ATTR_NAME) === $b.getAttribute(LINK_HREF_ATTR_NAME);
|
|
222
226
|
}
|
|
223
227
|
for (let i = 0; i < $a.classList.length; i++) {
|
|
224
228
|
if (!$b.classList.contains($a.classList[i])) {
|
|
@@ -228,7 +232,7 @@ const areSameInlineFormat = ($a, $b) => {
|
|
|
228
232
|
return true;
|
|
229
233
|
};
|
|
230
234
|
const createInlineWithText = (data, doc) => {
|
|
231
|
-
const $res = doc.createElement(
|
|
235
|
+
const $res = doc.createElement("SPAN");
|
|
232
236
|
$res.append(createTextNode(data, doc));
|
|
233
237
|
return $res;
|
|
234
238
|
};
|
|
@@ -240,25 +244,25 @@ const createInlineWithTextOfType = ($text, $source) => {
|
|
|
240
244
|
};
|
|
241
245
|
const createLink = (text, href, doc) => {
|
|
242
246
|
const $link = createInlineWithText(text, doc);
|
|
243
|
-
setInlineFormat($link,
|
|
247
|
+
setInlineFormat($link, "l", true);
|
|
244
248
|
$link.setAttribute(LINK_HREF_ATTR_NAME, href);
|
|
245
249
|
return $link;
|
|
246
250
|
};
|
|
247
|
-
const EMOJI_CHAR_ATTR_NAME =
|
|
251
|
+
const EMOJI_CHAR_ATTR_NAME = "data-char";
|
|
248
252
|
const createEmoji = (emojiChar, baseUrl, doc) => {
|
|
249
|
-
const $emoji = doc.createElement(
|
|
253
|
+
const $emoji = doc.createElement("img");
|
|
250
254
|
$emoji.setAttribute(EMOJI_CHAR_ATTR_NAME, emojiChar);
|
|
251
|
-
$emoji.setAttribute(
|
|
252
|
-
$emoji.classList.add(
|
|
255
|
+
$emoji.setAttribute("src", getEmojiUrl(baseUrl, emojiChar));
|
|
256
|
+
$emoji.classList.add("e");
|
|
253
257
|
return $emoji;
|
|
254
258
|
};
|
|
255
|
-
const PARAGRAPH_CLASSNAME =
|
|
256
|
-
const createActuallyEmptyParagraph = doc => {
|
|
257
|
-
const $p = doc.createElement(
|
|
259
|
+
const PARAGRAPH_CLASSNAME = "p";
|
|
260
|
+
const createActuallyEmptyParagraph = (doc) => {
|
|
261
|
+
const $p = doc.createElement("p");
|
|
258
262
|
$p.classList.add(PARAGRAPH_CLASSNAME);
|
|
259
263
|
return $p;
|
|
260
264
|
};
|
|
261
|
-
const createEmptyParagraph = doc => {
|
|
265
|
+
const createEmptyParagraph = (doc) => {
|
|
262
266
|
const res = createActuallyEmptyParagraph(doc);
|
|
263
267
|
res.append(createEmptyInline(doc));
|
|
264
268
|
return res;
|
|
@@ -271,17 +275,19 @@ const createParagraphWithChildren = (children, doc) => {
|
|
|
271
275
|
$p.append(...children);
|
|
272
276
|
return $p;
|
|
273
277
|
};
|
|
274
|
-
const ULI_CLASSNAME =
|
|
275
|
-
const OLI_CLASSNAME =
|
|
278
|
+
const ULI_CLASSNAME = "uli";
|
|
279
|
+
const OLI_CLASSNAME = "oli";
|
|
276
280
|
const createActuallyEmptyListItem = (isOrdered, listLevel, doc) => {
|
|
277
|
-
const $li = doc.createElement(
|
|
281
|
+
const $li = doc.createElement("p");
|
|
278
282
|
$li.className = isOrdered ? OLI_CLASSNAME : ULI_CLASSNAME;
|
|
279
283
|
setListItemLevel($li, listLevel);
|
|
280
284
|
return $li;
|
|
281
285
|
};
|
|
282
286
|
const createEmptyListItem = (isOrdered, listLevel, doc) => {
|
|
283
287
|
const $li = createActuallyEmptyListItem(isOrdered, listLevel, doc);
|
|
284
|
-
$li.append(
|
|
288
|
+
$li.append(
|
|
289
|
+
createEmptyInline(doc)
|
|
290
|
+
);
|
|
285
291
|
return $li;
|
|
286
292
|
};
|
|
287
293
|
const setListItemOrderedType = ($li, isOrdered) => {
|
|
@@ -304,7 +310,7 @@ const convertToListItem = ($p, isOrdered) => {
|
|
|
304
310
|
setListItemLevel($li, 0);
|
|
305
311
|
return $li;
|
|
306
312
|
};
|
|
307
|
-
const convertToParagraph = $li => {
|
|
313
|
+
const convertToParagraph = ($li) => {
|
|
308
314
|
removeListItemLevel($li);
|
|
309
315
|
$li.classList.remove(ULI_CLASSNAME, OLI_CLASSNAME);
|
|
310
316
|
$li.classList.add(PARAGRAPH_CLASSNAME);
|
|
@@ -319,7 +325,7 @@ const createListItemWithChildren = (children, isOrdered, listLevel, doc) => {
|
|
|
319
325
|
$li.append(...children);
|
|
320
326
|
return $li;
|
|
321
327
|
};
|
|
322
|
-
const getParentTextBlock = $node => {
|
|
328
|
+
const getParentTextBlock = ($node) => {
|
|
323
329
|
const $inline = isTextNode($node) ? getParentInline($node) : $node;
|
|
324
330
|
const $p = $inline.parentNode;
|
|
325
331
|
assertTextBlock($p);
|
|
@@ -331,22 +337,22 @@ const childIndexOf = ($parent, $child) => {
|
|
|
331
337
|
const getChildByIndex = ($parent, index) => {
|
|
332
338
|
const children = $parent.childNodes;
|
|
333
339
|
if (index < 0 || index >= children.length) {
|
|
334
|
-
throw new Error(
|
|
340
|
+
throw new Error("Invalid index");
|
|
335
341
|
}
|
|
336
342
|
const $ch = index >= children.length ? children[children.length - 1] : children[index];
|
|
337
343
|
return $ch;
|
|
338
344
|
};
|
|
339
|
-
const afterLastChildIndex = $parent => {
|
|
345
|
+
const afterLastChildIndex = ($parent) => {
|
|
340
346
|
return $parent.childNodes.length;
|
|
341
347
|
};
|
|
342
348
|
const isAfterLastChildIndex = ($parent, index) => {
|
|
343
349
|
return index >= $parent.childNodes.length;
|
|
344
350
|
};
|
|
345
|
-
const getLastChild = n => n.lastChild;
|
|
346
|
-
const getFirstChild = n => n.firstChild;
|
|
347
|
-
const getPrevSibling = n => n.previousSibling;
|
|
348
|
-
const getNextSibling = n => n.nextSibling;
|
|
349
|
-
const getSiblingTextBlock = getSibling => $node => {
|
|
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) => {
|
|
350
356
|
const $sib = getSibling($node);
|
|
351
357
|
if ($sib !== null) {
|
|
352
358
|
assertTextBlock($sib);
|
|
@@ -358,15 +364,6 @@ const getPrevSiblingTextBlock = getSiblingTextBlock(getPrevSibling);
|
|
|
358
364
|
const getNextSiblingTextBlock = getSiblingTextBlock(getNextSibling);
|
|
359
365
|
const getPrevSiblingTextContent = ($node, ensureValid) => {
|
|
360
366
|
const $sib = $node.previousSibling;
|
|
361
|
-
if ($sib === null && ensureValid === true) {
|
|
362
|
-
const $currentBlock = getParentTextBlock($node);
|
|
363
|
-
const $prevBlock = getPrevSiblingTextBlock($currentBlock);
|
|
364
|
-
if ($prevBlock === null) {
|
|
365
|
-
$currentBlock.prepend(createEmptyInline($node.ownerDocument));
|
|
366
|
-
return getFirstTextContent($currentBlock);
|
|
367
|
-
}
|
|
368
|
-
return getLastTextContent($prevBlock);
|
|
369
|
-
}
|
|
370
367
|
if ($sib !== null) {
|
|
371
368
|
assertTextContent($sib);
|
|
372
369
|
}
|
|
@@ -374,25 +371,13 @@ const getPrevSiblingTextContent = ($node, ensureValid) => {
|
|
|
374
371
|
};
|
|
375
372
|
const getNextSiblingTextContent = ($node, ensureValid) => {
|
|
376
373
|
const $sib = $node.nextSibling;
|
|
377
|
-
if ($sib === null && ensureValid === true) {
|
|
378
|
-
const $currentBlock = getParentTextBlock($node);
|
|
379
|
-
const $nextBlock = getNextSiblingTextBlock($currentBlock);
|
|
380
|
-
if ($nextBlock === null) {
|
|
381
|
-
$currentBlock.append(createEmptyInline($node.ownerDocument));
|
|
382
|
-
return getLastTextContent($currentBlock);
|
|
383
|
-
}
|
|
384
|
-
return getFirstTextContent($nextBlock);
|
|
385
|
-
}
|
|
386
374
|
if ($sib !== null) {
|
|
387
375
|
assertTextContent($sib);
|
|
388
376
|
}
|
|
389
377
|
return $sib;
|
|
390
378
|
};
|
|
391
|
-
const createCollapsedRange = cursor => {
|
|
392
|
-
const {
|
|
393
|
-
node,
|
|
394
|
-
offset
|
|
395
|
-
} = cursorToNodeWithOffset(cursor);
|
|
379
|
+
const createCollapsedRange = (cursor) => {
|
|
380
|
+
const { node, offset } = cursorToNodeWithOffset(cursor);
|
|
396
381
|
return {
|
|
397
382
|
startContainer: node,
|
|
398
383
|
startOffset: offset,
|
|
@@ -401,14 +386,8 @@ const createCollapsedRange = cursor => {
|
|
|
401
386
|
};
|
|
402
387
|
};
|
|
403
388
|
const createSpanningRange = (aCursor, bCursor) => {
|
|
404
|
-
const {
|
|
405
|
-
|
|
406
|
-
offset: startOffset
|
|
407
|
-
} = cursorToNodeWithOffset(aCursor);
|
|
408
|
-
const {
|
|
409
|
-
node: endContainer,
|
|
410
|
-
offset: endOffset
|
|
411
|
-
} = cursorToNodeWithOffset(bCursor);
|
|
389
|
+
const { node: startContainer, offset: startOffset } = cursorToNodeWithOffset(aCursor);
|
|
390
|
+
const { node: endContainer, offset: endOffset } = cursorToNodeWithOffset(bCursor);
|
|
412
391
|
return {
|
|
413
392
|
startContainer,
|
|
414
393
|
startOffset,
|
|
@@ -416,13 +395,13 @@ const createSpanningRange = (aCursor, bCursor) => {
|
|
|
416
395
|
endOffset
|
|
417
396
|
};
|
|
418
397
|
};
|
|
419
|
-
const removePrevSiblings = $node => {
|
|
398
|
+
const removePrevSiblings = ($node) => {
|
|
420
399
|
let $n;
|
|
421
400
|
while (($n = $node.previousSibling) !== null) {
|
|
422
401
|
$n.remove();
|
|
423
402
|
}
|
|
424
403
|
};
|
|
425
|
-
const removeNextSiblings = $node => {
|
|
404
|
+
const removeNextSiblings = ($node) => {
|
|
426
405
|
let $n;
|
|
427
406
|
while (($n = $node.nextSibling) !== null) {
|
|
428
407
|
$n.remove();
|
|
@@ -459,9 +438,11 @@ const removeNodesBetween = (aCursor, bCursor) => {
|
|
|
459
438
|
}
|
|
460
439
|
removeSiblingsBetween($cpChildA, $cpChildB);
|
|
461
440
|
};
|
|
462
|
-
const ensureCorrectTextBlockIfEmpty = $node => {
|
|
441
|
+
const ensureCorrectTextBlockIfEmpty = ($node) => {
|
|
463
442
|
if (!$node.hasChildNodes()) {
|
|
464
|
-
$node.append(
|
|
443
|
+
$node.append(
|
|
444
|
+
createEmptyInline($node.ownerDocument)
|
|
445
|
+
);
|
|
465
446
|
return;
|
|
466
447
|
}
|
|
467
448
|
const children = $node.childNodes;
|
|
@@ -475,15 +456,15 @@ const ensureCorrectTextBlockIfEmpty = $node => {
|
|
|
475
456
|
}
|
|
476
457
|
}
|
|
477
458
|
};
|
|
478
|
-
const getChildText = $node => {
|
|
459
|
+
const getChildText = ($node) => {
|
|
479
460
|
if ($node.childNodes.length !== 1) {
|
|
480
|
-
throw new Error(
|
|
461
|
+
throw new Error("Should have exact 1 child");
|
|
481
462
|
}
|
|
482
463
|
const $child = $node.firstChild;
|
|
483
464
|
assertTextNode($child);
|
|
484
465
|
return $child;
|
|
485
466
|
};
|
|
486
|
-
const getChildTextContent = getFirstOrLastChild => $node => {
|
|
467
|
+
const getChildTextContent = (getFirstOrLastChild) => ($node) => {
|
|
487
468
|
ensureCorrectTextBlockIfEmpty($node);
|
|
488
469
|
const $child = getFirstOrLastChild($node);
|
|
489
470
|
assertTextContent($child);
|
|
@@ -491,7 +472,7 @@ const getChildTextContent = getFirstOrLastChild => $node => {
|
|
|
491
472
|
};
|
|
492
473
|
const getLastTextContent = getChildTextContent(getLastChild);
|
|
493
474
|
const getFirstTextContent = getChildTextContent(getFirstChild);
|
|
494
|
-
const getFirstOrLastTextBlock = getFirstOrLastChild => $root => {
|
|
475
|
+
const getFirstOrLastTextBlock = (getFirstOrLastChild) => ($root) => {
|
|
495
476
|
let $lc = getFirstOrLastChild($root);
|
|
496
477
|
if ($lc === null) {
|
|
497
478
|
$lc = createEmptyParagraph($root.ownerDocument);
|
|
@@ -512,7 +493,7 @@ const mergeSiblingTextNodes = ($a, aCursor, bCursor) => {
|
|
|
512
493
|
const bContent = getTextValue($b);
|
|
513
494
|
const aContentLength = isEmptyText(aContent) ? 0 : aContent.length;
|
|
514
495
|
const bContentLength = isEmptyText(bContent) ? 0 : bContent.length;
|
|
515
|
-
let resultText = (isEmptyText(aContent) ?
|
|
496
|
+
let resultText = (isEmptyText(aContent) ? "" : aContent) + (isEmptyText(bContent) ? "" : bContent);
|
|
516
497
|
const isEmptyResultText = resultText.length === 0;
|
|
517
498
|
if (aCursor.$text === $a) {
|
|
518
499
|
aCursor.offset = isEmptyResultText ? 1 : aCursor.offset;
|
|
@@ -608,7 +589,7 @@ const mergeNextTextBlock = ($a, aCursor, bCursor) => {
|
|
|
608
589
|
};
|
|
609
590
|
const sliceChildren = ($parent, index) => {
|
|
610
591
|
if (index < 0) {
|
|
611
|
-
throw new Error(
|
|
592
|
+
throw new Error("Not found");
|
|
612
593
|
}
|
|
613
594
|
const children = Array.from($parent.childNodes);
|
|
614
595
|
if (index === 0) {
|
|
@@ -622,7 +603,10 @@ const splitTextBlock = ($a, childIndex) => {
|
|
|
622
603
|
ensureCorrectTextBlockIfEmpty($a);
|
|
623
604
|
ensureCorrectTextBlockIfEmpty($b);
|
|
624
605
|
$a.after($b);
|
|
625
|
-
return [
|
|
606
|
+
return [
|
|
607
|
+
$a,
|
|
608
|
+
$b
|
|
609
|
+
];
|
|
626
610
|
};
|
|
627
611
|
const splitTextNode = ($aText, offset) => {
|
|
628
612
|
const content = getTextValue($aText);
|
|
@@ -662,44 +646,42 @@ const splitTextNodeAndInsertEmptyInline = ($n, offset) => {
|
|
|
662
646
|
}
|
|
663
647
|
return $inline;
|
|
664
648
|
};
|
|
665
|
-
|
|
649
|
+
const formatInline = (formatType, range) => {
|
|
666
650
|
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
667
651
|
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
668
652
|
const formatName = FORMAT_TYPE_TO_NAME[formatType];
|
|
669
653
|
if (aCursor.$inline === bCursor.$inline && isTextNode(aCursor.$text)) {
|
|
670
|
-
const {
|
|
671
|
-
|
|
672
|
-
$inline,
|
|
673
|
-
offset: startOffset
|
|
674
|
-
} = aCursor;
|
|
675
|
-
const {
|
|
676
|
-
offset: endOffset
|
|
677
|
-
} = bCursor;
|
|
654
|
+
const { $text, $inline, offset: startOffset } = aCursor;
|
|
655
|
+
const { offset: endOffset } = bCursor;
|
|
678
656
|
if (isEmptyText($text.nodeValue)) {
|
|
679
657
|
assertInline($inline);
|
|
680
658
|
toggleInlineFormat($inline, formatName);
|
|
681
659
|
return {
|
|
682
660
|
prevent: true,
|
|
683
|
-
range: createCollapsedRange(
|
|
661
|
+
range: createCollapsedRange(
|
|
662
|
+
createEndCursorFromTextContent($inline)
|
|
663
|
+
)
|
|
684
664
|
};
|
|
685
665
|
}
|
|
686
666
|
if (startOffset === endOffset) {
|
|
687
|
-
const $
|
|
688
|
-
toggleInlineFormat($
|
|
667
|
+
const $newinline2 = splitTextNodeAndInsertEmptyInline($text, startOffset);
|
|
668
|
+
toggleInlineFormat($newinline2, formatName);
|
|
689
669
|
return {
|
|
690
670
|
prevent: true,
|
|
691
|
-
range: createCollapsedRange(
|
|
671
|
+
range: createCollapsedRange(
|
|
672
|
+
createEndCursorFromTextContent($newinline2)
|
|
673
|
+
)
|
|
692
674
|
};
|
|
693
675
|
}
|
|
694
676
|
const $newinline = sliceTextNode($text, startOffset, endOffset);
|
|
695
677
|
toggleInlineFormat($newinline, formatName);
|
|
696
|
-
const
|
|
697
|
-
const
|
|
698
|
-
mergeNextTextContentSibling($newinline,
|
|
699
|
-
mergePrevTextContentSibling($newinline,
|
|
678
|
+
const aTrackingCursor2 = createBeginCursorFromTextContent($newinline);
|
|
679
|
+
const bTrackingCursor2 = createEndCursorFromTextContent($newinline);
|
|
680
|
+
mergeNextTextContentSibling($newinline, aTrackingCursor2, bTrackingCursor2);
|
|
681
|
+
mergePrevTextContentSibling($newinline, aTrackingCursor2, bTrackingCursor2);
|
|
700
682
|
return {
|
|
701
683
|
prevent: true,
|
|
702
|
-
range: createSpanningRange(
|
|
684
|
+
range: createSpanningRange(aTrackingCursor2, bTrackingCursor2)
|
|
703
685
|
};
|
|
704
686
|
}
|
|
705
687
|
const areAllInline = isAllInsideFormatName(aCursor.$inline, bCursor.$inline, formatName);
|
|
@@ -742,7 +724,7 @@ const allSiblingsIncludingSatisfy = (aNode, bNode, func) => {
|
|
|
742
724
|
}
|
|
743
725
|
return true;
|
|
744
726
|
};
|
|
745
|
-
|
|
727
|
+
const formatIndent = (range) => {
|
|
746
728
|
if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && range.startOffset !== 0) {
|
|
747
729
|
return {
|
|
748
730
|
prevent: false
|
|
@@ -771,7 +753,7 @@ export const formatIndent = range => {
|
|
|
771
753
|
range
|
|
772
754
|
};
|
|
773
755
|
};
|
|
774
|
-
const ensureListItemLevelsAreCorrect = $li => {
|
|
756
|
+
const ensureListItemLevelsAreCorrect = ($li) => {
|
|
775
757
|
if ($li === null) {
|
|
776
758
|
return;
|
|
777
759
|
}
|
|
@@ -788,7 +770,7 @@ const ensureListItemLevelsAreCorrect = $li => {
|
|
|
788
770
|
$block = getNextSiblingTextBlock($block);
|
|
789
771
|
}
|
|
790
772
|
};
|
|
791
|
-
|
|
773
|
+
const formatOutdent = (range) => {
|
|
792
774
|
if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && range.startOffset !== 0) {
|
|
793
775
|
return {
|
|
794
776
|
prevent: false
|
|
@@ -816,7 +798,7 @@ export const formatOutdent = range => {
|
|
|
816
798
|
range
|
|
817
799
|
};
|
|
818
800
|
};
|
|
819
|
-
|
|
801
|
+
const formatList = (isOrdered, range) => {
|
|
820
802
|
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
821
803
|
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
822
804
|
const aBlock = getParentTextBlock(aCursor.$inline);
|
|
@@ -825,11 +807,11 @@ export const formatList = (isOrdered, range) => {
|
|
|
825
807
|
if (isInsideSameListType) {
|
|
826
808
|
assertListItem(aBlock);
|
|
827
809
|
assertListItem(bBlock);
|
|
828
|
-
const $
|
|
829
|
-
let $
|
|
830
|
-
while ($
|
|
831
|
-
convertToParagraph($
|
|
832
|
-
$
|
|
810
|
+
const $iterateUpToNode2 = getNextSiblingTextBlock(bBlock);
|
|
811
|
+
let $block2 = aBlock;
|
|
812
|
+
while ($block2 !== null && $block2 !== $iterateUpToNode2) {
|
|
813
|
+
convertToParagraph($block2);
|
|
814
|
+
$block2 = getNextSiblingTextBlock($block2);
|
|
833
815
|
}
|
|
834
816
|
return {
|
|
835
817
|
prevent: true,
|
|
@@ -859,7 +841,7 @@ const createCursorFromTextNode = (node, offset) => {
|
|
|
859
841
|
offset: Math.min(node.length, offset)
|
|
860
842
|
};
|
|
861
843
|
};
|
|
862
|
-
const createBeginCursorFromTextContent = node => {
|
|
844
|
+
const createBeginCursorFromTextContent = (node) => {
|
|
863
845
|
if (isInline(node)) {
|
|
864
846
|
const $text = getChildText(node);
|
|
865
847
|
const content = getTextValue($text);
|
|
@@ -875,7 +857,7 @@ const createBeginCursorFromTextContent = node => {
|
|
|
875
857
|
offset: 0
|
|
876
858
|
};
|
|
877
859
|
};
|
|
878
|
-
const createEndCursorFromTextContent = node => {
|
|
860
|
+
const createEndCursorFromTextContent = (node) => {
|
|
879
861
|
if (isInline(node)) {
|
|
880
862
|
const $text = getChildText(node);
|
|
881
863
|
return {
|
|
@@ -904,7 +886,9 @@ const createIncomingCursorFromNodeWithOffset = (node, offset) => {
|
|
|
904
886
|
}
|
|
905
887
|
if (isTextBlock(node)) {
|
|
906
888
|
if (isAfterLastChildIndex(node, offset)) {
|
|
907
|
-
return createEndCursorFromTextContent(
|
|
889
|
+
return createEndCursorFromTextContent(
|
|
890
|
+
getLastTextContent(node)
|
|
891
|
+
);
|
|
908
892
|
}
|
|
909
893
|
return createIncomingCursorFromNodeWithOffset(getChildByIndex(node, offset), 0);
|
|
910
894
|
}
|
|
@@ -922,15 +906,9 @@ const createIncomingCursorFromNodeWithOffset = (node, offset) => {
|
|
|
922
906
|
}
|
|
923
907
|
return createIncomingCursorFromNodeWithOffset(getChildByIndex(node, offset), 0);
|
|
924
908
|
}
|
|
925
|
-
throw new Error(
|
|
909
|
+
throw new Error("Should not happen");
|
|
926
910
|
};
|
|
927
|
-
const cursorToNodeWithOffset =
|
|
928
|
-
let {
|
|
929
|
-
$text,
|
|
930
|
-
$inline,
|
|
931
|
-
offset,
|
|
932
|
-
isAfterInline
|
|
933
|
-
} = _ref;
|
|
911
|
+
const cursorToNodeWithOffset = ({ $text, $inline, offset, isAfterInline }) => {
|
|
934
912
|
if (isTextNode($text)) {
|
|
935
913
|
return {
|
|
936
914
|
node: $text,
|
|
@@ -944,21 +922,15 @@ const cursorToNodeWithOffset = _ref => {
|
|
|
944
922
|
offset: childIndex
|
|
945
923
|
};
|
|
946
924
|
};
|
|
947
|
-
const removeContentInRange = range => {
|
|
925
|
+
const removeContentInRange = (range) => {
|
|
948
926
|
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
949
927
|
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
950
928
|
if (aCursor.$inline === bCursor.$inline && aCursor.offset === bCursor.offset && aCursor.isAfterInline === bCursor.isAfterInline) {
|
|
951
929
|
return aCursor;
|
|
952
930
|
}
|
|
953
931
|
if (aCursor.$text === bCursor.$text && isTextNode(aCursor.$text)) {
|
|
954
|
-
const {
|
|
955
|
-
|
|
956
|
-
$inline,
|
|
957
|
-
offset: startOffset
|
|
958
|
-
} = aCursor;
|
|
959
|
-
const {
|
|
960
|
-
offset: endOffset
|
|
961
|
-
} = bCursor;
|
|
932
|
+
const { $text, $inline, offset: startOffset } = aCursor;
|
|
933
|
+
const { offset: endOffset } = bCursor;
|
|
962
934
|
const content = getTextValue($text);
|
|
963
935
|
const nextContent = content.substring(0, startOffset) + content.substring(endOffset);
|
|
964
936
|
$text.nodeValue = nextContent;
|
|
@@ -1010,13 +982,8 @@ const removeContentInRange = range => {
|
|
|
1010
982
|
}
|
|
1011
983
|
return trackingCursor;
|
|
1012
984
|
};
|
|
1013
|
-
|
|
1014
|
-
const {
|
|
1015
|
-
startContainer,
|
|
1016
|
-
endContainer,
|
|
1017
|
-
startOffset,
|
|
1018
|
-
endOffset
|
|
1019
|
-
} = range;
|
|
985
|
+
const deleteContentBackward = ($root, range) => {
|
|
986
|
+
const { startContainer, endContainer, startOffset, endOffset } = range;
|
|
1020
987
|
if (startContainer === endContainer && startOffset + 1 === endOffset && isTextNode(startContainer)) {
|
|
1021
988
|
if (startContainer.length > 1) {
|
|
1022
989
|
return DEFAULT_ACTION_RESULT;
|
|
@@ -1066,17 +1033,14 @@ export const deleteContentBackward = ($root, range) => {
|
|
|
1066
1033
|
}
|
|
1067
1034
|
return {
|
|
1068
1035
|
prevent: true,
|
|
1069
|
-
range: createCollapsedRange(
|
|
1036
|
+
range: createCollapsedRange(
|
|
1037
|
+
removeContentInRange(range)
|
|
1038
|
+
)
|
|
1070
1039
|
};
|
|
1071
1040
|
};
|
|
1072
|
-
|
|
1041
|
+
const insertLink = ($root, text, href, range) => {
|
|
1073
1042
|
const cursor = removeContentInRange(range);
|
|
1074
|
-
const {
|
|
1075
|
-
$text,
|
|
1076
|
-
$inline,
|
|
1077
|
-
offset,
|
|
1078
|
-
isAfterInline: isAfterLastChild
|
|
1079
|
-
} = cursor;
|
|
1043
|
+
const { $text, $inline, offset, isAfterInline: isAfterLastChild } = cursor;
|
|
1080
1044
|
const $link = createLink(text, href, $root.ownerDocument);
|
|
1081
1045
|
if (isTextNode($text)) {
|
|
1082
1046
|
if (isEmptyText($text.nodeValue)) {
|
|
@@ -1097,24 +1061,23 @@ export const insertLink = ($root, text, href, range) => {
|
|
|
1097
1061
|
}
|
|
1098
1062
|
return {
|
|
1099
1063
|
prevent: true,
|
|
1100
|
-
range: createCollapsedRange(
|
|
1064
|
+
range: createCollapsedRange(
|
|
1065
|
+
createEndCursorFromTextContent($link)
|
|
1066
|
+
)
|
|
1101
1067
|
};
|
|
1102
1068
|
};
|
|
1103
|
-
|
|
1069
|
+
const insertLineBreak = (range) => {
|
|
1104
1070
|
const cursor = removeContentInRange(range);
|
|
1105
|
-
const {
|
|
1106
|
-
$text,
|
|
1107
|
-
$inline,
|
|
1108
|
-
offset,
|
|
1109
|
-
isAfterInline: isAfterLastChild
|
|
1110
|
-
} = cursor;
|
|
1071
|
+
const { $text, $inline, offset, isAfterInline: isAfterLastChild } = cursor;
|
|
1111
1072
|
const $block = getParentTextBlock($inline);
|
|
1112
1073
|
if (isListItem($block)) {
|
|
1113
1074
|
if (isEmptyTextBlock($block)) {
|
|
1114
1075
|
convertToParagraph($block);
|
|
1115
1076
|
return {
|
|
1116
1077
|
prevent: true,
|
|
1117
|
-
range: createCollapsedRange(
|
|
1078
|
+
range: createCollapsedRange(
|
|
1079
|
+
createEndCursorFromTextContent(getLastTextContent($block))
|
|
1080
|
+
)
|
|
1118
1081
|
};
|
|
1119
1082
|
}
|
|
1120
1083
|
}
|
|
@@ -1128,17 +1091,14 @@ export const insertLineBreak = range => {
|
|
|
1128
1091
|
const [_, $bBlock] = splitTextBlock($block, splitIndex);
|
|
1129
1092
|
return {
|
|
1130
1093
|
prevent: true,
|
|
1131
|
-
range: createCollapsedRange(
|
|
1094
|
+
range: createCollapsedRange(
|
|
1095
|
+
createBeginCursorFromTextContent(getFirstTextContent($bBlock))
|
|
1096
|
+
)
|
|
1132
1097
|
};
|
|
1133
1098
|
};
|
|
1134
1099
|
const insertEmoji = ($root, emojiChar, range) => {
|
|
1135
1100
|
const cursor = removeContentInRange(range);
|
|
1136
|
-
const {
|
|
1137
|
-
$text,
|
|
1138
|
-
$inline,
|
|
1139
|
-
offset,
|
|
1140
|
-
isAfterInline
|
|
1141
|
-
} = cursor;
|
|
1101
|
+
const { $text, $inline, offset, isAfterInline } = cursor;
|
|
1142
1102
|
const baseUrl = getEmojiBaseUrl($root);
|
|
1143
1103
|
const $emoji = createEmoji(emojiChar, baseUrl, $root.ownerDocument);
|
|
1144
1104
|
if (isTextNode($text)) {
|
|
@@ -1160,16 +1120,22 @@ const insertEmoji = ($root, emojiChar, range) => {
|
|
|
1160
1120
|
}
|
|
1161
1121
|
return {
|
|
1162
1122
|
prevent: true,
|
|
1163
|
-
range: createCollapsedRange(
|
|
1123
|
+
range: createCollapsedRange(
|
|
1124
|
+
createEndCursorFromTextContent($emoji)
|
|
1125
|
+
)
|
|
1164
1126
|
};
|
|
1165
1127
|
};
|
|
1166
|
-
|
|
1128
|
+
const insertText = ($root, data, range) => {
|
|
1167
1129
|
if (data !== null && isEmojiString(data)) {
|
|
1168
1130
|
return insertEmoji($root, data, range);
|
|
1169
1131
|
}
|
|
1170
|
-
if (
|
|
1171
|
-
|
|
1172
|
-
|
|
1132
|
+
if (
|
|
1133
|
+
// Is collapsed range
|
|
1134
|
+
range.startContainer === range.endContainer && range.startOffset === range.endOffset && // Is non-empty text node
|
|
1135
|
+
isTextNode(range.startContainer) && !isEmptyText(range.startContainer.nodeValue)
|
|
1136
|
+
) {
|
|
1137
|
+
const $inline2 = getParentInline(range.startContainer);
|
|
1138
|
+
const isHotTextWhitespace = range.startOffset === range.startContainer.length && data === TEXT_WHITESPACE && (isFormatCodetag($inline2) || isFormatLink($inline2));
|
|
1173
1139
|
if (!isHotTextWhitespace) {
|
|
1174
1140
|
return DEFAULT_ACTION_RESULT;
|
|
1175
1141
|
}
|
|
@@ -1181,12 +1147,7 @@ export const insertText = ($root, data, range) => {
|
|
|
1181
1147
|
range: createCollapsedRange(cursor)
|
|
1182
1148
|
};
|
|
1183
1149
|
}
|
|
1184
|
-
const {
|
|
1185
|
-
$text,
|
|
1186
|
-
$inline,
|
|
1187
|
-
offset,
|
|
1188
|
-
isAfterInline
|
|
1189
|
-
} = cursor;
|
|
1150
|
+
const { $text, $inline, offset, isAfterInline } = cursor;
|
|
1190
1151
|
if ($text === null && isEmoji($inline)) {
|
|
1191
1152
|
const $newInline = createInlineWithText(data, $root.ownerDocument);
|
|
1192
1153
|
if (isAfterInline === true) {
|
|
@@ -1196,7 +1157,9 @@ export const insertText = ($root, data, range) => {
|
|
|
1196
1157
|
}
|
|
1197
1158
|
return {
|
|
1198
1159
|
prevent: true,
|
|
1199
|
-
range: createCollapsedRange(
|
|
1160
|
+
range: createCollapsedRange(
|
|
1161
|
+
createEndCursorFromTextContent($newInline)
|
|
1162
|
+
)
|
|
1200
1163
|
};
|
|
1201
1164
|
}
|
|
1202
1165
|
if (isTextNode($text)) {
|
|
@@ -1205,7 +1168,9 @@ export const insertText = ($root, data, range) => {
|
|
|
1205
1168
|
$text.nodeValue = data;
|
|
1206
1169
|
return {
|
|
1207
1170
|
prevent: true,
|
|
1208
|
-
range: createCollapsedRange(
|
|
1171
|
+
range: createCollapsedRange(
|
|
1172
|
+
createCursorFromTextNode($text, data.length)
|
|
1173
|
+
)
|
|
1209
1174
|
};
|
|
1210
1175
|
}
|
|
1211
1176
|
if (offset === $text.length && data === TEXT_WHITESPACE) {
|
|
@@ -1214,7 +1179,9 @@ export const insertText = ($root, data, range) => {
|
|
|
1214
1179
|
$inline.after($newinline);
|
|
1215
1180
|
return {
|
|
1216
1181
|
prevent: true,
|
|
1217
|
-
range: createCollapsedRange(
|
|
1182
|
+
range: createCollapsedRange(
|
|
1183
|
+
createEndCursorFromTextContent($newinline)
|
|
1184
|
+
)
|
|
1218
1185
|
};
|
|
1219
1186
|
}
|
|
1220
1187
|
}
|
|
@@ -1222,7 +1189,9 @@ export const insertText = ($root, data, range) => {
|
|
|
1222
1189
|
$text.nodeValue = content.substring(0, offset) + data + content.substring(offset);
|
|
1223
1190
|
return {
|
|
1224
1191
|
prevent: true,
|
|
1225
|
-
range: createCollapsedRange(
|
|
1192
|
+
range: createCollapsedRange(
|
|
1193
|
+
createCursorFromTextNode($text, offset + data.length)
|
|
1194
|
+
)
|
|
1226
1195
|
};
|
|
1227
1196
|
}
|
|
1228
1197
|
return {
|
|
@@ -1230,14 +1199,9 @@ export const insertText = ($root, data, range) => {
|
|
|
1230
1199
|
range: createCollapsedRange(cursor)
|
|
1231
1200
|
};
|
|
1232
1201
|
};
|
|
1233
|
-
|
|
1202
|
+
const insertFromPaste = (data, range, visitor) => {
|
|
1234
1203
|
const cursor = removeContentInRange(range);
|
|
1235
|
-
const {
|
|
1236
|
-
$text,
|
|
1237
|
-
$inline,
|
|
1238
|
-
offset,
|
|
1239
|
-
isAfterInline
|
|
1240
|
-
} = cursor;
|
|
1204
|
+
const { $text, $inline, offset, isAfterInline } = cursor;
|
|
1241
1205
|
const $mdFragment = parseMarkdown(data, visitor);
|
|
1242
1206
|
if ($mdFragment.childNodes.length === 0) {
|
|
1243
1207
|
return {
|
|
@@ -1247,7 +1211,7 @@ export const insertFromPaste = (data, range, visitor) => {
|
|
|
1247
1211
|
}
|
|
1248
1212
|
const shouldSpreadNodesIntoBlock = $mdFragment.childNodes.length === 1;
|
|
1249
1213
|
if (shouldSpreadNodesIntoBlock) {
|
|
1250
|
-
const $
|
|
1214
|
+
const $block2 = getParentTextBlock($inline);
|
|
1251
1215
|
const $fragment = document.createDocumentFragment();
|
|
1252
1216
|
$fragment.append(...Array.from($mdFragment.childNodes[0].childNodes));
|
|
1253
1217
|
const $pasteLastChild = $fragment.lastChild;
|
|
@@ -1256,7 +1220,7 @@ export const insertFromPaste = (data, range, visitor) => {
|
|
|
1256
1220
|
}
|
|
1257
1221
|
if (isTextNode($text)) {
|
|
1258
1222
|
if (isEmptyText($text.nodeValue)) {
|
|
1259
|
-
$
|
|
1223
|
+
$block2.replaceChild($fragment, $inline);
|
|
1260
1224
|
} else {
|
|
1261
1225
|
const [$before, $after] = splitTextNode($text, offset);
|
|
1262
1226
|
if ($before === null) {
|
|
@@ -1273,7 +1237,9 @@ export const insertFromPaste = (data, range, visitor) => {
|
|
|
1273
1237
|
}
|
|
1274
1238
|
return {
|
|
1275
1239
|
prevent: true,
|
|
1276
|
-
range: createCollapsedRange(
|
|
1240
|
+
range: createCollapsedRange(
|
|
1241
|
+
createEndCursorFromTextContent($pasteLastChild ?? getLastTextContent($block2))
|
|
1242
|
+
)
|
|
1277
1243
|
};
|
|
1278
1244
|
}
|
|
1279
1245
|
const $block = getParentTextBlock($inline);
|
|
@@ -1304,39 +1270,46 @@ export const insertFromPaste = (data, range, visitor) => {
|
|
|
1304
1270
|
}
|
|
1305
1271
|
return {
|
|
1306
1272
|
prevent: true,
|
|
1307
|
-
range: createCollapsedRange(
|
|
1273
|
+
range: createCollapsedRange(
|
|
1274
|
+
createEndCursorFromTextContent(
|
|
1275
|
+
getLastTextContent($lastBlock)
|
|
1276
|
+
)
|
|
1277
|
+
)
|
|
1308
1278
|
};
|
|
1309
1279
|
};
|
|
1310
1280
|
const DEFAULT_ACTION_RESULT = {
|
|
1311
1281
|
prevent: false
|
|
1312
1282
|
};
|
|
1313
|
-
|
|
1283
|
+
const handleEmojiMousedown = ($n) => {
|
|
1314
1284
|
if (isEmoji($n)) {
|
|
1315
1285
|
return {
|
|
1316
1286
|
prevent: true,
|
|
1317
|
-
range: createCollapsedRange(
|
|
1287
|
+
range: createCollapsedRange(
|
|
1288
|
+
createEndCursorFromTextContent($n)
|
|
1289
|
+
)
|
|
1318
1290
|
};
|
|
1319
1291
|
}
|
|
1320
1292
|
return DEFAULT_ACTION_RESULT;
|
|
1321
1293
|
};
|
|
1322
|
-
|
|
1294
|
+
const getBeginRange = ($root) => {
|
|
1323
1295
|
const $block = getFirstTextBlock($root);
|
|
1324
1296
|
const $inline = getFirstTextContent($block);
|
|
1325
|
-
return createCollapsedRange(
|
|
1297
|
+
return createCollapsedRange(
|
|
1298
|
+
createBeginCursorFromTextContent($inline)
|
|
1299
|
+
);
|
|
1326
1300
|
};
|
|
1327
|
-
|
|
1301
|
+
const getEndRange = ($root) => {
|
|
1328
1302
|
const $block = getLastTextBlock($root);
|
|
1329
1303
|
const $inline = getLastTextContent($block);
|
|
1330
|
-
return createCollapsedRange(
|
|
1304
|
+
return createCollapsedRange(
|
|
1305
|
+
createEndCursorFromTextContent($inline)
|
|
1306
|
+
);
|
|
1331
1307
|
};
|
|
1332
|
-
|
|
1308
|
+
const getSelectionInfo = (range) => {
|
|
1333
1309
|
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
1334
1310
|
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
1335
1311
|
if (aCursor.$inline === bCursor.$inline) {
|
|
1336
|
-
const {
|
|
1337
|
-
$text,
|
|
1338
|
-
$inline
|
|
1339
|
-
} = aCursor;
|
|
1312
|
+
const { $text, $inline } = aCursor;
|
|
1340
1313
|
if ($text !== null || isInline($inline)) {
|
|
1341
1314
|
assertInline($inline);
|
|
1342
1315
|
return {
|
|
@@ -1369,19 +1342,19 @@ export const getSelectionInfo = range => {
|
|
|
1369
1342
|
ulist: isAllInsideList(false, aCursor.$inline, bCursor.$inline)
|
|
1370
1343
|
};
|
|
1371
1344
|
};
|
|
1372
|
-
|
|
1345
|
+
const isSelectionEqual = (a, b) => {
|
|
1373
1346
|
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;
|
|
1374
1347
|
};
|
|
1375
|
-
const isEmptyTextBlock = $block => {
|
|
1348
|
+
const isEmptyTextBlock = ($block) => {
|
|
1376
1349
|
const blockChildren = $block.childNodes;
|
|
1377
1350
|
if (blockChildren.length > 1) {
|
|
1378
1351
|
return false;
|
|
1379
1352
|
}
|
|
1380
1353
|
const $inline = blockChildren[0];
|
|
1381
|
-
const
|
|
1382
|
-
return
|
|
1354
|
+
const isEmptyText2 = isInline($inline) && !isFormatCodetag($inline) && isEmptyTextNode(getChildText($inline));
|
|
1355
|
+
return isEmptyText2;
|
|
1383
1356
|
};
|
|
1384
|
-
|
|
1357
|
+
const isEditorEmpty = ($root) => {
|
|
1385
1358
|
const rootChildren = $root.childNodes;
|
|
1386
1359
|
if (rootChildren.length > 1) {
|
|
1387
1360
|
return false;
|
|
@@ -1390,19 +1363,16 @@ export const isEditorEmpty = $root => {
|
|
|
1390
1363
|
assertTextBlock($block);
|
|
1391
1364
|
return isEmptyTextBlock($block);
|
|
1392
1365
|
};
|
|
1393
|
-
const serializeDescriptorReducer = range => (state, $n) => {
|
|
1366
|
+
const serializeDescriptorReducer = (range) => (state, $n) => {
|
|
1394
1367
|
if (isEmoji($n)) {
|
|
1395
|
-
const
|
|
1396
|
-
if (
|
|
1397
|
-
state.push({
|
|
1398
|
-
isEmoji: true,
|
|
1399
|
-
text
|
|
1400
|
-
});
|
|
1368
|
+
const text2 = $n.getAttribute(EMOJI_CHAR_ATTR_NAME) ?? "";
|
|
1369
|
+
if (text2.length > 0) {
|
|
1370
|
+
state.push({ isEmoji: true, text: text2 });
|
|
1401
1371
|
}
|
|
1402
1372
|
return state;
|
|
1403
1373
|
}
|
|
1404
1374
|
let text = getTextValue(getChildText($n));
|
|
1405
|
-
let trailingSpaces =
|
|
1375
|
+
let trailingSpaces = "";
|
|
1406
1376
|
if (range !== null) {
|
|
1407
1377
|
const [aCursor, bCursor] = range;
|
|
1408
1378
|
const isACursorPointingHere = aCursor.$inline === $n;
|
|
@@ -1419,34 +1389,21 @@ const serializeDescriptorReducer = range => (state, $n) => {
|
|
|
1419
1389
|
return state;
|
|
1420
1390
|
}
|
|
1421
1391
|
if (isFormatCodetag($n)) {
|
|
1422
|
-
state.push({
|
|
1423
|
-
isCodetag: true,
|
|
1424
|
-
text
|
|
1425
|
-
});
|
|
1392
|
+
state.push({ isCodetag: true, text });
|
|
1426
1393
|
return state;
|
|
1427
1394
|
}
|
|
1428
1395
|
if (isFormatLink($n)) {
|
|
1429
|
-
const href = $n.getAttribute(LINK_HREF_ATTR_NAME) ??
|
|
1430
|
-
state.push({
|
|
1431
|
-
isLink: true,
|
|
1432
|
-
text,
|
|
1433
|
-
href
|
|
1434
|
-
});
|
|
1396
|
+
const href = $n.getAttribute(LINK_HREF_ATTR_NAME) ?? "#";
|
|
1397
|
+
state.push({ isLink: true, text, href });
|
|
1435
1398
|
return state;
|
|
1436
1399
|
}
|
|
1437
1400
|
const leadingNonSpaceIndex = text.search(/\S/);
|
|
1438
1401
|
if (leadingNonSpaceIndex < 0) {
|
|
1439
|
-
state.push({
|
|
1440
|
-
isWhitespace: true,
|
|
1441
|
-
text
|
|
1442
|
-
});
|
|
1402
|
+
state.push({ isWhitespace: true, text });
|
|
1443
1403
|
return state;
|
|
1444
1404
|
}
|
|
1445
1405
|
if (leadingNonSpaceIndex > 0) {
|
|
1446
|
-
state.push({
|
|
1447
|
-
isWhitespace: true,
|
|
1448
|
-
text: text.substring(0, leadingNonSpaceIndex)
|
|
1449
|
-
});
|
|
1406
|
+
state.push({ isWhitespace: true, text: text.substring(0, leadingNonSpaceIndex) });
|
|
1450
1407
|
text = text.substring(leadingNonSpaceIndex);
|
|
1451
1408
|
}
|
|
1452
1409
|
const trailingSpaceIndex = text.search(/\s+$/);
|
|
@@ -1461,30 +1418,25 @@ const serializeDescriptorReducer = range => (state, $n) => {
|
|
|
1461
1418
|
text
|
|
1462
1419
|
});
|
|
1463
1420
|
if (trailingSpaces.length > 0) {
|
|
1464
|
-
state.push({
|
|
1465
|
-
isWhitespace: true,
|
|
1466
|
-
text: trailingSpaces
|
|
1467
|
-
});
|
|
1421
|
+
state.push({ isWhitespace: true, text: trailingSpaces });
|
|
1468
1422
|
}
|
|
1469
1423
|
return state;
|
|
1470
1424
|
};
|
|
1471
|
-
const MD_STRIKE_TOKEN =
|
|
1472
|
-
const MD_EM3_STAR_TOKEN =
|
|
1473
|
-
const MD_EM2_STAR_TOKEN =
|
|
1474
|
-
const MD_EM1_STAR_TOKEN =
|
|
1475
|
-
const MD_EM3_UNDERSCORE_TOKEN =
|
|
1476
|
-
const MD_EM2_UNDERSCORE_TOKEN =
|
|
1477
|
-
const MD_EM1_UNDERSCORE_TOKEN =
|
|
1478
|
-
const MD_LINEBREAK_TOKEN =
|
|
1479
|
-
const MD_CODETAG_TOKEN =
|
|
1480
|
-
const MD_ULISTITEM_TOKEN =
|
|
1481
|
-
const MD_OLISTITEM_TOKEN =
|
|
1482
|
-
const MD_LISTITEM_JOIN =
|
|
1483
|
-
const MD_PARAGRAPH_JOIN =
|
|
1425
|
+
const MD_STRIKE_TOKEN = "~~";
|
|
1426
|
+
const MD_EM3_STAR_TOKEN = "***";
|
|
1427
|
+
const MD_EM2_STAR_TOKEN = "**";
|
|
1428
|
+
const MD_EM1_STAR_TOKEN = "*";
|
|
1429
|
+
const MD_EM3_UNDERSCORE_TOKEN = "___";
|
|
1430
|
+
const MD_EM2_UNDERSCORE_TOKEN = "__";
|
|
1431
|
+
const MD_EM1_UNDERSCORE_TOKEN = "_";
|
|
1432
|
+
const MD_LINEBREAK_TOKEN = " \n";
|
|
1433
|
+
const MD_CODETAG_TOKEN = "`";
|
|
1434
|
+
const MD_ULISTITEM_TOKEN = "*";
|
|
1435
|
+
const MD_OLISTITEM_TOKEN = "1.";
|
|
1436
|
+
const MD_LISTITEM_JOIN = "\n";
|
|
1437
|
+
const MD_PARAGRAPH_JOIN = "\n\n";
|
|
1484
1438
|
const serializeTextReducer = (state, desc, i, descArray) => {
|
|
1485
|
-
const {
|
|
1486
|
-
chunks
|
|
1487
|
-
} = state;
|
|
1439
|
+
const { chunks } = state;
|
|
1488
1440
|
if (desc.isLink === true) {
|
|
1489
1441
|
chunks.push(`[${desc.text}](${desc.href})`);
|
|
1490
1442
|
return state;
|
|
@@ -1504,11 +1456,7 @@ const serializeTextReducer = (state, desc, i, descArray) => {
|
|
|
1504
1456
|
const prev = i === 0 ? null : descArray[i - 1];
|
|
1505
1457
|
const next = i >= descArray.length - 1 ? null : descArray[i + 1];
|
|
1506
1458
|
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);
|
|
1507
|
-
const {
|
|
1508
|
-
isBold,
|
|
1509
|
-
isItalic,
|
|
1510
|
-
isStrikethrough
|
|
1511
|
-
} = desc;
|
|
1459
|
+
const { isBold, isItalic, isStrikethrough } = desc;
|
|
1512
1460
|
if (shouldUseUnderscores) {
|
|
1513
1461
|
state.lastUnderscoreIndex = i;
|
|
1514
1462
|
}
|
|
@@ -1547,16 +1495,26 @@ const serializeTextBlock = ($n, range) => {
|
|
|
1547
1495
|
} else {
|
|
1548
1496
|
children = Array.from($n.childNodes);
|
|
1549
1497
|
}
|
|
1550
|
-
const result = children.reduce(
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1498
|
+
const result = children.reduce(
|
|
1499
|
+
serializeDescriptorReducer(range),
|
|
1500
|
+
[]
|
|
1501
|
+
).reduce(
|
|
1502
|
+
serializeTextReducer,
|
|
1503
|
+
{
|
|
1504
|
+
lastUnderscoreIndex: 0,
|
|
1505
|
+
chunks: []
|
|
1506
|
+
}
|
|
1507
|
+
);
|
|
1508
|
+
return result.chunks.join("");
|
|
1555
1509
|
};
|
|
1556
1510
|
const serializeListItemIndent = (level, isOrderedStack) => {
|
|
1557
|
-
let res =
|
|
1511
|
+
let res = "";
|
|
1558
1512
|
for (let i = 0; i < level; i++) {
|
|
1559
|
-
res = res.concat(
|
|
1513
|
+
res = res.concat(
|
|
1514
|
+
isOrderedStack[i] ? " " : " ",
|
|
1515
|
+
// MD_ULISTITEM_TOKEN.length
|
|
1516
|
+
" "
|
|
1517
|
+
);
|
|
1560
1518
|
}
|
|
1561
1519
|
return res;
|
|
1562
1520
|
};
|
|
@@ -1585,15 +1543,19 @@ const serializeRoot = ($root, range) => {
|
|
|
1585
1543
|
const paragraphChunks = [];
|
|
1586
1544
|
const flushListChunks = () => {
|
|
1587
1545
|
if (listChunks.length > 0) {
|
|
1588
|
-
chunks.push(
|
|
1546
|
+
chunks.push(
|
|
1547
|
+
listChunks.join(MD_LISTITEM_JOIN)
|
|
1548
|
+
);
|
|
1589
1549
|
listChunks.length = 0;
|
|
1590
1550
|
}
|
|
1591
1551
|
};
|
|
1592
1552
|
const flushParagraphChunks = () => {
|
|
1593
1553
|
if (paragraphChunks.length > 0) {
|
|
1594
|
-
chunks.push(
|
|
1595
|
-
|
|
1596
|
-
|
|
1554
|
+
chunks.push(
|
|
1555
|
+
paragraphChunks.reduce((a, b) => {
|
|
1556
|
+
return b.length > 0 ? a.concat(MD_LINEBREAK_TOKEN, b) : a.concat("<br>");
|
|
1557
|
+
})
|
|
1558
|
+
);
|
|
1597
1559
|
paragraphChunks.length = 0;
|
|
1598
1560
|
}
|
|
1599
1561
|
};
|
|
@@ -1605,18 +1567,22 @@ const serializeRoot = ($root, range) => {
|
|
|
1605
1567
|
if (isMainList) {
|
|
1606
1568
|
flushListChunks();
|
|
1607
1569
|
}
|
|
1608
|
-
listChunks.push(
|
|
1570
|
+
listChunks.push(
|
|
1571
|
+
serializeListItem($child, listIsOrderedStack, range)
|
|
1572
|
+
);
|
|
1609
1573
|
} else {
|
|
1610
1574
|
assertTextBlock($child);
|
|
1611
1575
|
flushListChunks();
|
|
1612
|
-
paragraphChunks.push(
|
|
1576
|
+
paragraphChunks.push(
|
|
1577
|
+
serializeTextBlock($child, range)
|
|
1578
|
+
);
|
|
1613
1579
|
}
|
|
1614
1580
|
}
|
|
1615
1581
|
flushListChunks();
|
|
1616
1582
|
flushParagraphChunks();
|
|
1617
1583
|
return chunks.join(MD_PARAGRAPH_JOIN);
|
|
1618
1584
|
};
|
|
1619
|
-
|
|
1585
|
+
const serializeMarkdown = ($root, range) => {
|
|
1620
1586
|
if (range !== null) {
|
|
1621
1587
|
const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
|
|
1622
1588
|
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
@@ -1624,7 +1590,7 @@ export const serializeMarkdown = ($root, range) => {
|
|
|
1624
1590
|
}
|
|
1625
1591
|
return serializeRoot($root, null);
|
|
1626
1592
|
};
|
|
1627
|
-
|
|
1593
|
+
const createParseVisitor = (doc) => {
|
|
1628
1594
|
let emojiBaseUrl = null;
|
|
1629
1595
|
return {
|
|
1630
1596
|
updateEmojiBaseUrl(url) {
|
|
@@ -1651,19 +1617,14 @@ export const createParseVisitor = doc => {
|
|
|
1651
1617
|
},
|
|
1652
1618
|
codetag(text) {
|
|
1653
1619
|
const $inline = createInlineWithText(text, doc);
|
|
1654
|
-
setInlineFormat($inline,
|
|
1620
|
+
setInlineFormat($inline, "c", true);
|
|
1655
1621
|
$currentBlock.appendChild($inline);
|
|
1656
1622
|
},
|
|
1657
|
-
inline(text,
|
|
1658
|
-
let {
|
|
1659
|
-
isBold,
|
|
1660
|
-
isItalic,
|
|
1661
|
-
isStrikethrough
|
|
1662
|
-
} = _ref2;
|
|
1623
|
+
inline(text, { isBold, isItalic, isStrikethrough }) {
|
|
1663
1624
|
const $inline = createInlineWithText(text, doc);
|
|
1664
|
-
setInlineFormat($inline,
|
|
1665
|
-
setInlineFormat($inline,
|
|
1666
|
-
setInlineFormat($inline,
|
|
1625
|
+
setInlineFormat($inline, "b", isBold === true);
|
|
1626
|
+
setInlineFormat($inline, "i", isItalic === true);
|
|
1627
|
+
setInlineFormat($inline, "s", isStrikethrough === true);
|
|
1667
1628
|
$currentBlock.appendChild($inline);
|
|
1668
1629
|
},
|
|
1669
1630
|
linebreak() {
|
|
@@ -1690,9 +1651,7 @@ export const createParseVisitor = doc => {
|
|
|
1690
1651
|
},
|
|
1691
1652
|
listItem() {
|
|
1692
1653
|
const listLevel = listsStack.length - 1;
|
|
1693
|
-
const {
|
|
1694
|
-
isOrdered
|
|
1695
|
-
} = listsStack.at(-1);
|
|
1654
|
+
const { isOrdered } = listsStack.at(-1);
|
|
1696
1655
|
const $li = createActuallyEmptyListItem(isOrdered, listLevel, doc);
|
|
1697
1656
|
if (listsStack.length === 1 && isFirstListItem) {
|
|
1698
1657
|
markListItemAsBlock($li);
|
|
@@ -1720,13 +1679,7 @@ export const createParseVisitor = doc => {
|
|
|
1720
1679
|
}
|
|
1721
1680
|
};
|
|
1722
1681
|
};
|
|
1723
|
-
|
|
1724
|
-
let {
|
|
1725
|
-
startContainer,
|
|
1726
|
-
startOffset,
|
|
1727
|
-
endContainer,
|
|
1728
|
-
endOffset
|
|
1729
|
-
} = _ref3;
|
|
1682
|
+
const setBrowserCaret = ({ startContainer, startOffset, endContainer, endOffset }) => {
|
|
1730
1683
|
const selection = document.getSelection();
|
|
1731
1684
|
if (selection === null) {
|
|
1732
1685
|
return;
|
|
@@ -1736,4 +1689,24 @@ export const setBrowserCaret = _ref3 => {
|
|
|
1736
1689
|
range.setStart(startContainer, startOffset);
|
|
1737
1690
|
range.setEnd(endContainer, endOffset);
|
|
1738
1691
|
selection.addRange(range);
|
|
1739
|
-
};
|
|
1692
|
+
};
|
|
1693
|
+
export {
|
|
1694
|
+
createParseVisitor,
|
|
1695
|
+
deleteContentBackward,
|
|
1696
|
+
formatIndent,
|
|
1697
|
+
formatInline,
|
|
1698
|
+
formatList,
|
|
1699
|
+
formatOutdent,
|
|
1700
|
+
getBeginRange,
|
|
1701
|
+
getEndRange,
|
|
1702
|
+
getSelectionInfo,
|
|
1703
|
+
handleEmojiMousedown,
|
|
1704
|
+
insertFromPaste,
|
|
1705
|
+
insertLineBreak,
|
|
1706
|
+
insertLink,
|
|
1707
|
+
insertText,
|
|
1708
|
+
isEditorEmpty,
|
|
1709
|
+
isSelectionEqual,
|
|
1710
|
+
serializeMarkdown,
|
|
1711
|
+
setBrowserCaret
|
|
1712
|
+
};
|