@123usmanhaider321/ui 0.1.8 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +416 -31
- package/dist/images/icon/1LINK.svg +50 -0
- package/dist/images/icon/CreditCard.svg +83 -0
- package/dist/images/icon/Easypaisa.png +0 -0
- package/dist/images/icon/MobileWallet.png +0 -0
- package/dist/images/icon/Raast-Logo.png +0 -0
- package/dist/images/icon/VISA.png +0 -0
- package/dist/images/icon/add-circle-1.svg +5 -0
- package/dist/images/icon/check-circle-broken.svg +3 -0
- package/dist/images/icon/close-circle.svg +5 -0
- package/dist/images/icon/jazzcash.png +0 -0
- package/dist/images/icon/loading_icon.json +3347 -0
- package/dist/images/icon/mastercard-logo.webp +0 -0
- package/dist/images/icon/paymo.jpeg +0 -0
- package/dist/images/icon/preview-svgrepo-com.svg +36 -0
- package/dist/images/icon/trash.svg +7 -0
- package/dist/images/icon/unionpay-logo.svg +9 -0
- package/dist/index-BLoegwT6.js +60476 -0
- package/dist/index-BLoegwT6.js.map +1 -0
- package/dist/index-CPnu5V8f.js +11119 -0
- package/dist/index-CPnu5V8f.js.map +1 -0
- package/dist/index.d.ts +1 -10
- package/dist/index.es-C5pDhGOr.js +16734 -0
- package/dist/index.es-C5pDhGOr.js.map +1 -0
- package/dist/index.js +40 -12
- package/dist/index.js.map +1 -1
- package/dist/loading_icon-n5H5dQBl.js +3375 -0
- package/dist/loading_icon-n5H5dQBl.js.map +1 -0
- package/dist/src/components/Alert/ErrorAlert.d.ts +6 -0
- package/dist/src/components/Alert/SuccessAlert.d.ts +6 -0
- package/dist/{components → src/components}/FormBuilder/DiscountInput.d.ts +3 -6
- package/dist/{components → src/components}/FormBuilder/FormBuilder.d.ts +2 -11
- package/dist/{components → src/components}/FormBuilder/QuestionCard.d.ts +0 -5
- package/dist/{components → src/components}/FormBuilder/QuestionEditor.d.ts +0 -5
- package/dist/{components → src/components}/FormBuilder/SortableQuestionList.d.ts +0 -5
- package/dist/src/components/FormBuilder/questionIcons.d.ts +5 -0
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/AddEventLayout.d.ts +2 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/AddEventStepper.d.ts +2 -2
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/common/ConfirmationModal.d.ts +1 -1
- package/dist/src/components/NewAddEvent/components/EventSubmissionConfirmationModal.d.ts +14 -0
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/StepTwo/TicketTierSection.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/TicketTierForm.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/hooks/useStepperForm.d.ts +22 -22
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/hooks/useTicketTierForm.d.ts +63 -15
- package/dist/src/components/NewAddEvent/schemas/step1.d.ts +211 -0
- package/dist/src/components/NewAddEvent/schemas/step2.d.ts +411 -0
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/schemas/utils.d.ts +8 -2
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/IndividualFormStep.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/SocialProfilesStep.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/TeamFormStep.d.ts +1 -1
- package/dist/src/components/Spinner/spinner.d.ts +4 -0
- package/dist/src/components/TicketlyUIProvider.d.ts +35 -0
- package/dist/src/components/common/Loader/index.d.ts +8 -0
- package/dist/src/components/common/Modals/ConfirmationModal.d.ts +7 -0
- package/dist/{components/FormInput → src/components/ui}/FormInput.d.ts +1 -1
- package/dist/src/components/ui/Loader.d.ts +4 -0
- package/dist/{components/Button/Button.d.ts → src/components/ui/button.d.ts} +1 -1
- package/dist/src/index.d.ts +10 -0
- package/dist/{lib → src/lib}/actions.d.ts +0 -126
- package/dist/src/lib/dom-utils.d.ts +2 -0
- package/dist/src/lib/storage-utils.d.ts +5 -0
- package/dist/src/lib/types.d.ts +258 -0
- package/dist/src/redux/baseQuery.d.ts +16 -0
- package/dist/{services → src/redux/features}/eventApi.d.ts +1053 -1745
- package/dist/src/redux/features/globalSlice.d.ts +17 -0
- package/dist/{services → src/redux/features/single-event}/single-event-api.d.ts +856 -1190
- package/dist/src/redux/types.d.ts +2 -0
- package/dist/src/services/library-services.d.ts +15 -0
- package/dist/src/services/remote-config.d.ts +27 -0
- package/dist/{services → src/services}/utils.d.ts +1 -1
- package/dist/src/theme/colors.d.ts +127 -0
- package/dist/src/theme/typography.d.ts +13 -0
- package/dist/src/types/api.d.ts +18 -0
- package/dist/style.css +2984 -0
- package/dist/styles.css +3760 -4014
- package/package.json +78 -68
- package/dist/_virtual/_commonjsHelpers.js +0 -9
- package/dist/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/_virtual/customParseFormat.js +0 -5
- package/dist/_virtual/customParseFormat.js.map +0 -1
- package/dist/_virtual/dayjs.min.js +0 -5
- package/dist/_virtual/dayjs.min.js.map +0 -1
- package/dist/_virtual/duration.js +0 -5
- package/dist/_virtual/duration.js.map +0 -1
- package/dist/_virtual/index.js +0 -5
- package/dist/_virtual/index.js.map +0 -1
- package/dist/_virtual/isBetween.js +0 -5
- package/dist/_virtual/isBetween.js.map +0 -1
- package/dist/_virtual/relativeTime.js +0 -5
- package/dist/_virtual/relativeTime.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.development.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.production.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/_virtual/with-selector.development.js +0 -5
- package/dist/_virtual/with-selector.development.js.map +0 -1
- package/dist/_virtual/with-selector.js +0 -5
- package/dist/_virtual/with-selector.js.map +0 -1
- package/dist/_virtual/with-selector.production.js +0 -5
- package/dist/_virtual/with-selector.production.js.map +0 -1
- package/dist/components/Alert/Alert.js +0 -51
- package/dist/components/Alert/Alert.js.map +0 -1
- package/dist/components/Button/Button.js +0 -52
- package/dist/components/Button/Button.js.map +0 -1
- package/dist/components/Button/Button.test.d.ts +0 -1
- package/dist/components/Button/index.d.ts +0 -1
- package/dist/components/Checkbox/Checkbox.js +0 -50
- package/dist/components/Checkbox/Checkbox.js.map +0 -1
- package/dist/components/Checkbox/Checkbox.test.d.ts +0 -1
- package/dist/components/Checkbox/index.d.ts +0 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +0 -25
- package/dist/components/CheckboxGroup/CheckboxGroup.js +0 -99
- package/dist/components/CheckboxGroup/CheckboxGroup.js.map +0 -1
- package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +0 -15
- package/dist/components/ConfirmationModal/ConfirmationModal.js +0 -136
- package/dist/components/ConfirmationModal/ConfirmationModal.js.map +0 -1
- package/dist/components/ConfirmationModal/index.d.ts +0 -2
- package/dist/components/CustomSelect/CustomSelect.js +0 -259
- package/dist/components/CustomSelect/CustomSelect.js.map +0 -1
- package/dist/components/EventAddForm/AddEventLayout.js +0 -227
- package/dist/components/EventAddForm/AddEventLayout.js.map +0 -1
- package/dist/components/EventAddForm/AddEventStepper.js +0 -719
- package/dist/components/EventAddForm/AddEventStepper.js.map +0 -1
- package/dist/components/EventAddForm/common/ConfirmationModal.js +0 -136
- package/dist/components/EventAddForm/common/ConfirmationModal.js.map +0 -1
- package/dist/components/EventAddForm/common/DescriptionModal.js +0 -70
- package/dist/components/EventAddForm/common/DescriptionModal.js.map +0 -1
- package/dist/components/EventAddForm/components/AnimatedBackground.d.ts +0 -8
- package/dist/components/EventAddForm/components/ApprovalConfirmationModal.d.ts +0 -7
- package/dist/components/EventAddForm/components/CheckboxGroup.js +0 -92
- package/dist/components/EventAddForm/components/CheckboxGroup.js.map +0 -1
- package/dist/components/EventAddForm/components/CustomMeetingForm.js +0 -237
- package/dist/components/EventAddForm/components/CustomMeetingForm.js.map +0 -1
- package/dist/components/EventAddForm/components/DateTimeField.js +0 -173
- package/dist/components/EventAddForm/components/DateTimeField.js.map +0 -1
- package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.d.ts +0 -33
- package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.js +0 -366
- package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.js.map +0 -1
- package/dist/components/EventAddForm/components/FileUpload.js +0 -412
- package/dist/components/EventAddForm/components/FileUpload.js.map +0 -1
- package/dist/components/EventAddForm/components/FormBuilderProceedModal.js +0 -197
- package/dist/components/EventAddForm/components/FormBuilderProceedModal.js.map +0 -1
- package/dist/components/EventAddForm/components/GoogleMapsAutocompleteInput.js +0 -1179
- package/dist/components/EventAddForm/components/GoogleMapsAutocompleteInput.js.map +0 -1
- package/dist/components/EventAddForm/components/InputField.d.ts +0 -15
- package/dist/components/EventAddForm/components/RadioGroupButton.d.ts +0 -14
- package/dist/components/EventAddForm/components/SelectField.d.ts +0 -19
- package/dist/components/EventAddForm/components/SingleDateTimeInput.js +0 -102
- package/dist/components/EventAddForm/components/SingleDateTimeInput.js.map +0 -1
- package/dist/components/EventAddForm/components/StepTwo/CustomFormSection.js +0 -277
- package/dist/components/EventAddForm/components/StepTwo/CustomFormSection.js.map +0 -1
- package/dist/components/EventAddForm/components/StepTwo/TicketTierSection.js +0 -148
- package/dist/components/EventAddForm/components/StepTwo/TicketTierSection.js.map +0 -1
- package/dist/components/EventAddForm/components/TicketTierForm.js +0 -418
- package/dist/components/EventAddForm/components/TicketTierForm.js.map +0 -1
- package/dist/components/EventAddForm/components/TicketTypeSelection.js +0 -93
- package/dist/components/EventAddForm/components/TicketTypeSelection.js.map +0 -1
- package/dist/components/EventAddForm/hooks/useStepperForm.js +0 -371
- package/dist/components/EventAddForm/hooks/useStepperForm.js.map +0 -1
- package/dist/components/EventAddForm/hooks/useTicketTierForm.js +0 -237
- package/dist/components/EventAddForm/hooks/useTicketTierForm.js.map +0 -1
- package/dist/components/EventAddForm/index.d.ts +0 -3
- package/dist/components/EventAddForm/index.js +0 -41
- package/dist/components/EventAddForm/index.js.map +0 -1
- package/dist/components/EventAddForm/schemas/index.d.ts +0 -2
- package/dist/components/EventAddForm/schemas/step1.d.ts +0 -47
- package/dist/components/EventAddForm/schemas/step1.js +0 -135
- package/dist/components/EventAddForm/schemas/step1.js.map +0 -1
- package/dist/components/EventAddForm/schemas/step2.d.ts +0 -138
- package/dist/components/EventAddForm/schemas/step2.js +0 -94
- package/dist/components/EventAddForm/schemas/step2.js.map +0 -1
- package/dist/components/EventAddForm/schemas/utils.js +0 -28
- package/dist/components/EventAddForm/schemas/utils.js.map +0 -1
- package/dist/components/EventAddForm/steps/IndividualFormStep.js +0 -85
- package/dist/components/EventAddForm/steps/IndividualFormStep.js.map +0 -1
- package/dist/components/EventAddForm/steps/SocialProfilesStep.js +0 -123
- package/dist/components/EventAddForm/steps/SocialProfilesStep.js.map +0 -1
- package/dist/components/EventAddForm/steps/StepOne.js +0 -462
- package/dist/components/EventAddForm/steps/StepOne.js.map +0 -1
- package/dist/components/EventAddForm/steps/StepTwo.js +0 -173
- package/dist/components/EventAddForm/steps/StepTwo.js.map +0 -1
- package/dist/components/EventAddForm/steps/TeamFormStep.js +0 -13
- package/dist/components/EventAddForm/steps/TeamFormStep.js.map +0 -1
- package/dist/components/FormBuilder/CategoryList.js +0 -242
- package/dist/components/FormBuilder/CategoryList.js.map +0 -1
- package/dist/components/FormBuilder/DiscountInput.js +0 -366
- package/dist/components/FormBuilder/DiscountInput.js.map +0 -1
- package/dist/components/FormBuilder/FormBuilder.js +0 -918
- package/dist/components/FormBuilder/FormBuilder.js.map +0 -1
- package/dist/components/FormBuilder/OptionList.js +0 -120
- package/dist/components/FormBuilder/OptionList.js.map +0 -1
- package/dist/components/FormBuilder/PaymentPreview.d.ts +0 -12
- package/dist/components/FormBuilder/PaymentPreview.js +0 -70
- package/dist/components/FormBuilder/PaymentPreview.js.map +0 -1
- package/dist/components/FormBuilder/PreviewInput.d.ts +0 -10
- package/dist/components/FormBuilder/PreviewInput.js +0 -143
- package/dist/components/FormBuilder/PreviewInput.js.map +0 -1
- package/dist/components/FormBuilder/QuestionCard.js +0 -252
- package/dist/components/FormBuilder/QuestionCard.js.map +0 -1
- package/dist/components/FormBuilder/QuestionEditor.js +0 -166
- package/dist/components/FormBuilder/QuestionEditor.js.map +0 -1
- package/dist/components/FormBuilder/RequiredToggle.js +0 -43
- package/dist/components/FormBuilder/RequiredToggle.js.map +0 -1
- package/dist/components/FormBuilder/SortableQuestionList.js +0 -137
- package/dist/components/FormBuilder/SortableQuestionList.js.map +0 -1
- package/dist/components/FormBuilder/index.d.ts +0 -4
- package/dist/components/FormBuilder/utils.js +0 -229
- package/dist/components/FormBuilder/utils.js.map +0 -1
- package/dist/components/FormInput/FormInput.js +0 -126
- package/dist/components/FormInput/FormInput.js.map +0 -1
- package/dist/components/FormInput/FormInput.test.d.ts +0 -1
- package/dist/components/FormInput/index.d.ts +0 -2
- package/dist/components/ImageCropModal/index.js +0 -464
- package/dist/components/ImageCropModal/index.js.map +0 -1
- package/dist/components/InformationPopover/InformationPopover.d.ts +0 -7
- package/dist/components/InformationPopover/InformationPopover.js +0 -19
- package/dist/components/InformationPopover/InformationPopover.js.map +0 -1
- package/dist/components/InformationPopover.js +0 -19
- package/dist/components/InformationPopover.js.map +0 -1
- package/dist/components/InputErrorMessage/InputErrorMessage.js +0 -21
- package/dist/components/InputErrorMessage/InputErrorMessage.js.map +0 -1
- package/dist/components/Modal/Modal.d.ts +0 -15
- package/dist/components/Modal/Modal.js +0 -73
- package/dist/components/Modal/Modal.js.map +0 -1
- package/dist/components/Radio/Radio.js +0 -35
- package/dist/components/Radio/Radio.js.map +0 -1
- package/dist/components/Spinner/spinner.d.ts +0 -2
- package/dist/components/Spinner/spinner.js +0 -22
- package/dist/components/Spinner/spinner.js.map +0 -1
- package/dist/components/Toggle/Toggle.d.ts +0 -16
- package/dist/components/Toggle/index.d.ts +0 -2
- package/dist/components/Tooltip/Tooltip.d.ts +0 -12
- package/dist/components/Tooltip/Tooltip.js +0 -134
- package/dist/components/Tooltip/Tooltip.js.map +0 -1
- package/dist/components/common/FallbackImage.js +0 -47
- package/dist/components/common/FallbackImage.js.map +0 -1
- package/dist/components/ui/Calendar/calendar-utils.js +0 -51
- package/dist/components/ui/Calendar/calendar-utils.js.map +0 -1
- package/dist/components/ui/Calendar/index.js +0 -142
- package/dist/components/ui/Calendar/index.js.map +0 -1
- package/dist/components/ui/Checkbox.d.ts +0 -9
- package/dist/components/ui/Checkbox.js +0 -50
- package/dist/components/ui/Checkbox.js.map +0 -1
- package/dist/components/ui/DatePicker/index.js +0 -188
- package/dist/components/ui/DatePicker/index.js.map +0 -1
- package/dist/components/ui/FormInput.js +0 -129
- package/dist/components/ui/FormInput.js.map +0 -1
- package/dist/components/ui/InputErrorMessage.d.ts +0 -7
- package/dist/components/ui/InputErrorMessage.js +0 -21
- package/dist/components/ui/InputErrorMessage.js.map +0 -1
- package/dist/components/ui/Modal/index.js +0 -73
- package/dist/components/ui/Modal/index.js.map +0 -1
- package/dist/components/ui/Radio.d.ts +0 -6
- package/dist/components/ui/Radio.js +0 -35
- package/dist/components/ui/Radio.js.map +0 -1
- package/dist/components/ui/RichTextEditor.js +0 -242
- package/dist/components/ui/RichTextEditor.js.map +0 -1
- package/dist/components/ui/TimePicker/index.js +0 -215
- package/dist/components/ui/TimePicker/index.js.map +0 -1
- package/dist/components/ui/TimeSelector/index.js +0 -138
- package/dist/components/ui/TimeSelector/index.js.map +0 -1
- package/dist/components/ui/Tooltip.d.ts +0 -12
- package/dist/components/ui/Tooltip.js +0 -136
- package/dist/components/ui/Tooltip.js.map +0 -1
- package/dist/hooks/useDropdownPosition.d.ts +0 -11
- package/dist/hooks/useFirebaseAuthState.d.ts +0 -6
- package/dist/hooks/useFirebaseAuthState.js +0 -23
- package/dist/hooks/useFirebaseAuthState.js.map +0 -1
- package/dist/hooks/useTicketTierForm.d.ts +0 -61
- package/dist/lib/actions.js +0 -32
- package/dist/lib/actions.js.map +0 -1
- package/dist/lib/cropImage.js +0 -113
- package/dist/lib/cropImage.js.map +0 -1
- package/dist/lib/imageAnalysis.js +0 -58
- package/dist/lib/imageAnalysis.js.map +0 -1
- package/dist/lib/utils.js +0 -9
- package/dist/lib/utils.js.map +0 -1
- package/dist/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js +0 -60
- package/dist/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js.map +0 -1
- package/dist/node_modules/@dnd-kit/core/dist/core.esm.js +0 -3458
- package/dist/node_modules/@dnd-kit/core/dist/core.esm.js.map +0 -1
- package/dist/node_modules/@dnd-kit/sortable/dist/sortable.esm.js +0 -593
- package/dist/node_modules/@dnd-kit/sortable/dist/sortable.esm.js.map +0 -1
- package/dist/node_modules/@dnd-kit/utilities/dist/utilities.esm.js +0 -302
- package/dist/node_modules/@dnd-kit/utilities/dist/utilities.esm.js.map +0 -1
- package/dist/node_modules/@firebase/app/dist/esm/index.esm.js +0 -768
- package/dist/node_modules/@firebase/app/dist/esm/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/component/dist/esm/index.esm.js +0 -340
- package/dist/node_modules/@firebase/component/dist/esm/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/logger/dist/esm/index.esm.js +0 -123
- package/dist/node_modules/@firebase/logger/dist/esm/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/storage/dist/index.esm.js +0 -2623
- package/dist/node_modules/@firebase/storage/dist/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/util/dist/index.esm.js +0 -658
- package/dist/node_modules/@firebase/util/dist/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/util/dist/postinstall.js +0 -5
- package/dist/node_modules/@firebase/util/dist/postinstall.js.map +0 -1
- package/dist/node_modules/@fortawesome/fontawesome-svg-core/index.js +0 -3179
- package/dist/node_modules/@fortawesome/fontawesome-svg-core/index.js.map +0 -1
- package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js +0 -60
- package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js.map +0 -1
- package/dist/node_modules/@fortawesome/react-fontawesome/dist/index.js +0 -400
- package/dist/node_modules/@fortawesome/react-fontawesome/dist/index.js.map +0 -1
- package/dist/node_modules/@heroicons/react/20/solid/esm/CheckIcon.js +0 -27
- package/dist/node_modules/@heroicons/react/20/solid/esm/CheckIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js +0 -27
- package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowRightIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowRightIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/ClockIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/ClockIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentDuplicateIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentDuplicateIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/InformationCircleIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/InformationCircleIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/LinkIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/LinkIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/MagnifyingGlassIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/MagnifyingGlassIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/MapPinIcon.js +0 -33
- package/dist/node_modules/@heroicons/react/24/outline/esm/MapPinIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/VideoCameraIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/VideoCameraIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js.map +0 -1
- package/dist/node_modules/@tiptap/core/dist/index.js +0 -5446
- package/dist/node_modules/@tiptap/core/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +0 -21
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +0 -78
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js +0 -100
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +0 -70
- package/dist/node_modules/@tiptap/extension-code/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +0 -317
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-document/dist/index.js +0 -16
- package/dist/node_modules/@tiptap/extension-document/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +0 -66
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +0 -86
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +0 -80
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js +0 -98
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +0 -423
- package/dist/node_modules/@tiptap/extension-link/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +0 -1039
- package/dist/node_modules/@tiptap/extension-list/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +0 -61
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js +0 -7
- package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js +0 -79
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-text/dist/index.js +0 -16
- package/dist/node_modules/@tiptap/extension-text/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-underline/dist/index.js +0 -76
- package/dist/node_modules/@tiptap/extension-underline/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extensions/dist/index.js +0 -376
- package/dist/node_modules/@tiptap/extensions/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/react/dist/index.js +0 -650
- package/dist/node_modules/@tiptap/react/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js +0 -97
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js.map +0 -1
- package/dist/node_modules/dayjs/dayjs.min.js +0 -283
- package/dist/node_modules/dayjs/dayjs.min.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/customParseFormat.js +0 -130
- package/dist/node_modules/dayjs/plugin/customParseFormat.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/duration.js +0 -137
- package/dist/node_modules/dayjs/plugin/duration.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/isBetween.js +0 -20
- package/dist/node_modules/dayjs/plugin/isBetween.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/relativeTime.js +0 -49
- package/dist/node_modules/dayjs/plugin/relativeTime.js.map +0 -1
- package/dist/node_modules/fast-equals/dist/es/index.js +0 -442
- package/dist/node_modules/fast-equals/dist/es/index.js.map +0 -1
- package/dist/node_modules/idb/build/index.js +0 -70
- package/dist/node_modules/idb/build/index.js.map +0 -1
- package/dist/node_modules/idb/build/wrap-idb-value.js +0 -149
- package/dist/node_modules/idb/build/wrap-idb-value.js.map +0 -1
- package/dist/node_modules/linkifyjs/dist/linkify.js +0 -1159
- package/dist/node_modules/linkifyjs/dist/linkify.js.map +0 -1
- package/dist/node_modules/orderedmap/dist/index.js +0 -120
- package/dist/node_modules/orderedmap/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-commands/dist/index.js +0 -527
- package/dist/node_modules/prosemirror-commands/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js +0 -137
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +0 -221
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-history/dist/index.js +0 -357
- package/dist/node_modules/prosemirror-history/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-keymap/dist/index.js +0 -84
- package/dist/node_modules/prosemirror-keymap/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-model/dist/index.js +0 -3209
- package/dist/node_modules/prosemirror-model/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-schema-list/dist/index.js +0 -131
- package/dist/node_modules/prosemirror-schema-list/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-state/dist/index.js +0 -936
- package/dist/node_modules/prosemirror-state/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-transform/dist/index.js +0 -1881
- package/dist/node_modules/prosemirror-transform/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-view/dist/index.js +0 -5232
- package/dist/node_modules/prosemirror-view/dist/index.js.map +0 -1
- package/dist/node_modules/rope-sequence/dist/index.js +0 -184
- package/dist/node_modules/rope-sequence/dist/index.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -82
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +0 -78
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -78
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -63
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/shim/index.js +0 -13
- package/dist/node_modules/use-sync-external-store/shim/index.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/shim/with-selector.js +0 -13
- package/dist/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -1
- package/dist/node_modules/w3c-keyname/index.js +0 -106
- package/dist/node_modules/w3c-keyname/index.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/coerce.js +0 -10
- package/dist/node_modules/zod/v4/classic/coerce.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/compat.js +0 -8
- package/dist/node_modules/zod/v4/classic/compat.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/errors.js +0 -45
- package/dist/node_modules/zod/v4/classic/errors.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/iso.js +0 -44
- package/dist/node_modules/zod/v4/classic/iso.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/parse.js +0 -30
- package/dist/node_modules/zod/v4/classic/parse.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/schemas.js +0 -711
- package/dist/node_modules/zod/v4/classic/schemas.js.map +0 -1
- package/dist/node_modules/zod/v4/core/api.js +0 -588
- package/dist/node_modules/zod/v4/core/api.js.map +0 -1
- package/dist/node_modules/zod/v4/core/checks.js +0 -411
- package/dist/node_modules/zod/v4/core/checks.js.map +0 -1
- package/dist/node_modules/zod/v4/core/core.js +0 -75
- package/dist/node_modules/zod/v4/core/core.js.map +0 -1
- package/dist/node_modules/zod/v4/core/doc.js +0 -38
- package/dist/node_modules/zod/v4/core/doc.js.map +0 -1
- package/dist/node_modules/zod/v4/core/errors.js +0 -73
- package/dist/node_modules/zod/v4/core/errors.js.map +0 -1
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -359
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +0 -1
- package/dist/node_modules/zod/v4/core/parse.js +0 -96
- package/dist/node_modules/zod/v4/core/parse.js.map +0 -1
- package/dist/node_modules/zod/v4/core/regexes.js +0 -84
- package/dist/node_modules/zod/v4/core/regexes.js.map +0 -1
- package/dist/node_modules/zod/v4/core/registries.js +0 -52
- package/dist/node_modules/zod/v4/core/registries.js.map +0 -1
- package/dist/node_modules/zod/v4/core/schemas.js +0 -1391
- package/dist/node_modules/zod/v4/core/schemas.js.map +0 -1
- package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -363
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +0 -1
- package/dist/node_modules/zod/v4/core/util.js +0 -431
- package/dist/node_modules/zod/v4/core/util.js.map +0 -1
- package/dist/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/zod/v4/core/versions.js.map +0 -1
- package/dist/redux/baseQuery.d.ts +0 -1
- package/dist/redux/baseQuery.js +0 -24
- package/dist/redux/baseQuery.js.map +0 -1
- package/dist/services/eventApi.js +0 -411
- package/dist/services/eventApi.js.map +0 -1
- package/dist/services/helpers.js +0 -115
- package/dist/services/helpers.js.map +0 -1
- package/dist/services/initialize-firebase.d.ts +0 -2
- package/dist/services/initialize-firebase.js +0 -20
- package/dist/services/initialize-firebase.js.map +0 -1
- package/dist/services/process-image-on-server.js +0 -30
- package/dist/services/process-image-on-server.js.map +0 -1
- package/dist/services/remote-config.d.ts +0 -5
- package/dist/services/remote-config.js +0 -9
- package/dist/services/remote-config.js.map +0 -1
- package/dist/services/single-event-api.js +0 -301
- package/dist/services/single-event-api.js.map +0 -1
- package/dist/services/utils.js +0 -107
- package/dist/services/utils.js.map +0 -1
- package/dist/setupTests.d.ts +0 -1
- package/dist/stories/Alert.stories.d.ts +0 -10
- package/dist/stories/Button.stories.d.ts +0 -13
- package/dist/types/redux-types.d.ts +0 -15
- package/dist/types/types.d.ts +0 -60
- package/dist/types/types.js +0 -10
- package/dist/types/types.js.map +0 -1
- package/dist/utils/cn.d.ts +0 -6
- package/dist/utils/cn.js +0 -9
- package/dist/utils/cn.js.map +0 -1
- package/dist/utils/date-range.d.ts +0 -4
- package/dist/utils/date-range.js +0 -13
- package/dist/utils/date-range.js.map +0 -1
- package/dist/utils/single-event-helpers.d.ts +0 -50
- package/dist/utils/single-event-helpers.js +0 -18
- package/dist/utils/single-event-helpers.js.map +0 -1
- package/dist/utils/social-validation.js +0 -42
- package/dist/utils/social-validation.js.map +0 -1
- package/dist/utils/utils.js +0 -20
- package/dist/utils/utils.js.map +0 -1
- /package/dist/{components/Alert/Alert.d.ts → src/components/Alert/index.d.ts} +0 -0
- /package/dist/{components → src/components}/FormBuilder/CategoryList.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/OptionList.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/RequiredToggle.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/types.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/utils.d.ts +0 -0
- /package/dist/{components → src/components}/ImageCropModal/index.d.ts +0 -0
- /package/dist/{components → src/components}/InformationPopover.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/common/DescriptionModal.d.ts +0 -0
- /package/dist/{components/ui/FormInput.d.ts → src/components/NewAddEvent/components/AddEventFormInput.d.ts} +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/CheckboxGroup.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/CustomMeetingForm.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/DateTimeField.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/FileUpload.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/FormBuilderProceedModal.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/GoogleMapsAutocompleteInput.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/SingleDateTimeInput.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/StepTwo/CustomFormSection.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/TicketTypeSelection.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/StepOne.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/StepTwo.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/types.d.ts +0 -0
- /package/dist/{components → src/components}/common/FallbackImage.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Calendar/calendar-utils.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Calendar/index.d.ts +0 -0
- /package/dist/{components/Checkbox → src/components/ui}/Checkbox.d.ts +0 -0
- /package/dist/{components/CustomSelect → src/components/ui}/CustomSelect.d.ts +0 -0
- /package/dist/{components → src/components}/ui/DatePicker/index.d.ts +0 -0
- /package/dist/{components/InputErrorMessage → src/components/ui}/InputErrorMessage.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Modal/index.d.ts +0 -0
- /package/dist/{components/Radio → src/components/ui}/Radio.d.ts +0 -0
- /package/dist/{components → src/components}/ui/RichTextEditor.d.ts +0 -0
- /package/dist/{components → src/components}/ui/TimePicker/index.d.ts +0 -0
- /package/dist/{components → src/components}/ui/TimeSelector/index.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Tooltip/index.d.ts +0 -0
- /package/dist/{lib → src/lib}/constants.d.ts +0 -0
- /package/dist/{lib → src/lib}/cropImage.d.ts +0 -0
- /package/dist/{lib → src/lib}/imageAnalysis.d.ts +0 -0
- /package/dist/{utils → src/lib}/social-validation.d.ts +0 -0
- /package/dist/{lib/utils.d.ts → src/lib/tailwind-merge.d.ts} +0 -0
- /package/dist/{utils → src/lib}/utils.d.ts +0 -0
- /package/dist/{services → src/redux/features/single-event}/helpers.d.ts +0 -0
- /package/dist/{services → src/services}/process-image-on-server.d.ts +0 -0
- /package/dist/{types → src/types}/events.d.ts +0 -0
- /package/dist/{types → src/types}/question.d.ts +0 -0
|
@@ -1,1881 +0,0 @@
|
|
|
1
|
-
import { Slice, Fragment, Mark, MarkType, ReplaceError } from "../../prosemirror-model/dist/index.js";
|
|
2
|
-
const lower16 = 65535;
|
|
3
|
-
const factor16 = Math.pow(2, 16);
|
|
4
|
-
function makeRecover(index, offset) {
|
|
5
|
-
return index + offset * factor16;
|
|
6
|
-
}
|
|
7
|
-
function recoverIndex(value) {
|
|
8
|
-
return value & lower16;
|
|
9
|
-
}
|
|
10
|
-
function recoverOffset(value) {
|
|
11
|
-
return (value - (value & lower16)) / factor16;
|
|
12
|
-
}
|
|
13
|
-
const DEL_BEFORE = 1, DEL_AFTER = 2, DEL_ACROSS = 4, DEL_SIDE = 8;
|
|
14
|
-
class MapResult {
|
|
15
|
-
/**
|
|
16
|
-
@internal
|
|
17
|
-
*/
|
|
18
|
-
constructor(pos, delInfo, recover) {
|
|
19
|
-
this.pos = pos;
|
|
20
|
-
this.delInfo = delInfo;
|
|
21
|
-
this.recover = recover;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
Tells you whether the position was deleted, that is, whether the
|
|
25
|
-
step removed the token on the side queried (via the `assoc`)
|
|
26
|
-
argument from the document.
|
|
27
|
-
*/
|
|
28
|
-
get deleted() {
|
|
29
|
-
return (this.delInfo & DEL_SIDE) > 0;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
Tells you whether the token before the mapped position was deleted.
|
|
33
|
-
*/
|
|
34
|
-
get deletedBefore() {
|
|
35
|
-
return (this.delInfo & (DEL_BEFORE | DEL_ACROSS)) > 0;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
True when the token after the mapped position was deleted.
|
|
39
|
-
*/
|
|
40
|
-
get deletedAfter() {
|
|
41
|
-
return (this.delInfo & (DEL_AFTER | DEL_ACROSS)) > 0;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
Tells whether any of the steps mapped through deletes across the
|
|
45
|
-
position (including both the token before and after the
|
|
46
|
-
position).
|
|
47
|
-
*/
|
|
48
|
-
get deletedAcross() {
|
|
49
|
-
return (this.delInfo & DEL_ACROSS) > 0;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
class StepMap {
|
|
53
|
-
/**
|
|
54
|
-
Create a position map. The modifications to the document are
|
|
55
|
-
represented as an array of numbers, in which each group of three
|
|
56
|
-
represents a modified chunk as `[start, oldSize, newSize]`.
|
|
57
|
-
*/
|
|
58
|
-
constructor(ranges, inverted = false) {
|
|
59
|
-
this.ranges = ranges;
|
|
60
|
-
this.inverted = inverted;
|
|
61
|
-
if (!ranges.length && StepMap.empty)
|
|
62
|
-
return StepMap.empty;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
@internal
|
|
66
|
-
*/
|
|
67
|
-
recover(value) {
|
|
68
|
-
let diff = 0, index = recoverIndex(value);
|
|
69
|
-
if (!this.inverted)
|
|
70
|
-
for (let i = 0; i < index; i++)
|
|
71
|
-
diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
|
|
72
|
-
return this.ranges[index * 3] + diff + recoverOffset(value);
|
|
73
|
-
}
|
|
74
|
-
mapResult(pos, assoc = 1) {
|
|
75
|
-
return this._map(pos, assoc, false);
|
|
76
|
-
}
|
|
77
|
-
map(pos, assoc = 1) {
|
|
78
|
-
return this._map(pos, assoc, true);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
@internal
|
|
82
|
-
*/
|
|
83
|
-
_map(pos, assoc, simple) {
|
|
84
|
-
let diff = 0, oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
|
|
85
|
-
for (let i = 0; i < this.ranges.length; i += 3) {
|
|
86
|
-
let start = this.ranges[i] - (this.inverted ? diff : 0);
|
|
87
|
-
if (start > pos)
|
|
88
|
-
break;
|
|
89
|
-
let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex], end = start + oldSize;
|
|
90
|
-
if (pos <= end) {
|
|
91
|
-
let side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;
|
|
92
|
-
let result = start + diff + (side < 0 ? 0 : newSize);
|
|
93
|
-
if (simple)
|
|
94
|
-
return result;
|
|
95
|
-
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
96
|
-
let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
97
|
-
if (assoc < 0 ? pos != start : pos != end)
|
|
98
|
-
del |= DEL_SIDE;
|
|
99
|
-
return new MapResult(result, del, recover);
|
|
100
|
-
}
|
|
101
|
-
diff += newSize - oldSize;
|
|
102
|
-
}
|
|
103
|
-
return simple ? pos + diff : new MapResult(pos + diff, 0, null);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
@internal
|
|
107
|
-
*/
|
|
108
|
-
touches(pos, recover) {
|
|
109
|
-
let diff = 0, index = recoverIndex(recover);
|
|
110
|
-
let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
|
|
111
|
-
for (let i = 0; i < this.ranges.length; i += 3) {
|
|
112
|
-
let start = this.ranges[i] - (this.inverted ? diff : 0);
|
|
113
|
-
if (start > pos)
|
|
114
|
-
break;
|
|
115
|
-
let oldSize = this.ranges[i + oldIndex], end = start + oldSize;
|
|
116
|
-
if (pos <= end && i == index * 3)
|
|
117
|
-
return true;
|
|
118
|
-
diff += this.ranges[i + newIndex] - oldSize;
|
|
119
|
-
}
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
Calls the given function on each of the changed ranges included in
|
|
124
|
-
this map.
|
|
125
|
-
*/
|
|
126
|
-
forEach(f) {
|
|
127
|
-
let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
|
|
128
|
-
for (let i = 0, diff = 0; i < this.ranges.length; i += 3) {
|
|
129
|
-
let start = this.ranges[i], oldStart = start - (this.inverted ? diff : 0), newStart = start + (this.inverted ? 0 : diff);
|
|
130
|
-
let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex];
|
|
131
|
-
f(oldStart, oldStart + oldSize, newStart, newStart + newSize);
|
|
132
|
-
diff += newSize - oldSize;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
Create an inverted version of this map. The result can be used to
|
|
137
|
-
map positions in the post-step document to the pre-step document.
|
|
138
|
-
*/
|
|
139
|
-
invert() {
|
|
140
|
-
return new StepMap(this.ranges, !this.inverted);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
@internal
|
|
144
|
-
*/
|
|
145
|
-
toString() {
|
|
146
|
-
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
Create a map that moves all positions by offset `n` (which may be
|
|
150
|
-
negative). This can be useful when applying steps meant for a
|
|
151
|
-
sub-document to a larger document, or vice-versa.
|
|
152
|
-
*/
|
|
153
|
-
static offset(n) {
|
|
154
|
-
return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
StepMap.empty = new StepMap([]);
|
|
158
|
-
class Mapping {
|
|
159
|
-
/**
|
|
160
|
-
Create a new mapping with the given position maps.
|
|
161
|
-
*/
|
|
162
|
-
constructor(maps, mirror, from = 0, to = maps ? maps.length : 0) {
|
|
163
|
-
this.mirror = mirror;
|
|
164
|
-
this.from = from;
|
|
165
|
-
this.to = to;
|
|
166
|
-
this._maps = maps || [];
|
|
167
|
-
this.ownData = !(maps || mirror);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
The step maps in this mapping.
|
|
171
|
-
*/
|
|
172
|
-
get maps() {
|
|
173
|
-
return this._maps;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
Create a mapping that maps only through a part of this one.
|
|
177
|
-
*/
|
|
178
|
-
slice(from = 0, to = this.maps.length) {
|
|
179
|
-
return new Mapping(this._maps, this.mirror, from, to);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
Add a step map to the end of this mapping. If `mirrors` is
|
|
183
|
-
given, it should be the index of the step map that is the mirror
|
|
184
|
-
image of this one.
|
|
185
|
-
*/
|
|
186
|
-
appendMap(map, mirrors) {
|
|
187
|
-
if (!this.ownData) {
|
|
188
|
-
this._maps = this._maps.slice();
|
|
189
|
-
this.mirror = this.mirror && this.mirror.slice();
|
|
190
|
-
this.ownData = true;
|
|
191
|
-
}
|
|
192
|
-
this.to = this._maps.push(map);
|
|
193
|
-
if (mirrors != null)
|
|
194
|
-
this.setMirror(this._maps.length - 1, mirrors);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
Add all the step maps in a given mapping to this one (preserving
|
|
198
|
-
mirroring information).
|
|
199
|
-
*/
|
|
200
|
-
appendMapping(mapping) {
|
|
201
|
-
for (let i = 0, startSize = this._maps.length; i < mapping._maps.length; i++) {
|
|
202
|
-
let mirr = mapping.getMirror(i);
|
|
203
|
-
this.appendMap(mapping._maps[i], mirr != null && mirr < i ? startSize + mirr : void 0);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
Finds the offset of the step map that mirrors the map at the
|
|
208
|
-
given offset, in this mapping (as per the second argument to
|
|
209
|
-
`appendMap`).
|
|
210
|
-
*/
|
|
211
|
-
getMirror(n) {
|
|
212
|
-
if (this.mirror) {
|
|
213
|
-
for (let i = 0; i < this.mirror.length; i++)
|
|
214
|
-
if (this.mirror[i] == n)
|
|
215
|
-
return this.mirror[i + (i % 2 ? -1 : 1)];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
@internal
|
|
220
|
-
*/
|
|
221
|
-
setMirror(n, m) {
|
|
222
|
-
if (!this.mirror)
|
|
223
|
-
this.mirror = [];
|
|
224
|
-
this.mirror.push(n, m);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
Append the inverse of the given mapping to this one.
|
|
228
|
-
*/
|
|
229
|
-
appendMappingInverted(mapping) {
|
|
230
|
-
for (let i = mapping.maps.length - 1, totalSize = this._maps.length + mapping._maps.length; i >= 0; i--) {
|
|
231
|
-
let mirr = mapping.getMirror(i);
|
|
232
|
-
this.appendMap(mapping._maps[i].invert(), mirr != null && mirr > i ? totalSize - mirr - 1 : void 0);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
Create an inverted version of this mapping.
|
|
237
|
-
*/
|
|
238
|
-
invert() {
|
|
239
|
-
let inverse = new Mapping();
|
|
240
|
-
inverse.appendMappingInverted(this);
|
|
241
|
-
return inverse;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
Map a position through this mapping.
|
|
245
|
-
*/
|
|
246
|
-
map(pos, assoc = 1) {
|
|
247
|
-
if (this.mirror)
|
|
248
|
-
return this._map(pos, assoc, true);
|
|
249
|
-
for (let i = this.from; i < this.to; i++)
|
|
250
|
-
pos = this._maps[i].map(pos, assoc);
|
|
251
|
-
return pos;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
Map a position through this mapping, returning a mapping
|
|
255
|
-
result.
|
|
256
|
-
*/
|
|
257
|
-
mapResult(pos, assoc = 1) {
|
|
258
|
-
return this._map(pos, assoc, false);
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
@internal
|
|
262
|
-
*/
|
|
263
|
-
_map(pos, assoc, simple) {
|
|
264
|
-
let delInfo = 0;
|
|
265
|
-
for (let i = this.from; i < this.to; i++) {
|
|
266
|
-
let map = this._maps[i], result = map.mapResult(pos, assoc);
|
|
267
|
-
if (result.recover != null) {
|
|
268
|
-
let corr = this.getMirror(i);
|
|
269
|
-
if (corr != null && corr > i && corr < this.to) {
|
|
270
|
-
i = corr;
|
|
271
|
-
pos = this._maps[corr].recover(result.recover);
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
delInfo |= result.delInfo;
|
|
276
|
-
pos = result.pos;
|
|
277
|
-
}
|
|
278
|
-
return simple ? pos : new MapResult(pos, delInfo, null);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
const stepsByID = /* @__PURE__ */ Object.create(null);
|
|
282
|
-
class Step {
|
|
283
|
-
/**
|
|
284
|
-
Get the step map that represents the changes made by this step,
|
|
285
|
-
and which can be used to transform between positions in the old
|
|
286
|
-
and the new document.
|
|
287
|
-
*/
|
|
288
|
-
getMap() {
|
|
289
|
-
return StepMap.empty;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
Try to merge this step with another one, to be applied directly
|
|
293
|
-
after it. Returns the merged step when possible, null if the
|
|
294
|
-
steps can't be merged.
|
|
295
|
-
*/
|
|
296
|
-
merge(other) {
|
|
297
|
-
return null;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
Deserialize a step from its JSON representation. Will call
|
|
301
|
-
through to the step class' own implementation of this method.
|
|
302
|
-
*/
|
|
303
|
-
static fromJSON(schema, json) {
|
|
304
|
-
if (!json || !json.stepType)
|
|
305
|
-
throw new RangeError("Invalid input for Step.fromJSON");
|
|
306
|
-
let type = stepsByID[json.stepType];
|
|
307
|
-
if (!type)
|
|
308
|
-
throw new RangeError(`No step type ${json.stepType} defined`);
|
|
309
|
-
return type.fromJSON(schema, json);
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
To be able to serialize steps to JSON, each step needs a string
|
|
313
|
-
ID to attach to its JSON representation. Use this method to
|
|
314
|
-
register an ID for your step classes. Try to pick something
|
|
315
|
-
that's unlikely to clash with steps from other modules.
|
|
316
|
-
*/
|
|
317
|
-
static jsonID(id, stepClass) {
|
|
318
|
-
if (id in stepsByID)
|
|
319
|
-
throw new RangeError("Duplicate use of step JSON ID " + id);
|
|
320
|
-
stepsByID[id] = stepClass;
|
|
321
|
-
stepClass.prototype.jsonID = id;
|
|
322
|
-
return stepClass;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
class StepResult {
|
|
326
|
-
/**
|
|
327
|
-
@internal
|
|
328
|
-
*/
|
|
329
|
-
constructor(doc, failed) {
|
|
330
|
-
this.doc = doc;
|
|
331
|
-
this.failed = failed;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
Create a successful step result.
|
|
335
|
-
*/
|
|
336
|
-
static ok(doc) {
|
|
337
|
-
return new StepResult(doc, null);
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
Create a failed step result.
|
|
341
|
-
*/
|
|
342
|
-
static fail(message) {
|
|
343
|
-
return new StepResult(null, message);
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
|
|
347
|
-
arguments. Create a successful result if it succeeds, and a
|
|
348
|
-
failed one if it throws a `ReplaceError`.
|
|
349
|
-
*/
|
|
350
|
-
static fromReplace(doc, from, to, slice) {
|
|
351
|
-
try {
|
|
352
|
-
return StepResult.ok(doc.replace(from, to, slice));
|
|
353
|
-
} catch (e) {
|
|
354
|
-
if (e instanceof ReplaceError)
|
|
355
|
-
return StepResult.fail(e.message);
|
|
356
|
-
throw e;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
function mapFragment(fragment, f, parent) {
|
|
361
|
-
let mapped = [];
|
|
362
|
-
for (let i = 0; i < fragment.childCount; i++) {
|
|
363
|
-
let child = fragment.child(i);
|
|
364
|
-
if (child.content.size)
|
|
365
|
-
child = child.copy(mapFragment(child.content, f, child));
|
|
366
|
-
if (child.isInline)
|
|
367
|
-
child = f(child, parent, i);
|
|
368
|
-
mapped.push(child);
|
|
369
|
-
}
|
|
370
|
-
return Fragment.fromArray(mapped);
|
|
371
|
-
}
|
|
372
|
-
class AddMarkStep extends Step {
|
|
373
|
-
/**
|
|
374
|
-
Create a mark step.
|
|
375
|
-
*/
|
|
376
|
-
constructor(from, to, mark) {
|
|
377
|
-
super();
|
|
378
|
-
this.from = from;
|
|
379
|
-
this.to = to;
|
|
380
|
-
this.mark = mark;
|
|
381
|
-
}
|
|
382
|
-
apply(doc) {
|
|
383
|
-
let oldSlice = doc.slice(this.from, this.to), $from = doc.resolve(this.from);
|
|
384
|
-
let parent = $from.node($from.sharedDepth(this.to));
|
|
385
|
-
let slice = new Slice(mapFragment(oldSlice.content, (node, parent2) => {
|
|
386
|
-
if (!node.isAtom || !parent2.type.allowsMarkType(this.mark.type))
|
|
387
|
-
return node;
|
|
388
|
-
return node.mark(this.mark.addToSet(node.marks));
|
|
389
|
-
}, parent), oldSlice.openStart, oldSlice.openEnd);
|
|
390
|
-
return StepResult.fromReplace(doc, this.from, this.to, slice);
|
|
391
|
-
}
|
|
392
|
-
invert() {
|
|
393
|
-
return new RemoveMarkStep(this.from, this.to, this.mark);
|
|
394
|
-
}
|
|
395
|
-
map(mapping) {
|
|
396
|
-
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
397
|
-
if (from.deleted && to.deleted || from.pos >= to.pos)
|
|
398
|
-
return null;
|
|
399
|
-
return new AddMarkStep(from.pos, to.pos, this.mark);
|
|
400
|
-
}
|
|
401
|
-
merge(other) {
|
|
402
|
-
if (other instanceof AddMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from)
|
|
403
|
-
return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
toJSON() {
|
|
407
|
-
return {
|
|
408
|
-
stepType: "addMark",
|
|
409
|
-
mark: this.mark.toJSON(),
|
|
410
|
-
from: this.from,
|
|
411
|
-
to: this.to
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
@internal
|
|
416
|
-
*/
|
|
417
|
-
static fromJSON(schema, json) {
|
|
418
|
-
if (typeof json.from != "number" || typeof json.to != "number")
|
|
419
|
-
throw new RangeError("Invalid input for AddMarkStep.fromJSON");
|
|
420
|
-
return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
Step.jsonID("addMark", AddMarkStep);
|
|
424
|
-
class RemoveMarkStep extends Step {
|
|
425
|
-
/**
|
|
426
|
-
Create a mark-removing step.
|
|
427
|
-
*/
|
|
428
|
-
constructor(from, to, mark) {
|
|
429
|
-
super();
|
|
430
|
-
this.from = from;
|
|
431
|
-
this.to = to;
|
|
432
|
-
this.mark = mark;
|
|
433
|
-
}
|
|
434
|
-
apply(doc) {
|
|
435
|
-
let oldSlice = doc.slice(this.from, this.to);
|
|
436
|
-
let slice = new Slice(mapFragment(oldSlice.content, (node) => {
|
|
437
|
-
return node.mark(this.mark.removeFromSet(node.marks));
|
|
438
|
-
}, doc), oldSlice.openStart, oldSlice.openEnd);
|
|
439
|
-
return StepResult.fromReplace(doc, this.from, this.to, slice);
|
|
440
|
-
}
|
|
441
|
-
invert() {
|
|
442
|
-
return new AddMarkStep(this.from, this.to, this.mark);
|
|
443
|
-
}
|
|
444
|
-
map(mapping) {
|
|
445
|
-
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
446
|
-
if (from.deleted && to.deleted || from.pos >= to.pos)
|
|
447
|
-
return null;
|
|
448
|
-
return new RemoveMarkStep(from.pos, to.pos, this.mark);
|
|
449
|
-
}
|
|
450
|
-
merge(other) {
|
|
451
|
-
if (other instanceof RemoveMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from)
|
|
452
|
-
return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
455
|
-
toJSON() {
|
|
456
|
-
return {
|
|
457
|
-
stepType: "removeMark",
|
|
458
|
-
mark: this.mark.toJSON(),
|
|
459
|
-
from: this.from,
|
|
460
|
-
to: this.to
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
@internal
|
|
465
|
-
*/
|
|
466
|
-
static fromJSON(schema, json) {
|
|
467
|
-
if (typeof json.from != "number" || typeof json.to != "number")
|
|
468
|
-
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
|
|
469
|
-
return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
Step.jsonID("removeMark", RemoveMarkStep);
|
|
473
|
-
class AddNodeMarkStep extends Step {
|
|
474
|
-
/**
|
|
475
|
-
Create a node mark step.
|
|
476
|
-
*/
|
|
477
|
-
constructor(pos, mark) {
|
|
478
|
-
super();
|
|
479
|
-
this.pos = pos;
|
|
480
|
-
this.mark = mark;
|
|
481
|
-
}
|
|
482
|
-
apply(doc) {
|
|
483
|
-
let node = doc.nodeAt(this.pos);
|
|
484
|
-
if (!node)
|
|
485
|
-
return StepResult.fail("No node at mark step's position");
|
|
486
|
-
let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
|
|
487
|
-
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
488
|
-
}
|
|
489
|
-
invert(doc) {
|
|
490
|
-
let node = doc.nodeAt(this.pos);
|
|
491
|
-
if (node) {
|
|
492
|
-
let newSet = this.mark.addToSet(node.marks);
|
|
493
|
-
if (newSet.length == node.marks.length) {
|
|
494
|
-
for (let i = 0; i < node.marks.length; i++)
|
|
495
|
-
if (!node.marks[i].isInSet(newSet))
|
|
496
|
-
return new AddNodeMarkStep(this.pos, node.marks[i]);
|
|
497
|
-
return new AddNodeMarkStep(this.pos, this.mark);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
return new RemoveNodeMarkStep(this.pos, this.mark);
|
|
501
|
-
}
|
|
502
|
-
map(mapping) {
|
|
503
|
-
let pos = mapping.mapResult(this.pos, 1);
|
|
504
|
-
return pos.deletedAfter ? null : new AddNodeMarkStep(pos.pos, this.mark);
|
|
505
|
-
}
|
|
506
|
-
toJSON() {
|
|
507
|
-
return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
@internal
|
|
511
|
-
*/
|
|
512
|
-
static fromJSON(schema, json) {
|
|
513
|
-
if (typeof json.pos != "number")
|
|
514
|
-
throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
|
|
515
|
-
return new AddNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
Step.jsonID("addNodeMark", AddNodeMarkStep);
|
|
519
|
-
class RemoveNodeMarkStep extends Step {
|
|
520
|
-
/**
|
|
521
|
-
Create a mark-removing step.
|
|
522
|
-
*/
|
|
523
|
-
constructor(pos, mark) {
|
|
524
|
-
super();
|
|
525
|
-
this.pos = pos;
|
|
526
|
-
this.mark = mark;
|
|
527
|
-
}
|
|
528
|
-
apply(doc) {
|
|
529
|
-
let node = doc.nodeAt(this.pos);
|
|
530
|
-
if (!node)
|
|
531
|
-
return StepResult.fail("No node at mark step's position");
|
|
532
|
-
let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
|
|
533
|
-
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
534
|
-
}
|
|
535
|
-
invert(doc) {
|
|
536
|
-
let node = doc.nodeAt(this.pos);
|
|
537
|
-
if (!node || !this.mark.isInSet(node.marks))
|
|
538
|
-
return this;
|
|
539
|
-
return new AddNodeMarkStep(this.pos, this.mark);
|
|
540
|
-
}
|
|
541
|
-
map(mapping) {
|
|
542
|
-
let pos = mapping.mapResult(this.pos, 1);
|
|
543
|
-
return pos.deletedAfter ? null : new RemoveNodeMarkStep(pos.pos, this.mark);
|
|
544
|
-
}
|
|
545
|
-
toJSON() {
|
|
546
|
-
return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
@internal
|
|
550
|
-
*/
|
|
551
|
-
static fromJSON(schema, json) {
|
|
552
|
-
if (typeof json.pos != "number")
|
|
553
|
-
throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
|
|
554
|
-
return new RemoveNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
Step.jsonID("removeNodeMark", RemoveNodeMarkStep);
|
|
558
|
-
class ReplaceStep extends Step {
|
|
559
|
-
/**
|
|
560
|
-
The given `slice` should fit the 'gap' between `from` and
|
|
561
|
-
`to`—the depths must line up, and the surrounding nodes must be
|
|
562
|
-
able to be joined with the open sides of the slice. When
|
|
563
|
-
`structure` is true, the step will fail if the content between
|
|
564
|
-
from and to is not just a sequence of closing and then opening
|
|
565
|
-
tokens (this is to guard against rebased replace steps
|
|
566
|
-
overwriting something they weren't supposed to).
|
|
567
|
-
*/
|
|
568
|
-
constructor(from, to, slice, structure = false) {
|
|
569
|
-
super();
|
|
570
|
-
this.from = from;
|
|
571
|
-
this.to = to;
|
|
572
|
-
this.slice = slice;
|
|
573
|
-
this.structure = structure;
|
|
574
|
-
}
|
|
575
|
-
apply(doc) {
|
|
576
|
-
if (this.structure && contentBetween(doc, this.from, this.to))
|
|
577
|
-
return StepResult.fail("Structure replace would overwrite content");
|
|
578
|
-
return StepResult.fromReplace(doc, this.from, this.to, this.slice);
|
|
579
|
-
}
|
|
580
|
-
getMap() {
|
|
581
|
-
return new StepMap([this.from, this.to - this.from, this.slice.size]);
|
|
582
|
-
}
|
|
583
|
-
invert(doc) {
|
|
584
|
-
return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
|
|
585
|
-
}
|
|
586
|
-
map(mapping) {
|
|
587
|
-
let to = mapping.mapResult(this.to, -1);
|
|
588
|
-
let from = this.from == this.to && ReplaceStep.MAP_BIAS < 0 ? to : mapping.mapResult(this.from, 1);
|
|
589
|
-
if (from.deletedAcross && to.deletedAcross)
|
|
590
|
-
return null;
|
|
591
|
-
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
|
|
592
|
-
}
|
|
593
|
-
merge(other) {
|
|
594
|
-
if (!(other instanceof ReplaceStep) || other.structure || this.structure)
|
|
595
|
-
return null;
|
|
596
|
-
if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {
|
|
597
|
-
let slice = this.slice.size + other.slice.size == 0 ? Slice.empty : new Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);
|
|
598
|
-
return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);
|
|
599
|
-
} else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {
|
|
600
|
-
let slice = this.slice.size + other.slice.size == 0 ? Slice.empty : new Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);
|
|
601
|
-
return new ReplaceStep(other.from, this.to, slice, this.structure);
|
|
602
|
-
} else {
|
|
603
|
-
return null;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
toJSON() {
|
|
607
|
-
let json = { stepType: "replace", from: this.from, to: this.to };
|
|
608
|
-
if (this.slice.size)
|
|
609
|
-
json.slice = this.slice.toJSON();
|
|
610
|
-
if (this.structure)
|
|
611
|
-
json.structure = true;
|
|
612
|
-
return json;
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
@internal
|
|
616
|
-
*/
|
|
617
|
-
static fromJSON(schema, json) {
|
|
618
|
-
if (typeof json.from != "number" || typeof json.to != "number")
|
|
619
|
-
throw new RangeError("Invalid input for ReplaceStep.fromJSON");
|
|
620
|
-
return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
ReplaceStep.MAP_BIAS = 1;
|
|
624
|
-
Step.jsonID("replace", ReplaceStep);
|
|
625
|
-
class ReplaceAroundStep extends Step {
|
|
626
|
-
/**
|
|
627
|
-
Create a replace-around step with the given range and gap.
|
|
628
|
-
`insert` should be the point in the slice into which the content
|
|
629
|
-
of the gap should be moved. `structure` has the same meaning as
|
|
630
|
-
it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
|
|
631
|
-
*/
|
|
632
|
-
constructor(from, to, gapFrom, gapTo, slice, insert, structure = false) {
|
|
633
|
-
super();
|
|
634
|
-
this.from = from;
|
|
635
|
-
this.to = to;
|
|
636
|
-
this.gapFrom = gapFrom;
|
|
637
|
-
this.gapTo = gapTo;
|
|
638
|
-
this.slice = slice;
|
|
639
|
-
this.insert = insert;
|
|
640
|
-
this.structure = structure;
|
|
641
|
-
}
|
|
642
|
-
apply(doc) {
|
|
643
|
-
if (this.structure && (contentBetween(doc, this.from, this.gapFrom) || contentBetween(doc, this.gapTo, this.to)))
|
|
644
|
-
return StepResult.fail("Structure gap-replace would overwrite content");
|
|
645
|
-
let gap = doc.slice(this.gapFrom, this.gapTo);
|
|
646
|
-
if (gap.openStart || gap.openEnd)
|
|
647
|
-
return StepResult.fail("Gap is not a flat range");
|
|
648
|
-
let inserted = this.slice.insertAt(this.insert, gap.content);
|
|
649
|
-
if (!inserted)
|
|
650
|
-
return StepResult.fail("Content does not fit in gap");
|
|
651
|
-
return StepResult.fromReplace(doc, this.from, this.to, inserted);
|
|
652
|
-
}
|
|
653
|
-
getMap() {
|
|
654
|
-
return new StepMap([
|
|
655
|
-
this.from,
|
|
656
|
-
this.gapFrom - this.from,
|
|
657
|
-
this.insert,
|
|
658
|
-
this.gapTo,
|
|
659
|
-
this.to - this.gapTo,
|
|
660
|
-
this.slice.size - this.insert
|
|
661
|
-
]);
|
|
662
|
-
}
|
|
663
|
-
invert(doc) {
|
|
664
|
-
let gap = this.gapTo - this.gapFrom;
|
|
665
|
-
return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
666
|
-
}
|
|
667
|
-
map(mapping) {
|
|
668
|
-
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
669
|
-
let gapFrom = this.from == this.gapFrom ? from.pos : mapping.map(this.gapFrom, -1);
|
|
670
|
-
let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
|
|
671
|
-
if (from.deletedAcross && to.deletedAcross || gapFrom < from.pos || gapTo > to.pos)
|
|
672
|
-
return null;
|
|
673
|
-
return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
674
|
-
}
|
|
675
|
-
toJSON() {
|
|
676
|
-
let json = {
|
|
677
|
-
stepType: "replaceAround",
|
|
678
|
-
from: this.from,
|
|
679
|
-
to: this.to,
|
|
680
|
-
gapFrom: this.gapFrom,
|
|
681
|
-
gapTo: this.gapTo,
|
|
682
|
-
insert: this.insert
|
|
683
|
-
};
|
|
684
|
-
if (this.slice.size)
|
|
685
|
-
json.slice = this.slice.toJSON();
|
|
686
|
-
if (this.structure)
|
|
687
|
-
json.structure = true;
|
|
688
|
-
return json;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
@internal
|
|
692
|
-
*/
|
|
693
|
-
static fromJSON(schema, json) {
|
|
694
|
-
if (typeof json.from != "number" || typeof json.to != "number" || typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
|
|
695
|
-
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
696
|
-
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
Step.jsonID("replaceAround", ReplaceAroundStep);
|
|
700
|
-
function contentBetween(doc, from, to) {
|
|
701
|
-
let $from = doc.resolve(from), dist = to - from, depth = $from.depth;
|
|
702
|
-
while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
|
|
703
|
-
depth--;
|
|
704
|
-
dist--;
|
|
705
|
-
}
|
|
706
|
-
if (dist > 0) {
|
|
707
|
-
let next = $from.node(depth).maybeChild($from.indexAfter(depth));
|
|
708
|
-
while (dist > 0) {
|
|
709
|
-
if (!next || next.isLeaf)
|
|
710
|
-
return true;
|
|
711
|
-
next = next.firstChild;
|
|
712
|
-
dist--;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
return false;
|
|
716
|
-
}
|
|
717
|
-
function addMark(tr, from, to, mark) {
|
|
718
|
-
let removed = [], added = [];
|
|
719
|
-
let removing, adding;
|
|
720
|
-
tr.doc.nodesBetween(from, to, (node, pos, parent) => {
|
|
721
|
-
if (!node.isInline)
|
|
722
|
-
return;
|
|
723
|
-
let marks = node.marks;
|
|
724
|
-
if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) {
|
|
725
|
-
let start = Math.max(pos, from), end = Math.min(pos + node.nodeSize, to);
|
|
726
|
-
let newSet = mark.addToSet(marks);
|
|
727
|
-
for (let i = 0; i < marks.length; i++) {
|
|
728
|
-
if (!marks[i].isInSet(newSet)) {
|
|
729
|
-
if (removing && removing.to == start && removing.mark.eq(marks[i]))
|
|
730
|
-
removing.to = end;
|
|
731
|
-
else
|
|
732
|
-
removed.push(removing = new RemoveMarkStep(start, end, marks[i]));
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
if (adding && adding.to == start)
|
|
736
|
-
adding.to = end;
|
|
737
|
-
else
|
|
738
|
-
added.push(adding = new AddMarkStep(start, end, mark));
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
removed.forEach((s) => tr.step(s));
|
|
742
|
-
added.forEach((s) => tr.step(s));
|
|
743
|
-
}
|
|
744
|
-
function removeMark(tr, from, to, mark) {
|
|
745
|
-
let matched = [], step = 0;
|
|
746
|
-
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
747
|
-
if (!node.isInline)
|
|
748
|
-
return;
|
|
749
|
-
step++;
|
|
750
|
-
let toRemove = null;
|
|
751
|
-
if (mark instanceof MarkType) {
|
|
752
|
-
let set = node.marks, found;
|
|
753
|
-
while (found = mark.isInSet(set)) {
|
|
754
|
-
(toRemove || (toRemove = [])).push(found);
|
|
755
|
-
set = found.removeFromSet(set);
|
|
756
|
-
}
|
|
757
|
-
} else if (mark) {
|
|
758
|
-
if (mark.isInSet(node.marks))
|
|
759
|
-
toRemove = [mark];
|
|
760
|
-
} else {
|
|
761
|
-
toRemove = node.marks;
|
|
762
|
-
}
|
|
763
|
-
if (toRemove && toRemove.length) {
|
|
764
|
-
let end = Math.min(pos + node.nodeSize, to);
|
|
765
|
-
for (let i = 0; i < toRemove.length; i++) {
|
|
766
|
-
let style = toRemove[i], found;
|
|
767
|
-
for (let j = 0; j < matched.length; j++) {
|
|
768
|
-
let m = matched[j];
|
|
769
|
-
if (m.step == step - 1 && style.eq(matched[j].style))
|
|
770
|
-
found = m;
|
|
771
|
-
}
|
|
772
|
-
if (found) {
|
|
773
|
-
found.to = end;
|
|
774
|
-
found.step = step;
|
|
775
|
-
} else {
|
|
776
|
-
matched.push({ style, from: Math.max(pos, from), to: end, step });
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
matched.forEach((m) => tr.step(new RemoveMarkStep(m.from, m.to, m.style)));
|
|
782
|
-
}
|
|
783
|
-
function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch, clearNewlines = true) {
|
|
784
|
-
let node = tr.doc.nodeAt(pos);
|
|
785
|
-
let replSteps = [], cur = pos + 1;
|
|
786
|
-
for (let i = 0; i < node.childCount; i++) {
|
|
787
|
-
let child = node.child(i), end = cur + child.nodeSize;
|
|
788
|
-
let allowed = match.matchType(child.type);
|
|
789
|
-
if (!allowed) {
|
|
790
|
-
replSteps.push(new ReplaceStep(cur, end, Slice.empty));
|
|
791
|
-
} else {
|
|
792
|
-
match = allowed;
|
|
793
|
-
for (let j = 0; j < child.marks.length; j++)
|
|
794
|
-
if (!parentType.allowsMarkType(child.marks[j].type))
|
|
795
|
-
tr.step(new RemoveMarkStep(cur, end, child.marks[j]));
|
|
796
|
-
if (clearNewlines && child.isText && parentType.whitespace != "pre") {
|
|
797
|
-
let m, newline = /\r?\n|\r/g, slice;
|
|
798
|
-
while (m = newline.exec(child.text)) {
|
|
799
|
-
if (!slice)
|
|
800
|
-
slice = new Slice(Fragment.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0);
|
|
801
|
-
replSteps.push(new ReplaceStep(cur + m.index, cur + m.index + m[0].length, slice));
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
cur = end;
|
|
806
|
-
}
|
|
807
|
-
if (!match.validEnd) {
|
|
808
|
-
let fill = match.fillBefore(Fragment.empty, true);
|
|
809
|
-
tr.replace(cur, cur, new Slice(fill, 0, 0));
|
|
810
|
-
}
|
|
811
|
-
for (let i = replSteps.length - 1; i >= 0; i--)
|
|
812
|
-
tr.step(replSteps[i]);
|
|
813
|
-
}
|
|
814
|
-
function canCut(node, start, end) {
|
|
815
|
-
return (start == 0 || node.canReplace(start, node.childCount)) && (end == node.childCount || node.canReplace(0, end));
|
|
816
|
-
}
|
|
817
|
-
function liftTarget(range) {
|
|
818
|
-
let parent = range.parent;
|
|
819
|
-
let content = parent.content.cutByIndex(range.startIndex, range.endIndex);
|
|
820
|
-
for (let depth = range.depth, contentBefore = 0, contentAfter = 0; ; --depth) {
|
|
821
|
-
let node = range.$from.node(depth);
|
|
822
|
-
let index = range.$from.index(depth) + contentBefore, endIndex = range.$to.indexAfter(depth) - contentAfter;
|
|
823
|
-
if (depth < range.depth && node.canReplace(index, endIndex, content))
|
|
824
|
-
return depth;
|
|
825
|
-
if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex))
|
|
826
|
-
break;
|
|
827
|
-
if (index)
|
|
828
|
-
contentBefore = 1;
|
|
829
|
-
if (endIndex < node.childCount)
|
|
830
|
-
contentAfter = 1;
|
|
831
|
-
}
|
|
832
|
-
return null;
|
|
833
|
-
}
|
|
834
|
-
function lift(tr, range, target) {
|
|
835
|
-
let { $from, $to, depth } = range;
|
|
836
|
-
let gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);
|
|
837
|
-
let start = gapStart, end = gapEnd;
|
|
838
|
-
let before = Fragment.empty, openStart = 0;
|
|
839
|
-
for (let d = depth, splitting = false; d > target; d--)
|
|
840
|
-
if (splitting || $from.index(d) > 0) {
|
|
841
|
-
splitting = true;
|
|
842
|
-
before = Fragment.from($from.node(d).copy(before));
|
|
843
|
-
openStart++;
|
|
844
|
-
} else {
|
|
845
|
-
start--;
|
|
846
|
-
}
|
|
847
|
-
let after = Fragment.empty, openEnd = 0;
|
|
848
|
-
for (let d = depth, splitting = false; d > target; d--)
|
|
849
|
-
if (splitting || $to.after(d + 1) < $to.end(d)) {
|
|
850
|
-
splitting = true;
|
|
851
|
-
after = Fragment.from($to.node(d).copy(after));
|
|
852
|
-
openEnd++;
|
|
853
|
-
} else {
|
|
854
|
-
end++;
|
|
855
|
-
}
|
|
856
|
-
tr.step(new ReplaceAroundStep(start, end, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
857
|
-
}
|
|
858
|
-
function findWrapping(range, nodeType, attrs = null, innerRange = range) {
|
|
859
|
-
let around = findWrappingOutside(range, nodeType);
|
|
860
|
-
let inner = around && findWrappingInside(innerRange, nodeType);
|
|
861
|
-
if (!inner)
|
|
862
|
-
return null;
|
|
863
|
-
return around.map(withAttrs).concat({ type: nodeType, attrs }).concat(inner.map(withAttrs));
|
|
864
|
-
}
|
|
865
|
-
function withAttrs(type) {
|
|
866
|
-
return { type, attrs: null };
|
|
867
|
-
}
|
|
868
|
-
function findWrappingOutside(range, type) {
|
|
869
|
-
let { parent, startIndex, endIndex } = range;
|
|
870
|
-
let around = parent.contentMatchAt(startIndex).findWrapping(type);
|
|
871
|
-
if (!around)
|
|
872
|
-
return null;
|
|
873
|
-
let outer = around.length ? around[0] : type;
|
|
874
|
-
return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;
|
|
875
|
-
}
|
|
876
|
-
function findWrappingInside(range, type) {
|
|
877
|
-
let { parent, startIndex, endIndex } = range;
|
|
878
|
-
let inner = parent.child(startIndex);
|
|
879
|
-
let inside = type.contentMatch.findWrapping(inner.type);
|
|
880
|
-
if (!inside)
|
|
881
|
-
return null;
|
|
882
|
-
let lastType = inside.length ? inside[inside.length - 1] : type;
|
|
883
|
-
let innerMatch = lastType.contentMatch;
|
|
884
|
-
for (let i = startIndex; innerMatch && i < endIndex; i++)
|
|
885
|
-
innerMatch = innerMatch.matchType(parent.child(i).type);
|
|
886
|
-
if (!innerMatch || !innerMatch.validEnd)
|
|
887
|
-
return null;
|
|
888
|
-
return inside;
|
|
889
|
-
}
|
|
890
|
-
function wrap(tr, range, wrappers) {
|
|
891
|
-
let content = Fragment.empty;
|
|
892
|
-
for (let i = wrappers.length - 1; i >= 0; i--) {
|
|
893
|
-
if (content.size) {
|
|
894
|
-
let match = wrappers[i].type.contentMatch.matchFragment(content);
|
|
895
|
-
if (!match || !match.validEnd)
|
|
896
|
-
throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
|
|
897
|
-
}
|
|
898
|
-
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
899
|
-
}
|
|
900
|
-
let start = range.start, end = range.end;
|
|
901
|
-
tr.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));
|
|
902
|
-
}
|
|
903
|
-
function setBlockType(tr, from, to, type, attrs) {
|
|
904
|
-
if (!type.isTextblock)
|
|
905
|
-
throw new RangeError("Type given to setBlockType should be a textblock");
|
|
906
|
-
let mapFrom = tr.steps.length;
|
|
907
|
-
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
908
|
-
let attrsHere = typeof attrs == "function" ? attrs(node) : attrs;
|
|
909
|
-
if (node.isTextblock && !node.hasMarkup(type, attrsHere) && canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) {
|
|
910
|
-
let convertNewlines = null;
|
|
911
|
-
if (type.schema.linebreakReplacement) {
|
|
912
|
-
let pre = type.whitespace == "pre", supportLinebreak = !!type.contentMatch.matchType(type.schema.linebreakReplacement);
|
|
913
|
-
if (pre && !supportLinebreak)
|
|
914
|
-
convertNewlines = false;
|
|
915
|
-
else if (!pre && supportLinebreak)
|
|
916
|
-
convertNewlines = true;
|
|
917
|
-
}
|
|
918
|
-
if (convertNewlines === false)
|
|
919
|
-
replaceLinebreaks(tr, node, pos, mapFrom);
|
|
920
|
-
clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type, void 0, convertNewlines === null);
|
|
921
|
-
let mapping = tr.mapping.slice(mapFrom);
|
|
922
|
-
let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
|
|
923
|
-
tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
|
|
924
|
-
if (convertNewlines === true)
|
|
925
|
-
replaceNewlines(tr, node, pos, mapFrom);
|
|
926
|
-
return false;
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
}
|
|
930
|
-
function replaceNewlines(tr, node, pos, mapFrom) {
|
|
931
|
-
node.forEach((child, offset) => {
|
|
932
|
-
if (child.isText) {
|
|
933
|
-
let m, newline = /\r?\n|\r/g;
|
|
934
|
-
while (m = newline.exec(child.text)) {
|
|
935
|
-
let start = tr.mapping.slice(mapFrom).map(pos + 1 + offset + m.index);
|
|
936
|
-
tr.replaceWith(start, start + 1, node.type.schema.linebreakReplacement.create());
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
function replaceLinebreaks(tr, node, pos, mapFrom) {
|
|
942
|
-
node.forEach((child, offset) => {
|
|
943
|
-
if (child.type == child.type.schema.linebreakReplacement) {
|
|
944
|
-
let start = tr.mapping.slice(mapFrom).map(pos + 1 + offset);
|
|
945
|
-
tr.replaceWith(start, start + 1, node.type.schema.text("\n"));
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
function canChangeType(doc, pos, type) {
|
|
950
|
-
let $pos = doc.resolve(pos), index = $pos.index();
|
|
951
|
-
return $pos.parent.canReplaceWith(index, index + 1, type);
|
|
952
|
-
}
|
|
953
|
-
function setNodeMarkup(tr, pos, type, attrs, marks) {
|
|
954
|
-
let node = tr.doc.nodeAt(pos);
|
|
955
|
-
if (!node)
|
|
956
|
-
throw new RangeError("No node at given position");
|
|
957
|
-
if (!type)
|
|
958
|
-
type = node.type;
|
|
959
|
-
let newNode = type.create(attrs, null, marks || node.marks);
|
|
960
|
-
if (node.isLeaf)
|
|
961
|
-
return tr.replaceWith(pos, pos + node.nodeSize, newNode);
|
|
962
|
-
if (!type.validContent(node.content))
|
|
963
|
-
throw new RangeError("Invalid content for node type " + type.name);
|
|
964
|
-
tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
965
|
-
}
|
|
966
|
-
function canSplit(doc, pos, depth = 1, typesAfter) {
|
|
967
|
-
let $pos = doc.resolve(pos), base = $pos.depth - depth;
|
|
968
|
-
let innerType = typesAfter && typesAfter[typesAfter.length - 1] || $pos.parent;
|
|
969
|
-
if (base < 0 || $pos.parent.type.spec.isolating || !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) || !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount)))
|
|
970
|
-
return false;
|
|
971
|
-
for (let d = $pos.depth - 1, i = depth - 2; d > base; d--, i--) {
|
|
972
|
-
let node = $pos.node(d), index2 = $pos.index(d);
|
|
973
|
-
if (node.type.spec.isolating)
|
|
974
|
-
return false;
|
|
975
|
-
let rest = node.content.cutByIndex(index2, node.childCount);
|
|
976
|
-
let overrideChild = typesAfter && typesAfter[i + 1];
|
|
977
|
-
if (overrideChild)
|
|
978
|
-
rest = rest.replaceChild(0, overrideChild.type.create(overrideChild.attrs));
|
|
979
|
-
let after = typesAfter && typesAfter[i] || node;
|
|
980
|
-
if (!node.canReplace(index2 + 1, node.childCount) || !after.type.validContent(rest))
|
|
981
|
-
return false;
|
|
982
|
-
}
|
|
983
|
-
let index = $pos.indexAfter(base);
|
|
984
|
-
let baseType = typesAfter && typesAfter[0];
|
|
985
|
-
return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type);
|
|
986
|
-
}
|
|
987
|
-
function split(tr, pos, depth = 1, typesAfter) {
|
|
988
|
-
let $pos = tr.doc.resolve(pos), before = Fragment.empty, after = Fragment.empty;
|
|
989
|
-
for (let d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {
|
|
990
|
-
before = Fragment.from($pos.node(d).copy(before));
|
|
991
|
-
let typeAfter = typesAfter && typesAfter[i];
|
|
992
|
-
after = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
|
|
993
|
-
}
|
|
994
|
-
tr.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true));
|
|
995
|
-
}
|
|
996
|
-
function canJoin(doc, pos) {
|
|
997
|
-
let $pos = doc.resolve(pos), index = $pos.index();
|
|
998
|
-
return joinable($pos.nodeBefore, $pos.nodeAfter) && $pos.parent.canReplace(index, index + 1);
|
|
999
|
-
}
|
|
1000
|
-
function canAppendWithSubstitutedLinebreaks(a, b) {
|
|
1001
|
-
if (!b.content.size)
|
|
1002
|
-
a.type.compatibleContent(b.type);
|
|
1003
|
-
let match = a.contentMatchAt(a.childCount);
|
|
1004
|
-
let { linebreakReplacement } = a.type.schema;
|
|
1005
|
-
for (let i = 0; i < b.childCount; i++) {
|
|
1006
|
-
let child = b.child(i);
|
|
1007
|
-
let type = child.type == linebreakReplacement ? a.type.schema.nodes.text : child.type;
|
|
1008
|
-
match = match.matchType(type);
|
|
1009
|
-
if (!match)
|
|
1010
|
-
return false;
|
|
1011
|
-
if (!a.type.allowsMarks(child.marks))
|
|
1012
|
-
return false;
|
|
1013
|
-
}
|
|
1014
|
-
return match.validEnd;
|
|
1015
|
-
}
|
|
1016
|
-
function joinable(a, b) {
|
|
1017
|
-
return !!(a && b && !a.isLeaf && canAppendWithSubstitutedLinebreaks(a, b));
|
|
1018
|
-
}
|
|
1019
|
-
function joinPoint(doc, pos, dir = -1) {
|
|
1020
|
-
let $pos = doc.resolve(pos);
|
|
1021
|
-
for (let d = $pos.depth; ; d--) {
|
|
1022
|
-
let before, after, index = $pos.index(d);
|
|
1023
|
-
if (d == $pos.depth) {
|
|
1024
|
-
before = $pos.nodeBefore;
|
|
1025
|
-
after = $pos.nodeAfter;
|
|
1026
|
-
} else if (dir > 0) {
|
|
1027
|
-
before = $pos.node(d + 1);
|
|
1028
|
-
index++;
|
|
1029
|
-
after = $pos.node(d).maybeChild(index);
|
|
1030
|
-
} else {
|
|
1031
|
-
before = $pos.node(d).maybeChild(index - 1);
|
|
1032
|
-
after = $pos.node(d + 1);
|
|
1033
|
-
}
|
|
1034
|
-
if (before && !before.isTextblock && joinable(before, after) && $pos.node(d).canReplace(index, index + 1))
|
|
1035
|
-
return pos;
|
|
1036
|
-
if (d == 0)
|
|
1037
|
-
break;
|
|
1038
|
-
pos = dir < 0 ? $pos.before(d) : $pos.after(d);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
function join(tr, pos, depth) {
|
|
1042
|
-
let convertNewlines = null;
|
|
1043
|
-
let { linebreakReplacement } = tr.doc.type.schema;
|
|
1044
|
-
let $before = tr.doc.resolve(pos - depth), beforeType = $before.node().type;
|
|
1045
|
-
if (linebreakReplacement && beforeType.inlineContent) {
|
|
1046
|
-
let pre = beforeType.whitespace == "pre";
|
|
1047
|
-
let supportLinebreak = !!beforeType.contentMatch.matchType(linebreakReplacement);
|
|
1048
|
-
if (pre && !supportLinebreak)
|
|
1049
|
-
convertNewlines = false;
|
|
1050
|
-
else if (!pre && supportLinebreak)
|
|
1051
|
-
convertNewlines = true;
|
|
1052
|
-
}
|
|
1053
|
-
let mapFrom = tr.steps.length;
|
|
1054
|
-
if (convertNewlines === false) {
|
|
1055
|
-
let $after = tr.doc.resolve(pos + depth);
|
|
1056
|
-
replaceLinebreaks(tr, $after.node(), $after.before(), mapFrom);
|
|
1057
|
-
}
|
|
1058
|
-
if (beforeType.inlineContent)
|
|
1059
|
-
clearIncompatible(tr, pos + depth - 1, beforeType, $before.node().contentMatchAt($before.index()), convertNewlines == null);
|
|
1060
|
-
let mapping = tr.mapping.slice(mapFrom), start = mapping.map(pos - depth);
|
|
1061
|
-
tr.step(new ReplaceStep(start, mapping.map(pos + depth, -1), Slice.empty, true));
|
|
1062
|
-
if (convertNewlines === true) {
|
|
1063
|
-
let $full = tr.doc.resolve(start);
|
|
1064
|
-
replaceNewlines(tr, $full.node(), $full.before(), tr.steps.length);
|
|
1065
|
-
}
|
|
1066
|
-
return tr;
|
|
1067
|
-
}
|
|
1068
|
-
function insertPoint(doc, pos, nodeType) {
|
|
1069
|
-
let $pos = doc.resolve(pos);
|
|
1070
|
-
if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType))
|
|
1071
|
-
return pos;
|
|
1072
|
-
if ($pos.parentOffset == 0)
|
|
1073
|
-
for (let d = $pos.depth - 1; d >= 0; d--) {
|
|
1074
|
-
let index = $pos.index(d);
|
|
1075
|
-
if ($pos.node(d).canReplaceWith(index, index, nodeType))
|
|
1076
|
-
return $pos.before(d + 1);
|
|
1077
|
-
if (index > 0)
|
|
1078
|
-
return null;
|
|
1079
|
-
}
|
|
1080
|
-
if ($pos.parentOffset == $pos.parent.content.size)
|
|
1081
|
-
for (let d = $pos.depth - 1; d >= 0; d--) {
|
|
1082
|
-
let index = $pos.indexAfter(d);
|
|
1083
|
-
if ($pos.node(d).canReplaceWith(index, index, nodeType))
|
|
1084
|
-
return $pos.after(d + 1);
|
|
1085
|
-
if (index < $pos.node(d).childCount)
|
|
1086
|
-
return null;
|
|
1087
|
-
}
|
|
1088
|
-
return null;
|
|
1089
|
-
}
|
|
1090
|
-
function dropPoint(doc, pos, slice) {
|
|
1091
|
-
let $pos = doc.resolve(pos);
|
|
1092
|
-
if (!slice.content.size)
|
|
1093
|
-
return pos;
|
|
1094
|
-
let content = slice.content;
|
|
1095
|
-
for (let i = 0; i < slice.openStart; i++)
|
|
1096
|
-
content = content.firstChild.content;
|
|
1097
|
-
for (let pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {
|
|
1098
|
-
for (let d = $pos.depth; d >= 0; d--) {
|
|
1099
|
-
let bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;
|
|
1100
|
-
let insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);
|
|
1101
|
-
let parent = $pos.node(d), fits = false;
|
|
1102
|
-
if (pass == 1) {
|
|
1103
|
-
fits = parent.canReplace(insertPos, insertPos, content);
|
|
1104
|
-
} else {
|
|
1105
|
-
let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);
|
|
1106
|
-
fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);
|
|
1107
|
-
}
|
|
1108
|
-
if (fits)
|
|
1109
|
-
return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
return null;
|
|
1113
|
-
}
|
|
1114
|
-
function replaceStep(doc, from, to = from, slice = Slice.empty) {
|
|
1115
|
-
if (from == to && !slice.size)
|
|
1116
|
-
return null;
|
|
1117
|
-
let $from = doc.resolve(from), $to = doc.resolve(to);
|
|
1118
|
-
if (fitsTrivially($from, $to, slice))
|
|
1119
|
-
return new ReplaceStep(from, to, slice);
|
|
1120
|
-
return new Fitter($from, $to, slice).fit();
|
|
1121
|
-
}
|
|
1122
|
-
function fitsTrivially($from, $to, slice) {
|
|
1123
|
-
return !slice.openStart && !slice.openEnd && $from.start() == $to.start() && $from.parent.canReplace($from.index(), $to.index(), slice.content);
|
|
1124
|
-
}
|
|
1125
|
-
class Fitter {
|
|
1126
|
-
constructor($from, $to, unplaced) {
|
|
1127
|
-
this.$from = $from;
|
|
1128
|
-
this.$to = $to;
|
|
1129
|
-
this.unplaced = unplaced;
|
|
1130
|
-
this.frontier = [];
|
|
1131
|
-
this.placed = Fragment.empty;
|
|
1132
|
-
for (let i = 0; i <= $from.depth; i++) {
|
|
1133
|
-
let node = $from.node(i);
|
|
1134
|
-
this.frontier.push({
|
|
1135
|
-
type: node.type,
|
|
1136
|
-
match: node.contentMatchAt($from.indexAfter(i))
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
for (let i = $from.depth; i > 0; i--)
|
|
1140
|
-
this.placed = Fragment.from($from.node(i).copy(this.placed));
|
|
1141
|
-
}
|
|
1142
|
-
get depth() {
|
|
1143
|
-
return this.frontier.length - 1;
|
|
1144
|
-
}
|
|
1145
|
-
fit() {
|
|
1146
|
-
while (this.unplaced.size) {
|
|
1147
|
-
let fit = this.findFittable();
|
|
1148
|
-
if (fit)
|
|
1149
|
-
this.placeNodes(fit);
|
|
1150
|
-
else
|
|
1151
|
-
this.openMore() || this.dropNode();
|
|
1152
|
-
}
|
|
1153
|
-
let moveInline = this.mustMoveInline(), placedSize = this.placed.size - this.depth - this.$from.depth;
|
|
1154
|
-
let $from = this.$from, $to = this.close(moveInline < 0 ? this.$to : $from.doc.resolve(moveInline));
|
|
1155
|
-
if (!$to)
|
|
1156
|
-
return null;
|
|
1157
|
-
let content = this.placed, openStart = $from.depth, openEnd = $to.depth;
|
|
1158
|
-
while (openStart && openEnd && content.childCount == 1) {
|
|
1159
|
-
content = content.firstChild.content;
|
|
1160
|
-
openStart--;
|
|
1161
|
-
openEnd--;
|
|
1162
|
-
}
|
|
1163
|
-
let slice = new Slice(content, openStart, openEnd);
|
|
1164
|
-
if (moveInline > -1)
|
|
1165
|
-
return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize);
|
|
1166
|
-
if (slice.size || $from.pos != this.$to.pos)
|
|
1167
|
-
return new ReplaceStep($from.pos, $to.pos, slice);
|
|
1168
|
-
return null;
|
|
1169
|
-
}
|
|
1170
|
-
// Find a position on the start spine of `this.unplaced` that has
|
|
1171
|
-
// content that can be moved somewhere on the frontier. Returns two
|
|
1172
|
-
// depths, one for the slice and one for the frontier.
|
|
1173
|
-
findFittable() {
|
|
1174
|
-
let startDepth = this.unplaced.openStart;
|
|
1175
|
-
for (let cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) {
|
|
1176
|
-
let node = cur.firstChild;
|
|
1177
|
-
if (cur.childCount > 1)
|
|
1178
|
-
openEnd = 0;
|
|
1179
|
-
if (node.type.spec.isolating && openEnd <= d) {
|
|
1180
|
-
startDepth = d;
|
|
1181
|
-
break;
|
|
1182
|
-
}
|
|
1183
|
-
cur = node.content;
|
|
1184
|
-
}
|
|
1185
|
-
for (let pass = 1; pass <= 2; pass++) {
|
|
1186
|
-
for (let sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
|
|
1187
|
-
let fragment, parent = null;
|
|
1188
|
-
if (sliceDepth) {
|
|
1189
|
-
parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;
|
|
1190
|
-
fragment = parent.content;
|
|
1191
|
-
} else {
|
|
1192
|
-
fragment = this.unplaced.content;
|
|
1193
|
-
}
|
|
1194
|
-
let first = fragment.firstChild;
|
|
1195
|
-
for (let frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {
|
|
1196
|
-
let { type, match } = this.frontier[frontierDepth], wrap2, inject = null;
|
|
1197
|
-
if (pass == 1 && (first ? match.matchType(first.type) || (inject = match.fillBefore(Fragment.from(first), false)) : parent && type.compatibleContent(parent.type)))
|
|
1198
|
-
return { sliceDepth, frontierDepth, parent, inject };
|
|
1199
|
-
else if (pass == 2 && first && (wrap2 = match.findWrapping(first.type)))
|
|
1200
|
-
return { sliceDepth, frontierDepth, parent, wrap: wrap2 };
|
|
1201
|
-
if (parent && match.matchType(parent.type))
|
|
1202
|
-
break;
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
openMore() {
|
|
1208
|
-
let { content, openStart, openEnd } = this.unplaced;
|
|
1209
|
-
let inner = contentAt(content, openStart);
|
|
1210
|
-
if (!inner.childCount || inner.firstChild.isLeaf)
|
|
1211
|
-
return false;
|
|
1212
|
-
this.unplaced = new Slice(content, openStart + 1, Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0));
|
|
1213
|
-
return true;
|
|
1214
|
-
}
|
|
1215
|
-
dropNode() {
|
|
1216
|
-
let { content, openStart, openEnd } = this.unplaced;
|
|
1217
|
-
let inner = contentAt(content, openStart);
|
|
1218
|
-
if (inner.childCount <= 1 && openStart > 0) {
|
|
1219
|
-
let openAtEnd = content.size - openStart <= openStart + inner.size;
|
|
1220
|
-
this.unplaced = new Slice(dropFromFragment(content, openStart - 1, 1), openStart - 1, openAtEnd ? openStart - 1 : openEnd);
|
|
1221
|
-
} else {
|
|
1222
|
-
this.unplaced = new Slice(dropFromFragment(content, openStart, 1), openStart, openEnd);
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
// Move content from the unplaced slice at `sliceDepth` to the
|
|
1226
|
-
// frontier node at `frontierDepth`. Close that frontier node when
|
|
1227
|
-
// applicable.
|
|
1228
|
-
placeNodes({ sliceDepth, frontierDepth, parent, inject, wrap: wrap2 }) {
|
|
1229
|
-
while (this.depth > frontierDepth)
|
|
1230
|
-
this.closeFrontierNode();
|
|
1231
|
-
if (wrap2)
|
|
1232
|
-
for (let i = 0; i < wrap2.length; i++)
|
|
1233
|
-
this.openFrontierNode(wrap2[i]);
|
|
1234
|
-
let slice = this.unplaced, fragment = parent ? parent.content : slice.content;
|
|
1235
|
-
let openStart = slice.openStart - sliceDepth;
|
|
1236
|
-
let taken = 0, add = [];
|
|
1237
|
-
let { match, type } = this.frontier[frontierDepth];
|
|
1238
|
-
if (inject) {
|
|
1239
|
-
for (let i = 0; i < inject.childCount; i++)
|
|
1240
|
-
add.push(inject.child(i));
|
|
1241
|
-
match = match.matchFragment(inject);
|
|
1242
|
-
}
|
|
1243
|
-
let openEndCount = fragment.size + sliceDepth - (slice.content.size - slice.openEnd);
|
|
1244
|
-
while (taken < fragment.childCount) {
|
|
1245
|
-
let next = fragment.child(taken), matches = match.matchType(next.type);
|
|
1246
|
-
if (!matches)
|
|
1247
|
-
break;
|
|
1248
|
-
taken++;
|
|
1249
|
-
if (taken > 1 || openStart == 0 || next.content.size) {
|
|
1250
|
-
match = matches;
|
|
1251
|
-
add.push(closeNodeStart(next.mark(type.allowedMarks(next.marks)), taken == 1 ? openStart : 0, taken == fragment.childCount ? openEndCount : -1));
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
let toEnd = taken == fragment.childCount;
|
|
1255
|
-
if (!toEnd)
|
|
1256
|
-
openEndCount = -1;
|
|
1257
|
-
this.placed = addToFragment(this.placed, frontierDepth, Fragment.from(add));
|
|
1258
|
-
this.frontier[frontierDepth].match = match;
|
|
1259
|
-
if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1)
|
|
1260
|
-
this.closeFrontierNode();
|
|
1261
|
-
for (let i = 0, cur = fragment; i < openEndCount; i++) {
|
|
1262
|
-
let node = cur.lastChild;
|
|
1263
|
-
this.frontier.push({ type: node.type, match: node.contentMatchAt(node.childCount) });
|
|
1264
|
-
cur = node.content;
|
|
1265
|
-
}
|
|
1266
|
-
this.unplaced = !toEnd ? new Slice(dropFromFragment(slice.content, sliceDepth, taken), slice.openStart, slice.openEnd) : sliceDepth == 0 ? Slice.empty : new Slice(dropFromFragment(slice.content, sliceDepth - 1, 1), sliceDepth - 1, openEndCount < 0 ? slice.openEnd : sliceDepth - 1);
|
|
1267
|
-
}
|
|
1268
|
-
mustMoveInline() {
|
|
1269
|
-
if (!this.$to.parent.isTextblock)
|
|
1270
|
-
return -1;
|
|
1271
|
-
let top = this.frontier[this.depth], level;
|
|
1272
|
-
if (!top.type.isTextblock || !contentAfterFits(this.$to, this.$to.depth, top.type, top.match, false) || this.$to.depth == this.depth && (level = this.findCloseLevel(this.$to)) && level.depth == this.depth)
|
|
1273
|
-
return -1;
|
|
1274
|
-
let { depth } = this.$to, after = this.$to.after(depth);
|
|
1275
|
-
while (depth > 1 && after == this.$to.end(--depth))
|
|
1276
|
-
++after;
|
|
1277
|
-
return after;
|
|
1278
|
-
}
|
|
1279
|
-
findCloseLevel($to) {
|
|
1280
|
-
scan: for (let i = Math.min(this.depth, $to.depth); i >= 0; i--) {
|
|
1281
|
-
let { match, type } = this.frontier[i];
|
|
1282
|
-
let dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));
|
|
1283
|
-
let fit = contentAfterFits($to, i, type, match, dropInner);
|
|
1284
|
-
if (!fit)
|
|
1285
|
-
continue;
|
|
1286
|
-
for (let d = i - 1; d >= 0; d--) {
|
|
1287
|
-
let { match: match2, type: type2 } = this.frontier[d];
|
|
1288
|
-
let matches = contentAfterFits($to, d, type2, match2, true);
|
|
1289
|
-
if (!matches || matches.childCount)
|
|
1290
|
-
continue scan;
|
|
1291
|
-
}
|
|
1292
|
-
return { depth: i, fit, move: dropInner ? $to.doc.resolve($to.after(i + 1)) : $to };
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
close($to) {
|
|
1296
|
-
let close = this.findCloseLevel($to);
|
|
1297
|
-
if (!close)
|
|
1298
|
-
return null;
|
|
1299
|
-
while (this.depth > close.depth)
|
|
1300
|
-
this.closeFrontierNode();
|
|
1301
|
-
if (close.fit.childCount)
|
|
1302
|
-
this.placed = addToFragment(this.placed, close.depth, close.fit);
|
|
1303
|
-
$to = close.move;
|
|
1304
|
-
for (let d = close.depth + 1; d <= $to.depth; d++) {
|
|
1305
|
-
let node = $to.node(d), add = node.type.contentMatch.fillBefore(node.content, true, $to.index(d));
|
|
1306
|
-
this.openFrontierNode(node.type, node.attrs, add);
|
|
1307
|
-
}
|
|
1308
|
-
return $to;
|
|
1309
|
-
}
|
|
1310
|
-
openFrontierNode(type, attrs = null, content) {
|
|
1311
|
-
let top = this.frontier[this.depth];
|
|
1312
|
-
top.match = top.match.matchType(type);
|
|
1313
|
-
this.placed = addToFragment(this.placed, this.depth, Fragment.from(type.create(attrs, content)));
|
|
1314
|
-
this.frontier.push({ type, match: type.contentMatch });
|
|
1315
|
-
}
|
|
1316
|
-
closeFrontierNode() {
|
|
1317
|
-
let open = this.frontier.pop();
|
|
1318
|
-
let add = open.match.fillBefore(Fragment.empty, true);
|
|
1319
|
-
if (add.childCount)
|
|
1320
|
-
this.placed = addToFragment(this.placed, this.frontier.length, add);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
function dropFromFragment(fragment, depth, count) {
|
|
1324
|
-
if (depth == 0)
|
|
1325
|
-
return fragment.cutByIndex(count, fragment.childCount);
|
|
1326
|
-
return fragment.replaceChild(0, fragment.firstChild.copy(dropFromFragment(fragment.firstChild.content, depth - 1, count)));
|
|
1327
|
-
}
|
|
1328
|
-
function addToFragment(fragment, depth, content) {
|
|
1329
|
-
if (depth == 0)
|
|
1330
|
-
return fragment.append(content);
|
|
1331
|
-
return fragment.replaceChild(fragment.childCount - 1, fragment.lastChild.copy(addToFragment(fragment.lastChild.content, depth - 1, content)));
|
|
1332
|
-
}
|
|
1333
|
-
function contentAt(fragment, depth) {
|
|
1334
|
-
for (let i = 0; i < depth; i++)
|
|
1335
|
-
fragment = fragment.firstChild.content;
|
|
1336
|
-
return fragment;
|
|
1337
|
-
}
|
|
1338
|
-
function closeNodeStart(node, openStart, openEnd) {
|
|
1339
|
-
if (openStart <= 0)
|
|
1340
|
-
return node;
|
|
1341
|
-
let frag = node.content;
|
|
1342
|
-
if (openStart > 1)
|
|
1343
|
-
frag = frag.replaceChild(0, closeNodeStart(frag.firstChild, openStart - 1, frag.childCount == 1 ? openEnd - 1 : 0));
|
|
1344
|
-
if (openStart > 0) {
|
|
1345
|
-
frag = node.type.contentMatch.fillBefore(frag).append(frag);
|
|
1346
|
-
if (openEnd <= 0)
|
|
1347
|
-
frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment.empty, true));
|
|
1348
|
-
}
|
|
1349
|
-
return node.copy(frag);
|
|
1350
|
-
}
|
|
1351
|
-
function contentAfterFits($to, depth, type, match, open) {
|
|
1352
|
-
let node = $to.node(depth), index = open ? $to.indexAfter(depth) : $to.index(depth);
|
|
1353
|
-
if (index == node.childCount && !type.compatibleContent(node.type))
|
|
1354
|
-
return null;
|
|
1355
|
-
let fit = match.fillBefore(node.content, true, index);
|
|
1356
|
-
return fit && !invalidMarks(type, node.content, index) ? fit : null;
|
|
1357
|
-
}
|
|
1358
|
-
function invalidMarks(type, fragment, start) {
|
|
1359
|
-
for (let i = start; i < fragment.childCount; i++)
|
|
1360
|
-
if (!type.allowsMarks(fragment.child(i).marks))
|
|
1361
|
-
return true;
|
|
1362
|
-
return false;
|
|
1363
|
-
}
|
|
1364
|
-
function definesContent(type) {
|
|
1365
|
-
return type.spec.defining || type.spec.definingForContent;
|
|
1366
|
-
}
|
|
1367
|
-
function replaceRange(tr, from, to, slice) {
|
|
1368
|
-
if (!slice.size)
|
|
1369
|
-
return tr.deleteRange(from, to);
|
|
1370
|
-
let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
|
|
1371
|
-
if (fitsTrivially($from, $to, slice))
|
|
1372
|
-
return tr.step(new ReplaceStep(from, to, slice));
|
|
1373
|
-
let targetDepths = coveredDepths($from, $to);
|
|
1374
|
-
if (targetDepths[targetDepths.length - 1] == 0)
|
|
1375
|
-
targetDepths.pop();
|
|
1376
|
-
let preferredTarget = -($from.depth + 1);
|
|
1377
|
-
targetDepths.unshift(preferredTarget);
|
|
1378
|
-
for (let d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {
|
|
1379
|
-
let spec = $from.node(d).type.spec;
|
|
1380
|
-
if (spec.defining || spec.definingAsContext || spec.isolating)
|
|
1381
|
-
break;
|
|
1382
|
-
if (targetDepths.indexOf(d) > -1)
|
|
1383
|
-
preferredTarget = d;
|
|
1384
|
-
else if ($from.before(d) == pos)
|
|
1385
|
-
targetDepths.splice(1, 0, -d);
|
|
1386
|
-
}
|
|
1387
|
-
let preferredTargetIndex = targetDepths.indexOf(preferredTarget);
|
|
1388
|
-
let leftNodes = [], preferredDepth = slice.openStart;
|
|
1389
|
-
for (let content = slice.content, i = 0; ; i++) {
|
|
1390
|
-
let node = content.firstChild;
|
|
1391
|
-
leftNodes.push(node);
|
|
1392
|
-
if (i == slice.openStart)
|
|
1393
|
-
break;
|
|
1394
|
-
content = node.content;
|
|
1395
|
-
}
|
|
1396
|
-
for (let d = preferredDepth - 1; d >= 0; d--) {
|
|
1397
|
-
let leftNode = leftNodes[d], def = definesContent(leftNode.type);
|
|
1398
|
-
if (def && !leftNode.sameMarkup($from.node(Math.abs(preferredTarget) - 1)))
|
|
1399
|
-
preferredDepth = d;
|
|
1400
|
-
else if (def || !leftNode.type.isTextblock)
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
for (let j = slice.openStart; j >= 0; j--) {
|
|
1404
|
-
let openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);
|
|
1405
|
-
let insert = leftNodes[openDepth];
|
|
1406
|
-
if (!insert)
|
|
1407
|
-
continue;
|
|
1408
|
-
for (let i = 0; i < targetDepths.length; i++) {
|
|
1409
|
-
let targetDepth = targetDepths[(i + preferredTargetIndex) % targetDepths.length], expand = true;
|
|
1410
|
-
if (targetDepth < 0) {
|
|
1411
|
-
expand = false;
|
|
1412
|
-
targetDepth = -targetDepth;
|
|
1413
|
-
}
|
|
1414
|
-
let parent = $from.node(targetDepth - 1), index = $from.index(targetDepth - 1);
|
|
1415
|
-
if (parent.canReplaceWith(index, index, insert.type, insert.marks))
|
|
1416
|
-
return tr.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new Slice(closeFragment(slice.content, 0, slice.openStart, openDepth), openDepth, slice.openEnd));
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
let startSteps = tr.steps.length;
|
|
1420
|
-
for (let i = targetDepths.length - 1; i >= 0; i--) {
|
|
1421
|
-
tr.replace(from, to, slice);
|
|
1422
|
-
if (tr.steps.length > startSteps)
|
|
1423
|
-
break;
|
|
1424
|
-
let depth = targetDepths[i];
|
|
1425
|
-
if (depth < 0)
|
|
1426
|
-
continue;
|
|
1427
|
-
from = $from.before(depth);
|
|
1428
|
-
to = $to.after(depth);
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
function closeFragment(fragment, depth, oldOpen, newOpen, parent) {
|
|
1432
|
-
if (depth < oldOpen) {
|
|
1433
|
-
let first = fragment.firstChild;
|
|
1434
|
-
fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));
|
|
1435
|
-
}
|
|
1436
|
-
if (depth > newOpen) {
|
|
1437
|
-
let match = parent.contentMatchAt(0);
|
|
1438
|
-
let start = match.fillBefore(fragment).append(fragment);
|
|
1439
|
-
fragment = start.append(match.matchFragment(start).fillBefore(Fragment.empty, true));
|
|
1440
|
-
}
|
|
1441
|
-
return fragment;
|
|
1442
|
-
}
|
|
1443
|
-
function replaceRangeWith(tr, from, to, node) {
|
|
1444
|
-
if (!node.isInline && from == to && tr.doc.resolve(from).parent.content.size) {
|
|
1445
|
-
let point = insertPoint(tr.doc, from, node.type);
|
|
1446
|
-
if (point != null)
|
|
1447
|
-
from = to = point;
|
|
1448
|
-
}
|
|
1449
|
-
tr.replaceRange(from, to, new Slice(Fragment.from(node), 0, 0));
|
|
1450
|
-
}
|
|
1451
|
-
function deleteRange(tr, from, to) {
|
|
1452
|
-
let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
|
|
1453
|
-
if ($from.parent.isTextblock && $to.parent.isTextblock && $from.start() != $to.start() && $from.parentOffset == 0 && $to.parentOffset == 0) {
|
|
1454
|
-
let shared = $from.sharedDepth(to), isolated = false;
|
|
1455
|
-
for (let d = $from.depth; d > shared; d--)
|
|
1456
|
-
if ($from.node(d).type.spec.isolating)
|
|
1457
|
-
isolated = true;
|
|
1458
|
-
for (let d = $to.depth; d > shared; d--)
|
|
1459
|
-
if ($to.node(d).type.spec.isolating)
|
|
1460
|
-
isolated = true;
|
|
1461
|
-
if (!isolated) {
|
|
1462
|
-
for (let d = $from.depth; d > 0 && from == $from.start(d); d--)
|
|
1463
|
-
from = $from.before(d);
|
|
1464
|
-
for (let d = $to.depth; d > 0 && to == $to.start(d); d--)
|
|
1465
|
-
to = $to.before(d);
|
|
1466
|
-
$from = tr.doc.resolve(from);
|
|
1467
|
-
$to = tr.doc.resolve(to);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
let covered = coveredDepths($from, $to);
|
|
1471
|
-
for (let i = 0; i < covered.length; i++) {
|
|
1472
|
-
let depth = covered[i], last = i == covered.length - 1;
|
|
1473
|
-
if (last && depth == 0 || $from.node(depth).type.contentMatch.validEnd)
|
|
1474
|
-
return tr.delete($from.start(depth), $to.end(depth));
|
|
1475
|
-
if (depth > 0 && (last || $from.node(depth - 1).canReplace($from.index(depth - 1), $to.indexAfter(depth - 1))))
|
|
1476
|
-
return tr.delete($from.before(depth), $to.after(depth));
|
|
1477
|
-
}
|
|
1478
|
-
for (let d = 1; d <= $from.depth && d <= $to.depth; d++) {
|
|
1479
|
-
if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d && $from.start(d - 1) == $to.start(d - 1) && $from.node(d - 1).canReplace($from.index(d - 1), $to.index(d - 1)))
|
|
1480
|
-
return tr.delete($from.before(d), to);
|
|
1481
|
-
}
|
|
1482
|
-
tr.delete(from, to);
|
|
1483
|
-
}
|
|
1484
|
-
function coveredDepths($from, $to) {
|
|
1485
|
-
let result = [], minDepth = Math.min($from.depth, $to.depth);
|
|
1486
|
-
for (let d = minDepth; d >= 0; d--) {
|
|
1487
|
-
let start = $from.start(d);
|
|
1488
|
-
if (start < $from.pos - ($from.depth - d) || $to.end(d) > $to.pos + ($to.depth - d) || $from.node(d).type.spec.isolating || $to.node(d).type.spec.isolating)
|
|
1489
|
-
break;
|
|
1490
|
-
if (start == $to.start(d) || d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent && d && $to.start(d - 1) == start - 1)
|
|
1491
|
-
result.push(d);
|
|
1492
|
-
}
|
|
1493
|
-
return result;
|
|
1494
|
-
}
|
|
1495
|
-
class AttrStep extends Step {
|
|
1496
|
-
/**
|
|
1497
|
-
Construct an attribute step.
|
|
1498
|
-
*/
|
|
1499
|
-
constructor(pos, attr, value) {
|
|
1500
|
-
super();
|
|
1501
|
-
this.pos = pos;
|
|
1502
|
-
this.attr = attr;
|
|
1503
|
-
this.value = value;
|
|
1504
|
-
}
|
|
1505
|
-
apply(doc) {
|
|
1506
|
-
let node = doc.nodeAt(this.pos);
|
|
1507
|
-
if (!node)
|
|
1508
|
-
return StepResult.fail("No node at attribute step's position");
|
|
1509
|
-
let attrs = /* @__PURE__ */ Object.create(null);
|
|
1510
|
-
for (let name in node.attrs)
|
|
1511
|
-
attrs[name] = node.attrs[name];
|
|
1512
|
-
attrs[this.attr] = this.value;
|
|
1513
|
-
let updated = node.type.create(attrs, null, node.marks);
|
|
1514
|
-
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
1515
|
-
}
|
|
1516
|
-
getMap() {
|
|
1517
|
-
return StepMap.empty;
|
|
1518
|
-
}
|
|
1519
|
-
invert(doc) {
|
|
1520
|
-
return new AttrStep(this.pos, this.attr, doc.nodeAt(this.pos).attrs[this.attr]);
|
|
1521
|
-
}
|
|
1522
|
-
map(mapping) {
|
|
1523
|
-
let pos = mapping.mapResult(this.pos, 1);
|
|
1524
|
-
return pos.deletedAfter ? null : new AttrStep(pos.pos, this.attr, this.value);
|
|
1525
|
-
}
|
|
1526
|
-
toJSON() {
|
|
1527
|
-
return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
|
|
1528
|
-
}
|
|
1529
|
-
static fromJSON(schema, json) {
|
|
1530
|
-
if (typeof json.pos != "number" || typeof json.attr != "string")
|
|
1531
|
-
throw new RangeError("Invalid input for AttrStep.fromJSON");
|
|
1532
|
-
return new AttrStep(json.pos, json.attr, json.value);
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
Step.jsonID("attr", AttrStep);
|
|
1536
|
-
class DocAttrStep extends Step {
|
|
1537
|
-
/**
|
|
1538
|
-
Construct an attribute step.
|
|
1539
|
-
*/
|
|
1540
|
-
constructor(attr, value) {
|
|
1541
|
-
super();
|
|
1542
|
-
this.attr = attr;
|
|
1543
|
-
this.value = value;
|
|
1544
|
-
}
|
|
1545
|
-
apply(doc) {
|
|
1546
|
-
let attrs = /* @__PURE__ */ Object.create(null);
|
|
1547
|
-
for (let name in doc.attrs)
|
|
1548
|
-
attrs[name] = doc.attrs[name];
|
|
1549
|
-
attrs[this.attr] = this.value;
|
|
1550
|
-
let updated = doc.type.create(attrs, doc.content, doc.marks);
|
|
1551
|
-
return StepResult.ok(updated);
|
|
1552
|
-
}
|
|
1553
|
-
getMap() {
|
|
1554
|
-
return StepMap.empty;
|
|
1555
|
-
}
|
|
1556
|
-
invert(doc) {
|
|
1557
|
-
return new DocAttrStep(this.attr, doc.attrs[this.attr]);
|
|
1558
|
-
}
|
|
1559
|
-
map(mapping) {
|
|
1560
|
-
return this;
|
|
1561
|
-
}
|
|
1562
|
-
toJSON() {
|
|
1563
|
-
return { stepType: "docAttr", attr: this.attr, value: this.value };
|
|
1564
|
-
}
|
|
1565
|
-
static fromJSON(schema, json) {
|
|
1566
|
-
if (typeof json.attr != "string")
|
|
1567
|
-
throw new RangeError("Invalid input for DocAttrStep.fromJSON");
|
|
1568
|
-
return new DocAttrStep(json.attr, json.value);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
Step.jsonID("docAttr", DocAttrStep);
|
|
1572
|
-
let TransformError = class extends Error {
|
|
1573
|
-
};
|
|
1574
|
-
TransformError = function TransformError2(message) {
|
|
1575
|
-
let err = Error.call(this, message);
|
|
1576
|
-
err.__proto__ = TransformError2.prototype;
|
|
1577
|
-
return err;
|
|
1578
|
-
};
|
|
1579
|
-
TransformError.prototype = Object.create(Error.prototype);
|
|
1580
|
-
TransformError.prototype.constructor = TransformError;
|
|
1581
|
-
TransformError.prototype.name = "TransformError";
|
|
1582
|
-
class Transform {
|
|
1583
|
-
/**
|
|
1584
|
-
Create a transform that starts with the given document.
|
|
1585
|
-
*/
|
|
1586
|
-
constructor(doc) {
|
|
1587
|
-
this.doc = doc;
|
|
1588
|
-
this.steps = [];
|
|
1589
|
-
this.docs = [];
|
|
1590
|
-
this.mapping = new Mapping();
|
|
1591
|
-
}
|
|
1592
|
-
/**
|
|
1593
|
-
The starting document.
|
|
1594
|
-
*/
|
|
1595
|
-
get before() {
|
|
1596
|
-
return this.docs.length ? this.docs[0] : this.doc;
|
|
1597
|
-
}
|
|
1598
|
-
/**
|
|
1599
|
-
Apply a new step in this transform, saving the result. Throws an
|
|
1600
|
-
error when the step fails.
|
|
1601
|
-
*/
|
|
1602
|
-
step(step) {
|
|
1603
|
-
let result = this.maybeStep(step);
|
|
1604
|
-
if (result.failed)
|
|
1605
|
-
throw new TransformError(result.failed);
|
|
1606
|
-
return this;
|
|
1607
|
-
}
|
|
1608
|
-
/**
|
|
1609
|
-
Try to apply a step in this transformation, ignoring it if it
|
|
1610
|
-
fails. Returns the step result.
|
|
1611
|
-
*/
|
|
1612
|
-
maybeStep(step) {
|
|
1613
|
-
let result = step.apply(this.doc);
|
|
1614
|
-
if (!result.failed)
|
|
1615
|
-
this.addStep(step, result.doc);
|
|
1616
|
-
return result;
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
True when the document has been changed (when there are any
|
|
1620
|
-
steps).
|
|
1621
|
-
*/
|
|
1622
|
-
get docChanged() {
|
|
1623
|
-
return this.steps.length > 0;
|
|
1624
|
-
}
|
|
1625
|
-
/**
|
|
1626
|
-
Return a single range, in post-transform document positions,
|
|
1627
|
-
that covers all content changed by this transform. Returns null
|
|
1628
|
-
if no replacements are made. Note that this will ignore changes
|
|
1629
|
-
that add/remove marks without replacing the underlying content.
|
|
1630
|
-
*/
|
|
1631
|
-
changedRange() {
|
|
1632
|
-
let from = 1e9, to = -1e9;
|
|
1633
|
-
for (let i = 0; i < this.mapping.maps.length; i++) {
|
|
1634
|
-
let map = this.mapping.maps[i];
|
|
1635
|
-
if (i) {
|
|
1636
|
-
from = map.map(from, 1);
|
|
1637
|
-
to = map.map(to, -1);
|
|
1638
|
-
}
|
|
1639
|
-
map.forEach((_f, _t, fromB, toB) => {
|
|
1640
|
-
from = Math.min(from, fromB);
|
|
1641
|
-
to = Math.max(to, toB);
|
|
1642
|
-
});
|
|
1643
|
-
}
|
|
1644
|
-
return from == 1e9 ? null : { from, to };
|
|
1645
|
-
}
|
|
1646
|
-
/**
|
|
1647
|
-
@internal
|
|
1648
|
-
*/
|
|
1649
|
-
addStep(step, doc) {
|
|
1650
|
-
this.docs.push(this.doc);
|
|
1651
|
-
this.steps.push(step);
|
|
1652
|
-
this.mapping.appendMap(step.getMap());
|
|
1653
|
-
this.doc = doc;
|
|
1654
|
-
}
|
|
1655
|
-
/**
|
|
1656
|
-
Replace the part of the document between `from` and `to` with the
|
|
1657
|
-
given `slice`.
|
|
1658
|
-
*/
|
|
1659
|
-
replace(from, to = from, slice = Slice.empty) {
|
|
1660
|
-
let step = replaceStep(this.doc, from, to, slice);
|
|
1661
|
-
if (step)
|
|
1662
|
-
this.step(step);
|
|
1663
|
-
return this;
|
|
1664
|
-
}
|
|
1665
|
-
/**
|
|
1666
|
-
Replace the given range with the given content, which may be a
|
|
1667
|
-
fragment, node, or array of nodes.
|
|
1668
|
-
*/
|
|
1669
|
-
replaceWith(from, to, content) {
|
|
1670
|
-
return this.replace(from, to, new Slice(Fragment.from(content), 0, 0));
|
|
1671
|
-
}
|
|
1672
|
-
/**
|
|
1673
|
-
Delete the content between the given positions.
|
|
1674
|
-
*/
|
|
1675
|
-
delete(from, to) {
|
|
1676
|
-
return this.replace(from, to, Slice.empty);
|
|
1677
|
-
}
|
|
1678
|
-
/**
|
|
1679
|
-
Insert the given content at the given position.
|
|
1680
|
-
*/
|
|
1681
|
-
insert(pos, content) {
|
|
1682
|
-
return this.replaceWith(pos, pos, content);
|
|
1683
|
-
}
|
|
1684
|
-
/**
|
|
1685
|
-
Replace a range of the document with a given slice, using
|
|
1686
|
-
`from`, `to`, and the slice's
|
|
1687
|
-
[`openStart`](https://prosemirror.net/docs/ref/#model.Slice.openStart) property as hints, rather
|
|
1688
|
-
than fixed start and end points. This method may grow the
|
|
1689
|
-
replaced area or close open nodes in the slice in order to get a
|
|
1690
|
-
fit that is more in line with WYSIWYG expectations, by dropping
|
|
1691
|
-
fully covered parent nodes of the replaced region when they are
|
|
1692
|
-
marked [non-defining as
|
|
1693
|
-
context](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext), or including an
|
|
1694
|
-
open parent node from the slice that _is_ marked as [defining
|
|
1695
|
-
its content](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
|
|
1696
|
-
|
|
1697
|
-
This is the method, for example, to handle paste. The similar
|
|
1698
|
-
[`replace`](https://prosemirror.net/docs/ref/#transform.Transform.replace) method is a more
|
|
1699
|
-
primitive tool which will _not_ move the start and end of its given
|
|
1700
|
-
range, and is useful in situations where you need more precise
|
|
1701
|
-
control over what happens.
|
|
1702
|
-
*/
|
|
1703
|
-
replaceRange(from, to, slice) {
|
|
1704
|
-
replaceRange(this, from, to, slice);
|
|
1705
|
-
return this;
|
|
1706
|
-
}
|
|
1707
|
-
/**
|
|
1708
|
-
Replace the given range with a node, but use `from` and `to` as
|
|
1709
|
-
hints, rather than precise positions. When from and to are the same
|
|
1710
|
-
and are at the start or end of a parent node in which the given
|
|
1711
|
-
node doesn't fit, this method may _move_ them out towards a parent
|
|
1712
|
-
that does allow the given node to be placed. When the given range
|
|
1713
|
-
completely covers a parent node, this method may completely replace
|
|
1714
|
-
that parent node.
|
|
1715
|
-
*/
|
|
1716
|
-
replaceRangeWith(from, to, node) {
|
|
1717
|
-
replaceRangeWith(this, from, to, node);
|
|
1718
|
-
return this;
|
|
1719
|
-
}
|
|
1720
|
-
/**
|
|
1721
|
-
Delete the given range, expanding it to cover fully covered
|
|
1722
|
-
parent nodes until a valid replace is found.
|
|
1723
|
-
*/
|
|
1724
|
-
deleteRange(from, to) {
|
|
1725
|
-
deleteRange(this, from, to);
|
|
1726
|
-
return this;
|
|
1727
|
-
}
|
|
1728
|
-
/**
|
|
1729
|
-
Split the content in the given range off from its parent, if there
|
|
1730
|
-
is sibling content before or after it, and move it up the tree to
|
|
1731
|
-
the depth specified by `target`. You'll probably want to use
|
|
1732
|
-
[`liftTarget`](https://prosemirror.net/docs/ref/#transform.liftTarget) to compute `target`, to make
|
|
1733
|
-
sure the lift is valid.
|
|
1734
|
-
*/
|
|
1735
|
-
lift(range, target) {
|
|
1736
|
-
lift(this, range, target);
|
|
1737
|
-
return this;
|
|
1738
|
-
}
|
|
1739
|
-
/**
|
|
1740
|
-
Join the blocks around the given position. If depth is 2, their
|
|
1741
|
-
last and first siblings are also joined, and so on.
|
|
1742
|
-
*/
|
|
1743
|
-
join(pos, depth = 1) {
|
|
1744
|
-
join(this, pos, depth);
|
|
1745
|
-
return this;
|
|
1746
|
-
}
|
|
1747
|
-
/**
|
|
1748
|
-
Wrap the given [range](https://prosemirror.net/docs/ref/#model.NodeRange) in the given set of wrappers.
|
|
1749
|
-
The wrappers are assumed to be valid in this position, and should
|
|
1750
|
-
probably be computed with [`findWrapping`](https://prosemirror.net/docs/ref/#transform.findWrapping).
|
|
1751
|
-
*/
|
|
1752
|
-
wrap(range, wrappers) {
|
|
1753
|
-
wrap(this, range, wrappers);
|
|
1754
|
-
return this;
|
|
1755
|
-
}
|
|
1756
|
-
/**
|
|
1757
|
-
Set the type of all textblocks (partly) between `from` and `to` to
|
|
1758
|
-
the given node type with the given attributes.
|
|
1759
|
-
*/
|
|
1760
|
-
setBlockType(from, to = from, type, attrs = null) {
|
|
1761
|
-
setBlockType(this, from, to, type, attrs);
|
|
1762
|
-
return this;
|
|
1763
|
-
}
|
|
1764
|
-
/**
|
|
1765
|
-
Change the type, attributes, and/or marks of the node at `pos`.
|
|
1766
|
-
When `type` isn't given, the existing node type is preserved,
|
|
1767
|
-
*/
|
|
1768
|
-
setNodeMarkup(pos, type, attrs = null, marks) {
|
|
1769
|
-
setNodeMarkup(this, pos, type, attrs, marks);
|
|
1770
|
-
return this;
|
|
1771
|
-
}
|
|
1772
|
-
/**
|
|
1773
|
-
Set a single attribute on a given node to a new value.
|
|
1774
|
-
The `pos` addresses the document content. Use `setDocAttribute`
|
|
1775
|
-
to set attributes on the document itself.
|
|
1776
|
-
*/
|
|
1777
|
-
setNodeAttribute(pos, attr, value) {
|
|
1778
|
-
this.step(new AttrStep(pos, attr, value));
|
|
1779
|
-
return this;
|
|
1780
|
-
}
|
|
1781
|
-
/**
|
|
1782
|
-
Set a single attribute on the document to a new value.
|
|
1783
|
-
*/
|
|
1784
|
-
setDocAttribute(attr, value) {
|
|
1785
|
-
this.step(new DocAttrStep(attr, value));
|
|
1786
|
-
return this;
|
|
1787
|
-
}
|
|
1788
|
-
/**
|
|
1789
|
-
Add a mark to the node at position `pos`.
|
|
1790
|
-
*/
|
|
1791
|
-
addNodeMark(pos, mark) {
|
|
1792
|
-
this.step(new AddNodeMarkStep(pos, mark));
|
|
1793
|
-
return this;
|
|
1794
|
-
}
|
|
1795
|
-
/**
|
|
1796
|
-
Remove a mark (or all marks of the given type) from the node at
|
|
1797
|
-
position `pos`.
|
|
1798
|
-
*/
|
|
1799
|
-
removeNodeMark(pos, mark) {
|
|
1800
|
-
let node = this.doc.nodeAt(pos);
|
|
1801
|
-
if (!node)
|
|
1802
|
-
throw new RangeError("No node at position " + pos);
|
|
1803
|
-
if (mark instanceof Mark) {
|
|
1804
|
-
if (mark.isInSet(node.marks))
|
|
1805
|
-
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
1806
|
-
} else {
|
|
1807
|
-
let set = node.marks, found, steps = [];
|
|
1808
|
-
while (found = mark.isInSet(set)) {
|
|
1809
|
-
steps.push(new RemoveNodeMarkStep(pos, found));
|
|
1810
|
-
set = found.removeFromSet(set);
|
|
1811
|
-
}
|
|
1812
|
-
for (let i = steps.length - 1; i >= 0; i--)
|
|
1813
|
-
this.step(steps[i]);
|
|
1814
|
-
}
|
|
1815
|
-
return this;
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
Split the node at the given position, and optionally, if `depth` is
|
|
1819
|
-
greater than one, any number of nodes above that. By default, the
|
|
1820
|
-
parts split off will inherit the node type of the original node.
|
|
1821
|
-
This can be changed by passing an array of types and attributes to
|
|
1822
|
-
use after the split (with the outermost nodes coming first).
|
|
1823
|
-
*/
|
|
1824
|
-
split(pos, depth = 1, typesAfter) {
|
|
1825
|
-
split(this, pos, depth, typesAfter);
|
|
1826
|
-
return this;
|
|
1827
|
-
}
|
|
1828
|
-
/**
|
|
1829
|
-
Add the given mark to the inline content between `from` and `to`.
|
|
1830
|
-
*/
|
|
1831
|
-
addMark(from, to, mark) {
|
|
1832
|
-
addMark(this, from, to, mark);
|
|
1833
|
-
return this;
|
|
1834
|
-
}
|
|
1835
|
-
/**
|
|
1836
|
-
Remove marks from inline nodes between `from` and `to`. When
|
|
1837
|
-
`mark` is a single mark, remove precisely that mark. When it is
|
|
1838
|
-
a mark type, remove all marks of that type. When it is null,
|
|
1839
|
-
remove all marks of any type.
|
|
1840
|
-
*/
|
|
1841
|
-
removeMark(from, to, mark) {
|
|
1842
|
-
removeMark(this, from, to, mark);
|
|
1843
|
-
return this;
|
|
1844
|
-
}
|
|
1845
|
-
/**
|
|
1846
|
-
Removes all marks and nodes from the content of the node at
|
|
1847
|
-
`pos` that don't match the given new parent node type. Accepts
|
|
1848
|
-
an optional starting [content match](https://prosemirror.net/docs/ref/#model.ContentMatch) as
|
|
1849
|
-
third argument.
|
|
1850
|
-
*/
|
|
1851
|
-
clearIncompatible(pos, parentType, match) {
|
|
1852
|
-
clearIncompatible(this, pos, parentType, match);
|
|
1853
|
-
return this;
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
export {
|
|
1857
|
-
AddMarkStep,
|
|
1858
|
-
AddNodeMarkStep,
|
|
1859
|
-
AttrStep,
|
|
1860
|
-
DocAttrStep,
|
|
1861
|
-
MapResult,
|
|
1862
|
-
Mapping,
|
|
1863
|
-
RemoveMarkStep,
|
|
1864
|
-
RemoveNodeMarkStep,
|
|
1865
|
-
ReplaceAroundStep,
|
|
1866
|
-
ReplaceStep,
|
|
1867
|
-
Step,
|
|
1868
|
-
StepMap,
|
|
1869
|
-
StepResult,
|
|
1870
|
-
Transform,
|
|
1871
|
-
TransformError,
|
|
1872
|
-
canJoin,
|
|
1873
|
-
canSplit,
|
|
1874
|
-
dropPoint,
|
|
1875
|
-
findWrapping,
|
|
1876
|
-
insertPoint,
|
|
1877
|
-
joinPoint,
|
|
1878
|
-
liftTarget,
|
|
1879
|
-
replaceStep
|
|
1880
|
-
};
|
|
1881
|
-
//# sourceMappingURL=index.js.map
|