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