@onereach/ui-components 2.70.0-beta.2185.0 → 2.70.0-beta.2206.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/dist/bundled/v2/components/OrAvatar/OrAvatar.js +116 -10
- package/dist/bundled/v2/components/OrAvatar/constants.js +8 -0
- package/dist/bundled/v2/components/OrAvatar/index.js +9 -6
- package/dist/bundled/v2/components/OrAvatarV3/OrAvatarV3.js +121 -6
- package/dist/bundled/v2/components/OrAvatarV3/index.js +11 -4
- package/dist/bundled/v2/components/OrAvatarV3/props.js +19 -0
- package/dist/bundled/v2/components/OrAvatarV3/styles.js +65 -0
- package/dist/bundled/v2/components/OrBottomSheetV3/OrBottomSheetV3.js +5 -38
- package/dist/bundled/v2/components/OrBottomSheetV3/index.js +5 -2
- package/dist/bundled/v2/components/OrBottomSheetV3/styles.js +37 -0
- package/dist/bundled/v2/components/OrButton/OrButton.js +176 -5
- package/dist/bundled/v2/components/OrButton/constants.js +25 -0
- package/dist/bundled/v2/components/OrButton/index.js +4 -2
- package/dist/bundled/v2/components/OrButtonV2/OrButtonV2.js +10 -7
- package/dist/bundled/v2/{constants-c5d1139f.js → components/OrButtonV2/constants.js} +1 -1
- package/dist/bundled/v2/components/OrButtonV2/index.js +10 -7
- package/dist/bundled/v2/components/OrButtonV3/OrButtonV3.js +116 -5
- package/dist/bundled/v2/components/OrButtonV3/index.js +7 -3
- package/dist/bundled/v2/components/OrButtonV3/props.js +21 -0
- package/dist/bundled/v2/components/OrButtonV3/styles.js +61 -0
- package/dist/bundled/v2/components/OrCardCollection/OrCardCollection.js +228 -14
- package/dist/bundled/v2/components/OrCardCollection/constants.js +7 -0
- package/dist/bundled/v2/components/OrCardCollection/index.js +12 -8
- package/dist/bundled/v2/components/OrCardCollectionV3/OrCardCollectionV3.js +277 -18
- package/dist/bundled/v2/components/OrCardCollectionV3/index.js +39 -13
- package/dist/bundled/v2/components/OrCardCollectionV3/props.js +16 -0
- package/dist/bundled/v2/components/OrCardCollectionV3/styles.js +30 -0
- package/dist/bundled/v2/components/OrCardCollectionView.vue2V3/OrCardCollectionView.vue2V3.js +65 -3
- package/dist/bundled/v2/components/OrCardCollectionView.vue3V3/OrCardCollectionView.vue3V3.js +2 -1
- package/dist/bundled/v2/components/OrCardV3/OrCardV3.js +2 -15
- package/dist/bundled/v2/components/OrCardV3/index.js +2 -1
- package/dist/bundled/v2/components/OrCardV3/styles.js +15 -0
- package/dist/bundled/v2/components/OrCarousel/OrCarousel.js +10 -27
- package/dist/bundled/v2/components/OrCarousel/constants.js +21 -0
- package/dist/bundled/v2/components/OrCarousel/index.js +8 -5
- package/dist/bundled/v2/components/OrCheckbox/OrCheckbox.js +7 -5
- package/dist/bundled/v2/components/OrCheckbox/index.js +7 -5
- package/dist/bundled/v2/components/OrCheckboxV3/OrCheckboxV3.js +5 -32
- package/dist/bundled/v2/components/OrCheckboxV3/index.js +5 -2
- package/dist/bundled/v2/components/OrCheckboxV3/styles.js +31 -0
- package/dist/bundled/v2/components/OrChip/OrChip.js +7 -5
- package/dist/bundled/v2/components/OrChips/OrChips.js +9 -6
- package/dist/bundled/v2/components/OrChips/constants.js +10 -0
- package/dist/bundled/v2/components/OrChips/index.js +9 -6
- package/dist/bundled/v2/components/OrChipsInput/OrChipsInput.js +150 -10
- package/dist/bundled/v2/components/OrCode/OrCode.js +4088 -19
- package/dist/bundled/v2/components/OrCode/constants.js +11 -0
- package/dist/bundled/v2/components/OrCode/index.js +15 -9
- package/dist/bundled/v2/components/OrCode/lang.js +2 -0
- package/dist/bundled/v2/components/OrCollapse/OrCollapse.js +2 -2
- package/dist/bundled/v2/components/OrCollapse/index.js +2 -2
- package/dist/bundled/v2/components/OrColorPicker/OrColorPicker.js +166 -8
- package/dist/bundled/{v3/OrColorPicker.vue_vue_type_script_lang-5e190fa5.js → v2/components/OrColorPicker/constants.js} +1 -67
- package/dist/bundled/v2/components/OrColorPicker/defultPalette.js +15 -0
- package/dist/bundled/v2/components/OrColorPicker/index.js +7 -4
- package/dist/bundled/v2/components/OrConfirm/OrConfirm.js +12 -8
- package/dist/bundled/v2/components/OrConfirm/index.js +12 -8
- package/dist/bundled/v2/components/OrConfirmV3/OrConfirmV3.js +302 -17
- package/dist/bundled/v2/components/OrConfirmV3/index.js +36 -12
- package/dist/bundled/v2/components/OrConfirmV3/props.js +7 -0
- package/dist/bundled/v2/components/OrConfirmV3/styles.js +45 -0
- package/dist/bundled/v2/components/OrDateTimePicker/OrDateTimePicker.js +12 -8
- package/dist/bundled/v2/components/OrDateTimePicker/constants.js +20 -0
- package/dist/bundled/v2/components/OrDateTimePicker/index.js +14 -10
- package/dist/bundled/v2/components/OrDateTimePickerCalendarItem/OrDateTimePickerCalendarItem.js +112 -5
- package/dist/bundled/v2/components/OrEmptyStateV3/OrEmptyStateV3.js +111 -3
- package/dist/bundled/v2/components/OrEmptyStateV3/index.js +3 -1
- package/dist/bundled/v2/components/OrEmptyStateV3/props.js +7 -0
- package/dist/bundled/v2/components/OrEmptyStateV3/styles.js +46 -0
- package/dist/bundled/v2/components/OrErrorTagV3/OrErrorTagV3.js +5 -18
- package/dist/bundled/v2/components/OrErrorTagV3/index.js +5 -2
- package/dist/bundled/v2/components/OrErrorTagV3/styles.js +17 -0
- package/dist/bundled/v2/components/OrErrorV3/OrErrorV3.js +2 -21
- package/dist/bundled/v2/components/OrErrorV3/index.js +2 -1
- package/dist/bundled/v2/components/OrErrorV3/styles.js +21 -0
- package/dist/bundled/v2/components/OrExpansionPanelV3/OrExpansionPanelV3.js +121 -5
- package/dist/bundled/v2/components/OrExpansionPanelV3/index.js +7 -3
- package/dist/bundled/v2/components/OrExpansionPanelV3/props.js +12 -0
- package/dist/bundled/v2/components/OrExpansionPanelV3/styles.js +49 -0
- package/dist/bundled/v2/components/OrFabV3/OrFabV3.js +85 -5
- package/dist/bundled/v2/components/OrFabV3/index.js +7 -3
- package/dist/bundled/v2/components/OrFabV3/props.js +7 -0
- package/dist/bundled/v2/components/OrFabV3/styles.js +19 -0
- package/dist/bundled/v2/components/OrFloating/OrFloating.js +190 -8
- package/dist/bundled/v2/components/OrFloating/constants.js +22 -0
- package/dist/bundled/v2/components/OrFloating/index.js +4 -3
- package/dist/bundled/v2/components/OrHintV3/OrHintV3.js +2 -21
- package/dist/bundled/v2/components/OrHintV3/index.js +2 -1
- package/dist/bundled/v2/components/OrHintV3/styles.js +21 -0
- package/dist/bundled/v2/components/OrIcon/OrIcon.js +159 -10
- package/dist/bundled/v2/components/OrIcon/constants.js +24 -0
- package/dist/bundled/v2/components/OrIcon/index.js +7 -5
- package/dist/bundled/v2/components/OrIconButtonV2/OrIconButtonV2.js +10 -7
- package/dist/bundled/v2/components/OrIconButtonV2/index.js +10 -7
- package/dist/bundled/v2/components/OrIconButtonV3/OrIconButtonV3.js +122 -9
- package/dist/bundled/v2/components/OrIconButtonV3/index.js +17 -7
- package/dist/bundled/v2/components/OrIconButtonV3/props.js +10 -0
- package/dist/bundled/{v3/OrIconButton.vue_vue_type_script_lang-7663827a.js → v2/components/OrIconButtonV3/styles.js} +1 -59
- package/dist/bundled/v2/components/OrIconV3/OrIconV3.js +72 -4
- package/dist/bundled/v2/components/OrIconV3/index.js +4 -2
- package/dist/bundled/v2/components/OrIconV3/props.js +17 -0
- package/dist/bundled/v2/components/OrIconV3/styles.js +44 -0
- package/dist/bundled/v2/components/OrInlineInputBoxV3/OrInlineInputBoxV3.js +71 -4
- package/dist/bundled/v2/components/OrInlineInputBoxV3/index.js +4 -2
- package/dist/bundled/v2/components/OrInlineInputBoxV3/props.js +7 -0
- package/dist/bundled/{v3/OrInlineInputBox.vue_vue_type_script_lang-ef7d7eaf.js → v2/components/OrInlineInputBoxV3/styles.js} +1 -37
- package/dist/bundled/v2/components/OrInlineInputV3/OrInlineInputV3.js +349 -13
- package/dist/bundled/v2/components/OrInlineInputV3/index.js +24 -8
- package/dist/bundled/v2/components/OrInlineInputV3/props.js +9 -0
- package/dist/bundled/v2/components/OrInlineInputV3/styles.js +29 -0
- package/dist/bundled/v2/components/OrInlineTextEdit/OrInlineTextEdit.js +397 -15
- package/dist/bundled/v2/components/OrInlineTextEdit/constants.js +13 -0
- package/dist/bundled/v2/components/OrInlineTextEdit/index.js +12 -8
- package/dist/bundled/v2/components/OrInlineTextareaV3/OrInlineTextareaV3.js +22 -27
- package/dist/bundled/v2/components/OrInlineTextareaV3/index.js +22 -7
- package/dist/bundled/v2/components/OrInlineTextareaV3/styles.js +21 -0
- package/dist/bundled/v2/components/OrInput/OrInput.js +2 -2
- package/dist/bundled/v2/components/OrInputBoxV3/OrInputBoxV3.js +85 -4
- package/dist/bundled/v2/components/OrInputBoxV3/index.js +4 -2
- package/dist/bundled/v2/components/OrInputBoxV3/props.js +12 -0
- package/dist/bundled/{v3/OrInputBox.vue_vue_type_script_lang-d3b211c2.js → v2/components/OrInputBoxV3/styles.js} +1 -54
- package/dist/bundled/v2/components/OrInputV3/OrInputV3.js +386 -14
- package/dist/bundled/v2/components/OrInputV3/index.js +27 -9
- package/dist/bundled/v2/components/OrInputV3/props.js +11 -0
- package/dist/bundled/v2/components/OrInputV3/styles.js +14 -0
- package/dist/bundled/v2/components/OrInputs/index.js +11 -8
- package/dist/bundled/v2/components/OrLabelV3/OrLabelV3.js +92 -4
- package/dist/bundled/v2/components/OrLabelV3/index.js +4 -2
- package/dist/bundled/v2/components/OrLabelV3/props.js +7 -0
- package/dist/bundled/v2/components/OrLabelV3/styles.js +29 -0
- package/dist/bundled/v2/components/OrLinkV3/OrLinkV3.js +88 -4
- package/dist/bundled/v2/components/OrLinkV3/index.js +4 -2
- package/dist/bundled/v2/components/OrLinkV3/props.js +10 -0
- package/dist/bundled/v2/components/OrLinkV3/styles.js +26 -0
- package/dist/bundled/v2/components/OrList/OrList.js +10 -7
- package/dist/bundled/v2/components/OrList/index.js +10 -7
- package/dist/bundled/v2/components/OrListOfInputs/OrListOfInputs.js +10 -7
- package/dist/bundled/v2/components/OrListOfInputs/index.js +10 -7
- package/dist/bundled/v2/components/OrLoader/OrLoader.js +109 -5
- package/dist/bundled/v2/components/OrLoader/constants.js +8 -0
- package/dist/bundled/v2/components/OrLoader/index.js +2 -1
- package/dist/bundled/v2/components/OrLoaderV3/OrLoaderV3.js +150 -4
- package/dist/bundled/v2/components/OrLoaderV3/index.js +4 -2
- package/dist/bundled/v2/components/OrLoaderV3/props.js +18 -0
- package/dist/bundled/v2/components/OrLoaderV3/styles.js +17 -0
- package/dist/bundled/v2/components/OrMenuItemV3/OrMenuItemV3.js +5 -18
- package/dist/bundled/v2/components/OrMenuItemV3/index.js +5 -2
- package/dist/bundled/v2/components/OrMenuItemV3/styles.js +17 -0
- package/dist/bundled/v2/components/OrMenuV3/OrMenuV3.js +10 -13
- package/dist/bundled/v2/components/OrMenuV3/index.js +11 -5
- package/dist/bundled/v2/components/OrMenuV3/props.js +1 -0
- package/dist/bundled/v2/components/OrMenuV3/styles.js +10 -0
- package/dist/bundled/v2/components/OrModal/OrModal.js +1465 -15
- package/dist/bundled/v2/components/OrModal/constants.js +10 -0
- package/dist/bundled/v2/components/OrModal/index.js +12 -8
- package/dist/bundled/v2/components/OrModalV3/OrModalV3.js +141 -10
- package/dist/bundled/v2/components/OrModalV3/index.js +19 -7
- package/dist/bundled/v2/components/OrModalV3/props.js +8 -0
- package/dist/bundled/v2/components/OrModalV3/styles.js +38 -0
- package/dist/bundled/v2/components/OrNotification/OrNotification.js +140 -12
- package/dist/bundled/v2/components/OrNotification/constants.js +14 -0
- package/dist/bundled/v2/components/OrNotification/index.js +12 -8
- package/dist/bundled/v2/components/OrNotificationV3/OrNotificationV3.js +122 -9
- package/dist/bundled/v2/components/OrNotificationV3/index.js +19 -7
- package/dist/bundled/v2/components/OrNotificationV3/props.js +9 -0
- package/dist/bundled/v2/components/OrNotificationV3/styles.js +59 -0
- package/dist/bundled/v2/components/OrNumberInput/OrNumberInput.js +2 -2
- package/dist/bundled/v2/components/OrOverflowMenu/OrOverflowMenu.js +10 -7
- package/dist/bundled/v2/components/OrOverflowMenu/index.js +10 -7
- package/dist/bundled/v2/components/OrOverflowMenuItem/OrOverflowMenuItem.js +10 -7
- package/dist/bundled/v2/components/OrOverlayV3/OrOverlayV3.js +4 -10
- package/dist/bundled/v2/components/OrOverlayV3/index.js +4 -2
- package/dist/bundled/v2/components/OrOverlayV3/styles.js +9 -0
- package/dist/bundled/v2/components/OrPassword/OrPassword.js +11 -8
- package/dist/bundled/v2/components/OrPopoverV3/OrPopoverV3.js +224 -10
- package/dist/bundled/v2/components/OrPopoverV3/index.js +9 -4
- package/dist/bundled/v2/components/OrPopoverV3/props.js +23 -0
- package/dist/bundled/v2/components/OrPopoverV3/styles.js +44 -0
- package/dist/bundled/v2/components/OrProgress/OrProgress.js +214 -5
- package/dist/bundled/v2/components/OrProgress/constants.js +15 -0
- package/dist/bundled/v2/components/OrProgress/index.js +2 -1
- package/dist/bundled/v2/components/OrProgressV3/OrProgressV3.js +245 -7
- package/dist/bundled/v2/components/OrProgressV3/index.js +5 -3
- package/dist/bundled/v2/components/OrProgressV3/props.js +15 -0
- package/dist/bundled/v2/components/OrProgressV3/styles.js +63 -0
- package/dist/bundled/v2/components/OrRadioV3/OrRadioV3.js +5 -32
- package/dist/bundled/v2/components/OrRadioV3/index.js +5 -2
- package/dist/bundled/v2/components/OrRadioV3/styles.js +31 -0
- package/dist/bundled/v2/components/OrSearch/OrSearch.js +10 -7
- package/dist/bundled/v2/components/OrSearchV3/OrSearchV3.js +27 -9
- package/dist/bundled/v2/components/OrSearchV3/index.js +27 -9
- package/dist/bundled/v2/components/OrSearchV3/props.js +1 -0
- package/dist/bundled/v2/components/OrSegmentedControlItemV3/OrSegmentedControlItemV3.js +2 -31
- package/dist/bundled/v2/components/OrSegmentedControlV3/OrSegmentedControlV3.js +127 -5
- package/dist/bundled/v2/components/OrSegmentedControlV3/index.js +4 -2
- package/dist/bundled/v2/components/OrSegmentedControlV3/props.js +7 -0
- package/dist/bundled/v2/components/OrSegmentedControlV3/styles.js +31 -0
- package/dist/bundled/v2/components/OrSelect/OrSelect.js +10 -7
- package/dist/bundled/{v3/constants-59507e57.js → v2/components/OrSelect/constants.js} +1 -1
- package/dist/bundled/v2/components/OrSelect/index.js +10 -7
- package/dist/bundled/v2/components/OrSelectContent/OrSelectContent.js +10 -7
- package/dist/bundled/v2/components/OrSelectContentEmpty/OrSelectContentEmpty.js +1 -1
- package/dist/bundled/v2/components/OrSelectContentOptions/OrSelectContentOptions.js +8 -6
- package/dist/bundled/v2/components/OrSelectInput/OrSelectInput.js +8 -6
- package/dist/bundled/v2/components/OrSelectInputValue/OrSelectInputValue.js +8 -6
- package/dist/bundled/v2/components/OrSelectMain/OrSelectMain.js +10 -7
- package/dist/bundled/v2/components/OrSelectOption/OrSelectOption.js +7 -5
- package/dist/bundled/v2/components/OrSelectSearchOptions/OrSelectSearchOptions.js +8 -6
- package/dist/bundled/v2/components/OrSelectV3/OrSelectV3.js +39 -49
- package/dist/bundled/v2/components/OrSelectV3/index.js +39 -13
- package/dist/bundled/v2/components/OrSelectV3/props.js +1 -0
- package/dist/bundled/v2/components/OrSelectV3/styles.js +37 -0
- package/dist/bundled/v2/components/OrSidebar/OrSidebar.js +145 -6
- package/dist/bundled/v2/components/OrSidebar/constants.js +7 -0
- package/dist/bundled/v2/components/OrSidebar/index.js +2 -1
- package/dist/bundled/v2/components/OrSidebarV3/OrSidebarV3.js +159 -5
- package/dist/bundled/v2/components/OrSidebarV3/index.js +3 -1
- package/dist/bundled/v2/components/OrSidebarV3/props.js +7 -0
- package/dist/bundled/v2/components/OrSidebarV3/styles.js +68 -0
- package/dist/bundled/v2/components/OrSkeleton/constants.js +12 -0
- package/dist/bundled/v2/components/OrSkeleton/index.js +3 -2
- package/dist/bundled/v2/components/OrSkeletonCircle/OrSkeletonCircle.js +1 -1
- package/dist/bundled/v2/components/OrSkeletonCircleV3/OrSkeletonCircleV3.js +3 -3
- package/dist/bundled/v2/components/OrSkeletonRect/OrSkeletonRect.js +1 -1
- package/dist/bundled/v2/components/OrSkeletonRectV3/OrSkeletonRectV3.js +3 -3
- package/dist/bundled/v2/components/OrSkeletonText/OrSkeletonText.js +97 -6
- package/dist/bundled/v2/components/OrSkeletonTextV3/OrSkeletonTextV3.js +3 -3
- package/dist/bundled/v2/components/OrSkeletonV3/index.js +3 -3
- package/dist/bundled/{v3/styles-ed564e39.js → v2/components/OrSkeletonV3/styles.js} +1 -1
- package/dist/bundled/v2/components/OrSlider/OrSlider.js +7 -5
- package/dist/bundled/v2/components/OrSlider/index.js +7 -5
- package/dist/bundled/v2/components/OrSortHeaderV3/OrSortHeaderV3.js +5 -16
- package/dist/bundled/v2/components/OrSortHeaderV3/index.js +5 -2
- package/dist/bundled/v2/components/OrSortHeaderV3/styles.js +15 -0
- package/dist/bundled/v2/components/OrStepper/OrStepper.js +10 -7
- package/dist/bundled/v2/components/OrStepper/index.js +10 -7
- package/dist/bundled/v2/components/OrStepperButtonOptions/OrStepperButtonOptions.js +10 -7
- package/dist/bundled/v2/components/OrStepperOptionHorizontal/OrStepperOptionHorizontal.js +10 -7
- package/dist/bundled/v2/components/OrStepperOptionVertical/OrStepperOptionVertical.js +10 -7
- package/dist/bundled/v2/components/OrSwitch/OrSwitch.js +2 -1
- package/dist/bundled/v2/components/OrSwitch/index.js +2 -1
- package/dist/bundled/v2/components/OrSwitchV3/OrSwitchV3.js +8 -53
- package/dist/bundled/v2/components/OrSwitchV3/index.js +8 -3
- package/dist/bundled/{v3/OrSwitch.vue_vue_type_script_lang-088550b0.js → v2/components/OrSwitchV3/styles.js} +1 -85
- package/dist/bundled/v2/components/OrTabV3/OrTabV3.js +2 -19
- package/dist/bundled/v2/components/OrTabV3/index.js +2 -1
- package/dist/bundled/{v3/OrTab.vue_vue_type_script_lang-a4c48577.js → v2/components/OrTabV3/styles.js} +1 -28
- package/dist/bundled/v2/components/OrTabsV3/OrTabsV3.js +223 -12
- package/dist/bundled/v2/components/OrTabsV3/index.js +18 -6
- package/dist/bundled/v2/components/OrTabsV3/props.js +7 -0
- package/dist/bundled/v2/components/OrTabsV3/styles.js +19 -0
- package/dist/bundled/v2/components/OrTag/OrTag.js +11 -6
- package/dist/bundled/v2/components/OrTag/index.js +11 -6
- package/dist/bundled/v2/components/OrTagV3/OrTagV3.js +135 -9
- package/dist/bundled/v2/components/OrTagV3/index.js +19 -7
- package/dist/bundled/v2/components/OrTagV3/props.js +13 -0
- package/dist/bundled/v2/components/OrTagV3/styles.js +34 -0
- package/dist/bundled/v2/{constants-b4c183aa.js → components/OrTeleport/constants.js} +1 -1
- package/dist/bundled/v2/components/OrTeleport/index.js +1 -1
- package/dist/bundled/v2/components/OrTeleportVue2/OrTeleportVue2.js +1 -1
- package/dist/bundled/v2/components/OrTeleportVue3/OrTeleportVue3.js +1 -1
- package/dist/bundled/v2/components/OrTextV3/OrTextV3.js +2 -17
- package/dist/bundled/v2/components/OrTextV3/index.js +2 -1
- package/dist/bundled/v2/components/OrTextV3/styles.js +17 -0
- package/dist/bundled/v2/components/OrTextarea/OrTextarea.js +2 -2
- package/dist/bundled/v2/components/OrTextareaV3/OrTextareaV3.js +10 -16
- package/dist/bundled/v2/components/OrTextareaV3/index.js +10 -3
- package/dist/bundled/v2/components/OrTextareaV3/props.js +1 -0
- package/dist/bundled/v2/components/OrTextareaV3/styles.js +14 -0
- package/dist/bundled/v2/components/OrTextbox/OrTextbox.js +528 -18
- package/dist/bundled/v2/components/OrTextbox/constants.js +11 -0
- package/dist/bundled/v2/components/OrTextbox/index.js +13 -9
- package/dist/bundled/v2/components/OrToast/OrToast.js +13 -9
- package/dist/bundled/v2/components/OrToast/Timer.js +37 -0
- package/dist/bundled/v2/{constants-25998e4c.js → components/OrToast/constants.js} +1 -1
- package/dist/bundled/v2/components/OrToast/index.js +5 -3
- package/dist/bundled/{v3/useToastEventBus-422dae05.js → v2/components/OrToast/useQueue.js} +1 -23
- package/dist/bundled/{v3/useToast-0c42015d.js → v2/components/OrToast/useToast.js} +5 -38
- package/dist/bundled/v2/components/OrToast/useToastEventBus.js +24 -0
- package/dist/bundled/v2/components/OrToastContainer/OrToastContainer.js +15 -10
- package/dist/bundled/v2/components/OrToastContainerV3/OrToastContainerV3.js +23 -9
- package/dist/bundled/v2/components/OrToastV3/OrToastV3.js +196 -12
- package/dist/bundled/v2/components/OrToastV3/Timer.js +37 -0
- package/dist/bundled/v2/components/OrToastV3/index.js +4 -2
- package/dist/bundled/v2/components/OrToastV3/props.js +1 -0
- package/dist/bundled/v2/components/OrToastV3/styles.js +64 -0
- package/dist/bundled/v2/{useToastEventBus-422dae05.js → components/OrToastV3/useQueue.js} +1 -23
- package/dist/bundled/v2/{useToast-40bff6ec.js → components/OrToastV3/useToast.js} +5 -38
- package/dist/bundled/v2/components/OrToastV3/useToastEventBus.js +24 -0
- package/dist/bundled/v2/components/OrTooltip/OrTooltip.js +4 -3
- package/dist/bundled/v2/components/OrTooltip/index.js +4 -3
- package/dist/bundled/v2/components/OrTooltipV3/OrTooltipV3.js +10 -49
- package/dist/bundled/v2/components/OrTooltipV3/index.js +11 -5
- package/dist/bundled/v2/components/OrTooltipV3/props.js +1 -0
- package/dist/bundled/v2/components/OrTooltipV3/styles.js +46 -0
- package/dist/bundled/v2/components/OrTooltipWrapperV2/OrTooltipWrapperV2.js +4 -3
- package/dist/bundled/v2/components/index.js +157 -61
- package/dist/bundled/v2/directives/dropdown-close.js +15 -0
- package/dist/bundled/{v3/dropdown-open-0d314aa4.js → v2/directives/dropdown-open.js} +1 -13
- package/dist/bundled/v2/directives/index.js +2 -1
- package/dist/bundled/v2/hooks/index.js +6 -5
- package/dist/bundled/v2/{useClassAttribute-47fdb016.js → hooks/useClassAttribute.js} +1 -1
- package/dist/bundled/v2/{useElevation-31bfe1f6.js → hooks/useElevation.js} +2 -5
- package/dist/bundled/v2/{useOverflow-af6161c8.js → hooks/useOverflow.js} +1 -1
- package/dist/bundled/v2/hooks/useResponsive/index.js +1 -1
- package/dist/bundled/{v3/useResponsive-a02e95b7.js → v2/hooks/useResponsive/useResponsive.js} +1 -1
- package/dist/bundled/v2/{useToggle-29e4d7c7.js → hooks/useToggle.js} +1 -1
- package/dist/bundled/v2/index.js +159 -70
- package/dist/bundled/{v3/OrCode.vue_vue_type_script_lang-fe4c9a58.js → v2/lang-d640563a.js} +276 -4238
- package/dist/bundled/v2/utils/constants/color.js +16 -0
- package/dist/bundled/v2/utils/constants/key-codes.js +16 -0
- package/dist/bundled/v2/utils/constants/poper.js +10 -0
- package/dist/bundled/v2/utils/constants/regex.js +49 -0
- package/dist/bundled/v2/{color-1f348774.js → utils/functions/color.js} +11 -32
- package/dist/bundled/v2/utils/functions/dom.js +167 -0
- package/dist/bundled/v2/utils/functions/hash.js +8 -0
- package/dist/bundled/v2/{px-to-rem-0b26b83e.js → utils/functions/px-to-rem.js} +1 -1
- package/dist/bundled/v2/utils/functions/text.js +9 -0
- package/dist/bundled/v2/utils/isVisible.js +5 -0
- package/dist/bundled/v3/OrAvatar.vue_vue_type_script_lang-51387b7f.js +69 -0
- package/dist/bundled/v3/{OrAvatar.vue_vue_type_script_lang-a3740c88.js → OrAvatar.vue_vue_type_script_lang-7f2cfae5.js} +3 -9
- package/dist/bundled/v3/{OrBottomSheet.vue_vue_type_script_lang-7926afd5.js → OrBottomSheet.vue_vue_type_script_lang-bcf12a2a.js} +3 -38
- package/dist/bundled/v3/OrButton.vue_vue_type_script_lang-76ff19e0.js +55 -0
- package/dist/bundled/v3/{OrButton.vue_vue_type_script_lang-aa34ef87.js → OrButton.vue_vue_type_script_lang-b48cc1bf.js} +4 -3
- package/dist/bundled/v3/{OrButton.vue_vue_type_script_lang-255594c4.js → OrButton.vue_vue_type_script_lang-ed520a05.js} +4 -26
- package/dist/bundled/v3/{OrCard.vue_vue_type_script_lang-51a6b8a8.js → OrCard.vue_vue_type_script_lang-92676a3f.js} +2 -15
- package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-136bbb5b.js → OrCardCollection.vue_vue_type_script_lang-7ea46f31.js} +5 -10
- package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-761c74df.js → OrCardCollection.vue_vue_type_script_lang-80ed3d2d.js} +11 -24
- package/dist/bundled/v3/{OrCarousel.vue_vue_type_script_lang-80efcb20.js → OrCarousel.vue_vue_type_script_lang-d347c544.js} +4 -23
- package/dist/bundled/v3/{OrCheckbox.vue_vue_type_script_lang-3e6ddbd0.js → OrCheckbox.vue_vue_type_script_lang-841594f0.js} +4 -32
- package/dist/bundled/v3/{OrCheckbox.vue_vue_type_script_lang-dbf18135.js → OrCheckbox.vue_vue_type_script_lang-948ed4f0.js} +1 -1
- package/dist/bundled/v3/{OrChips.vue_vue_type_script_lang-fc2bd126.js → OrChips.vue_vue_type_script_lang-20f25092.js} +2 -1
- package/dist/bundled/v3/OrCode.vue_vue_type_script_lang-ec35d27e.js +3957 -0
- package/dist/bundled/v3/{OrCollapse.vue_vue_type_script_lang-76b28b03.js → OrCollapse.vue_vue_type_script_lang-e22b5a76.js} +2 -2
- package/dist/bundled/v3/OrColorPicker.vue_vue_type_script_lang-7987074d.js +58 -0
- package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-9367f23b.js → OrConfirm.vue_vue_type_script_lang-96d0eb06.js} +4 -3
- package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-642b8f83.js → OrConfirm.vue_vue_type_script_lang-9f31c964.js} +7 -52
- package/dist/bundled/v3/{OrDateTimePicker.vue_vue_type_script_lang-09a33c8a.js → OrDateTimePicker.vue_vue_type_script_lang-a3b3aac4.js} +7 -6
- package/dist/bundled/v3/{OrEmptyState.vue_vue_type_script_lang-8392055c.js → OrEmptyState.vue_vue_type_script_lang-4c5ad2a9.js} +3 -50
- package/dist/bundled/v3/{OrError.vue_vue_type_script_lang-6954e9de.js → OrError.vue_vue_type_script_lang-98601766.js} +2 -21
- package/dist/bundled/v3/{OrErrorTag.vue_vue_type_script_lang-4fd7c0f4.js → OrErrorTag.vue_vue_type_script_lang-05e8460d.js} +3 -18
- package/dist/bundled/v3/OrExpansionPanel.vue_vue_type_script_lang-c908e8be.js +53 -0
- package/dist/bundled/v3/{OrFab.vue_vue_type_script_lang-2fd2bd45.js → OrFab.vue_vue_type_script_lang-e0018fef.js} +4 -26
- package/dist/bundled/v3/{OrFloating.vue_vue_type_script_lang-d29049e5.js → OrFloating.vue_vue_type_script_lang-66ce28ae.js} +3 -23
- package/dist/bundled/v3/{OrHint.vue_vue_type_script_lang-7dc58eba.js → OrHint.vue_vue_type_script_lang-e5ffd5fa.js} +2 -21
- package/dist/bundled/v3/OrIcon.vue_vue_type_script_lang-1cb537ef.js +37 -0
- package/dist/bundled/v3/{OrIcon.vue_vue_type_script_lang-d4254862.js → OrIcon.vue_vue_type_script_lang-aadbcbe3.js} +5 -26
- package/dist/bundled/v3/{OrIconButton.vue_vue_type_script_lang-71dd403b.js → OrIconButton.vue_vue_type_script_lang-721e0c2f.js} +4 -4
- package/dist/bundled/v3/OrIconButton.vue_vue_type_script_lang-da74839d.js +55 -0
- package/dist/bundled/v3/{OrInlineInput.vue_vue_type_script_lang-fdb31f3d.js → OrInlineInput.vue_vue_type_script_lang-c4f6a48e.js} +9 -40
- package/dist/bundled/v3/OrInlineInputBox.vue_vue_type_script_lang-5fd272da.js +33 -0
- package/dist/bundled/v3/{OrInlineTextEdit.vue_vue_type_script_lang-02e46795.js → OrInlineTextEdit.vue_vue_type_script_lang-e253d248.js} +6 -17
- package/dist/bundled/v3/{OrInlineTextarea.vue_vue_type_script_lang-f04c4f6c.js → OrInlineTextarea.vue_vue_type_script_lang-228e0fe5.js} +6 -25
- package/dist/bundled/v3/{OrInput.vue_vue_type_script_lang-e970f1b2.js → OrInput.vue_vue_type_script_lang-d1c06414.js} +11 -29
- package/dist/bundled/v3/OrInputBox.vue_vue_type_script_lang-49d89486.js +45 -0
- package/dist/bundled/v3/OrLabel.vue_vue_type_script_lang-5bedeb7c.js +45 -0
- package/dist/bundled/v3/OrLink.vue_vue_type_script_lang-2f3d1a29.js +49 -0
- package/dist/bundled/v3/{OrList.vue_vue_type_script_lang-3c02c236.js → OrList.vue_vue_type_script_lang-49d54b35.js} +3 -3
- package/dist/bundled/v3/{OrListOfInputs.vue_vue_type_script_lang-8b0e7a41.js → OrListOfInputs.vue_vue_type_script_lang-1176c219.js} +3 -3
- package/dist/bundled/v3/{OrLoader.vue_vue_type_script_lang-352f1432.js → OrLoader.vue_vue_type_script_lang-b48715a3.js} +2 -8
- package/dist/bundled/v3/{OrLoader.vue_vue_type_script_lang-b8a13a32.js → OrLoader.vue_vue_type_script_lang-f692d020.js} +4 -35
- package/dist/bundled/v3/{OrMenu.vue_vue_type_script_lang-2b12f986.js → OrMenu.vue_vue_type_script_lang-b642edb4.js} +4 -11
- package/dist/bundled/v3/{OrMenuItem.vue_vue_type_script_lang-53cb4736.js → OrMenuItem.vue_vue_type_script_lang-78262bac.js} +3 -18
- package/dist/bundled/v3/{OrModal.vue_vue_type_script_lang-76e9e15a.js → OrModal.vue_vue_type_script_lang-0768f700.js} +6 -48
- package/dist/bundled/v3/{OrModal.vue_vue_type_script_lang-a988003c.js → OrModal.vue_vue_type_script_lang-ee130ace.js} +3 -11
- package/dist/bundled/v3/{OrNotification.vue_vue_type_script_lang-050af525.js → OrNotification.vue_vue_type_script_lang-bfa90980.js} +4 -16
- package/dist/bundled/v3/OrNotification.vue_vue_type_script_lang-fc61927a.js +55 -0
- package/dist/bundled/v3/{OrNumberInput.vue_vue_type_script_lang-b8c3e548.js → OrNumberInput.vue_vue_type_script_lang-62ab9884.js} +0 -0
- package/dist/bundled/v3/{OrOverflowMenu.vue_vue_type_script_lang-eee56669.js → OrOverflowMenu.vue_vue_type_script_lang-5b37e82f.js} +3 -2
- package/dist/bundled/v3/{OrOverlay.vue_vue_type_script_lang-f2bdd70b.js → OrOverlay.vue_vue_type_script_lang-5e5b5fac.js} +3 -10
- package/dist/bundled/v3/{OrPassword.vue_vue_type_script_lang-aae45890.js → OrPassword.vue_vue_type_script_lang-0be1092d.js} +3 -3
- package/dist/bundled/v3/{OrPopover.vue_vue_type_script_lang-3aab2e20.js → OrPopover.vue_vue_type_script_lang-bca04ff0.js} +7 -70
- package/dist/bundled/v3/{OrProgress.vue_vue_type_script_lang-6105a07e.js → OrProgress.vue_vue_type_script_lang-26d7b3da.js} +2 -15
- package/dist/bundled/v3/{OrProgress.vue_vue_type_script_lang-42d51690.js → OrProgress.vue_vue_type_script_lang-720cd55c.js} +5 -77
- package/dist/bundled/v3/{OrRadio.vue_vue_type_script_lang-1dc76d07.js → OrRadio.vue_vue_type_script_lang-5cc9bde1.js} +4 -32
- package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-692ef46f.js → OrSearch.vue_vue_type_script_lang-94badc35.js} +3 -3
- package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-923fcd46.js → OrSearch.vue_vue_type_script_lang-a55b9a2b.js} +2 -2
- package/dist/bundled/v3/{OrSegmentedControl.vue_vue_type_script_lang-4ef23285.js → OrSegmentedControl.vue_vue_type_script_lang-0723e144.js} +3 -8
- package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-2e23b39c.js → OrSelect.vue_vue_type_script_lang-055a36a4.js} +17 -50
- package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-0ec9363b.js → OrSelect.vue_vue_type_script_lang-14c949c1.js} +1 -1
- package/dist/bundled/v3/{OrSidebar.vue_vue_type_script_lang-755f291c.js → OrSidebar.vue_vue_type_script_lang-00e9cda7.js} +2 -7
- package/dist/bundled/v3/{OrSidebar.vue_vue_type_script_lang-d438c111.js → OrSidebar.vue_vue_type_script_lang-4f5c8abd.js} +3 -72
- package/dist/bundled/v3/{OrSkeletonCircle.vue_vue_type_script_lang-30516785.js → OrSkeletonCircle.vue_vue_type_script_lang-e8f70634.js} +1 -1
- package/dist/bundled/v3/{OrSkeletonCircle.vue_vue_type_script_lang-21b57a2f.js → OrSkeletonCircle.vue_vue_type_script_lang-ef1d0034.js} +3 -3
- package/dist/bundled/v3/{OrSkeletonRect.vue_vue_type_script_lang-71f648ad.js → OrSkeletonRect.vue_vue_type_script_lang-808412d2.js} +1 -1
- package/dist/bundled/v3/{OrSkeletonRect.vue_vue_type_script_lang-f6cc46a6.js → OrSkeletonRect.vue_vue_type_script_lang-87fe8cfd.js} +3 -3
- package/dist/bundled/v3/{OrSkeletonText.vue_vue_type_script_lang-eb7a0efa.js → OrSkeletonText.vue_vue_type_script_lang-66622b63.js} +3 -3
- package/dist/bundled/v3/{OrSkeletonText.vue_vue_type_script_lang-2a1e065a.js → OrSkeletonText.vue_vue_type_script_lang-c8b26b0a.js} +3 -13
- package/dist/bundled/v3/{OrSlider.vue_vue_type_script_lang-a5e4b426.js → OrSlider.vue_vue_type_script_lang-ad7c7c0e.js} +2 -2
- package/dist/bundled/v3/{OrSortHeader.vue_vue_type_script_lang-b4b32dc2.js → OrSortHeader.vue_vue_type_script_lang-dcee77e5.js} +3 -16
- package/dist/bundled/v3/{OrStepper.vue_vue_type_script_lang-13ba3e63.js → OrStepper.vue_vue_type_script_lang-305d2a1a.js} +0 -0
- package/dist/bundled/v3/{OrSwitch.vue_vue_type_script_lang-85ca85ee.js → OrSwitch.vue_vue_type_script_lang-1c079a74.js} +1 -1
- package/dist/bundled/v3/OrSwitch.vue_vue_type_script_lang-7912c1f9.js +87 -0
- package/dist/bundled/v3/OrTab.vue_vue_type_script_lang-61ff4904.js +29 -0
- package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-86b1bf60.js → OrTabs.vue_vue_type_script_lang-ec821ca3.js} +8 -30
- package/dist/bundled/v3/{OrTag.vue_vue_type_script_lang-35dd890d.js → OrTag.vue_vue_type_script_lang-0ecaa8bc.js} +2 -2
- package/dist/bundled/v3/{OrTag.vue_vue_type_script_lang-d70c4e48.js → OrTag.vue_vue_type_script_lang-c9188abe.js} +5 -48
- package/dist/bundled/v3/{OrText.vue_vue_type_script_lang-16fa067b.js → OrText.vue_vue_type_script_lang-1edab64a.js} +2 -17
- package/dist/bundled/v3/{OrTextarea.vue_vue_type_script_lang-1f2bdb60.js → OrTextarea.vue_vue_type_script_lang-1d983e7f.js} +3 -3
- package/dist/bundled/v3/{OrTextarea.vue_vue_type_script_lang-ee596578.js → OrTextarea.vue_vue_type_script_lang-d7f4ea68.js} +7 -18
- package/dist/bundled/v3/{OrTextbox.vue_vue_type_script_lang-d5d776d4.js → OrTextbox.vue_vue_type_script_lang-7118b5ac.js} +7 -16
- package/dist/bundled/v3/{OrToastContainer.vue_vue_type_script_lang-5c92febc.js → OrToastContainer.vue_vue_type_script_lang-05c8eaef.js} +3 -2
- package/dist/bundled/v3/{OrToastContainer.vue_vue_type_script_lang-2256f09d.js → OrToastContainer.vue_vue_type_script_lang-23dc2104.js} +4 -2
- package/dist/bundled/v3/{OrTooltip.vue_vue_type_script_lang-680dfd41.js → OrTooltip.vue_vue_type_script_lang-1e610987.js} +4 -47
- package/dist/bundled/v3/{OrTooltip.vue_vue_type_script_lang-42773e6f.js → OrTooltip.vue_vue_type_script_lang-f8b8a2c1.js} +2 -1
- package/dist/bundled/v3/components/OrAvatar/OrAvatar.js +10 -7
- package/dist/bundled/v3/components/OrAvatar/constants.js +8 -0
- package/dist/bundled/v3/components/OrAvatar/index.js +9 -6
- package/dist/bundled/v3/components/OrAvatarV3/OrAvatarV3.js +12 -5
- package/dist/bundled/v3/components/OrAvatarV3/index.js +11 -4
- package/dist/bundled/v3/components/OrAvatarV3/props.js +19 -0
- package/dist/bundled/v3/components/OrAvatarV3/styles.js +65 -0
- package/dist/bundled/v3/components/OrBottomSheetV3/OrBottomSheetV3.js +8 -5
- package/dist/bundled/v3/components/OrBottomSheetV3/index.js +7 -4
- package/dist/bundled/v3/components/OrBottomSheetV3/styles.js +37 -0
- package/dist/bundled/v3/components/OrButton/OrButton.js +5 -3
- package/dist/bundled/v3/components/OrButton/constants.js +25 -0
- package/dist/bundled/v3/components/OrButton/index.js +4 -2
- package/dist/bundled/v3/components/OrButtonV2/OrButtonV2.js +12 -9
- package/dist/bundled/v3/{constants-c5d1139f.js → components/OrButtonV2/constants.js} +1 -1
- package/dist/bundled/v3/components/OrButtonV2/index.js +13 -10
- package/dist/bundled/v3/components/OrButtonV3/OrButtonV3.js +8 -4
- package/dist/bundled/v3/components/OrButtonV3/index.js +7 -3
- package/dist/bundled/v3/components/OrButtonV3/props.js +21 -0
- package/dist/bundled/v3/components/OrButtonV3/styles.js +61 -0
- package/dist/bundled/v3/components/OrCardCollection/OrCardCollection.js +17 -13
- package/dist/bundled/v3/components/OrCardCollection/constants.js +7 -0
- package/dist/bundled/v3/components/OrCardCollection/index.js +16 -12
- package/dist/bundled/v3/components/OrCardCollectionV3/OrCardCollectionV3.js +48 -22
- package/dist/bundled/v3/components/OrCardCollectionV3/index.js +47 -21
- package/dist/bundled/v3/components/OrCardCollectionV3/props.js +16 -0
- package/dist/bundled/v3/components/OrCardCollectionV3/styles.js +30 -0
- package/dist/bundled/v3/components/OrCardCollectionView.vue2V3/OrCardCollectionView.vue2V3.js +41 -3
- package/dist/bundled/v3/components/OrCardCollectionView.vue3V3/OrCardCollectionView.vue3V3.js +2 -1
- package/dist/bundled/v3/components/OrCardV3/OrCardV3.js +4 -3
- package/dist/bundled/v3/components/OrCardV3/index.js +3 -2
- package/dist/bundled/v3/components/OrCardV3/styles.js +15 -0
- package/dist/bundled/v3/components/OrCarousel/OrCarousel.js +10 -7
- package/dist/bundled/v3/components/OrCarousel/constants.js +21 -0
- package/dist/bundled/v3/components/OrCarousel/index.js +9 -6
- package/dist/bundled/v3/components/OrCheckbox/OrCheckbox.js +9 -7
- package/dist/bundled/v3/components/OrCheckbox/index.js +8 -6
- package/dist/bundled/v3/components/OrCheckboxV3/OrCheckboxV3.js +7 -4
- package/dist/bundled/v3/components/OrCheckboxV3/index.js +6 -3
- package/dist/bundled/v3/components/OrCheckboxV3/styles.js +31 -0
- package/dist/bundled/v3/components/OrChip/OrChip.js +7 -5
- package/dist/bundled/v3/components/OrChips/OrChips.js +11 -8
- package/dist/bundled/v3/components/OrChips/constants.js +10 -0
- package/dist/bundled/v3/components/OrChips/index.js +10 -7
- package/dist/bundled/v3/components/OrChipsInput/OrChipsInput.js +105 -10
- package/dist/bundled/v3/components/OrCode/OrCode.js +18 -12
- package/dist/bundled/v3/components/OrCode/constants.js +11 -0
- package/dist/bundled/v3/components/OrCode/index.js +17 -11
- package/dist/bundled/v3/components/OrCode/lang.js +2 -0
- package/dist/bundled/v3/components/OrCollapse/OrCollapse.js +4 -4
- package/dist/bundled/v3/components/OrCollapse/index.js +3 -3
- package/dist/bundled/v3/components/OrColorPicker/OrColorPicker.js +8 -5
- package/dist/bundled/v3/components/OrColorPicker/constants.js +323 -0
- package/dist/bundled/v3/components/OrColorPicker/defultPalette.js +15 -0
- package/dist/bundled/v3/components/OrColorPicker/index.js +7 -4
- package/dist/bundled/v3/components/OrConfirm/OrConfirm.js +18 -14
- package/dist/bundled/v3/components/OrConfirm/index.js +17 -13
- package/dist/bundled/v3/components/OrConfirmV3/OrConfirmV3.js +42 -18
- package/dist/bundled/v3/components/OrConfirmV3/index.js +41 -17
- package/dist/bundled/v3/components/OrConfirmV3/props.js +7 -0
- package/dist/bundled/v3/components/OrConfirmV3/styles.js +45 -0
- package/dist/bundled/v3/components/OrDateTimePicker/OrDateTimePicker.js +17 -13
- package/dist/bundled/v3/components/OrDateTimePicker/constants.js +20 -0
- package/dist/bundled/v3/components/OrDateTimePicker/index.js +17 -13
- package/dist/bundled/v3/components/OrDateTimePickerCalendarItem/OrDateTimePickerCalendarItem.js +81 -5
- package/dist/bundled/v3/components/OrEmptyStateV3/OrEmptyStateV3.js +4 -2
- package/dist/bundled/v3/components/OrEmptyStateV3/index.js +3 -1
- package/dist/bundled/v3/components/OrEmptyStateV3/props.js +7 -0
- package/dist/bundled/v3/components/OrEmptyStateV3/styles.js +46 -0
- package/dist/bundled/v3/components/OrErrorTagV3/OrErrorTagV3.js +7 -4
- package/dist/bundled/v3/components/OrErrorTagV3/index.js +6 -3
- package/dist/bundled/v3/components/OrErrorTagV3/styles.js +17 -0
- package/dist/bundled/v3/components/OrErrorV3/OrErrorV3.js +4 -3
- package/dist/bundled/v3/components/OrErrorV3/index.js +3 -2
- package/dist/bundled/v3/components/OrErrorV3/styles.js +21 -0
- package/dist/bundled/v3/components/OrExpansionPanelV3/OrExpansionPanelV3.js +8 -4
- package/dist/bundled/v3/components/OrExpansionPanelV3/index.js +7 -3
- package/dist/bundled/v3/components/OrExpansionPanelV3/props.js +12 -0
- package/dist/bundled/v3/components/OrExpansionPanelV3/styles.js +49 -0
- package/dist/bundled/v3/components/OrFabV3/OrFabV3.js +8 -4
- package/dist/bundled/v3/components/OrFabV3/index.js +7 -3
- package/dist/bundled/v3/components/OrFabV3/props.js +7 -0
- package/dist/bundled/v3/components/OrFabV3/styles.js +19 -0
- package/dist/bundled/v3/components/OrFloating/OrFloating.js +5 -4
- package/dist/bundled/v3/components/OrFloating/constants.js +22 -0
- package/dist/bundled/v3/components/OrFloating/index.js +4 -3
- package/dist/bundled/v3/components/OrHintV3/OrHintV3.js +4 -3
- package/dist/bundled/v3/components/OrHintV3/index.js +3 -2
- package/dist/bundled/v3/components/OrHintV3/styles.js +21 -0
- package/dist/bundled/v3/components/OrIcon/OrIcon.js +8 -6
- package/dist/bundled/v3/components/OrIcon/constants.js +24 -0
- package/dist/bundled/v3/components/OrIcon/index.js +7 -5
- package/dist/bundled/v3/components/OrIconButtonV2/OrIconButtonV2.js +13 -10
- package/dist/bundled/v3/components/OrIconButtonV2/index.js +12 -9
- package/dist/bundled/v3/components/OrIconButtonV3/OrIconButtonV3.js +20 -10
- package/dist/bundled/v3/components/OrIconButtonV3/index.js +19 -9
- package/dist/bundled/v3/components/OrIconButtonV3/props.js +10 -0
- package/dist/bundled/v3/components/OrIconButtonV3/styles.js +48 -0
- package/dist/bundled/v3/components/OrIconV3/OrIconV3.js +5 -3
- package/dist/bundled/v3/components/OrIconV3/index.js +4 -2
- package/dist/bundled/v3/components/OrIconV3/props.js +17 -0
- package/dist/bundled/v3/components/OrIconV3/styles.js +44 -0
- package/dist/bundled/v3/components/OrInlineInputBoxV3/OrInlineInputBoxV3.js +5 -3
- package/dist/bundled/v3/components/OrInlineInputBoxV3/index.js +4 -2
- package/dist/bundled/v3/components/OrInlineInputBoxV3/props.js +7 -0
- package/dist/bundled/{v2/OrInlineInputBox-614a3bf6.js → v3/components/OrInlineInputBoxV3/styles.js} +1 -75
- package/dist/bundled/v3/components/OrInlineInputV3/OrInlineInputV3.js +30 -14
- package/dist/bundled/v3/components/OrInlineInputV3/index.js +29 -13
- package/dist/bundled/v3/components/OrInlineInputV3/props.js +9 -0
- package/dist/bundled/v3/components/OrInlineInputV3/styles.js +29 -0
- package/dist/bundled/v3/components/OrInlineTextEdit/OrInlineTextEdit.js +16 -12
- package/dist/bundled/v3/components/OrInlineTextEdit/constants.js +13 -0
- package/dist/bundled/v3/components/OrInlineTextEdit/index.js +15 -11
- package/dist/bundled/v3/components/OrInlineTextareaV3/OrInlineTextareaV3.js +29 -14
- package/dist/bundled/v3/components/OrInlineTextareaV3/index.js +28 -13
- package/dist/bundled/v3/components/OrInlineTextareaV3/styles.js +21 -0
- package/dist/bundled/v3/components/OrInput/OrInput.js +3 -3
- package/dist/bundled/v3/components/OrInputBoxV3/OrInputBoxV3.js +5 -3
- package/dist/bundled/v3/components/OrInputBoxV3/index.js +4 -2
- package/dist/bundled/v3/components/OrInputBoxV3/props.js +12 -0
- package/dist/bundled/{v2/OrInputBox-65544401.js → v3/components/OrInputBoxV3/styles.js} +1 -94
- package/dist/bundled/v3/components/OrInputV3/OrInputV3.js +33 -15
- package/dist/bundled/v3/components/OrInputV3/index.js +32 -14
- package/dist/bundled/v3/components/OrInputV3/props.js +11 -0
- package/dist/bundled/v3/components/OrInputV3/styles.js +14 -0
- package/dist/bundled/v3/components/OrInputs/index.js +18 -15
- package/dist/bundled/v3/components/OrLabelV3/OrLabelV3.js +5 -3
- package/dist/bundled/v3/components/OrLabelV3/index.js +4 -2
- package/dist/bundled/v3/components/OrLabelV3/props.js +7 -0
- package/dist/bundled/v3/components/OrLabelV3/styles.js +29 -0
- package/dist/bundled/v3/components/OrLinkV3/OrLinkV3.js +5 -3
- package/dist/bundled/v3/components/OrLinkV3/index.js +4 -2
- package/dist/bundled/v3/components/OrLinkV3/props.js +10 -0
- package/dist/bundled/v3/components/OrLinkV3/styles.js +26 -0
- package/dist/bundled/v3/components/OrList/OrList.js +15 -12
- package/dist/bundled/v3/components/OrList/index.js +14 -11
- package/dist/bundled/v3/components/OrListOfInputs/OrListOfInputs.js +17 -14
- package/dist/bundled/v3/components/OrListOfInputs/index.js +16 -13
- package/dist/bundled/v3/components/OrLoader/OrLoader.js +3 -2
- package/dist/bundled/v3/components/OrLoader/constants.js +8 -0
- package/dist/bundled/v3/components/OrLoader/index.js +2 -1
- package/dist/bundled/v3/components/OrLoaderV3/OrLoaderV3.js +5 -3
- package/dist/bundled/v3/components/OrLoaderV3/index.js +4 -2
- package/dist/bundled/v3/components/OrLoaderV3/props.js +18 -0
- package/dist/bundled/v3/components/OrLoaderV3/styles.js +17 -0
- package/dist/bundled/v3/components/OrMenuItemV3/OrMenuItemV3.js +7 -4
- package/dist/bundled/v3/components/OrMenuItemV3/index.js +6 -3
- package/dist/bundled/v3/components/OrMenuItemV3/styles.js +17 -0
- package/dist/bundled/v3/components/OrMenuV3/OrMenuV3.js +14 -8
- package/dist/bundled/v3/components/OrMenuV3/index.js +14 -8
- package/dist/bundled/v3/components/OrMenuV3/props.js +1 -0
- package/dist/bundled/v3/components/OrMenuV3/styles.js +10 -0
- package/dist/bundled/v3/components/OrModal/OrModal.js +15 -11
- package/dist/bundled/v3/components/OrModal/constants.js +10 -0
- package/dist/bundled/v3/components/OrModal/index.js +14 -10
- package/dist/bundled/v3/components/OrModalV3/OrModalV3.js +23 -11
- package/dist/bundled/v3/components/OrModalV3/index.js +22 -10
- package/dist/bundled/v3/components/OrModalV3/props.js +8 -0
- package/dist/bundled/v3/components/OrModalV3/styles.js +38 -0
- package/dist/bundled/v3/components/OrNotification/OrNotification.js +15 -11
- package/dist/bundled/v3/components/OrNotification/constants.js +14 -0
- package/dist/bundled/v3/components/OrNotification/index.js +14 -10
- package/dist/bundled/v3/components/OrNotificationV3/OrNotificationV3.js +23 -11
- package/dist/bundled/v3/components/OrNotificationV3/index.js +22 -10
- package/dist/bundled/v3/components/OrNotificationV3/props.js +9 -0
- package/dist/bundled/v3/components/OrNotificationV3/styles.js +59 -0
- package/dist/bundled/v3/components/OrNumberInput/OrNumberInput.js +5 -5
- package/dist/bundled/v3/components/OrOverflowMenu/OrOverflowMenu.js +15 -12
- package/dist/bundled/v3/components/OrOverflowMenu/index.js +14 -11
- package/dist/bundled/v3/components/OrOverflowMenuItem/OrOverflowMenuItem.js +11 -8
- package/dist/bundled/v3/components/OrOverlayV3/OrOverlayV3.js +6 -4
- package/dist/bundled/v3/components/OrOverlayV3/index.js +5 -3
- package/dist/bundled/v3/components/OrOverlayV3/styles.js +9 -0
- package/dist/bundled/v3/components/OrPassword/OrPassword.js +16 -13
- package/dist/bundled/v3/components/OrPopoverV3/OrPopoverV3.js +12 -7
- package/dist/bundled/v3/components/OrPopoverV3/index.js +11 -6
- package/dist/bundled/v3/components/OrPopoverV3/props.js +23 -0
- package/dist/bundled/v3/components/OrPopoverV3/styles.js +44 -0
- package/dist/bundled/v3/components/OrProgress/OrProgress.js +3 -2
- package/dist/bundled/v3/components/OrProgress/constants.js +15 -0
- package/dist/bundled/v3/components/OrProgress/index.js +2 -1
- package/dist/bundled/v3/components/OrProgressV3/OrProgressV3.js +6 -4
- package/dist/bundled/v3/components/OrProgressV3/index.js +5 -3
- package/dist/bundled/v3/components/OrProgressV3/props.js +15 -0
- package/dist/bundled/v3/components/OrProgressV3/styles.js +63 -0
- package/dist/bundled/v3/components/OrRadioV3/OrRadioV3.js +7 -4
- package/dist/bundled/v3/components/OrRadioV3/index.js +6 -3
- package/dist/bundled/v3/components/OrRadioV3/styles.js +31 -0
- package/dist/bundled/v3/components/OrSearch/OrSearch.js +15 -12
- package/dist/bundled/v3/components/OrSearchV3/OrSearchV3.js +34 -16
- package/dist/bundled/v3/components/OrSearchV3/index.js +33 -15
- package/dist/bundled/v3/components/OrSearchV3/props.js +1 -0
- package/dist/bundled/v3/components/OrSegmentedControlItemV3/OrSegmentedControlItemV3.js +2 -31
- package/dist/bundled/v3/components/OrSegmentedControlV3/OrSegmentedControlV3.js +5 -3
- package/dist/bundled/v3/components/OrSegmentedControlV3/index.js +4 -2
- package/dist/bundled/v3/components/OrSegmentedControlV3/props.js +7 -0
- package/dist/bundled/v3/components/OrSegmentedControlV3/styles.js +31 -0
- package/dist/bundled/v3/components/OrSelect/OrSelect.js +13 -10
- package/dist/bundled/{v2/constants-59507e57.js → v3/components/OrSelect/constants.js} +1 -1
- package/dist/bundled/v3/components/OrSelect/index.js +12 -9
- package/dist/bundled/v3/components/OrSelectContent/OrSelectContent.js +11 -8
- package/dist/bundled/v3/components/OrSelectContentEmpty/OrSelectContentEmpty.js +1 -1
- package/dist/bundled/v3/components/OrSelectContentOptions/OrSelectContentOptions.js +9 -7
- package/dist/bundled/v3/components/OrSelectInput/OrSelectInput.js +8 -6
- package/dist/bundled/v3/components/OrSelectInputValue/OrSelectInputValue.js +8 -6
- package/dist/bundled/v3/components/OrSelectMain/OrSelectMain.js +11 -8
- package/dist/bundled/v3/components/OrSelectOption/OrSelectOption.js +8 -6
- package/dist/bundled/v3/components/OrSelectSearchOptions/OrSelectSearchOptions.js +8 -6
- package/dist/bundled/v3/components/OrSelectV3/OrSelectV3.js +48 -22
- package/dist/bundled/v3/components/OrSelectV3/index.js +47 -21
- package/dist/bundled/v3/components/OrSelectV3/props.js +1 -0
- package/dist/bundled/v3/components/OrSelectV3/styles.js +37 -0
- package/dist/bundled/v3/components/OrSidebar/OrSidebar.js +3 -2
- package/dist/bundled/v3/components/OrSidebar/constants.js +7 -0
- package/dist/bundled/v3/components/OrSidebar/index.js +2 -1
- package/dist/bundled/v3/components/OrSidebarV3/OrSidebarV3.js +4 -2
- package/dist/bundled/v3/components/OrSidebarV3/index.js +3 -1
- package/dist/bundled/v3/components/OrSidebarV3/props.js +7 -0
- package/dist/bundled/v3/components/OrSidebarV3/styles.js +68 -0
- package/dist/bundled/v3/components/OrSkeleton/constants.js +12 -0
- package/dist/bundled/v3/components/OrSkeleton/index.js +5 -4
- package/dist/bundled/v3/components/OrSkeletonCircle/OrSkeletonCircle.js +3 -3
- package/dist/bundled/v3/components/OrSkeletonCircleV3/OrSkeletonCircleV3.js +5 -5
- package/dist/bundled/v3/components/OrSkeletonRect/OrSkeletonRect.js +3 -3
- package/dist/bundled/v3/components/OrSkeletonRectV3/OrSkeletonRectV3.js +5 -5
- package/dist/bundled/v3/components/OrSkeletonText/OrSkeletonText.js +4 -3
- package/dist/bundled/v3/components/OrSkeletonTextV3/OrSkeletonTextV3.js +5 -5
- package/dist/bundled/v3/components/OrSkeletonV3/index.js +6 -6
- package/dist/bundled/{v2/styles-ed564e39.js → v3/components/OrSkeletonV3/styles.js} +1 -1
- package/dist/bundled/v3/components/OrSlider/OrSlider.js +9 -7
- package/dist/bundled/v3/components/OrSlider/index.js +8 -6
- package/dist/bundled/v3/components/OrSortHeaderV3/OrSortHeaderV3.js +7 -4
- package/dist/bundled/v3/components/OrSortHeaderV3/index.js +6 -3
- package/dist/bundled/v3/components/OrSortHeaderV3/styles.js +15 -0
- package/dist/bundled/v3/components/OrStepper/OrStepper.js +13 -10
- package/dist/bundled/v3/components/OrStepper/index.js +12 -9
- package/dist/bundled/v3/components/OrStepperButtonOptions/OrStepperButtonOptions.js +11 -8
- package/dist/bundled/v3/components/OrStepperOptionHorizontal/OrStepperOptionHorizontal.js +11 -8
- package/dist/bundled/v3/components/OrStepperOptionVertical/OrStepperOptionVertical.js +11 -8
- package/dist/bundled/v3/components/OrSwitch/OrSwitch.js +4 -3
- package/dist/bundled/v3/components/OrSwitch/index.js +3 -2
- package/dist/bundled/v3/components/OrSwitchV3/OrSwitchV3.js +10 -5
- package/dist/bundled/v3/components/OrSwitchV3/index.js +9 -4
- package/dist/bundled/v3/components/OrSwitchV3/styles.js +51 -0
- package/dist/bundled/v3/components/OrTabV3/OrTabV3.js +4 -3
- package/dist/bundled/v3/components/OrTabV3/index.js +3 -2
- package/dist/bundled/v3/components/OrTabV3/styles.js +19 -0
- package/dist/bundled/v3/components/OrTabsV3/OrTabsV3.js +24 -12
- package/dist/bundled/v3/components/OrTabsV3/index.js +23 -11
- package/dist/bundled/v3/components/OrTabsV3/props.js +7 -0
- package/dist/bundled/v3/components/OrTabsV3/styles.js +19 -0
- package/dist/bundled/v3/components/OrTag/OrTag.js +13 -8
- package/dist/bundled/v3/components/OrTag/index.js +12 -7
- package/dist/bundled/v3/components/OrTagV3/OrTagV3.js +23 -11
- package/dist/bundled/v3/components/OrTagV3/index.js +22 -10
- package/dist/bundled/v3/components/OrTagV3/props.js +13 -0
- package/dist/bundled/v3/components/OrTagV3/styles.js +34 -0
- package/dist/bundled/v3/{constants-b4c183aa.js → components/OrTeleport/constants.js} +1 -1
- package/dist/bundled/v3/components/OrTeleport/index.js +1 -1
- package/dist/bundled/v3/components/OrTeleportVue2/OrTeleportVue2.js +1 -1
- package/dist/bundled/v3/components/OrTeleportVue3/OrTeleportVue3.js +1 -1
- package/dist/bundled/v3/components/OrTextV3/OrTextV3.js +4 -3
- package/dist/bundled/v3/components/OrTextV3/index.js +3 -2
- package/dist/bundled/v3/components/OrTextV3/styles.js +17 -0
- package/dist/bundled/v3/components/OrTextarea/OrTextarea.js +5 -5
- package/dist/bundled/v3/components/OrTextareaV3/OrTextareaV3.js +14 -7
- package/dist/bundled/v3/components/OrTextareaV3/index.js +13 -6
- package/dist/bundled/v3/components/OrTextareaV3/props.js +1 -0
- package/dist/bundled/v3/components/OrTextareaV3/styles.js +14 -0
- package/dist/bundled/v3/components/OrTextbox/OrTextbox.js +17 -13
- package/dist/bundled/v3/components/OrTextbox/constants.js +11 -0
- package/dist/bundled/v3/components/OrTextbox/index.js +16 -12
- package/dist/bundled/v3/components/OrToast/OrToast.js +15 -11
- package/dist/bundled/v3/components/OrToast/Timer.js +37 -0
- package/dist/bundled/v3/{constants-25998e4c.js → components/OrToast/constants.js} +1 -1
- package/dist/bundled/v3/components/OrToast/index.js +5 -3
- package/dist/bundled/{v2/useToastEventBus-578adc7c.js → v3/components/OrToast/useQueue.js} +1 -23
- package/dist/bundled/{v2/useToast-0c42015d.js → v3/components/OrToast/useToast.js} +5 -38
- package/dist/bundled/v3/components/OrToast/useToastEventBus.js +24 -0
- package/dist/bundled/v3/components/OrToastContainer/OrToastContainer.js +19 -14
- package/dist/bundled/v3/components/OrToastContainerV3/OrToastContainerV3.js +28 -14
- package/dist/bundled/v3/components/OrToastV3/OrToastV3.js +167 -16
- package/dist/bundled/v3/components/OrToastV3/Timer.js +37 -0
- package/dist/bundled/v3/components/OrToastV3/index.js +4 -2
- package/dist/bundled/v3/components/OrToastV3/props.js +1 -0
- package/dist/bundled/v3/components/OrToastV3/styles.js +64 -0
- package/dist/bundled/v3/{useToastEventBus-578adc7c.js → components/OrToastV3/useQueue.js} +1 -23
- package/dist/bundled/v3/{useToast-40bff6ec.js → components/OrToastV3/useToast.js} +5 -38
- package/dist/bundled/v3/components/OrToastV3/useToastEventBus.js +24 -0
- package/dist/bundled/v3/components/OrTooltip/OrTooltip.js +6 -5
- package/dist/bundled/v3/components/OrTooltip/index.js +5 -4
- package/dist/bundled/v3/components/OrTooltipV3/OrTooltipV3.js +14 -8
- package/dist/bundled/v3/components/OrTooltipV3/index.js +14 -8
- package/dist/bundled/v3/components/OrTooltipV3/props.js +1 -0
- package/dist/bundled/v3/components/OrTooltipV3/styles.js +46 -0
- package/dist/bundled/v3/components/OrTooltipWrapperV2/OrTooltipWrapperV2.js +5 -4
- package/dist/bundled/v3/components/index.js +204 -108
- package/dist/bundled/v3/directives/dropdown-close.js +15 -0
- package/dist/bundled/{v2/dropdown-open-0d314aa4.js → v3/directives/dropdown-open.js} +1 -13
- package/dist/bundled/v3/directives/index.js +2 -1
- package/dist/bundled/v3/hooks/index.js +6 -5
- package/dist/bundled/v3/{useClassAttribute-47fdb016.js → hooks/useClassAttribute.js} +1 -1
- package/dist/bundled/v3/{useElevation-31bfe1f6.js → hooks/useElevation.js} +2 -5
- package/dist/bundled/v3/{useOverflow-af6161c8.js → hooks/useOverflow.js} +1 -1
- package/dist/bundled/v3/hooks/useResponsive/index.js +1 -1
- package/dist/bundled/{v2/useResponsive-a02e95b7.js → v3/hooks/useResponsive/useResponsive.js} +1 -1
- package/dist/bundled/v3/{useToggle-29e4d7c7.js → hooks/useToggle.js} +1 -1
- package/dist/bundled/v3/index.js +205 -116
- package/dist/bundled/{v2/OrCode-62c3d816.js → v3/lang-d640563a.js} +254 -4336
- package/dist/bundled/v3/utils/constants/color.js +16 -0
- package/dist/bundled/v3/utils/constants/key-codes.js +16 -0
- package/dist/bundled/v3/utils/constants/poper.js +10 -0
- package/dist/bundled/v3/utils/constants/regex.js +49 -0
- package/dist/bundled/v3/{color-1f348774.js → utils/functions/color.js} +11 -32
- package/dist/bundled/v3/utils/functions/dom.js +167 -0
- package/dist/bundled/v3/utils/functions/hash.js +8 -0
- package/dist/bundled/v3/{px-to-rem-0b26b83e.js → utils/functions/px-to-rem.js} +1 -1
- package/dist/bundled/v3/utils/functions/text.js +9 -0
- package/dist/bundled/v3/utils/isVisible.js +5 -0
- package/package.json +2 -2
- package/dist/bundled/v2/OrAvatar-6268adbf.js +0 -116
- package/dist/bundled/v2/OrAvatar-bf65f9a9.js +0 -194
- package/dist/bundled/v2/OrButton-2ca1c3d6.js +0 -198
- package/dist/bundled/v2/OrButton-e28c7ff6.js +0 -192
- package/dist/bundled/v2/OrCardCollection-dc511c6a.js +0 -224
- package/dist/bundled/v2/OrCardCollection-f49f899c.js +0 -259
- package/dist/bundled/v2/OrCardCollectionView.vue2-56150344.js +0 -93
- package/dist/bundled/v2/OrChipsInput-8b18de32.js +0 -151
- package/dist/bundled/v2/OrColorPicker-99f6c9e0.js +0 -495
- package/dist/bundled/v2/OrConfirm-ba45ed78.js +0 -317
- package/dist/bundled/v2/OrDateTimePickerCalendarItem-9d83bb44.js +0 -130
- package/dist/bundled/v2/OrEmptyState-2481f13f.js +0 -158
- package/dist/bundled/v2/OrExpansionPanel-94bf7c43.js +0 -176
- package/dist/bundled/v2/OrFab-9921d745.js +0 -104
- package/dist/bundled/v2/OrFloating-0397263c.js +0 -209
- package/dist/bundled/v2/OrIcon-7e3098b7.js +0 -129
- package/dist/bundled/v2/OrIcon-d69f7e66.js +0 -178
- package/dist/bundled/v2/OrIconButton-69a3f0e3.js +0 -163
- package/dist/bundled/v2/OrInlineInput-cfc0b5e2.js +0 -363
- package/dist/bundled/v2/OrInlineTextEdit-9dfa5fd9.js +0 -400
- package/dist/bundled/v2/OrInput-f5a4e016.js +0 -386
- package/dist/bundled/v2/OrLabel-b26f4298.js +0 -124
- package/dist/bundled/v2/OrLink-bb7b075d.js +0 -120
- package/dist/bundled/v2/OrLoader-003941a2.js +0 -115
- package/dist/bundled/v2/OrLoader-5cf41b7d.js +0 -181
- package/dist/bundled/v2/OrModal-6ee4a641.js +0 -1463
- package/dist/bundled/v2/OrModal-cc607462.js +0 -169
- package/dist/bundled/v2/OrNotification-648598db.js +0 -173
- package/dist/bundled/v2/OrNotification-9b05b5b8.js +0 -143
- package/dist/bundled/v2/OrPopover-6750b9e2.js +0 -284
- package/dist/bundled/v2/OrProgress-005c516d.js +0 -317
- package/dist/bundled/v2/OrProgress-4ee24824.js +0 -227
- package/dist/bundled/v2/OrSegmentedControl-42ce2576.js +0 -131
- package/dist/bundled/v2/OrSidebar-7d6125bb.js +0 -150
- package/dist/bundled/v2/OrSidebar-fabc7bc9.js +0 -228
- package/dist/bundled/v2/OrSkeletonText-de14d2a1.js +0 -107
- package/dist/bundled/v2/OrTabs-67a73c3d.js +0 -232
- package/dist/bundled/v2/OrTag-75925f25.js +0 -164
- package/dist/bundled/v2/OrTextbox-b203d2d3.js +0 -529
- package/dist/bundled/v2/OrToast-feaa0a27.js +0 -241
- package/dist/bundled/v2/dom-a98e78cb.js +0 -59
- package/dist/bundled/v3/OrAvatar.vue_vue_type_script_lang-4f793db1.js +0 -147
- package/dist/bundled/v3/OrButton.vue_vue_type_script_lang-65924b87.js +0 -133
- package/dist/bundled/v3/OrCardCollectionView.vue3-27432e35.js +0 -69
- package/dist/bundled/v3/OrChipsInput-949fd28b.js +0 -106
- package/dist/bundled/v3/OrDateTimePickerCalendarItem-6c38b593.js +0 -99
- package/dist/bundled/v3/OrExpansionPanel.vue_vue_type_script_lang-efcd3cc1.js +0 -110
- package/dist/bundled/v3/OrIcon.vue_vue_type_script_lang-c13ec0ac.js +0 -94
- package/dist/bundled/v3/OrLabel.vue_vue_type_script_lang-55e01b7a.js +0 -77
- package/dist/bundled/v3/OrLink.vue_vue_type_script_lang-faa57156.js +0 -81
- package/dist/bundled/v3/OrNotification.vue_vue_type_script_lang-6a4fc666.js +0 -119
- package/dist/bundled/v3/OrToast-86bdb931.js +0 -210
- package/dist/bundled/v3/dom-a98e78cb.js +0 -59
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { defineComponent, ref } from 'vue-demi';
|
|
4
|
-
import script$3 from './components/OrTeleportVue3/OrTeleportVue3.js';
|
|
5
|
-
import './components/OrIconButtonV2/OrIconButtonV2.js';
|
|
6
|
-
import './components/OrModal/OrModal.js';
|
|
7
|
-
import { s as script$2 } from './OrModal.vue_vue_type_script_lang-a988003c.js';
|
|
8
|
-
import './components/OrError/OrError.js';
|
|
9
|
-
import './components/OrHint/OrHint.js';
|
|
10
|
-
import './components/OrLabel/OrLabel.js';
|
|
11
|
-
import { s as script$1 } from './OrIconButton.vue_vue_type_script_lang-71dd403b.js';
|
|
12
|
-
import { s as script$4 } from './OrError.vue_vue_type_script_lang-450321b8.js';
|
|
13
|
-
import { s as script$5 } from './OrHint.vue_vue_type_script_lang-5d628c6c.js';
|
|
14
|
-
import { s as script$6 } from './OrLabel.vue_vue_type_script_lang-95601b40.js';
|
|
1
|
+
import { OrCodeLanguages } from './components/OrCode/constants.js';
|
|
15
2
|
|
|
16
3
|
/**
|
|
17
4
|
The data structure for documents. @nonabstract
|
|
@@ -2422,9 +2409,9 @@ function extendTransaction(tr) {
|
|
|
2422
2409
|
}
|
|
2423
2410
|
return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
|
|
2424
2411
|
}
|
|
2425
|
-
const none$
|
|
2412
|
+
const none$2 = [];
|
|
2426
2413
|
function asArray$1(value) {
|
|
2427
|
-
return value == null ? none$
|
|
2414
|
+
return value == null ? none$2 : Array.isArray(value) ? value : [value];
|
|
2428
2415
|
}
|
|
2429
2416
|
|
|
2430
2417
|
/**
|
|
@@ -8217,12 +8204,12 @@ class BlockInfo {
|
|
|
8217
8204
|
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
|
|
8218
8205
|
}
|
|
8219
8206
|
}
|
|
8220
|
-
var QueryType
|
|
8207
|
+
var QueryType = /*@__PURE__*/function (QueryType) {
|
|
8221
8208
|
QueryType[QueryType["ByPos"] = 0] = "ByPos";
|
|
8222
8209
|
QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
|
|
8223
8210
|
QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
|
|
8224
8211
|
return QueryType;
|
|
8225
|
-
}(QueryType
|
|
8212
|
+
}(QueryType || (QueryType = {}));
|
|
8226
8213
|
const Epsilon = 1e-3;
|
|
8227
8214
|
class HeightMap {
|
|
8228
8215
|
constructor(length,
|
|
@@ -8268,15 +8255,15 @@ class HeightMap {
|
|
|
8268
8255
|
fromB,
|
|
8269
8256
|
toB
|
|
8270
8257
|
} = changes[i];
|
|
8271
|
-
let start = me.lineAt(fromA, QueryType
|
|
8272
|
-
let end = start.to >= toA ? start : me.lineAt(toA, QueryType
|
|
8258
|
+
let start = me.lineAt(fromA, QueryType.ByPosNoHeight, oldDoc, 0, 0);
|
|
8259
|
+
let end = start.to >= toA ? start : me.lineAt(toA, QueryType.ByPosNoHeight, oldDoc, 0, 0);
|
|
8273
8260
|
toB += end.to - toA;
|
|
8274
8261
|
toA = end.to;
|
|
8275
8262
|
while (i > 0 && start.from <= changes[i - 1].toA) {
|
|
8276
8263
|
fromA = changes[i - 1].fromA;
|
|
8277
8264
|
fromB = changes[i - 1].fromB;
|
|
8278
8265
|
i--;
|
|
8279
|
-
if (fromA < start.from) start = me.lineAt(fromA, QueryType
|
|
8266
|
+
if (fromA < start.from) start = me.lineAt(fromA, QueryType.ByPosNoHeight, oldDoc, 0, 0);
|
|
8280
8267
|
}
|
|
8281
8268
|
fromB += start.from - fromA;
|
|
8282
8269
|
fromA = start.from;
|
|
@@ -8409,8 +8396,8 @@ class HeightMapGap extends HeightMap {
|
|
|
8409
8396
|
return new BlockInfo(from, length, top + lineHeight * line, lineHeight, BlockType.Text);
|
|
8410
8397
|
}
|
|
8411
8398
|
lineAt(value, type, doc, top, offset) {
|
|
8412
|
-
if (type == QueryType
|
|
8413
|
-
if (type == QueryType
|
|
8399
|
+
if (type == QueryType.ByHeight) return this.blockAt(value, doc, top, offset);
|
|
8400
|
+
if (type == QueryType.ByPosNoHeight) {
|
|
8414
8401
|
let {
|
|
8415
8402
|
from,
|
|
8416
8403
|
to
|
|
@@ -8512,10 +8499,10 @@ class HeightMapBranch extends HeightMap {
|
|
|
8512
8499
|
lineAt(value, type, doc, top, offset) {
|
|
8513
8500
|
let rightTop = top + this.left.height,
|
|
8514
8501
|
rightOffset = offset + this.left.length + this.break;
|
|
8515
|
-
let left = type == QueryType
|
|
8502
|
+
let left = type == QueryType.ByHeight ? value < rightTop : value < rightOffset;
|
|
8516
8503
|
let base = left ? this.left.lineAt(value, type, doc, top, offset) : this.right.lineAt(value, type, doc, rightTop, rightOffset);
|
|
8517
8504
|
if (this.break || (left ? base.to < rightOffset : base.from > rightOffset)) return base;
|
|
8518
|
-
let subQuery = type == QueryType
|
|
8505
|
+
let subQuery = type == QueryType.ByPosNoHeight ? QueryType.ByPosNoHeight : QueryType.ByPos;
|
|
8519
8506
|
if (left) return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));else return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
|
|
8520
8507
|
}
|
|
8521
8508
|
forEachLine(from, to, doc, top, offset, f) {
|
|
@@ -8525,7 +8512,7 @@ class HeightMapBranch extends HeightMap {
|
|
|
8525
8512
|
if (from < rightOffset) this.left.forEachLine(from, to, doc, top, offset, f);
|
|
8526
8513
|
if (to >= rightOffset) this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
|
|
8527
8514
|
} else {
|
|
8528
|
-
let mid = this.lineAt(rightOffset, QueryType
|
|
8515
|
+
let mid = this.lineAt(rightOffset, QueryType.ByPos, doc, top, offset);
|
|
8529
8516
|
if (from < mid.from) this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
|
|
8530
8517
|
if (mid.to >= from && mid.from <= to) f(mid);
|
|
8531
8518
|
if (to > mid.to) this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
|
|
@@ -9003,7 +8990,7 @@ class ViewState {
|
|
|
9003
8990
|
visibleTop,
|
|
9004
8991
|
visibleBottom
|
|
9005
8992
|
} = this;
|
|
9006
|
-
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType
|
|
8993
|
+
let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType.ByHeight, doc, 0, 0).to);
|
|
9007
8994
|
// If scrollTarget is given, make sure the viewport includes that position
|
|
9008
8995
|
if (scrollTarget) {
|
|
9009
8996
|
let {
|
|
@@ -9011,10 +8998,10 @@ class ViewState {
|
|
|
9011
8998
|
} = scrollTarget.range;
|
|
9012
8999
|
if (head < viewport.from || head > viewport.to) {
|
|
9013
9000
|
let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
|
|
9014
|
-
let block = map.lineAt(head, QueryType
|
|
9001
|
+
let block = map.lineAt(head, QueryType.ByPos, doc, 0, 0),
|
|
9015
9002
|
topPos;
|
|
9016
9003
|
if (scrollTarget.y == "center") topPos = (block.top + block.bottom) / 2 - viewHeight / 2;else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from) topPos = block.top;else topPos = block.bottom - viewHeight;
|
|
9017
|
-
viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType
|
|
9004
|
+
viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType.ByHeight, doc, 0, 0).to);
|
|
9018
9005
|
}
|
|
9019
9006
|
}
|
|
9020
9007
|
return viewport;
|
|
@@ -9022,7 +9009,7 @@ class ViewState {
|
|
|
9022
9009
|
mapViewport(viewport, changes) {
|
|
9023
9010
|
let from = changes.mapPos(viewport.from, -1),
|
|
9024
9011
|
to = changes.mapPos(viewport.to, 1);
|
|
9025
|
-
return new Viewport(this.heightMap.lineAt(from, QueryType
|
|
9012
|
+
return new Viewport(this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0).to);
|
|
9026
9013
|
}
|
|
9027
9014
|
// Checks if a given viewport covers the visible part of the
|
|
9028
9015
|
// document and not too much beyond that.
|
|
@@ -9033,10 +9020,10 @@ class ViewState {
|
|
|
9033
9020
|
if (!this.inView) return true;
|
|
9034
9021
|
let {
|
|
9035
9022
|
top
|
|
9036
|
-
} = this.heightMap.lineAt(from, QueryType
|
|
9023
|
+
} = this.heightMap.lineAt(from, QueryType.ByPos, this.state.doc, 0, 0);
|
|
9037
9024
|
let {
|
|
9038
9025
|
bottom
|
|
9039
|
-
} = this.heightMap.lineAt(to, QueryType
|
|
9026
|
+
} = this.heightMap.lineAt(to, QueryType.ByPos, this.state.doc, 0, 0);
|
|
9040
9027
|
let {
|
|
9041
9028
|
visibleTop,
|
|
9042
9029
|
visibleBottom
|
|
@@ -9161,10 +9148,10 @@ class ViewState {
|
|
|
9161
9148
|
return changed ? 4 /* UpdateFlag.Viewport */ : 0;
|
|
9162
9149
|
}
|
|
9163
9150
|
lineBlockAt(pos) {
|
|
9164
|
-
return pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos) || scaleBlock(this.heightMap.lineAt(pos, QueryType
|
|
9151
|
+
return pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos) || scaleBlock(this.heightMap.lineAt(pos, QueryType.ByPos, this.state.doc, 0, 0), this.scaler);
|
|
9165
9152
|
}
|
|
9166
9153
|
lineBlockAtHeight(height) {
|
|
9167
|
-
return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType
|
|
9154
|
+
return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.state.doc, 0, 0), this.scaler);
|
|
9168
9155
|
}
|
|
9169
9156
|
elementAtHeight(height) {
|
|
9170
9157
|
return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
|
|
@@ -9269,8 +9256,8 @@ class BigScaler {
|
|
|
9269
9256
|
from,
|
|
9270
9257
|
to
|
|
9271
9258
|
}) => {
|
|
9272
|
-
let top = heightMap.lineAt(from, QueryType
|
|
9273
|
-
let bottom = heightMap.lineAt(to, QueryType
|
|
9259
|
+
let top = heightMap.lineAt(from, QueryType.ByPos, doc, 0, 0).top;
|
|
9260
|
+
let bottom = heightMap.lineAt(to, QueryType.ByPos, doc, 0, 0).bottom;
|
|
9274
9261
|
vpHeight += bottom - top;
|
|
9275
9262
|
return {
|
|
9276
9263
|
from,
|
|
@@ -9337,7 +9324,7 @@ function buildTheme(main, spec, scopes) {
|
|
|
9337
9324
|
}
|
|
9338
9325
|
});
|
|
9339
9326
|
}
|
|
9340
|
-
const baseTheme$1$
|
|
9327
|
+
const baseTheme$1$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
9341
9328
|
"&": {
|
|
9342
9329
|
position: "relative !important",
|
|
9343
9330
|
boxSizing: "border-box",
|
|
@@ -10643,7 +10630,7 @@ class EditorView {
|
|
|
10643
10630
|
}
|
|
10644
10631
|
mountStyles() {
|
|
10645
10632
|
this.styleModules = this.state.facet(styleModule);
|
|
10646
|
-
StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$
|
|
10633
|
+
StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$1).reverse());
|
|
10647
10634
|
}
|
|
10648
10635
|
readMeasured() {
|
|
10649
10636
|
if (this.updateState == 2 /* UpdateState.Updating */) throw new Error("Reading the editor layout isn't allowed during an update");
|
|
@@ -12452,7 +12439,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
12452
12439
|
}
|
|
12453
12440
|
}
|
|
12454
12441
|
});
|
|
12455
|
-
const baseTheme$
|
|
12442
|
+
const baseTheme$3 = /*@__PURE__*/EditorView.baseTheme({
|
|
12456
12443
|
".cm-tooltip": {
|
|
12457
12444
|
zIndex: 100,
|
|
12458
12445
|
boxSizing: "border-box"
|
|
@@ -12522,7 +12509,7 @@ const noOffset = {
|
|
|
12522
12509
|
Facet to which an extension can add a value to show a tooltip.
|
|
12523
12510
|
*/
|
|
12524
12511
|
const showTooltip = /*@__PURE__*/Facet.define({
|
|
12525
|
-
enables: [tooltipPlugin, baseTheme$
|
|
12512
|
+
enables: [tooltipPlugin, baseTheme$3]
|
|
12526
12513
|
});
|
|
12527
12514
|
const showHoverTooltip = /*@__PURE__*/Facet.define();
|
|
12528
12515
|
class HoverTooltipHost {
|
|
@@ -17323,7 +17310,7 @@ const foldConfig = /*@__PURE__*/Facet.define({
|
|
|
17323
17310
|
Create an extension that configures code folding.
|
|
17324
17311
|
*/
|
|
17325
17312
|
function codeFolding(config) {
|
|
17326
|
-
let result = [foldState, baseTheme$1
|
|
17313
|
+
let result = [foldState, baseTheme$1];
|
|
17327
17314
|
if (config) result.push(foldConfig.of(config));
|
|
17328
17315
|
return result;
|
|
17329
17316
|
}
|
|
@@ -17437,7 +17424,7 @@ function foldGutter(config = {}) {
|
|
|
17437
17424
|
})
|
|
17438
17425
|
}), codeFolding()];
|
|
17439
17426
|
}
|
|
17440
|
-
const baseTheme$1
|
|
17427
|
+
const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
|
|
17441
17428
|
".cm-foldPlaceholder": {
|
|
17442
17429
|
backgroundColor: "#eee",
|
|
17443
17430
|
border: "1px solid #ddd",
|
|
@@ -17630,7 +17617,7 @@ const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([{
|
|
|
17630
17617
|
tag: tags$1.invalid,
|
|
17631
17618
|
color: "#f00"
|
|
17632
17619
|
}]);
|
|
17633
|
-
const baseTheme$
|
|
17620
|
+
const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
|
|
17634
17621
|
"&.cm-focused .cm-matchingBracket": {
|
|
17635
17622
|
backgroundColor: "#328c8252"
|
|
17636
17623
|
},
|
|
@@ -17680,7 +17667,7 @@ const bracketMatchingState = /*@__PURE__*/StateField.define({
|
|
|
17680
17667
|
},
|
|
17681
17668
|
provide: f => EditorView.decorations.from(f)
|
|
17682
17669
|
});
|
|
17683
|
-
const bracketMatchingUnique = [bracketMatchingState, baseTheme$
|
|
17670
|
+
const bracketMatchingUnique = [bracketMatchingState, baseTheme$2];
|
|
17684
17671
|
/**
|
|
17685
17672
|
Create an extension that enables bracket matching. Whenever the
|
|
17686
17673
|
cursor is next to a bracket, that bracket and the one it matches
|
|
@@ -17851,3235 +17838,170 @@ function createTokenType(extra, tagStr) {
|
|
|
17851
17838
|
}
|
|
17852
17839
|
|
|
17853
17840
|
/**
|
|
17854
|
-
|
|
17855
|
-
if available, otherwise falling back to block comments.
|
|
17856
|
-
*/
|
|
17857
|
-
const toggleComment = target => {
|
|
17858
|
-
let {
|
|
17859
|
-
state
|
|
17860
|
-
} = target,
|
|
17861
|
-
line = state.doc.lineAt(state.selection.main.head),
|
|
17862
|
-
config = getConfig(target.state, line.from);
|
|
17863
|
-
return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
|
|
17864
|
-
};
|
|
17865
|
-
function command(f, option) {
|
|
17866
|
-
return ({
|
|
17867
|
-
state,
|
|
17868
|
-
dispatch
|
|
17869
|
-
}) => {
|
|
17870
|
-
if (state.readOnly) return false;
|
|
17871
|
-
let tr = f(option, state);
|
|
17872
|
-
if (!tr) return false;
|
|
17873
|
-
dispatch(state.update(tr));
|
|
17874
|
-
return true;
|
|
17875
|
-
};
|
|
17876
|
-
}
|
|
17877
|
-
/**
|
|
17878
|
-
Comment or uncomment the current selection using line comments.
|
|
17879
|
-
The line comment syntax is taken from the
|
|
17880
|
-
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
|
17881
|
-
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
|
17882
|
-
*/
|
|
17883
|
-
const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */);
|
|
17884
|
-
/**
|
|
17885
|
-
Comment or uncomment the current selection using block comments.
|
|
17886
|
-
The block comment syntax is taken from the
|
|
17887
|
-
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
|
17888
|
-
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
|
17889
|
-
*/
|
|
17890
|
-
const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */);
|
|
17891
|
-
/**
|
|
17892
|
-
Comment or uncomment the lines around the current selection using
|
|
17893
|
-
block comments.
|
|
17894
|
-
*/
|
|
17895
|
-
const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);
|
|
17896
|
-
function getConfig(state, pos) {
|
|
17897
|
-
let data = state.languageDataAt("commentTokens", pos);
|
|
17898
|
-
return data.length ? data[0] : {};
|
|
17899
|
-
}
|
|
17900
|
-
const SearchMargin = 50;
|
|
17901
|
-
/**
|
|
17902
|
-
Determines if the given range is block-commented in the given
|
|
17903
|
-
state.
|
|
17841
|
+
An instance of this is passed to completion source functions.
|
|
17904
17842
|
*/
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17843
|
+
class CompletionContext {
|
|
17844
|
+
/**
|
|
17845
|
+
Create a new completion context. (Mostly useful for testing
|
|
17846
|
+
completion sources—in the editor, the extension will create
|
|
17847
|
+
these for you.)
|
|
17848
|
+
*/
|
|
17849
|
+
constructor(
|
|
17850
|
+
/**
|
|
17851
|
+
The editor state that the completion happens in.
|
|
17852
|
+
*/
|
|
17853
|
+
state,
|
|
17854
|
+
/**
|
|
17855
|
+
The position at which the completion is happening.
|
|
17856
|
+
*/
|
|
17857
|
+
pos,
|
|
17858
|
+
/**
|
|
17859
|
+
Indicates whether completion was activated explicitly, or
|
|
17860
|
+
implicitly by typing. The usual way to respond to this is to
|
|
17861
|
+
only return completions when either there is part of a
|
|
17862
|
+
completable entity before the cursor, or `explicit` is true.
|
|
17863
|
+
*/
|
|
17864
|
+
explicit) {
|
|
17865
|
+
this.state = state;
|
|
17866
|
+
this.pos = pos;
|
|
17867
|
+
this.explicit = explicit;
|
|
17868
|
+
/**
|
|
17869
|
+
@internal
|
|
17870
|
+
*/
|
|
17871
|
+
this.abortListeners = [];
|
|
17925
17872
|
}
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17873
|
+
/**
|
|
17874
|
+
Get the extent, content, and (if there is a token) type of the
|
|
17875
|
+
token before `this.pos`.
|
|
17876
|
+
*/
|
|
17877
|
+
tokenBefore(types) {
|
|
17878
|
+
let token = syntaxTree(this.state).resolveInner(this.pos, -1);
|
|
17879
|
+
while (token && types.indexOf(token.name) < 0) token = token.parent;
|
|
17880
|
+
return token ? {
|
|
17881
|
+
from: token.from,
|
|
17882
|
+
to: this.pos,
|
|
17883
|
+
text: this.state.sliceDoc(token.from, this.pos),
|
|
17884
|
+
type: token.type
|
|
17885
|
+
} : null;
|
|
17932
17886
|
}
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17887
|
+
/**
|
|
17888
|
+
Get the match of the given expression directly before the
|
|
17889
|
+
cursor.
|
|
17890
|
+
*/
|
|
17891
|
+
matchBefore(expr) {
|
|
17892
|
+
let line = this.state.doc.lineAt(this.pos);
|
|
17893
|
+
let start = Math.max(line.from, this.pos - 250);
|
|
17894
|
+
let str = line.text.slice(start - line.from, this.pos - line.from);
|
|
17895
|
+
let found = str.search(ensureAnchor(expr, false));
|
|
17896
|
+
return found < 0 ? null : {
|
|
17897
|
+
from: start + found,
|
|
17898
|
+
to: this.pos,
|
|
17899
|
+
text: str.slice(found)
|
|
17946
17900
|
};
|
|
17947
17901
|
}
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
|
|
17955
|
-
let last = ranges.length - 1;
|
|
17956
|
-
if (last >= 0 && ranges[last].to > fromLine.from) ranges[last].to = toLine.to;else ranges.push({
|
|
17957
|
-
from: fromLine.from,
|
|
17958
|
-
to: toLine.to
|
|
17959
|
-
});
|
|
17902
|
+
/**
|
|
17903
|
+
Yields true when the query has been aborted. Can be useful in
|
|
17904
|
+
asynchronous queries to avoid doing work that will be ignored.
|
|
17905
|
+
*/
|
|
17906
|
+
get aborted() {
|
|
17907
|
+
return this.abortListeners == null;
|
|
17960
17908
|
}
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
|
|
17968
|
-
let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
|
|
17969
|
-
if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {
|
|
17970
|
-
return {
|
|
17971
|
-
changes: state.changes(ranges.map((range, i) => {
|
|
17972
|
-
if (comments[i]) return [];
|
|
17973
|
-
return [{
|
|
17974
|
-
from: range.from,
|
|
17975
|
-
insert: tokens[i].open + " "
|
|
17976
|
-
}, {
|
|
17977
|
-
from: range.to,
|
|
17978
|
-
insert: " " + tokens[i].close
|
|
17979
|
-
}];
|
|
17980
|
-
}))
|
|
17981
|
-
};
|
|
17982
|
-
} else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {
|
|
17983
|
-
let changes = [];
|
|
17984
|
-
for (let i = 0, comment; i < comments.length; i++) if (comment = comments[i]) {
|
|
17985
|
-
let token = tokens[i],
|
|
17986
|
-
{
|
|
17987
|
-
open,
|
|
17988
|
-
close
|
|
17989
|
-
} = comment;
|
|
17990
|
-
changes.push({
|
|
17991
|
-
from: open.pos - token.open.length,
|
|
17992
|
-
to: open.pos + open.margin
|
|
17993
|
-
}, {
|
|
17994
|
-
from: close.pos - close.margin,
|
|
17995
|
-
to: close.pos + token.close.length
|
|
17996
|
-
});
|
|
17997
|
-
}
|
|
17998
|
-
return {
|
|
17999
|
-
changes
|
|
18000
|
-
};
|
|
17909
|
+
/**
|
|
17910
|
+
Allows you to register abort handlers, which will be called when
|
|
17911
|
+
the query is
|
|
17912
|
+
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
|
|
17913
|
+
*/
|
|
17914
|
+
addEventListener(type, listener) {
|
|
17915
|
+
if (type == "abort" && this.abortListeners) this.abortListeners.push(listener);
|
|
18001
17916
|
}
|
|
18002
|
-
return null;
|
|
18003
17917
|
}
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
let
|
|
18007
|
-
|
|
17918
|
+
function toSet(chars) {
|
|
17919
|
+
let flat = Object.keys(chars).join("");
|
|
17920
|
+
let words = /\w/.test(flat);
|
|
17921
|
+
if (words) flat = flat.replace(/\w/g, "");
|
|
17922
|
+
return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
|
|
17923
|
+
}
|
|
17924
|
+
function prefixMatch(options) {
|
|
17925
|
+
let first = Object.create(null),
|
|
17926
|
+
rest = Object.create(null);
|
|
18008
17927
|
for (let {
|
|
18009
|
-
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
let
|
|
18013
|
-
minIndent = 1e9;
|
|
18014
|
-
for (let pos = from; pos <= to;) {
|
|
18015
|
-
let line = state.doc.lineAt(pos);
|
|
18016
|
-
if (line.from > prevLine && (from == to || to > line.from)) {
|
|
18017
|
-
prevLine = line.from;
|
|
18018
|
-
let token = getConfig(state, line.from).line;
|
|
18019
|
-
if (!token) continue;
|
|
18020
|
-
let indent = /^\s*/.exec(line.text)[0].length;
|
|
18021
|
-
let empty = indent == line.length;
|
|
18022
|
-
let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
|
|
18023
|
-
if (indent < line.text.length && indent < minIndent) minIndent = indent;
|
|
18024
|
-
lines.push({
|
|
18025
|
-
line,
|
|
18026
|
-
comment,
|
|
18027
|
-
token,
|
|
18028
|
-
indent,
|
|
18029
|
-
empty,
|
|
18030
|
-
single: false
|
|
18031
|
-
});
|
|
18032
|
-
}
|
|
18033
|
-
pos = line.to + 1;
|
|
18034
|
-
}
|
|
18035
|
-
if (minIndent < 1e9) for (let i = startI; i < lines.length; i++) if (lines[i].indent < lines[i].line.text.length) lines[i].indent = minIndent;
|
|
18036
|
-
if (lines.length == startI + 1) lines[startI].single = true;
|
|
18037
|
-
}
|
|
18038
|
-
if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
|
|
18039
|
-
let changes = [];
|
|
18040
|
-
for (let {
|
|
18041
|
-
line,
|
|
18042
|
-
token,
|
|
18043
|
-
indent,
|
|
18044
|
-
empty,
|
|
18045
|
-
single
|
|
18046
|
-
} of lines) if (single || !empty) changes.push({
|
|
18047
|
-
from: line.from + indent,
|
|
18048
|
-
insert: token + " "
|
|
18049
|
-
});
|
|
18050
|
-
let changeSet = state.changes(changes);
|
|
18051
|
-
return {
|
|
18052
|
-
changes: changeSet,
|
|
18053
|
-
selection: state.selection.map(changeSet, 1)
|
|
18054
|
-
};
|
|
18055
|
-
} else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {
|
|
18056
|
-
let changes = [];
|
|
18057
|
-
for (let {
|
|
18058
|
-
line,
|
|
18059
|
-
comment,
|
|
18060
|
-
token
|
|
18061
|
-
} of lines) if (comment >= 0) {
|
|
18062
|
-
let from = line.from + comment,
|
|
18063
|
-
to = from + token.length;
|
|
18064
|
-
if (line.text[to - line.from] == " ") to++;
|
|
18065
|
-
changes.push({
|
|
18066
|
-
from,
|
|
18067
|
-
to
|
|
18068
|
-
});
|
|
18069
|
-
}
|
|
18070
|
-
return {
|
|
18071
|
-
changes
|
|
18072
|
-
};
|
|
17928
|
+
label
|
|
17929
|
+
} of options) {
|
|
17930
|
+
first[label[0]] = true;
|
|
17931
|
+
for (let i = 1; i < label.length; i++) rest[label[i]] = true;
|
|
18073
17932
|
}
|
|
18074
|
-
|
|
17933
|
+
let source = toSet(first) + toSet(rest) + "*$";
|
|
17934
|
+
return [new RegExp("^" + source), new RegExp(source)];
|
|
18075
17935
|
}
|
|
18076
|
-
const fromHistory = /*@__PURE__*/Annotation.define();
|
|
18077
17936
|
/**
|
|
18078
|
-
|
|
18079
|
-
|
|
18080
|
-
`"before"`, it'll prevent merging with previous transactions. With
|
|
18081
|
-
`"after"`, subsequent transactions won't be combined with this
|
|
18082
|
-
one. With `"full"`, the transaction is isolated on both sides.
|
|
17937
|
+
Given a a fixed array of options, return an autocompleter that
|
|
17938
|
+
completes them.
|
|
18083
17939
|
*/
|
|
18084
|
-
|
|
17940
|
+
function completeFromList(list) {
|
|
17941
|
+
let options = list.map(o => typeof o == "string" ? {
|
|
17942
|
+
label: o
|
|
17943
|
+
} : o);
|
|
17944
|
+
let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options);
|
|
17945
|
+
return context => {
|
|
17946
|
+
let token = context.matchBefore(match);
|
|
17947
|
+
return token || context.explicit ? {
|
|
17948
|
+
from: token ? token.from : context.pos,
|
|
17949
|
+
options,
|
|
17950
|
+
validFor
|
|
17951
|
+
} : null;
|
|
17952
|
+
};
|
|
17953
|
+
}
|
|
18085
17954
|
/**
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
store when inverting the transaction. This can be used to
|
|
18089
|
-
integrate some kinds of effects in the history, so that they can
|
|
18090
|
-
be undone (and redone again).
|
|
17955
|
+
Wrap the given completion source so that it will not fire when the
|
|
17956
|
+
cursor is in a syntax node with one of the given names.
|
|
18091
17957
|
*/
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
return
|
|
18096
|
-
|
|
18097
|
-
newGroupDelay: 500,
|
|
18098
|
-
joinToEvent: (_t, isAdjacent) => isAdjacent
|
|
18099
|
-
}, {
|
|
18100
|
-
minDepth: Math.max,
|
|
18101
|
-
newGroupDelay: Math.min,
|
|
18102
|
-
joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj)
|
|
18103
|
-
});
|
|
18104
|
-
}
|
|
18105
|
-
});
|
|
18106
|
-
function changeEnd(changes) {
|
|
18107
|
-
let end = 0;
|
|
18108
|
-
changes.iterChangedRanges((_, to) => end = to);
|
|
18109
|
-
return end;
|
|
17958
|
+
function ifNotIn(nodes, source) {
|
|
17959
|
+
return context => {
|
|
17960
|
+
for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) if (nodes.indexOf(pos.name) > -1) return null;
|
|
17961
|
+
return source(context);
|
|
17962
|
+
};
|
|
18110
17963
|
}
|
|
18111
|
-
|
|
18112
|
-
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
let config = tr.state.facet(historyConfig);
|
|
18117
|
-
let fromHist = tr.annotation(fromHistory);
|
|
18118
|
-
if (fromHist) {
|
|
18119
|
-
let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;
|
|
18120
|
-
let item = HistEvent.fromTransaction(tr, selection),
|
|
18121
|
-
from = fromHist.side;
|
|
18122
|
-
let other = from == 0 /* BranchName.Done */ ? state.undone : state.done;
|
|
18123
|
-
if (item) other = updateBranch(other, other.length, config.minDepth, item);else other = addSelection(other, tr.startState.selection);
|
|
18124
|
-
return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);
|
|
18125
|
-
}
|
|
18126
|
-
let isolate = tr.annotation(isolateHistory);
|
|
18127
|
-
if (isolate == "full" || isolate == "before") state = state.isolate();
|
|
18128
|
-
if (tr.annotation(Transaction.addToHistory) === false) return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;
|
|
18129
|
-
let event = HistEvent.fromTransaction(tr);
|
|
18130
|
-
let time = tr.annotation(Transaction.time),
|
|
18131
|
-
userEvent = tr.annotation(Transaction.userEvent);
|
|
18132
|
-
if (event) state = state.addChanges(event, time, userEvent, config, tr);else if (tr.selection) state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
|
|
18133
|
-
if (isolate == "full" || isolate == "after") state = state.isolate();
|
|
18134
|
-
return state;
|
|
18135
|
-
},
|
|
18136
|
-
toJSON(value) {
|
|
18137
|
-
return {
|
|
18138
|
-
done: value.done.map(e => e.toJSON()),
|
|
18139
|
-
undone: value.undone.map(e => e.toJSON())
|
|
18140
|
-
};
|
|
18141
|
-
},
|
|
18142
|
-
fromJSON(json) {
|
|
18143
|
-
return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));
|
|
17964
|
+
class Option {
|
|
17965
|
+
constructor(completion, source, match) {
|
|
17966
|
+
this.completion = completion;
|
|
17967
|
+
this.source = source;
|
|
17968
|
+
this.match = match;
|
|
18144
17969
|
}
|
|
18145
|
-
});
|
|
18146
|
-
/**
|
|
18147
|
-
Create a history extension with the given configuration.
|
|
18148
|
-
*/
|
|
18149
|
-
function history(config = {}) {
|
|
18150
|
-
return [historyField_, historyConfig.of(config), EditorView.domEventHandlers({
|
|
18151
|
-
beforeinput(e, view) {
|
|
18152
|
-
let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null;
|
|
18153
|
-
if (!command) return false;
|
|
18154
|
-
e.preventDefault();
|
|
18155
|
-
return command(view);
|
|
18156
|
-
}
|
|
18157
|
-
})];
|
|
18158
17970
|
}
|
|
18159
|
-
function
|
|
18160
|
-
return
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18165
|
-
|
|
18166
|
-
|
|
18167
|
-
|
|
18168
|
-
|
|
18169
|
-
|
|
18170
|
-
|
|
18171
|
-
|
|
17971
|
+
function cur(state) {
|
|
17972
|
+
return state.selection.main.head;
|
|
17973
|
+
}
|
|
17974
|
+
// Make sure the given regexp has a $ at its end and, if `start` is
|
|
17975
|
+
// true, a ^ at its start.
|
|
17976
|
+
function ensureAnchor(expr, start) {
|
|
17977
|
+
var _a;
|
|
17978
|
+
let {
|
|
17979
|
+
source
|
|
17980
|
+
} = expr;
|
|
17981
|
+
let addStart = start && source[0] != "^",
|
|
17982
|
+
addEnd = source[source.length - 1] != "$";
|
|
17983
|
+
if (!addStart && !addEnd) return expr;
|
|
17984
|
+
return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : expr.ignoreCase ? "i" : "");
|
|
18172
17985
|
}
|
|
18173
17986
|
/**
|
|
18174
|
-
|
|
18175
|
-
|
|
18176
|
-
*/
|
|
18177
|
-
const undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false);
|
|
18178
|
-
/**
|
|
18179
|
-
Redo a group of history events. Returns false if no group was
|
|
18180
|
-
available.
|
|
18181
|
-
*/
|
|
18182
|
-
const redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false);
|
|
18183
|
-
/**
|
|
18184
|
-
Undo a change or selection change.
|
|
17987
|
+
This annotation is added to transactions that are produced by
|
|
17988
|
+
picking a completion.
|
|
18185
17989
|
*/
|
|
18186
|
-
const
|
|
17990
|
+
const pickedCompletion = /*@__PURE__*/Annotation.define();
|
|
18187
17991
|
/**
|
|
18188
|
-
|
|
17992
|
+
Helper function that returns a transaction spec which inserts a
|
|
17993
|
+
completion's text in the main selection range, and any other
|
|
17994
|
+
selection range that has the same text in front of it.
|
|
18189
17995
|
*/
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
// changes == startSelection == undefined
|
|
18200
|
-
changes,
|
|
18201
|
-
// The effects associated with this event
|
|
18202
|
-
effects,
|
|
18203
|
-
// Accumulated mapping (from addToHistory==false) that should be
|
|
18204
|
-
// applied to events below this one.
|
|
18205
|
-
mapped,
|
|
18206
|
-
// The selection before this event
|
|
18207
|
-
startSelection,
|
|
18208
|
-
// Stores selection changes after this event, to be used for
|
|
18209
|
-
// selection undo/redo.
|
|
18210
|
-
selectionsAfter) {
|
|
18211
|
-
this.changes = changes;
|
|
18212
|
-
this.effects = effects;
|
|
18213
|
-
this.mapped = mapped;
|
|
18214
|
-
this.startSelection = startSelection;
|
|
18215
|
-
this.selectionsAfter = selectionsAfter;
|
|
18216
|
-
}
|
|
18217
|
-
setSelAfter(after) {
|
|
18218
|
-
return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);
|
|
18219
|
-
}
|
|
18220
|
-
toJSON() {
|
|
18221
|
-
var _a, _b, _c;
|
|
18222
|
-
return {
|
|
18223
|
-
changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),
|
|
18224
|
-
mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),
|
|
18225
|
-
startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),
|
|
18226
|
-
selectionsAfter: this.selectionsAfter.map(s => s.toJSON())
|
|
18227
|
-
};
|
|
18228
|
-
}
|
|
18229
|
-
static fromJSON(json) {
|
|
18230
|
-
return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.fromJSON));
|
|
18231
|
-
}
|
|
18232
|
-
// This does not check `addToHistory` and such, it assumes the
|
|
18233
|
-
// transaction needs to be converted to an item. Returns null when
|
|
18234
|
-
// there are no changes or effects in the transaction.
|
|
18235
|
-
static fromTransaction(tr, selection) {
|
|
18236
|
-
let effects = none$2;
|
|
18237
|
-
for (let invert of tr.startState.facet(invertedEffects)) {
|
|
18238
|
-
let result = invert(tr);
|
|
18239
|
-
if (result.length) effects = effects.concat(result);
|
|
18240
|
-
}
|
|
18241
|
-
if (!effects.length && tr.changes.empty) return null;
|
|
18242
|
-
return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none$2);
|
|
18243
|
-
}
|
|
18244
|
-
static selection(selections) {
|
|
18245
|
-
return new HistEvent(undefined, none$2, undefined, undefined, selections);
|
|
18246
|
-
}
|
|
18247
|
-
}
|
|
18248
|
-
function updateBranch(branch, to, maxLen, newEvent) {
|
|
18249
|
-
let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;
|
|
18250
|
-
let newBranch = branch.slice(start, to);
|
|
18251
|
-
newBranch.push(newEvent);
|
|
18252
|
-
return newBranch;
|
|
18253
|
-
}
|
|
18254
|
-
function isAdjacent(a, b) {
|
|
18255
|
-
let ranges = [],
|
|
18256
|
-
isAdjacent = false;
|
|
18257
|
-
a.iterChangedRanges((f, t) => ranges.push(f, t));
|
|
18258
|
-
b.iterChangedRanges((_f, _t, f, t) => {
|
|
18259
|
-
for (let i = 0; i < ranges.length;) {
|
|
18260
|
-
let from = ranges[i++],
|
|
18261
|
-
to = ranges[i++];
|
|
18262
|
-
if (t >= from && f <= to) isAdjacent = true;
|
|
18263
|
-
}
|
|
18264
|
-
});
|
|
18265
|
-
return isAdjacent;
|
|
18266
|
-
}
|
|
18267
|
-
function eqSelectionShape(a, b) {
|
|
18268
|
-
return a.ranges.length == b.ranges.length && a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;
|
|
18269
|
-
}
|
|
18270
|
-
function conc(a, b) {
|
|
18271
|
-
return !a.length ? b : !b.length ? a : a.concat(b);
|
|
18272
|
-
}
|
|
18273
|
-
const none$2 = [];
|
|
18274
|
-
const MaxSelectionsPerEvent = 200;
|
|
18275
|
-
function addSelection(branch, selection) {
|
|
18276
|
-
if (!branch.length) {
|
|
18277
|
-
return [HistEvent.selection([selection])];
|
|
18278
|
-
} else {
|
|
18279
|
-
let lastEvent = branch[branch.length - 1];
|
|
18280
|
-
let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));
|
|
18281
|
-
if (sels.length && sels[sels.length - 1].eq(selection)) return branch;
|
|
18282
|
-
sels.push(selection);
|
|
18283
|
-
return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));
|
|
18284
|
-
}
|
|
18285
|
-
}
|
|
18286
|
-
// Assumes the top item has one or more selectionAfter values
|
|
18287
|
-
function popSelection(branch) {
|
|
18288
|
-
let last = branch[branch.length - 1];
|
|
18289
|
-
let newBranch = branch.slice();
|
|
18290
|
-
newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));
|
|
18291
|
-
return newBranch;
|
|
18292
|
-
}
|
|
18293
|
-
// Add a mapping to the top event in the given branch. If this maps
|
|
18294
|
-
// away all the changes and effects in that item, drop it and
|
|
18295
|
-
// propagate the mapping to the next item.
|
|
18296
|
-
function addMappingToBranch(branch, mapping) {
|
|
18297
|
-
if (!branch.length) return branch;
|
|
18298
|
-
let length = branch.length,
|
|
18299
|
-
selections = none$2;
|
|
18300
|
-
while (length) {
|
|
18301
|
-
let event = mapEvent(branch[length - 1], mapping, selections);
|
|
18302
|
-
if (event.changes && !event.changes.empty || event.effects.length) {
|
|
18303
|
-
// Event survived mapping
|
|
18304
|
-
let result = branch.slice(0, length);
|
|
18305
|
-
result[length - 1] = event;
|
|
18306
|
-
return result;
|
|
18307
|
-
} else {
|
|
18308
|
-
// Drop this event, since there's no changes or effects left
|
|
18309
|
-
mapping = event.mapped;
|
|
18310
|
-
length--;
|
|
18311
|
-
selections = event.selectionsAfter;
|
|
18312
|
-
}
|
|
18313
|
-
}
|
|
18314
|
-
return selections.length ? [HistEvent.selection(selections)] : none$2;
|
|
18315
|
-
}
|
|
18316
|
-
function mapEvent(event, mapping, extraSelections) {
|
|
18317
|
-
let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none$2, extraSelections);
|
|
18318
|
-
// Change-less events don't store mappings (they are always the last event in a branch)
|
|
18319
|
-
if (!event.changes) return HistEvent.selection(selections);
|
|
18320
|
-
let mappedChanges = event.changes.map(mapping),
|
|
18321
|
-
before = mapping.mapDesc(event.changes, true);
|
|
18322
|
-
let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;
|
|
18323
|
-
return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);
|
|
18324
|
-
}
|
|
18325
|
-
const joinableUserEvent = /^(input\.type|delete)($|\.)/;
|
|
18326
|
-
class HistoryState {
|
|
18327
|
-
constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {
|
|
18328
|
-
this.done = done;
|
|
18329
|
-
this.undone = undone;
|
|
18330
|
-
this.prevTime = prevTime;
|
|
18331
|
-
this.prevUserEvent = prevUserEvent;
|
|
18332
|
-
}
|
|
18333
|
-
isolate() {
|
|
18334
|
-
return this.prevTime ? new HistoryState(this.done, this.undone) : this;
|
|
18335
|
-
}
|
|
18336
|
-
addChanges(event, time, userEvent, config, tr) {
|
|
18337
|
-
let done = this.done,
|
|
18338
|
-
lastEvent = done[done.length - 1];
|
|
18339
|
-
if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes && (!userEvent || joinableUserEvent.test(userEvent)) && (!lastEvent.selectionsAfter.length && time - this.prevTime < config.newGroupDelay && config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes)) ||
|
|
18340
|
-
// For compose (but not compose.start) events, always join with previous event
|
|
18341
|
-
userEvent == "input.type.compose")) {
|
|
18342
|
-
done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none$2));
|
|
18343
|
-
} else {
|
|
18344
|
-
done = updateBranch(done, done.length, config.minDepth, event);
|
|
18345
|
-
}
|
|
18346
|
-
return new HistoryState(done, none$2, time, userEvent);
|
|
18347
|
-
}
|
|
18348
|
-
addSelection(selection, time, userEvent, newGroupDelay) {
|
|
18349
|
-
let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none$2;
|
|
18350
|
-
if (last.length > 0 && time - this.prevTime < newGroupDelay && userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) && eqSelectionShape(last[last.length - 1], selection)) return this;
|
|
18351
|
-
return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);
|
|
18352
|
-
}
|
|
18353
|
-
addMapping(mapping) {
|
|
18354
|
-
return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
|
|
18355
|
-
}
|
|
18356
|
-
pop(side, state, selection) {
|
|
18357
|
-
let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;
|
|
18358
|
-
if (branch.length == 0) return null;
|
|
18359
|
-
let event = branch[branch.length - 1];
|
|
18360
|
-
if (selection && event.selectionsAfter.length) {
|
|
18361
|
-
return state.update({
|
|
18362
|
-
selection: event.selectionsAfter[event.selectionsAfter.length - 1],
|
|
18363
|
-
annotations: fromHistory.of({
|
|
18364
|
-
side,
|
|
18365
|
-
rest: popSelection(branch)
|
|
18366
|
-
}),
|
|
18367
|
-
userEvent: side == 0 /* BranchName.Done */ ? "select.undo" : "select.redo",
|
|
18368
|
-
scrollIntoView: true
|
|
18369
|
-
});
|
|
18370
|
-
} else if (!event.changes) {
|
|
18371
|
-
return null;
|
|
18372
|
-
} else {
|
|
18373
|
-
let rest = branch.length == 1 ? none$2 : branch.slice(0, branch.length - 1);
|
|
18374
|
-
if (event.mapped) rest = addMappingToBranch(rest, event.mapped);
|
|
18375
|
-
return state.update({
|
|
18376
|
-
changes: event.changes,
|
|
18377
|
-
selection: event.startSelection,
|
|
18378
|
-
effects: event.effects,
|
|
18379
|
-
annotations: fromHistory.of({
|
|
18380
|
-
side,
|
|
18381
|
-
rest
|
|
18382
|
-
}),
|
|
18383
|
-
filter: false,
|
|
18384
|
-
userEvent: side == 0 /* BranchName.Done */ ? "undo" : "redo",
|
|
18385
|
-
scrollIntoView: true
|
|
18386
|
-
});
|
|
18387
|
-
}
|
|
18388
|
-
}
|
|
18389
|
-
}
|
|
18390
|
-
HistoryState.empty = /*@__PURE__*/new HistoryState(none$2, none$2);
|
|
18391
|
-
/**
|
|
18392
|
-
Default key bindings for the undo history.
|
|
18393
|
-
|
|
18394
|
-
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
|
|
18395
|
-
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
|
18396
|
-
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
|
|
18397
|
-
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
|
18398
|
-
*/
|
|
18399
|
-
const historyKeymap = [{
|
|
18400
|
-
key: "Mod-z",
|
|
18401
|
-
run: undo,
|
|
18402
|
-
preventDefault: true
|
|
18403
|
-
}, {
|
|
18404
|
-
key: "Mod-y",
|
|
18405
|
-
mac: "Mod-Shift-z",
|
|
18406
|
-
run: redo,
|
|
18407
|
-
preventDefault: true
|
|
18408
|
-
}, {
|
|
18409
|
-
linux: "Ctrl-Shift-z",
|
|
18410
|
-
run: redo,
|
|
18411
|
-
preventDefault: true
|
|
18412
|
-
}, {
|
|
18413
|
-
key: "Mod-u",
|
|
18414
|
-
run: undoSelection,
|
|
18415
|
-
preventDefault: true
|
|
18416
|
-
}, {
|
|
18417
|
-
key: "Alt-u",
|
|
18418
|
-
mac: "Mod-Shift-u",
|
|
18419
|
-
run: redoSelection,
|
|
18420
|
-
preventDefault: true
|
|
18421
|
-
}];
|
|
18422
|
-
function updateSel(sel, by) {
|
|
18423
|
-
return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);
|
|
18424
|
-
}
|
|
18425
|
-
function setSel(state, selection) {
|
|
18426
|
-
return state.update({
|
|
18427
|
-
selection,
|
|
18428
|
-
scrollIntoView: true,
|
|
18429
|
-
userEvent: "select"
|
|
18430
|
-
});
|
|
18431
|
-
}
|
|
18432
|
-
function moveSel({
|
|
18433
|
-
state,
|
|
18434
|
-
dispatch
|
|
18435
|
-
}, how) {
|
|
18436
|
-
let selection = updateSel(state.selection, how);
|
|
18437
|
-
if (selection.eq(state.selection)) return false;
|
|
18438
|
-
dispatch(setSel(state, selection));
|
|
18439
|
-
return true;
|
|
18440
|
-
}
|
|
18441
|
-
function rangeEnd(range, forward) {
|
|
18442
|
-
return EditorSelection.cursor(forward ? range.to : range.from);
|
|
18443
|
-
}
|
|
18444
|
-
function cursorByChar(view, forward) {
|
|
18445
|
-
return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
|
|
18446
|
-
}
|
|
18447
|
-
function ltrAtCursor(view) {
|
|
18448
|
-
return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;
|
|
18449
|
-
}
|
|
18450
|
-
/**
|
|
18451
|
-
Move the selection one character to the left (which is backward in
|
|
18452
|
-
left-to-right text, forward in right-to-left text).
|
|
18453
|
-
*/
|
|
18454
|
-
const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
|
|
18455
|
-
/**
|
|
18456
|
-
Move the selection one character to the right.
|
|
18457
|
-
*/
|
|
18458
|
-
const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));
|
|
18459
|
-
function cursorByGroup(view, forward) {
|
|
18460
|
-
return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
|
|
18461
|
-
}
|
|
18462
|
-
/**
|
|
18463
|
-
Move the selection to the left across one group of word or
|
|
18464
|
-
non-word (but also non-space) characters.
|
|
18465
|
-
*/
|
|
18466
|
-
const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
|
|
18467
|
-
/**
|
|
18468
|
-
Move the selection one group to the right.
|
|
18469
|
-
*/
|
|
18470
|
-
const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));
|
|
18471
|
-
function interestingNode(state, node, bracketProp) {
|
|
18472
|
-
if (node.type.prop(bracketProp)) return true;
|
|
18473
|
-
let len = node.to - node.from;
|
|
18474
|
-
return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;
|
|
18475
|
-
}
|
|
18476
|
-
function moveBySyntax(state, start, forward) {
|
|
18477
|
-
let pos = syntaxTree(state).resolveInner(start.head);
|
|
18478
|
-
let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy;
|
|
18479
|
-
// Scan forward through child nodes to see if there's an interesting
|
|
18480
|
-
// node ahead.
|
|
18481
|
-
for (let at = start.head;;) {
|
|
18482
|
-
let next = forward ? pos.childAfter(at) : pos.childBefore(at);
|
|
18483
|
-
if (!next) break;
|
|
18484
|
-
if (interestingNode(state, next, bracketProp)) pos = next;else at = forward ? next.to : next.from;
|
|
18485
|
-
}
|
|
18486
|
-
let bracket = pos.type.prop(bracketProp),
|
|
18487
|
-
match,
|
|
18488
|
-
newPos;
|
|
18489
|
-
if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched) newPos = forward ? match.end.to : match.end.from;else newPos = forward ? pos.to : pos.from;
|
|
18490
|
-
return EditorSelection.cursor(newPos, forward ? -1 : 1);
|
|
18491
|
-
}
|
|
18492
|
-
/**
|
|
18493
|
-
Move the cursor over the next syntactic element to the left.
|
|
18494
|
-
*/
|
|
18495
|
-
const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
|
|
18496
|
-
/**
|
|
18497
|
-
Move the cursor over the next syntactic element to the right.
|
|
18498
|
-
*/
|
|
18499
|
-
const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
|
|
18500
|
-
function cursorByLine(view, forward) {
|
|
18501
|
-
return moveSel(view, range => {
|
|
18502
|
-
if (!range.empty) return rangeEnd(range, forward);
|
|
18503
|
-
let moved = view.moveVertically(range, forward);
|
|
18504
|
-
return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);
|
|
18505
|
-
});
|
|
18506
|
-
}
|
|
18507
|
-
/**
|
|
18508
|
-
Move the selection one line up.
|
|
18509
|
-
*/
|
|
18510
|
-
const cursorLineUp = view => cursorByLine(view, false);
|
|
18511
|
-
/**
|
|
18512
|
-
Move the selection one line down.
|
|
18513
|
-
*/
|
|
18514
|
-
const cursorLineDown = view => cursorByLine(view, true);
|
|
18515
|
-
function pageInfo(view) {
|
|
18516
|
-
let selfScroll = view.scrollDOM.clientHeight < view.scrollDOM.scrollHeight - 2;
|
|
18517
|
-
let marginTop = 0,
|
|
18518
|
-
marginBottom = 0,
|
|
18519
|
-
height;
|
|
18520
|
-
if (selfScroll) {
|
|
18521
|
-
for (let source of view.state.facet(EditorView.scrollMargins)) {
|
|
18522
|
-
let margins = source(view);
|
|
18523
|
-
if (margins === null || margins === void 0 ? void 0 : margins.top) marginTop = Math.max(margins === null || margins === void 0 ? void 0 : margins.top, marginTop);
|
|
18524
|
-
if (margins === null || margins === void 0 ? void 0 : margins.bottom) marginBottom = Math.max(margins === null || margins === void 0 ? void 0 : margins.bottom, marginBottom);
|
|
18525
|
-
}
|
|
18526
|
-
height = view.scrollDOM.clientHeight - marginTop - marginBottom;
|
|
18527
|
-
} else {
|
|
18528
|
-
height = (view.dom.ownerDocument.defaultView || window).innerHeight;
|
|
18529
|
-
}
|
|
18530
|
-
return {
|
|
18531
|
-
marginTop,
|
|
18532
|
-
marginBottom,
|
|
18533
|
-
selfScroll,
|
|
18534
|
-
height: Math.max(view.defaultLineHeight, height - 5)
|
|
18535
|
-
};
|
|
18536
|
-
}
|
|
18537
|
-
function cursorByPage(view, forward) {
|
|
18538
|
-
let page = pageInfo(view);
|
|
18539
|
-
let {
|
|
18540
|
-
state
|
|
18541
|
-
} = view,
|
|
18542
|
-
selection = updateSel(state.selection, range => {
|
|
18543
|
-
return range.empty ? view.moveVertically(range, forward, page.height) : rangeEnd(range, forward);
|
|
18544
|
-
});
|
|
18545
|
-
if (selection.eq(state.selection)) return false;
|
|
18546
|
-
let effect;
|
|
18547
|
-
if (page.selfScroll) {
|
|
18548
|
-
let startPos = view.coordsAtPos(state.selection.main.head);
|
|
18549
|
-
let scrollRect = view.scrollDOM.getBoundingClientRect();
|
|
18550
|
-
let scrollTop = scrollRect.top + page.marginTop,
|
|
18551
|
-
scrollBottom = scrollRect.bottom - page.marginBottom;
|
|
18552
|
-
if (startPos && startPos.top > scrollTop && startPos.bottom < scrollBottom) effect = EditorView.scrollIntoView(selection.main.head, {
|
|
18553
|
-
y: "start",
|
|
18554
|
-
yMargin: startPos.top - scrollTop
|
|
18555
|
-
});
|
|
18556
|
-
}
|
|
18557
|
-
view.dispatch(setSel(state, selection), {
|
|
18558
|
-
effects: effect
|
|
18559
|
-
});
|
|
18560
|
-
return true;
|
|
18561
|
-
}
|
|
18562
|
-
/**
|
|
18563
|
-
Move the selection one page up.
|
|
18564
|
-
*/
|
|
18565
|
-
const cursorPageUp = view => cursorByPage(view, false);
|
|
18566
|
-
/**
|
|
18567
|
-
Move the selection one page down.
|
|
18568
|
-
*/
|
|
18569
|
-
const cursorPageDown = view => cursorByPage(view, true);
|
|
18570
|
-
function moveByLineBoundary(view, start, forward) {
|
|
18571
|
-
let line = view.lineBlockAt(start.head),
|
|
18572
|
-
moved = view.moveToLineBoundary(start, forward);
|
|
18573
|
-
if (moved.head == start.head && moved.head != (forward ? line.to : line.from)) moved = view.moveToLineBoundary(start, forward, false);
|
|
18574
|
-
if (!forward && moved.head == line.from && line.length) {
|
|
18575
|
-
let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;
|
|
18576
|
-
if (space && start.head != line.from + space) moved = EditorSelection.cursor(line.from + space);
|
|
18577
|
-
}
|
|
18578
|
-
return moved;
|
|
18579
|
-
}
|
|
18580
|
-
/**
|
|
18581
|
-
Move the selection to the next line wrap point, or to the end of
|
|
18582
|
-
the line if there isn't one left on this line.
|
|
18583
|
-
*/
|
|
18584
|
-
const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));
|
|
18585
|
-
/**
|
|
18586
|
-
Move the selection to previous line wrap point, or failing that to
|
|
18587
|
-
the start of the line. If the line is indented, and the cursor
|
|
18588
|
-
isn't already at the end of the indentation, this will move to the
|
|
18589
|
-
end of the indentation instead of the start of the line.
|
|
18590
|
-
*/
|
|
18591
|
-
const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
|
|
18592
|
-
/**
|
|
18593
|
-
Move the selection one line wrap point to the left.
|
|
18594
|
-
*/
|
|
18595
|
-
const cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
|
|
18596
|
-
/**
|
|
18597
|
-
Move the selection one line wrap point to the right.
|
|
18598
|
-
*/
|
|
18599
|
-
const cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
|
|
18600
|
-
/**
|
|
18601
|
-
Move the selection to the start of the line.
|
|
18602
|
-
*/
|
|
18603
|
-
const cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));
|
|
18604
|
-
/**
|
|
18605
|
-
Move the selection to the end of the line.
|
|
18606
|
-
*/
|
|
18607
|
-
const cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1));
|
|
18608
|
-
function toMatchingBracket(state, dispatch, extend) {
|
|
18609
|
-
let found = false,
|
|
18610
|
-
selection = updateSel(state.selection, range => {
|
|
18611
|
-
let matching = matchBrackets(state, range.head, -1) || matchBrackets(state, range.head, 1) || range.head > 0 && matchBrackets(state, range.head - 1, 1) || range.head < state.doc.length && matchBrackets(state, range.head + 1, -1);
|
|
18612
|
-
if (!matching || !matching.end) return range;
|
|
18613
|
-
found = true;
|
|
18614
|
-
let head = matching.start.from == range.head ? matching.end.to : matching.end.from;
|
|
18615
|
-
return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head);
|
|
18616
|
-
});
|
|
18617
|
-
if (!found) return false;
|
|
18618
|
-
dispatch(setSel(state, selection));
|
|
18619
|
-
return true;
|
|
18620
|
-
}
|
|
18621
|
-
/**
|
|
18622
|
-
Move the selection to the bracket matching the one it is currently
|
|
18623
|
-
on, if any.
|
|
18624
|
-
*/
|
|
18625
|
-
const cursorMatchingBracket = ({
|
|
18626
|
-
state,
|
|
18627
|
-
dispatch
|
|
18628
|
-
}) => toMatchingBracket(state, dispatch, false);
|
|
18629
|
-
function extendSel(view, how) {
|
|
18630
|
-
let selection = updateSel(view.state.selection, range => {
|
|
18631
|
-
let head = how(range);
|
|
18632
|
-
return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined);
|
|
18633
|
-
});
|
|
18634
|
-
if (selection.eq(view.state.selection)) return false;
|
|
18635
|
-
view.dispatch(setSel(view.state, selection));
|
|
18636
|
-
return true;
|
|
18637
|
-
}
|
|
18638
|
-
function selectByChar(view, forward) {
|
|
18639
|
-
return extendSel(view, range => view.moveByChar(range, forward));
|
|
18640
|
-
}
|
|
18641
|
-
/**
|
|
18642
|
-
Move the selection head one character to the left, while leaving
|
|
18643
|
-
the anchor in place.
|
|
18644
|
-
*/
|
|
18645
|
-
const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));
|
|
18646
|
-
/**
|
|
18647
|
-
Move the selection head one character to the right.
|
|
18648
|
-
*/
|
|
18649
|
-
const selectCharRight = view => selectByChar(view, ltrAtCursor(view));
|
|
18650
|
-
function selectByGroup(view, forward) {
|
|
18651
|
-
return extendSel(view, range => view.moveByGroup(range, forward));
|
|
18652
|
-
}
|
|
18653
|
-
/**
|
|
18654
|
-
Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
|
|
18655
|
-
the left.
|
|
18656
|
-
*/
|
|
18657
|
-
const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));
|
|
18658
|
-
/**
|
|
18659
|
-
Move the selection head one group to the right.
|
|
18660
|
-
*/
|
|
18661
|
-
const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));
|
|
18662
|
-
/**
|
|
18663
|
-
Move the selection head over the next syntactic element to the left.
|
|
18664
|
-
*/
|
|
18665
|
-
const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
|
|
18666
|
-
/**
|
|
18667
|
-
Move the selection head over the next syntactic element to the right.
|
|
18668
|
-
*/
|
|
18669
|
-
const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
|
|
18670
|
-
function selectByLine(view, forward) {
|
|
18671
|
-
return extendSel(view, range => view.moveVertically(range, forward));
|
|
18672
|
-
}
|
|
18673
|
-
/**
|
|
18674
|
-
Move the selection head one line up.
|
|
18675
|
-
*/
|
|
18676
|
-
const selectLineUp = view => selectByLine(view, false);
|
|
18677
|
-
/**
|
|
18678
|
-
Move the selection head one line down.
|
|
18679
|
-
*/
|
|
18680
|
-
const selectLineDown = view => selectByLine(view, true);
|
|
18681
|
-
function selectByPage(view, forward) {
|
|
18682
|
-
return extendSel(view, range => view.moveVertically(range, forward, pageInfo(view).height));
|
|
18683
|
-
}
|
|
18684
|
-
/**
|
|
18685
|
-
Move the selection head one page up.
|
|
18686
|
-
*/
|
|
18687
|
-
const selectPageUp = view => selectByPage(view, false);
|
|
18688
|
-
/**
|
|
18689
|
-
Move the selection head one page down.
|
|
18690
|
-
*/
|
|
18691
|
-
const selectPageDown = view => selectByPage(view, true);
|
|
18692
|
-
/**
|
|
18693
|
-
Move the selection head to the next line boundary.
|
|
18694
|
-
*/
|
|
18695
|
-
const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));
|
|
18696
|
-
/**
|
|
18697
|
-
Move the selection head to the previous line boundary.
|
|
18698
|
-
*/
|
|
18699
|
-
const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
|
|
18700
|
-
/**
|
|
18701
|
-
Move the selection head one line boundary to the left.
|
|
18702
|
-
*/
|
|
18703
|
-
const selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));
|
|
18704
|
-
/**
|
|
18705
|
-
Move the selection head one line boundary to the right.
|
|
18706
|
-
*/
|
|
18707
|
-
const selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));
|
|
18708
|
-
/**
|
|
18709
|
-
Move the selection head to the start of the line.
|
|
18710
|
-
*/
|
|
18711
|
-
const selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));
|
|
18712
|
-
/**
|
|
18713
|
-
Move the selection head to the end of the line.
|
|
18714
|
-
*/
|
|
18715
|
-
const selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to));
|
|
18716
|
-
/**
|
|
18717
|
-
Move the selection to the start of the document.
|
|
18718
|
-
*/
|
|
18719
|
-
const cursorDocStart = ({
|
|
18720
|
-
state,
|
|
18721
|
-
dispatch
|
|
18722
|
-
}) => {
|
|
18723
|
-
dispatch(setSel(state, {
|
|
18724
|
-
anchor: 0
|
|
18725
|
-
}));
|
|
18726
|
-
return true;
|
|
18727
|
-
};
|
|
18728
|
-
/**
|
|
18729
|
-
Move the selection to the end of the document.
|
|
18730
|
-
*/
|
|
18731
|
-
const cursorDocEnd = ({
|
|
18732
|
-
state,
|
|
18733
|
-
dispatch
|
|
18734
|
-
}) => {
|
|
18735
|
-
dispatch(setSel(state, {
|
|
18736
|
-
anchor: state.doc.length
|
|
18737
|
-
}));
|
|
18738
|
-
return true;
|
|
18739
|
-
};
|
|
18740
|
-
/**
|
|
18741
|
-
Move the selection head to the start of the document.
|
|
18742
|
-
*/
|
|
18743
|
-
const selectDocStart = ({
|
|
18744
|
-
state,
|
|
18745
|
-
dispatch
|
|
18746
|
-
}) => {
|
|
18747
|
-
dispatch(setSel(state, {
|
|
18748
|
-
anchor: state.selection.main.anchor,
|
|
18749
|
-
head: 0
|
|
18750
|
-
}));
|
|
18751
|
-
return true;
|
|
18752
|
-
};
|
|
18753
|
-
/**
|
|
18754
|
-
Move the selection head to the end of the document.
|
|
18755
|
-
*/
|
|
18756
|
-
const selectDocEnd = ({
|
|
18757
|
-
state,
|
|
18758
|
-
dispatch
|
|
18759
|
-
}) => {
|
|
18760
|
-
dispatch(setSel(state, {
|
|
18761
|
-
anchor: state.selection.main.anchor,
|
|
18762
|
-
head: state.doc.length
|
|
18763
|
-
}));
|
|
18764
|
-
return true;
|
|
18765
|
-
};
|
|
18766
|
-
/**
|
|
18767
|
-
Select the entire document.
|
|
18768
|
-
*/
|
|
18769
|
-
const selectAll = ({
|
|
18770
|
-
state,
|
|
18771
|
-
dispatch
|
|
18772
|
-
}) => {
|
|
18773
|
-
dispatch(state.update({
|
|
18774
|
-
selection: {
|
|
18775
|
-
anchor: 0,
|
|
18776
|
-
head: state.doc.length
|
|
18777
|
-
},
|
|
18778
|
-
userEvent: "select"
|
|
18779
|
-
}));
|
|
18780
|
-
return true;
|
|
18781
|
-
};
|
|
18782
|
-
/**
|
|
18783
|
-
Expand the selection to cover entire lines.
|
|
18784
|
-
*/
|
|
18785
|
-
const selectLine = ({
|
|
18786
|
-
state,
|
|
18787
|
-
dispatch
|
|
18788
|
-
}) => {
|
|
18789
|
-
let ranges = selectedLineBlocks(state).map(({
|
|
18790
|
-
from,
|
|
18791
|
-
to
|
|
18792
|
-
}) => EditorSelection.range(from, Math.min(to + 1, state.doc.length)));
|
|
18793
|
-
dispatch(state.update({
|
|
18794
|
-
selection: EditorSelection.create(ranges),
|
|
18795
|
-
userEvent: "select"
|
|
18796
|
-
}));
|
|
18797
|
-
return true;
|
|
18798
|
-
};
|
|
18799
|
-
/**
|
|
18800
|
-
Select the next syntactic construct that is larger than the
|
|
18801
|
-
selection. Note that this will only work insofar as the language
|
|
18802
|
-
[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
|
|
18803
|
-
syntax tree.
|
|
18804
|
-
*/
|
|
18805
|
-
const selectParentSyntax = ({
|
|
18806
|
-
state,
|
|
18807
|
-
dispatch
|
|
18808
|
-
}) => {
|
|
18809
|
-
let selection = updateSel(state.selection, range => {
|
|
18810
|
-
var _a;
|
|
18811
|
-
let context = syntaxTree(state).resolveInner(range.head, 1);
|
|
18812
|
-
while (!(context.from < range.from && context.to >= range.to || context.to > range.to && context.from <= range.from || !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent))) context = context.parent;
|
|
18813
|
-
return EditorSelection.range(context.to, context.from);
|
|
18814
|
-
});
|
|
18815
|
-
dispatch(setSel(state, selection));
|
|
18816
|
-
return true;
|
|
18817
|
-
};
|
|
18818
|
-
/**
|
|
18819
|
-
Simplify the current selection. When multiple ranges are selected,
|
|
18820
|
-
reduce it to its main range. Otherwise, if the selection is
|
|
18821
|
-
non-empty, convert it to a cursor selection.
|
|
18822
|
-
*/
|
|
18823
|
-
const simplifySelection = ({
|
|
18824
|
-
state,
|
|
18825
|
-
dispatch
|
|
18826
|
-
}) => {
|
|
18827
|
-
let cur = state.selection,
|
|
18828
|
-
selection = null;
|
|
18829
|
-
if (cur.ranges.length > 1) selection = EditorSelection.create([cur.main]);else if (!cur.main.empty) selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]);
|
|
18830
|
-
if (!selection) return false;
|
|
18831
|
-
dispatch(setSel(state, selection));
|
|
18832
|
-
return true;
|
|
18833
|
-
};
|
|
18834
|
-
function deleteBy(target, by) {
|
|
18835
|
-
if (target.state.readOnly) return false;
|
|
18836
|
-
let event = "delete.selection",
|
|
18837
|
-
{
|
|
18838
|
-
state
|
|
18839
|
-
} = target;
|
|
18840
|
-
let changes = state.changeByRange(range => {
|
|
18841
|
-
let {
|
|
18842
|
-
from,
|
|
18843
|
-
to
|
|
18844
|
-
} = range;
|
|
18845
|
-
if (from == to) {
|
|
18846
|
-
let towards = by(from);
|
|
18847
|
-
if (towards < from) {
|
|
18848
|
-
event = "delete.backward";
|
|
18849
|
-
towards = skipAtomic(target, towards, false);
|
|
18850
|
-
} else if (towards > from) {
|
|
18851
|
-
event = "delete.forward";
|
|
18852
|
-
towards = skipAtomic(target, towards, true);
|
|
18853
|
-
}
|
|
18854
|
-
from = Math.min(from, towards);
|
|
18855
|
-
to = Math.max(to, towards);
|
|
18856
|
-
} else {
|
|
18857
|
-
from = skipAtomic(target, from, false);
|
|
18858
|
-
to = skipAtomic(target, to, true);
|
|
18859
|
-
}
|
|
18860
|
-
return from == to ? {
|
|
18861
|
-
range
|
|
18862
|
-
} : {
|
|
18863
|
-
changes: {
|
|
18864
|
-
from,
|
|
18865
|
-
to
|
|
18866
|
-
},
|
|
18867
|
-
range: EditorSelection.cursor(from)
|
|
18868
|
-
};
|
|
18869
|
-
});
|
|
18870
|
-
if (changes.changes.empty) return false;
|
|
18871
|
-
target.dispatch(state.update(changes, {
|
|
18872
|
-
scrollIntoView: true,
|
|
18873
|
-
userEvent: event,
|
|
18874
|
-
effects: event == "delete.selection" ? EditorView.announce.of(state.phrase("Selection deleted")) : undefined
|
|
18875
|
-
}));
|
|
18876
|
-
return true;
|
|
18877
|
-
}
|
|
18878
|
-
function skipAtomic(target, pos, forward) {
|
|
18879
|
-
if (target instanceof EditorView) for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target))) ranges.between(pos, pos, (from, to) => {
|
|
18880
|
-
if (from < pos && to > pos) pos = forward ? to : from;
|
|
18881
|
-
});
|
|
18882
|
-
return pos;
|
|
18883
|
-
}
|
|
18884
|
-
const deleteByChar = (target, forward) => deleteBy(target, pos => {
|
|
18885
|
-
let {
|
|
18886
|
-
state
|
|
18887
|
-
} = target,
|
|
18888
|
-
line = state.doc.lineAt(pos),
|
|
18889
|
-
before,
|
|
18890
|
-
targetPos;
|
|
18891
|
-
if (!forward && pos > line.from && pos < line.from + 200 && !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) {
|
|
18892
|
-
if (before[before.length - 1] == "\t") return pos - 1;
|
|
18893
|
-
let col = countColumn(before, state.tabSize),
|
|
18894
|
-
drop = col % getIndentUnit(state) || getIndentUnit(state);
|
|
18895
|
-
for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++) pos--;
|
|
18896
|
-
targetPos = pos;
|
|
18897
|
-
} else {
|
|
18898
|
-
targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from;
|
|
18899
|
-
if (targetPos == pos && line.number != (forward ? state.doc.lines : 1)) targetPos += forward ? 1 : -1;
|
|
18900
|
-
}
|
|
18901
|
-
return targetPos;
|
|
18902
|
-
});
|
|
18903
|
-
/**
|
|
18904
|
-
Delete the selection, or, for cursor selections, the character
|
|
18905
|
-
before the cursor.
|
|
18906
|
-
*/
|
|
18907
|
-
const deleteCharBackward = view => deleteByChar(view, false);
|
|
18908
|
-
/**
|
|
18909
|
-
Delete the selection or the character after the cursor.
|
|
18910
|
-
*/
|
|
18911
|
-
const deleteCharForward = view => deleteByChar(view, true);
|
|
18912
|
-
const deleteByGroup = (target, forward) => deleteBy(target, start => {
|
|
18913
|
-
let pos = start,
|
|
18914
|
-
{
|
|
18915
|
-
state
|
|
18916
|
-
} = target,
|
|
18917
|
-
line = state.doc.lineAt(pos);
|
|
18918
|
-
let categorize = state.charCategorizer(pos);
|
|
18919
|
-
for (let cat = null;;) {
|
|
18920
|
-
if (pos == (forward ? line.to : line.from)) {
|
|
18921
|
-
if (pos == start && line.number != (forward ? state.doc.lines : 1)) pos += forward ? 1 : -1;
|
|
18922
|
-
break;
|
|
18923
|
-
}
|
|
18924
|
-
let next = findClusterBreak(line.text, pos - line.from, forward) + line.from;
|
|
18925
|
-
let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);
|
|
18926
|
-
let nextCat = categorize(nextChar);
|
|
18927
|
-
if (cat != null && nextCat != cat) break;
|
|
18928
|
-
if (nextChar != " " || pos != start) cat = nextCat;
|
|
18929
|
-
pos = next;
|
|
18930
|
-
}
|
|
18931
|
-
return pos;
|
|
18932
|
-
});
|
|
18933
|
-
/**
|
|
18934
|
-
Delete the selection or backward until the end of the next
|
|
18935
|
-
[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
|
|
18936
|
-
whitespace when they consist of a single space.
|
|
18937
|
-
*/
|
|
18938
|
-
const deleteGroupBackward = target => deleteByGroup(target, false);
|
|
18939
|
-
/**
|
|
18940
|
-
Delete the selection or forward until the end of the next group.
|
|
18941
|
-
*/
|
|
18942
|
-
const deleteGroupForward = target => deleteByGroup(target, true);
|
|
18943
|
-
/**
|
|
18944
|
-
Delete the selection, or, if it is a cursor selection, delete to
|
|
18945
|
-
the end of the line. If the cursor is directly at the end of the
|
|
18946
|
-
line, delete the line break after it.
|
|
18947
|
-
*/
|
|
18948
|
-
const deleteToLineEnd = view => deleteBy(view, pos => {
|
|
18949
|
-
let lineEnd = view.lineBlockAt(pos).to;
|
|
18950
|
-
return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);
|
|
18951
|
-
});
|
|
18952
|
-
/**
|
|
18953
|
-
Delete the selection, or, if it is a cursor selection, delete to
|
|
18954
|
-
the start of the line. If the cursor is directly at the start of the
|
|
18955
|
-
line, delete the line break before it.
|
|
18956
|
-
*/
|
|
18957
|
-
const deleteToLineStart = view => deleteBy(view, pos => {
|
|
18958
|
-
let lineStart = view.lineBlockAt(pos).from;
|
|
18959
|
-
return pos > lineStart ? lineStart : Math.max(0, pos - 1);
|
|
18960
|
-
});
|
|
18961
|
-
/**
|
|
18962
|
-
Replace each selection range with a line break, leaving the cursor
|
|
18963
|
-
on the line before the break.
|
|
18964
|
-
*/
|
|
18965
|
-
const splitLine = ({
|
|
18966
|
-
state,
|
|
18967
|
-
dispatch
|
|
18968
|
-
}) => {
|
|
18969
|
-
if (state.readOnly) return false;
|
|
18970
|
-
let changes = state.changeByRange(range => {
|
|
18971
|
-
return {
|
|
18972
|
-
changes: {
|
|
18973
|
-
from: range.from,
|
|
18974
|
-
to: range.to,
|
|
18975
|
-
insert: Text.of(["", ""])
|
|
18976
|
-
},
|
|
18977
|
-
range: EditorSelection.cursor(range.from)
|
|
18978
|
-
};
|
|
18979
|
-
});
|
|
18980
|
-
dispatch(state.update(changes, {
|
|
18981
|
-
scrollIntoView: true,
|
|
18982
|
-
userEvent: "input"
|
|
18983
|
-
}));
|
|
18984
|
-
return true;
|
|
18985
|
-
};
|
|
18986
|
-
/**
|
|
18987
|
-
Flip the characters before and after the cursor(s).
|
|
18988
|
-
*/
|
|
18989
|
-
const transposeChars = ({
|
|
18990
|
-
state,
|
|
18991
|
-
dispatch
|
|
18992
|
-
}) => {
|
|
18993
|
-
if (state.readOnly) return false;
|
|
18994
|
-
let changes = state.changeByRange(range => {
|
|
18995
|
-
if (!range.empty || range.from == 0 || range.from == state.doc.length) return {
|
|
18996
|
-
range
|
|
18997
|
-
};
|
|
18998
|
-
let pos = range.from,
|
|
18999
|
-
line = state.doc.lineAt(pos);
|
|
19000
|
-
let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from;
|
|
19001
|
-
let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from;
|
|
19002
|
-
return {
|
|
19003
|
-
changes: {
|
|
19004
|
-
from,
|
|
19005
|
-
to,
|
|
19006
|
-
insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos))
|
|
19007
|
-
},
|
|
19008
|
-
range: EditorSelection.cursor(to)
|
|
19009
|
-
};
|
|
19010
|
-
});
|
|
19011
|
-
if (changes.changes.empty) return false;
|
|
19012
|
-
dispatch(state.update(changes, {
|
|
19013
|
-
scrollIntoView: true,
|
|
19014
|
-
userEvent: "move.character"
|
|
19015
|
-
}));
|
|
19016
|
-
return true;
|
|
19017
|
-
};
|
|
19018
|
-
function selectedLineBlocks(state) {
|
|
19019
|
-
let blocks = [],
|
|
19020
|
-
upto = -1;
|
|
19021
|
-
for (let range of state.selection.ranges) {
|
|
19022
|
-
let startLine = state.doc.lineAt(range.from),
|
|
19023
|
-
endLine = state.doc.lineAt(range.to);
|
|
19024
|
-
if (!range.empty && range.to == endLine.from) endLine = state.doc.lineAt(range.to - 1);
|
|
19025
|
-
if (upto >= startLine.number) {
|
|
19026
|
-
let prev = blocks[blocks.length - 1];
|
|
19027
|
-
prev.to = endLine.to;
|
|
19028
|
-
prev.ranges.push(range);
|
|
19029
|
-
} else {
|
|
19030
|
-
blocks.push({
|
|
19031
|
-
from: startLine.from,
|
|
19032
|
-
to: endLine.to,
|
|
19033
|
-
ranges: [range]
|
|
19034
|
-
});
|
|
19035
|
-
}
|
|
19036
|
-
upto = endLine.number + 1;
|
|
19037
|
-
}
|
|
19038
|
-
return blocks;
|
|
19039
|
-
}
|
|
19040
|
-
function moveLine(state, dispatch, forward) {
|
|
19041
|
-
if (state.readOnly) return false;
|
|
19042
|
-
let changes = [],
|
|
19043
|
-
ranges = [];
|
|
19044
|
-
for (let block of selectedLineBlocks(state)) {
|
|
19045
|
-
if (forward ? block.to == state.doc.length : block.from == 0) continue;
|
|
19046
|
-
let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);
|
|
19047
|
-
let size = nextLine.length + 1;
|
|
19048
|
-
if (forward) {
|
|
19049
|
-
changes.push({
|
|
19050
|
-
from: block.to,
|
|
19051
|
-
to: nextLine.to
|
|
19052
|
-
}, {
|
|
19053
|
-
from: block.from,
|
|
19054
|
-
insert: nextLine.text + state.lineBreak
|
|
19055
|
-
});
|
|
19056
|
-
for (let r of block.ranges) ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
|
|
19057
|
-
} else {
|
|
19058
|
-
changes.push({
|
|
19059
|
-
from: nextLine.from,
|
|
19060
|
-
to: block.from
|
|
19061
|
-
}, {
|
|
19062
|
-
from: block.to,
|
|
19063
|
-
insert: state.lineBreak + nextLine.text
|
|
19064
|
-
});
|
|
19065
|
-
for (let r of block.ranges) ranges.push(EditorSelection.range(r.anchor - size, r.head - size));
|
|
19066
|
-
}
|
|
19067
|
-
}
|
|
19068
|
-
if (!changes.length) return false;
|
|
19069
|
-
dispatch(state.update({
|
|
19070
|
-
changes,
|
|
19071
|
-
scrollIntoView: true,
|
|
19072
|
-
selection: EditorSelection.create(ranges, state.selection.mainIndex),
|
|
19073
|
-
userEvent: "move.line"
|
|
19074
|
-
}));
|
|
19075
|
-
return true;
|
|
19076
|
-
}
|
|
19077
|
-
/**
|
|
19078
|
-
Move the selected lines up one line.
|
|
19079
|
-
*/
|
|
19080
|
-
const moveLineUp = ({
|
|
19081
|
-
state,
|
|
19082
|
-
dispatch
|
|
19083
|
-
}) => moveLine(state, dispatch, false);
|
|
19084
|
-
/**
|
|
19085
|
-
Move the selected lines down one line.
|
|
19086
|
-
*/
|
|
19087
|
-
const moveLineDown = ({
|
|
19088
|
-
state,
|
|
19089
|
-
dispatch
|
|
19090
|
-
}) => moveLine(state, dispatch, true);
|
|
19091
|
-
function copyLine(state, dispatch, forward) {
|
|
19092
|
-
if (state.readOnly) return false;
|
|
19093
|
-
let changes = [];
|
|
19094
|
-
for (let block of selectedLineBlocks(state)) {
|
|
19095
|
-
if (forward) changes.push({
|
|
19096
|
-
from: block.from,
|
|
19097
|
-
insert: state.doc.slice(block.from, block.to) + state.lineBreak
|
|
19098
|
-
});else changes.push({
|
|
19099
|
-
from: block.to,
|
|
19100
|
-
insert: state.lineBreak + state.doc.slice(block.from, block.to)
|
|
19101
|
-
});
|
|
19102
|
-
}
|
|
19103
|
-
dispatch(state.update({
|
|
19104
|
-
changes,
|
|
19105
|
-
scrollIntoView: true,
|
|
19106
|
-
userEvent: "input.copyline"
|
|
19107
|
-
}));
|
|
19108
|
-
return true;
|
|
19109
|
-
}
|
|
19110
|
-
/**
|
|
19111
|
-
Create a copy of the selected lines. Keep the selection in the top copy.
|
|
19112
|
-
*/
|
|
19113
|
-
const copyLineUp = ({
|
|
19114
|
-
state,
|
|
19115
|
-
dispatch
|
|
19116
|
-
}) => copyLine(state, dispatch, false);
|
|
19117
|
-
/**
|
|
19118
|
-
Create a copy of the selected lines. Keep the selection in the bottom copy.
|
|
19119
|
-
*/
|
|
19120
|
-
const copyLineDown = ({
|
|
19121
|
-
state,
|
|
19122
|
-
dispatch
|
|
19123
|
-
}) => copyLine(state, dispatch, true);
|
|
19124
|
-
/**
|
|
19125
|
-
Delete selected lines.
|
|
19126
|
-
*/
|
|
19127
|
-
const deleteLine = view => {
|
|
19128
|
-
if (view.state.readOnly) return false;
|
|
19129
|
-
let {
|
|
19130
|
-
state
|
|
19131
|
-
} = view,
|
|
19132
|
-
changes = state.changes(selectedLineBlocks(state).map(({
|
|
19133
|
-
from,
|
|
19134
|
-
to
|
|
19135
|
-
}) => {
|
|
19136
|
-
if (from > 0) from--;else if (to < state.doc.length) to++;
|
|
19137
|
-
return {
|
|
19138
|
-
from,
|
|
19139
|
-
to
|
|
19140
|
-
};
|
|
19141
|
-
}));
|
|
19142
|
-
let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);
|
|
19143
|
-
view.dispatch({
|
|
19144
|
-
changes,
|
|
19145
|
-
selection,
|
|
19146
|
-
scrollIntoView: true,
|
|
19147
|
-
userEvent: "delete.line"
|
|
19148
|
-
});
|
|
19149
|
-
return true;
|
|
19150
|
-
};
|
|
19151
|
-
function isBetweenBrackets(state, pos) {
|
|
19152
|
-
if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1))) return {
|
|
19153
|
-
from: pos,
|
|
19154
|
-
to: pos
|
|
19155
|
-
};
|
|
19156
|
-
let context = syntaxTree(state).resolveInner(pos);
|
|
19157
|
-
let before = context.childBefore(pos),
|
|
19158
|
-
after = context.childAfter(pos),
|
|
19159
|
-
closedBy;
|
|
19160
|
-
if (before && after && before.to <= pos && after.from >= pos && (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 && state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from) return {
|
|
19161
|
-
from: before.to,
|
|
19162
|
-
to: after.from
|
|
19163
|
-
};
|
|
19164
|
-
return null;
|
|
19165
|
-
}
|
|
19166
|
-
/**
|
|
19167
|
-
Replace the selection with a newline and indent the newly created
|
|
19168
|
-
line(s). If the current line consists only of whitespace, this
|
|
19169
|
-
will also delete that whitespace. When the cursor is between
|
|
19170
|
-
matching brackets, an additional newline will be inserted after
|
|
19171
|
-
the cursor.
|
|
19172
|
-
*/
|
|
19173
|
-
const insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);
|
|
19174
|
-
/**
|
|
19175
|
-
Create a blank, indented line below the current line.
|
|
19176
|
-
*/
|
|
19177
|
-
const insertBlankLine = /*@__PURE__*/newlineAndIndent(true);
|
|
19178
|
-
function newlineAndIndent(atEof) {
|
|
19179
|
-
return ({
|
|
19180
|
-
state,
|
|
19181
|
-
dispatch
|
|
19182
|
-
}) => {
|
|
19183
|
-
if (state.readOnly) return false;
|
|
19184
|
-
let changes = state.changeByRange(range => {
|
|
19185
|
-
let {
|
|
19186
|
-
from,
|
|
19187
|
-
to
|
|
19188
|
-
} = range,
|
|
19189
|
-
line = state.doc.lineAt(from);
|
|
19190
|
-
let explode = !atEof && from == to && isBetweenBrackets(state, from);
|
|
19191
|
-
if (atEof) from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;
|
|
19192
|
-
let cx = new IndentContext(state, {
|
|
19193
|
-
simulateBreak: from,
|
|
19194
|
-
simulateDoubleBreak: !!explode
|
|
19195
|
-
});
|
|
19196
|
-
let indent = getIndentation(cx, from);
|
|
19197
|
-
if (indent == null) indent = /^\s*/.exec(state.doc.lineAt(from).text)[0].length;
|
|
19198
|
-
while (to < line.to && /\s/.test(line.text[to - line.from])) to++;
|
|
19199
|
-
if (explode) ({
|
|
19200
|
-
from,
|
|
19201
|
-
to
|
|
19202
|
-
} = explode);else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from))) from = line.from;
|
|
19203
|
-
let insert = ["", indentString(state, indent)];
|
|
19204
|
-
if (explode) insert.push(indentString(state, cx.lineIndent(line.from, -1)));
|
|
19205
|
-
return {
|
|
19206
|
-
changes: {
|
|
19207
|
-
from,
|
|
19208
|
-
to,
|
|
19209
|
-
insert: Text.of(insert)
|
|
19210
|
-
},
|
|
19211
|
-
range: EditorSelection.cursor(from + 1 + insert[1].length)
|
|
19212
|
-
};
|
|
19213
|
-
});
|
|
19214
|
-
dispatch(state.update(changes, {
|
|
19215
|
-
scrollIntoView: true,
|
|
19216
|
-
userEvent: "input"
|
|
19217
|
-
}));
|
|
19218
|
-
return true;
|
|
19219
|
-
};
|
|
19220
|
-
}
|
|
19221
|
-
function changeBySelectedLine(state, f) {
|
|
19222
|
-
let atLine = -1;
|
|
19223
|
-
return state.changeByRange(range => {
|
|
19224
|
-
let changes = [];
|
|
19225
|
-
for (let pos = range.from; pos <= range.to;) {
|
|
19226
|
-
let line = state.doc.lineAt(pos);
|
|
19227
|
-
if (line.number > atLine && (range.empty || range.to > line.from)) {
|
|
19228
|
-
f(line, changes, range);
|
|
19229
|
-
atLine = line.number;
|
|
19230
|
-
}
|
|
19231
|
-
pos = line.to + 1;
|
|
19232
|
-
}
|
|
19233
|
-
let changeSet = state.changes(changes);
|
|
19234
|
-
return {
|
|
19235
|
-
changes,
|
|
19236
|
-
range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1))
|
|
19237
|
-
};
|
|
19238
|
-
});
|
|
19239
|
-
}
|
|
19240
|
-
/**
|
|
19241
|
-
Auto-indent the selected lines. This uses the [indentation service
|
|
19242
|
-
facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
|
|
19243
|
-
information.
|
|
19244
|
-
*/
|
|
19245
|
-
const indentSelection = ({
|
|
19246
|
-
state,
|
|
19247
|
-
dispatch
|
|
19248
|
-
}) => {
|
|
19249
|
-
if (state.readOnly) return false;
|
|
19250
|
-
let updated = Object.create(null);
|
|
19251
|
-
let context = new IndentContext(state, {
|
|
19252
|
-
overrideIndentation: start => {
|
|
19253
|
-
let found = updated[start];
|
|
19254
|
-
return found == null ? -1 : found;
|
|
19255
|
-
}
|
|
19256
|
-
});
|
|
19257
|
-
let changes = changeBySelectedLine(state, (line, changes, range) => {
|
|
19258
|
-
let indent = getIndentation(context, line.from);
|
|
19259
|
-
if (indent == null) return;
|
|
19260
|
-
if (!/\S/.test(line.text)) indent = 0;
|
|
19261
|
-
let cur = /^\s*/.exec(line.text)[0];
|
|
19262
|
-
let norm = indentString(state, indent);
|
|
19263
|
-
if (cur != norm || range.from < line.from + cur.length) {
|
|
19264
|
-
updated[line.from] = indent;
|
|
19265
|
-
changes.push({
|
|
19266
|
-
from: line.from,
|
|
19267
|
-
to: line.from + cur.length,
|
|
19268
|
-
insert: norm
|
|
19269
|
-
});
|
|
19270
|
-
}
|
|
19271
|
-
});
|
|
19272
|
-
if (!changes.changes.empty) dispatch(state.update(changes, {
|
|
19273
|
-
userEvent: "indent"
|
|
19274
|
-
}));
|
|
19275
|
-
return true;
|
|
19276
|
-
};
|
|
19277
|
-
/**
|
|
19278
|
-
Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
|
|
19279
|
-
lines.
|
|
19280
|
-
*/
|
|
19281
|
-
const indentMore = ({
|
|
19282
|
-
state,
|
|
19283
|
-
dispatch
|
|
19284
|
-
}) => {
|
|
19285
|
-
if (state.readOnly) return false;
|
|
19286
|
-
dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
|
|
19287
|
-
changes.push({
|
|
19288
|
-
from: line.from,
|
|
19289
|
-
insert: state.facet(indentUnit)
|
|
19290
|
-
});
|
|
19291
|
-
}), {
|
|
19292
|
-
userEvent: "input.indent"
|
|
19293
|
-
}));
|
|
19294
|
-
return true;
|
|
19295
|
-
};
|
|
19296
|
-
/**
|
|
19297
|
-
Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
|
|
19298
|
-
selected lines.
|
|
19299
|
-
*/
|
|
19300
|
-
const indentLess = ({
|
|
19301
|
-
state,
|
|
19302
|
-
dispatch
|
|
19303
|
-
}) => {
|
|
19304
|
-
if (state.readOnly) return false;
|
|
19305
|
-
dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
|
|
19306
|
-
let space = /^\s*/.exec(line.text)[0];
|
|
19307
|
-
if (!space) return;
|
|
19308
|
-
let col = countColumn(space, state.tabSize),
|
|
19309
|
-
keep = 0;
|
|
19310
|
-
let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));
|
|
19311
|
-
while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep)) keep++;
|
|
19312
|
-
changes.push({
|
|
19313
|
-
from: line.from + keep,
|
|
19314
|
-
to: line.from + space.length,
|
|
19315
|
-
insert: insert.slice(keep)
|
|
19316
|
-
});
|
|
19317
|
-
}), {
|
|
19318
|
-
userEvent: "delete.dedent"
|
|
19319
|
-
}));
|
|
19320
|
-
return true;
|
|
19321
|
-
};
|
|
19322
|
-
/**
|
|
19323
|
-
Array of key bindings containing the Emacs-style bindings that are
|
|
19324
|
-
available on macOS by default.
|
|
19325
|
-
|
|
19326
|
-
- Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
|
19327
|
-
- Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
|
19328
|
-
- Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
|
19329
|
-
- Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
|
19330
|
-
- Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
|
19331
|
-
- Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
|
19332
|
-
- Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
|
19333
|
-
- Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
|
19334
|
-
- Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
|
|
19335
|
-
- Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
|
19336
|
-
- Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
|
|
19337
|
-
- Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
|
|
19338
|
-
- Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
|
|
19339
|
-
- Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
|
|
19340
|
-
*/
|
|
19341
|
-
const emacsStyleKeymap = [{
|
|
19342
|
-
key: "Ctrl-b",
|
|
19343
|
-
run: cursorCharLeft,
|
|
19344
|
-
shift: selectCharLeft,
|
|
19345
|
-
preventDefault: true
|
|
19346
|
-
}, {
|
|
19347
|
-
key: "Ctrl-f",
|
|
19348
|
-
run: cursorCharRight,
|
|
19349
|
-
shift: selectCharRight
|
|
19350
|
-
}, {
|
|
19351
|
-
key: "Ctrl-p",
|
|
19352
|
-
run: cursorLineUp,
|
|
19353
|
-
shift: selectLineUp
|
|
19354
|
-
}, {
|
|
19355
|
-
key: "Ctrl-n",
|
|
19356
|
-
run: cursorLineDown,
|
|
19357
|
-
shift: selectLineDown
|
|
19358
|
-
}, {
|
|
19359
|
-
key: "Ctrl-a",
|
|
19360
|
-
run: cursorLineStart,
|
|
19361
|
-
shift: selectLineStart
|
|
19362
|
-
}, {
|
|
19363
|
-
key: "Ctrl-e",
|
|
19364
|
-
run: cursorLineEnd,
|
|
19365
|
-
shift: selectLineEnd
|
|
19366
|
-
}, {
|
|
19367
|
-
key: "Ctrl-d",
|
|
19368
|
-
run: deleteCharForward
|
|
19369
|
-
}, {
|
|
19370
|
-
key: "Ctrl-h",
|
|
19371
|
-
run: deleteCharBackward
|
|
19372
|
-
}, {
|
|
19373
|
-
key: "Ctrl-k",
|
|
19374
|
-
run: deleteToLineEnd
|
|
19375
|
-
}, {
|
|
19376
|
-
key: "Ctrl-Alt-h",
|
|
19377
|
-
run: deleteGroupBackward
|
|
19378
|
-
}, {
|
|
19379
|
-
key: "Ctrl-o",
|
|
19380
|
-
run: splitLine
|
|
19381
|
-
}, {
|
|
19382
|
-
key: "Ctrl-t",
|
|
19383
|
-
run: transposeChars
|
|
19384
|
-
}, {
|
|
19385
|
-
key: "Ctrl-v",
|
|
19386
|
-
run: cursorPageDown
|
|
19387
|
-
}];
|
|
19388
|
-
/**
|
|
19389
|
-
An array of key bindings closely sticking to platform-standard or
|
|
19390
|
-
widely used bindings. (This includes the bindings from
|
|
19391
|
-
[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
|
|
19392
|
-
property changed to `mac`.)
|
|
19393
|
-
|
|
19394
|
-
- ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
|
19395
|
-
- ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
|
19396
|
-
- Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
|
|
19397
|
-
- Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
|
|
19398
|
-
- Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
|
19399
|
-
- Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
|
19400
|
-
- ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
|
19401
|
-
- ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
|
19402
|
-
- Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
|
19403
|
-
- Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
|
19404
|
-
- Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
|
19405
|
-
- Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
|
19406
|
-
- PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
|
19407
|
-
- PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
|
19408
|
-
- Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
|
|
19409
|
-
- End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
|
|
19410
|
-
- Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
|
19411
|
-
- Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
|
19412
|
-
- Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
|
|
19413
|
-
- Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
|
|
19414
|
-
- Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
|
19415
|
-
- Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
|
19416
|
-
- Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
|
19417
|
-
- Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
|
|
19418
|
-
- Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
|
|
19419
|
-
- Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
|
|
19420
|
-
*/
|
|
19421
|
-
const standardKeymap = /*@__PURE__*/[{
|
|
19422
|
-
key: "ArrowLeft",
|
|
19423
|
-
run: cursorCharLeft,
|
|
19424
|
-
shift: selectCharLeft,
|
|
19425
|
-
preventDefault: true
|
|
19426
|
-
}, {
|
|
19427
|
-
key: "Mod-ArrowLeft",
|
|
19428
|
-
mac: "Alt-ArrowLeft",
|
|
19429
|
-
run: cursorGroupLeft,
|
|
19430
|
-
shift: selectGroupLeft,
|
|
19431
|
-
preventDefault: true
|
|
19432
|
-
}, {
|
|
19433
|
-
mac: "Cmd-ArrowLeft",
|
|
19434
|
-
run: cursorLineBoundaryLeft,
|
|
19435
|
-
shift: selectLineBoundaryLeft,
|
|
19436
|
-
preventDefault: true
|
|
19437
|
-
}, {
|
|
19438
|
-
key: "ArrowRight",
|
|
19439
|
-
run: cursorCharRight,
|
|
19440
|
-
shift: selectCharRight,
|
|
19441
|
-
preventDefault: true
|
|
19442
|
-
}, {
|
|
19443
|
-
key: "Mod-ArrowRight",
|
|
19444
|
-
mac: "Alt-ArrowRight",
|
|
19445
|
-
run: cursorGroupRight,
|
|
19446
|
-
shift: selectGroupRight,
|
|
19447
|
-
preventDefault: true
|
|
19448
|
-
}, {
|
|
19449
|
-
mac: "Cmd-ArrowRight",
|
|
19450
|
-
run: cursorLineBoundaryRight,
|
|
19451
|
-
shift: selectLineBoundaryRight,
|
|
19452
|
-
preventDefault: true
|
|
19453
|
-
}, {
|
|
19454
|
-
key: "ArrowUp",
|
|
19455
|
-
run: cursorLineUp,
|
|
19456
|
-
shift: selectLineUp,
|
|
19457
|
-
preventDefault: true
|
|
19458
|
-
}, {
|
|
19459
|
-
mac: "Cmd-ArrowUp",
|
|
19460
|
-
run: cursorDocStart,
|
|
19461
|
-
shift: selectDocStart
|
|
19462
|
-
}, {
|
|
19463
|
-
mac: "Ctrl-ArrowUp",
|
|
19464
|
-
run: cursorPageUp,
|
|
19465
|
-
shift: selectPageUp
|
|
19466
|
-
}, {
|
|
19467
|
-
key: "ArrowDown",
|
|
19468
|
-
run: cursorLineDown,
|
|
19469
|
-
shift: selectLineDown,
|
|
19470
|
-
preventDefault: true
|
|
19471
|
-
}, {
|
|
19472
|
-
mac: "Cmd-ArrowDown",
|
|
19473
|
-
run: cursorDocEnd,
|
|
19474
|
-
shift: selectDocEnd
|
|
19475
|
-
}, {
|
|
19476
|
-
mac: "Ctrl-ArrowDown",
|
|
19477
|
-
run: cursorPageDown,
|
|
19478
|
-
shift: selectPageDown
|
|
19479
|
-
}, {
|
|
19480
|
-
key: "PageUp",
|
|
19481
|
-
run: cursorPageUp,
|
|
19482
|
-
shift: selectPageUp
|
|
19483
|
-
}, {
|
|
19484
|
-
key: "PageDown",
|
|
19485
|
-
run: cursorPageDown,
|
|
19486
|
-
shift: selectPageDown
|
|
19487
|
-
}, {
|
|
19488
|
-
key: "Home",
|
|
19489
|
-
run: cursorLineBoundaryBackward,
|
|
19490
|
-
shift: selectLineBoundaryBackward,
|
|
19491
|
-
preventDefault: true
|
|
19492
|
-
}, {
|
|
19493
|
-
key: "Mod-Home",
|
|
19494
|
-
run: cursorDocStart,
|
|
19495
|
-
shift: selectDocStart
|
|
19496
|
-
}, {
|
|
19497
|
-
key: "End",
|
|
19498
|
-
run: cursorLineBoundaryForward,
|
|
19499
|
-
shift: selectLineBoundaryForward,
|
|
19500
|
-
preventDefault: true
|
|
19501
|
-
}, {
|
|
19502
|
-
key: "Mod-End",
|
|
19503
|
-
run: cursorDocEnd,
|
|
19504
|
-
shift: selectDocEnd
|
|
19505
|
-
}, {
|
|
19506
|
-
key: "Enter",
|
|
19507
|
-
run: insertNewlineAndIndent
|
|
19508
|
-
}, {
|
|
19509
|
-
key: "Mod-a",
|
|
19510
|
-
run: selectAll
|
|
19511
|
-
}, {
|
|
19512
|
-
key: "Backspace",
|
|
19513
|
-
run: deleteCharBackward,
|
|
19514
|
-
shift: deleteCharBackward
|
|
19515
|
-
}, {
|
|
19516
|
-
key: "Delete",
|
|
19517
|
-
run: deleteCharForward
|
|
19518
|
-
}, {
|
|
19519
|
-
key: "Mod-Backspace",
|
|
19520
|
-
mac: "Alt-Backspace",
|
|
19521
|
-
run: deleteGroupBackward
|
|
19522
|
-
}, {
|
|
19523
|
-
key: "Mod-Delete",
|
|
19524
|
-
mac: "Alt-Delete",
|
|
19525
|
-
run: deleteGroupForward
|
|
19526
|
-
}, {
|
|
19527
|
-
mac: "Mod-Backspace",
|
|
19528
|
-
run: deleteToLineStart
|
|
19529
|
-
}, {
|
|
19530
|
-
mac: "Mod-Delete",
|
|
19531
|
-
run: deleteToLineEnd
|
|
19532
|
-
}].concat( /*@__PURE__*/emacsStyleKeymap.map(b => ({
|
|
19533
|
-
mac: b.key,
|
|
19534
|
-
run: b.run,
|
|
19535
|
-
shift: b.shift
|
|
19536
|
-
})));
|
|
19537
|
-
/**
|
|
19538
|
-
The default keymap. Includes all bindings from
|
|
19539
|
-
[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
|
|
19540
|
-
|
|
19541
|
-
- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
|
|
19542
|
-
- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
|
|
19543
|
-
- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
|
|
19544
|
-
- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
|
|
19545
|
-
- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
|
|
19546
|
-
- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
|
|
19547
|
-
- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
|
|
19548
|
-
- Ctrl-Enter (Comd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
|
|
19549
|
-
- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
|
|
19550
|
-
- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
|
|
19551
|
-
- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
|
|
19552
|
-
- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
|
|
19553
|
-
- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
|
|
19554
|
-
- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
|
|
19555
|
-
- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
|
|
19556
|
-
- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
|
|
19557
|
-
- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
|
|
19558
|
-
*/
|
|
19559
|
-
const defaultKeymap = /*@__PURE__*/[{
|
|
19560
|
-
key: "Alt-ArrowLeft",
|
|
19561
|
-
mac: "Ctrl-ArrowLeft",
|
|
19562
|
-
run: cursorSyntaxLeft,
|
|
19563
|
-
shift: selectSyntaxLeft
|
|
19564
|
-
}, {
|
|
19565
|
-
key: "Alt-ArrowRight",
|
|
19566
|
-
mac: "Ctrl-ArrowRight",
|
|
19567
|
-
run: cursorSyntaxRight,
|
|
19568
|
-
shift: selectSyntaxRight
|
|
19569
|
-
}, {
|
|
19570
|
-
key: "Alt-ArrowUp",
|
|
19571
|
-
run: moveLineUp
|
|
19572
|
-
}, {
|
|
19573
|
-
key: "Shift-Alt-ArrowUp",
|
|
19574
|
-
run: copyLineUp
|
|
19575
|
-
}, {
|
|
19576
|
-
key: "Alt-ArrowDown",
|
|
19577
|
-
run: moveLineDown
|
|
19578
|
-
}, {
|
|
19579
|
-
key: "Shift-Alt-ArrowDown",
|
|
19580
|
-
run: copyLineDown
|
|
19581
|
-
}, {
|
|
19582
|
-
key: "Escape",
|
|
19583
|
-
run: simplifySelection
|
|
19584
|
-
}, {
|
|
19585
|
-
key: "Mod-Enter",
|
|
19586
|
-
run: insertBlankLine
|
|
19587
|
-
}, {
|
|
19588
|
-
key: "Alt-l",
|
|
19589
|
-
mac: "Ctrl-l",
|
|
19590
|
-
run: selectLine
|
|
19591
|
-
}, {
|
|
19592
|
-
key: "Mod-i",
|
|
19593
|
-
run: selectParentSyntax,
|
|
19594
|
-
preventDefault: true
|
|
19595
|
-
}, {
|
|
19596
|
-
key: "Mod-[",
|
|
19597
|
-
run: indentLess
|
|
19598
|
-
}, {
|
|
19599
|
-
key: "Mod-]",
|
|
19600
|
-
run: indentMore
|
|
19601
|
-
}, {
|
|
19602
|
-
key: "Mod-Alt-\\",
|
|
19603
|
-
run: indentSelection
|
|
19604
|
-
}, {
|
|
19605
|
-
key: "Shift-Mod-k",
|
|
19606
|
-
run: deleteLine
|
|
19607
|
-
}, {
|
|
19608
|
-
key: "Shift-Mod-\\",
|
|
19609
|
-
run: cursorMatchingBracket
|
|
19610
|
-
}, {
|
|
19611
|
-
key: "Mod-/",
|
|
19612
|
-
run: toggleComment
|
|
19613
|
-
}, {
|
|
19614
|
-
key: "Alt-A",
|
|
19615
|
-
run: toggleBlockComment
|
|
19616
|
-
}].concat(standardKeymap);
|
|
19617
|
-
/**
|
|
19618
|
-
A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
|
|
19619
|
-
Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
|
|
19620
|
-
Please see the [Tab example](../../examples/tab/) before using
|
|
19621
|
-
this.
|
|
19622
|
-
*/
|
|
19623
|
-
const indentWithTab = {
|
|
19624
|
-
key: "Tab",
|
|
19625
|
-
run: indentMore,
|
|
19626
|
-
shift: indentLess
|
|
19627
|
-
};
|
|
19628
|
-
|
|
19629
|
-
function crelt() {
|
|
19630
|
-
var elt = arguments[0];
|
|
19631
|
-
if (typeof elt == "string") elt = document.createElement(elt);
|
|
19632
|
-
var i = 1,
|
|
19633
|
-
next = arguments[1];
|
|
19634
|
-
if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
|
|
19635
|
-
for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
|
|
19636
|
-
var value = next[name];
|
|
19637
|
-
if (typeof value == "string") elt.setAttribute(name, value);else if (value != null) elt[name] = value;
|
|
19638
|
-
}
|
|
19639
|
-
i++;
|
|
19640
|
-
}
|
|
19641
|
-
for (; i < arguments.length; i++) add(elt, arguments[i]);
|
|
19642
|
-
return elt;
|
|
19643
|
-
}
|
|
19644
|
-
function add(elt, child) {
|
|
19645
|
-
if (typeof child == "string") {
|
|
19646
|
-
elt.appendChild(document.createTextNode(child));
|
|
19647
|
-
} else if (child == null) ; else if (child.nodeType != null) {
|
|
19648
|
-
elt.appendChild(child);
|
|
19649
|
-
} else if (Array.isArray(child)) {
|
|
19650
|
-
for (var i = 0; i < child.length; i++) add(elt, child[i]);
|
|
19651
|
-
} else {
|
|
19652
|
-
throw new RangeError("Unsupported child node: " + child);
|
|
19653
|
-
}
|
|
19654
|
-
}
|
|
19655
|
-
|
|
19656
|
-
const basicNormalize = typeof String.prototype.normalize == "function" ? x => x.normalize("NFKD") : x => x;
|
|
19657
|
-
/**
|
|
19658
|
-
A search cursor provides an iterator over text matches in a
|
|
19659
|
-
document.
|
|
19660
|
-
*/
|
|
19661
|
-
class SearchCursor {
|
|
19662
|
-
/**
|
|
19663
|
-
Create a text cursor. The query is the search string, `from` to
|
|
19664
|
-
`to` provides the region to search.
|
|
19665
|
-
|
|
19666
|
-
When `normalize` is given, it will be called, on both the query
|
|
19667
|
-
string and the content it is matched against, before comparing.
|
|
19668
|
-
You can, for example, create a case-insensitive search by
|
|
19669
|
-
passing `s => s.toLowerCase()`.
|
|
19670
|
-
|
|
19671
|
-
Text is always normalized with
|
|
19672
|
-
[`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
19673
|
-
(when supported).
|
|
19674
|
-
*/
|
|
19675
|
-
constructor(text, query, from = 0, to = text.length, normalize, test) {
|
|
19676
|
-
this.test = test;
|
|
19677
|
-
/**
|
|
19678
|
-
The current match (only holds a meaningful value after
|
|
19679
|
-
[`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
|
|
19680
|
-
`done` is false).
|
|
19681
|
-
*/
|
|
19682
|
-
this.value = {
|
|
19683
|
-
from: 0,
|
|
19684
|
-
to: 0
|
|
19685
|
-
};
|
|
19686
|
-
/**
|
|
19687
|
-
Whether the end of the iterated region has been reached.
|
|
19688
|
-
*/
|
|
19689
|
-
this.done = false;
|
|
19690
|
-
this.matches = [];
|
|
19691
|
-
this.buffer = "";
|
|
19692
|
-
this.bufferPos = 0;
|
|
19693
|
-
this.iter = text.iterRange(from, to);
|
|
19694
|
-
this.bufferStart = from;
|
|
19695
|
-
this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;
|
|
19696
|
-
this.query = this.normalize(query);
|
|
19697
|
-
}
|
|
19698
|
-
peek() {
|
|
19699
|
-
if (this.bufferPos == this.buffer.length) {
|
|
19700
|
-
this.bufferStart += this.buffer.length;
|
|
19701
|
-
this.iter.next();
|
|
19702
|
-
if (this.iter.done) return -1;
|
|
19703
|
-
this.bufferPos = 0;
|
|
19704
|
-
this.buffer = this.iter.value;
|
|
19705
|
-
}
|
|
19706
|
-
return codePointAt(this.buffer, this.bufferPos);
|
|
19707
|
-
}
|
|
19708
|
-
/**
|
|
19709
|
-
Look for the next match. Updates the iterator's
|
|
19710
|
-
[`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
|
|
19711
|
-
[`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
|
|
19712
|
-
at least once before using the cursor.
|
|
19713
|
-
*/
|
|
19714
|
-
next() {
|
|
19715
|
-
while (this.matches.length) this.matches.pop();
|
|
19716
|
-
return this.nextOverlapping();
|
|
19717
|
-
}
|
|
19718
|
-
/**
|
|
19719
|
-
The `next` method will ignore matches that partially overlap a
|
|
19720
|
-
previous match. This method behaves like `next`, but includes
|
|
19721
|
-
such matches.
|
|
19722
|
-
*/
|
|
19723
|
-
nextOverlapping() {
|
|
19724
|
-
for (;;) {
|
|
19725
|
-
let next = this.peek();
|
|
19726
|
-
if (next < 0) {
|
|
19727
|
-
this.done = true;
|
|
19728
|
-
return this;
|
|
19729
|
-
}
|
|
19730
|
-
let str = fromCodePoint(next),
|
|
19731
|
-
start = this.bufferStart + this.bufferPos;
|
|
19732
|
-
this.bufferPos += codePointSize(next);
|
|
19733
|
-
let norm = this.normalize(str);
|
|
19734
|
-
for (let i = 0, pos = start;; i++) {
|
|
19735
|
-
let code = norm.charCodeAt(i);
|
|
19736
|
-
let match = this.match(code, pos);
|
|
19737
|
-
if (match) {
|
|
19738
|
-
this.value = match;
|
|
19739
|
-
return this;
|
|
19740
|
-
}
|
|
19741
|
-
if (i == norm.length - 1) break;
|
|
19742
|
-
if (pos == start && i < str.length && str.charCodeAt(i) == code) pos++;
|
|
19743
|
-
}
|
|
19744
|
-
}
|
|
19745
|
-
}
|
|
19746
|
-
match(code, pos) {
|
|
19747
|
-
let match = null;
|
|
19748
|
-
for (let i = 0; i < this.matches.length; i += 2) {
|
|
19749
|
-
let index = this.matches[i],
|
|
19750
|
-
keep = false;
|
|
19751
|
-
if (this.query.charCodeAt(index) == code) {
|
|
19752
|
-
if (index == this.query.length - 1) {
|
|
19753
|
-
match = {
|
|
19754
|
-
from: this.matches[i + 1],
|
|
19755
|
-
to: pos + 1
|
|
19756
|
-
};
|
|
19757
|
-
} else {
|
|
19758
|
-
this.matches[i]++;
|
|
19759
|
-
keep = true;
|
|
19760
|
-
}
|
|
19761
|
-
}
|
|
19762
|
-
if (!keep) {
|
|
19763
|
-
this.matches.splice(i, 2);
|
|
19764
|
-
i -= 2;
|
|
19765
|
-
}
|
|
19766
|
-
}
|
|
19767
|
-
if (this.query.charCodeAt(0) == code) {
|
|
19768
|
-
if (this.query.length == 1) match = {
|
|
19769
|
-
from: pos,
|
|
19770
|
-
to: pos + 1
|
|
19771
|
-
};else this.matches.push(1, pos);
|
|
19772
|
-
}
|
|
19773
|
-
if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferPos)) match = null;
|
|
19774
|
-
return match;
|
|
19775
|
-
}
|
|
19776
|
-
}
|
|
19777
|
-
if (typeof Symbol != "undefined") SearchCursor.prototype[Symbol.iterator] = function () {
|
|
19778
|
-
return this;
|
|
19779
|
-
};
|
|
19780
|
-
const empty = {
|
|
19781
|
-
from: -1,
|
|
19782
|
-
to: -1,
|
|
19783
|
-
match: /*@__PURE__*/ /.*/.exec("")
|
|
19784
|
-
};
|
|
19785
|
-
const baseFlags = "gm" + (/x/.unicode == null ? "" : "u");
|
|
19786
|
-
/**
|
|
19787
|
-
This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
|
|
19788
|
-
but searches for a regular expression pattern instead of a plain
|
|
19789
|
-
string.
|
|
19790
|
-
*/
|
|
19791
|
-
class RegExpCursor {
|
|
19792
|
-
/**
|
|
19793
|
-
Create a cursor that will search the given range in the given
|
|
19794
|
-
document. `query` should be the raw pattern (as you'd pass it to
|
|
19795
|
-
`new RegExp`).
|
|
19796
|
-
*/
|
|
19797
|
-
constructor(text, query, options, from = 0, to = text.length) {
|
|
19798
|
-
this.text = text;
|
|
19799
|
-
this.to = to;
|
|
19800
|
-
this.curLine = "";
|
|
19801
|
-
/**
|
|
19802
|
-
Set to `true` when the cursor has reached the end of the search
|
|
19803
|
-
range.
|
|
19804
|
-
*/
|
|
19805
|
-
this.done = false;
|
|
19806
|
-
/**
|
|
19807
|
-
Will contain an object with the extent of the match and the
|
|
19808
|
-
match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
|
|
19809
|
-
sucessfully finds a match.
|
|
19810
|
-
*/
|
|
19811
|
-
this.value = empty;
|
|
19812
|
-
if (/\\[sWDnr]|\n|\r|\[\^/.test(query)) return new MultilineRegExpCursor(text, query, options, from, to);
|
|
19813
|
-
this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
|
|
19814
|
-
this.test = options === null || options === void 0 ? void 0 : options.test;
|
|
19815
|
-
this.iter = text.iter();
|
|
19816
|
-
let startLine = text.lineAt(from);
|
|
19817
|
-
this.curLineStart = startLine.from;
|
|
19818
|
-
this.matchPos = toCharEnd(text, from);
|
|
19819
|
-
this.getLine(this.curLineStart);
|
|
19820
|
-
}
|
|
19821
|
-
getLine(skip) {
|
|
19822
|
-
this.iter.next(skip);
|
|
19823
|
-
if (this.iter.lineBreak) {
|
|
19824
|
-
this.curLine = "";
|
|
19825
|
-
} else {
|
|
19826
|
-
this.curLine = this.iter.value;
|
|
19827
|
-
if (this.curLineStart + this.curLine.length > this.to) this.curLine = this.curLine.slice(0, this.to - this.curLineStart);
|
|
19828
|
-
this.iter.next();
|
|
19829
|
-
}
|
|
19830
|
-
}
|
|
19831
|
-
nextLine() {
|
|
19832
|
-
this.curLineStart = this.curLineStart + this.curLine.length + 1;
|
|
19833
|
-
if (this.curLineStart > this.to) this.curLine = "";else this.getLine(0);
|
|
19834
|
-
}
|
|
19835
|
-
/**
|
|
19836
|
-
Move to the next match, if there is one.
|
|
19837
|
-
*/
|
|
19838
|
-
next() {
|
|
19839
|
-
for (let off = this.matchPos - this.curLineStart;;) {
|
|
19840
|
-
this.re.lastIndex = off;
|
|
19841
|
-
let match = this.matchPos <= this.to && this.re.exec(this.curLine);
|
|
19842
|
-
if (match) {
|
|
19843
|
-
let from = this.curLineStart + match.index,
|
|
19844
|
-
to = from + match[0].length;
|
|
19845
|
-
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
|
19846
|
-
if (from == this.curLineStart + this.curLine.length) this.nextLine();
|
|
19847
|
-
if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {
|
|
19848
|
-
this.value = {
|
|
19849
|
-
from,
|
|
19850
|
-
to,
|
|
19851
|
-
match
|
|
19852
|
-
};
|
|
19853
|
-
return this;
|
|
19854
|
-
}
|
|
19855
|
-
off = this.matchPos - this.curLineStart;
|
|
19856
|
-
} else if (this.curLineStart + this.curLine.length < this.to) {
|
|
19857
|
-
this.nextLine();
|
|
19858
|
-
off = 0;
|
|
19859
|
-
} else {
|
|
19860
|
-
this.done = true;
|
|
19861
|
-
return this;
|
|
19862
|
-
}
|
|
19863
|
-
}
|
|
19864
|
-
}
|
|
19865
|
-
}
|
|
19866
|
-
const flattened = /*@__PURE__*/new WeakMap();
|
|
19867
|
-
// Reusable (partially) flattened document strings
|
|
19868
|
-
class FlattenedDoc {
|
|
19869
|
-
constructor(from, text) {
|
|
19870
|
-
this.from = from;
|
|
19871
|
-
this.text = text;
|
|
19872
|
-
}
|
|
19873
|
-
get to() {
|
|
19874
|
-
return this.from + this.text.length;
|
|
19875
|
-
}
|
|
19876
|
-
static get(doc, from, to) {
|
|
19877
|
-
let cached = flattened.get(doc);
|
|
19878
|
-
if (!cached || cached.from >= to || cached.to <= from) {
|
|
19879
|
-
let flat = new FlattenedDoc(from, doc.sliceString(from, to));
|
|
19880
|
-
flattened.set(doc, flat);
|
|
19881
|
-
return flat;
|
|
19882
|
-
}
|
|
19883
|
-
if (cached.from == from && cached.to == to) return cached;
|
|
19884
|
-
let {
|
|
19885
|
-
text,
|
|
19886
|
-
from: cachedFrom
|
|
19887
|
-
} = cached;
|
|
19888
|
-
if (cachedFrom > from) {
|
|
19889
|
-
text = doc.sliceString(from, cachedFrom) + text;
|
|
19890
|
-
cachedFrom = from;
|
|
19891
|
-
}
|
|
19892
|
-
if (cached.to < to) text += doc.sliceString(cached.to, to);
|
|
19893
|
-
flattened.set(doc, new FlattenedDoc(cachedFrom, text));
|
|
19894
|
-
return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));
|
|
19895
|
-
}
|
|
19896
|
-
}
|
|
19897
|
-
class MultilineRegExpCursor {
|
|
19898
|
-
constructor(text, query, options, from, to) {
|
|
19899
|
-
this.text = text;
|
|
19900
|
-
this.to = to;
|
|
19901
|
-
this.done = false;
|
|
19902
|
-
this.value = empty;
|
|
19903
|
-
this.matchPos = toCharEnd(text, from);
|
|
19904
|
-
this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
|
|
19905
|
-
this.test = options === null || options === void 0 ? void 0 : options.test;
|
|
19906
|
-
this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Chunk.Base */));
|
|
19907
|
-
}
|
|
19908
|
-
|
|
19909
|
-
chunkEnd(pos) {
|
|
19910
|
-
return pos >= this.to ? this.to : this.text.lineAt(pos).to;
|
|
19911
|
-
}
|
|
19912
|
-
next() {
|
|
19913
|
-
for (;;) {
|
|
19914
|
-
let off = this.re.lastIndex = this.matchPos - this.flat.from;
|
|
19915
|
-
let match = this.re.exec(this.flat.text);
|
|
19916
|
-
// Skip empty matches directly after the last match
|
|
19917
|
-
if (match && !match[0] && match.index == off) {
|
|
19918
|
-
this.re.lastIndex = off + 1;
|
|
19919
|
-
match = this.re.exec(this.flat.text);
|
|
19920
|
-
}
|
|
19921
|
-
if (match) {
|
|
19922
|
-
let from = this.flat.from + match.index,
|
|
19923
|
-
to = from + match[0].length;
|
|
19924
|
-
// If a match goes almost to the end of a noncomplete chunk, try
|
|
19925
|
-
// again, since it'll likely be able to match more
|
|
19926
|
-
if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) && (!this.test || this.test(from, to, match))) {
|
|
19927
|
-
this.value = {
|
|
19928
|
-
from,
|
|
19929
|
-
to,
|
|
19930
|
-
match
|
|
19931
|
-
};
|
|
19932
|
-
this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));
|
|
19933
|
-
return this;
|
|
19934
|
-
}
|
|
19935
|
-
}
|
|
19936
|
-
if (this.flat.to == this.to) {
|
|
19937
|
-
this.done = true;
|
|
19938
|
-
return this;
|
|
19939
|
-
}
|
|
19940
|
-
// Grow the flattened doc
|
|
19941
|
-
this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
|
|
19942
|
-
}
|
|
19943
|
-
}
|
|
19944
|
-
}
|
|
19945
|
-
if (typeof Symbol != "undefined") {
|
|
19946
|
-
RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] = function () {
|
|
19947
|
-
return this;
|
|
19948
|
-
};
|
|
19949
|
-
}
|
|
19950
|
-
function validRegExp(source) {
|
|
19951
|
-
try {
|
|
19952
|
-
new RegExp(source, baseFlags);
|
|
19953
|
-
return true;
|
|
19954
|
-
} catch (_a) {
|
|
19955
|
-
return false;
|
|
19956
|
-
}
|
|
19957
|
-
}
|
|
19958
|
-
function toCharEnd(text, pos) {
|
|
19959
|
-
if (pos >= text.length) return pos;
|
|
19960
|
-
let line = text.lineAt(pos),
|
|
19961
|
-
next;
|
|
19962
|
-
while (pos < line.to && (next = line.text.charCodeAt(pos - line.from)) >= 0xDC00 && next < 0xE000) pos++;
|
|
19963
|
-
return pos;
|
|
19964
|
-
}
|
|
19965
|
-
function createLineDialog(view) {
|
|
19966
|
-
let input = crelt("input", {
|
|
19967
|
-
class: "cm-textfield",
|
|
19968
|
-
name: "line"
|
|
19969
|
-
});
|
|
19970
|
-
let dom = crelt("form", {
|
|
19971
|
-
class: "cm-gotoLine",
|
|
19972
|
-
onkeydown: event => {
|
|
19973
|
-
if (event.keyCode == 27) {
|
|
19974
|
-
// Escape
|
|
19975
|
-
event.preventDefault();
|
|
19976
|
-
view.dispatch({
|
|
19977
|
-
effects: dialogEffect.of(false)
|
|
19978
|
-
});
|
|
19979
|
-
view.focus();
|
|
19980
|
-
} else if (event.keyCode == 13) {
|
|
19981
|
-
// Enter
|
|
19982
|
-
event.preventDefault();
|
|
19983
|
-
go();
|
|
19984
|
-
}
|
|
19985
|
-
},
|
|
19986
|
-
onsubmit: event => {
|
|
19987
|
-
event.preventDefault();
|
|
19988
|
-
go();
|
|
19989
|
-
}
|
|
19990
|
-
}, crelt("label", view.state.phrase("Go to line"), ": ", input), " ", crelt("button", {
|
|
19991
|
-
class: "cm-button",
|
|
19992
|
-
type: "submit"
|
|
19993
|
-
}, view.state.phrase("go")));
|
|
19994
|
-
function go() {
|
|
19995
|
-
let match = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);
|
|
19996
|
-
if (!match) return;
|
|
19997
|
-
let {
|
|
19998
|
-
state
|
|
19999
|
-
} = view,
|
|
20000
|
-
startLine = state.doc.lineAt(state.selection.main.head);
|
|
20001
|
-
let [, sign, ln, cl, percent] = match;
|
|
20002
|
-
let col = cl ? +cl.slice(1) : 0;
|
|
20003
|
-
let line = ln ? +ln : startLine.number;
|
|
20004
|
-
if (ln && percent) {
|
|
20005
|
-
let pc = line / 100;
|
|
20006
|
-
if (sign) pc = pc * (sign == "-" ? -1 : 1) + startLine.number / state.doc.lines;
|
|
20007
|
-
line = Math.round(state.doc.lines * pc);
|
|
20008
|
-
} else if (ln && sign) {
|
|
20009
|
-
line = line * (sign == "-" ? -1 : 1) + startLine.number;
|
|
20010
|
-
}
|
|
20011
|
-
let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));
|
|
20012
|
-
view.dispatch({
|
|
20013
|
-
effects: dialogEffect.of(false),
|
|
20014
|
-
selection: EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length))),
|
|
20015
|
-
scrollIntoView: true
|
|
20016
|
-
});
|
|
20017
|
-
view.focus();
|
|
20018
|
-
}
|
|
20019
|
-
return {
|
|
20020
|
-
dom
|
|
20021
|
-
};
|
|
20022
|
-
}
|
|
20023
|
-
const dialogEffect = /*@__PURE__*/StateEffect.define();
|
|
20024
|
-
const dialogField = /*@__PURE__*/StateField.define({
|
|
20025
|
-
create() {
|
|
20026
|
-
return true;
|
|
20027
|
-
},
|
|
20028
|
-
update(value, tr) {
|
|
20029
|
-
for (let e of tr.effects) if (e.is(dialogEffect)) value = e.value;
|
|
20030
|
-
return value;
|
|
20031
|
-
},
|
|
20032
|
-
provide: f => showPanel.from(f, val => val ? createLineDialog : null)
|
|
20033
|
-
});
|
|
20034
|
-
/**
|
|
20035
|
-
Command that shows a dialog asking the user for a line number, and
|
|
20036
|
-
when a valid position is provided, moves the cursor to that line.
|
|
20037
|
-
|
|
20038
|
-
Supports line numbers, relative line offsets prefixed with `+` or
|
|
20039
|
-
`-`, document percentages suffixed with `%`, and an optional
|
|
20040
|
-
column position by adding `:` and a second number after the line
|
|
20041
|
-
number.
|
|
20042
|
-
|
|
20043
|
-
The dialog can be styled with the `panel.gotoLine` theme
|
|
20044
|
-
selector.
|
|
20045
|
-
*/
|
|
20046
|
-
const gotoLine = view => {
|
|
20047
|
-
let panel = getPanel(view, createLineDialog);
|
|
20048
|
-
if (!panel) {
|
|
20049
|
-
let effects = [dialogEffect.of(true)];
|
|
20050
|
-
if (view.state.field(dialogField, false) == null) effects.push(StateEffect.appendConfig.of([dialogField, baseTheme$1$1]));
|
|
20051
|
-
view.dispatch({
|
|
20052
|
-
effects
|
|
20053
|
-
});
|
|
20054
|
-
panel = getPanel(view, createLineDialog);
|
|
20055
|
-
}
|
|
20056
|
-
if (panel) panel.dom.querySelector("input").focus();
|
|
20057
|
-
return true;
|
|
20058
|
-
};
|
|
20059
|
-
const baseTheme$1$1 = /*@__PURE__*/EditorView.baseTheme({
|
|
20060
|
-
".cm-panel.cm-gotoLine": {
|
|
20061
|
-
padding: "2px 6px 4px",
|
|
20062
|
-
"& label": {
|
|
20063
|
-
fontSize: "80%"
|
|
20064
|
-
}
|
|
20065
|
-
}
|
|
20066
|
-
});
|
|
20067
|
-
const defaultHighlightOptions = {
|
|
20068
|
-
highlightWordAroundCursor: false,
|
|
20069
|
-
minSelectionLength: 1,
|
|
20070
|
-
maxMatches: 100,
|
|
20071
|
-
wholeWords: false
|
|
20072
|
-
};
|
|
20073
|
-
const highlightConfig = /*@__PURE__*/Facet.define({
|
|
20074
|
-
combine(options) {
|
|
20075
|
-
return combineConfig(options, defaultHighlightOptions, {
|
|
20076
|
-
highlightWordAroundCursor: (a, b) => a || b,
|
|
20077
|
-
minSelectionLength: Math.min,
|
|
20078
|
-
maxMatches: Math.min
|
|
20079
|
-
});
|
|
20080
|
-
}
|
|
20081
|
-
});
|
|
20082
|
-
/**
|
|
20083
|
-
This extension highlights text that matches the selection. It uses
|
|
20084
|
-
the `"cm-selectionMatch"` class for the highlighting. When
|
|
20085
|
-
`highlightWordAroundCursor` is enabled, the word at the cursor
|
|
20086
|
-
itself will be highlighted with `"cm-selectionMatch-main"`.
|
|
20087
|
-
*/
|
|
20088
|
-
function highlightSelectionMatches(options) {
|
|
20089
|
-
let ext = [defaultTheme, matchHighlighter];
|
|
20090
|
-
if (options) ext.push(highlightConfig.of(options));
|
|
20091
|
-
return ext;
|
|
20092
|
-
}
|
|
20093
|
-
const matchDeco = /*@__PURE__*/Decoration.mark({
|
|
20094
|
-
class: "cm-selectionMatch"
|
|
20095
|
-
});
|
|
20096
|
-
const mainMatchDeco = /*@__PURE__*/Decoration.mark({
|
|
20097
|
-
class: "cm-selectionMatch cm-selectionMatch-main"
|
|
20098
|
-
});
|
|
20099
|
-
// Whether the characters directly outside the given positions are non-word characters
|
|
20100
|
-
function insideWordBoundaries(check, state, from, to) {
|
|
20101
|
-
return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory.Word) && (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory.Word);
|
|
20102
|
-
}
|
|
20103
|
-
// Whether the characters directly at the given positions are word characters
|
|
20104
|
-
function insideWord(check, state, from, to) {
|
|
20105
|
-
return check(state.sliceDoc(from, from + 1)) == CharCategory.Word && check(state.sliceDoc(to - 1, to)) == CharCategory.Word;
|
|
20106
|
-
}
|
|
20107
|
-
const matchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
20108
|
-
constructor(view) {
|
|
20109
|
-
this.decorations = this.getDeco(view);
|
|
20110
|
-
}
|
|
20111
|
-
update(update) {
|
|
20112
|
-
if (update.selectionSet || update.docChanged || update.viewportChanged) this.decorations = this.getDeco(update.view);
|
|
20113
|
-
}
|
|
20114
|
-
getDeco(view) {
|
|
20115
|
-
let conf = view.state.facet(highlightConfig);
|
|
20116
|
-
let {
|
|
20117
|
-
state
|
|
20118
|
-
} = view,
|
|
20119
|
-
sel = state.selection;
|
|
20120
|
-
if (sel.ranges.length > 1) return Decoration.none;
|
|
20121
|
-
let range = sel.main,
|
|
20122
|
-
query,
|
|
20123
|
-
check = null;
|
|
20124
|
-
if (range.empty) {
|
|
20125
|
-
if (!conf.highlightWordAroundCursor) return Decoration.none;
|
|
20126
|
-
let word = state.wordAt(range.head);
|
|
20127
|
-
if (!word) return Decoration.none;
|
|
20128
|
-
check = state.charCategorizer(range.head);
|
|
20129
|
-
query = state.sliceDoc(word.from, word.to);
|
|
20130
|
-
} else {
|
|
20131
|
-
let len = range.to - range.from;
|
|
20132
|
-
if (len < conf.minSelectionLength || len > 200) return Decoration.none;
|
|
20133
|
-
if (conf.wholeWords) {
|
|
20134
|
-
query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?
|
|
20135
|
-
check = state.charCategorizer(range.head);
|
|
20136
|
-
if (!(insideWordBoundaries(check, state, range.from, range.to) && insideWord(check, state, range.from, range.to))) return Decoration.none;
|
|
20137
|
-
} else {
|
|
20138
|
-
query = state.sliceDoc(range.from, range.to).trim();
|
|
20139
|
-
if (!query) return Decoration.none;
|
|
20140
|
-
}
|
|
20141
|
-
}
|
|
20142
|
-
let deco = [];
|
|
20143
|
-
for (let part of view.visibleRanges) {
|
|
20144
|
-
let cursor = new SearchCursor(state.doc, query, part.from, part.to);
|
|
20145
|
-
while (!cursor.next().done) {
|
|
20146
|
-
let {
|
|
20147
|
-
from,
|
|
20148
|
-
to
|
|
20149
|
-
} = cursor.value;
|
|
20150
|
-
if (!check || insideWordBoundaries(check, state, from, to)) {
|
|
20151
|
-
if (range.empty && from <= range.from && to >= range.to) deco.push(mainMatchDeco.range(from, to));else if (from >= range.to || to <= range.from) deco.push(matchDeco.range(from, to));
|
|
20152
|
-
if (deco.length > conf.maxMatches) return Decoration.none;
|
|
20153
|
-
}
|
|
20154
|
-
}
|
|
20155
|
-
}
|
|
20156
|
-
return Decoration.set(deco);
|
|
20157
|
-
}
|
|
20158
|
-
}, {
|
|
20159
|
-
decorations: v => v.decorations
|
|
20160
|
-
});
|
|
20161
|
-
const defaultTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
20162
|
-
".cm-selectionMatch": {
|
|
20163
|
-
backgroundColor: "#99ff7780"
|
|
20164
|
-
},
|
|
20165
|
-
".cm-searchMatch .cm-selectionMatch": {
|
|
20166
|
-
backgroundColor: "transparent"
|
|
20167
|
-
}
|
|
20168
|
-
});
|
|
20169
|
-
// Select the words around the cursors.
|
|
20170
|
-
const selectWord = ({
|
|
20171
|
-
state,
|
|
20172
|
-
dispatch
|
|
20173
|
-
}) => {
|
|
20174
|
-
let {
|
|
20175
|
-
selection
|
|
20176
|
-
} = state;
|
|
20177
|
-
let newSel = EditorSelection.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection.cursor(range.head)), selection.mainIndex);
|
|
20178
|
-
if (newSel.eq(selection)) return false;
|
|
20179
|
-
dispatch(state.update({
|
|
20180
|
-
selection: newSel
|
|
20181
|
-
}));
|
|
20182
|
-
return true;
|
|
20183
|
-
};
|
|
20184
|
-
// Find next occurrence of query relative to last cursor. Wrap around
|
|
20185
|
-
// the document if there are no more matches.
|
|
20186
|
-
function findNextOccurrence(state, query) {
|
|
20187
|
-
let {
|
|
20188
|
-
main,
|
|
20189
|
-
ranges
|
|
20190
|
-
} = state.selection;
|
|
20191
|
-
let word = state.wordAt(main.head),
|
|
20192
|
-
fullWord = word && word.from == main.from && word.to == main.to;
|
|
20193
|
-
for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {
|
|
20194
|
-
cursor.next();
|
|
20195
|
-
if (cursor.done) {
|
|
20196
|
-
if (cycled) return null;
|
|
20197
|
-
cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
|
|
20198
|
-
cycled = true;
|
|
20199
|
-
} else {
|
|
20200
|
-
if (cycled && ranges.some(r => r.from == cursor.value.from)) continue;
|
|
20201
|
-
if (fullWord) {
|
|
20202
|
-
let word = state.wordAt(cursor.value.from);
|
|
20203
|
-
if (!word || word.from != cursor.value.from || word.to != cursor.value.to) continue;
|
|
20204
|
-
}
|
|
20205
|
-
return cursor.value;
|
|
20206
|
-
}
|
|
20207
|
-
}
|
|
20208
|
-
}
|
|
20209
|
-
/**
|
|
20210
|
-
Select next occurrence of the current selection. Expand selection
|
|
20211
|
-
to the surrounding word when the selection is empty.
|
|
20212
|
-
*/
|
|
20213
|
-
const selectNextOccurrence = ({
|
|
20214
|
-
state,
|
|
20215
|
-
dispatch
|
|
20216
|
-
}) => {
|
|
20217
|
-
let {
|
|
20218
|
-
ranges
|
|
20219
|
-
} = state.selection;
|
|
20220
|
-
if (ranges.some(sel => sel.from === sel.to)) return selectWord({
|
|
20221
|
-
state,
|
|
20222
|
-
dispatch
|
|
20223
|
-
});
|
|
20224
|
-
let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);
|
|
20225
|
-
if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText)) return false;
|
|
20226
|
-
let range = findNextOccurrence(state, searchedText);
|
|
20227
|
-
if (!range) return false;
|
|
20228
|
-
dispatch(state.update({
|
|
20229
|
-
selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),
|
|
20230
|
-
effects: EditorView.scrollIntoView(range.to)
|
|
20231
|
-
}));
|
|
20232
|
-
return true;
|
|
20233
|
-
};
|
|
20234
|
-
const searchConfigFacet = /*@__PURE__*/Facet.define({
|
|
20235
|
-
combine(configs) {
|
|
20236
|
-
return combineConfig(configs, {
|
|
20237
|
-
top: false,
|
|
20238
|
-
caseSensitive: false,
|
|
20239
|
-
literal: false,
|
|
20240
|
-
wholeWord: false,
|
|
20241
|
-
createPanel: view => new SearchPanel(view)
|
|
20242
|
-
});
|
|
20243
|
-
}
|
|
20244
|
-
});
|
|
20245
|
-
/**
|
|
20246
|
-
A search query. Part of the editor's search state.
|
|
20247
|
-
*/
|
|
20248
|
-
class SearchQuery {
|
|
20249
|
-
/**
|
|
20250
|
-
Create a query object.
|
|
20251
|
-
*/
|
|
20252
|
-
constructor(config) {
|
|
20253
|
-
this.search = config.search;
|
|
20254
|
-
this.caseSensitive = !!config.caseSensitive;
|
|
20255
|
-
this.literal = !!config.literal;
|
|
20256
|
-
this.regexp = !!config.regexp;
|
|
20257
|
-
this.replace = config.replace || "";
|
|
20258
|
-
this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
|
|
20259
|
-
this.unquoted = this.unquote(this.search);
|
|
20260
|
-
this.wholeWord = !!config.wholeWord;
|
|
20261
|
-
}
|
|
20262
|
-
/**
|
|
20263
|
-
@internal
|
|
20264
|
-
*/
|
|
20265
|
-
unquote(text) {
|
|
20266
|
-
return this.literal ? text : text.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
|
|
20267
|
-
}
|
|
20268
|
-
/**
|
|
20269
|
-
Compare this query to another query.
|
|
20270
|
-
*/
|
|
20271
|
-
eq(other) {
|
|
20272
|
-
return this.search == other.search && this.replace == other.replace && this.caseSensitive == other.caseSensitive && this.regexp == other.regexp && this.wholeWord == other.wholeWord;
|
|
20273
|
-
}
|
|
20274
|
-
/**
|
|
20275
|
-
@internal
|
|
20276
|
-
*/
|
|
20277
|
-
create() {
|
|
20278
|
-
return this.regexp ? new RegExpQuery(this) : new StringQuery(this);
|
|
20279
|
-
}
|
|
20280
|
-
/**
|
|
20281
|
-
Get a search cursor for this query, searching through the given
|
|
20282
|
-
range in the given state.
|
|
20283
|
-
*/
|
|
20284
|
-
getCursor(state, from = 0, to) {
|
|
20285
|
-
let st = state.doc ? state : EditorState.create({
|
|
20286
|
-
doc: state
|
|
20287
|
-
});
|
|
20288
|
-
if (to == null) to = st.doc.length;
|
|
20289
|
-
return this.regexp ? regexpCursor(this, st, from, to) : stringCursor(this, st, from, to);
|
|
20290
|
-
}
|
|
20291
|
-
}
|
|
20292
|
-
class QueryType {
|
|
20293
|
-
constructor(spec) {
|
|
20294
|
-
this.spec = spec;
|
|
20295
|
-
}
|
|
20296
|
-
}
|
|
20297
|
-
function stringCursor(spec, state, from, to) {
|
|
20298
|
-
return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);
|
|
20299
|
-
}
|
|
20300
|
-
function stringWordTest(doc, categorizer) {
|
|
20301
|
-
return (from, to, buf, bufPos) => {
|
|
20302
|
-
if (bufPos > from || bufPos + buf.length < to) {
|
|
20303
|
-
bufPos = Math.max(0, from - 2);
|
|
20304
|
-
buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));
|
|
20305
|
-
}
|
|
20306
|
-
return (categorizer(charBefore(buf, from - bufPos)) != CharCategory.Word || categorizer(charAfter(buf, from - bufPos)) != CharCategory.Word) && (categorizer(charAfter(buf, to - bufPos)) != CharCategory.Word || categorizer(charBefore(buf, to - bufPos)) != CharCategory.Word);
|
|
20307
|
-
};
|
|
20308
|
-
}
|
|
20309
|
-
class StringQuery extends QueryType {
|
|
20310
|
-
constructor(spec) {
|
|
20311
|
-
super(spec);
|
|
20312
|
-
}
|
|
20313
|
-
nextMatch(state, curFrom, curTo) {
|
|
20314
|
-
let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();
|
|
20315
|
-
if (cursor.done) cursor = stringCursor(this.spec, state, 0, curFrom).nextOverlapping();
|
|
20316
|
-
return cursor.done ? null : cursor.value;
|
|
20317
|
-
}
|
|
20318
|
-
// Searching in reverse is, rather than implementing inverted search
|
|
20319
|
-
// cursor, done by scanning chunk after chunk forward.
|
|
20320
|
-
prevMatchInRange(state, from, to) {
|
|
20321
|
-
for (let pos = to;;) {
|
|
20322
|
-
let start = Math.max(from, pos - 10000 /* FindPrev.ChunkSize */ - this.spec.unquoted.length);
|
|
20323
|
-
let cursor = stringCursor(this.spec, state, start, pos),
|
|
20324
|
-
range = null;
|
|
20325
|
-
while (!cursor.nextOverlapping().done) range = cursor.value;
|
|
20326
|
-
if (range) return range;
|
|
20327
|
-
if (start == from) return null;
|
|
20328
|
-
pos -= 10000 /* FindPrev.ChunkSize */;
|
|
20329
|
-
}
|
|
20330
|
-
}
|
|
20331
|
-
|
|
20332
|
-
prevMatch(state, curFrom, curTo) {
|
|
20333
|
-
return this.prevMatchInRange(state, 0, curFrom) || this.prevMatchInRange(state, curTo, state.doc.length);
|
|
20334
|
-
}
|
|
20335
|
-
getReplacement(_result) {
|
|
20336
|
-
return this.spec.unquote(this.spec.replace);
|
|
20337
|
-
}
|
|
20338
|
-
matchAll(state, limit) {
|
|
20339
|
-
let cursor = stringCursor(this.spec, state, 0, state.doc.length),
|
|
20340
|
-
ranges = [];
|
|
20341
|
-
while (!cursor.next().done) {
|
|
20342
|
-
if (ranges.length >= limit) return null;
|
|
20343
|
-
ranges.push(cursor.value);
|
|
20344
|
-
}
|
|
20345
|
-
return ranges;
|
|
20346
|
-
}
|
|
20347
|
-
highlight(state, from, to, add) {
|
|
20348
|
-
let cursor = stringCursor(this.spec, state, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, state.doc.length));
|
|
20349
|
-
while (!cursor.next().done) add(cursor.value.from, cursor.value.to);
|
|
20350
|
-
}
|
|
20351
|
-
}
|
|
20352
|
-
function regexpCursor(spec, state, from, to) {
|
|
20353
|
-
return new RegExpCursor(state.doc, spec.search, {
|
|
20354
|
-
ignoreCase: !spec.caseSensitive,
|
|
20355
|
-
test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined
|
|
20356
|
-
}, from, to);
|
|
20357
|
-
}
|
|
20358
|
-
function charBefore(str, index) {
|
|
20359
|
-
return str.slice(findClusterBreak(str, index, false), index);
|
|
20360
|
-
}
|
|
20361
|
-
function charAfter(str, index) {
|
|
20362
|
-
return str.slice(index, findClusterBreak(str, index));
|
|
20363
|
-
}
|
|
20364
|
-
function regexpWordTest(categorizer) {
|
|
20365
|
-
return (_from, _to, match) => !match[0].length || (categorizer(charBefore(match.input, match.index)) != CharCategory.Word || categorizer(charAfter(match.input, match.index)) != CharCategory.Word) && (categorizer(charAfter(match.input, match.index + match[0].length)) != CharCategory.Word || categorizer(charBefore(match.input, match.index + match[0].length)) != CharCategory.Word);
|
|
20366
|
-
}
|
|
20367
|
-
class RegExpQuery extends QueryType {
|
|
20368
|
-
nextMatch(state, curFrom, curTo) {
|
|
20369
|
-
let cursor = regexpCursor(this.spec, state, curTo, state.doc.length).next();
|
|
20370
|
-
if (cursor.done) cursor = regexpCursor(this.spec, state, 0, curFrom).next();
|
|
20371
|
-
return cursor.done ? null : cursor.value;
|
|
20372
|
-
}
|
|
20373
|
-
prevMatchInRange(state, from, to) {
|
|
20374
|
-
for (let size = 1;; size++) {
|
|
20375
|
-
let start = Math.max(from, to - size * 10000 /* FindPrev.ChunkSize */);
|
|
20376
|
-
let cursor = regexpCursor(this.spec, state, start, to),
|
|
20377
|
-
range = null;
|
|
20378
|
-
while (!cursor.next().done) range = cursor.value;
|
|
20379
|
-
if (range && (start == from || range.from > start + 10)) return range;
|
|
20380
|
-
if (start == from) return null;
|
|
20381
|
-
}
|
|
20382
|
-
}
|
|
20383
|
-
prevMatch(state, curFrom, curTo) {
|
|
20384
|
-
return this.prevMatchInRange(state, 0, curFrom) || this.prevMatchInRange(state, curTo, state.doc.length);
|
|
20385
|
-
}
|
|
20386
|
-
getReplacement(result) {
|
|
20387
|
-
return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$" : i == "&" ? result.match[0] : i != "0" && +i < result.match.length ? result.match[i] : m));
|
|
20388
|
-
}
|
|
20389
|
-
matchAll(state, limit) {
|
|
20390
|
-
let cursor = regexpCursor(this.spec, state, 0, state.doc.length),
|
|
20391
|
-
ranges = [];
|
|
20392
|
-
while (!cursor.next().done) {
|
|
20393
|
-
if (ranges.length >= limit) return null;
|
|
20394
|
-
ranges.push(cursor.value);
|
|
20395
|
-
}
|
|
20396
|
-
return ranges;
|
|
20397
|
-
}
|
|
20398
|
-
highlight(state, from, to, add) {
|
|
20399
|
-
let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250 /* RegExp.HighlightMargin */), Math.min(to + 250 /* RegExp.HighlightMargin */, state.doc.length));
|
|
20400
|
-
while (!cursor.next().done) add(cursor.value.from, cursor.value.to);
|
|
20401
|
-
}
|
|
20402
|
-
}
|
|
20403
|
-
/**
|
|
20404
|
-
A state effect that updates the current search query. Note that
|
|
20405
|
-
this only has an effect if the search state has been initialized
|
|
20406
|
-
(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
|
|
20407
|
-
by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
|
|
20408
|
-
once).
|
|
20409
|
-
*/
|
|
20410
|
-
const setSearchQuery = /*@__PURE__*/StateEffect.define();
|
|
20411
|
-
const togglePanel$1 = /*@__PURE__*/StateEffect.define();
|
|
20412
|
-
const searchState = /*@__PURE__*/StateField.define({
|
|
20413
|
-
create(state) {
|
|
20414
|
-
return new SearchState(defaultQuery(state).create(), null);
|
|
20415
|
-
},
|
|
20416
|
-
update(value, tr) {
|
|
20417
|
-
for (let effect of tr.effects) {
|
|
20418
|
-
if (effect.is(setSearchQuery)) value = new SearchState(effect.value.create(), value.panel);else if (effect.is(togglePanel$1)) value = new SearchState(value.query, effect.value ? createSearchPanel : null);
|
|
20419
|
-
}
|
|
20420
|
-
return value;
|
|
20421
|
-
},
|
|
20422
|
-
provide: f => showPanel.from(f, val => val.panel)
|
|
20423
|
-
});
|
|
20424
|
-
class SearchState {
|
|
20425
|
-
constructor(query, panel) {
|
|
20426
|
-
this.query = query;
|
|
20427
|
-
this.panel = panel;
|
|
20428
|
-
}
|
|
20429
|
-
}
|
|
20430
|
-
const matchMark = /*@__PURE__*/Decoration.mark({
|
|
20431
|
-
class: "cm-searchMatch"
|
|
20432
|
-
}),
|
|
20433
|
-
selectedMatchMark = /*@__PURE__*/Decoration.mark({
|
|
20434
|
-
class: "cm-searchMatch cm-searchMatch-selected"
|
|
20435
|
-
});
|
|
20436
|
-
const searchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
20437
|
-
constructor(view) {
|
|
20438
|
-
this.view = view;
|
|
20439
|
-
this.decorations = this.highlight(view.state.field(searchState));
|
|
20440
|
-
}
|
|
20441
|
-
update(update) {
|
|
20442
|
-
let state = update.state.field(searchState);
|
|
20443
|
-
if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged) this.decorations = this.highlight(state);
|
|
20444
|
-
}
|
|
20445
|
-
highlight({
|
|
20446
|
-
query,
|
|
20447
|
-
panel
|
|
20448
|
-
}) {
|
|
20449
|
-
if (!panel || !query.spec.valid) return Decoration.none;
|
|
20450
|
-
let {
|
|
20451
|
-
view
|
|
20452
|
-
} = this;
|
|
20453
|
-
let builder = new RangeSetBuilder();
|
|
20454
|
-
for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {
|
|
20455
|
-
let {
|
|
20456
|
-
from,
|
|
20457
|
-
to
|
|
20458
|
-
} = ranges[i];
|
|
20459
|
-
while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* RegExp.HighlightMargin */) to = ranges[++i].to;
|
|
20460
|
-
query.highlight(view.state, from, to, (from, to) => {
|
|
20461
|
-
let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);
|
|
20462
|
-
builder.add(from, to, selected ? selectedMatchMark : matchMark);
|
|
20463
|
-
});
|
|
20464
|
-
}
|
|
20465
|
-
return builder.finish();
|
|
20466
|
-
}
|
|
20467
|
-
}, {
|
|
20468
|
-
decorations: v => v.decorations
|
|
20469
|
-
});
|
|
20470
|
-
function searchCommand(f) {
|
|
20471
|
-
return view => {
|
|
20472
|
-
let state = view.state.field(searchState, false);
|
|
20473
|
-
return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);
|
|
20474
|
-
};
|
|
20475
|
-
}
|
|
20476
|
-
/**
|
|
20477
|
-
Open the search panel if it isn't already open, and move the
|
|
20478
|
-
selection to the first match after the current main selection.
|
|
20479
|
-
Will wrap around to the start of the document when it reaches the
|
|
20480
|
-
end.
|
|
20481
|
-
*/
|
|
20482
|
-
const findNext = /*@__PURE__*/searchCommand((view, {
|
|
20483
|
-
query
|
|
20484
|
-
}) => {
|
|
20485
|
-
let {
|
|
20486
|
-
to
|
|
20487
|
-
} = view.state.selection.main;
|
|
20488
|
-
let next = query.nextMatch(view.state, to, to);
|
|
20489
|
-
if (!next) return false;
|
|
20490
|
-
view.dispatch({
|
|
20491
|
-
selection: {
|
|
20492
|
-
anchor: next.from,
|
|
20493
|
-
head: next.to
|
|
20494
|
-
},
|
|
20495
|
-
scrollIntoView: true,
|
|
20496
|
-
effects: announceMatch(view, next),
|
|
20497
|
-
userEvent: "select.search"
|
|
20498
|
-
});
|
|
20499
|
-
return true;
|
|
20500
|
-
});
|
|
20501
|
-
/**
|
|
20502
|
-
Move the selection to the previous instance of the search query,
|
|
20503
|
-
before the current main selection. Will wrap past the start
|
|
20504
|
-
of the document to start searching at the end again.
|
|
20505
|
-
*/
|
|
20506
|
-
const findPrevious = /*@__PURE__*/searchCommand((view, {
|
|
20507
|
-
query
|
|
20508
|
-
}) => {
|
|
20509
|
-
let {
|
|
20510
|
-
state
|
|
20511
|
-
} = view,
|
|
20512
|
-
{
|
|
20513
|
-
from
|
|
20514
|
-
} = state.selection.main;
|
|
20515
|
-
let range = query.prevMatch(state, from, from);
|
|
20516
|
-
if (!range) return false;
|
|
20517
|
-
view.dispatch({
|
|
20518
|
-
selection: {
|
|
20519
|
-
anchor: range.from,
|
|
20520
|
-
head: range.to
|
|
20521
|
-
},
|
|
20522
|
-
scrollIntoView: true,
|
|
20523
|
-
effects: announceMatch(view, range),
|
|
20524
|
-
userEvent: "select.search"
|
|
20525
|
-
});
|
|
20526
|
-
return true;
|
|
20527
|
-
});
|
|
20528
|
-
/**
|
|
20529
|
-
Select all instances of the search query.
|
|
20530
|
-
*/
|
|
20531
|
-
const selectMatches = /*@__PURE__*/searchCommand((view, {
|
|
20532
|
-
query
|
|
20533
|
-
}) => {
|
|
20534
|
-
let ranges = query.matchAll(view.state, 1000);
|
|
20535
|
-
if (!ranges || !ranges.length) return false;
|
|
20536
|
-
view.dispatch({
|
|
20537
|
-
selection: EditorSelection.create(ranges.map(r => EditorSelection.range(r.from, r.to))),
|
|
20538
|
-
userEvent: "select.search.matches"
|
|
20539
|
-
});
|
|
20540
|
-
return true;
|
|
20541
|
-
});
|
|
20542
|
-
/**
|
|
20543
|
-
Select all instances of the currently selected text.
|
|
20544
|
-
*/
|
|
20545
|
-
const selectSelectionMatches = ({
|
|
20546
|
-
state,
|
|
20547
|
-
dispatch
|
|
20548
|
-
}) => {
|
|
20549
|
-
let sel = state.selection;
|
|
20550
|
-
if (sel.ranges.length > 1 || sel.main.empty) return false;
|
|
20551
|
-
let {
|
|
20552
|
-
from,
|
|
20553
|
-
to
|
|
20554
|
-
} = sel.main;
|
|
20555
|
-
let ranges = [],
|
|
20556
|
-
main = 0;
|
|
20557
|
-
for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {
|
|
20558
|
-
if (ranges.length > 1000) return false;
|
|
20559
|
-
if (cur.value.from == from) main = ranges.length;
|
|
20560
|
-
ranges.push(EditorSelection.range(cur.value.from, cur.value.to));
|
|
20561
|
-
}
|
|
20562
|
-
dispatch(state.update({
|
|
20563
|
-
selection: EditorSelection.create(ranges, main),
|
|
20564
|
-
userEvent: "select.search.matches"
|
|
20565
|
-
}));
|
|
20566
|
-
return true;
|
|
20567
|
-
};
|
|
20568
|
-
/**
|
|
20569
|
-
Replace the current match of the search query.
|
|
20570
|
-
*/
|
|
20571
|
-
const replaceNext = /*@__PURE__*/searchCommand((view, {
|
|
20572
|
-
query
|
|
20573
|
-
}) => {
|
|
20574
|
-
let {
|
|
20575
|
-
state
|
|
20576
|
-
} = view,
|
|
20577
|
-
{
|
|
20578
|
-
from,
|
|
20579
|
-
to
|
|
20580
|
-
} = state.selection.main;
|
|
20581
|
-
if (state.readOnly) return false;
|
|
20582
|
-
let next = query.nextMatch(state, from, from);
|
|
20583
|
-
if (!next) return false;
|
|
20584
|
-
let changes = [],
|
|
20585
|
-
selection,
|
|
20586
|
-
replacement;
|
|
20587
|
-
let announce = [];
|
|
20588
|
-
if (next.from == from && next.to == to) {
|
|
20589
|
-
replacement = state.toText(query.getReplacement(next));
|
|
20590
|
-
changes.push({
|
|
20591
|
-
from: next.from,
|
|
20592
|
-
to: next.to,
|
|
20593
|
-
insert: replacement
|
|
20594
|
-
});
|
|
20595
|
-
next = query.nextMatch(state, next.from, next.to);
|
|
20596
|
-
announce.push(EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
|
|
20597
|
-
}
|
|
20598
|
-
if (next) {
|
|
20599
|
-
let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;
|
|
20600
|
-
selection = {
|
|
20601
|
-
anchor: next.from - off,
|
|
20602
|
-
head: next.to - off
|
|
20603
|
-
};
|
|
20604
|
-
announce.push(announceMatch(view, next));
|
|
20605
|
-
}
|
|
20606
|
-
view.dispatch({
|
|
20607
|
-
changes,
|
|
20608
|
-
selection,
|
|
20609
|
-
scrollIntoView: !!selection,
|
|
20610
|
-
effects: announce,
|
|
20611
|
-
userEvent: "input.replace"
|
|
20612
|
-
});
|
|
20613
|
-
return true;
|
|
20614
|
-
});
|
|
20615
|
-
/**
|
|
20616
|
-
Replace all instances of the search query with the given
|
|
20617
|
-
replacement.
|
|
20618
|
-
*/
|
|
20619
|
-
const replaceAll = /*@__PURE__*/searchCommand((view, {
|
|
20620
|
-
query
|
|
20621
|
-
}) => {
|
|
20622
|
-
if (view.state.readOnly) return false;
|
|
20623
|
-
let changes = query.matchAll(view.state, 1e9).map(match => {
|
|
20624
|
-
let {
|
|
20625
|
-
from,
|
|
20626
|
-
to
|
|
20627
|
-
} = match;
|
|
20628
|
-
return {
|
|
20629
|
-
from,
|
|
20630
|
-
to,
|
|
20631
|
-
insert: query.getReplacement(match)
|
|
20632
|
-
};
|
|
20633
|
-
});
|
|
20634
|
-
if (!changes.length) return false;
|
|
20635
|
-
let announceText = view.state.phrase("replaced $ matches", changes.length) + ".";
|
|
20636
|
-
view.dispatch({
|
|
20637
|
-
changes,
|
|
20638
|
-
effects: EditorView.announce.of(announceText),
|
|
20639
|
-
userEvent: "input.replace.all"
|
|
20640
|
-
});
|
|
20641
|
-
return true;
|
|
20642
|
-
});
|
|
20643
|
-
function createSearchPanel(view) {
|
|
20644
|
-
return view.state.facet(searchConfigFacet).createPanel(view);
|
|
20645
|
-
}
|
|
20646
|
-
function defaultQuery(state, fallback) {
|
|
20647
|
-
var _a, _b, _c, _d;
|
|
20648
|
-
let sel = state.selection.main;
|
|
20649
|
-
let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to);
|
|
20650
|
-
if (fallback && !selText) return fallback;
|
|
20651
|
-
let config = state.facet(searchConfigFacet);
|
|
20652
|
-
return new SearchQuery({
|
|
20653
|
-
search: ((_a = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _a !== void 0 ? _a : config.literal) ? selText : selText.replace(/\n/g, "\\n"),
|
|
20654
|
-
caseSensitive: (_b = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _b !== void 0 ? _b : config.caseSensitive,
|
|
20655
|
-
literal: (_c = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _c !== void 0 ? _c : config.literal,
|
|
20656
|
-
wholeWord: (_d = fallback === null || fallback === void 0 ? void 0 : fallback.wholeWord) !== null && _d !== void 0 ? _d : config.wholeWord
|
|
20657
|
-
});
|
|
20658
|
-
}
|
|
20659
|
-
/**
|
|
20660
|
-
Make sure the search panel is open and focused.
|
|
20661
|
-
*/
|
|
20662
|
-
const openSearchPanel = view => {
|
|
20663
|
-
let state = view.state.field(searchState, false);
|
|
20664
|
-
if (state && state.panel) {
|
|
20665
|
-
let panel = getPanel(view, createSearchPanel);
|
|
20666
|
-
if (!panel) return false;
|
|
20667
|
-
let searchInput = panel.dom.querySelector("[main-field]");
|
|
20668
|
-
if (searchInput && searchInput != view.root.activeElement) {
|
|
20669
|
-
let query = defaultQuery(view.state, state.query.spec);
|
|
20670
|
-
if (query.valid) view.dispatch({
|
|
20671
|
-
effects: setSearchQuery.of(query)
|
|
20672
|
-
});
|
|
20673
|
-
searchInput.focus();
|
|
20674
|
-
searchInput.select();
|
|
20675
|
-
}
|
|
20676
|
-
} else {
|
|
20677
|
-
view.dispatch({
|
|
20678
|
-
effects: [togglePanel$1.of(true), state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect.appendConfig.of(searchExtensions)]
|
|
20679
|
-
});
|
|
20680
|
-
}
|
|
20681
|
-
return true;
|
|
20682
|
-
};
|
|
20683
|
-
/**
|
|
20684
|
-
Close the search panel.
|
|
20685
|
-
*/
|
|
20686
|
-
const closeSearchPanel = view => {
|
|
20687
|
-
let state = view.state.field(searchState, false);
|
|
20688
|
-
if (!state || !state.panel) return false;
|
|
20689
|
-
let panel = getPanel(view, createSearchPanel);
|
|
20690
|
-
if (panel && panel.dom.contains(view.root.activeElement)) view.focus();
|
|
20691
|
-
view.dispatch({
|
|
20692
|
-
effects: togglePanel$1.of(false)
|
|
20693
|
-
});
|
|
20694
|
-
return true;
|
|
20695
|
-
};
|
|
20696
|
-
/**
|
|
20697
|
-
Default search-related key bindings.
|
|
20698
|
-
|
|
20699
|
-
- Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
|
|
20700
|
-
- F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
|
|
20701
|
-
- Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
|
|
20702
|
-
- Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
|
|
20703
|
-
- Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
|
|
20704
|
-
*/
|
|
20705
|
-
const searchKeymap = [{
|
|
20706
|
-
key: "Mod-f",
|
|
20707
|
-
run: openSearchPanel,
|
|
20708
|
-
scope: "editor search-panel"
|
|
20709
|
-
}, {
|
|
20710
|
-
key: "F3",
|
|
20711
|
-
run: findNext,
|
|
20712
|
-
shift: findPrevious,
|
|
20713
|
-
scope: "editor search-panel",
|
|
20714
|
-
preventDefault: true
|
|
20715
|
-
}, {
|
|
20716
|
-
key: "Mod-g",
|
|
20717
|
-
run: findNext,
|
|
20718
|
-
shift: findPrevious,
|
|
20719
|
-
scope: "editor search-panel",
|
|
20720
|
-
preventDefault: true
|
|
20721
|
-
}, {
|
|
20722
|
-
key: "Escape",
|
|
20723
|
-
run: closeSearchPanel,
|
|
20724
|
-
scope: "editor search-panel"
|
|
20725
|
-
}, {
|
|
20726
|
-
key: "Mod-Shift-l",
|
|
20727
|
-
run: selectSelectionMatches
|
|
20728
|
-
}, {
|
|
20729
|
-
key: "Alt-g",
|
|
20730
|
-
run: gotoLine
|
|
20731
|
-
}, {
|
|
20732
|
-
key: "Mod-d",
|
|
20733
|
-
run: selectNextOccurrence,
|
|
20734
|
-
preventDefault: true
|
|
20735
|
-
}];
|
|
20736
|
-
class SearchPanel {
|
|
20737
|
-
constructor(view) {
|
|
20738
|
-
this.view = view;
|
|
20739
|
-
let query = this.query = view.state.field(searchState).query.spec;
|
|
20740
|
-
this.commit = this.commit.bind(this);
|
|
20741
|
-
this.searchField = crelt("input", {
|
|
20742
|
-
value: query.search,
|
|
20743
|
-
placeholder: phrase(view, "Find"),
|
|
20744
|
-
"aria-label": phrase(view, "Find"),
|
|
20745
|
-
class: "cm-textfield",
|
|
20746
|
-
name: "search",
|
|
20747
|
-
form: "",
|
|
20748
|
-
"main-field": "true",
|
|
20749
|
-
onchange: this.commit,
|
|
20750
|
-
onkeyup: this.commit
|
|
20751
|
-
});
|
|
20752
|
-
this.replaceField = crelt("input", {
|
|
20753
|
-
value: query.replace,
|
|
20754
|
-
placeholder: phrase(view, "Replace"),
|
|
20755
|
-
"aria-label": phrase(view, "Replace"),
|
|
20756
|
-
class: "cm-textfield",
|
|
20757
|
-
name: "replace",
|
|
20758
|
-
form: "",
|
|
20759
|
-
onchange: this.commit,
|
|
20760
|
-
onkeyup: this.commit
|
|
20761
|
-
});
|
|
20762
|
-
this.caseField = crelt("input", {
|
|
20763
|
-
type: "checkbox",
|
|
20764
|
-
name: "case",
|
|
20765
|
-
form: "",
|
|
20766
|
-
checked: query.caseSensitive,
|
|
20767
|
-
onchange: this.commit
|
|
20768
|
-
});
|
|
20769
|
-
this.reField = crelt("input", {
|
|
20770
|
-
type: "checkbox",
|
|
20771
|
-
name: "re",
|
|
20772
|
-
form: "",
|
|
20773
|
-
checked: query.regexp,
|
|
20774
|
-
onchange: this.commit
|
|
20775
|
-
});
|
|
20776
|
-
this.wordField = crelt("input", {
|
|
20777
|
-
type: "checkbox",
|
|
20778
|
-
name: "word",
|
|
20779
|
-
form: "",
|
|
20780
|
-
checked: query.wholeWord,
|
|
20781
|
-
onchange: this.commit
|
|
20782
|
-
});
|
|
20783
|
-
function button(name, onclick, content) {
|
|
20784
|
-
return crelt("button", {
|
|
20785
|
-
class: "cm-button",
|
|
20786
|
-
name,
|
|
20787
|
-
onclick,
|
|
20788
|
-
type: "button"
|
|
20789
|
-
}, content);
|
|
20790
|
-
}
|
|
20791
|
-
this.dom = crelt("div", {
|
|
20792
|
-
onkeydown: e => this.keydown(e),
|
|
20793
|
-
class: "cm-search"
|
|
20794
|
-
}, [this.searchField, button("next", () => findNext(view), [phrase(view, "next")]), button("prev", () => findPrevious(view), [phrase(view, "previous")]), button("select", () => selectMatches(view), [phrase(view, "all")]), crelt("label", null, [this.caseField, phrase(view, "match case")]), crelt("label", null, [this.reField, phrase(view, "regexp")]), crelt("label", null, [this.wordField, phrase(view, "by word")]), ...(view.state.readOnly ? [] : [crelt("br"), this.replaceField, button("replace", () => replaceNext(view), [phrase(view, "replace")]), button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")])]), crelt("button", {
|
|
20795
|
-
name: "close",
|
|
20796
|
-
onclick: () => closeSearchPanel(view),
|
|
20797
|
-
"aria-label": phrase(view, "close"),
|
|
20798
|
-
type: "button"
|
|
20799
|
-
}, ["×"])]);
|
|
20800
|
-
}
|
|
20801
|
-
commit() {
|
|
20802
|
-
let query = new SearchQuery({
|
|
20803
|
-
search: this.searchField.value,
|
|
20804
|
-
caseSensitive: this.caseField.checked,
|
|
20805
|
-
regexp: this.reField.checked,
|
|
20806
|
-
wholeWord: this.wordField.checked,
|
|
20807
|
-
replace: this.replaceField.value
|
|
20808
|
-
});
|
|
20809
|
-
if (!query.eq(this.query)) {
|
|
20810
|
-
this.query = query;
|
|
20811
|
-
this.view.dispatch({
|
|
20812
|
-
effects: setSearchQuery.of(query)
|
|
20813
|
-
});
|
|
20814
|
-
}
|
|
20815
|
-
}
|
|
20816
|
-
keydown(e) {
|
|
20817
|
-
if (runScopeHandlers(this.view, e, "search-panel")) {
|
|
20818
|
-
e.preventDefault();
|
|
20819
|
-
} else if (e.keyCode == 13 && e.target == this.searchField) {
|
|
20820
|
-
e.preventDefault();
|
|
20821
|
-
(e.shiftKey ? findPrevious : findNext)(this.view);
|
|
20822
|
-
} else if (e.keyCode == 13 && e.target == this.replaceField) {
|
|
20823
|
-
e.preventDefault();
|
|
20824
|
-
replaceNext(this.view);
|
|
20825
|
-
}
|
|
20826
|
-
}
|
|
20827
|
-
update(update) {
|
|
20828
|
-
for (let tr of update.transactions) for (let effect of tr.effects) {
|
|
20829
|
-
if (effect.is(setSearchQuery) && !effect.value.eq(this.query)) this.setQuery(effect.value);
|
|
20830
|
-
}
|
|
20831
|
-
}
|
|
20832
|
-
setQuery(query) {
|
|
20833
|
-
this.query = query;
|
|
20834
|
-
this.searchField.value = query.search;
|
|
20835
|
-
this.replaceField.value = query.replace;
|
|
20836
|
-
this.caseField.checked = query.caseSensitive;
|
|
20837
|
-
this.reField.checked = query.regexp;
|
|
20838
|
-
this.wordField.checked = query.wholeWord;
|
|
20839
|
-
}
|
|
20840
|
-
mount() {
|
|
20841
|
-
this.searchField.select();
|
|
20842
|
-
}
|
|
20843
|
-
get pos() {
|
|
20844
|
-
return 80;
|
|
20845
|
-
}
|
|
20846
|
-
get top() {
|
|
20847
|
-
return this.view.state.facet(searchConfigFacet).top;
|
|
20848
|
-
}
|
|
20849
|
-
}
|
|
20850
|
-
function phrase(view, phrase) {
|
|
20851
|
-
return view.state.phrase(phrase);
|
|
20852
|
-
}
|
|
20853
|
-
const AnnounceMargin = 30;
|
|
20854
|
-
const Break = /[\s\.,:;?!]/;
|
|
20855
|
-
function announceMatch(view, {
|
|
20856
|
-
from,
|
|
20857
|
-
to
|
|
20858
|
-
}) {
|
|
20859
|
-
let line = view.state.doc.lineAt(from),
|
|
20860
|
-
lineEnd = view.state.doc.lineAt(to).to;
|
|
20861
|
-
let start = Math.max(line.from, from - AnnounceMargin),
|
|
20862
|
-
end = Math.min(lineEnd, to + AnnounceMargin);
|
|
20863
|
-
let text = view.state.sliceDoc(start, end);
|
|
20864
|
-
if (start != line.from) {
|
|
20865
|
-
for (let i = 0; i < AnnounceMargin; i++) if (!Break.test(text[i + 1]) && Break.test(text[i])) {
|
|
20866
|
-
text = text.slice(i);
|
|
20867
|
-
break;
|
|
20868
|
-
}
|
|
20869
|
-
}
|
|
20870
|
-
if (end != lineEnd) {
|
|
20871
|
-
for (let i = text.length - 1; i > text.length - AnnounceMargin; i--) if (!Break.test(text[i - 1]) && Break.test(text[i])) {
|
|
20872
|
-
text = text.slice(0, i);
|
|
20873
|
-
break;
|
|
20874
|
-
}
|
|
20875
|
-
}
|
|
20876
|
-
return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${line.number}.`);
|
|
20877
|
-
}
|
|
20878
|
-
const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
|
|
20879
|
-
".cm-panel.cm-search": {
|
|
20880
|
-
padding: "2px 6px 4px",
|
|
20881
|
-
position: "relative",
|
|
20882
|
-
"& [name=close]": {
|
|
20883
|
-
position: "absolute",
|
|
20884
|
-
top: "0",
|
|
20885
|
-
right: "4px",
|
|
20886
|
-
backgroundColor: "inherit",
|
|
20887
|
-
border: "none",
|
|
20888
|
-
font: "inherit",
|
|
20889
|
-
padding: 0,
|
|
20890
|
-
margin: 0
|
|
20891
|
-
},
|
|
20892
|
-
"& input, & button, & label": {
|
|
20893
|
-
margin: ".2em .6em .2em 0"
|
|
20894
|
-
},
|
|
20895
|
-
"& input[type=checkbox]": {
|
|
20896
|
-
marginRight: ".2em"
|
|
20897
|
-
},
|
|
20898
|
-
"& label": {
|
|
20899
|
-
fontSize: "80%",
|
|
20900
|
-
whiteSpace: "pre"
|
|
20901
|
-
}
|
|
20902
|
-
},
|
|
20903
|
-
"&light .cm-searchMatch": {
|
|
20904
|
-
backgroundColor: "#ffff0054"
|
|
20905
|
-
},
|
|
20906
|
-
"&dark .cm-searchMatch": {
|
|
20907
|
-
backgroundColor: "#00ffff8a"
|
|
20908
|
-
},
|
|
20909
|
-
"&light .cm-searchMatch-selected": {
|
|
20910
|
-
backgroundColor: "#ff6a0054"
|
|
20911
|
-
},
|
|
20912
|
-
"&dark .cm-searchMatch-selected": {
|
|
20913
|
-
backgroundColor: "#ff00ff8a"
|
|
20914
|
-
}
|
|
20915
|
-
});
|
|
20916
|
-
const searchExtensions = [searchState, /*@__PURE__*/Prec.lowest(searchHighlighter), baseTheme$2];
|
|
20917
|
-
|
|
20918
|
-
/**
|
|
20919
|
-
An instance of this is passed to completion source functions.
|
|
20920
|
-
*/
|
|
20921
|
-
class CompletionContext {
|
|
20922
|
-
/**
|
|
20923
|
-
Create a new completion context. (Mostly useful for testing
|
|
20924
|
-
completion sources—in the editor, the extension will create
|
|
20925
|
-
these for you.)
|
|
20926
|
-
*/
|
|
20927
|
-
constructor(
|
|
20928
|
-
/**
|
|
20929
|
-
The editor state that the completion happens in.
|
|
20930
|
-
*/
|
|
20931
|
-
state,
|
|
20932
|
-
/**
|
|
20933
|
-
The position at which the completion is happening.
|
|
20934
|
-
*/
|
|
20935
|
-
pos,
|
|
20936
|
-
/**
|
|
20937
|
-
Indicates whether completion was activated explicitly, or
|
|
20938
|
-
implicitly by typing. The usual way to respond to this is to
|
|
20939
|
-
only return completions when either there is part of a
|
|
20940
|
-
completable entity before the cursor, or `explicit` is true.
|
|
20941
|
-
*/
|
|
20942
|
-
explicit) {
|
|
20943
|
-
this.state = state;
|
|
20944
|
-
this.pos = pos;
|
|
20945
|
-
this.explicit = explicit;
|
|
20946
|
-
/**
|
|
20947
|
-
@internal
|
|
20948
|
-
*/
|
|
20949
|
-
this.abortListeners = [];
|
|
20950
|
-
}
|
|
20951
|
-
/**
|
|
20952
|
-
Get the extent, content, and (if there is a token) type of the
|
|
20953
|
-
token before `this.pos`.
|
|
20954
|
-
*/
|
|
20955
|
-
tokenBefore(types) {
|
|
20956
|
-
let token = syntaxTree(this.state).resolveInner(this.pos, -1);
|
|
20957
|
-
while (token && types.indexOf(token.name) < 0) token = token.parent;
|
|
20958
|
-
return token ? {
|
|
20959
|
-
from: token.from,
|
|
20960
|
-
to: this.pos,
|
|
20961
|
-
text: this.state.sliceDoc(token.from, this.pos),
|
|
20962
|
-
type: token.type
|
|
20963
|
-
} : null;
|
|
20964
|
-
}
|
|
20965
|
-
/**
|
|
20966
|
-
Get the match of the given expression directly before the
|
|
20967
|
-
cursor.
|
|
20968
|
-
*/
|
|
20969
|
-
matchBefore(expr) {
|
|
20970
|
-
let line = this.state.doc.lineAt(this.pos);
|
|
20971
|
-
let start = Math.max(line.from, this.pos - 250);
|
|
20972
|
-
let str = line.text.slice(start - line.from, this.pos - line.from);
|
|
20973
|
-
let found = str.search(ensureAnchor(expr, false));
|
|
20974
|
-
return found < 0 ? null : {
|
|
20975
|
-
from: start + found,
|
|
20976
|
-
to: this.pos,
|
|
20977
|
-
text: str.slice(found)
|
|
20978
|
-
};
|
|
20979
|
-
}
|
|
20980
|
-
/**
|
|
20981
|
-
Yields true when the query has been aborted. Can be useful in
|
|
20982
|
-
asynchronous queries to avoid doing work that will be ignored.
|
|
20983
|
-
*/
|
|
20984
|
-
get aborted() {
|
|
20985
|
-
return this.abortListeners == null;
|
|
20986
|
-
}
|
|
20987
|
-
/**
|
|
20988
|
-
Allows you to register abort handlers, which will be called when
|
|
20989
|
-
the query is
|
|
20990
|
-
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
|
|
20991
|
-
*/
|
|
20992
|
-
addEventListener(type, listener) {
|
|
20993
|
-
if (type == "abort" && this.abortListeners) this.abortListeners.push(listener);
|
|
20994
|
-
}
|
|
20995
|
-
}
|
|
20996
|
-
function toSet(chars) {
|
|
20997
|
-
let flat = Object.keys(chars).join("");
|
|
20998
|
-
let words = /\w/.test(flat);
|
|
20999
|
-
if (words) flat = flat.replace(/\w/g, "");
|
|
21000
|
-
return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
|
|
21001
|
-
}
|
|
21002
|
-
function prefixMatch(options) {
|
|
21003
|
-
let first = Object.create(null),
|
|
21004
|
-
rest = Object.create(null);
|
|
21005
|
-
for (let {
|
|
21006
|
-
label
|
|
21007
|
-
} of options) {
|
|
21008
|
-
first[label[0]] = true;
|
|
21009
|
-
for (let i = 1; i < label.length; i++) rest[label[i]] = true;
|
|
21010
|
-
}
|
|
21011
|
-
let source = toSet(first) + toSet(rest) + "*$";
|
|
21012
|
-
return [new RegExp("^" + source), new RegExp(source)];
|
|
21013
|
-
}
|
|
21014
|
-
/**
|
|
21015
|
-
Given a a fixed array of options, return an autocompleter that
|
|
21016
|
-
completes them.
|
|
21017
|
-
*/
|
|
21018
|
-
function completeFromList(list) {
|
|
21019
|
-
let options = list.map(o => typeof o == "string" ? {
|
|
21020
|
-
label: o
|
|
21021
|
-
} : o);
|
|
21022
|
-
let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options);
|
|
21023
|
-
return context => {
|
|
21024
|
-
let token = context.matchBefore(match);
|
|
21025
|
-
return token || context.explicit ? {
|
|
21026
|
-
from: token ? token.from : context.pos,
|
|
21027
|
-
options,
|
|
21028
|
-
validFor
|
|
21029
|
-
} : null;
|
|
21030
|
-
};
|
|
21031
|
-
}
|
|
21032
|
-
/**
|
|
21033
|
-
Wrap the given completion source so that it will not fire when the
|
|
21034
|
-
cursor is in a syntax node with one of the given names.
|
|
21035
|
-
*/
|
|
21036
|
-
function ifNotIn(nodes, source) {
|
|
21037
|
-
return context => {
|
|
21038
|
-
for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) if (nodes.indexOf(pos.name) > -1) return null;
|
|
21039
|
-
return source(context);
|
|
21040
|
-
};
|
|
21041
|
-
}
|
|
21042
|
-
class Option {
|
|
21043
|
-
constructor(completion, source, match) {
|
|
21044
|
-
this.completion = completion;
|
|
21045
|
-
this.source = source;
|
|
21046
|
-
this.match = match;
|
|
21047
|
-
}
|
|
21048
|
-
}
|
|
21049
|
-
function cur(state) {
|
|
21050
|
-
return state.selection.main.head;
|
|
21051
|
-
}
|
|
21052
|
-
// Make sure the given regexp has a $ at its end and, if `start` is
|
|
21053
|
-
// true, a ^ at its start.
|
|
21054
|
-
function ensureAnchor(expr, start) {
|
|
21055
|
-
var _a;
|
|
21056
|
-
let {
|
|
21057
|
-
source
|
|
21058
|
-
} = expr;
|
|
21059
|
-
let addStart = start && source[0] != "^",
|
|
21060
|
-
addEnd = source[source.length - 1] != "$";
|
|
21061
|
-
if (!addStart && !addEnd) return expr;
|
|
21062
|
-
return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : expr.ignoreCase ? "i" : "");
|
|
21063
|
-
}
|
|
21064
|
-
/**
|
|
21065
|
-
This annotation is added to transactions that are produced by
|
|
21066
|
-
picking a completion.
|
|
21067
|
-
*/
|
|
21068
|
-
const pickedCompletion = /*@__PURE__*/Annotation.define();
|
|
21069
|
-
/**
|
|
21070
|
-
Helper function that returns a transaction spec which inserts a
|
|
21071
|
-
completion's text in the main selection range, and any other
|
|
21072
|
-
selection range that has the same text in front of it.
|
|
21073
|
-
*/
|
|
21074
|
-
function insertCompletionText(state, text, from, to) {
|
|
21075
|
-
return Object.assign(Object.assign({}, state.changeByRange(range => {
|
|
21076
|
-
if (range == state.selection.main) return {
|
|
21077
|
-
changes: {
|
|
21078
|
-
from: from,
|
|
21079
|
-
to: to,
|
|
21080
|
-
insert: text
|
|
21081
|
-
},
|
|
21082
|
-
range: EditorSelection.cursor(from + text.length)
|
|
17996
|
+
function insertCompletionText(state, text, from, to) {
|
|
17997
|
+
return Object.assign(Object.assign({}, state.changeByRange(range => {
|
|
17998
|
+
if (range == state.selection.main) return {
|
|
17999
|
+
changes: {
|
|
18000
|
+
from: from,
|
|
18001
|
+
to: to,
|
|
18002
|
+
insert: text
|
|
18003
|
+
},
|
|
18004
|
+
range: EditorSelection.cursor(from + text.length)
|
|
21083
18005
|
};
|
|
21084
18006
|
let len = to - from;
|
|
21085
18007
|
if (!range.empty || len && state.sliceDoc(range.from - len, range.from) != state.sliceDoc(from, to)) return {
|
|
@@ -21953,7 +18875,7 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
21953
18875
|
}
|
|
21954
18876
|
});
|
|
21955
18877
|
|
|
21956
|
-
const baseTheme
|
|
18878
|
+
const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
21957
18879
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
21958
18880
|
"& > ul": {
|
|
21959
18881
|
fontFamily: "monospace",
|
|
@@ -22296,7 +19218,7 @@ function snippet(template) {
|
|
|
22296
19218
|
if (ranges.length > 1) {
|
|
22297
19219
|
let active = new ActiveSnippet(ranges, 0);
|
|
22298
19220
|
let effects = spec.effects = [setActive.of(active)];
|
|
22299
|
-
if (editor.state.field(snippetState, false) === undefined) effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme
|
|
19221
|
+
if (editor.state.field(snippetState, false) === undefined) effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
|
|
22300
19222
|
}
|
|
22301
19223
|
editor.dispatch(editor.state.update(spec));
|
|
22302
19224
|
};
|
|
@@ -22605,790 +19527,120 @@ function handleSame(state, token, allowTriple, config) {
|
|
|
22605
19527
|
return {
|
|
22606
19528
|
changes: {
|
|
22607
19529
|
insert: token + token,
|
|
22608
|
-
from: pos
|
|
22609
|
-
},
|
|
22610
|
-
effects: closeBracketEffect.of(pos + token.length),
|
|
22611
|
-
range: EditorSelection.cursor(pos + token.length)
|
|
22612
|
-
};
|
|
22613
|
-
} else if (closedBracketAt(state, pos)) {
|
|
22614
|
-
let isTriple = allowTriple && state.sliceDoc(pos, pos + token.length * 3) == token + token + token;
|
|
22615
|
-
return {
|
|
22616
|
-
range: EditorSelection.cursor(pos + token.length * (isTriple ? 3 : 1)),
|
|
22617
|
-
effects: skipBracketEffect.of(pos)
|
|
22618
|
-
};
|
|
22619
|
-
}
|
|
22620
|
-
} else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token && (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 && nodeStart$1(state, start)) {
|
|
22621
|
-
return {
|
|
22622
|
-
changes: {
|
|
22623
|
-
insert: token + token + token + token,
|
|
22624
|
-
from: pos
|
|
22625
|
-
},
|
|
22626
|
-
effects: closeBracketEffect.of(pos + token.length),
|
|
22627
|
-
range: EditorSelection.cursor(pos + token.length)
|
|
22628
|
-
};
|
|
22629
|
-
} else if (state.charCategorizer(pos)(next) != CharCategory.Word) {
|
|
22630
|
-
if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes)) return {
|
|
22631
|
-
changes: {
|
|
22632
|
-
insert: token + token,
|
|
22633
|
-
from: pos
|
|
22634
|
-
},
|
|
22635
|
-
effects: closeBracketEffect.of(pos + token.length),
|
|
22636
|
-
range: EditorSelection.cursor(pos + token.length)
|
|
22637
|
-
};
|
|
22638
|
-
}
|
|
22639
|
-
return {
|
|
22640
|
-
range: dont = range
|
|
22641
|
-
};
|
|
22642
|
-
});
|
|
22643
|
-
return dont ? null : state.update(changes, {
|
|
22644
|
-
scrollIntoView: true,
|
|
22645
|
-
userEvent: "input.type"
|
|
22646
|
-
});
|
|
22647
|
-
}
|
|
22648
|
-
function nodeStart$1(state, pos) {
|
|
22649
|
-
let tree = syntaxTree(state).resolveInner(pos + 1);
|
|
22650
|
-
return tree.parent && tree.from == pos;
|
|
22651
|
-
}
|
|
22652
|
-
function probablyInString(state, pos, quoteToken, prefixes) {
|
|
22653
|
-
let node = syntaxTree(state).resolveInner(pos, -1);
|
|
22654
|
-
let maxPrefix = prefixes.reduce((m, p) => Math.max(m, p.length), 0);
|
|
22655
|
-
for (let i = 0; i < 5; i++) {
|
|
22656
|
-
let start = state.sliceDoc(node.from, Math.min(node.to, node.from + quoteToken.length + maxPrefix));
|
|
22657
|
-
let quotePos = start.indexOf(quoteToken);
|
|
22658
|
-
if (!quotePos || quotePos > -1 && prefixes.indexOf(start.slice(0, quotePos)) > -1) {
|
|
22659
|
-
let first = node.firstChild;
|
|
22660
|
-
while (first && first.from == node.from && first.to - first.from > quoteToken.length + quotePos) {
|
|
22661
|
-
if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken) return false;
|
|
22662
|
-
first = first.firstChild;
|
|
22663
|
-
}
|
|
22664
|
-
return true;
|
|
22665
|
-
}
|
|
22666
|
-
let parent = node.to == pos && node.parent;
|
|
22667
|
-
if (!parent) break;
|
|
22668
|
-
node = parent;
|
|
22669
|
-
}
|
|
22670
|
-
return false;
|
|
22671
|
-
}
|
|
22672
|
-
function canStartStringAt(state, pos, prefixes) {
|
|
22673
|
-
let charCat = state.charCategorizer(pos);
|
|
22674
|
-
if (charCat(state.sliceDoc(pos - 1, pos)) != CharCategory.Word) return pos;
|
|
22675
|
-
for (let prefix of prefixes) {
|
|
22676
|
-
let start = pos - prefix.length;
|
|
22677
|
-
if (state.sliceDoc(start, pos) == prefix && charCat(state.sliceDoc(start - 1, start)) != CharCategory.Word) return start;
|
|
22678
|
-
}
|
|
22679
|
-
return -1;
|
|
22680
|
-
}
|
|
22681
|
-
|
|
22682
|
-
/**
|
|
22683
|
-
Returns an extension that enables autocompletion.
|
|
22684
|
-
*/
|
|
22685
|
-
function autocompletion(config = {}) {
|
|
22686
|
-
return [completionState, completionConfig.of(config), completionPlugin, completionKeymapExt, baseTheme$1];
|
|
22687
|
-
}
|
|
22688
|
-
/**
|
|
22689
|
-
Basic keybindings for autocompletion.
|
|
22690
|
-
|
|
22691
|
-
- Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
|
|
22692
|
-
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
|
|
22693
|
-
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
|
|
22694
|
-
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
|
|
22695
|
-
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
|
22696
|
-
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
|
22697
|
-
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
|
|
22698
|
-
*/
|
|
22699
|
-
const completionKeymap = [{
|
|
22700
|
-
key: "Ctrl-Space",
|
|
22701
|
-
run: startCompletion
|
|
22702
|
-
}, {
|
|
22703
|
-
key: "Escape",
|
|
22704
|
-
run: closeCompletion
|
|
22705
|
-
}, {
|
|
22706
|
-
key: "ArrowDown",
|
|
22707
|
-
run: /*@__PURE__*/moveCompletionSelection(true)
|
|
22708
|
-
}, {
|
|
22709
|
-
key: "ArrowUp",
|
|
22710
|
-
run: /*@__PURE__*/moveCompletionSelection(false)
|
|
22711
|
-
}, {
|
|
22712
|
-
key: "PageDown",
|
|
22713
|
-
run: /*@__PURE__*/moveCompletionSelection(true, "page")
|
|
22714
|
-
}, {
|
|
22715
|
-
key: "PageUp",
|
|
22716
|
-
run: /*@__PURE__*/moveCompletionSelection(false, "page")
|
|
22717
|
-
}, {
|
|
22718
|
-
key: "Enter",
|
|
22719
|
-
run: acceptCompletion
|
|
22720
|
-
}];
|
|
22721
|
-
const completionKeymapExt = /*@__PURE__*/Prec.highest( /*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
|
|
22722
|
-
|
|
22723
|
-
class SelectedDiagnostic {
|
|
22724
|
-
constructor(from, to, diagnostic) {
|
|
22725
|
-
this.from = from;
|
|
22726
|
-
this.to = to;
|
|
22727
|
-
this.diagnostic = diagnostic;
|
|
22728
|
-
}
|
|
22729
|
-
}
|
|
22730
|
-
class LintState {
|
|
22731
|
-
constructor(diagnostics, panel, selected) {
|
|
22732
|
-
this.diagnostics = diagnostics;
|
|
22733
|
-
this.panel = panel;
|
|
22734
|
-
this.selected = selected;
|
|
22735
|
-
}
|
|
22736
|
-
static init(diagnostics, panel, state) {
|
|
22737
|
-
// Filter the list of diagnostics for which to create markers
|
|
22738
|
-
let markedDiagnostics = diagnostics;
|
|
22739
|
-
let diagnosticFilter = state.facet(lintConfig).markerFilter;
|
|
22740
|
-
if (diagnosticFilter) markedDiagnostics = diagnosticFilter(markedDiagnostics);
|
|
22741
|
-
let ranges = Decoration.set(markedDiagnostics.map(d => {
|
|
22742
|
-
// For zero-length ranges or ranges covering only a line break, create a widget
|
|
22743
|
-
return d.from == d.to || d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from ? Decoration.widget({
|
|
22744
|
-
widget: new DiagnosticWidget(d),
|
|
22745
|
-
diagnostic: d
|
|
22746
|
-
}).range(d.from) : Decoration.mark({
|
|
22747
|
-
attributes: {
|
|
22748
|
-
class: "cm-lintRange cm-lintRange-" + d.severity
|
|
22749
|
-
},
|
|
22750
|
-
diagnostic: d
|
|
22751
|
-
}).range(d.from, d.to);
|
|
22752
|
-
}), true);
|
|
22753
|
-
return new LintState(ranges, panel, findDiagnostic(ranges));
|
|
22754
|
-
}
|
|
22755
|
-
}
|
|
22756
|
-
function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|
22757
|
-
let found = null;
|
|
22758
|
-
diagnostics.between(after, 1e9, (from, to, {
|
|
22759
|
-
spec
|
|
22760
|
-
}) => {
|
|
22761
|
-
if (diagnostic && spec.diagnostic != diagnostic) return;
|
|
22762
|
-
found = new SelectedDiagnostic(from, to, spec.diagnostic);
|
|
22763
|
-
return false;
|
|
22764
|
-
});
|
|
22765
|
-
return found;
|
|
22766
|
-
}
|
|
22767
|
-
function hideTooltip(tr, tooltip) {
|
|
22768
|
-
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
|
22769
|
-
}
|
|
22770
|
-
function maybeEnableLint(state, effects) {
|
|
22771
|
-
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([lintState, EditorView.decorations.compute([lintState], state => {
|
|
22772
|
-
let {
|
|
22773
|
-
selected,
|
|
22774
|
-
panel
|
|
22775
|
-
} = state.field(lintState);
|
|
22776
|
-
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([activeMark.range(selected.from, selected.to)]);
|
|
22777
|
-
}), hoverTooltip(lintTooltip, {
|
|
22778
|
-
hideOn: hideTooltip
|
|
22779
|
-
}), baseTheme]));
|
|
22780
|
-
}
|
|
22781
|
-
/**
|
|
22782
|
-
Returns a transaction spec which updates the current set of
|
|
22783
|
-
diagnostics, and enables the lint extension if if wasn't already
|
|
22784
|
-
active.
|
|
22785
|
-
*/
|
|
22786
|
-
function setDiagnostics(state, diagnostics) {
|
|
22787
|
-
return {
|
|
22788
|
-
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
|
|
22789
|
-
};
|
|
22790
|
-
}
|
|
22791
|
-
/**
|
|
22792
|
-
The state effect that updates the set of active diagnostics. Can
|
|
22793
|
-
be useful when writing an extension that needs to track these.
|
|
22794
|
-
*/
|
|
22795
|
-
const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
|
|
22796
|
-
const togglePanel = /*@__PURE__*/StateEffect.define();
|
|
22797
|
-
const movePanelSelection = /*@__PURE__*/StateEffect.define();
|
|
22798
|
-
const lintState = /*@__PURE__*/StateField.define({
|
|
22799
|
-
create() {
|
|
22800
|
-
return new LintState(Decoration.none, null, null);
|
|
22801
|
-
},
|
|
22802
|
-
update(value, tr) {
|
|
22803
|
-
if (tr.docChanged) {
|
|
22804
|
-
let mapped = value.diagnostics.map(tr.changes),
|
|
22805
|
-
selected = null;
|
|
22806
|
-
if (value.selected) {
|
|
22807
|
-
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
|
22808
|
-
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
|
22809
|
-
}
|
|
22810
|
-
value = new LintState(mapped, value.panel, selected);
|
|
22811
|
-
}
|
|
22812
|
-
for (let effect of tr.effects) {
|
|
22813
|
-
if (effect.is(setDiagnosticsEffect)) {
|
|
22814
|
-
value = LintState.init(effect.value, value.panel, tr.state);
|
|
22815
|
-
} else if (effect.is(togglePanel)) {
|
|
22816
|
-
value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
|
|
22817
|
-
} else if (effect.is(movePanelSelection)) {
|
|
22818
|
-
value = new LintState(value.diagnostics, value.panel, effect.value);
|
|
22819
|
-
}
|
|
22820
|
-
}
|
|
22821
|
-
return value;
|
|
22822
|
-
},
|
|
22823
|
-
provide: f => [showPanel.from(f, val => val.panel), EditorView.decorations.from(f, s => s.diagnostics)]
|
|
22824
|
-
});
|
|
22825
|
-
const activeMark = /*@__PURE__*/Decoration.mark({
|
|
22826
|
-
class: "cm-lintRange cm-lintRange-active"
|
|
22827
|
-
});
|
|
22828
|
-
function lintTooltip(view, pos, side) {
|
|
22829
|
-
let {
|
|
22830
|
-
diagnostics
|
|
22831
|
-
} = view.state.field(lintState);
|
|
22832
|
-
let found = [],
|
|
22833
|
-
stackStart = 2e8,
|
|
22834
|
-
stackEnd = 0;
|
|
22835
|
-
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, {
|
|
22836
|
-
spec
|
|
22837
|
-
}) => {
|
|
22838
|
-
if (pos >= from && pos <= to && (from == to || (pos > from || side > 0) && (pos < to || side < 0))) {
|
|
22839
|
-
found.push(spec.diagnostic);
|
|
22840
|
-
stackStart = Math.min(from, stackStart);
|
|
22841
|
-
stackEnd = Math.max(to, stackEnd);
|
|
22842
|
-
}
|
|
22843
|
-
});
|
|
22844
|
-
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
|
|
22845
|
-
if (diagnosticFilter) found = diagnosticFilter(found);
|
|
22846
|
-
if (!found.length) return null;
|
|
22847
|
-
return {
|
|
22848
|
-
pos: stackStart,
|
|
22849
|
-
end: stackEnd,
|
|
22850
|
-
above: view.state.doc.lineAt(stackStart).to < stackEnd,
|
|
22851
|
-
create() {
|
|
22852
|
-
return {
|
|
22853
|
-
dom: diagnosticsTooltip(view, found)
|
|
22854
|
-
};
|
|
22855
|
-
}
|
|
22856
|
-
};
|
|
22857
|
-
}
|
|
22858
|
-
function diagnosticsTooltip(view, diagnostics) {
|
|
22859
|
-
return crelt("ul", {
|
|
22860
|
-
class: "cm-tooltip-lint"
|
|
22861
|
-
}, diagnostics.map(d => renderDiagnostic(view, d, false)));
|
|
22862
|
-
}
|
|
22863
|
-
/**
|
|
22864
|
-
Command to open and focus the lint panel.
|
|
22865
|
-
*/
|
|
22866
|
-
const openLintPanel = view => {
|
|
22867
|
-
let field = view.state.field(lintState, false);
|
|
22868
|
-
if (!field || !field.panel) view.dispatch({
|
|
22869
|
-
effects: maybeEnableLint(view.state, [togglePanel.of(true)])
|
|
22870
|
-
});
|
|
22871
|
-
let panel = getPanel(view, LintPanel.open);
|
|
22872
|
-
if (panel) panel.dom.querySelector(".cm-panel-lint ul").focus();
|
|
22873
|
-
return true;
|
|
22874
|
-
};
|
|
22875
|
-
/**
|
|
22876
|
-
Command to close the lint panel, when open.
|
|
22877
|
-
*/
|
|
22878
|
-
const closeLintPanel = view => {
|
|
22879
|
-
let field = view.state.field(lintState, false);
|
|
22880
|
-
if (!field || !field.panel) return false;
|
|
22881
|
-
view.dispatch({
|
|
22882
|
-
effects: togglePanel.of(false)
|
|
22883
|
-
});
|
|
22884
|
-
return true;
|
|
22885
|
-
};
|
|
22886
|
-
/**
|
|
22887
|
-
Move the selection to the next diagnostic.
|
|
22888
|
-
*/
|
|
22889
|
-
const nextDiagnostic = view => {
|
|
22890
|
-
let field = view.state.field(lintState, false);
|
|
22891
|
-
if (!field) return false;
|
|
22892
|
-
let sel = view.state.selection.main,
|
|
22893
|
-
next = field.diagnostics.iter(sel.to + 1);
|
|
22894
|
-
if (!next.value) {
|
|
22895
|
-
next = field.diagnostics.iter(0);
|
|
22896
|
-
if (!next.value || next.from == sel.from && next.to == sel.to) return false;
|
|
22897
|
-
}
|
|
22898
|
-
view.dispatch({
|
|
22899
|
-
selection: {
|
|
22900
|
-
anchor: next.from,
|
|
22901
|
-
head: next.to
|
|
22902
|
-
},
|
|
22903
|
-
scrollIntoView: true
|
|
22904
|
-
});
|
|
22905
|
-
return true;
|
|
22906
|
-
};
|
|
22907
|
-
/**
|
|
22908
|
-
A set of default key bindings for the lint functionality.
|
|
22909
|
-
|
|
22910
|
-
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
|
22911
|
-
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
|
22912
|
-
*/
|
|
22913
|
-
const lintKeymap = [{
|
|
22914
|
-
key: "Mod-Shift-m",
|
|
22915
|
-
run: openLintPanel,
|
|
22916
|
-
preventDefault: true
|
|
22917
|
-
}, {
|
|
22918
|
-
key: "F8",
|
|
22919
|
-
run: nextDiagnostic
|
|
22920
|
-
}];
|
|
22921
|
-
const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
22922
|
-
constructor(view) {
|
|
22923
|
-
this.view = view;
|
|
22924
|
-
this.timeout = -1;
|
|
22925
|
-
this.set = true;
|
|
22926
|
-
let {
|
|
22927
|
-
delay
|
|
22928
|
-
} = view.state.facet(lintConfig);
|
|
22929
|
-
this.lintTime = Date.now() + delay;
|
|
22930
|
-
this.run = this.run.bind(this);
|
|
22931
|
-
this.timeout = setTimeout(this.run, delay);
|
|
22932
|
-
}
|
|
22933
|
-
run() {
|
|
22934
|
-
let now = Date.now();
|
|
22935
|
-
if (now < this.lintTime - 10) {
|
|
22936
|
-
setTimeout(this.run, this.lintTime - now);
|
|
22937
|
-
} else {
|
|
22938
|
-
this.set = false;
|
|
22939
|
-
let {
|
|
22940
|
-
state
|
|
22941
|
-
} = this.view,
|
|
22942
|
-
{
|
|
22943
|
-
sources
|
|
22944
|
-
} = state.facet(lintConfig);
|
|
22945
|
-
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
|
|
22946
|
-
let all = annotations.reduce((a, b) => a.concat(b));
|
|
22947
|
-
if (this.view.state.doc == state.doc) this.view.dispatch(setDiagnostics(this.view.state, all));
|
|
22948
|
-
}, error => {
|
|
22949
|
-
logException(this.view.state, error);
|
|
22950
|
-
});
|
|
22951
|
-
}
|
|
22952
|
-
}
|
|
22953
|
-
update(update) {
|
|
22954
|
-
let config = update.state.facet(lintConfig);
|
|
22955
|
-
if (update.docChanged || config != update.startState.facet(lintConfig)) {
|
|
22956
|
-
this.lintTime = Date.now() + config.delay;
|
|
22957
|
-
if (!this.set) {
|
|
22958
|
-
this.set = true;
|
|
22959
|
-
this.timeout = setTimeout(this.run, config.delay);
|
|
22960
|
-
}
|
|
22961
|
-
}
|
|
22962
|
-
}
|
|
22963
|
-
force() {
|
|
22964
|
-
if (this.set) {
|
|
22965
|
-
this.lintTime = Date.now();
|
|
22966
|
-
this.run();
|
|
22967
|
-
}
|
|
22968
|
-
}
|
|
22969
|
-
destroy() {
|
|
22970
|
-
clearTimeout(this.timeout);
|
|
22971
|
-
}
|
|
22972
|
-
});
|
|
22973
|
-
const lintConfig = /*@__PURE__*/Facet.define({
|
|
22974
|
-
combine(input) {
|
|
22975
|
-
return Object.assign({
|
|
22976
|
-
sources: input.map(i => i.source)
|
|
22977
|
-
}, combineConfig(input.map(i => i.config), {
|
|
22978
|
-
delay: 750,
|
|
22979
|
-
markerFilter: null,
|
|
22980
|
-
tooltipFilter: null
|
|
22981
|
-
}));
|
|
22982
|
-
},
|
|
22983
|
-
enables: lintPlugin
|
|
22984
|
-
});
|
|
22985
|
-
function assignKeys(actions) {
|
|
22986
|
-
let assigned = [];
|
|
22987
|
-
if (actions) actions: for (let {
|
|
22988
|
-
name
|
|
22989
|
-
} of actions) {
|
|
22990
|
-
for (let i = 0; i < name.length; i++) {
|
|
22991
|
-
let ch = name[i];
|
|
22992
|
-
if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
|
|
22993
|
-
assigned.push(ch);
|
|
22994
|
-
continue actions;
|
|
19530
|
+
from: pos
|
|
19531
|
+
},
|
|
19532
|
+
effects: closeBracketEffect.of(pos + token.length),
|
|
19533
|
+
range: EditorSelection.cursor(pos + token.length)
|
|
19534
|
+
};
|
|
19535
|
+
} else if (closedBracketAt(state, pos)) {
|
|
19536
|
+
let isTriple = allowTriple && state.sliceDoc(pos, pos + token.length * 3) == token + token + token;
|
|
19537
|
+
return {
|
|
19538
|
+
range: EditorSelection.cursor(pos + token.length * (isTriple ? 3 : 1)),
|
|
19539
|
+
effects: skipBracketEffect.of(pos)
|
|
19540
|
+
};
|
|
19541
|
+
}
|
|
19542
|
+
} else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token && (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 && nodeStart$1(state, start)) {
|
|
19543
|
+
return {
|
|
19544
|
+
changes: {
|
|
19545
|
+
insert: token + token + token + token,
|
|
19546
|
+
from: pos
|
|
19547
|
+
},
|
|
19548
|
+
effects: closeBracketEffect.of(pos + token.length),
|
|
19549
|
+
range: EditorSelection.cursor(pos + token.length)
|
|
19550
|
+
};
|
|
19551
|
+
} else if (state.charCategorizer(pos)(next) != CharCategory.Word) {
|
|
19552
|
+
if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes)) return {
|
|
19553
|
+
changes: {
|
|
19554
|
+
insert: token + token,
|
|
19555
|
+
from: pos
|
|
19556
|
+
},
|
|
19557
|
+
effects: closeBracketEffect.of(pos + token.length),
|
|
19558
|
+
range: EditorSelection.cursor(pos + token.length)
|
|
19559
|
+
};
|
|
22995
19560
|
}
|
|
22996
|
-
|
|
22997
|
-
|
|
22998
|
-
|
|
22999
|
-
return assigned;
|
|
23000
|
-
}
|
|
23001
|
-
function renderDiagnostic(view, diagnostic, inPanel) {
|
|
23002
|
-
var _a;
|
|
23003
|
-
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
|
23004
|
-
return crelt("li", {
|
|
23005
|
-
class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity
|
|
23006
|
-
}, crelt("span", {
|
|
23007
|
-
class: "cm-diagnosticText"
|
|
23008
|
-
}, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
23009
|
-
let click = e => {
|
|
23010
|
-
e.preventDefault();
|
|
23011
|
-
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
|
|
23012
|
-
if (found) action.apply(view, found.from, found.to);
|
|
23013
|
-
};
|
|
23014
|
-
let {
|
|
23015
|
-
name
|
|
23016
|
-
} = action,
|
|
23017
|
-
keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
|
|
23018
|
-
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex), crelt("u", name.slice(keyIndex, keyIndex + 1)), name.slice(keyIndex + 1)];
|
|
23019
|
-
return crelt("button", {
|
|
23020
|
-
type: "button",
|
|
23021
|
-
class: "cm-diagnosticAction",
|
|
23022
|
-
onclick: click,
|
|
23023
|
-
onmousedown: click,
|
|
23024
|
-
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
23025
|
-
}, nameElt);
|
|
23026
|
-
}), diagnostic.source && crelt("div", {
|
|
23027
|
-
class: "cm-diagnosticSource"
|
|
23028
|
-
}, diagnostic.source));
|
|
23029
|
-
}
|
|
23030
|
-
class DiagnosticWidget extends WidgetType {
|
|
23031
|
-
constructor(diagnostic) {
|
|
23032
|
-
super();
|
|
23033
|
-
this.diagnostic = diagnostic;
|
|
23034
|
-
}
|
|
23035
|
-
eq(other) {
|
|
23036
|
-
return other.diagnostic == this.diagnostic;
|
|
23037
|
-
}
|
|
23038
|
-
toDOM() {
|
|
23039
|
-
return crelt("span", {
|
|
23040
|
-
class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity
|
|
19561
|
+
return {
|
|
19562
|
+
range: dont = range
|
|
19563
|
+
};
|
|
23041
19564
|
});
|
|
23042
|
-
|
|
19565
|
+
return dont ? null : state.update(changes, {
|
|
19566
|
+
scrollIntoView: true,
|
|
19567
|
+
userEvent: "input.type"
|
|
19568
|
+
});
|
|
23043
19569
|
}
|
|
23044
|
-
|
|
23045
|
-
|
|
23046
|
-
|
|
23047
|
-
this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
|
|
23048
|
-
this.dom = renderDiagnostic(view, diagnostic, true);
|
|
23049
|
-
this.dom.id = this.id;
|
|
23050
|
-
this.dom.setAttribute("role", "option");
|
|
23051
|
-
}
|
|
19570
|
+
function nodeStart$1(state, pos) {
|
|
19571
|
+
let tree = syntaxTree(state).resolveInner(pos + 1);
|
|
19572
|
+
return tree.parent && tree.from == pos;
|
|
23052
19573
|
}
|
|
23053
|
-
|
|
23054
|
-
|
|
23055
|
-
|
|
23056
|
-
|
|
23057
|
-
let
|
|
23058
|
-
|
|
23059
|
-
|
|
23060
|
-
|
|
23061
|
-
|
|
23062
|
-
|
|
23063
|
-
|
|
23064
|
-
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
|
|
23065
|
-
} else if (event.keyCode == 40 || event.keyCode == 34) {
|
|
23066
|
-
// ArrowDown, PageDown
|
|
23067
|
-
this.moveSelection((this.selectedIndex + 1) % this.items.length);
|
|
23068
|
-
} else if (event.keyCode == 36) {
|
|
23069
|
-
// Home
|
|
23070
|
-
this.moveSelection(0);
|
|
23071
|
-
} else if (event.keyCode == 35) {
|
|
23072
|
-
// End
|
|
23073
|
-
this.moveSelection(this.items.length - 1);
|
|
23074
|
-
} else if (event.keyCode == 13) {
|
|
23075
|
-
// Enter
|
|
23076
|
-
this.view.focus();
|
|
23077
|
-
} else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) {
|
|
23078
|
-
// A-Z
|
|
23079
|
-
let {
|
|
23080
|
-
diagnostic
|
|
23081
|
-
} = this.items[this.selectedIndex],
|
|
23082
|
-
keys = assignKeys(diagnostic.actions);
|
|
23083
|
-
for (let i = 0; i < keys.length; i++) if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
|
|
23084
|
-
let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
|
|
23085
|
-
if (found) diagnostic.actions[i].apply(view, found.from, found.to);
|
|
23086
|
-
}
|
|
23087
|
-
} else {
|
|
23088
|
-
return;
|
|
23089
|
-
}
|
|
23090
|
-
event.preventDefault();
|
|
23091
|
-
};
|
|
23092
|
-
let onclick = event => {
|
|
23093
|
-
for (let i = 0; i < this.items.length; i++) {
|
|
23094
|
-
if (this.items[i].dom.contains(event.target)) this.moveSelection(i);
|
|
23095
|
-
}
|
|
23096
|
-
};
|
|
23097
|
-
this.list = crelt("ul", {
|
|
23098
|
-
tabIndex: 0,
|
|
23099
|
-
role: "listbox",
|
|
23100
|
-
"aria-label": this.view.state.phrase("Diagnostics"),
|
|
23101
|
-
onkeydown,
|
|
23102
|
-
onclick
|
|
23103
|
-
});
|
|
23104
|
-
this.dom = crelt("div", {
|
|
23105
|
-
class: "cm-panel-lint"
|
|
23106
|
-
}, this.list, crelt("button", {
|
|
23107
|
-
type: "button",
|
|
23108
|
-
name: "close",
|
|
23109
|
-
"aria-label": this.view.state.phrase("close"),
|
|
23110
|
-
onclick: () => closeLintPanel(this.view)
|
|
23111
|
-
}, "×"));
|
|
23112
|
-
this.update();
|
|
23113
|
-
}
|
|
23114
|
-
get selectedIndex() {
|
|
23115
|
-
let selected = this.view.state.field(lintState).selected;
|
|
23116
|
-
if (!selected) return -1;
|
|
23117
|
-
for (let i = 0; i < this.items.length; i++) if (this.items[i].diagnostic == selected.diagnostic) return i;
|
|
23118
|
-
return -1;
|
|
23119
|
-
}
|
|
23120
|
-
update() {
|
|
23121
|
-
let {
|
|
23122
|
-
diagnostics,
|
|
23123
|
-
selected
|
|
23124
|
-
} = this.view.state.field(lintState);
|
|
23125
|
-
let i = 0,
|
|
23126
|
-
needsSync = false,
|
|
23127
|
-
newSelectedItem = null;
|
|
23128
|
-
diagnostics.between(0, this.view.state.doc.length, (_start, _end, {
|
|
23129
|
-
spec
|
|
23130
|
-
}) => {
|
|
23131
|
-
let found = -1,
|
|
23132
|
-
item;
|
|
23133
|
-
for (let j = i; j < this.items.length; j++) if (this.items[j].diagnostic == spec.diagnostic) {
|
|
23134
|
-
found = j;
|
|
23135
|
-
break;
|
|
23136
|
-
}
|
|
23137
|
-
if (found < 0) {
|
|
23138
|
-
item = new PanelItem(this.view, spec.diagnostic);
|
|
23139
|
-
this.items.splice(i, 0, item);
|
|
23140
|
-
needsSync = true;
|
|
23141
|
-
} else {
|
|
23142
|
-
item = this.items[found];
|
|
23143
|
-
if (found > i) {
|
|
23144
|
-
this.items.splice(i, found - i);
|
|
23145
|
-
needsSync = true;
|
|
23146
|
-
}
|
|
23147
|
-
}
|
|
23148
|
-
if (selected && item.diagnostic == selected.diagnostic) {
|
|
23149
|
-
if (!item.dom.hasAttribute("aria-selected")) {
|
|
23150
|
-
item.dom.setAttribute("aria-selected", "true");
|
|
23151
|
-
newSelectedItem = item;
|
|
23152
|
-
}
|
|
23153
|
-
} else if (item.dom.hasAttribute("aria-selected")) {
|
|
23154
|
-
item.dom.removeAttribute("aria-selected");
|
|
23155
|
-
}
|
|
23156
|
-
i++;
|
|
23157
|
-
});
|
|
23158
|
-
while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
|
|
23159
|
-
needsSync = true;
|
|
23160
|
-
this.items.pop();
|
|
23161
|
-
}
|
|
23162
|
-
if (this.items.length == 0) {
|
|
23163
|
-
this.items.push(new PanelItem(this.view, {
|
|
23164
|
-
from: -1,
|
|
23165
|
-
to: -1,
|
|
23166
|
-
severity: "info",
|
|
23167
|
-
message: this.view.state.phrase("No diagnostics")
|
|
23168
|
-
}));
|
|
23169
|
-
needsSync = true;
|
|
23170
|
-
}
|
|
23171
|
-
if (newSelectedItem) {
|
|
23172
|
-
this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
|
|
23173
|
-
this.view.requestMeasure({
|
|
23174
|
-
key: this,
|
|
23175
|
-
read: () => ({
|
|
23176
|
-
sel: newSelectedItem.dom.getBoundingClientRect(),
|
|
23177
|
-
panel: this.list.getBoundingClientRect()
|
|
23178
|
-
}),
|
|
23179
|
-
write: ({
|
|
23180
|
-
sel,
|
|
23181
|
-
panel
|
|
23182
|
-
}) => {
|
|
23183
|
-
if (sel.top < panel.top) this.list.scrollTop -= panel.top - sel.top;else if (sel.bottom > panel.bottom) this.list.scrollTop += sel.bottom - panel.bottom;
|
|
23184
|
-
}
|
|
23185
|
-
});
|
|
23186
|
-
} else if (this.selectedIndex < 0) {
|
|
23187
|
-
this.list.removeAttribute("aria-activedescendant");
|
|
23188
|
-
}
|
|
23189
|
-
if (needsSync) this.sync();
|
|
23190
|
-
}
|
|
23191
|
-
sync() {
|
|
23192
|
-
let domPos = this.list.firstChild;
|
|
23193
|
-
function rm() {
|
|
23194
|
-
let prev = domPos;
|
|
23195
|
-
domPos = prev.nextSibling;
|
|
23196
|
-
prev.remove();
|
|
23197
|
-
}
|
|
23198
|
-
for (let item of this.items) {
|
|
23199
|
-
if (item.dom.parentNode == this.list) {
|
|
23200
|
-
while (domPos != item.dom) rm();
|
|
23201
|
-
domPos = item.dom.nextSibling;
|
|
23202
|
-
} else {
|
|
23203
|
-
this.list.insertBefore(item.dom, domPos);
|
|
19574
|
+
function probablyInString(state, pos, quoteToken, prefixes) {
|
|
19575
|
+
let node = syntaxTree(state).resolveInner(pos, -1);
|
|
19576
|
+
let maxPrefix = prefixes.reduce((m, p) => Math.max(m, p.length), 0);
|
|
19577
|
+
for (let i = 0; i < 5; i++) {
|
|
19578
|
+
let start = state.sliceDoc(node.from, Math.min(node.to, node.from + quoteToken.length + maxPrefix));
|
|
19579
|
+
let quotePos = start.indexOf(quoteToken);
|
|
19580
|
+
if (!quotePos || quotePos > -1 && prefixes.indexOf(start.slice(0, quotePos)) > -1) {
|
|
19581
|
+
let first = node.firstChild;
|
|
19582
|
+
while (first && first.from == node.from && first.to - first.from > quoteToken.length + quotePos) {
|
|
19583
|
+
if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken) return false;
|
|
19584
|
+
first = first.firstChild;
|
|
23204
19585
|
}
|
|
19586
|
+
return true;
|
|
23205
19587
|
}
|
|
23206
|
-
|
|
23207
|
-
|
|
23208
|
-
|
|
23209
|
-
if (this.selectedIndex < 0) return;
|
|
23210
|
-
let field = this.view.state.field(lintState);
|
|
23211
|
-
let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
|
|
23212
|
-
if (!selection) return;
|
|
23213
|
-
this.view.dispatch({
|
|
23214
|
-
selection: {
|
|
23215
|
-
anchor: selection.from,
|
|
23216
|
-
head: selection.to
|
|
23217
|
-
},
|
|
23218
|
-
scrollIntoView: true,
|
|
23219
|
-
effects: movePanelSelection.of(selection)
|
|
23220
|
-
});
|
|
23221
|
-
}
|
|
23222
|
-
static open(view) {
|
|
23223
|
-
return new LintPanel(view);
|
|
19588
|
+
let parent = node.to == pos && node.parent;
|
|
19589
|
+
if (!parent) break;
|
|
19590
|
+
node = parent;
|
|
23224
19591
|
}
|
|
19592
|
+
return false;
|
|
23225
19593
|
}
|
|
23226
|
-
function
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
23233
|
-
".cm-diagnostic": {
|
|
23234
|
-
padding: "3px 6px 3px 8px",
|
|
23235
|
-
marginLeft: "-1px",
|
|
23236
|
-
display: "block",
|
|
23237
|
-
whiteSpace: "pre-wrap"
|
|
23238
|
-
},
|
|
23239
|
-
".cm-diagnostic-error": {
|
|
23240
|
-
borderLeft: "5px solid #d11"
|
|
23241
|
-
},
|
|
23242
|
-
".cm-diagnostic-warning": {
|
|
23243
|
-
borderLeft: "5px solid orange"
|
|
23244
|
-
},
|
|
23245
|
-
".cm-diagnostic-info": {
|
|
23246
|
-
borderLeft: "5px solid #999"
|
|
23247
|
-
},
|
|
23248
|
-
".cm-diagnosticAction": {
|
|
23249
|
-
font: "inherit",
|
|
23250
|
-
border: "none",
|
|
23251
|
-
padding: "2px 4px",
|
|
23252
|
-
backgroundColor: "#444",
|
|
23253
|
-
color: "white",
|
|
23254
|
-
borderRadius: "3px",
|
|
23255
|
-
marginLeft: "8px"
|
|
23256
|
-
},
|
|
23257
|
-
".cm-diagnosticSource": {
|
|
23258
|
-
fontSize: "70%",
|
|
23259
|
-
opacity: .7
|
|
23260
|
-
},
|
|
23261
|
-
".cm-lintRange": {
|
|
23262
|
-
backgroundPosition: "left bottom",
|
|
23263
|
-
backgroundRepeat: "repeat-x",
|
|
23264
|
-
paddingBottom: "0.7px"
|
|
23265
|
-
},
|
|
23266
|
-
".cm-lintRange-error": {
|
|
23267
|
-
backgroundImage: /*@__PURE__*/underline("#d11")
|
|
23268
|
-
},
|
|
23269
|
-
".cm-lintRange-warning": {
|
|
23270
|
-
backgroundImage: /*@__PURE__*/underline("orange")
|
|
23271
|
-
},
|
|
23272
|
-
".cm-lintRange-info": {
|
|
23273
|
-
backgroundImage: /*@__PURE__*/underline("#999")
|
|
23274
|
-
},
|
|
23275
|
-
".cm-lintRange-active": {
|
|
23276
|
-
backgroundColor: "#ffdd9980"
|
|
23277
|
-
},
|
|
23278
|
-
".cm-tooltip-lint": {
|
|
23279
|
-
padding: 0,
|
|
23280
|
-
margin: 0
|
|
23281
|
-
},
|
|
23282
|
-
".cm-lintPoint": {
|
|
23283
|
-
position: "relative",
|
|
23284
|
-
"&:after": {
|
|
23285
|
-
content: '""',
|
|
23286
|
-
position: "absolute",
|
|
23287
|
-
bottom: 0,
|
|
23288
|
-
left: "-2px",
|
|
23289
|
-
borderLeft: "3px solid transparent",
|
|
23290
|
-
borderRight: "3px solid transparent",
|
|
23291
|
-
borderBottom: "4px solid #d11"
|
|
23292
|
-
}
|
|
23293
|
-
},
|
|
23294
|
-
".cm-lintPoint-warning": {
|
|
23295
|
-
"&:after": {
|
|
23296
|
-
borderBottomColor: "orange"
|
|
23297
|
-
}
|
|
23298
|
-
},
|
|
23299
|
-
".cm-lintPoint-info": {
|
|
23300
|
-
"&:after": {
|
|
23301
|
-
borderBottomColor: "#999"
|
|
23302
|
-
}
|
|
23303
|
-
},
|
|
23304
|
-
".cm-panel.cm-panel-lint": {
|
|
23305
|
-
position: "relative",
|
|
23306
|
-
"& ul": {
|
|
23307
|
-
maxHeight: "100px",
|
|
23308
|
-
overflowY: "auto",
|
|
23309
|
-
"& [aria-selected]": {
|
|
23310
|
-
backgroundColor: "#ddd",
|
|
23311
|
-
"& u": {
|
|
23312
|
-
textDecoration: "underline"
|
|
23313
|
-
}
|
|
23314
|
-
},
|
|
23315
|
-
"&:focus [aria-selected]": {
|
|
23316
|
-
background_fallback: "#bdf",
|
|
23317
|
-
backgroundColor: "Highlight",
|
|
23318
|
-
color_fallback: "white",
|
|
23319
|
-
color: "HighlightText"
|
|
23320
|
-
},
|
|
23321
|
-
"& u": {
|
|
23322
|
-
textDecoration: "none"
|
|
23323
|
-
},
|
|
23324
|
-
padding: 0,
|
|
23325
|
-
margin: 0
|
|
23326
|
-
},
|
|
23327
|
-
"& [name=close]": {
|
|
23328
|
-
position: "absolute",
|
|
23329
|
-
top: "0",
|
|
23330
|
-
right: "2px",
|
|
23331
|
-
background: "inherit",
|
|
23332
|
-
border: "none",
|
|
23333
|
-
font: "inherit",
|
|
23334
|
-
padding: 0,
|
|
23335
|
-
margin: 0
|
|
23336
|
-
}
|
|
19594
|
+
function canStartStringAt(state, pos, prefixes) {
|
|
19595
|
+
let charCat = state.charCategorizer(pos);
|
|
19596
|
+
if (charCat(state.sliceDoc(pos - 1, pos)) != CharCategory.Word) return pos;
|
|
19597
|
+
for (let prefix of prefixes) {
|
|
19598
|
+
let start = pos - prefix.length;
|
|
19599
|
+
if (state.sliceDoc(start, pos) == prefix && charCat(state.sliceDoc(start - 1, start)) != CharCategory.Word) return start;
|
|
23337
19600
|
}
|
|
23338
|
-
|
|
19601
|
+
return -1;
|
|
19602
|
+
}
|
|
23339
19603
|
|
|
23340
|
-
// (The superfluous function calls around the list of extensions work
|
|
23341
|
-
// around current limitations in tree-shaking software.)
|
|
23342
19604
|
/**
|
|
23343
|
-
|
|
23344
|
-
extensions that you might want in a basic editor. It is meant as a
|
|
23345
|
-
convenient helper to quickly set up CodeMirror without installing
|
|
23346
|
-
and importing a lot of separate packages.
|
|
23347
|
-
|
|
23348
|
-
Specifically, it includes...
|
|
23349
|
-
|
|
23350
|
-
- [the default command bindings](https://codemirror.net/6/docs/ref/#commands.defaultKeymap)
|
|
23351
|
-
- [line numbers](https://codemirror.net/6/docs/ref/#view.lineNumbers)
|
|
23352
|
-
- [special character highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars)
|
|
23353
|
-
- [the undo history](https://codemirror.net/6/docs/ref/#commands.history)
|
|
23354
|
-
- [a fold gutter](https://codemirror.net/6/docs/ref/#language.foldGutter)
|
|
23355
|
-
- [custom selection drawing](https://codemirror.net/6/docs/ref/#view.drawSelection)
|
|
23356
|
-
- [drop cursor](https://codemirror.net/6/docs/ref/#view.dropCursor)
|
|
23357
|
-
- [multiple selections](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
|
|
23358
|
-
- [reindentation on input](https://codemirror.net/6/docs/ref/#language.indentOnInput)
|
|
23359
|
-
- [the default highlight style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle) (as fallback)
|
|
23360
|
-
- [bracket matching](https://codemirror.net/6/docs/ref/#language.bracketMatching)
|
|
23361
|
-
- [bracket closing](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets)
|
|
23362
|
-
- [autocompletion](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion)
|
|
23363
|
-
- [rectangular selection](https://codemirror.net/6/docs/ref/#view.rectangularSelection) and [crosshair cursor](https://codemirror.net/6/docs/ref/#view.crosshairCursor)
|
|
23364
|
-
- [active line highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLine)
|
|
23365
|
-
- [active line gutter highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLineGutter)
|
|
23366
|
-
- [selection match highlighting](https://codemirror.net/6/docs/ref/#search.highlightSelectionMatches)
|
|
23367
|
-
- [search](https://codemirror.net/6/docs/ref/#search.searchKeymap)
|
|
23368
|
-
- [linting](https://codemirror.net/6/docs/ref/#lint.lintKeymap)
|
|
23369
|
-
|
|
23370
|
-
(You'll probably want to add some language package to your setup
|
|
23371
|
-
too.)
|
|
23372
|
-
|
|
23373
|
-
This extension does not allow customization. The idea is that,
|
|
23374
|
-
once you decide you want to configure your editor more precisely,
|
|
23375
|
-
you take this package's source (which is just a bunch of imports
|
|
23376
|
-
and an array literal), copy it into your own code, and adjust it
|
|
23377
|
-
as desired.
|
|
19605
|
+
Returns an extension that enables autocompletion.
|
|
23378
19606
|
*/
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
}
|
|
19607
|
+
function autocompletion(config = {}) {
|
|
19608
|
+
return [completionState, completionConfig.of(config), completionPlugin, completionKeymapExt, baseTheme];
|
|
19609
|
+
}
|
|
19610
|
+
/**
|
|
19611
|
+
Basic keybindings for autocompletion.
|
|
23382
19612
|
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
|
|
23388
|
-
|
|
23389
|
-
|
|
23390
|
-
|
|
23391
|
-
|
|
19613
|
+
- Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
|
|
19614
|
+
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
|
|
19615
|
+
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
|
|
19616
|
+
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
|
|
19617
|
+
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
|
19618
|
+
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
|
19619
|
+
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
|
|
19620
|
+
*/
|
|
19621
|
+
const completionKeymap = [{
|
|
19622
|
+
key: "Ctrl-Space",
|
|
19623
|
+
run: startCompletion
|
|
19624
|
+
}, {
|
|
19625
|
+
key: "Escape",
|
|
19626
|
+
run: closeCompletion
|
|
19627
|
+
}, {
|
|
19628
|
+
key: "ArrowDown",
|
|
19629
|
+
run: /*@__PURE__*/moveCompletionSelection(true)
|
|
19630
|
+
}, {
|
|
19631
|
+
key: "ArrowUp",
|
|
19632
|
+
run: /*@__PURE__*/moveCompletionSelection(false)
|
|
19633
|
+
}, {
|
|
19634
|
+
key: "PageDown",
|
|
19635
|
+
run: /*@__PURE__*/moveCompletionSelection(true, "page")
|
|
19636
|
+
}, {
|
|
19637
|
+
key: "PageUp",
|
|
19638
|
+
run: /*@__PURE__*/moveCompletionSelection(false, "page")
|
|
19639
|
+
}, {
|
|
19640
|
+
key: "Enter",
|
|
19641
|
+
run: acceptCompletion
|
|
19642
|
+
}];
|
|
19643
|
+
const completionKeymapExt = /*@__PURE__*/Prec.highest( /*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
|
|
23392
19644
|
|
|
23393
19645
|
/// A parse stack. These are used internally by the parser to track
|
|
23394
19646
|
/// parsing progress. They also provide some properties and methods
|
|
@@ -29392,218 +25644,4 @@ var languages = {
|
|
|
29392
25644
|
[OrCodeLanguages.MD]: MD
|
|
29393
25645
|
};
|
|
29394
25646
|
|
|
29395
|
-
|
|
29396
|
-
var script = defineComponent({
|
|
29397
|
-
name: 'OrCode',
|
|
29398
|
-
components: {
|
|
29399
|
-
OrIconButton: script$1,
|
|
29400
|
-
OrModal: script$2,
|
|
29401
|
-
OrTeleport: script$3,
|
|
29402
|
-
OrError: script$4,
|
|
29403
|
-
OrHint: script$5,
|
|
29404
|
-
OrLabel: script$6
|
|
29405
|
-
},
|
|
29406
|
-
model: {
|
|
29407
|
-
prop: 'modelValue',
|
|
29408
|
-
event: 'update:modelValue'
|
|
29409
|
-
},
|
|
29410
|
-
props: {
|
|
29411
|
-
label: {
|
|
29412
|
-
type: String,
|
|
29413
|
-
default: '',
|
|
29414
|
-
required: false
|
|
29415
|
-
},
|
|
29416
|
-
modelValue: {
|
|
29417
|
-
type: String,
|
|
29418
|
-
default: '',
|
|
29419
|
-
required: false
|
|
29420
|
-
},
|
|
29421
|
-
language: {
|
|
29422
|
-
type: [Object, String],
|
|
29423
|
-
required: false,
|
|
29424
|
-
default: OrCodeLanguages.JS
|
|
29425
|
-
},
|
|
29426
|
-
isReadonly: {
|
|
29427
|
-
type: Boolean,
|
|
29428
|
-
required: false,
|
|
29429
|
-
default: false
|
|
29430
|
-
},
|
|
29431
|
-
extensions: {
|
|
29432
|
-
type: Array,
|
|
29433
|
-
required: false,
|
|
29434
|
-
default: () => [basicSetup]
|
|
29435
|
-
},
|
|
29436
|
-
phrases: {
|
|
29437
|
-
type: Object,
|
|
29438
|
-
required: false,
|
|
29439
|
-
default: null
|
|
29440
|
-
},
|
|
29441
|
-
isShowingFullscreen: {
|
|
29442
|
-
type: Boolean,
|
|
29443
|
-
default: true,
|
|
29444
|
-
required: false
|
|
29445
|
-
},
|
|
29446
|
-
isInvalid: {
|
|
29447
|
-
type: Boolean,
|
|
29448
|
-
default: false,
|
|
29449
|
-
required: false
|
|
29450
|
-
},
|
|
29451
|
-
error: {
|
|
29452
|
-
type: String,
|
|
29453
|
-
default: '',
|
|
29454
|
-
required: false
|
|
29455
|
-
},
|
|
29456
|
-
hint: {
|
|
29457
|
-
type: String,
|
|
29458
|
-
default: '',
|
|
29459
|
-
required: false
|
|
29460
|
-
},
|
|
29461
|
-
allowPaste: {
|
|
29462
|
-
type: Boolean,
|
|
29463
|
-
default: true
|
|
29464
|
-
},
|
|
29465
|
-
allowDrop: {
|
|
29466
|
-
type: Boolean,
|
|
29467
|
-
default: true
|
|
29468
|
-
},
|
|
29469
|
-
lineWrapping: {
|
|
29470
|
-
type: Boolean,
|
|
29471
|
-
default: false
|
|
29472
|
-
}
|
|
29473
|
-
},
|
|
29474
|
-
emits: ['update:modelValue', 'focus', 'blur'],
|
|
29475
|
-
setup(props, {
|
|
29476
|
-
emit
|
|
29477
|
-
}) {
|
|
29478
|
-
const root = ref();
|
|
29479
|
-
const target = ref();
|
|
29480
|
-
const fullscreenTarget = ref();
|
|
29481
|
-
const isHovered = useElementHover(root);
|
|
29482
|
-
const editor = new EditorView({
|
|
29483
|
-
state: EditorState.create({
|
|
29484
|
-
doc: props.modelValue
|
|
29485
|
-
}),
|
|
29486
|
-
dispatch: tr => {
|
|
29487
|
-
editor.update([tr]);
|
|
29488
|
-
if (tr.changes.empty) return;
|
|
29489
|
-
emit('update:modelValue', editor.state.doc.toString());
|
|
29490
|
-
}
|
|
29491
|
-
});
|
|
29492
|
-
return {
|
|
29493
|
-
root,
|
|
29494
|
-
target,
|
|
29495
|
-
fullscreenTarget,
|
|
29496
|
-
editor,
|
|
29497
|
-
isHovered
|
|
29498
|
-
};
|
|
29499
|
-
},
|
|
29500
|
-
data() {
|
|
29501
|
-
return {
|
|
29502
|
-
isFullscreen: false
|
|
29503
|
-
};
|
|
29504
|
-
},
|
|
29505
|
-
computed: {
|
|
29506
|
-
localLanguage() {
|
|
29507
|
-
if (_.includes(_.values(OrCodeLanguages), this.language)) {
|
|
29508
|
-
return languages[this.language];
|
|
29509
|
-
} else {
|
|
29510
|
-
return this.language;
|
|
29511
|
-
}
|
|
29512
|
-
},
|
|
29513
|
-
localExtensions() {
|
|
29514
|
-
const {
|
|
29515
|
-
allowDrop,
|
|
29516
|
-
allowPaste,
|
|
29517
|
-
lineWrapping
|
|
29518
|
-
} = this;
|
|
29519
|
-
const ext = _.compact([
|
|
29520
|
-
// Toggle light/dark mode
|
|
29521
|
-
EditorView.baseTheme({}),
|
|
29522
|
-
// locale settings
|
|
29523
|
-
this.phrases ? EditorState.phrases.of(this.phrases) : undefined,
|
|
29524
|
-
// Parser language setting
|
|
29525
|
-
this.localLanguage,
|
|
29526
|
-
// Editable option
|
|
29527
|
-
EditorView.editable.of(!this.isReadonly),
|
|
29528
|
-
// Focus and blur listener
|
|
29529
|
-
EditorView.updateListener.of(viewUpdate => {
|
|
29530
|
-
if (viewUpdate.focusChanged) {
|
|
29531
|
-
viewUpdate.view.hasFocus ? this.$emit('focus') : this.$emit('blur', viewUpdate.state.doc.toString());
|
|
29532
|
-
}
|
|
29533
|
-
}), EditorView.domEventHandlers({
|
|
29534
|
-
drop(event) {
|
|
29535
|
-
if (!allowDrop) {
|
|
29536
|
-
event.preventDefault();
|
|
29537
|
-
return true;
|
|
29538
|
-
}
|
|
29539
|
-
},
|
|
29540
|
-
paste(event) {
|
|
29541
|
-
if (!allowPaste) {
|
|
29542
|
-
event.preventDefault();
|
|
29543
|
-
return true;
|
|
29544
|
-
}
|
|
29545
|
-
}
|
|
29546
|
-
}),
|
|
29547
|
-
// line wrapping
|
|
29548
|
-
lineWrapping ? EditorView.lineWrapping : undefined, keymap.of([indentWithTab])]);
|
|
29549
|
-
// Append Extensions (such as basic-setup)
|
|
29550
|
-
if (this.extensions.length !== 0) _.merge(ext, this.extensions);
|
|
29551
|
-
return ext;
|
|
29552
|
-
},
|
|
29553
|
-
isShowingError() {
|
|
29554
|
-
return !!this.error && this.isInvalid;
|
|
29555
|
-
},
|
|
29556
|
-
isShowingHint() {
|
|
29557
|
-
return !!this.hint && !this.isShowingError;
|
|
29558
|
-
},
|
|
29559
|
-
isShowingHeader() {
|
|
29560
|
-
var _a;
|
|
29561
|
-
return this.isShowingFullscreen || this.$slots.label || this.$slots.actions || ((_a = this.$scopedSlots) === null || _a === void 0 ? void 0 : _a.actions);
|
|
29562
|
-
}
|
|
29563
|
-
},
|
|
29564
|
-
watch: {
|
|
29565
|
-
modelValue(value) {
|
|
29566
|
-
if (this.editor.composing) return;
|
|
29567
|
-
if (this.editor.state.doc.toString() === value) return;
|
|
29568
|
-
const previous = this.editor.state.selection;
|
|
29569
|
-
this.editor.setState(EditorState.create({
|
|
29570
|
-
doc: value,
|
|
29571
|
-
extensions: this.localExtensions,
|
|
29572
|
-
selection: _.some(previous.ranges, range => range.to > value.length) ? {
|
|
29573
|
-
anchor: value.length
|
|
29574
|
-
} : previous
|
|
29575
|
-
}));
|
|
29576
|
-
},
|
|
29577
|
-
isFullscreen(value) {
|
|
29578
|
-
if (value) {
|
|
29579
|
-
this.fullscreenTarget.append(this.editor.dom);
|
|
29580
|
-
} else {
|
|
29581
|
-
this.target.append(this.editor.dom);
|
|
29582
|
-
}
|
|
29583
|
-
},
|
|
29584
|
-
localExtensions() {
|
|
29585
|
-
this.updateEditorState();
|
|
29586
|
-
}
|
|
29587
|
-
},
|
|
29588
|
-
mounted() {
|
|
29589
|
-
this.updateEditorState();
|
|
29590
|
-
this.target.append(this.editor.dom);
|
|
29591
|
-
},
|
|
29592
|
-
beforeUnmount() {
|
|
29593
|
-
var _a;
|
|
29594
|
-
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
29595
|
-
},
|
|
29596
|
-
methods: {
|
|
29597
|
-
updateEditorState() {
|
|
29598
|
-
this.editor.setState(EditorState.create({
|
|
29599
|
-
doc: this.modelValue,
|
|
29600
|
-
extensions: this.localExtensions
|
|
29601
|
-
}));
|
|
29602
|
-
},
|
|
29603
|
-
toggleFullscreen(value) {
|
|
29604
|
-
this.isFullscreen = value === undefined ? !this.isFullscreen : value;
|
|
29605
|
-
}
|
|
29606
|
-
}
|
|
29607
|
-
});
|
|
29608
|
-
|
|
29609
|
-
export { OrCodeLanguages as O, script as s };
|
|
25647
|
+
export { closeBracketsKeymap as $, Annotation as A, highlightSpecialChars as B, ChangeSet as C, Direction as D, EditorView as E, Facet as F, foldGutter as G, drawSelection as H, IndentContext as I, dropCursor as J, indentOnInput as K, syntaxHighlighting as L, defaultHighlightStyle as M, NodeProp as N, bracketMatching as O, Prec as P, closeBrackets as Q, RangeSetBuilder as R, StateField as S, Transaction as T, autocompletion as U, ViewPlugin as V, WidgetType as W, rectangularSelection as X, crosshairCursor as Y, highlightActiveLine as Z, keymap as _, EditorSelection as a, foldKeymap as a0, completionKeymap as a1, languages as a2, JS as a3, TS as a4, CSS as a5, HTML as a6, JSON$1 as a7, MD as a8, ChangeDesc as b, combineConfig as c, Text as d, indentUnit as e, countColumn as f, getIndentation as g, getIndentUnit as h, indentString as i, StateEffect as j, findClusterBreak as k, Decoration as l, matchBrackets as m, codePointAt as n, codePointSize as o, getPanel as p, CharCategory as q, fromCodePoint as r, syntaxTree as s, showPanel as t, EditorState as u, runScopeHandlers as v, hoverTooltip as w, logException as x, lineNumbers as y, highlightActiveLineGutter as z };
|