@unicom-cloud/ui 0.8.109 → 0.8.111
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/Affix.js +2 -2
- package/Alert.js +1 -1
- package/AutoComplete.js +1 -1
- package/BackTop.js +2 -2
- package/Badge.js +1 -1
- package/Breadcrumb.js +2 -2
- package/Button.js +1 -1
- package/Calendar.js +1 -1
- package/Card.js +1 -1
- package/Carousel.js +1 -1
- package/Cascader.js +1 -1
- package/Checkbox.js +1 -1
- package/ColorPicker.js +1 -1
- package/Comment.js +1 -1
- package/ConfigProvider.js +1 -1
- package/Copy.js +6 -4
- package/Countdown.js +42 -8
- package/DatePicker.js +1 -1
- package/Descriptions.js +1 -1
- package/Details.js +42 -6
- package/Development.js +1 -1
- package/Divider.js +1 -1
- package/Draggable.js +1 -1
- package/Dropdown.js +1 -1
- package/Empty.js +1 -1
- package/Flex.js +43 -7
- package/Form.js +21 -16
- package/Icon.js +1 -1
- package/IconHover.js +1 -1
- package/Image.js +1 -1
- package/InputNumber.js +1 -1
- package/Layout.js +1 -1
- package/Link.js +2 -2
- package/LiquidFill.js +12 -10
- package/List.js +1 -1
- package/Loading.js +42 -6
- package/Marquee.js +12 -10
- package/Mentions.js +1 -1
- package/Menu.js +1 -1
- package/Message.js +3 -3
- package/Modal.js +1 -1
- package/Notice.js +41 -5
- package/Notification.js +1 -1
- package/OverflowEllipsis.js +1 -1
- package/PageHeader.js +2 -2
- package/Popconfirm.js +1 -1
- package/Popover.js +1 -1
- package/Progress.js +1 -1
- package/QrCode.js +12 -10
- package/Radio.js +1 -1
- package/Rate.js +1 -1
- package/ResizeBox.js +1 -1
- package/Result.js +1 -1
- package/RichText.js +19 -0
- package/Segmented.js +42 -7
- package/Skeleton.js +1 -1
- package/Slider.js +1 -1
- package/Space.js +43 -7
- package/Spin.js +1 -1
- package/Statistic.js +1 -1
- package/Steps.js +1 -1
- package/Switch.js +1 -1
- package/Table.js +1 -1
- package/Tabs.js +1 -1
- package/Tag.js +2 -2
- package/Tooltip.js +1 -1
- package/Tour.js +13 -11
- package/Transfer.js +1 -1
- package/Tree.js +1 -1
- package/TreeSelect.js +1 -1
- package/Trigger.js +1 -1
- package/affix/index.js +2 -2
- package/alert/index.js +1 -1
- package/anchor/Anchor.js +2 -2
- package/anchor/Link.js +1 -1
- package/app/App.js +2 -2
- package/auto-complete/index.js +1 -1
- package/avatar/Avatar.js +1 -1
- package/avatar/Group.js +1 -1
- package/back-top/index.js +2 -2
- package/badge/index.js +1 -1
- package/breadcrumb/index.js +2 -2
- package/button/Group.js +1 -1
- package/button/index.js +1 -1
- package/calendar/index.js +3 -3
- package/card/Grid.js +1 -1
- package/card/Meta.js +1 -1
- package/card/index.js +1 -1
- package/carousel/Arrow.js +2 -2
- package/carousel/Indicator.js +1 -1
- package/carousel/index.js +1 -1
- package/cascader/Cascader.js +3 -3
- package/cascader/index.js +1 -1
- package/cascader/util.js +1 -1
- package/checkbox/Checkbox.js +2 -2
- package/checkbox/Group.js +2 -2
- package/checkbox/GroupBlock.js +2 -2
- package/checkbox/index.js +2 -2
- package/chunk/BDMqvmVH.js +4239 -0
- package/chunk/BDgzrqDN.js +154 -0
- package/chunk/BG6j6Ct7.js +30 -0
- package/chunk/BGJspFG9.js +56 -0
- package/chunk/BO_5qdS_.js +13 -0
- package/chunk/{DblEjsQ8.js → BUNoUPLs.js} +1 -1
- package/chunk/B_c0gPsX.js +83 -0
- package/chunk/BcEZk8pT.js +837 -0
- package/chunk/{DGSfSsAY.js → BeHcDey_.js} +1 -1
- package/chunk/{B9YvSTvI.js → BlflTd2i.js} +695 -856
- package/chunk/{Bm3gJPkz.js → BnUWOu3_.js} +5 -5
- package/chunk/Bvxzb1wd.js +16 -0
- package/chunk/{DryCfcSV.js → CFyN9Eio.js} +4 -4
- package/chunk/CN7NKv_2.js +11 -0
- package/chunk/{BDKb_-wj.js → COsRZOz1.js} +4 -4
- package/chunk/CT7ury1Z.js +13 -0
- package/chunk/Ca6eMq_Y.js +8 -0
- package/chunk/{p9jiLDTk.js → CgN4U7Ou.js} +2 -2
- package/chunk/{Bg3uJGPu.js → CsqGBZv1.js} +1 -1
- package/chunk/CylJZkp8.js +6 -0
- package/chunk/{9WWq1a0I.js → DSqW_efI.js} +1 -1
- package/chunk/{Bz3KT4sO.js → Dbw0YUY1.js} +81 -47
- package/chunk/Dh-zFF65.js +15 -0
- package/chunk/Di5KBCVQ.js +4 -0
- package/chunk/{DjPTURUf.js → Lyh0cz3R.js} +3 -3
- package/chunk/{DgWzb7M5.js → Y_GQsZUt.js} +1 -1
- package/chunk/{BfBHo0RR.js → n1tirBXA.js} +7 -7
- package/chunk/{DYc9a7tm.js → qsVvkBLU.js} +1 -1
- package/collapse/Collapse.js +2 -2
- package/collapse/Item.js +2 -2
- package/color-picker/ControlBar.js +1 -1
- package/color-picker/InputAlpha.js +1 -1
- package/color-picker/InputHex.js +1 -1
- package/color-picker/InputRgb.js +1 -1
- package/color-picker/Palette.js +1 -1
- package/color-picker/Panel.js +2 -2
- package/color-picker/index.js +1 -1
- package/comment/index.js +1 -1
- package/config-provider/ConfigProvider.js +1 -1
- package/config-provider/context.js +1 -1
- package/config-provider/index.js +2 -2
- package/copy/index.js +10 -8
- package/countdown/index.js +67 -33
- package/date-picker/Picker.js +1 -1
- package/date-picker/RangePicker.js +2 -2
- package/date-picker/index.js +1 -1
- package/descriptions/index.js +1 -1
- package/details/index.js +74 -38
- package/development/index.js +1 -1
- package/divider/index.js +1 -1
- package/draggable/index.js +1 -1
- package/drawer/Drawer.js +1 -1
- package/dropdown/Button.js +1 -1
- package/dropdown/index.js +1 -1
- package/empty/index.js +1 -1
- package/flex/index.js +63 -29
- package/form/Form.js +3 -3
- package/form/FormItem.js +1 -1
- package/form/index.js +85 -77
- package/grid/Grid.js +1 -1
- package/grid/Item.js +1 -1
- package/hooks/index.js +123 -129
- package/hooks/useCreation.js +4 -0
- package/hooks/useId.js +1 -1
- package/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/hooks/useKeyboardEvent.js +1 -1
- package/hooks/useMedia.js +1 -1
- package/hooks/usePersistCallback.js +1 -1
- package/hooks/useRefs.js +1 -1
- package/hooks/useStateWithPromise.js +1 -1
- package/hooks/useWatch.js +1 -1
- package/hooks/useWindowSize.js +1 -1
- package/icon/index.js +1 -1
- package/icon-hover/index.js +1 -1
- package/icons/file.js +1 -1
- package/image/Image.js +3 -3
- package/image/ImagePreview.js +44 -9
- package/image/ImagePreviewArrow.js +1 -1
- package/image/ImagePreviewGroup.js +1 -1
- package/image/index.js +1 -1
- package/index.js +470 -470
- package/input/Button.js +1 -1
- package/input/Group.js +1 -1
- package/input/Input.js +3 -3
- package/input/InputElement.js +2 -2
- package/input/Password.js +2 -2
- package/input/Search.js +1 -1
- package/input/Textarea.js +2 -2
- package/input-number/index.js +1 -1
- package/input-number/useSelectionRange.js +1 -1
- package/input-tag/InputTag.js +1 -1
- package/layout/Content.js +1 -1
- package/layout/Footer.js +1 -1
- package/layout/Header.js +1 -1
- package/layout/Sider.js +1 -1
- package/layout/index.js +1 -1
- package/link/index.js +2 -2
- package/liquid-fill/index.js +17 -15
- package/list/Item.js +1 -1
- package/list/Meta.js +1 -1
- package/list/index.js +1 -1
- package/loading/index.js +54 -18
- package/marquee/index.js +19 -17
- package/marquee-/index.js +17 -15
- package/mentions/index.js +1 -1
- package/menu/Menu.js +4 -4
- package/menu/OverflowWrap.js +1 -1
- package/menu/index.js +2 -2
- package/message/index.js +3 -3
- package/message/useMessage.js +4 -3
- package/modal/Confirm.js +2 -2
- package/modal/Modal.js +2 -2
- package/modal/index.js +2 -2
- package/notice/index.js +41 -5
- package/notification/index.js +1 -1
- package/notification/useNotification.js +1 -1
- package/overflow-ellipsis/OverflowItem.js +1 -1
- package/overflow-ellipsis/index.js +1 -1
- package/package.json +1 -1
- package/page-header/index.js +120 -81
- package/pagination/PageItem.js +2 -2
- package/pagination/PageJumper.js +1 -1
- package/pagination/PageOption.js +1 -1
- package/pagination/Pagination.js +1 -1
- package/picker/Input.js +1 -1
- package/picker/InputRange.js +1 -1
- package/popconfirm/index.js +1 -1
- package/popover/index.js +1 -1
- package/progress/CircleProgress.js +2 -2
- package/progress/index.js +1 -1
- package/qr-code/index.js +15 -13
- package/radio/Group.js +2 -2
- package/radio/GroupBlock.js +2 -2
- package/radio/Radio.js +2 -2
- package/radio/index.js +2 -2
- package/rate/index.js +1 -1
- package/resize-box/ResizeTrigger.js +1 -1
- package/resize-box/Split.js +2 -2
- package/resize-box/SplitGroup.js +1 -1
- package/resize-box/index.js +1 -1
- package/result/index.js +1 -1
- package/rich-text/constant.js +5 -0
- package/rich-text/core.js +11 -0
- package/rich-text/index.js +119 -0
- package/rich-text/interface.js +1 -0
- package/rich-text/rich.js +1877 -0
- package/row-col/Col-.js +1 -1
- package/row-col/Col.js +1 -1
- package/row-col/Row.js +1 -1
- package/segmented/index.js +145 -110
- package/select/Option.js +1 -1
- package/select/Select.js +235 -227
- package/select-view/Core.js +2 -2
- package/skeleton/index.js +1 -1
- package/slider/Button.js +2 -2
- package/slider/index.js +1 -1
- package/space/index.js +51 -15
- package/spin/DotLoading.js +1 -1
- package/spin/index.js +1 -1
- package/splitter/Panel.js +1 -1
- package/splitter/SplitBar.js +2 -2
- package/splitter/Splitter.js +2 -2
- package/statistic/index.js +1 -1
- package/steps/index.js +1 -1
- package/style.css +1 -1
- package/switch/index.js +1 -1
- package/table/Table.js +3 -3
- package/table/index.js +41 -39
- package/tabs/Tab.js +3 -3
- package/tabs/TabContent.js +2 -2
- package/tabs/TabPane.js +1 -1
- package/tabs/index.js +2 -2
- package/tag/index.js +2 -2
- package/time-picker/Picker.js +1 -1
- package/time-picker/TimePicker.js +1 -1
- package/timeline/Item.js +1 -1
- package/timeline/Timeline.js +1 -1
- package/tooltip/index.js +1 -1
- package/tour/index.js +20 -18
- package/transfer/Item.js +3 -3
- package/transfer/List.js +3 -3
- package/transfer/index.js +1 -1
- package/tree/Animation.js +2 -2
- package/tree/Node.js +3 -3
- package/tree/NodeList.js +1 -1
- package/tree/Tree.js +2 -2
- package/tree/index.js +1 -1
- package/tree-select/Select.js +4 -4
- package/tree-select/index.js +1 -1
- package/trigger/index.js +1 -1
- package/types/common/hooks/src/index.d.ts +1 -5
- package/types/common/hooks/src/use-url-state/index.d.ts +1 -1
- package/types/common/hooks/useId.d.ts +1 -1
- package/types/common/hooks/useIsomorphicLayoutEffect.d.ts +1 -3
- package/types/common/hooks/useKeyboardEvent.d.ts +1 -1
- package/types/common/hooks/{useListenResize.d.ts → useListenWindowResize.d.ts} +4 -6
- package/types/common/hooks/useWatch.d.ts +1 -1
- package/types/common/hooks/useWindowSize.d.ts +2 -2
- package/types/common/utils/index.d.ts +47 -0
- package/types/common/utils/keyboardCode.d.ts +4 -0
- package/types/common/utils/math.d.ts +1 -0
- package/types/common/utils/mitt.d.ts +1 -0
- package/types/common/utils/pinyin.d.ts +1 -0
- package/types/common/utils/reactTransitionGroup.d.ts +1 -0
- package/types/common/utils/uuid.d.ts +1 -0
- package/types/common/utils/validate.d.ts +1 -0
- package/types/pc/config-provider/interface.d.ts +2 -0
- package/types/pc/date-picker/RangePicker.d.ts +1 -1
- package/types/pc/form/index.d.ts +6 -1
- package/types/pc/hooks/index.d.ts +2 -2
- package/types/pc/hooks/useCreation.d.ts +1 -0
- package/types/pc/hooks/useListenWindowResize.d.ts +1 -0
- package/types/pc/index.d.ts +2 -0
- package/types/pc/message/index.d.ts +1 -0
- package/types/pc/message/interface.d.ts +2 -2
- package/types/pc/page-header/interface.d.ts +3 -0
- package/types/pc/rich-text/blots/block.d.ts +34 -0
- package/types/pc/rich-text/blots/break.d.ts +8 -0
- package/types/pc/rich-text/blots/container.d.ts +4 -0
- package/types/pc/rich-text/blots/cursor.d.ts +26 -0
- package/types/pc/rich-text/blots/embed.d.ts +18 -0
- package/types/pc/rich-text/blots/inline.d.ts +12 -0
- package/types/pc/rich-text/blots/scroll.d.ts +49 -0
- package/types/pc/rich-text/blots/text.d.ts +5 -0
- package/types/pc/rich-text/constant.d.ts +1 -0
- package/types/pc/rich-text/core/composition.d.ts +12 -0
- package/types/pc/rich-text/core/editor.d.ts +28 -0
- package/types/pc/rich-text/core/emitter.d.ts +37 -0
- package/types/pc/rich-text/core/instances.d.ts +3 -0
- package/types/pc/rich-text/core/logger.d.ts +7 -0
- package/types/pc/rich-text/core/module.d.ts +8 -0
- package/types/pc/rich-text/core/rich.d.ts +217 -0
- package/types/pc/rich-text/core/selection.d.ts +74 -0
- package/types/pc/rich-text/core/theme.d.ts +32 -0
- package/types/pc/rich-text/core/utils/createRegistryWithFormats.d.ts +5 -0
- package/types/pc/rich-text/core/utils/scrollRectIntoView.d.ts +11 -0
- package/types/pc/rich-text/core.d.ts +7 -0
- package/types/pc/rich-text/delta/AttributeMap.d.ts +10 -0
- package/types/pc/rich-text/delta/Op.d.ts +11 -0
- package/types/pc/rich-text/delta/OpIterator.d.ts +13 -0
- package/types/pc/rich-text/delta/index.d.ts +45 -0
- package/types/pc/rich-text/formats/align.d.ts +5 -0
- package/types/pc/rich-text/formats/background.d.ts +5 -0
- package/types/pc/rich-text/formats/blockquote.d.ts +6 -0
- package/types/pc/rich-text/formats/bold.d.ts +11 -0
- package/types/pc/rich-text/formats/code.d.ts +15 -0
- package/types/pc/rich-text/formats/color.d.ts +7 -0
- package/types/pc/rich-text/formats/direction.d.ts +5 -0
- package/types/pc/rich-text/formats/font.d.ts +7 -0
- package/types/pc/rich-text/formats/formula.d.ts +10 -0
- package/types/pc/rich-text/formats/header.d.ts +7 -0
- package/types/pc/rich-text/formats/image.d.ts +13 -0
- package/types/pc/rich-text/formats/indent.d.ts +8 -0
- package/types/pc/rich-text/formats/italic.d.ts +6 -0
- package/types/pc/rich-text/formats/link.d.ts +13 -0
- package/types/pc/rich-text/formats/list.d.ts +13 -0
- package/types/pc/rich-text/formats/script.d.ts +8 -0
- package/types/pc/rich-text/formats/size.d.ts +4 -0
- package/types/pc/rich-text/formats/strike.d.ts +6 -0
- package/types/pc/rich-text/formats/table.d.ts +45 -0
- package/types/pc/rich-text/formats/underline.d.ts +6 -0
- package/types/pc/rich-text/formats/video.d.ts +14 -0
- package/types/pc/rich-text/index.d.ts +6 -0
- package/types/pc/rich-text/interface.d.ts +17 -0
- package/types/pc/rich-text/modules/clipboard.d.ts +43 -0
- package/types/pc/rich-text/modules/history.d.ts +36 -0
- package/types/pc/rich-text/modules/input.d.ts +10 -0
- package/types/pc/rich-text/modules/keyboard.d.ts +58 -0
- package/types/pc/rich-text/modules/normalizeExternalHTML/index.d.ts +2 -0
- package/types/pc/rich-text/modules/normalizeExternalHTML/normalizers/googleDocs.d.ts +1 -0
- package/types/pc/rich-text/modules/normalizeExternalHTML/normalizers/msWord.d.ts +1 -0
- package/types/pc/rich-text/modules/syntax.d.ts +50 -0
- package/types/pc/rich-text/modules/table.d.ts +20 -0
- package/types/pc/rich-text/modules/tableEmbed.d.ts +27 -0
- package/types/pc/rich-text/modules/toolbar.d.ts +24 -0
- package/types/pc/rich-text/modules/uiNode.d.ts +19 -0
- package/types/pc/rich-text/modules/uploader.d.ts +15 -0
- package/types/pc/rich-text/parchment/attributor/attributor.d.ts +17 -0
- package/types/pc/rich-text/parchment/attributor/class.d.ts +8 -0
- package/types/pc/rich-text/parchment/attributor/store.d.ts +15 -0
- package/types/pc/rich-text/parchment/attributor/style.d.ts +8 -0
- package/types/pc/rich-text/parchment/blot/abstract/blot.d.ts +115 -0
- package/types/pc/rich-text/parchment/blot/abstract/container.d.ts +18 -0
- package/types/pc/rich-text/parchment/blot/abstract/leaf.d.ts +29 -0
- package/types/pc/rich-text/parchment/blot/abstract/parent.d.ts +50 -0
- package/types/pc/rich-text/parchment/blot/abstract/shadow.d.ts +37 -0
- package/types/pc/rich-text/parchment/blot/block.d.ts +25 -0
- package/types/pc/rich-text/parchment/blot/embed.d.ts +11 -0
- package/types/pc/rich-text/parchment/blot/inline.d.ts +28 -0
- package/types/pc/rich-text/parchment/blot/scroll.d.ts +34 -0
- package/types/pc/rich-text/parchment/blot/text.d.ts +26 -0
- package/types/pc/rich-text/parchment/collection/linked-list.d.ts +21 -0
- package/types/pc/rich-text/parchment/collection/linked-node.d.ts +6 -0
- package/types/pc/rich-text/parchment/error.d.ts +6 -0
- package/types/pc/rich-text/parchment/index.d.ts +21 -0
- package/types/pc/rich-text/parchment/registry.d.ts +21 -0
- package/types/pc/rich-text/parchment/scope.d.ts +14 -0
- package/types/pc/rich-text/rich.d.ts +5 -0
- package/types/pc/rich-text/themes/base.d.ts +35 -0
- package/types/pc/rich-text/themes/bubble.d.ts +18 -0
- package/types/pc/rich-text/themes/snow.d.ts +9 -0
- package/types/pc/rich-text/ui/color-picker.d.ts +7 -0
- package/types/pc/rich-text/ui/icon-picker.d.ts +7 -0
- package/types/pc/rich-text/ui/icons.d.ts +51 -0
- package/types/pc/rich-text/ui/picker.d.ts +16 -0
- package/types/pc/rich-text/ui/tooltip.d.ts +12 -0
- package/types/pc/select/interface.d.ts +4 -0
- package/types/pc/utils/index.d.ts +2 -0
- package/types/pc/utils/mitt.d.ts +1 -0
- package/types/pc/utils/names.d.ts +107 -91
- package/types/pc/utils/pinyin.d.ts +1 -0
- package/types/pc/version/index.d.ts +1 -1
- package/typography/Base.js +1 -1
- package/typography/Ellipsis.js +5 -3
- package/typography/Operations.js +6 -4
- package/typography/Paragraph.js +1 -1
- package/typography/Typography.js +1 -1
- package/typography/useEllipsis.js +1 -1
- package/upload/TriggerNode.js +2 -2
- package/upload/Upload.js +2 -2
- package/utils/contextHolder.js +1 -1
- package/utils/index.js +167 -163
- package/utils/mitt.js +5 -0
- package/utils/names.js +12 -2
- package/utils/pinyin.js +5 -0
- package/verification-code/VerificationCode.js +1 -1
- package/version/index.js +1 -1
- package/virtual-list/VirtualList.js +2 -2
- package/watermark/Watermark.js +1 -1
- package/chunk/5_U1CBIu.js +0 -8
- package/chunk/BLOlsa0k.js +0 -11
- package/chunk/BTLlOOe9.js +0 -189
- package/chunk/C6Aw3qIJ.js +0 -16
- package/chunk/CMl7m9nA.js +0 -6
- package/chunk/COqvRD0G.js +0 -11
- package/chunk/DXlwLh0Y.js +0 -806
- package/chunk/DlSv5Vu0.js +0 -16
- package/chunk/DmDh7NRL.js +0 -14
- package/chunk/Duezix3m.js +0 -25
- package/chunk/siEVY1s5.js +0 -33
- package/hooks/useCreate.js +0 -4
- package/types/common/hooks/src/use-dynamic-list/index.d.ts +0 -18
- package/types/common/hooks/src/use-event-emitter/index.d.ts +0 -11
- package/types/common/hooks/src/use-map/index.d.ts +0 -8
- package/types/common/hooks/src/use-set/index.d.ts +0 -6
- package/types/common/hooks/useCreate.d.ts +0 -2
- package/types/pc/hooks/useCreate.d.ts +0 -1
- package/types/pc/hooks/useListenResize.d.ts +0 -1
- /package/hooks/{useListenResize.js → useListenWindowResize.js} +0 -0
|
@@ -0,0 +1,4239 @@
|
|
|
1
|
+
import it from "lodash/merge";
|
|
2
|
+
import { RICH_TEXT_CLASS_NAME_PREFIX as L } from "../rich-text/constant.js";
|
|
3
|
+
import lt from "@unicom-cloud/utils/diff";
|
|
4
|
+
import W from "lodash/cloneDeep";
|
|
5
|
+
import X from "lodash/isEqual";
|
|
6
|
+
import ue from "@unicom-cloud/utils/mitt";
|
|
7
|
+
import { isMacOS as fe } from "@unicom-cloud/utils/constant/platform";
|
|
8
|
+
var kt;
|
|
9
|
+
((r) => {
|
|
10
|
+
function t(n = {}, o = {}, l = !1) {
|
|
11
|
+
typeof n != "object" && (n = {}), typeof o != "object" && (o = {});
|
|
12
|
+
let a = W(o);
|
|
13
|
+
l || (a = Object.keys(a).reduce((c, h) => (a[h] != null && (c[h] = a[h]), c), {}));
|
|
14
|
+
for (const c in n)
|
|
15
|
+
n[c] !== void 0 && o[c] === void 0 && (a[c] = n[c]);
|
|
16
|
+
return Object.keys(a).length > 0 ? a : void 0;
|
|
17
|
+
}
|
|
18
|
+
r.compose = t;
|
|
19
|
+
function e(n = {}, o = {}) {
|
|
20
|
+
typeof n != "object" && (n = {}), typeof o != "object" && (o = {});
|
|
21
|
+
const l = Object.keys(n).concat(Object.keys(o)).reduce((a, c) => (X(n[c], o[c]) || (a[c] = o[c] === void 0 ? null : o[c]), a), {});
|
|
22
|
+
return Object.keys(l).length > 0 ? l : void 0;
|
|
23
|
+
}
|
|
24
|
+
r.diff = e;
|
|
25
|
+
function s(n = {}, o = {}) {
|
|
26
|
+
n = n || {};
|
|
27
|
+
const l = Object.keys(o).reduce((a, c) => (o[c] !== n[c] && n[c] !== void 0 && (a[c] = o[c]), a), {});
|
|
28
|
+
return Object.keys(n).reduce((a, c) => (n[c] !== o[c] && o[c] === void 0 && (a[c] = null), a), l);
|
|
29
|
+
}
|
|
30
|
+
r.invert = s;
|
|
31
|
+
function i(n, o, l = !1) {
|
|
32
|
+
if (typeof n != "object")
|
|
33
|
+
return o;
|
|
34
|
+
if (typeof o != "object")
|
|
35
|
+
return;
|
|
36
|
+
if (!l)
|
|
37
|
+
return o;
|
|
38
|
+
const a = Object.keys(o).reduce((c, h) => (n[h] === void 0 && (c[h] = o[h]), c), {});
|
|
39
|
+
return Object.keys(a).length > 0 ? a : void 0;
|
|
40
|
+
}
|
|
41
|
+
r.transform = i;
|
|
42
|
+
})(kt || (kt = {}));
|
|
43
|
+
const C = kt;
|
|
44
|
+
var Ot;
|
|
45
|
+
((r) => {
|
|
46
|
+
function t(e) {
|
|
47
|
+
return typeof e.delete == "number" ? e.delete : typeof e.retain == "number" ? e.retain : typeof e.retain == "object" && e.retain !== null ? 1 : typeof e.insert == "string" ? e.insert.length : 1;
|
|
48
|
+
}
|
|
49
|
+
r.length = t;
|
|
50
|
+
})(Ot || (Ot = {}));
|
|
51
|
+
const k = Ot;
|
|
52
|
+
class R {
|
|
53
|
+
constructor(t) {
|
|
54
|
+
this.ops = t, this.index = 0, this.offset = 0;
|
|
55
|
+
}
|
|
56
|
+
hasNext() {
|
|
57
|
+
return this.peekLength() < 1 / 0;
|
|
58
|
+
}
|
|
59
|
+
next(t) {
|
|
60
|
+
t || (t = 1 / 0);
|
|
61
|
+
const e = this.ops[this.index];
|
|
62
|
+
if (e) {
|
|
63
|
+
const s = this.offset, i = k.length(e);
|
|
64
|
+
if (t >= i - s ? (t = i - s, this.index += 1, this.offset = 0) : this.offset += t, typeof e.delete == "number")
|
|
65
|
+
return { delete: t };
|
|
66
|
+
{
|
|
67
|
+
const n = {};
|
|
68
|
+
return e.attributes && (n.attributes = e.attributes), typeof e.retain == "number" ? n.retain = t : typeof e.retain == "object" && e.retain !== null ? n.retain = e.retain : typeof e.insert == "string" ? n.insert = e.insert.substr(s, t) : n.insert = e.insert, n;
|
|
69
|
+
}
|
|
70
|
+
} else
|
|
71
|
+
return { retain: 1 / 0 };
|
|
72
|
+
}
|
|
73
|
+
peek() {
|
|
74
|
+
return this.ops[this.index];
|
|
75
|
+
}
|
|
76
|
+
peekLength() {
|
|
77
|
+
return this.ops[this.index] ? k.length(this.ops[this.index]) - this.offset : 1 / 0;
|
|
78
|
+
}
|
|
79
|
+
peekType() {
|
|
80
|
+
const t = this.ops[this.index];
|
|
81
|
+
return t ? typeof t.delete == "number" ? "delete" : typeof t.retain == "number" || typeof t.retain == "object" && t.retain !== null ? "retain" : "insert" : "retain";
|
|
82
|
+
}
|
|
83
|
+
rest() {
|
|
84
|
+
if (this.hasNext()) {
|
|
85
|
+
if (this.offset === 0)
|
|
86
|
+
return this.ops.slice(this.index);
|
|
87
|
+
{
|
|
88
|
+
const t = this.offset, e = this.index, s = this.next(), i = this.ops.slice(this.index);
|
|
89
|
+
return this.offset = t, this.index = e, [s].concat(i);
|
|
90
|
+
}
|
|
91
|
+
} else return [];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const de = "\0", jt = (r, t) => {
|
|
95
|
+
if (typeof r != "object" || r === null)
|
|
96
|
+
throw new Error(`cannot retain a ${typeof r}`);
|
|
97
|
+
if (typeof t != "object" || t === null)
|
|
98
|
+
throw new Error(`cannot retain a ${typeof t}`);
|
|
99
|
+
const e = Object.keys(r)[0];
|
|
100
|
+
if (!e || e !== Object.keys(t)[0])
|
|
101
|
+
throw new Error(
|
|
102
|
+
`embed types not matched: ${e} != ${Object.keys(t)[0]}`
|
|
103
|
+
);
|
|
104
|
+
return [e, r[e], t[e]];
|
|
105
|
+
};
|
|
106
|
+
class f {
|
|
107
|
+
static {
|
|
108
|
+
this.Op = k;
|
|
109
|
+
}
|
|
110
|
+
static {
|
|
111
|
+
this.OpIterator = R;
|
|
112
|
+
}
|
|
113
|
+
static {
|
|
114
|
+
this.AttributeMap = C;
|
|
115
|
+
}
|
|
116
|
+
static {
|
|
117
|
+
this.handlers = {};
|
|
118
|
+
}
|
|
119
|
+
static registerEmbed(t, e) {
|
|
120
|
+
this.handlers[t] = e;
|
|
121
|
+
}
|
|
122
|
+
static unregisterEmbed(t) {
|
|
123
|
+
delete this.handlers[t];
|
|
124
|
+
}
|
|
125
|
+
static getHandler(t) {
|
|
126
|
+
const e = this.handlers[t];
|
|
127
|
+
if (!e)
|
|
128
|
+
throw new Error(`no handlers for embed type "${t}"`);
|
|
129
|
+
return e;
|
|
130
|
+
}
|
|
131
|
+
constructor(t) {
|
|
132
|
+
Array.isArray(t) ? this.ops = t : t != null && Array.isArray(t.ops) ? this.ops = t.ops : this.ops = [];
|
|
133
|
+
}
|
|
134
|
+
insert(t, e) {
|
|
135
|
+
const s = {};
|
|
136
|
+
return typeof t == "string" && t.length === 0 ? this : (s.insert = t, e != null && typeof e == "object" && Object.keys(e).length > 0 && (s.attributes = e), this.push(s));
|
|
137
|
+
}
|
|
138
|
+
delete(t) {
|
|
139
|
+
return t <= 0 ? this : this.push({ delete: t });
|
|
140
|
+
}
|
|
141
|
+
retain(t, e) {
|
|
142
|
+
if (typeof t == "number" && t <= 0)
|
|
143
|
+
return this;
|
|
144
|
+
const s = { retain: t };
|
|
145
|
+
return e != null && typeof e == "object" && Object.keys(e).length > 0 && (s.attributes = e), this.push(s);
|
|
146
|
+
}
|
|
147
|
+
push(t) {
|
|
148
|
+
let e = this.ops.length, s = this.ops[e - 1];
|
|
149
|
+
if (t = W(t), typeof s == "object") {
|
|
150
|
+
if (typeof t.delete == "number" && typeof s.delete == "number")
|
|
151
|
+
return this.ops[e - 1] = { delete: s.delete + t.delete }, this;
|
|
152
|
+
if (typeof s.delete == "number" && t.insert != null && (e -= 1, s = this.ops[e - 1], typeof s != "object"))
|
|
153
|
+
return this.ops.unshift(t), this;
|
|
154
|
+
if (X(t.attributes, s.attributes)) {
|
|
155
|
+
if (typeof t.insert == "string" && typeof s.insert == "string")
|
|
156
|
+
return this.ops[e - 1] = { insert: s.insert + t.insert }, typeof t.attributes == "object" && (this.ops[e - 1].attributes = t.attributes), this;
|
|
157
|
+
if (typeof t.retain == "number" && typeof s.retain == "number")
|
|
158
|
+
return this.ops[e - 1] = { retain: s.retain + t.retain }, typeof t.attributes == "object" && (this.ops[e - 1].attributes = t.attributes), this;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return e === this.ops.length ? this.ops.push(t) : this.ops.splice(e, 0, t), this;
|
|
162
|
+
}
|
|
163
|
+
chop() {
|
|
164
|
+
const t = this.ops[this.ops.length - 1];
|
|
165
|
+
return t && typeof t.retain == "number" && !t.attributes && this.ops.pop(), this;
|
|
166
|
+
}
|
|
167
|
+
filter(t) {
|
|
168
|
+
return this.ops.filter(t);
|
|
169
|
+
}
|
|
170
|
+
forEach(t) {
|
|
171
|
+
this.ops.forEach(t);
|
|
172
|
+
}
|
|
173
|
+
map(t) {
|
|
174
|
+
return this.ops.map(t);
|
|
175
|
+
}
|
|
176
|
+
partition(t) {
|
|
177
|
+
const e = [], s = [];
|
|
178
|
+
return this.forEach((i) => {
|
|
179
|
+
(t(i) ? e : s).push(i);
|
|
180
|
+
}), [e, s];
|
|
181
|
+
}
|
|
182
|
+
reduce(t, e) {
|
|
183
|
+
return this.ops.reduce(t, e);
|
|
184
|
+
}
|
|
185
|
+
changeLength() {
|
|
186
|
+
return this.reduce((t, e) => e.insert ? t + k.length(e) : e.delete ? t - e.delete : t, 0);
|
|
187
|
+
}
|
|
188
|
+
length() {
|
|
189
|
+
return this.reduce((t, e) => t + k.length(e), 0);
|
|
190
|
+
}
|
|
191
|
+
slice(t = 0, e = 1 / 0) {
|
|
192
|
+
const s = [], i = new R(this.ops);
|
|
193
|
+
let n = 0;
|
|
194
|
+
for (; n < e && i.hasNext(); ) {
|
|
195
|
+
let o;
|
|
196
|
+
n < t ? o = i.next(t - n) : (o = i.next(e - n), s.push(o)), n += k.length(o);
|
|
197
|
+
}
|
|
198
|
+
return new f(s);
|
|
199
|
+
}
|
|
200
|
+
compose(t) {
|
|
201
|
+
const e = new R(this.ops), s = new R(t.ops), i = [], n = s.peek();
|
|
202
|
+
if (n != null && typeof n.retain == "number" && n.attributes == null) {
|
|
203
|
+
let l = n.retain;
|
|
204
|
+
for (; e.peekType() === "insert" && e.peekLength() <= l; )
|
|
205
|
+
l -= e.peekLength(), i.push(e.next());
|
|
206
|
+
n.retain - l > 0 && s.next(n.retain - l);
|
|
207
|
+
}
|
|
208
|
+
const o = new f(i);
|
|
209
|
+
for (; e.hasNext() || s.hasNext(); )
|
|
210
|
+
if (s.peekType() === "insert")
|
|
211
|
+
o.push(s.next());
|
|
212
|
+
else if (e.peekType() === "delete")
|
|
213
|
+
o.push(e.next());
|
|
214
|
+
else {
|
|
215
|
+
const l = Math.min(e.peekLength(), s.peekLength()), a = e.next(l), c = s.next(l);
|
|
216
|
+
if (c.retain) {
|
|
217
|
+
const h = {};
|
|
218
|
+
if (typeof a.retain == "number")
|
|
219
|
+
h.retain = typeof c.retain == "number" ? l : c.retain;
|
|
220
|
+
else if (typeof c.retain == "number")
|
|
221
|
+
a.retain == null ? h.insert = a.insert : h.retain = a.retain;
|
|
222
|
+
else {
|
|
223
|
+
const g = a.retain == null ? "insert" : "retain", [b, N, E] = jt(
|
|
224
|
+
a[g],
|
|
225
|
+
c.retain
|
|
226
|
+
), w = f.getHandler(b);
|
|
227
|
+
h[g] = {
|
|
228
|
+
[b]: w.compose(
|
|
229
|
+
N,
|
|
230
|
+
E,
|
|
231
|
+
g === "retain"
|
|
232
|
+
)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
const d = C.compose(
|
|
236
|
+
a.attributes,
|
|
237
|
+
c.attributes,
|
|
238
|
+
typeof a.retain == "number"
|
|
239
|
+
);
|
|
240
|
+
if (d && (h.attributes = d), o.push(h), !s.hasNext() && X(o.ops[o.ops.length - 1], h)) {
|
|
241
|
+
const g = new f(e.rest());
|
|
242
|
+
return o.concat(g).chop();
|
|
243
|
+
}
|
|
244
|
+
} else typeof c.delete == "number" && (typeof a.retain == "number" || typeof a.retain == "object" && a.retain !== null) && o.push(c);
|
|
245
|
+
}
|
|
246
|
+
return o.chop();
|
|
247
|
+
}
|
|
248
|
+
concat(t) {
|
|
249
|
+
const e = new f(this.ops.slice());
|
|
250
|
+
return t.ops.length > 0 && (e.push(t.ops[0]), e.ops = e.ops.concat(t.ops.slice(1))), e;
|
|
251
|
+
}
|
|
252
|
+
diff(t, e) {
|
|
253
|
+
if (this.ops === t.ops)
|
|
254
|
+
return new f();
|
|
255
|
+
const s = [this, t].map((a) => a.map((c) => {
|
|
256
|
+
if (c.insert != null)
|
|
257
|
+
return typeof c.insert == "string" ? c.insert : de;
|
|
258
|
+
const h = a === t ? "on" : "with";
|
|
259
|
+
throw new Error("diff() called " + h + " non-document");
|
|
260
|
+
}).join("")), i = new f(), n = lt(s[0], s[1], e, !0), o = new R(this.ops), l = new R(t.ops);
|
|
261
|
+
return n.forEach((a) => {
|
|
262
|
+
let c = a[1].length;
|
|
263
|
+
for (; c > 0; ) {
|
|
264
|
+
let h = 0;
|
|
265
|
+
switch (a[0]) {
|
|
266
|
+
case lt.INSERT:
|
|
267
|
+
h = Math.min(l.peekLength(), c), i.push(l.next(h));
|
|
268
|
+
break;
|
|
269
|
+
case lt.DELETE:
|
|
270
|
+
h = Math.min(c, o.peekLength()), o.next(h), i.delete(h);
|
|
271
|
+
break;
|
|
272
|
+
case lt.EQUAL:
|
|
273
|
+
h = Math.min(
|
|
274
|
+
o.peekLength(),
|
|
275
|
+
l.peekLength(),
|
|
276
|
+
c
|
|
277
|
+
);
|
|
278
|
+
const d = o.next(h), g = l.next(h);
|
|
279
|
+
X(d.insert, g.insert) ? i.retain(
|
|
280
|
+
h,
|
|
281
|
+
C.diff(d.attributes, g.attributes)
|
|
282
|
+
) : i.push(g).delete(h);
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
c -= h;
|
|
286
|
+
}
|
|
287
|
+
}), i.chop();
|
|
288
|
+
}
|
|
289
|
+
eachLine(t, e = `
|
|
290
|
+
`) {
|
|
291
|
+
const s = new R(this.ops);
|
|
292
|
+
let i = new f(), n = 0;
|
|
293
|
+
for (; s.hasNext(); ) {
|
|
294
|
+
if (s.peekType() !== "insert")
|
|
295
|
+
return;
|
|
296
|
+
const o = s.peek(), l = k.length(o) - s.peekLength(), a = typeof o.insert == "string" ? o.insert.indexOf(e, l) - l : -1;
|
|
297
|
+
if (a < 0)
|
|
298
|
+
i.push(s.next());
|
|
299
|
+
else if (a > 0)
|
|
300
|
+
i.push(s.next(a));
|
|
301
|
+
else {
|
|
302
|
+
if (t(i, s.next(1).attributes || {}, n) === !1)
|
|
303
|
+
return;
|
|
304
|
+
n += 1, i = new f();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
i.length() > 0 && t(i, {}, n);
|
|
308
|
+
}
|
|
309
|
+
invert(t) {
|
|
310
|
+
const e = new f();
|
|
311
|
+
return this.reduce((s, i) => {
|
|
312
|
+
if (i.insert)
|
|
313
|
+
e.delete(k.length(i));
|
|
314
|
+
else {
|
|
315
|
+
if (typeof i.retain == "number" && i.attributes == null)
|
|
316
|
+
return e.retain(i.retain), s + i.retain;
|
|
317
|
+
if (i.delete || typeof i.retain == "number") {
|
|
318
|
+
const n = i.delete || i.retain;
|
|
319
|
+
return t.slice(s, s + n).forEach((l) => {
|
|
320
|
+
i.delete ? e.push(l) : i.retain && i.attributes && e.retain(
|
|
321
|
+
k.length(l),
|
|
322
|
+
C.invert(i.attributes, l.attributes)
|
|
323
|
+
);
|
|
324
|
+
}), s + n;
|
|
325
|
+
} else if (typeof i.retain == "object" && i.retain !== null) {
|
|
326
|
+
const n = t.slice(s, s + 1), o = new R(n.ops).next(), [l, a, c] = jt(
|
|
327
|
+
i.retain,
|
|
328
|
+
o.insert
|
|
329
|
+
), h = f.getHandler(l);
|
|
330
|
+
return e.retain(
|
|
331
|
+
{ [l]: h.invert(a, c) },
|
|
332
|
+
C.invert(i.attributes, o.attributes)
|
|
333
|
+
), s + 1;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return s;
|
|
337
|
+
}, 0), e.chop();
|
|
338
|
+
}
|
|
339
|
+
transform(t, e = !1) {
|
|
340
|
+
if (e = !!e, typeof t == "number")
|
|
341
|
+
return this.transformPosition(t, e);
|
|
342
|
+
const s = t, i = new R(this.ops), n = new R(s.ops), o = new f();
|
|
343
|
+
for (; i.hasNext() || n.hasNext(); )
|
|
344
|
+
if (i.peekType() === "insert" && (e || n.peekType() !== "insert"))
|
|
345
|
+
o.retain(k.length(i.next()));
|
|
346
|
+
else if (n.peekType() === "insert")
|
|
347
|
+
o.push(n.next());
|
|
348
|
+
else {
|
|
349
|
+
const l = Math.min(i.peekLength(), n.peekLength()), a = i.next(l), c = n.next(l);
|
|
350
|
+
if (a.delete)
|
|
351
|
+
continue;
|
|
352
|
+
if (c.delete)
|
|
353
|
+
o.push(c);
|
|
354
|
+
else {
|
|
355
|
+
const h = a.retain, d = c.retain;
|
|
356
|
+
let g = typeof d == "object" && d !== null ? d : l;
|
|
357
|
+
if (typeof h == "object" && h !== null && typeof d == "object" && d !== null) {
|
|
358
|
+
const b = Object.keys(h)[0];
|
|
359
|
+
if (b === Object.keys(d)[0]) {
|
|
360
|
+
const N = f.getHandler(b);
|
|
361
|
+
N && (g = {
|
|
362
|
+
[b]: N.transform(
|
|
363
|
+
h[b],
|
|
364
|
+
d[b],
|
|
365
|
+
e
|
|
366
|
+
)
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
o.retain(
|
|
371
|
+
g,
|
|
372
|
+
C.transform(
|
|
373
|
+
a.attributes,
|
|
374
|
+
c.attributes,
|
|
375
|
+
e
|
|
376
|
+
)
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return o.chop();
|
|
381
|
+
}
|
|
382
|
+
transformPosition(t, e = !1) {
|
|
383
|
+
e = !!e;
|
|
384
|
+
const s = new R(this.ops);
|
|
385
|
+
let i = 0;
|
|
386
|
+
for (; s.hasNext() && i <= t; ) {
|
|
387
|
+
const n = s.peekLength(), o = s.peekType();
|
|
388
|
+
if (s.next(), o === "delete") {
|
|
389
|
+
t -= Math.min(n, t - i);
|
|
390
|
+
continue;
|
|
391
|
+
} else o === "insert" && (i < t || !e) && (t += n);
|
|
392
|
+
i += n;
|
|
393
|
+
}
|
|
394
|
+
return t;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
var p = /* @__PURE__ */ ((r) => (r[r.TYPE = 3] = "TYPE", r[r.LEVEL = 12] = "LEVEL", r[r.ATTRIBUTE = 13] = "ATTRIBUTE", r[r.BLOT = 14] = "BLOT", r[r.INLINE = 7] = "INLINE", r[r.BLOCK = 11] = "BLOCK", r[r.BLOCK_BLOT = 10] = "BLOCK_BLOT", r[r.INLINE_BLOT = 6] = "INLINE_BLOT", r[r.BLOCK_ATTRIBUTE = 9] = "BLOCK_ATTRIBUTE", r[r.INLINE_ATTRIBUTE = 5] = "INLINE_ATTRIBUTE", r[r.ANY = 15] = "ANY", r))(p || {});
|
|
398
|
+
class pe {
|
|
399
|
+
constructor() {
|
|
400
|
+
this.head = null, this.tail = null, this.length = 0;
|
|
401
|
+
}
|
|
402
|
+
append(...t) {
|
|
403
|
+
if (this.insertBefore(t[0], null), t.length > 1) {
|
|
404
|
+
const e = t.slice(1);
|
|
405
|
+
this.append(...e);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
at(t) {
|
|
409
|
+
const e = this.iterator();
|
|
410
|
+
let s = e();
|
|
411
|
+
for (; s && t > 0; )
|
|
412
|
+
t -= 1, s = e();
|
|
413
|
+
return s;
|
|
414
|
+
}
|
|
415
|
+
contains(t) {
|
|
416
|
+
const e = this.iterator();
|
|
417
|
+
let s = e();
|
|
418
|
+
for (; s; ) {
|
|
419
|
+
if (s === t)
|
|
420
|
+
return !0;
|
|
421
|
+
s = e();
|
|
422
|
+
}
|
|
423
|
+
return !1;
|
|
424
|
+
}
|
|
425
|
+
indexOf(t) {
|
|
426
|
+
const e = this.iterator();
|
|
427
|
+
let s = e(), i = 0;
|
|
428
|
+
for (; s; ) {
|
|
429
|
+
if (s === t)
|
|
430
|
+
return i;
|
|
431
|
+
i += 1, s = e();
|
|
432
|
+
}
|
|
433
|
+
return -1;
|
|
434
|
+
}
|
|
435
|
+
insertBefore(t, e) {
|
|
436
|
+
t != null && (this.remove(t), t.next = e, e != null ? (t.prev = e.prev, e.prev != null && (e.prev.next = t), e.prev = t, e === this.head && (this.head = t)) : this.tail != null ? (this.tail.next = t, t.prev = this.tail, this.tail = t) : (t.prev = null, this.head = this.tail = t), this.length += 1);
|
|
437
|
+
}
|
|
438
|
+
offset(t) {
|
|
439
|
+
let e = 0, s = this.head;
|
|
440
|
+
for (; s != null; ) {
|
|
441
|
+
if (s === t)
|
|
442
|
+
return e;
|
|
443
|
+
e += s.length(), s = s.next;
|
|
444
|
+
}
|
|
445
|
+
return -1;
|
|
446
|
+
}
|
|
447
|
+
remove(t) {
|
|
448
|
+
this.contains(t) && (t.prev != null && (t.prev.next = t.next), t.next != null && (t.next.prev = t.prev), t === this.head && (this.head = t.next), t === this.tail && (this.tail = t.prev), this.length -= 1);
|
|
449
|
+
}
|
|
450
|
+
iterator(t = this.head) {
|
|
451
|
+
return () => {
|
|
452
|
+
const e = t;
|
|
453
|
+
return t != null && (t = t.next), e;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
find(t, e = !1) {
|
|
457
|
+
const s = this.iterator();
|
|
458
|
+
let i = s();
|
|
459
|
+
for (; i; ) {
|
|
460
|
+
const n = i.length();
|
|
461
|
+
if (t < n || e && t === n && (i.next == null || i.next.length() !== 0))
|
|
462
|
+
return [i, t];
|
|
463
|
+
t -= n, i = s();
|
|
464
|
+
}
|
|
465
|
+
return [null, 0];
|
|
466
|
+
}
|
|
467
|
+
forEach(t) {
|
|
468
|
+
const e = this.iterator();
|
|
469
|
+
let s = e();
|
|
470
|
+
for (; s; )
|
|
471
|
+
t(s), s = e();
|
|
472
|
+
}
|
|
473
|
+
forEachAt(t, e, s) {
|
|
474
|
+
if (e <= 0)
|
|
475
|
+
return;
|
|
476
|
+
const [i, n] = this.find(t);
|
|
477
|
+
let o = t - n;
|
|
478
|
+
const l = this.iterator(i);
|
|
479
|
+
let a = l();
|
|
480
|
+
for (; a && o < t + e; ) {
|
|
481
|
+
const c = a.length();
|
|
482
|
+
t > o ? s(
|
|
483
|
+
a,
|
|
484
|
+
t - o,
|
|
485
|
+
Math.min(e, o + c - t)
|
|
486
|
+
) : s(a, 0, Math.min(c, t + e - o)), o += c, a = l();
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
map(t) {
|
|
490
|
+
return this.reduce((e, s) => (e.push(t(s)), e), []);
|
|
491
|
+
}
|
|
492
|
+
reduce(t, e) {
|
|
493
|
+
const s = this.iterator();
|
|
494
|
+
let i = s();
|
|
495
|
+
for (; i; )
|
|
496
|
+
e = t(e, i), i = s();
|
|
497
|
+
return e;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
class J extends Error {
|
|
501
|
+
constructor(t) {
|
|
502
|
+
t = "[Parchment] " + t, super(t), this.message = t, this.name = this.constructor.name;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
class K {
|
|
506
|
+
constructor() {
|
|
507
|
+
this.attributes = {}, this.classes = {}, this.tags = {}, this.types = {};
|
|
508
|
+
}
|
|
509
|
+
static {
|
|
510
|
+
this.blots = /* @__PURE__ */ new WeakMap();
|
|
511
|
+
}
|
|
512
|
+
static find(t, e = !1) {
|
|
513
|
+
if (t == null)
|
|
514
|
+
return null;
|
|
515
|
+
if (this.blots.has(t))
|
|
516
|
+
return this.blots.get(t) || null;
|
|
517
|
+
if (e) {
|
|
518
|
+
let s = null;
|
|
519
|
+
try {
|
|
520
|
+
s = t.parentNode;
|
|
521
|
+
} catch {
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
524
|
+
return this.find(s, e);
|
|
525
|
+
}
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
create(t, e, s) {
|
|
529
|
+
const i = this.query(e);
|
|
530
|
+
if (i == null)
|
|
531
|
+
throw new J(`Unable to create ${e} blot`);
|
|
532
|
+
const n = i, o = e instanceof Node || e.nodeType === Node.TEXT_NODE ? e : n.create(s), l = new n(t, o, s);
|
|
533
|
+
return K.blots.set(l.domNode, l), l;
|
|
534
|
+
}
|
|
535
|
+
find(t, e = !1) {
|
|
536
|
+
return K.find(t, e);
|
|
537
|
+
}
|
|
538
|
+
query(t, e = p.ANY) {
|
|
539
|
+
let s;
|
|
540
|
+
return typeof t == "string" ? s = this.types[t] || this.attributes[t] : t instanceof Text || t.nodeType === Node.TEXT_NODE ? s = this.types.text : typeof t == "number" ? t & p.LEVEL & p.BLOCK ? s = this.types.block : t & p.LEVEL & p.INLINE && (s = this.types.inline) : t instanceof Element && ((t.getAttribute("class") || "").split(/\s+/).some((n) => (s = this.classes[n], !!s)), s = s || this.tags[t.tagName]), s == null ? null : "scope" in s && e & p.LEVEL & s.scope && e & p.TYPE & s.scope ? s : null;
|
|
541
|
+
}
|
|
542
|
+
register(...t) {
|
|
543
|
+
return t.map((e) => {
|
|
544
|
+
const s = "blotName" in e, i = "attrName" in e;
|
|
545
|
+
if (!s && !i)
|
|
546
|
+
throw new J("Invalid definition");
|
|
547
|
+
if (s && e.blotName === "abstract")
|
|
548
|
+
throw new J("Cannot register abstract class");
|
|
549
|
+
const n = s ? e.blotName : i ? e.attrName : void 0;
|
|
550
|
+
return this.types[n] = e, i ? typeof e.keyName == "string" && (this.attributes[e.keyName] = e) : s && (e.className && (this.classes[e.className] = e), e.tagName && (Array.isArray(e.tagName) ? e.tagName = e.tagName.map((l) => l.toUpperCase()) : e.tagName = e.tagName.toUpperCase(), (Array.isArray(e.tagName) ? e.tagName : [e.tagName]).forEach((l) => {
|
|
551
|
+
(this.tags[l] == null || e.className == null) && (this.tags[l] = e);
|
|
552
|
+
}))), e;
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
class ee {
|
|
557
|
+
constructor(t, e) {
|
|
558
|
+
this.scroll = t, this.domNode = e, K.blots.set(e, this), this.prev = null, this.next = null;
|
|
559
|
+
}
|
|
560
|
+
static {
|
|
561
|
+
this.blotName = "abstract";
|
|
562
|
+
}
|
|
563
|
+
static create(t) {
|
|
564
|
+
if (this.tagName == null)
|
|
565
|
+
throw new J("Blot definition missing tagName");
|
|
566
|
+
let e, s;
|
|
567
|
+
return Array.isArray(this.tagName) ? (typeof t == "string" ? (s = t.toUpperCase(), parseInt(s, 10).toString() === s && (s = parseInt(s, 10))) : typeof t == "number" && (s = t), typeof s == "number" ? e = document.createElement(this.tagName[s - 1]) : s && this.tagName.indexOf(s) > -1 ? e = document.createElement(s) : e = document.createElement(this.tagName[0])) : e = document.createElement(this.tagName), this.className && e.classList.add(this.className), e;
|
|
568
|
+
}
|
|
569
|
+
// Hack for accessing inherited static methods
|
|
570
|
+
get statics() {
|
|
571
|
+
return this.constructor;
|
|
572
|
+
}
|
|
573
|
+
attach() {
|
|
574
|
+
}
|
|
575
|
+
clone() {
|
|
576
|
+
const t = this.domNode.cloneNode(!1);
|
|
577
|
+
return this.scroll.create(t);
|
|
578
|
+
}
|
|
579
|
+
detach() {
|
|
580
|
+
this.parent != null && this.parent.removeChild(this), K.blots.delete(this.domNode);
|
|
581
|
+
}
|
|
582
|
+
deleteAt(t, e) {
|
|
583
|
+
this.isolate(t, e).remove();
|
|
584
|
+
}
|
|
585
|
+
formatAt(t, e, s, i) {
|
|
586
|
+
const n = this.isolate(t, e);
|
|
587
|
+
if (this.scroll.query(s, p.BLOT) != null && i)
|
|
588
|
+
n.wrap(s, i);
|
|
589
|
+
else if (this.scroll.query(s, p.ATTRIBUTE) != null) {
|
|
590
|
+
const o = this.scroll.create(this.statics.scope);
|
|
591
|
+
n.wrap(o), o.format(s, i);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
insertAt(t, e, s) {
|
|
595
|
+
const i = s == null ? this.scroll.create("text", e) : this.scroll.create(e, s), n = this.split(t);
|
|
596
|
+
this.parent.insertBefore(i, n || void 0);
|
|
597
|
+
}
|
|
598
|
+
isolate(t, e) {
|
|
599
|
+
const s = this.split(t);
|
|
600
|
+
if (s == null)
|
|
601
|
+
throw new Error("Attempt to isolate at end");
|
|
602
|
+
return s.split(e), s;
|
|
603
|
+
}
|
|
604
|
+
length() {
|
|
605
|
+
return 1;
|
|
606
|
+
}
|
|
607
|
+
offset(t = this.parent) {
|
|
608
|
+
return this.parent == null || this === t ? 0 : this.parent.children.offset(this) + this.parent.offset(t);
|
|
609
|
+
}
|
|
610
|
+
optimize(t) {
|
|
611
|
+
this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer) && this.wrap(this.statics.requiredContainer.blotName);
|
|
612
|
+
}
|
|
613
|
+
remove() {
|
|
614
|
+
this.domNode.parentNode != null && this.domNode.parentNode.removeChild(this.domNode), this.detach();
|
|
615
|
+
}
|
|
616
|
+
replaceWith(t, e) {
|
|
617
|
+
const s = typeof t == "string" ? this.scroll.create(t, e) : t;
|
|
618
|
+
return this.parent != null && (this.parent.insertBefore(s, this.next || void 0), this.remove()), s;
|
|
619
|
+
}
|
|
620
|
+
split(t, e) {
|
|
621
|
+
return t === 0 ? this : this.next;
|
|
622
|
+
}
|
|
623
|
+
update(t, e) {
|
|
624
|
+
}
|
|
625
|
+
wrap(t, e) {
|
|
626
|
+
const s = typeof t == "string" ? this.scroll.create(t, e) : t;
|
|
627
|
+
if (this.parent != null && this.parent.insertBefore(s, this.next || void 0), typeof s.appendChild != "function")
|
|
628
|
+
throw new J(`Cannot wrap ${t}`);
|
|
629
|
+
return s.appendChild(this), s;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
function $t(r, t) {
|
|
633
|
+
const e = t.find(r);
|
|
634
|
+
if (e) return e;
|
|
635
|
+
try {
|
|
636
|
+
return t.create(r);
|
|
637
|
+
} catch {
|
|
638
|
+
const i = t.create(p.INLINE);
|
|
639
|
+
return Array.from(r.childNodes).forEach((n) => {
|
|
640
|
+
i.domNode.appendChild(n);
|
|
641
|
+
}), r.parentNode && r.parentNode.replaceChild(i.domNode, r), i.attach(), i;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
class T extends ee {
|
|
645
|
+
constructor(t, e) {
|
|
646
|
+
super(t, e), this.uiNode = null, this.build();
|
|
647
|
+
}
|
|
648
|
+
static {
|
|
649
|
+
this.uiClass = "";
|
|
650
|
+
}
|
|
651
|
+
appendChild(t) {
|
|
652
|
+
this.insertBefore(t);
|
|
653
|
+
}
|
|
654
|
+
attach() {
|
|
655
|
+
super.attach(), this.children.forEach((t) => {
|
|
656
|
+
t.attach();
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
attachUI(t) {
|
|
660
|
+
this.uiNode != null && this.uiNode.remove(), this.uiNode = t, T.uiClass && this.uiNode.classList.add(T.uiClass), this.uiNode.setAttribute("contenteditable", "false"), this.domNode.insertBefore(this.uiNode, this.domNode.firstChild);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Called during construction, should fill its own children LinkedList.
|
|
664
|
+
*/
|
|
665
|
+
build() {
|
|
666
|
+
this.children = new pe(), Array.from(this.domNode.childNodes).filter((t) => t !== this.uiNode).reverse().forEach((t) => {
|
|
667
|
+
try {
|
|
668
|
+
const e = $t(t, this.scroll);
|
|
669
|
+
this.insertBefore(e, this.children.head || void 0);
|
|
670
|
+
} catch (e) {
|
|
671
|
+
if (e instanceof J)
|
|
672
|
+
return;
|
|
673
|
+
throw e;
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
deleteAt(t, e) {
|
|
678
|
+
if (t === 0 && e === this.length())
|
|
679
|
+
return this.remove();
|
|
680
|
+
this.children.forEachAt(t, e, (s, i, n) => {
|
|
681
|
+
s.deleteAt(i, n);
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
descendant(t, e = 0) {
|
|
685
|
+
const [s, i] = this.children.find(e);
|
|
686
|
+
return t.blotName == null && t(s) || t.blotName != null && s instanceof t ? [s, i] : s instanceof T ? s.descendant(t, i) : [null, -1];
|
|
687
|
+
}
|
|
688
|
+
descendants(t, e = 0, s = Number.MAX_VALUE) {
|
|
689
|
+
let i = [], n = s;
|
|
690
|
+
return this.children.forEachAt(
|
|
691
|
+
e,
|
|
692
|
+
s,
|
|
693
|
+
(o, l, a) => {
|
|
694
|
+
(t.blotName == null && t(o) || t.blotName != null && o instanceof t) && i.push(o), o instanceof T && (i = i.concat(
|
|
695
|
+
o.descendants(t, l, n)
|
|
696
|
+
)), n -= a;
|
|
697
|
+
}
|
|
698
|
+
), i;
|
|
699
|
+
}
|
|
700
|
+
detach() {
|
|
701
|
+
this.children.forEach((t) => {
|
|
702
|
+
t.detach();
|
|
703
|
+
}), super.detach();
|
|
704
|
+
}
|
|
705
|
+
enforceAllowedChildren() {
|
|
706
|
+
let t = !1;
|
|
707
|
+
this.children.forEach((e) => {
|
|
708
|
+
t || this.statics.allowedChildren.some(
|
|
709
|
+
(i) => e instanceof i
|
|
710
|
+
) || (e.statics.scope === p.BLOCK_BLOT ? (e.next != null && this.splitAfter(e), e.prev != null && this.splitAfter(e.prev), e.parent.unwrap(), t = !0) : e instanceof T ? e.unwrap() : e.remove());
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
formatAt(t, e, s, i) {
|
|
714
|
+
this.children.forEachAt(t, e, (n, o, l) => {
|
|
715
|
+
n.formatAt(o, l, s, i);
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
insertAt(t, e, s) {
|
|
719
|
+
const [i, n] = this.children.find(t);
|
|
720
|
+
if (i)
|
|
721
|
+
i.insertAt(n, e, s);
|
|
722
|
+
else {
|
|
723
|
+
const o = s == null ? this.scroll.create("text", e) : this.scroll.create(e, s);
|
|
724
|
+
this.appendChild(o);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
insertBefore(t, e) {
|
|
728
|
+
t.parent != null && t.parent.children.remove(t);
|
|
729
|
+
let s = null;
|
|
730
|
+
this.children.insertBefore(t, e || null), t.parent = this, e != null && (s = e.domNode), (this.domNode.parentNode !== t.domNode || this.domNode.nextSibling !== s) && this.domNode.insertBefore(t.domNode, s), t.attach();
|
|
731
|
+
}
|
|
732
|
+
length() {
|
|
733
|
+
return this.children.reduce((t, e) => t + e.length(), 0);
|
|
734
|
+
}
|
|
735
|
+
moveChildren(t, e) {
|
|
736
|
+
this.children.forEach((s) => {
|
|
737
|
+
t.insertBefore(s, e);
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
optimize(t) {
|
|
741
|
+
if (super.optimize(t), this.enforceAllowedChildren(), this.uiNode != null && this.uiNode !== this.domNode.firstChild && this.domNode.insertBefore(this.uiNode, this.domNode.firstChild), this.children.length === 0)
|
|
742
|
+
if (this.statics.defaultChild != null) {
|
|
743
|
+
const e = this.scroll.create(this.statics.defaultChild.blotName);
|
|
744
|
+
this.appendChild(e);
|
|
745
|
+
} else
|
|
746
|
+
this.remove();
|
|
747
|
+
}
|
|
748
|
+
path(t, e = !1) {
|
|
749
|
+
const [s, i] = this.children.find(t, e), n = [[this, t]];
|
|
750
|
+
return s instanceof T ? n.concat(s.path(i, e)) : (s != null && n.push([s, i]), n);
|
|
751
|
+
}
|
|
752
|
+
removeChild(t) {
|
|
753
|
+
this.children.remove(t);
|
|
754
|
+
}
|
|
755
|
+
replaceWith(t, e) {
|
|
756
|
+
const s = typeof t == "string" ? this.scroll.create(t, e) : t;
|
|
757
|
+
return s instanceof T && this.moveChildren(s), super.replaceWith(s);
|
|
758
|
+
}
|
|
759
|
+
split(t, e = !1) {
|
|
760
|
+
if (!e) {
|
|
761
|
+
if (t === 0)
|
|
762
|
+
return this;
|
|
763
|
+
if (t === this.length())
|
|
764
|
+
return this.next;
|
|
765
|
+
}
|
|
766
|
+
const s = this.clone();
|
|
767
|
+
return this.parent && this.parent.insertBefore(s, this.next || void 0), this.children.forEachAt(t, this.length(), (i, n, o) => {
|
|
768
|
+
const l = i.split(n, e);
|
|
769
|
+
l != null && s.appendChild(l);
|
|
770
|
+
}), s;
|
|
771
|
+
}
|
|
772
|
+
splitAfter(t) {
|
|
773
|
+
const e = this.clone();
|
|
774
|
+
for (; t.next != null; )
|
|
775
|
+
e.appendChild(t.next);
|
|
776
|
+
return this.parent && this.parent.insertBefore(e, this.next || void 0), e;
|
|
777
|
+
}
|
|
778
|
+
unwrap() {
|
|
779
|
+
this.parent && this.moveChildren(this.parent, this.next || void 0), this.remove();
|
|
780
|
+
}
|
|
781
|
+
update(t, e) {
|
|
782
|
+
const s = [], i = [];
|
|
783
|
+
t.forEach((n) => {
|
|
784
|
+
n.target === this.domNode && n.type === "childList" && (s.push(...n.addedNodes), i.push(...n.removedNodes));
|
|
785
|
+
}), i.forEach((n) => {
|
|
786
|
+
if (n.parentNode != null && n.tagName !== "IFRAME" && document.body.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_CONTAINED_BY)
|
|
787
|
+
return;
|
|
788
|
+
const o = this.scroll.find(n);
|
|
789
|
+
o != null && (o.domNode.parentNode == null || o.domNode.parentNode === this.domNode) && o.detach();
|
|
790
|
+
}), s.filter((n) => n.parentNode === this.domNode && n !== this.uiNode).sort((n, o) => n === o ? 0 : n.compareDocumentPosition(o) & Node.DOCUMENT_POSITION_FOLLOWING ? 1 : -1).forEach((n) => {
|
|
791
|
+
let o = null;
|
|
792
|
+
n.nextSibling != null && (o = this.scroll.find(n.nextSibling));
|
|
793
|
+
const l = $t(n, this.scroll);
|
|
794
|
+
(l.next !== o || l.next == null) && (l.parent != null && l.parent.removeChild(this), this.insertBefore(l, o || void 0));
|
|
795
|
+
}), this.enforceAllowedChildren();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
class dt extends T {
|
|
799
|
+
static {
|
|
800
|
+
this.blotName = "container";
|
|
801
|
+
}
|
|
802
|
+
static {
|
|
803
|
+
this.scope = p.BLOCK_BLOT;
|
|
804
|
+
}
|
|
805
|
+
checkMerge() {
|
|
806
|
+
return this.next !== null && this.next.statics.blotName === this.statics.blotName;
|
|
807
|
+
}
|
|
808
|
+
deleteAt(t, e) {
|
|
809
|
+
super.deleteAt(t, e), this.enforceAllowedChildren();
|
|
810
|
+
}
|
|
811
|
+
formatAt(t, e, s, i) {
|
|
812
|
+
super.formatAt(t, e, s, i), this.enforceAllowedChildren();
|
|
813
|
+
}
|
|
814
|
+
insertAt(t, e, s) {
|
|
815
|
+
super.insertAt(t, e, s), this.enforceAllowedChildren();
|
|
816
|
+
}
|
|
817
|
+
optimize(t) {
|
|
818
|
+
super.optimize(t), this.children.length > 0 && this.next != null && this.checkMerge() && (this.next.moveChildren(this), this.next.remove());
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
class A extends ee {
|
|
822
|
+
static {
|
|
823
|
+
this.scope = p.INLINE_BLOT;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Returns the value represented by domNode if it is this Blot's type
|
|
827
|
+
* No checking that domNode can represent this Blot type is required so
|
|
828
|
+
* applications needing it should check externally before calling.
|
|
829
|
+
*/
|
|
830
|
+
static value(t) {
|
|
831
|
+
return !0;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Given location represented by node and offset from DOM Selection Range,
|
|
835
|
+
* return index to that location.
|
|
836
|
+
*/
|
|
837
|
+
index(t, e) {
|
|
838
|
+
return this.domNode === t || this.domNode.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_CONTAINED_BY ? Math.min(e, 1) : -1;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Given index to location within blot, return node and offset representing
|
|
842
|
+
* that location, consumable by DOM Selection Range
|
|
843
|
+
*/
|
|
844
|
+
position(t, e) {
|
|
845
|
+
let i = Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);
|
|
846
|
+
return t > 0 && (i += 1), [this.parent.domNode, i];
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Return value represented by this blot
|
|
850
|
+
* Should not change without interaction from API or
|
|
851
|
+
* user change detectable by update()
|
|
852
|
+
*/
|
|
853
|
+
value() {
|
|
854
|
+
return {
|
|
855
|
+
[this.statics.blotName]: this.statics.value(this.domNode) || !0
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
class j {
|
|
860
|
+
constructor(t, e, s = {}) {
|
|
861
|
+
this.attrName = t, this.keyName = e;
|
|
862
|
+
const i = p.TYPE & p.ATTRIBUTE;
|
|
863
|
+
this.scope = s.scope != null ? (
|
|
864
|
+
// Ignore type bits, force attribute bit
|
|
865
|
+
s.scope & p.LEVEL | i
|
|
866
|
+
) : p.ATTRIBUTE, s.whitelist != null && (this.whitelist = s.whitelist);
|
|
867
|
+
}
|
|
868
|
+
static keys(t) {
|
|
869
|
+
return Array.from(t.attributes).map((e) => e.name);
|
|
870
|
+
}
|
|
871
|
+
add(t, e) {
|
|
872
|
+
return this.canAdd(t, e) ? (t.setAttribute(this.keyName, e), !0) : !1;
|
|
873
|
+
}
|
|
874
|
+
canAdd(t, e) {
|
|
875
|
+
return this.whitelist == null ? !0 : typeof e == "string" ? this.whitelist.indexOf(e.replace(/["']/g, "")) > -1 : this.whitelist.indexOf(e) > -1;
|
|
876
|
+
}
|
|
877
|
+
remove(t) {
|
|
878
|
+
t.removeAttribute(this.keyName);
|
|
879
|
+
}
|
|
880
|
+
value(t) {
|
|
881
|
+
const e = t.getAttribute(this.keyName);
|
|
882
|
+
return this.canAdd(t, e) && e ? e : "";
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function Ft(r, t) {
|
|
886
|
+
return (r.getAttribute("class") || "").split(/\s+/).filter((s) => s.indexOf(`${t}-`) === 0);
|
|
887
|
+
}
|
|
888
|
+
class q extends j {
|
|
889
|
+
static keys(t) {
|
|
890
|
+
return (t.getAttribute("class") || "").split(/\s+/).map((e) => e.split("-").slice(0, -1).join("-"));
|
|
891
|
+
}
|
|
892
|
+
add(t, e) {
|
|
893
|
+
return this.canAdd(t, e) ? (this.remove(t), t.classList.add(`${this.keyName}-${e}`), !0) : !1;
|
|
894
|
+
}
|
|
895
|
+
remove(t) {
|
|
896
|
+
Ft(t, this.keyName).forEach((s) => {
|
|
897
|
+
t.classList.remove(s);
|
|
898
|
+
}), t.classList.length === 0 && t.removeAttribute("class");
|
|
899
|
+
}
|
|
900
|
+
value(t) {
|
|
901
|
+
const s = (Ft(t, this.keyName)[0] || "").slice(this.keyName.length + 1);
|
|
902
|
+
return this.canAdd(t, s) ? s : "";
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function bt(r) {
|
|
906
|
+
const t = r.split("-"), e = t.slice(1).map((s) => s[0].toUpperCase() + s.slice(1)).join("");
|
|
907
|
+
return t[0] + e;
|
|
908
|
+
}
|
|
909
|
+
class V extends j {
|
|
910
|
+
static keys(t) {
|
|
911
|
+
return (t.getAttribute("style") || "").split(";").map((e) => e.split(":")[0].trim());
|
|
912
|
+
}
|
|
913
|
+
add(t, e) {
|
|
914
|
+
return this.canAdd(t, e) ? (t.style[bt(this.keyName)] = e, !0) : !1;
|
|
915
|
+
}
|
|
916
|
+
remove(t) {
|
|
917
|
+
t.style[bt(this.keyName)] = "", t.getAttribute("style") || t.removeAttribute("style");
|
|
918
|
+
}
|
|
919
|
+
value(t) {
|
|
920
|
+
const e = t.style[bt(this.keyName)];
|
|
921
|
+
return this.canAdd(t, e) ? e : "";
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
class pt {
|
|
925
|
+
constructor(t) {
|
|
926
|
+
this.attributes = {}, this.domNode = t, this.build();
|
|
927
|
+
}
|
|
928
|
+
attribute(t, e) {
|
|
929
|
+
e ? t.add(this.domNode, e) && (t.value(this.domNode) != null ? this.attributes[t.attrName] = t : delete this.attributes[t.attrName]) : (t.remove(this.domNode), delete this.attributes[t.attrName]);
|
|
930
|
+
}
|
|
931
|
+
build() {
|
|
932
|
+
this.attributes = {};
|
|
933
|
+
const t = K.find(this.domNode);
|
|
934
|
+
if (t == null)
|
|
935
|
+
return;
|
|
936
|
+
const e = j.keys(this.domNode), s = q.keys(this.domNode), i = V.keys(this.domNode);
|
|
937
|
+
e.concat(s).concat(i).forEach((n) => {
|
|
938
|
+
const o = t.scroll.query(n, p.ATTRIBUTE);
|
|
939
|
+
o instanceof j && (this.attributes[o.attrName] = o);
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
copy(t) {
|
|
943
|
+
Object.keys(this.attributes).forEach((e) => {
|
|
944
|
+
const s = this.attributes[e].value(this.domNode);
|
|
945
|
+
t.format(e, s);
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
move(t) {
|
|
949
|
+
this.copy(t), Object.keys(this.attributes).forEach((e) => {
|
|
950
|
+
this.attributes[e].remove(this.domNode);
|
|
951
|
+
}), this.attributes = {};
|
|
952
|
+
}
|
|
953
|
+
values() {
|
|
954
|
+
return Object.keys(this.attributes).reduce(
|
|
955
|
+
(t, e) => (t[e] = this.attributes[e].value(this.domNode), t),
|
|
956
|
+
{}
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
function me(r, t) {
|
|
961
|
+
if (Object.keys(r).length !== Object.keys(t).length)
|
|
962
|
+
return !1;
|
|
963
|
+
for (const e in r)
|
|
964
|
+
if (r[e] !== t[e])
|
|
965
|
+
return !1;
|
|
966
|
+
return !0;
|
|
967
|
+
}
|
|
968
|
+
class D extends T {
|
|
969
|
+
static {
|
|
970
|
+
this.allowedChildren = [D, A];
|
|
971
|
+
}
|
|
972
|
+
static {
|
|
973
|
+
this.blotName = "inline";
|
|
974
|
+
}
|
|
975
|
+
static {
|
|
976
|
+
this.scope = p.INLINE_BLOT;
|
|
977
|
+
}
|
|
978
|
+
static {
|
|
979
|
+
this.tagName = "SPAN";
|
|
980
|
+
}
|
|
981
|
+
static create(t) {
|
|
982
|
+
return super.create(t);
|
|
983
|
+
}
|
|
984
|
+
static formats(t, e) {
|
|
985
|
+
const s = e.query(D.blotName);
|
|
986
|
+
if (!(s != null && t.tagName === s.tagName)) {
|
|
987
|
+
if (typeof this.tagName == "string")
|
|
988
|
+
return !0;
|
|
989
|
+
if (Array.isArray(this.tagName))
|
|
990
|
+
return t.tagName.toLowerCase();
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
constructor(t, e) {
|
|
994
|
+
super(t, e), this.attributes = new pt(this.domNode);
|
|
995
|
+
}
|
|
996
|
+
format(t, e) {
|
|
997
|
+
if (t === this.statics.blotName && !e)
|
|
998
|
+
this.children.forEach((s) => {
|
|
999
|
+
s instanceof D || (s = s.wrap(D.blotName, !0)), this.attributes.copy(s);
|
|
1000
|
+
}), this.unwrap();
|
|
1001
|
+
else {
|
|
1002
|
+
const s = this.scroll.query(t, p.INLINE);
|
|
1003
|
+
if (s == null)
|
|
1004
|
+
return;
|
|
1005
|
+
s instanceof j ? this.attributes.attribute(s, e) : e && (t !== this.statics.blotName || this.formats()[t] !== e) && this.replaceWith(t, e);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
formats() {
|
|
1009
|
+
const t = this.attributes.values(), e = this.statics.formats(this.domNode, this.scroll);
|
|
1010
|
+
return e != null && (t[this.statics.blotName] = e), t;
|
|
1011
|
+
}
|
|
1012
|
+
formatAt(t, e, s, i) {
|
|
1013
|
+
this.formats()[s] != null || this.scroll.query(s, p.ATTRIBUTE) ? this.isolate(t, e).format(s, i) : super.formatAt(t, e, s, i);
|
|
1014
|
+
}
|
|
1015
|
+
optimize(t) {
|
|
1016
|
+
super.optimize(t);
|
|
1017
|
+
const e = this.formats();
|
|
1018
|
+
if (Object.keys(e).length === 0)
|
|
1019
|
+
return this.unwrap();
|
|
1020
|
+
const s = this.next;
|
|
1021
|
+
s instanceof D && s.prev === this && me(e, s.formats()) && (s.moveChildren(this), s.remove());
|
|
1022
|
+
}
|
|
1023
|
+
replaceWith(t, e) {
|
|
1024
|
+
const s = super.replaceWith(t, e);
|
|
1025
|
+
return this.attributes.copy(s), s;
|
|
1026
|
+
}
|
|
1027
|
+
update(t, e) {
|
|
1028
|
+
super.update(t, e), t.some(
|
|
1029
|
+
(i) => i.target === this.domNode && i.type === "attributes"
|
|
1030
|
+
) && this.attributes.build();
|
|
1031
|
+
}
|
|
1032
|
+
wrap(t, e) {
|
|
1033
|
+
const s = super.wrap(t, e);
|
|
1034
|
+
return s instanceof D && this.attributes.move(s), s;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
class _ extends T {
|
|
1038
|
+
static {
|
|
1039
|
+
this.blotName = "block";
|
|
1040
|
+
}
|
|
1041
|
+
static {
|
|
1042
|
+
this.scope = p.BLOCK_BLOT;
|
|
1043
|
+
}
|
|
1044
|
+
static {
|
|
1045
|
+
this.tagName = "P";
|
|
1046
|
+
}
|
|
1047
|
+
static {
|
|
1048
|
+
this.allowedChildren = [
|
|
1049
|
+
D,
|
|
1050
|
+
_,
|
|
1051
|
+
A
|
|
1052
|
+
];
|
|
1053
|
+
}
|
|
1054
|
+
static create(t) {
|
|
1055
|
+
return super.create(t);
|
|
1056
|
+
}
|
|
1057
|
+
static formats(t, e) {
|
|
1058
|
+
const s = e.query(_.blotName);
|
|
1059
|
+
if (!(s != null && t.tagName === s.tagName)) {
|
|
1060
|
+
if (typeof this.tagName == "string")
|
|
1061
|
+
return !0;
|
|
1062
|
+
if (Array.isArray(this.tagName))
|
|
1063
|
+
return t.tagName.toLowerCase();
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
constructor(t, e) {
|
|
1067
|
+
super(t, e), this.attributes = new pt(this.domNode);
|
|
1068
|
+
}
|
|
1069
|
+
format(t, e) {
|
|
1070
|
+
const s = this.scroll.query(t, p.BLOCK);
|
|
1071
|
+
s != null && (s instanceof j ? this.attributes.attribute(s, e) : t === this.statics.blotName && !e ? this.replaceWith(_.blotName) : e && (t !== this.statics.blotName || this.formats()[t] !== e) && this.replaceWith(t, e));
|
|
1072
|
+
}
|
|
1073
|
+
formats() {
|
|
1074
|
+
const t = this.attributes.values(), e = this.statics.formats(this.domNode, this.scroll);
|
|
1075
|
+
return e != null && (t[this.statics.blotName] = e), t;
|
|
1076
|
+
}
|
|
1077
|
+
formatAt(t, e, s, i) {
|
|
1078
|
+
this.scroll.query(s, p.BLOCK) != null ? this.format(s, i) : super.formatAt(t, e, s, i);
|
|
1079
|
+
}
|
|
1080
|
+
insertAt(t, e, s) {
|
|
1081
|
+
if (s == null || this.scroll.query(e, p.INLINE) != null)
|
|
1082
|
+
super.insertAt(t, e, s);
|
|
1083
|
+
else {
|
|
1084
|
+
const i = this.split(t);
|
|
1085
|
+
if (i != null) {
|
|
1086
|
+
const n = this.scroll.create(e, s);
|
|
1087
|
+
i.parent.insertBefore(n, i);
|
|
1088
|
+
} else
|
|
1089
|
+
throw new Error("Attempt to insertAt after block boundaries");
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
replaceWith(t, e) {
|
|
1093
|
+
const s = super.replaceWith(t, e);
|
|
1094
|
+
return this.attributes.copy(s), s;
|
|
1095
|
+
}
|
|
1096
|
+
update(t, e) {
|
|
1097
|
+
super.update(t, e), t.some(
|
|
1098
|
+
(i) => i.target === this.domNode && i.type === "attributes"
|
|
1099
|
+
) && this.attributes.build();
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
class B extends A {
|
|
1103
|
+
static formats(t, e) {
|
|
1104
|
+
}
|
|
1105
|
+
format(t, e) {
|
|
1106
|
+
super.formatAt(0, this.length(), t, e);
|
|
1107
|
+
}
|
|
1108
|
+
formatAt(t, e, s, i) {
|
|
1109
|
+
t === 0 && e === this.length() ? this.format(s, i) : super.formatAt(t, e, s, i);
|
|
1110
|
+
}
|
|
1111
|
+
formats() {
|
|
1112
|
+
return this.statics.formats(this.domNode, this.scroll);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
const ge = {
|
|
1116
|
+
attributes: !0,
|
|
1117
|
+
characterData: !0,
|
|
1118
|
+
characterDataOldValue: !0,
|
|
1119
|
+
childList: !0,
|
|
1120
|
+
subtree: !0
|
|
1121
|
+
}, be = 100;
|
|
1122
|
+
class It extends T {
|
|
1123
|
+
constructor(t, e) {
|
|
1124
|
+
super(null, e), this.registry = t, this.scroll = this, this.build(), this.observer = new MutationObserver((s) => {
|
|
1125
|
+
this.update(s);
|
|
1126
|
+
}), this.observer.observe(this.domNode, ge), this.attach();
|
|
1127
|
+
}
|
|
1128
|
+
static {
|
|
1129
|
+
this.blotName = "scroll";
|
|
1130
|
+
}
|
|
1131
|
+
static {
|
|
1132
|
+
this.defaultChild = _;
|
|
1133
|
+
}
|
|
1134
|
+
static {
|
|
1135
|
+
this.allowedChildren = [_, dt];
|
|
1136
|
+
}
|
|
1137
|
+
static {
|
|
1138
|
+
this.scope = p.BLOCK_BLOT;
|
|
1139
|
+
}
|
|
1140
|
+
static {
|
|
1141
|
+
this.tagName = "DIV";
|
|
1142
|
+
}
|
|
1143
|
+
create(t, e) {
|
|
1144
|
+
return this.registry.create(this, t, e);
|
|
1145
|
+
}
|
|
1146
|
+
find(t, e = !1) {
|
|
1147
|
+
const s = this.registry.find(t, e);
|
|
1148
|
+
return s ? s.scroll === this ? s : e ? this.find(s.scroll.domNode.parentNode, !0) : null : null;
|
|
1149
|
+
}
|
|
1150
|
+
query(t, e = p.ANY) {
|
|
1151
|
+
return this.registry.query(t, e);
|
|
1152
|
+
}
|
|
1153
|
+
register(...t) {
|
|
1154
|
+
return this.registry.register(...t);
|
|
1155
|
+
}
|
|
1156
|
+
build() {
|
|
1157
|
+
this.scroll != null && super.build();
|
|
1158
|
+
}
|
|
1159
|
+
detach() {
|
|
1160
|
+
super.detach(), this.observer.disconnect();
|
|
1161
|
+
}
|
|
1162
|
+
deleteAt(t, e) {
|
|
1163
|
+
this.update(), t === 0 && e === this.length() ? this.children.forEach((s) => {
|
|
1164
|
+
s.remove();
|
|
1165
|
+
}) : super.deleteAt(t, e);
|
|
1166
|
+
}
|
|
1167
|
+
formatAt(t, e, s, i) {
|
|
1168
|
+
this.update(), super.formatAt(t, e, s, i);
|
|
1169
|
+
}
|
|
1170
|
+
insertAt(t, e, s) {
|
|
1171
|
+
this.update(), super.insertAt(t, e, s);
|
|
1172
|
+
}
|
|
1173
|
+
optimize(t = [], e = {}) {
|
|
1174
|
+
super.optimize(e);
|
|
1175
|
+
const s = e.mutationsMap || /* @__PURE__ */ new WeakMap();
|
|
1176
|
+
let i = Array.from(this.observer.takeRecords());
|
|
1177
|
+
for (; i.length > 0; )
|
|
1178
|
+
t.push(i.pop());
|
|
1179
|
+
const n = (a, c = !0) => {
|
|
1180
|
+
a == null || a === this || a.domNode.parentNode != null && (s.has(a.domNode) || s.set(a.domNode, []), c && n(a.parent));
|
|
1181
|
+
}, o = (a) => {
|
|
1182
|
+
s.has(a.domNode) && (a instanceof T && a.children.forEach(o), s.delete(a.domNode), a.optimize(e));
|
|
1183
|
+
};
|
|
1184
|
+
let l = t;
|
|
1185
|
+
for (let a = 0; l.length > 0; a += 1) {
|
|
1186
|
+
if (a >= be)
|
|
1187
|
+
throw new Error("[Parchment] Maximum optimize iterations reached");
|
|
1188
|
+
for (l.forEach((c) => {
|
|
1189
|
+
const h = this.find(c.target, !0);
|
|
1190
|
+
h != null && (h.domNode === c.target && (c.type === "childList" ? (n(this.find(c.previousSibling, !1)), Array.from(c.addedNodes).forEach((d) => {
|
|
1191
|
+
const g = this.find(d, !1);
|
|
1192
|
+
n(g, !1), g instanceof T && g.children.forEach((b) => {
|
|
1193
|
+
n(b, !1);
|
|
1194
|
+
});
|
|
1195
|
+
})) : c.type === "attributes" && n(h.prev)), n(h));
|
|
1196
|
+
}), this.children.forEach(o), l = Array.from(this.observer.takeRecords()), i = l.slice(); i.length > 0; )
|
|
1197
|
+
t.push(i.pop());
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
update(t, e = {}) {
|
|
1201
|
+
t = t || this.observer.takeRecords();
|
|
1202
|
+
const s = /* @__PURE__ */ new WeakMap();
|
|
1203
|
+
t.map((i) => {
|
|
1204
|
+
const n = this.find(i.target, !0);
|
|
1205
|
+
return n == null ? null : s.has(n.domNode) ? (s.get(n.domNode).push(i), null) : (s.set(n.domNode, [i]), n);
|
|
1206
|
+
}).forEach((i) => {
|
|
1207
|
+
i != null && i !== this && s.has(i.domNode) && i.update(s.get(i.domNode) || [], e);
|
|
1208
|
+
}), e.mutationsMap = s, s.has(this.domNode) && super.update(s.get(this.domNode), e), this.optimize(t, e);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
class et extends A {
|
|
1212
|
+
static {
|
|
1213
|
+
this.blotName = "text";
|
|
1214
|
+
}
|
|
1215
|
+
static {
|
|
1216
|
+
this.scope = p.INLINE_BLOT;
|
|
1217
|
+
}
|
|
1218
|
+
static create(t) {
|
|
1219
|
+
return document.createTextNode(t);
|
|
1220
|
+
}
|
|
1221
|
+
static value(t) {
|
|
1222
|
+
return t.data;
|
|
1223
|
+
}
|
|
1224
|
+
constructor(t, e) {
|
|
1225
|
+
super(t, e), this.text = this.statics.value(this.domNode);
|
|
1226
|
+
}
|
|
1227
|
+
deleteAt(t, e) {
|
|
1228
|
+
this.domNode.data = this.text = this.text.slice(0, t) + this.text.slice(t + e);
|
|
1229
|
+
}
|
|
1230
|
+
index(t, e) {
|
|
1231
|
+
return this.domNode === t ? e : -1;
|
|
1232
|
+
}
|
|
1233
|
+
insertAt(t, e, s) {
|
|
1234
|
+
s == null ? (this.text = this.text.slice(0, t) + e + this.text.slice(t), this.domNode.data = this.text) : super.insertAt(t, e, s);
|
|
1235
|
+
}
|
|
1236
|
+
length() {
|
|
1237
|
+
return this.text.length;
|
|
1238
|
+
}
|
|
1239
|
+
optimize(t) {
|
|
1240
|
+
super.optimize(t), this.text = this.statics.value(this.domNode), this.text.length === 0 ? this.remove() : this.next instanceof et && this.next.prev === this && (this.insertAt(this.length(), this.next.value()), this.next.remove());
|
|
1241
|
+
}
|
|
1242
|
+
position(t, e = !1) {
|
|
1243
|
+
return [this.domNode, t];
|
|
1244
|
+
}
|
|
1245
|
+
split(t, e = !1) {
|
|
1246
|
+
if (!e) {
|
|
1247
|
+
if (t === 0)
|
|
1248
|
+
return this;
|
|
1249
|
+
if (t === this.length())
|
|
1250
|
+
return this.next;
|
|
1251
|
+
}
|
|
1252
|
+
const s = this.scroll.create(this.domNode.splitText(t));
|
|
1253
|
+
return this.parent.insertBefore(s, this.next || void 0), this.text = this.statics.value(this.domNode), s;
|
|
1254
|
+
}
|
|
1255
|
+
update(t, e) {
|
|
1256
|
+
t.some((s) => s.type === "characterData" && s.target === this.domNode) && (this.text = this.statics.value(this.domNode));
|
|
1257
|
+
}
|
|
1258
|
+
value() {
|
|
1259
|
+
return this.text;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
const Ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1263
|
+
__proto__: null,
|
|
1264
|
+
Attributor: j,
|
|
1265
|
+
AttributorStore: pt,
|
|
1266
|
+
BlockBlot: _,
|
|
1267
|
+
ClassAttributor: q,
|
|
1268
|
+
ContainerBlot: dt,
|
|
1269
|
+
EmbedBlot: B,
|
|
1270
|
+
InlineBlot: D,
|
|
1271
|
+
LeafBlot: A,
|
|
1272
|
+
ParentBlot: T,
|
|
1273
|
+
Registry: K,
|
|
1274
|
+
Scope: p,
|
|
1275
|
+
ScrollBlot: It,
|
|
1276
|
+
StyleAttributor: V,
|
|
1277
|
+
TextBlot: et
|
|
1278
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1279
|
+
let $ = class extends et {
|
|
1280
|
+
};
|
|
1281
|
+
const ye = {
|
|
1282
|
+
"&": "&",
|
|
1283
|
+
"<": "<",
|
|
1284
|
+
">": ">",
|
|
1285
|
+
'"': """,
|
|
1286
|
+
"'": "'"
|
|
1287
|
+
};
|
|
1288
|
+
function se(r) {
|
|
1289
|
+
return r.replace(/[&<>"']/g, (t) => ye[t]);
|
|
1290
|
+
}
|
|
1291
|
+
const at = "\uFEFF";
|
|
1292
|
+
class ie extends B {
|
|
1293
|
+
constructor(t, e) {
|
|
1294
|
+
super(t, e), this.contentNode = document.createElement("span"), this.contentNode.setAttribute("contenteditable", "false"), Array.from(this.domNode.childNodes).forEach((s) => {
|
|
1295
|
+
this.contentNode.appendChild(s);
|
|
1296
|
+
}), this.leftGuard = document.createTextNode(at), this.rightGuard = document.createTextNode(at), this.domNode.appendChild(this.leftGuard), this.domNode.appendChild(this.contentNode), this.domNode.appendChild(this.rightGuard);
|
|
1297
|
+
}
|
|
1298
|
+
index(t, e) {
|
|
1299
|
+
return t === this.leftGuard ? 0 : t === this.rightGuard ? 1 : super.index(t, e);
|
|
1300
|
+
}
|
|
1301
|
+
restore(t) {
|
|
1302
|
+
let e = null, s;
|
|
1303
|
+
const i = t.data.split(at).join("");
|
|
1304
|
+
if (t === this.leftGuard)
|
|
1305
|
+
if (this.prev instanceof $) {
|
|
1306
|
+
const n = this.prev.length();
|
|
1307
|
+
this.prev.insertAt(n, i), e = {
|
|
1308
|
+
startNode: this.prev.domNode,
|
|
1309
|
+
startOffset: n + i.length
|
|
1310
|
+
};
|
|
1311
|
+
} else
|
|
1312
|
+
s = document.createTextNode(i), this.parent.insertBefore(this.scroll.create(s), this), e = {
|
|
1313
|
+
startNode: s,
|
|
1314
|
+
startOffset: i.length
|
|
1315
|
+
};
|
|
1316
|
+
else t === this.rightGuard && (this.next instanceof $ ? (this.next.insertAt(0, i), e = {
|
|
1317
|
+
startNode: this.next.domNode,
|
|
1318
|
+
startOffset: i.length
|
|
1319
|
+
}) : (s = document.createTextNode(i), this.parent.insertBefore(this.scroll.create(s), this.next), e = {
|
|
1320
|
+
startNode: s,
|
|
1321
|
+
startOffset: i.length
|
|
1322
|
+
}));
|
|
1323
|
+
return t.data = at, e;
|
|
1324
|
+
}
|
|
1325
|
+
update(t, e) {
|
|
1326
|
+
t.forEach((s) => {
|
|
1327
|
+
if (s.type === "characterData" && (s.target === this.leftGuard || s.target === this.rightGuard)) {
|
|
1328
|
+
const i = this.restore(s.target);
|
|
1329
|
+
i && (e.range = i);
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
const vt = /* @__PURE__ */ new WeakMap(), xt = ["error", "warn", "log", "info"];
|
|
1335
|
+
let Rt = "warn";
|
|
1336
|
+
function re(r, ...t) {
|
|
1337
|
+
Rt && xt.indexOf(r) <= xt.indexOf(Rt) && console[r](...t);
|
|
1338
|
+
}
|
|
1339
|
+
function G(r) {
|
|
1340
|
+
return xt.reduce(
|
|
1341
|
+
(t, e) => (t[e] = re.bind(console, e, r), t),
|
|
1342
|
+
{}
|
|
1343
|
+
);
|
|
1344
|
+
}
|
|
1345
|
+
G.level = (r) => {
|
|
1346
|
+
Rt = r;
|
|
1347
|
+
};
|
|
1348
|
+
re.level = G.level;
|
|
1349
|
+
const Nt = G("rich:events"), Ee = ["selectionchange", "mousedown", "mouseup", "click"];
|
|
1350
|
+
Ee.forEach((r) => {
|
|
1351
|
+
document.addEventListener(r, (...t) => {
|
|
1352
|
+
Array.from(
|
|
1353
|
+
document.querySelectorAll(`.${L}-container`)
|
|
1354
|
+
).forEach((e) => {
|
|
1355
|
+
const s = vt.get(e);
|
|
1356
|
+
s && s.emitter && s.emitter.handleDOM(...t);
|
|
1357
|
+
});
|
|
1358
|
+
});
|
|
1359
|
+
});
|
|
1360
|
+
class m {
|
|
1361
|
+
constructor() {
|
|
1362
|
+
this.emitter = ue(), this.domListeners = {}, this.on("error", Nt.error);
|
|
1363
|
+
}
|
|
1364
|
+
static {
|
|
1365
|
+
this.events = {
|
|
1366
|
+
EDITOR_CHANGE: "editor-change",
|
|
1367
|
+
SCROLL_BEFORE_UPDATE: "scroll-before-update",
|
|
1368
|
+
SCROLL_BLOT_MOUNT: "scroll-blot-mount",
|
|
1369
|
+
SCROLL_BLOT_UNMOUNT: "scroll-blot-unmount",
|
|
1370
|
+
SCROLL_OPTIMIZE: "scroll-optimize",
|
|
1371
|
+
SCROLL_UPDATE: "scroll-update",
|
|
1372
|
+
SCROLL_EMBED_UPDATE: "scroll-embed-update",
|
|
1373
|
+
SELECTION_CHANGE: "selection-change",
|
|
1374
|
+
TEXT_CHANGE: "text-change",
|
|
1375
|
+
COMPOSITION_BEFORE_START: "composition-before-start",
|
|
1376
|
+
COMPOSITION_START: "composition-start",
|
|
1377
|
+
COMPOSITION_BEFORE_END: "composition-before-end",
|
|
1378
|
+
COMPOSITION_END: "composition-end"
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
static {
|
|
1382
|
+
this.sources = {
|
|
1383
|
+
API: "api",
|
|
1384
|
+
SILENT: "silent",
|
|
1385
|
+
USER: "user"
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
on(...t) {
|
|
1389
|
+
return this.emitter.on(...t);
|
|
1390
|
+
}
|
|
1391
|
+
once(...t) {
|
|
1392
|
+
return this.emitter.once(...t);
|
|
1393
|
+
}
|
|
1394
|
+
emit(...t) {
|
|
1395
|
+
return Nt.log.call(Nt, ...t), this.emitter.emit(...t);
|
|
1396
|
+
}
|
|
1397
|
+
off(...t) {
|
|
1398
|
+
return this.emitter.off(...t);
|
|
1399
|
+
}
|
|
1400
|
+
offAll(...t) {
|
|
1401
|
+
return this.emitter.offAll(...t);
|
|
1402
|
+
}
|
|
1403
|
+
handleDOM(t, ...e) {
|
|
1404
|
+
(this.domListeners[t.type] || []).forEach(({ node: s, handler: i }) => {
|
|
1405
|
+
(t.target === s || s.contains(t.target)) && i(t, ...e);
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
listenDOM(t, e, s) {
|
|
1409
|
+
this.domListeners[t] || (this.domListeners[t] = []), this.domListeners[t].push({ node: e, handler: s });
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
class Te {
|
|
1413
|
+
constructor(t, e) {
|
|
1414
|
+
this.scroll = t, this.emitter = e, this.isComposing = !1, this.setupListeners();
|
|
1415
|
+
}
|
|
1416
|
+
setupListeners() {
|
|
1417
|
+
this.scroll.domNode.addEventListener("compositionstart", (t) => {
|
|
1418
|
+
this.isComposing || this.handleCompositionStart(t);
|
|
1419
|
+
}), this.scroll.domNode.addEventListener("compositionend", (t) => {
|
|
1420
|
+
this.isComposing && queueMicrotask(() => {
|
|
1421
|
+
this.handleCompositionEnd(t);
|
|
1422
|
+
});
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
handleCompositionStart(t) {
|
|
1426
|
+
const e = t.target instanceof Node ? this.scroll.find(t.target, !0) : null;
|
|
1427
|
+
e && !(e instanceof ie) && (this.emitter.emit(m.events.COMPOSITION_BEFORE_START, t), this.scroll.batchStart(), this.emitter.emit(m.events.COMPOSITION_START, t), this.isComposing = !0);
|
|
1428
|
+
}
|
|
1429
|
+
handleCompositionEnd(t) {
|
|
1430
|
+
this.emitter.emit(m.events.COMPOSITION_BEFORE_END, t), this.scroll.batchEnd(), this.emitter.emit(m.events.COMPOSITION_END, t), this.isComposing = !1;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
class F extends B {
|
|
1434
|
+
static value() {
|
|
1435
|
+
}
|
|
1436
|
+
optimize() {
|
|
1437
|
+
(this.prev || this.next) && this.remove();
|
|
1438
|
+
}
|
|
1439
|
+
length() {
|
|
1440
|
+
return 0;
|
|
1441
|
+
}
|
|
1442
|
+
value() {
|
|
1443
|
+
return "";
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
F.blotName = "break";
|
|
1447
|
+
F.tagName = "BR";
|
|
1448
|
+
class M extends D {
|
|
1449
|
+
static {
|
|
1450
|
+
this.allowedChildren = [M, F, B, $];
|
|
1451
|
+
}
|
|
1452
|
+
static {
|
|
1453
|
+
this.order = [
|
|
1454
|
+
"cursor",
|
|
1455
|
+
"inline",
|
|
1456
|
+
// Must be lower
|
|
1457
|
+
"link",
|
|
1458
|
+
// Chrome wants <a> to be lower
|
|
1459
|
+
"underline",
|
|
1460
|
+
"strike",
|
|
1461
|
+
"italic",
|
|
1462
|
+
"bold",
|
|
1463
|
+
"script",
|
|
1464
|
+
"code"
|
|
1465
|
+
// Must be higher
|
|
1466
|
+
];
|
|
1467
|
+
}
|
|
1468
|
+
static compare(t, e) {
|
|
1469
|
+
const s = M.order.indexOf(t), i = M.order.indexOf(e);
|
|
1470
|
+
return s >= 0 || i >= 0 ? s - i : t === e ? 0 : t < e ? -1 : 1;
|
|
1471
|
+
}
|
|
1472
|
+
formatAt(t, e, s, i) {
|
|
1473
|
+
if (M.compare(this.statics.blotName, s) < 0 && this.scroll.query(s, p.BLOT)) {
|
|
1474
|
+
const n = this.isolate(t, e);
|
|
1475
|
+
i && n.wrap(s, i);
|
|
1476
|
+
} else
|
|
1477
|
+
super.formatAt(t, e, s, i);
|
|
1478
|
+
}
|
|
1479
|
+
optimize(t) {
|
|
1480
|
+
if (super.optimize(t), this.parent instanceof M && M.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
|
|
1481
|
+
const e = this.parent.isolate(this.offset(), this.length());
|
|
1482
|
+
this.moveChildren(e), e.wrap(this);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
const Pt = 1;
|
|
1487
|
+
class O extends _ {
|
|
1488
|
+
constructor() {
|
|
1489
|
+
super(...arguments), this.cache = {};
|
|
1490
|
+
}
|
|
1491
|
+
delta() {
|
|
1492
|
+
return this.cache.delta == null && (this.cache.delta = Le(this)), this.cache.delta;
|
|
1493
|
+
}
|
|
1494
|
+
deleteAt(t, e) {
|
|
1495
|
+
super.deleteAt(t, e), this.cache = {};
|
|
1496
|
+
}
|
|
1497
|
+
formatAt(t, e, s, i) {
|
|
1498
|
+
e <= 0 || (this.scroll.query(s, p.BLOCK) ? t + e === this.length() && this.format(s, i) : super.formatAt(
|
|
1499
|
+
t,
|
|
1500
|
+
Math.min(e, this.length() - t - 1),
|
|
1501
|
+
s,
|
|
1502
|
+
i
|
|
1503
|
+
), this.cache = {});
|
|
1504
|
+
}
|
|
1505
|
+
insertAt(t, e, s) {
|
|
1506
|
+
if (s != null) {
|
|
1507
|
+
super.insertAt(t, e, s), this.cache = {};
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (e.length === 0) return;
|
|
1511
|
+
const i = e.split(`
|
|
1512
|
+
`), n = i.shift();
|
|
1513
|
+
n.length > 0 && (t < this.length() - 1 || this.children.tail == null ? super.insertAt(Math.min(t, this.length() - 1), n) : this.children.tail.insertAt(this.children.tail.length(), n), this.cache = {});
|
|
1514
|
+
let o = this;
|
|
1515
|
+
i.reduce((l, a) => (o = o.split(l, !0), o.insertAt(0, a), a.length), t + n.length);
|
|
1516
|
+
}
|
|
1517
|
+
insertBefore(t, e) {
|
|
1518
|
+
const { head: s } = this.children;
|
|
1519
|
+
super.insertBefore(t, e), s instanceof F && s.remove(), this.cache = {};
|
|
1520
|
+
}
|
|
1521
|
+
length() {
|
|
1522
|
+
return this.cache.length == null && (this.cache.length = super.length() + Pt), this.cache.length;
|
|
1523
|
+
}
|
|
1524
|
+
moveChildren(t, e) {
|
|
1525
|
+
super.moveChildren(t, e), this.cache = {};
|
|
1526
|
+
}
|
|
1527
|
+
optimize(t) {
|
|
1528
|
+
super.optimize(t), this.cache = {};
|
|
1529
|
+
}
|
|
1530
|
+
path(t) {
|
|
1531
|
+
return super.path(t, !0);
|
|
1532
|
+
}
|
|
1533
|
+
removeChild(t) {
|
|
1534
|
+
super.removeChild(t), this.cache = {};
|
|
1535
|
+
}
|
|
1536
|
+
split(t, e = !1) {
|
|
1537
|
+
if (e && (t === 0 || t >= this.length() - Pt)) {
|
|
1538
|
+
const i = this.clone();
|
|
1539
|
+
return t === 0 ? (this.parent.insertBefore(i, this), this) : (this.parent.insertBefore(i, this.next), i);
|
|
1540
|
+
}
|
|
1541
|
+
const s = super.split(t, e);
|
|
1542
|
+
return this.cache = {}, s;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
O.blotName = "block";
|
|
1546
|
+
O.tagName = "P";
|
|
1547
|
+
O.defaultChild = F;
|
|
1548
|
+
O.allowedChildren = [F, M, B, $];
|
|
1549
|
+
class I extends B {
|
|
1550
|
+
attach() {
|
|
1551
|
+
super.attach(), this.attributes = new pt(this.domNode);
|
|
1552
|
+
}
|
|
1553
|
+
delta() {
|
|
1554
|
+
return new f().insert(this.value(), {
|
|
1555
|
+
...this.formats(),
|
|
1556
|
+
...this.attributes.values()
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
format(t, e) {
|
|
1560
|
+
const s = this.scroll.query(t, p.BLOCK_ATTRIBUTE);
|
|
1561
|
+
s != null && this.attributes.attribute(s, e);
|
|
1562
|
+
}
|
|
1563
|
+
formatAt(t, e, s, i) {
|
|
1564
|
+
this.format(s, i);
|
|
1565
|
+
}
|
|
1566
|
+
insertAt(t, e, s) {
|
|
1567
|
+
if (s != null) {
|
|
1568
|
+
super.insertAt(t, e, s);
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
const i = e.split(`
|
|
1572
|
+
`), n = i.pop(), o = i.map((a) => {
|
|
1573
|
+
const c = this.scroll.create(O.blotName);
|
|
1574
|
+
return c.insertAt(0, a), c;
|
|
1575
|
+
}), l = this.split(t);
|
|
1576
|
+
o.forEach((a) => {
|
|
1577
|
+
this.parent.insertBefore(a, l);
|
|
1578
|
+
}), n && this.parent.insertBefore(this.scroll.create("text", n), l);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
I.scope = p.BLOCK_BLOT;
|
|
1582
|
+
function Le(r, t = !0) {
|
|
1583
|
+
return r.descendants(A).reduce((e, s) => s.length() === 0 ? e : e.insert(s.value(), x(s, {}, t)), new f()).insert(`
|
|
1584
|
+
`, x(r));
|
|
1585
|
+
}
|
|
1586
|
+
function x(r, t = {}, e = !0) {
|
|
1587
|
+
return r == null || ("formats" in r && typeof r.formats == "function" && (t = {
|
|
1588
|
+
...t,
|
|
1589
|
+
...r.formats()
|
|
1590
|
+
}, e && delete t["code-token"]), r.parent == null || r.parent.statics.blotName === "scroll" || r.parent.statics.scope !== r.statics.scope) ? t : x(r.parent, t, e);
|
|
1591
|
+
}
|
|
1592
|
+
class U extends B {
|
|
1593
|
+
static {
|
|
1594
|
+
this.blotName = "cursor";
|
|
1595
|
+
}
|
|
1596
|
+
static {
|
|
1597
|
+
this.className = `${L}-cursor`;
|
|
1598
|
+
}
|
|
1599
|
+
static {
|
|
1600
|
+
this.tagName = "span";
|
|
1601
|
+
}
|
|
1602
|
+
static {
|
|
1603
|
+
this.CONTENTS = "\uFEFF";
|
|
1604
|
+
}
|
|
1605
|
+
// Zero width no break space
|
|
1606
|
+
static value() {
|
|
1607
|
+
}
|
|
1608
|
+
constructor(t, e, s) {
|
|
1609
|
+
super(t, e), this.selection = s, this.textNode = document.createTextNode(U.CONTENTS), this.domNode.appendChild(this.textNode), this.savedLength = 0;
|
|
1610
|
+
}
|
|
1611
|
+
detach() {
|
|
1612
|
+
this.parent != null && this.parent.removeChild(this);
|
|
1613
|
+
}
|
|
1614
|
+
format(t, e) {
|
|
1615
|
+
if (this.savedLength !== 0) {
|
|
1616
|
+
super.format(t, e);
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
let s = this, i = 0;
|
|
1620
|
+
for (; s != null && s.statics.scope !== p.BLOCK_BLOT; )
|
|
1621
|
+
i += s.offset(s.parent), s = s.parent;
|
|
1622
|
+
s != null && (this.savedLength = U.CONTENTS.length, s.optimize(), s.formatAt(i, U.CONTENTS.length, t, e), this.savedLength = 0);
|
|
1623
|
+
}
|
|
1624
|
+
index(t, e) {
|
|
1625
|
+
return t === this.textNode ? 0 : super.index(t, e);
|
|
1626
|
+
}
|
|
1627
|
+
length() {
|
|
1628
|
+
return this.savedLength;
|
|
1629
|
+
}
|
|
1630
|
+
position() {
|
|
1631
|
+
return [this.textNode, this.textNode.data.length];
|
|
1632
|
+
}
|
|
1633
|
+
remove() {
|
|
1634
|
+
super.remove(), this.parent = null;
|
|
1635
|
+
}
|
|
1636
|
+
restore() {
|
|
1637
|
+
if (this.selection.composing || this.parent == null) return null;
|
|
1638
|
+
const t = this.selection.getNativeRange();
|
|
1639
|
+
for (; this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode; )
|
|
1640
|
+
this.domNode.parentNode.insertBefore(
|
|
1641
|
+
this.domNode.lastChild,
|
|
1642
|
+
this.domNode
|
|
1643
|
+
);
|
|
1644
|
+
const e = this.prev instanceof $ ? this.prev : null, s = e ? e.length() : 0, i = this.next instanceof $ ? this.next : null, n = i ? i.text : "", { textNode: o } = this, l = o.data.split(U.CONTENTS).join("");
|
|
1645
|
+
o.data = U.CONTENTS;
|
|
1646
|
+
let a;
|
|
1647
|
+
if (e)
|
|
1648
|
+
a = e, (l || i) && (e.insertAt(e.length(), l + n), i && i.remove());
|
|
1649
|
+
else if (i)
|
|
1650
|
+
a = i, i.insertAt(0, l);
|
|
1651
|
+
else {
|
|
1652
|
+
const c = document.createTextNode(l);
|
|
1653
|
+
a = this.scroll.create(c), this.parent.insertBefore(a, this);
|
|
1654
|
+
}
|
|
1655
|
+
if (this.remove(), t) {
|
|
1656
|
+
const c = (g, b) => e && g === e.domNode ? b : g === o ? s + b - 1 : i && g === i.domNode ? s + l.length + b : null, h = c(t.start.node, t.start.offset), d = c(t.end.node, t.end.offset);
|
|
1657
|
+
if (h !== null && d !== null)
|
|
1658
|
+
return {
|
|
1659
|
+
startNode: a.domNode,
|
|
1660
|
+
startOffset: h,
|
|
1661
|
+
endNode: a.domNode,
|
|
1662
|
+
endOffset: d
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
return null;
|
|
1666
|
+
}
|
|
1667
|
+
update(t, e) {
|
|
1668
|
+
if (t.some((s) => s.type === "characterData" && s.target === this.textNode)) {
|
|
1669
|
+
const s = this.restore();
|
|
1670
|
+
s && (e.range = s);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
// Avoid .${RICH_TEXT_CLASS_NAME_PREFIX}-cursor being a descendant of `<a/>`.
|
|
1674
|
+
// The reason is Safari pushes down `<a/>` on text insertion.
|
|
1675
|
+
// That will cause DOM nodes not sync with the model.
|
|
1676
|
+
//
|
|
1677
|
+
// For example ({I} is the caret), given the markup:
|
|
1678
|
+
// <a><span class=`${RICH_TEXT_CLASS_NAME_PREFIX}-cursor`>\uFEFF{I}</span></a>
|
|
1679
|
+
// When typing a char "x", `<a/>` will be pushed down inside the `<span>` first:
|
|
1680
|
+
// <span class=`${RICH_TEXT_CLASS_NAME_PREFIX}-cursor`><a>\uFEFF{I}</a></span>
|
|
1681
|
+
// And then "x" will be inserted after `<a/>`:
|
|
1682
|
+
// <span class=`${RICH_TEXT_CLASS_NAME_PREFIX}-cursor`><a>\uFEFF</a>d{I}</span>
|
|
1683
|
+
optimize(t) {
|
|
1684
|
+
super.optimize(t);
|
|
1685
|
+
let { parent: e } = this;
|
|
1686
|
+
for (; e; ) {
|
|
1687
|
+
if (e.domNode.tagName === "A") {
|
|
1688
|
+
this.savedLength = U.CONTENTS.length, e.isolate(this.offset(e), this.length()).unwrap(), this.savedLength = 0;
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
e = e.parent;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
value() {
|
|
1695
|
+
return "";
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
const yt = G("rich:selection");
|
|
1699
|
+
class rt {
|
|
1700
|
+
constructor(t, e = 0) {
|
|
1701
|
+
this.index = t, this.length = e;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
class Ae {
|
|
1705
|
+
constructor(t, e) {
|
|
1706
|
+
this.emitter = e, this.scroll = t, this.composing = !1, this.mouseDown = !1, this.root = this.scroll.domNode, this.cursor = this.scroll.create("cursor", this), this.savedRange = new rt(0, 0), this.lastRange = this.savedRange, this.lastNative = null, this.handleComposition(), this.handleDragging(), this.emitter.listenDOM("selectionchange", document, () => {
|
|
1707
|
+
!this.mouseDown && !this.composing && setTimeout(this.update.bind(this, m.sources.USER), 1);
|
|
1708
|
+
}), this.emitter.on(m.events.SCROLL_BEFORE_UPDATE, () => {
|
|
1709
|
+
if (!this.hasFocus()) return;
|
|
1710
|
+
const s = this.getNativeRange();
|
|
1711
|
+
s != null && s.start.node !== this.cursor.textNode && this.emitter.once(
|
|
1712
|
+
m.events.SCROLL_UPDATE,
|
|
1713
|
+
(i, n) => {
|
|
1714
|
+
try {
|
|
1715
|
+
this.root.contains(s.start.node) && this.root.contains(s.end.node) && this.setNativeRange(
|
|
1716
|
+
s.start.node,
|
|
1717
|
+
s.start.offset,
|
|
1718
|
+
s.end.node,
|
|
1719
|
+
s.end.offset
|
|
1720
|
+
);
|
|
1721
|
+
const o = n.some(
|
|
1722
|
+
(l) => l.type === "characterData" || l.type === "childList" || l.type === "attributes" && l.target === this.root
|
|
1723
|
+
);
|
|
1724
|
+
this.update(o ? m.sources.SILENT : i);
|
|
1725
|
+
} catch {
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
);
|
|
1729
|
+
}), this.emitter.on(m.events.SCROLL_OPTIMIZE, (s, i) => {
|
|
1730
|
+
if (i.range) {
|
|
1731
|
+
const { startNode: n, startOffset: o, endNode: l, endOffset: a } = i.range;
|
|
1732
|
+
this.setNativeRange(n, o, l, a), this.update(m.sources.SILENT);
|
|
1733
|
+
}
|
|
1734
|
+
}), this.update(m.sources.SILENT);
|
|
1735
|
+
}
|
|
1736
|
+
handleComposition() {
|
|
1737
|
+
this.emitter.on(m.events.COMPOSITION_BEFORE_START, () => {
|
|
1738
|
+
this.composing = !0;
|
|
1739
|
+
}), this.emitter.on(m.events.COMPOSITION_END, () => {
|
|
1740
|
+
if (this.composing = !1, this.cursor.parent) {
|
|
1741
|
+
const t = this.cursor.restore();
|
|
1742
|
+
if (!t) return;
|
|
1743
|
+
setTimeout(() => {
|
|
1744
|
+
this.setNativeRange(
|
|
1745
|
+
t.startNode,
|
|
1746
|
+
t.startOffset,
|
|
1747
|
+
t.endNode,
|
|
1748
|
+
t.endOffset
|
|
1749
|
+
);
|
|
1750
|
+
}, 1);
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
handleDragging() {
|
|
1755
|
+
this.emitter.listenDOM("mousedown", document.body, () => {
|
|
1756
|
+
this.mouseDown = !0;
|
|
1757
|
+
}), this.emitter.listenDOM("mouseup", document.body, () => {
|
|
1758
|
+
this.mouseDown = !1, this.update(m.sources.USER);
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
focus() {
|
|
1762
|
+
this.hasFocus() || (this.root.focus({ preventScroll: !0 }), this.setRange(this.savedRange));
|
|
1763
|
+
}
|
|
1764
|
+
format(t, e) {
|
|
1765
|
+
this.scroll.update();
|
|
1766
|
+
const s = this.getNativeRange();
|
|
1767
|
+
if (!(s == null || !s.native.collapsed || this.scroll.query(t, p.BLOCK))) {
|
|
1768
|
+
if (s.start.node !== this.cursor.textNode) {
|
|
1769
|
+
const i = this.scroll.find(s.start.node, !1);
|
|
1770
|
+
if (i == null) return;
|
|
1771
|
+
if (i instanceof A) {
|
|
1772
|
+
const n = i.split(s.start.offset);
|
|
1773
|
+
i.parent.insertBefore(this.cursor, n);
|
|
1774
|
+
} else
|
|
1775
|
+
i.insertBefore(this.cursor, s.start.node);
|
|
1776
|
+
this.cursor.attach();
|
|
1777
|
+
}
|
|
1778
|
+
this.cursor.format(t, e), this.scroll.optimize(), this.setNativeRange(this.cursor.textNode, this.cursor.textNode.data.length), this.update();
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
getBounds(t, e = 0) {
|
|
1782
|
+
const s = this.scroll.length();
|
|
1783
|
+
t = Math.min(t, s - 1), e = Math.min(t + e, s - 1) - t;
|
|
1784
|
+
let i, [n, o] = this.scroll.leaf(t);
|
|
1785
|
+
if (n == null) return null;
|
|
1786
|
+
if (e > 0 && o === n.length()) {
|
|
1787
|
+
const [h] = this.scroll.leaf(t + 1);
|
|
1788
|
+
if (h) {
|
|
1789
|
+
const [d] = this.scroll.line(t), [g] = this.scroll.line(t + 1);
|
|
1790
|
+
d === g && (n = h, o = 0);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
[i, o] = n.position(o, !0);
|
|
1794
|
+
const l = document.createRange();
|
|
1795
|
+
if (e > 0)
|
|
1796
|
+
return l.setStart(i, o), [n, o] = this.scroll.leaf(t + e), n == null ? null : ([i, o] = n.position(o, !0), l.setEnd(i, o), l.getBoundingClientRect());
|
|
1797
|
+
let a = "left", c;
|
|
1798
|
+
if (i instanceof Text) {
|
|
1799
|
+
if (!i.data.length)
|
|
1800
|
+
return null;
|
|
1801
|
+
o < i.data.length ? (l.setStart(i, o), l.setEnd(i, o + 1)) : (l.setStart(i, o - 1), l.setEnd(i, o), a = "right"), c = l.getBoundingClientRect();
|
|
1802
|
+
} else {
|
|
1803
|
+
if (!(n.domNode instanceof Element)) return null;
|
|
1804
|
+
c = n.domNode.getBoundingClientRect(), o > 0 && (a = "right");
|
|
1805
|
+
}
|
|
1806
|
+
return {
|
|
1807
|
+
bottom: c.top + c.height,
|
|
1808
|
+
height: c.height,
|
|
1809
|
+
left: c[a],
|
|
1810
|
+
right: c[a],
|
|
1811
|
+
top: c.top,
|
|
1812
|
+
width: 0
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
getNativeRange() {
|
|
1816
|
+
const t = document.getSelection();
|
|
1817
|
+
if (t == null || t.rangeCount <= 0) return null;
|
|
1818
|
+
const e = t.getRangeAt(0);
|
|
1819
|
+
if (e == null) return null;
|
|
1820
|
+
const s = this.normalizeNative(e);
|
|
1821
|
+
return yt.info("getNativeRange", s), s;
|
|
1822
|
+
}
|
|
1823
|
+
getRange() {
|
|
1824
|
+
const t = this.scroll.domNode;
|
|
1825
|
+
if ("isConnected" in t && !t.isConnected)
|
|
1826
|
+
return [null, null];
|
|
1827
|
+
const e = this.getNativeRange();
|
|
1828
|
+
return e == null ? [null, null] : [this.normalizedToRange(e), e];
|
|
1829
|
+
}
|
|
1830
|
+
hasFocus() {
|
|
1831
|
+
return document.activeElement === this.root || document.activeElement != null && Et(this.root, document.activeElement);
|
|
1832
|
+
}
|
|
1833
|
+
normalizedToRange(t) {
|
|
1834
|
+
const e = [
|
|
1835
|
+
[t.start.node, t.start.offset]
|
|
1836
|
+
];
|
|
1837
|
+
t.native.collapsed || e.push([t.end.node, t.end.offset]);
|
|
1838
|
+
const s = e.map((o) => {
|
|
1839
|
+
const [l, a] = o, c = this.scroll.find(l, !0), h = c.offset(this.scroll);
|
|
1840
|
+
return a === 0 ? h : c instanceof A ? h + c.index(l, a) : h + c.length();
|
|
1841
|
+
}), i = Math.min(Math.max(...s), this.scroll.length() - 1), n = Math.min(i, ...s);
|
|
1842
|
+
return new rt(n, i - n);
|
|
1843
|
+
}
|
|
1844
|
+
normalizeNative(t) {
|
|
1845
|
+
if (!Et(this.root, t.startContainer) || !t.collapsed && !Et(this.root, t.endContainer))
|
|
1846
|
+
return null;
|
|
1847
|
+
const e = {
|
|
1848
|
+
start: {
|
|
1849
|
+
node: t.startContainer,
|
|
1850
|
+
offset: t.startOffset
|
|
1851
|
+
},
|
|
1852
|
+
end: { node: t.endContainer, offset: t.endOffset },
|
|
1853
|
+
native: t
|
|
1854
|
+
};
|
|
1855
|
+
return [e.start, e.end].forEach((s) => {
|
|
1856
|
+
let { node: i, offset: n } = s;
|
|
1857
|
+
for (; !(i instanceof Text) && i.childNodes.length > 0; )
|
|
1858
|
+
if (i.childNodes.length > n)
|
|
1859
|
+
i = i.childNodes[n], n = 0;
|
|
1860
|
+
else if (i.childNodes.length === n)
|
|
1861
|
+
i = i.lastChild, i instanceof Text ? n = i.data.length : i.childNodes.length > 0 ? n = i.childNodes.length : n = i.childNodes.length + 1;
|
|
1862
|
+
else
|
|
1863
|
+
break;
|
|
1864
|
+
s.node = i, s.offset = n;
|
|
1865
|
+
}), e;
|
|
1866
|
+
}
|
|
1867
|
+
rangeToNative(t) {
|
|
1868
|
+
const e = this.scroll.length(), s = (i, n) => {
|
|
1869
|
+
i = Math.min(e - 1, i);
|
|
1870
|
+
const [o, l] = this.scroll.leaf(i);
|
|
1871
|
+
return o ? o.position(l, n) : [null, -1];
|
|
1872
|
+
};
|
|
1873
|
+
return [
|
|
1874
|
+
...s(t.index, !1),
|
|
1875
|
+
...s(t.index + t.length, !0)
|
|
1876
|
+
];
|
|
1877
|
+
}
|
|
1878
|
+
setNativeRange(t, e, s = t, i = e, n = !1) {
|
|
1879
|
+
if (yt.info("setNativeRange", t, e, s, i), t != null && (this.root.parentNode == null || t.parentNode == null || s.parentNode == null))
|
|
1880
|
+
return;
|
|
1881
|
+
const o = document.getSelection();
|
|
1882
|
+
if (o != null)
|
|
1883
|
+
if (t != null) {
|
|
1884
|
+
this.hasFocus() || this.root.focus({ preventScroll: !0 });
|
|
1885
|
+
const { native: l } = this.getNativeRange() || {};
|
|
1886
|
+
if (l == null || n || t !== l.startContainer || e !== l.startOffset || s !== l.endContainer || i !== l.endOffset) {
|
|
1887
|
+
t instanceof Element && t.tagName === "BR" && (e = Array.from(t.parentNode.childNodes).indexOf(
|
|
1888
|
+
t
|
|
1889
|
+
), t = t.parentNode), s instanceof Element && s.tagName === "BR" && (i = Array.from(s.parentNode.childNodes).indexOf(
|
|
1890
|
+
s
|
|
1891
|
+
), s = s.parentNode);
|
|
1892
|
+
const a = document.createRange();
|
|
1893
|
+
a.setStart(t, e), a.setEnd(s, i), o.removeAllRanges(), o.addRange(a);
|
|
1894
|
+
}
|
|
1895
|
+
} else
|
|
1896
|
+
o.removeAllRanges(), this.root.blur();
|
|
1897
|
+
}
|
|
1898
|
+
setRange(t, e = !1, s = m.sources.API) {
|
|
1899
|
+
if (typeof e == "string" && (s = e, e = !1), yt.info("setRange", t), t != null) {
|
|
1900
|
+
const i = this.rangeToNative(t);
|
|
1901
|
+
this.setNativeRange(...i, e);
|
|
1902
|
+
} else
|
|
1903
|
+
this.setNativeRange(null);
|
|
1904
|
+
this.update(s);
|
|
1905
|
+
}
|
|
1906
|
+
update(t = m.sources.USER) {
|
|
1907
|
+
const e = this.lastRange, [s, i] = this.getRange();
|
|
1908
|
+
if (this.lastRange = s, this.lastNative = i, this.lastRange != null && (this.savedRange = this.lastRange), !X(e, this.lastRange)) {
|
|
1909
|
+
if (!this.composing && i != null && i.native.collapsed && i.start.node !== this.cursor.textNode) {
|
|
1910
|
+
const o = this.cursor.restore();
|
|
1911
|
+
o && this.setNativeRange(
|
|
1912
|
+
o.startNode,
|
|
1913
|
+
o.startOffset,
|
|
1914
|
+
o.endNode,
|
|
1915
|
+
o.endOffset
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
const n = [
|
|
1919
|
+
m.events.SELECTION_CHANGE,
|
|
1920
|
+
W(this.lastRange),
|
|
1921
|
+
W(e),
|
|
1922
|
+
t
|
|
1923
|
+
];
|
|
1924
|
+
this.emitter.emit(m.events.EDITOR_CHANGE, ...n), t !== m.sources.SILENT && this.emitter.emit(...n);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
function Et(r, t) {
|
|
1929
|
+
try {
|
|
1930
|
+
t.parentNode;
|
|
1931
|
+
} catch {
|
|
1932
|
+
return !1;
|
|
1933
|
+
}
|
|
1934
|
+
return r.contains(t);
|
|
1935
|
+
}
|
|
1936
|
+
const we = /^[ -~]*$/;
|
|
1937
|
+
class Ce {
|
|
1938
|
+
constructor(t) {
|
|
1939
|
+
this.scroll = t, this.delta = this.getDelta();
|
|
1940
|
+
}
|
|
1941
|
+
applyDelta(t) {
|
|
1942
|
+
this.scroll.update();
|
|
1943
|
+
let e = this.scroll.length();
|
|
1944
|
+
this.scroll.batchStart();
|
|
1945
|
+
const s = _t(t), i = new f();
|
|
1946
|
+
return Oe(s.ops.slice()).reduce((o, l) => {
|
|
1947
|
+
const a = k.length(l);
|
|
1948
|
+
let c = l.attributes || {}, h = !1, d = !1;
|
|
1949
|
+
if (l.insert != null) {
|
|
1950
|
+
if (i.retain(a), typeof l.insert == "string") {
|
|
1951
|
+
const N = l.insert;
|
|
1952
|
+
d = !N.endsWith(`
|
|
1953
|
+
`) && (e <= o || !!this.scroll.descendant(I, o)[0]), this.scroll.insertAt(o, N);
|
|
1954
|
+
const [E, w] = this.scroll.line(o);
|
|
1955
|
+
let y = it({}, x(E));
|
|
1956
|
+
if (E instanceof O) {
|
|
1957
|
+
const [v] = E.descendant(A, w);
|
|
1958
|
+
v && (y = it(y, x(v)));
|
|
1959
|
+
}
|
|
1960
|
+
c = C.diff(y, c) || {};
|
|
1961
|
+
} else if (typeof l.insert == "object") {
|
|
1962
|
+
const N = Object.keys(l.insert)[0];
|
|
1963
|
+
if (N == null) return o;
|
|
1964
|
+
const E = this.scroll.query(N, p.INLINE) != null;
|
|
1965
|
+
if (E)
|
|
1966
|
+
(e <= o || this.scroll.descendant(I, o)[0]) && (d = !0);
|
|
1967
|
+
else if (o > 0) {
|
|
1968
|
+
const [w, y] = this.scroll.descendant(A, o - 1);
|
|
1969
|
+
w instanceof $ ? w.value()[y] !== `
|
|
1970
|
+
` && (h = !0) : w instanceof B && w.statics.scope === p.INLINE_BLOT && (h = !0);
|
|
1971
|
+
}
|
|
1972
|
+
if (this.scroll.insertAt(o, N, l.insert[N]), E) {
|
|
1973
|
+
const [w] = this.scroll.descendant(A, o);
|
|
1974
|
+
if (w) {
|
|
1975
|
+
const y = it({}, x(w));
|
|
1976
|
+
c = C.diff(y, c) || {};
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
e += a;
|
|
1981
|
+
} else if (i.push(l), l.retain !== null && typeof l.retain == "object") {
|
|
1982
|
+
const N = Object.keys(l.retain)[0];
|
|
1983
|
+
if (N == null) return o;
|
|
1984
|
+
this.scroll.updateEmbedAt(o, N, l.retain[N]);
|
|
1985
|
+
}
|
|
1986
|
+
Object.keys(c).forEach((N) => {
|
|
1987
|
+
this.scroll.formatAt(o, a, N, c[N]);
|
|
1988
|
+
});
|
|
1989
|
+
const g = h ? 1 : 0, b = d ? 1 : 0;
|
|
1990
|
+
return e += g + b, i.retain(g), i.delete(b), o + a + g + b;
|
|
1991
|
+
}, 0), i.reduce((o, l) => typeof l.delete == "number" ? (this.scroll.deleteAt(o, l.delete), o) : o + k.length(l), 0), this.scroll.batchEnd(), this.scroll.optimize(), this.update(s);
|
|
1992
|
+
}
|
|
1993
|
+
deleteText(t, e) {
|
|
1994
|
+
return this.scroll.deleteAt(t, e), this.update(new f().retain(t).delete(e));
|
|
1995
|
+
}
|
|
1996
|
+
formatLine(t, e, s = {}) {
|
|
1997
|
+
this.scroll.update(), Object.keys(s).forEach((n) => {
|
|
1998
|
+
this.scroll.lines(t, Math.max(e, 1)).forEach((o) => {
|
|
1999
|
+
o.format(n, s[n]);
|
|
2000
|
+
});
|
|
2001
|
+
}), this.scroll.optimize();
|
|
2002
|
+
const i = new f().retain(t).retain(e, W(s));
|
|
2003
|
+
return this.update(i);
|
|
2004
|
+
}
|
|
2005
|
+
formatText(t, e, s = {}) {
|
|
2006
|
+
Object.keys(s).forEach((n) => {
|
|
2007
|
+
this.scroll.formatAt(t, e, n, s[n]);
|
|
2008
|
+
});
|
|
2009
|
+
const i = new f().retain(t).retain(e, W(s));
|
|
2010
|
+
return this.update(i);
|
|
2011
|
+
}
|
|
2012
|
+
getContents(t, e) {
|
|
2013
|
+
return this.delta.slice(t, t + e);
|
|
2014
|
+
}
|
|
2015
|
+
getDelta() {
|
|
2016
|
+
return this.scroll.lines().reduce((t, e) => t.concat(e.delta()), new f());
|
|
2017
|
+
}
|
|
2018
|
+
getFormat(t, e = 0) {
|
|
2019
|
+
let s = [], i = [];
|
|
2020
|
+
e === 0 ? this.scroll.path(t).forEach((l) => {
|
|
2021
|
+
const [a] = l;
|
|
2022
|
+
a instanceof O ? s.push(a) : a instanceof A && i.push(a);
|
|
2023
|
+
}) : (s = this.scroll.lines(t, e), i = this.scroll.descendants(A, t, e));
|
|
2024
|
+
const [n, o] = [s, i].map((l) => {
|
|
2025
|
+
const a = l.shift();
|
|
2026
|
+
if (a == null) return {};
|
|
2027
|
+
let c = x(a);
|
|
2028
|
+
for (; Object.keys(c).length > 0; ) {
|
|
2029
|
+
const h = l.shift();
|
|
2030
|
+
if (h == null) return c;
|
|
2031
|
+
c = ke(x(h), c);
|
|
2032
|
+
}
|
|
2033
|
+
return c;
|
|
2034
|
+
});
|
|
2035
|
+
return { ...n, ...o };
|
|
2036
|
+
}
|
|
2037
|
+
getHTML(t, e) {
|
|
2038
|
+
const [s, i] = this.scroll.line(t);
|
|
2039
|
+
if (s) {
|
|
2040
|
+
const n = s.length();
|
|
2041
|
+
return s.length() >= i + e && !(i === 0 && e === n) ? nt(s, i, e, !0) : nt(this.scroll, t, e, !0);
|
|
2042
|
+
}
|
|
2043
|
+
return "";
|
|
2044
|
+
}
|
|
2045
|
+
getText(t, e) {
|
|
2046
|
+
return this.getContents(t, e).filter((s) => typeof s.insert == "string").map((s) => s.insert).join("");
|
|
2047
|
+
}
|
|
2048
|
+
insertContents(t, e) {
|
|
2049
|
+
const s = _t(e), i = new f().retain(t).concat(s);
|
|
2050
|
+
return this.scroll.insertContents(t, s), this.update(i);
|
|
2051
|
+
}
|
|
2052
|
+
insertEmbed(t, e, s) {
|
|
2053
|
+
return this.scroll.insertAt(t, e, s), this.update(new f().retain(t).insert({ [e]: s }));
|
|
2054
|
+
}
|
|
2055
|
+
insertText(t, e, s = {}) {
|
|
2056
|
+
return e = e.replace(/\r\n/g, `
|
|
2057
|
+
`).replace(/\r/g, `
|
|
2058
|
+
`), this.scroll.insertAt(t, e), Object.keys(s).forEach((i) => {
|
|
2059
|
+
this.scroll.formatAt(t, e.length, i, s[i]);
|
|
2060
|
+
}), this.update(
|
|
2061
|
+
new f().retain(t).insert(e, W(s))
|
|
2062
|
+
);
|
|
2063
|
+
}
|
|
2064
|
+
isBlank() {
|
|
2065
|
+
if (this.scroll.children.length === 0) return !0;
|
|
2066
|
+
if (this.scroll.children.length > 1) return !1;
|
|
2067
|
+
const t = this.scroll.children.head;
|
|
2068
|
+
if (t?.statics.blotName !== O.blotName) return !1;
|
|
2069
|
+
const e = t;
|
|
2070
|
+
return e.children.length > 1 ? !1 : e.children.head instanceof F;
|
|
2071
|
+
}
|
|
2072
|
+
removeFormat(t, e) {
|
|
2073
|
+
const s = this.getText(t, e), [i, n] = this.scroll.line(t + e);
|
|
2074
|
+
let o = 0, l = new f();
|
|
2075
|
+
i != null && (o = i.length() - n, l = i.delta().slice(n, n + o - 1).insert(`
|
|
2076
|
+
`));
|
|
2077
|
+
const c = this.getContents(t, e + o).diff(new f().insert(s).concat(l)), h = new f().retain(t).concat(c);
|
|
2078
|
+
return this.applyDelta(h);
|
|
2079
|
+
}
|
|
2080
|
+
update(t, e = [], s = void 0) {
|
|
2081
|
+
const i = this.delta;
|
|
2082
|
+
if (e.length === 1 && e[0].type === "characterData" && e[0].target.data.match(we) && this.scroll.find(e[0].target)) {
|
|
2083
|
+
const n = this.scroll.find(e[0].target), o = x(n), l = n.offset(this.scroll), a = e[0].oldValue.replace(U.CONTENTS, ""), c = new f().insert(a), h = new f().insert(n.value()), d = s && {
|
|
2084
|
+
oldRange: zt(s.oldRange, -l),
|
|
2085
|
+
newRange: zt(s.newRange, -l)
|
|
2086
|
+
};
|
|
2087
|
+
t = new f().retain(l).concat(c.diff(h, d)).reduce((b, N) => N.insert ? b.insert(N.insert, o) : b.push(N), new f()), this.delta = i.compose(t);
|
|
2088
|
+
} else
|
|
2089
|
+
this.delta = this.getDelta(), (!t || !X(i.compose(t), this.delta)) && (t = i.diff(this.delta, s));
|
|
2090
|
+
return t;
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
function Q(r, t, e) {
|
|
2094
|
+
if (r.length === 0) {
|
|
2095
|
+
const [b] = Tt(e.pop());
|
|
2096
|
+
return t <= 0 ? `</li></${b}>` : `</li></${b}>${Q([], t - 1, e)}`;
|
|
2097
|
+
}
|
|
2098
|
+
const [{ child: s, offset: i, length: n, indent: o, type: l }, ...a] = r, [c, h] = Tt(l);
|
|
2099
|
+
if (o > t)
|
|
2100
|
+
return e.push(l), o === t + 1 ? `<${c}><li${h}>${nt(
|
|
2101
|
+
s,
|
|
2102
|
+
i,
|
|
2103
|
+
n
|
|
2104
|
+
)}${Q(a, o, e)}` : `<${c}><li>${Q(r, t + 1, e)}`;
|
|
2105
|
+
const d = e[e.length - 1];
|
|
2106
|
+
if (o === t && l === d)
|
|
2107
|
+
return `</li><li${h}>${nt(
|
|
2108
|
+
s,
|
|
2109
|
+
i,
|
|
2110
|
+
n
|
|
2111
|
+
)}${Q(a, o, e)}`;
|
|
2112
|
+
const [g] = Tt(e.pop());
|
|
2113
|
+
return `</li></${g}>${Q(r, t - 1, e)}`;
|
|
2114
|
+
}
|
|
2115
|
+
function nt(r, t, e, s = !1) {
|
|
2116
|
+
if ("html" in r && typeof r.html == "function")
|
|
2117
|
+
return r.html(t, e);
|
|
2118
|
+
if (r instanceof $)
|
|
2119
|
+
return se(r.value().slice(t, t + e)).replaceAll(" ", " ");
|
|
2120
|
+
if (r instanceof T) {
|
|
2121
|
+
if (r.statics.blotName === "list-container") {
|
|
2122
|
+
const c = [];
|
|
2123
|
+
return r.children.forEachAt(t, e, (h, d, g) => {
|
|
2124
|
+
const b = "formats" in h && typeof h.formats == "function" ? h.formats() : {};
|
|
2125
|
+
c.push({
|
|
2126
|
+
child: h,
|
|
2127
|
+
offset: d,
|
|
2128
|
+
length: g,
|
|
2129
|
+
indent: b.indent || 0,
|
|
2130
|
+
type: b.list
|
|
2131
|
+
});
|
|
2132
|
+
}), Q(c, -1, []);
|
|
2133
|
+
}
|
|
2134
|
+
const i = [];
|
|
2135
|
+
if (r.children.forEachAt(t, e, (c, h, d) => {
|
|
2136
|
+
i.push(nt(c, h, d));
|
|
2137
|
+
}), s || r.statics.blotName === "list")
|
|
2138
|
+
return i.join("");
|
|
2139
|
+
const { outerHTML: n, innerHTML: o } = r.domNode, [l, a] = n.split(`>${o}<`);
|
|
2140
|
+
return l === "<table" ? `<table style="border: 1px solid #000;">${i.join("")}<${a}` : `${l}>${i.join("")}<${a}`;
|
|
2141
|
+
}
|
|
2142
|
+
return r.domNode instanceof Element ? r.domNode.outerHTML : "";
|
|
2143
|
+
}
|
|
2144
|
+
function ke(r, t) {
|
|
2145
|
+
return Object.keys(t).reduce(
|
|
2146
|
+
(e, s) => {
|
|
2147
|
+
if (r[s] == null) return e;
|
|
2148
|
+
const i = t[s];
|
|
2149
|
+
return i === r[s] ? e[s] = i : Array.isArray(i) ? i.indexOf(r[s]) < 0 ? e[s] = i.concat([r[s]]) : e[s] = i : e[s] = [i, r[s]], e;
|
|
2150
|
+
},
|
|
2151
|
+
{}
|
|
2152
|
+
);
|
|
2153
|
+
}
|
|
2154
|
+
function Tt(r) {
|
|
2155
|
+
const t = r === "ordered" ? "ol" : "ul";
|
|
2156
|
+
switch (r) {
|
|
2157
|
+
case "checked":
|
|
2158
|
+
return [t, ' data-list="checked"'];
|
|
2159
|
+
case "unchecked":
|
|
2160
|
+
return [t, ' data-list="unchecked"'];
|
|
2161
|
+
default:
|
|
2162
|
+
return [t, ""];
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
function _t(r) {
|
|
2166
|
+
return r.reduce((t, e) => {
|
|
2167
|
+
if (typeof e.insert == "string") {
|
|
2168
|
+
const s = e.insert.replace(/\r\n/g, `
|
|
2169
|
+
`).replace(/\r/g, `
|
|
2170
|
+
`);
|
|
2171
|
+
return t.insert(s, e.attributes);
|
|
2172
|
+
}
|
|
2173
|
+
return t.push(e);
|
|
2174
|
+
}, new f());
|
|
2175
|
+
}
|
|
2176
|
+
function zt({ index: r, length: t }, e) {
|
|
2177
|
+
return new rt(r + e, t);
|
|
2178
|
+
}
|
|
2179
|
+
function Oe(r) {
|
|
2180
|
+
const t = [];
|
|
2181
|
+
return r.forEach((e) => {
|
|
2182
|
+
typeof e.insert == "string" ? e.insert.split(`
|
|
2183
|
+
`).forEach((i, n) => {
|
|
2184
|
+
n && t.push({ insert: `
|
|
2185
|
+
`, attributes: e.attributes }), i && t.push({ insert: i, attributes: e.attributes });
|
|
2186
|
+
}) : t.push(e);
|
|
2187
|
+
}), t;
|
|
2188
|
+
}
|
|
2189
|
+
class Y {
|
|
2190
|
+
constructor(t, e = {}) {
|
|
2191
|
+
this.rich = t, this.options = e;
|
|
2192
|
+
}
|
|
2193
|
+
static {
|
|
2194
|
+
this.DEFAULTS = {};
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
class mt {
|
|
2198
|
+
constructor(t, e) {
|
|
2199
|
+
this.rich = t, this.options = e, this.modules = {};
|
|
2200
|
+
}
|
|
2201
|
+
static {
|
|
2202
|
+
this.DEFAULTS = {
|
|
2203
|
+
modules: {}
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
static {
|
|
2207
|
+
this.themes = {
|
|
2208
|
+
default: mt
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
init() {
|
|
2212
|
+
Object.keys(this.options.modules).forEach((t) => {
|
|
2213
|
+
this.modules[t] == null && this.addModule(t);
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
addModule(t) {
|
|
2217
|
+
const e = this.rich.constructor.import(`modules/${t}`);
|
|
2218
|
+
return this.modules[t] = new e(
|
|
2219
|
+
this.rich,
|
|
2220
|
+
this.options.modules[t] || {}
|
|
2221
|
+
), this.modules[t];
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
const ve = 100, xe = ["block", "break", "cursor", "inline", "scroll", "text"], Re = (r, t, e) => {
|
|
2225
|
+
const s = new K();
|
|
2226
|
+
return xe.forEach((i) => {
|
|
2227
|
+
const n = t.query(i);
|
|
2228
|
+
n && s.register(n);
|
|
2229
|
+
}), r.forEach((i) => {
|
|
2230
|
+
let n = t.query(i);
|
|
2231
|
+
n || e.error(
|
|
2232
|
+
`Cannot register "${i}" specified in "formats" config. Are you sure it was registered?`
|
|
2233
|
+
);
|
|
2234
|
+
let o = 0;
|
|
2235
|
+
for (; n; )
|
|
2236
|
+
if (s.register(n), n = "blotName" in n ? n.requiredContainer ?? null : null, o += 1, o > ve) {
|
|
2237
|
+
e.error(
|
|
2238
|
+
`Cycle detected in registering blot requiredContainer: "${i}"`
|
|
2239
|
+
);
|
|
2240
|
+
break;
|
|
2241
|
+
}
|
|
2242
|
+
}), s;
|
|
2243
|
+
}, Se = (r) => r.parentElement || r.getRootNode().host || null, Ie = (r) => {
|
|
2244
|
+
const t = r.getBoundingClientRect(), e = "offsetWidth" in r && Math.abs(t.width) / r.offsetWidth || 1, s = "offsetHeight" in r && Math.abs(t.height) / r.offsetHeight || 1;
|
|
2245
|
+
return {
|
|
2246
|
+
top: t.top,
|
|
2247
|
+
right: t.left + r.clientWidth * e,
|
|
2248
|
+
bottom: t.top + r.clientHeight * s,
|
|
2249
|
+
left: t.left
|
|
2250
|
+
};
|
|
2251
|
+
}, ct = (r) => {
|
|
2252
|
+
const t = parseInt(r, 10);
|
|
2253
|
+
return Number.isNaN(t) ? 0 : t;
|
|
2254
|
+
}, Kt = (r, t, e, s, i, n) => r < e && t > s ? 0 : r < e ? -(e - r + i) : t > s ? t - r > s - e ? r + i - e : t - s + n : 0, Be = (r, t, e = {}) => {
|
|
2255
|
+
const s = r.ownerDocument;
|
|
2256
|
+
let i = t;
|
|
2257
|
+
const n = [];
|
|
2258
|
+
let o = r;
|
|
2259
|
+
for (; o; ) {
|
|
2260
|
+
const l = o === s.body, a = l ? {
|
|
2261
|
+
top: 0,
|
|
2262
|
+
right: window.visualViewport?.width ?? s.documentElement.clientWidth,
|
|
2263
|
+
bottom: window.visualViewport?.height ?? s.documentElement.clientHeight,
|
|
2264
|
+
left: 0
|
|
2265
|
+
} : Ie(o), c = getComputedStyle(o), h = Kt(
|
|
2266
|
+
i.left,
|
|
2267
|
+
i.right,
|
|
2268
|
+
a.left,
|
|
2269
|
+
a.right,
|
|
2270
|
+
ct(c.scrollPaddingLeft),
|
|
2271
|
+
ct(c.scrollPaddingRight)
|
|
2272
|
+
), d = Kt(
|
|
2273
|
+
i.top,
|
|
2274
|
+
i.bottom,
|
|
2275
|
+
a.top,
|
|
2276
|
+
a.bottom,
|
|
2277
|
+
ct(c.scrollPaddingTop),
|
|
2278
|
+
ct(c.scrollPaddingBottom)
|
|
2279
|
+
);
|
|
2280
|
+
if (h || d)
|
|
2281
|
+
if (l)
|
|
2282
|
+
s.defaultView && (n.push({
|
|
2283
|
+
element: s.defaultView,
|
|
2284
|
+
left: h,
|
|
2285
|
+
top: d
|
|
2286
|
+
}), s.defaultView.scrollBy(h, d));
|
|
2287
|
+
else {
|
|
2288
|
+
const { scrollLeft: g, scrollTop: b } = o;
|
|
2289
|
+
d && (o.scrollTop += d), h && (o.scrollLeft += h), n.push({
|
|
2290
|
+
element: o,
|
|
2291
|
+
left: h,
|
|
2292
|
+
top: d
|
|
2293
|
+
});
|
|
2294
|
+
const N = o.scrollLeft - g, E = o.scrollTop - b;
|
|
2295
|
+
i = {
|
|
2296
|
+
left: i.left - N,
|
|
2297
|
+
top: i.top - E,
|
|
2298
|
+
right: i.right - N,
|
|
2299
|
+
bottom: i.bottom - E
|
|
2300
|
+
};
|
|
2301
|
+
}
|
|
2302
|
+
o = l || c.position === "fixed" ? null : Se(o);
|
|
2303
|
+
}
|
|
2304
|
+
e.smooth && n.forEach(({ element: l, top: a, left: c }) => {
|
|
2305
|
+
l.scrollBy({ top: -a, left: -c, behavior: "instant" }), l.scrollBy({ top: a, left: c, behavior: "smooth" });
|
|
2306
|
+
});
|
|
2307
|
+
}, tt = G("rich"), ht = new K();
|
|
2308
|
+
T.uiClass = `${L}-ui`;
|
|
2309
|
+
class u {
|
|
2310
|
+
static {
|
|
2311
|
+
this.DEFAULTS = {
|
|
2312
|
+
bounds: null,
|
|
2313
|
+
modules: {
|
|
2314
|
+
clipboard: !0,
|
|
2315
|
+
keyboard: !0,
|
|
2316
|
+
history: !0,
|
|
2317
|
+
uploader: !0
|
|
2318
|
+
},
|
|
2319
|
+
placeholder: "",
|
|
2320
|
+
readOnly: !1,
|
|
2321
|
+
registry: ht,
|
|
2322
|
+
theme: "default"
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
static {
|
|
2326
|
+
this.events = m.events;
|
|
2327
|
+
}
|
|
2328
|
+
static {
|
|
2329
|
+
this.sources = m.sources;
|
|
2330
|
+
}
|
|
2331
|
+
static {
|
|
2332
|
+
this.imports = {
|
|
2333
|
+
delta: f,
|
|
2334
|
+
parchment: Ne,
|
|
2335
|
+
"core/module": Y,
|
|
2336
|
+
"core/theme": mt
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
static debug(t) {
|
|
2340
|
+
t === !0 && (t = "log"), G.level(t);
|
|
2341
|
+
}
|
|
2342
|
+
static find(t, e = !1) {
|
|
2343
|
+
return vt.get(t) || ht.find(t, e);
|
|
2344
|
+
}
|
|
2345
|
+
static import(t) {
|
|
2346
|
+
return this.imports[t] == null && tt.error(`Cannot import ${t}. Are you sure it was registered?`), this.imports[t];
|
|
2347
|
+
}
|
|
2348
|
+
static register(...t) {
|
|
2349
|
+
if (typeof t[0] != "string") {
|
|
2350
|
+
const e = t[0], s = !!t[1], i = "attrName" in e ? e.attrName : e.blotName;
|
|
2351
|
+
typeof i == "string" ? this.register(`formats/${i}`, e, s) : Object.keys(e).forEach((n) => {
|
|
2352
|
+
this.register(n, e[n], s);
|
|
2353
|
+
});
|
|
2354
|
+
} else {
|
|
2355
|
+
const e = t[0], s = t[1], i = !!t[2];
|
|
2356
|
+
this.imports[e] != null && !i && tt.warn(`Overwriting ${e} with`, s), this.imports[e] = s, (e.startsWith("blots/") || e.startsWith("formats/")) && s && typeof s != "boolean" && s.blotName !== "abstract" && ht.register(s), typeof s.register == "function" && s.register(ht);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
constructor(t, e = {}) {
|
|
2360
|
+
if (this.options = De(t, e), this.container = this.options.container, this.container == null) {
|
|
2361
|
+
tt.error("Invalid Rich container", t);
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
this.options.debug && u.debug(this.options.debug);
|
|
2365
|
+
const s = this.container.innerHTML.trim();
|
|
2366
|
+
this.container.classList.add(`${L}-container`), this.container.innerHTML = "", vt.set(this.container, this), this.root = this.addContainer(`${L}-editor`), this.root.classList.add(`${L}-blank`), this.emitter = new m();
|
|
2367
|
+
const i = It.blotName, n = this.options.registry.query(i);
|
|
2368
|
+
if (!n || !("blotName" in n))
|
|
2369
|
+
throw new Error(
|
|
2370
|
+
`Cannot initialize Rich without "${i}" blot`
|
|
2371
|
+
);
|
|
2372
|
+
if (this.scroll = new n(this.options.registry, this.root, {
|
|
2373
|
+
emitter: this.emitter
|
|
2374
|
+
}), this.editor = new Ce(this.scroll), this.selection = new Ae(this.scroll, this.emitter), this.composition = new Te(this.scroll, this.emitter), this.theme = new this.options.theme(this, this.options), this.keyboard = this.theme.addModule("keyboard"), this.clipboard = this.theme.addModule("clipboard"), this.history = this.theme.addModule("history"), this.uploader = this.theme.addModule("uploader"), this.theme.addModule("input"), this.theme.addModule("uiNode"), this.theme.init(), this.emitter.on(m.events.EDITOR_CHANGE, (o) => {
|
|
2375
|
+
o === m.events.TEXT_CHANGE && this.root.classList.toggle(
|
|
2376
|
+
`${L}-blank`,
|
|
2377
|
+
this.editor.isBlank()
|
|
2378
|
+
);
|
|
2379
|
+
}), this.emitter.on(m.events.SCROLL_UPDATE, (o, l) => {
|
|
2380
|
+
const a = this.selection.lastRange, [c] = this.selection.getRange(), h = a && c ? { oldRange: a, newRange: c } : void 0;
|
|
2381
|
+
S.call(
|
|
2382
|
+
this,
|
|
2383
|
+
() => this.editor.update(null, l, h),
|
|
2384
|
+
o
|
|
2385
|
+
);
|
|
2386
|
+
}), this.emitter.on(m.events.SCROLL_EMBED_UPDATE, (o, l) => {
|
|
2387
|
+
const a = this.selection.lastRange, [c] = this.selection.getRange(), h = a && c ? { oldRange: a, newRange: c } : void 0;
|
|
2388
|
+
S.call(
|
|
2389
|
+
this,
|
|
2390
|
+
() => {
|
|
2391
|
+
const d = new f().retain(o.offset(this)).retain({ [o.statics.blotName]: l });
|
|
2392
|
+
return this.editor.update(d, [], h);
|
|
2393
|
+
},
|
|
2394
|
+
u.sources.USER
|
|
2395
|
+
);
|
|
2396
|
+
}), s) {
|
|
2397
|
+
const o = this.clipboard.convert({
|
|
2398
|
+
html: `${s}<p><br></p>`,
|
|
2399
|
+
text: `
|
|
2400
|
+
`
|
|
2401
|
+
});
|
|
2402
|
+
this.setContents(o);
|
|
2403
|
+
}
|
|
2404
|
+
this.history.clear(), this.options.placeholder && this.root.setAttribute("data-placeholder", this.options.placeholder), this.options.readOnly && this.disable(), this.allowReadOnlyEdits = !1;
|
|
2405
|
+
}
|
|
2406
|
+
addContainer(t, e = null) {
|
|
2407
|
+
if (typeof t == "string") {
|
|
2408
|
+
const s = t;
|
|
2409
|
+
t = document.createElement("div"), t.classList.add(s);
|
|
2410
|
+
}
|
|
2411
|
+
return this.container.insertBefore(t, e), t;
|
|
2412
|
+
}
|
|
2413
|
+
blur() {
|
|
2414
|
+
this.selection.setRange(null);
|
|
2415
|
+
}
|
|
2416
|
+
deleteText(t, e, s) {
|
|
2417
|
+
return [t, e, , s] = P(t, e, s), S.call(
|
|
2418
|
+
this,
|
|
2419
|
+
() => this.editor.deleteText(t, e),
|
|
2420
|
+
s,
|
|
2421
|
+
t,
|
|
2422
|
+
-1 * e
|
|
2423
|
+
);
|
|
2424
|
+
}
|
|
2425
|
+
disable() {
|
|
2426
|
+
this.enable(!1);
|
|
2427
|
+
}
|
|
2428
|
+
editReadOnly(t) {
|
|
2429
|
+
this.allowReadOnlyEdits = !0;
|
|
2430
|
+
const e = t();
|
|
2431
|
+
return this.allowReadOnlyEdits = !1, e;
|
|
2432
|
+
}
|
|
2433
|
+
enable(t = !0) {
|
|
2434
|
+
this.scroll.enable(t), this.container.classList.toggle(
|
|
2435
|
+
`${L}-disabled`,
|
|
2436
|
+
!t
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
focus(t = {}) {
|
|
2440
|
+
this.selection.focus(), t.preventScroll || this.scrollSelectionIntoView();
|
|
2441
|
+
}
|
|
2442
|
+
format(t, e, s = m.sources.API) {
|
|
2443
|
+
return S.call(
|
|
2444
|
+
this,
|
|
2445
|
+
() => {
|
|
2446
|
+
const i = this.getSelection(!0);
|
|
2447
|
+
let n = new f();
|
|
2448
|
+
if (i == null) return n;
|
|
2449
|
+
if (this.scroll.query(t, p.BLOCK))
|
|
2450
|
+
n = this.editor.formatLine(i.index, i.length, {
|
|
2451
|
+
[t]: e
|
|
2452
|
+
});
|
|
2453
|
+
else {
|
|
2454
|
+
if (i.length === 0)
|
|
2455
|
+
return this.selection.format(t, e), n;
|
|
2456
|
+
n = this.editor.formatText(i.index, i.length, {
|
|
2457
|
+
[t]: e
|
|
2458
|
+
});
|
|
2459
|
+
}
|
|
2460
|
+
return this.setSelection(i, m.sources.SILENT), n;
|
|
2461
|
+
},
|
|
2462
|
+
s
|
|
2463
|
+
);
|
|
2464
|
+
}
|
|
2465
|
+
formatLine(t, e, s, i, n) {
|
|
2466
|
+
let o;
|
|
2467
|
+
return [t, e, o, n] = P(
|
|
2468
|
+
t,
|
|
2469
|
+
e,
|
|
2470
|
+
s,
|
|
2471
|
+
i,
|
|
2472
|
+
n
|
|
2473
|
+
), S.call(
|
|
2474
|
+
this,
|
|
2475
|
+
() => this.editor.formatLine(t, e, o),
|
|
2476
|
+
n,
|
|
2477
|
+
t,
|
|
2478
|
+
0
|
|
2479
|
+
);
|
|
2480
|
+
}
|
|
2481
|
+
formatText(t, e, s, i, n) {
|
|
2482
|
+
let o;
|
|
2483
|
+
return [t, e, o, n] = P(
|
|
2484
|
+
t,
|
|
2485
|
+
e,
|
|
2486
|
+
s,
|
|
2487
|
+
i,
|
|
2488
|
+
n
|
|
2489
|
+
), S.call(
|
|
2490
|
+
this,
|
|
2491
|
+
() => this.editor.formatText(t, e, o),
|
|
2492
|
+
n,
|
|
2493
|
+
t,
|
|
2494
|
+
0
|
|
2495
|
+
);
|
|
2496
|
+
}
|
|
2497
|
+
getBounds(t, e = 0) {
|
|
2498
|
+
let s = null;
|
|
2499
|
+
if (typeof t == "number" ? s = this.selection.getBounds(t, e) : s = this.selection.getBounds(t.index, t.length), !s) return null;
|
|
2500
|
+
const i = this.container.getBoundingClientRect();
|
|
2501
|
+
return {
|
|
2502
|
+
bottom: s.bottom - i.top,
|
|
2503
|
+
height: s.height,
|
|
2504
|
+
left: s.left - i.left,
|
|
2505
|
+
right: s.right - i.left,
|
|
2506
|
+
top: s.top - i.top,
|
|
2507
|
+
width: s.width
|
|
2508
|
+
};
|
|
2509
|
+
}
|
|
2510
|
+
getContents(t = 0, e = this.getLength() - t) {
|
|
2511
|
+
return [t, e] = P(t, e), this.editor.getContents(t, e);
|
|
2512
|
+
}
|
|
2513
|
+
getFormat(t = this.getSelection(!0), e = 0) {
|
|
2514
|
+
return typeof t == "number" ? this.editor.getFormat(t, e) : this.editor.getFormat(t.index, t.length);
|
|
2515
|
+
}
|
|
2516
|
+
getIndex(t) {
|
|
2517
|
+
return t.offset(this.scroll);
|
|
2518
|
+
}
|
|
2519
|
+
getLength() {
|
|
2520
|
+
return this.scroll.length();
|
|
2521
|
+
}
|
|
2522
|
+
getLeaf(t) {
|
|
2523
|
+
return this.scroll.leaf(t);
|
|
2524
|
+
}
|
|
2525
|
+
getLine(t) {
|
|
2526
|
+
return this.scroll.line(t);
|
|
2527
|
+
}
|
|
2528
|
+
getLines(t = 0, e = Number.MAX_VALUE) {
|
|
2529
|
+
return typeof t != "number" ? this.scroll.lines(t.index, t.length) : this.scroll.lines(t, e);
|
|
2530
|
+
}
|
|
2531
|
+
getModule(t) {
|
|
2532
|
+
return this.theme.modules[t];
|
|
2533
|
+
}
|
|
2534
|
+
getSelection(t = !1) {
|
|
2535
|
+
return t && this.focus(), this.update(), this.selection.getRange()[0];
|
|
2536
|
+
}
|
|
2537
|
+
getSemanticHTML(t = 0, e) {
|
|
2538
|
+
return typeof t == "number" && (e = e ?? this.getLength() - t), [t, e] = P(t, e), this.editor.getHTML(t, e);
|
|
2539
|
+
}
|
|
2540
|
+
getText(t = 0, e) {
|
|
2541
|
+
return typeof t == "number" && (e = e ?? this.getLength() - t), [t, e] = P(t, e), this.editor.getText(t, e);
|
|
2542
|
+
}
|
|
2543
|
+
hasFocus() {
|
|
2544
|
+
return this.selection.hasFocus();
|
|
2545
|
+
}
|
|
2546
|
+
insertEmbed(t, e, s, i = u.sources.API) {
|
|
2547
|
+
return S.call(
|
|
2548
|
+
this,
|
|
2549
|
+
() => this.editor.insertEmbed(t, e, s),
|
|
2550
|
+
i,
|
|
2551
|
+
t
|
|
2552
|
+
);
|
|
2553
|
+
}
|
|
2554
|
+
insertText(t, e, s, i, n) {
|
|
2555
|
+
let o;
|
|
2556
|
+
return [t, , o, n] = P(t, 0, s, i, n), S.call(
|
|
2557
|
+
this,
|
|
2558
|
+
() => this.editor.insertText(t, e, o),
|
|
2559
|
+
n,
|
|
2560
|
+
t,
|
|
2561
|
+
e.length
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
isEnabled() {
|
|
2565
|
+
return this.scroll.isEnabled();
|
|
2566
|
+
}
|
|
2567
|
+
off(...t) {
|
|
2568
|
+
return this.emitter.off(...t);
|
|
2569
|
+
}
|
|
2570
|
+
on(...t) {
|
|
2571
|
+
return this.emitter.on(...t);
|
|
2572
|
+
}
|
|
2573
|
+
once(...t) {
|
|
2574
|
+
return this.emitter.once(...t);
|
|
2575
|
+
}
|
|
2576
|
+
removeFormat(t, e, s) {
|
|
2577
|
+
return [t, e, , s] = P(t, e, s), S.call(
|
|
2578
|
+
this,
|
|
2579
|
+
() => this.editor.removeFormat(t, e),
|
|
2580
|
+
s,
|
|
2581
|
+
t
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
scrollRectIntoView(t, e = {}) {
|
|
2585
|
+
Be(this.root, t, e);
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* @deprecated Use Rich#scrollSelectionIntoView() instead.
|
|
2589
|
+
*/
|
|
2590
|
+
scrollIntoView() {
|
|
2591
|
+
console.warn(
|
|
2592
|
+
"Rich#scrollIntoView() has been deprecated and will be removed in the near future. Please use Rich#scrollSelectionIntoView() instead."
|
|
2593
|
+
), this.scrollSelectionIntoView();
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* Scroll the current selection into the visible area.
|
|
2597
|
+
* If the selection is already visible, no scrolling will occur.
|
|
2598
|
+
*/
|
|
2599
|
+
scrollSelectionIntoView(t = {}) {
|
|
2600
|
+
const e = this.selection.lastRange, s = e && this.selection.getBounds(e.index, e.length);
|
|
2601
|
+
s && this.scrollRectIntoView(s, t);
|
|
2602
|
+
}
|
|
2603
|
+
setContents(t, e = m.sources.API) {
|
|
2604
|
+
return S.call(
|
|
2605
|
+
this,
|
|
2606
|
+
() => {
|
|
2607
|
+
t = new f(t);
|
|
2608
|
+
const s = this.getLength(), i = this.editor.deleteText(0, s), n = this.editor.insertContents(0, t), o = this.editor.deleteText(this.getLength() - 1, 1);
|
|
2609
|
+
return i.compose(n).compose(o);
|
|
2610
|
+
},
|
|
2611
|
+
e
|
|
2612
|
+
);
|
|
2613
|
+
}
|
|
2614
|
+
setSelection(t, e, s) {
|
|
2615
|
+
t == null ? this.selection.setRange(null, e || u.sources.API) : ([t, e, , s] = P(t, e, s), this.selection.setRange(new rt(Math.max(0, t), e), s), s !== m.sources.SILENT && this.scrollSelectionIntoView());
|
|
2616
|
+
}
|
|
2617
|
+
setText(t, e = m.sources.API) {
|
|
2618
|
+
const s = new f().insert(t);
|
|
2619
|
+
return this.setContents(s, e);
|
|
2620
|
+
}
|
|
2621
|
+
update(t = m.sources.USER) {
|
|
2622
|
+
const e = this.scroll.update(t);
|
|
2623
|
+
return this.selection.update(t), e;
|
|
2624
|
+
}
|
|
2625
|
+
updateContents(t, e = m.sources.API) {
|
|
2626
|
+
return S.call(
|
|
2627
|
+
this,
|
|
2628
|
+
() => (t = new f(t), this.editor.applyDelta(t)),
|
|
2629
|
+
e,
|
|
2630
|
+
!0
|
|
2631
|
+
);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
function qt(r) {
|
|
2635
|
+
return typeof r == "string" ? document.querySelector(r) : r;
|
|
2636
|
+
}
|
|
2637
|
+
function Lt(r) {
|
|
2638
|
+
return Object.entries(r ?? {}).reduce(
|
|
2639
|
+
(t, [e, s]) => ({
|
|
2640
|
+
...t,
|
|
2641
|
+
[e]: s === !0 ? {} : s
|
|
2642
|
+
}),
|
|
2643
|
+
{}
|
|
2644
|
+
);
|
|
2645
|
+
}
|
|
2646
|
+
function Ht(r) {
|
|
2647
|
+
return Object.fromEntries(
|
|
2648
|
+
Object.entries(r).filter((t) => t[1] !== void 0)
|
|
2649
|
+
);
|
|
2650
|
+
}
|
|
2651
|
+
function De(r, t) {
|
|
2652
|
+
const e = qt(r);
|
|
2653
|
+
if (!e)
|
|
2654
|
+
throw new Error("Invalid Rich container");
|
|
2655
|
+
const i = !t.theme || t.theme === u.DEFAULTS.theme ? mt : u.import(`themes/${t.theme}`);
|
|
2656
|
+
if (!i)
|
|
2657
|
+
throw new Error(`Invalid theme ${t.theme}. Did you register it?`);
|
|
2658
|
+
const { modules: n, ...o } = u.DEFAULTS, { modules: l, ...a } = i.DEFAULTS;
|
|
2659
|
+
let c = Lt(t.modules);
|
|
2660
|
+
c != null && c.toolbar && c.toolbar.constructor !== Object && (c = {
|
|
2661
|
+
...c,
|
|
2662
|
+
toolbar: { container: c.toolbar }
|
|
2663
|
+
});
|
|
2664
|
+
const h = it(
|
|
2665
|
+
{},
|
|
2666
|
+
Lt(n),
|
|
2667
|
+
Lt(l),
|
|
2668
|
+
c
|
|
2669
|
+
), d = {
|
|
2670
|
+
...o,
|
|
2671
|
+
...Ht(a),
|
|
2672
|
+
...Ht(t)
|
|
2673
|
+
};
|
|
2674
|
+
let g = t.registry;
|
|
2675
|
+
return g ? t.formats && tt.warn('Ignoring "formats" option because "registry" is specified') : g = t.formats ? Re(t.formats, d.registry, tt) : d.registry, {
|
|
2676
|
+
...d,
|
|
2677
|
+
registry: g,
|
|
2678
|
+
container: e,
|
|
2679
|
+
theme: i,
|
|
2680
|
+
modules: Object.entries(h).reduce(
|
|
2681
|
+
(b, [N, E]) => {
|
|
2682
|
+
if (!E) return b;
|
|
2683
|
+
const w = u.import(`modules/${N}`);
|
|
2684
|
+
return w == null ? (tt.error(
|
|
2685
|
+
`Cannot load ${N} module. Are you sure you registered it?`
|
|
2686
|
+
), b) : {
|
|
2687
|
+
...b,
|
|
2688
|
+
[N]: it({}, w.DEFAULTS || {}, E)
|
|
2689
|
+
};
|
|
2690
|
+
},
|
|
2691
|
+
{}
|
|
2692
|
+
),
|
|
2693
|
+
bounds: qt(d.bounds)
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
function S(r, t, e, s) {
|
|
2697
|
+
if (!this.isEnabled() && t === m.sources.USER && !this.allowReadOnlyEdits)
|
|
2698
|
+
return new f();
|
|
2699
|
+
let i = e == null ? null : this.getSelection();
|
|
2700
|
+
const n = this.editor.delta, o = r();
|
|
2701
|
+
if (i != null && (e === !0 && (e = i.index), s == null ? i = Wt(i, o, t) : s !== 0 && (i = Wt(i, e, s, t)), this.setSelection(i, m.sources.SILENT)), o.length() > 0) {
|
|
2702
|
+
const l = [m.events.TEXT_CHANGE, o, n, t];
|
|
2703
|
+
this.emitter.emit(m.events.EDITOR_CHANGE, ...l), t !== m.sources.SILENT && this.emitter.emit(...l);
|
|
2704
|
+
}
|
|
2705
|
+
return o;
|
|
2706
|
+
}
|
|
2707
|
+
function P(r, t, e, s, i) {
|
|
2708
|
+
let n = {};
|
|
2709
|
+
return typeof r.index == "number" && typeof r.length == "number" ? typeof t != "number" ? (i = s, s = e, e = t, t = r.length, r = r.index) : (t = r.length, r = r.index) : typeof t != "number" && (i = s, s = e, e = t, t = 0), typeof e == "object" ? (n = e, i = s) : typeof e == "string" && (s != null ? n[e] = s : i = e), i = i || m.sources.API, [r, t, n, i];
|
|
2710
|
+
}
|
|
2711
|
+
function Wt(r, t, e, s) {
|
|
2712
|
+
const i = typeof e == "number" ? e : 0;
|
|
2713
|
+
if (r == null) return null;
|
|
2714
|
+
let n, o;
|
|
2715
|
+
return t && typeof t.transformPosition == "function" ? [n, o] = [r.index, r.index + r.length].map(
|
|
2716
|
+
(l) => t.transformPosition(l, s !== m.sources.USER)
|
|
2717
|
+
) : [n, o] = [r.index, r.index + r.length].map((l) => l < t || l === t && s === m.sources.USER ? l : i >= 0 ? l + i : Math.max(t, l + i)), new rt(n, o - n);
|
|
2718
|
+
}
|
|
2719
|
+
class Bt extends dt {
|
|
2720
|
+
}
|
|
2721
|
+
function Vt(r) {
|
|
2722
|
+
return r instanceof O || r instanceof I;
|
|
2723
|
+
}
|
|
2724
|
+
function Gt(r) {
|
|
2725
|
+
return typeof r.updateContent == "function";
|
|
2726
|
+
}
|
|
2727
|
+
class Me extends It {
|
|
2728
|
+
static {
|
|
2729
|
+
this.blotName = "scroll";
|
|
2730
|
+
}
|
|
2731
|
+
static {
|
|
2732
|
+
this.className = `${L}-editor`;
|
|
2733
|
+
}
|
|
2734
|
+
static {
|
|
2735
|
+
this.tagName = "DIV";
|
|
2736
|
+
}
|
|
2737
|
+
static {
|
|
2738
|
+
this.defaultChild = O;
|
|
2739
|
+
}
|
|
2740
|
+
static {
|
|
2741
|
+
this.allowedChildren = [O, I, Bt];
|
|
2742
|
+
}
|
|
2743
|
+
constructor(t, e, { emitter: s }) {
|
|
2744
|
+
super(t, e), this.emitter = s, this.batch = !1, this.optimize(), this.enable(), this.domNode.addEventListener("dragstart", (i) => this.handleDragStart(i));
|
|
2745
|
+
}
|
|
2746
|
+
batchStart() {
|
|
2747
|
+
Array.isArray(this.batch) || (this.batch = []);
|
|
2748
|
+
}
|
|
2749
|
+
batchEnd() {
|
|
2750
|
+
if (!this.batch) return;
|
|
2751
|
+
const t = this.batch;
|
|
2752
|
+
this.batch = !1, this.update(t);
|
|
2753
|
+
}
|
|
2754
|
+
emitMount(t) {
|
|
2755
|
+
this.emitter.emit(m.events.SCROLL_BLOT_MOUNT, t);
|
|
2756
|
+
}
|
|
2757
|
+
emitUnmount(t) {
|
|
2758
|
+
this.emitter.emit(m.events.SCROLL_BLOT_UNMOUNT, t);
|
|
2759
|
+
}
|
|
2760
|
+
emitEmbedUpdate(t, e) {
|
|
2761
|
+
this.emitter.emit(m.events.SCROLL_EMBED_UPDATE, t, e);
|
|
2762
|
+
}
|
|
2763
|
+
deleteAt(t, e) {
|
|
2764
|
+
const [s, i] = this.line(t), [n] = this.line(t + e);
|
|
2765
|
+
if (super.deleteAt(t, e), n != null && s !== n && i > 0) {
|
|
2766
|
+
if (s instanceof I || n instanceof I) {
|
|
2767
|
+
this.optimize();
|
|
2768
|
+
return;
|
|
2769
|
+
}
|
|
2770
|
+
const o = n.children.head instanceof F ? null : n.children.head;
|
|
2771
|
+
s.moveChildren(n, o), s.remove();
|
|
2772
|
+
}
|
|
2773
|
+
this.optimize();
|
|
2774
|
+
}
|
|
2775
|
+
enable(t = !0) {
|
|
2776
|
+
this.domNode.setAttribute("contenteditable", t ? "true" : "false");
|
|
2777
|
+
}
|
|
2778
|
+
formatAt(t, e, s, i) {
|
|
2779
|
+
super.formatAt(t, e, s, i), this.optimize();
|
|
2780
|
+
}
|
|
2781
|
+
insertAt(t, e, s) {
|
|
2782
|
+
if (t >= this.length())
|
|
2783
|
+
if (s == null || this.scroll.query(e, p.BLOCK) == null) {
|
|
2784
|
+
const i = this.scroll.create(this.statics.defaultChild.blotName);
|
|
2785
|
+
this.appendChild(i), s == null && e.endsWith(`
|
|
2786
|
+
`) ? i.insertAt(0, e.slice(0, -1), s) : i.insertAt(0, e, s);
|
|
2787
|
+
} else {
|
|
2788
|
+
const i = this.scroll.create(e, s);
|
|
2789
|
+
this.appendChild(i);
|
|
2790
|
+
}
|
|
2791
|
+
else
|
|
2792
|
+
super.insertAt(t, e, s);
|
|
2793
|
+
this.optimize();
|
|
2794
|
+
}
|
|
2795
|
+
insertBefore(t, e) {
|
|
2796
|
+
if (t.statics.scope === p.INLINE_BLOT) {
|
|
2797
|
+
const s = this.scroll.create(
|
|
2798
|
+
this.statics.defaultChild.blotName
|
|
2799
|
+
);
|
|
2800
|
+
s.appendChild(t), super.insertBefore(s, e);
|
|
2801
|
+
} else
|
|
2802
|
+
super.insertBefore(t, e);
|
|
2803
|
+
}
|
|
2804
|
+
insertContents(t, e) {
|
|
2805
|
+
const s = this.deltaToRenderBlocks(
|
|
2806
|
+
e.concat(new f().insert(`
|
|
2807
|
+
`))
|
|
2808
|
+
), i = s.pop();
|
|
2809
|
+
if (i == null) return;
|
|
2810
|
+
this.batchStart();
|
|
2811
|
+
const n = s.shift();
|
|
2812
|
+
if (n) {
|
|
2813
|
+
const a = n.type === "block" && (n.delta.length() === 0 || !this.descendant(I, t)[0] && t < this.length()), c = n.type === "block" ? n.delta : new f().insert({ [n.key]: n.value });
|
|
2814
|
+
At(this, t, c);
|
|
2815
|
+
const h = n.type === "block" ? 1 : 0, d = t + c.length() + h;
|
|
2816
|
+
a && this.insertAt(d - 1, `
|
|
2817
|
+
`);
|
|
2818
|
+
const g = x(this.line(t)[0]), b = C.diff(g, n.attributes) || {};
|
|
2819
|
+
Object.keys(b).forEach((N) => {
|
|
2820
|
+
this.formatAt(d - 1, 1, N, b[N]);
|
|
2821
|
+
}), t = d;
|
|
2822
|
+
}
|
|
2823
|
+
let [o, l] = this.children.find(t);
|
|
2824
|
+
if (s.length && (o && (o = o.split(l), l = 0), s.forEach((a) => {
|
|
2825
|
+
if (a.type === "block") {
|
|
2826
|
+
const c = this.createBlock(
|
|
2827
|
+
a.attributes,
|
|
2828
|
+
o || void 0
|
|
2829
|
+
);
|
|
2830
|
+
At(c, 0, a.delta);
|
|
2831
|
+
} else {
|
|
2832
|
+
const c = this.create(
|
|
2833
|
+
a.key,
|
|
2834
|
+
a.value
|
|
2835
|
+
);
|
|
2836
|
+
this.insertBefore(c, o || void 0), Object.keys(a.attributes).forEach((h) => {
|
|
2837
|
+
c.format(h, a.attributes[h]);
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
})), i.type === "block" && i.delta.length()) {
|
|
2841
|
+
const a = o ? o.offset(o.scroll) + l : this.length();
|
|
2842
|
+
At(this, a, i.delta);
|
|
2843
|
+
}
|
|
2844
|
+
this.batchEnd(), this.optimize();
|
|
2845
|
+
}
|
|
2846
|
+
isEnabled() {
|
|
2847
|
+
return this.domNode.getAttribute("contenteditable") === "true";
|
|
2848
|
+
}
|
|
2849
|
+
leaf(t) {
|
|
2850
|
+
const e = this.path(t).pop();
|
|
2851
|
+
if (!e)
|
|
2852
|
+
return [null, -1];
|
|
2853
|
+
const [s, i] = e;
|
|
2854
|
+
return s instanceof A ? [s, i] : [null, -1];
|
|
2855
|
+
}
|
|
2856
|
+
line(t) {
|
|
2857
|
+
return t === this.length() ? this.line(t - 1) : this.descendant(Vt, t);
|
|
2858
|
+
}
|
|
2859
|
+
lines(t = 0, e = Number.MAX_VALUE) {
|
|
2860
|
+
const s = (i, n, o) => {
|
|
2861
|
+
let l = [], a = o;
|
|
2862
|
+
return i.children.forEachAt(
|
|
2863
|
+
n,
|
|
2864
|
+
o,
|
|
2865
|
+
(c, h, d) => {
|
|
2866
|
+
Vt(c) ? l.push(c) : c instanceof dt && (l = l.concat(s(c, h, a))), a -= d;
|
|
2867
|
+
}
|
|
2868
|
+
), l;
|
|
2869
|
+
};
|
|
2870
|
+
return s(this, t, e);
|
|
2871
|
+
}
|
|
2872
|
+
optimize(t = [], e = {}) {
|
|
2873
|
+
this.batch || (super.optimize(t, e), t.length > 0 && this.emitter.emit(m.events.SCROLL_OPTIMIZE, t, e));
|
|
2874
|
+
}
|
|
2875
|
+
path(t) {
|
|
2876
|
+
return super.path(t).slice(1);
|
|
2877
|
+
}
|
|
2878
|
+
remove() {
|
|
2879
|
+
}
|
|
2880
|
+
update(t) {
|
|
2881
|
+
if (this.batch) {
|
|
2882
|
+
Array.isArray(t) && (this.batch = this.batch.concat(t));
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2885
|
+
let e = m.sources.USER;
|
|
2886
|
+
typeof t == "string" && (e = t), Array.isArray(t) || (t = this.observer.takeRecords()), t = t.filter(({ target: s }) => {
|
|
2887
|
+
const i = this.find(s, !0);
|
|
2888
|
+
return i && !Gt(i);
|
|
2889
|
+
}), t.length > 0 && this.emitter.emit(m.events.SCROLL_BEFORE_UPDATE, e, t), super.update(t.concat([])), t.length > 0 && this.emitter.emit(m.events.SCROLL_UPDATE, e, t);
|
|
2890
|
+
}
|
|
2891
|
+
updateEmbedAt(t, e, s) {
|
|
2892
|
+
const [i] = this.descendant((n) => n instanceof I, t);
|
|
2893
|
+
i && i.statics.blotName === e && Gt(i) && i.updateContent(s);
|
|
2894
|
+
}
|
|
2895
|
+
handleDragStart(t) {
|
|
2896
|
+
t.preventDefault();
|
|
2897
|
+
}
|
|
2898
|
+
deltaToRenderBlocks(t) {
|
|
2899
|
+
const e = [];
|
|
2900
|
+
let s = new f();
|
|
2901
|
+
return t.forEach((i) => {
|
|
2902
|
+
const n = i?.insert;
|
|
2903
|
+
if (n)
|
|
2904
|
+
if (typeof n == "string") {
|
|
2905
|
+
const o = n.split(`
|
|
2906
|
+
`);
|
|
2907
|
+
o.slice(0, -1).forEach((a) => {
|
|
2908
|
+
s.insert(a, i.attributes), e.push({
|
|
2909
|
+
type: "block",
|
|
2910
|
+
delta: s,
|
|
2911
|
+
attributes: i.attributes ?? {}
|
|
2912
|
+
}), s = new f();
|
|
2913
|
+
});
|
|
2914
|
+
const l = o[o.length - 1];
|
|
2915
|
+
l && s.insert(l, i.attributes);
|
|
2916
|
+
} else {
|
|
2917
|
+
const o = Object.keys(n)[0];
|
|
2918
|
+
if (!o) return;
|
|
2919
|
+
this.query(o, p.INLINE) ? s.push(i) : (s.length() && e.push({
|
|
2920
|
+
type: "block",
|
|
2921
|
+
delta: s,
|
|
2922
|
+
attributes: {}
|
|
2923
|
+
}), s = new f(), e.push({
|
|
2924
|
+
type: "blockEmbed",
|
|
2925
|
+
key: o,
|
|
2926
|
+
value: n[o],
|
|
2927
|
+
attributes: i.attributes ?? {}
|
|
2928
|
+
}));
|
|
2929
|
+
}
|
|
2930
|
+
}), s.length() && e.push({
|
|
2931
|
+
type: "block",
|
|
2932
|
+
delta: s,
|
|
2933
|
+
attributes: {}
|
|
2934
|
+
}), e;
|
|
2935
|
+
}
|
|
2936
|
+
createBlock(t, e) {
|
|
2937
|
+
let s;
|
|
2938
|
+
const i = {};
|
|
2939
|
+
Object.entries(t).forEach(([l, a]) => {
|
|
2940
|
+
this.query(l, p.BLOCK & p.BLOT) != null ? s = l : i[l] = a;
|
|
2941
|
+
});
|
|
2942
|
+
const n = this.create(
|
|
2943
|
+
s || this.statics.defaultChild.blotName,
|
|
2944
|
+
s ? t[s] : void 0
|
|
2945
|
+
);
|
|
2946
|
+
this.insertBefore(n, e || void 0);
|
|
2947
|
+
const o = n.length();
|
|
2948
|
+
return Object.entries(i).forEach(([l, a]) => {
|
|
2949
|
+
n.formatAt(0, o, l, a);
|
|
2950
|
+
}), n;
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
function At(r, t, e) {
|
|
2954
|
+
e.reduce((s, i) => {
|
|
2955
|
+
const n = k.length(i);
|
|
2956
|
+
let o = i.attributes || {};
|
|
2957
|
+
if (i.insert != null) {
|
|
2958
|
+
if (typeof i.insert == "string") {
|
|
2959
|
+
const l = i.insert;
|
|
2960
|
+
r.insertAt(s, l);
|
|
2961
|
+
const [a] = r.descendant(A, s), c = x(a);
|
|
2962
|
+
o = C.diff(c, o) || {};
|
|
2963
|
+
} else if (typeof i.insert == "object") {
|
|
2964
|
+
const l = Object.keys(i.insert)[0];
|
|
2965
|
+
if (l == null) return s;
|
|
2966
|
+
if (r.insertAt(s, l, i.insert[l]), r.scroll.query(l, p.INLINE) != null) {
|
|
2967
|
+
const [c] = r.descendant(A, s), h = x(c);
|
|
2968
|
+
o = C.diff(h, o) || {};
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
return Object.keys(o).forEach((l) => {
|
|
2973
|
+
r.formatAt(s, n, l, o[l]);
|
|
2974
|
+
}), s + n;
|
|
2975
|
+
}, t);
|
|
2976
|
+
}
|
|
2977
|
+
const Dt = {
|
|
2978
|
+
scope: p.BLOCK,
|
|
2979
|
+
whitelist: ["right", "center", "justify"]
|
|
2980
|
+
}, Ue = new j("align", "align", Dt), zs = new q(
|
|
2981
|
+
"align",
|
|
2982
|
+
`${L}-align`,
|
|
2983
|
+
Dt
|
|
2984
|
+
), je = new V("align", "text-align", Dt);
|
|
2985
|
+
class ne extends V {
|
|
2986
|
+
value(t) {
|
|
2987
|
+
let e = super.value(t);
|
|
2988
|
+
return e.startsWith("rgb(") ? (e = e.replace(/^[^\d]+/, "").replace(/[^\d]+$/, ""), `#${e.split(",").map((i) => `00${parseInt(i, 10).toString(16)}`.slice(-2)).join("")}`) : e;
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
const Ks = new q(
|
|
2992
|
+
"color",
|
|
2993
|
+
`${L}-color`,
|
|
2994
|
+
{
|
|
2995
|
+
scope: p.INLINE
|
|
2996
|
+
}
|
|
2997
|
+
), $e = new ne("color", "color", {
|
|
2998
|
+
scope: p.INLINE
|
|
2999
|
+
}), qs = new q(
|
|
3000
|
+
"background",
|
|
3001
|
+
`${L}-bg`,
|
|
3002
|
+
{
|
|
3003
|
+
scope: p.INLINE
|
|
3004
|
+
}
|
|
3005
|
+
), Fe = new ne("background", "background-color", {
|
|
3006
|
+
scope: p.INLINE
|
|
3007
|
+
});
|
|
3008
|
+
class st extends Bt {
|
|
3009
|
+
static create(t) {
|
|
3010
|
+
const e = super.create(t);
|
|
3011
|
+
return e.setAttribute("spellcheck", "false"), e;
|
|
3012
|
+
}
|
|
3013
|
+
code(t, e) {
|
|
3014
|
+
return this.children.map((s) => s.length() <= 1 ? "" : s.domNode.innerText).join(`
|
|
3015
|
+
`).slice(t, t + e);
|
|
3016
|
+
}
|
|
3017
|
+
html(t, e) {
|
|
3018
|
+
return `<pre>
|
|
3019
|
+
${se(this.code(t, e))}
|
|
3020
|
+
</pre>`;
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
class z extends O {
|
|
3024
|
+
static {
|
|
3025
|
+
this.TAB = " ";
|
|
3026
|
+
}
|
|
3027
|
+
static register() {
|
|
3028
|
+
u.register(st);
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
class oe extends M {
|
|
3032
|
+
}
|
|
3033
|
+
oe.blotName = "code";
|
|
3034
|
+
oe.tagName = "CODE";
|
|
3035
|
+
z.blotName = "code-block";
|
|
3036
|
+
z.className = `${L}-code-block`;
|
|
3037
|
+
z.tagName = "DIV";
|
|
3038
|
+
st.blotName = "code-block-container";
|
|
3039
|
+
st.className = `${L}-code-block-container`;
|
|
3040
|
+
st.tagName = "DIV";
|
|
3041
|
+
st.allowedChildren = [z];
|
|
3042
|
+
z.allowedChildren = [$, F, U];
|
|
3043
|
+
z.requiredContainer = st;
|
|
3044
|
+
const Mt = {
|
|
3045
|
+
scope: p.BLOCK,
|
|
3046
|
+
whitelist: ["rtl"]
|
|
3047
|
+
}, Pe = new j("direction", "dir", Mt), Hs = new q(
|
|
3048
|
+
"direction",
|
|
3049
|
+
`${L}-direction`,
|
|
3050
|
+
Mt
|
|
3051
|
+
), _e = new V("direction", "direction", Mt), le = {
|
|
3052
|
+
scope: p.INLINE,
|
|
3053
|
+
whitelist: ["serif", "monospace"]
|
|
3054
|
+
}, Ws = new q(
|
|
3055
|
+
"font",
|
|
3056
|
+
`${L}-font`,
|
|
3057
|
+
le
|
|
3058
|
+
);
|
|
3059
|
+
class ze extends V {
|
|
3060
|
+
value(t) {
|
|
3061
|
+
return super.value(t).replace(/["']/g, "");
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
const Ke = new ze("font", "font-family", le), Vs = new q(
|
|
3065
|
+
"size",
|
|
3066
|
+
`${L}-size`,
|
|
3067
|
+
{
|
|
3068
|
+
scope: p.INLINE,
|
|
3069
|
+
whitelist: ["small", "large", "huge"]
|
|
3070
|
+
}
|
|
3071
|
+
), qe = new V("size", "font-size", {
|
|
3072
|
+
scope: p.INLINE,
|
|
3073
|
+
whitelist: ["10px", "18px", "32px"]
|
|
3074
|
+
}), He = G("rich:keyboard"), We = /Mac/i.test(navigator.platform) ? "metaKey" : "ctrlKey";
|
|
3075
|
+
class gt extends Y {
|
|
3076
|
+
static match(t, e) {
|
|
3077
|
+
return ["altKey", "ctrlKey", "metaKey", "shiftKey"].some((s) => !!e[s] !== t[s] && e[s] !== null) ? !1 : e.key === t.key || e.key === t.which;
|
|
3078
|
+
}
|
|
3079
|
+
constructor(t, e) {
|
|
3080
|
+
super(t, e), this.bindings = {}, Object.keys(this.options.bindings).forEach((s) => {
|
|
3081
|
+
this.options.bindings[s] && this.addBinding(this.options.bindings[s]);
|
|
3082
|
+
}), this.addBinding({ key: "Enter", shiftKey: null }, this.handleEnter), this.addBinding(
|
|
3083
|
+
{ key: "Enter", metaKey: null, ctrlKey: null, altKey: null },
|
|
3084
|
+
() => {
|
|
3085
|
+
}
|
|
3086
|
+
), /Firefox/i.test(navigator.userAgent) ? (this.addBinding(
|
|
3087
|
+
{ key: "Backspace" },
|
|
3088
|
+
{ collapsed: !0 },
|
|
3089
|
+
this.handleBackspace
|
|
3090
|
+
), this.addBinding(
|
|
3091
|
+
{ key: "Delete" },
|
|
3092
|
+
{ collapsed: !0 },
|
|
3093
|
+
this.handleDelete
|
|
3094
|
+
)) : (this.addBinding(
|
|
3095
|
+
{ key: "Backspace" },
|
|
3096
|
+
{ collapsed: !0, prefix: /^.?$/ },
|
|
3097
|
+
this.handleBackspace
|
|
3098
|
+
), this.addBinding(
|
|
3099
|
+
{ key: "Delete" },
|
|
3100
|
+
{ collapsed: !0, suffix: /^.?$/ },
|
|
3101
|
+
this.handleDelete
|
|
3102
|
+
)), this.addBinding(
|
|
3103
|
+
{ key: "Backspace" },
|
|
3104
|
+
{ collapsed: !1 },
|
|
3105
|
+
this.handleDeleteRange
|
|
3106
|
+
), this.addBinding(
|
|
3107
|
+
{ key: "Delete" },
|
|
3108
|
+
{ collapsed: !1 },
|
|
3109
|
+
this.handleDeleteRange
|
|
3110
|
+
), this.addBinding(
|
|
3111
|
+
{
|
|
3112
|
+
key: "Backspace",
|
|
3113
|
+
altKey: null,
|
|
3114
|
+
ctrlKey: null,
|
|
3115
|
+
metaKey: null,
|
|
3116
|
+
shiftKey: null
|
|
3117
|
+
},
|
|
3118
|
+
{ collapsed: !0, offset: 0 },
|
|
3119
|
+
this.handleBackspace
|
|
3120
|
+
), this.listen();
|
|
3121
|
+
}
|
|
3122
|
+
addBinding(t, e = {}, s = {}) {
|
|
3123
|
+
const i = Ge(t);
|
|
3124
|
+
if (i == null) {
|
|
3125
|
+
He.warn("Attempted to add invalid keyboard binding", i);
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
typeof e == "function" && (e = { handler: e }), typeof s == "function" && (s = { handler: s }), (Array.isArray(i.key) ? i.key : [i.key]).forEach((o) => {
|
|
3129
|
+
const l = {
|
|
3130
|
+
...i,
|
|
3131
|
+
key: o,
|
|
3132
|
+
...e,
|
|
3133
|
+
...s
|
|
3134
|
+
};
|
|
3135
|
+
this.bindings[l.key] = this.bindings[l.key] || [], this.bindings[l.key].push(l);
|
|
3136
|
+
});
|
|
3137
|
+
}
|
|
3138
|
+
listen() {
|
|
3139
|
+
this.rich.root.addEventListener("keydown", (t) => {
|
|
3140
|
+
if (t.defaultPrevented || t.isComposing || t.keyCode === 229 && (t.key === "Enter" || t.key === "Backspace")) return;
|
|
3141
|
+
const i = (this.bindings[t.key] || []).concat(
|
|
3142
|
+
this.bindings[t.which] || []
|
|
3143
|
+
).filter(
|
|
3144
|
+
(y) => gt.match(t, y)
|
|
3145
|
+
);
|
|
3146
|
+
if (i.length === 0) return;
|
|
3147
|
+
const n = u.find(t.target, !0);
|
|
3148
|
+
if (n && n.scroll !== this.rich.scroll) return;
|
|
3149
|
+
const o = this.rich.getSelection();
|
|
3150
|
+
if (o == null || !this.rich.hasFocus()) return;
|
|
3151
|
+
const [l, a] = this.rich.getLine(o.index), [c, h] = this.rich.getLeaf(o.index), [d, g] = o.length === 0 ? [c, h] : this.rich.getLeaf(o.index + o.length), b = c instanceof et ? c.value().slice(0, h) : "", N = d instanceof et ? d.value().slice(g) : "", E = {
|
|
3152
|
+
collapsed: o.length === 0,
|
|
3153
|
+
empty: o.length === 0 && l.length() <= 1,
|
|
3154
|
+
format: this.rich.getFormat(o),
|
|
3155
|
+
line: l,
|
|
3156
|
+
offset: a,
|
|
3157
|
+
prefix: b,
|
|
3158
|
+
suffix: N,
|
|
3159
|
+
event: t
|
|
3160
|
+
};
|
|
3161
|
+
i.some((y) => {
|
|
3162
|
+
if (y.collapsed != null && y.collapsed !== E.collapsed || y.empty != null && y.empty !== E.empty || y.offset != null && y.offset !== E.offset)
|
|
3163
|
+
return !1;
|
|
3164
|
+
if (Array.isArray(y.format)) {
|
|
3165
|
+
if (y.format.every((v) => E.format[v] == null))
|
|
3166
|
+
return !1;
|
|
3167
|
+
} else if (typeof y.format == "object" && !Object.keys(y.format).every((v) => y.format[v] === !0 ? E.format[v] != null : y.format[v] === !1 ? E.format[v] == null : X(y.format[v], E.format[v])))
|
|
3168
|
+
return !1;
|
|
3169
|
+
return y.prefix != null && !y.prefix.test(E.prefix) || y.suffix != null && !y.suffix.test(E.suffix) ? !1 : y.handler.call(this, o, E, y) !== !0;
|
|
3170
|
+
}) && t.preventDefault();
|
|
3171
|
+
});
|
|
3172
|
+
}
|
|
3173
|
+
handleBackspace(t, e) {
|
|
3174
|
+
const s = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(e.prefix) ? 2 : 1;
|
|
3175
|
+
if (t.index === 0 || this.rich.getLength() <= 1) return;
|
|
3176
|
+
let i = {};
|
|
3177
|
+
const [n] = this.rich.getLine(t.index);
|
|
3178
|
+
let o = new f().retain(t.index - s).delete(s);
|
|
3179
|
+
if (e.offset === 0) {
|
|
3180
|
+
const [l] = this.rich.getLine(t.index - 1);
|
|
3181
|
+
if (l && !(l.statics.blotName === "block" && l.length() <= 1)) {
|
|
3182
|
+
const c = n.formats(), h = this.rich.getFormat(t.index - 1, 1);
|
|
3183
|
+
if (i = C.diff(c, h) || {}, Object.keys(i).length > 0) {
|
|
3184
|
+
const d = new f().retain(t.index + n.length() - 2).retain(1, i);
|
|
3185
|
+
o = o.compose(d);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
this.rich.updateContents(o, u.sources.USER), this.rich.focus();
|
|
3190
|
+
}
|
|
3191
|
+
handleDelete(t, e) {
|
|
3192
|
+
const s = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(e.suffix) ? 2 : 1;
|
|
3193
|
+
if (t.index >= this.rich.getLength() - s) return;
|
|
3194
|
+
let i = {};
|
|
3195
|
+
const [n] = this.rich.getLine(t.index);
|
|
3196
|
+
let o = new f().retain(t.index).delete(s);
|
|
3197
|
+
if (e.offset >= n.length() - 1) {
|
|
3198
|
+
const [l] = this.rich.getLine(t.index + 1);
|
|
3199
|
+
if (l) {
|
|
3200
|
+
const a = n.formats(), c = this.rich.getFormat(t.index, 1);
|
|
3201
|
+
i = C.diff(a, c) || {}, Object.keys(i).length > 0 && (o = o.retain(l.length() - 1).retain(1, i));
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
this.rich.updateContents(o, u.sources.USER), this.rich.focus();
|
|
3205
|
+
}
|
|
3206
|
+
handleDeleteRange(t) {
|
|
3207
|
+
Ut({ range: t, rich: this.rich }), this.rich.focus();
|
|
3208
|
+
}
|
|
3209
|
+
handleEnter(t, e) {
|
|
3210
|
+
const s = Object.keys(e.format).reduce(
|
|
3211
|
+
(n, o) => (this.rich.scroll.query(o, p.BLOCK) && !Array.isArray(e.format[o]) && (n[o] = e.format[o]), n),
|
|
3212
|
+
{}
|
|
3213
|
+
), i = new f().retain(t.index).delete(t.length).insert(`
|
|
3214
|
+
`, s);
|
|
3215
|
+
this.rich.updateContents(i, u.sources.USER), this.rich.setSelection(t.index + 1, u.sources.SILENT), this.rich.focus();
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
const Ve = {
|
|
3219
|
+
bindings: {
|
|
3220
|
+
bold: wt("bold"),
|
|
3221
|
+
italic: wt("italic"),
|
|
3222
|
+
underline: wt("underline"),
|
|
3223
|
+
indent: {
|
|
3224
|
+
// highlight tab or tab at beginning of list, indent or blockquote
|
|
3225
|
+
key: "Tab",
|
|
3226
|
+
format: ["blockquote", "indent", "list"],
|
|
3227
|
+
handler(r, t) {
|
|
3228
|
+
return t.collapsed && t.offset !== 0 ? !0 : (this.rich.format("indent", "+1", u.sources.USER), !1);
|
|
3229
|
+
}
|
|
3230
|
+
},
|
|
3231
|
+
outdent: {
|
|
3232
|
+
key: "Tab",
|
|
3233
|
+
shiftKey: !0,
|
|
3234
|
+
format: ["blockquote", "indent", "list"],
|
|
3235
|
+
// highlight tab or tab at beginning of list, indent or blockquote
|
|
3236
|
+
handler(r, t) {
|
|
3237
|
+
return t.collapsed && t.offset !== 0 ? !0 : (this.rich.format("indent", "-1", u.sources.USER), !1);
|
|
3238
|
+
}
|
|
3239
|
+
},
|
|
3240
|
+
"outdent backspace": {
|
|
3241
|
+
key: "Backspace",
|
|
3242
|
+
collapsed: !0,
|
|
3243
|
+
shiftKey: null,
|
|
3244
|
+
metaKey: null,
|
|
3245
|
+
ctrlKey: null,
|
|
3246
|
+
altKey: null,
|
|
3247
|
+
format: ["indent", "list"],
|
|
3248
|
+
offset: 0,
|
|
3249
|
+
handler(r, t) {
|
|
3250
|
+
t.format.indent != null ? this.rich.format("indent", "-1", u.sources.USER) : t.format.list != null && this.rich.format("list", !1, u.sources.USER);
|
|
3251
|
+
}
|
|
3252
|
+
},
|
|
3253
|
+
"indent code-block": Xt(!0),
|
|
3254
|
+
"outdent code-block": Xt(!1),
|
|
3255
|
+
"remove tab": {
|
|
3256
|
+
key: "Tab",
|
|
3257
|
+
shiftKey: !0,
|
|
3258
|
+
collapsed: !0,
|
|
3259
|
+
prefix: /\t$/,
|
|
3260
|
+
handler(r) {
|
|
3261
|
+
this.rich.deleteText(r.index - 1, 1, u.sources.USER);
|
|
3262
|
+
}
|
|
3263
|
+
},
|
|
3264
|
+
tab: {
|
|
3265
|
+
key: "Tab",
|
|
3266
|
+
handler(r, t) {
|
|
3267
|
+
if (t.format.table) return !0;
|
|
3268
|
+
this.rich.history.cutoff();
|
|
3269
|
+
const e = new f().retain(r.index).delete(r.length).insert(" ");
|
|
3270
|
+
return this.rich.updateContents(e, u.sources.USER), this.rich.history.cutoff(), this.rich.setSelection(r.index + 1, u.sources.SILENT), !1;
|
|
3271
|
+
}
|
|
3272
|
+
},
|
|
3273
|
+
"blockquote empty enter": {
|
|
3274
|
+
key: "Enter",
|
|
3275
|
+
collapsed: !0,
|
|
3276
|
+
format: ["blockquote"],
|
|
3277
|
+
empty: !0,
|
|
3278
|
+
handler() {
|
|
3279
|
+
this.rich.format("blockquote", !1, u.sources.USER);
|
|
3280
|
+
}
|
|
3281
|
+
},
|
|
3282
|
+
"list empty enter": {
|
|
3283
|
+
key: "Enter",
|
|
3284
|
+
collapsed: !0,
|
|
3285
|
+
format: ["list"],
|
|
3286
|
+
empty: !0,
|
|
3287
|
+
handler(r, t) {
|
|
3288
|
+
const e = { list: !1 };
|
|
3289
|
+
t.format.indent && (e.indent = !1), this.rich.formatLine(
|
|
3290
|
+
r.index,
|
|
3291
|
+
r.length,
|
|
3292
|
+
e,
|
|
3293
|
+
u.sources.USER
|
|
3294
|
+
);
|
|
3295
|
+
}
|
|
3296
|
+
},
|
|
3297
|
+
"checklist enter": {
|
|
3298
|
+
key: "Enter",
|
|
3299
|
+
collapsed: !0,
|
|
3300
|
+
format: { list: "checked" },
|
|
3301
|
+
handler(r) {
|
|
3302
|
+
const [t, e] = this.rich.getLine(r.index), s = {
|
|
3303
|
+
...t.formats(),
|
|
3304
|
+
list: "checked"
|
|
3305
|
+
}, i = new f().retain(r.index).insert(`
|
|
3306
|
+
`, s).retain(t.length() - e - 1).retain(1, { list: "unchecked" });
|
|
3307
|
+
this.rich.updateContents(i, u.sources.USER), this.rich.setSelection(r.index + 1, u.sources.SILENT), this.rich.scrollSelectionIntoView();
|
|
3308
|
+
}
|
|
3309
|
+
},
|
|
3310
|
+
"header enter": {
|
|
3311
|
+
key: "Enter",
|
|
3312
|
+
collapsed: !0,
|
|
3313
|
+
format: ["header"],
|
|
3314
|
+
suffix: /^$/,
|
|
3315
|
+
handler(r, t) {
|
|
3316
|
+
const [e, s] = this.rich.getLine(r.index), i = new f().retain(r.index).insert(`
|
|
3317
|
+
`, t.format).retain(e.length() - s - 1).retain(1, { header: null });
|
|
3318
|
+
this.rich.updateContents(i, u.sources.USER), this.rich.setSelection(r.index + 1, u.sources.SILENT), this.rich.scrollSelectionIntoView();
|
|
3319
|
+
}
|
|
3320
|
+
},
|
|
3321
|
+
"table backspace": {
|
|
3322
|
+
key: "Backspace",
|
|
3323
|
+
format: ["table"],
|
|
3324
|
+
collapsed: !0,
|
|
3325
|
+
offset: 0,
|
|
3326
|
+
handler() {
|
|
3327
|
+
}
|
|
3328
|
+
},
|
|
3329
|
+
"table delete": {
|
|
3330
|
+
key: "Delete",
|
|
3331
|
+
format: ["table"],
|
|
3332
|
+
collapsed: !0,
|
|
3333
|
+
suffix: /^$/,
|
|
3334
|
+
handler() {
|
|
3335
|
+
}
|
|
3336
|
+
},
|
|
3337
|
+
"table enter": {
|
|
3338
|
+
key: "Enter",
|
|
3339
|
+
shiftKey: null,
|
|
3340
|
+
format: ["table"],
|
|
3341
|
+
handler(r) {
|
|
3342
|
+
const t = this.rich.getModule("table");
|
|
3343
|
+
if (t) {
|
|
3344
|
+
const [e, s, i, n] = t.getTable(r), o = Xe(e, s, i, n);
|
|
3345
|
+
if (o == null) return;
|
|
3346
|
+
let l = e.offset();
|
|
3347
|
+
if (o < 0) {
|
|
3348
|
+
const a = new f().retain(l).insert(`
|
|
3349
|
+
`);
|
|
3350
|
+
this.rich.updateContents(a, u.sources.USER), this.rich.setSelection(
|
|
3351
|
+
r.index + 1,
|
|
3352
|
+
r.length,
|
|
3353
|
+
u.sources.SILENT
|
|
3354
|
+
);
|
|
3355
|
+
} else if (o > 0) {
|
|
3356
|
+
l += e.length();
|
|
3357
|
+
const a = new f().retain(l).insert(`
|
|
3358
|
+
`);
|
|
3359
|
+
this.rich.updateContents(a, u.sources.USER), this.rich.setSelection(l, u.sources.USER);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
}
|
|
3363
|
+
},
|
|
3364
|
+
"table tab": {
|
|
3365
|
+
key: "Tab",
|
|
3366
|
+
shiftKey: null,
|
|
3367
|
+
format: ["table"],
|
|
3368
|
+
handler(r, t) {
|
|
3369
|
+
const { event: e, line: s } = t, i = s.offset(this.rich.scroll);
|
|
3370
|
+
e.shiftKey ? this.rich.setSelection(i - 1, u.sources.USER) : this.rich.setSelection(i + s.length(), u.sources.USER);
|
|
3371
|
+
}
|
|
3372
|
+
},
|
|
3373
|
+
"list autofill": {
|
|
3374
|
+
key: " ",
|
|
3375
|
+
shiftKey: null,
|
|
3376
|
+
collapsed: !0,
|
|
3377
|
+
format: {
|
|
3378
|
+
"code-block": !1,
|
|
3379
|
+
blockquote: !1,
|
|
3380
|
+
table: !1
|
|
3381
|
+
},
|
|
3382
|
+
prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,
|
|
3383
|
+
handler(r, t) {
|
|
3384
|
+
if (this.rich.scroll.query("list") == null) return !0;
|
|
3385
|
+
const { length: e } = t.prefix, [s, i] = this.rich.getLine(r.index);
|
|
3386
|
+
if (i > e) return !0;
|
|
3387
|
+
let n;
|
|
3388
|
+
switch (t.prefix.trim()) {
|
|
3389
|
+
case "[]":
|
|
3390
|
+
case "[ ]":
|
|
3391
|
+
n = "unchecked";
|
|
3392
|
+
break;
|
|
3393
|
+
case "[x]":
|
|
3394
|
+
n = "checked";
|
|
3395
|
+
break;
|
|
3396
|
+
case "-":
|
|
3397
|
+
case "*":
|
|
3398
|
+
n = "bullet";
|
|
3399
|
+
break;
|
|
3400
|
+
default:
|
|
3401
|
+
n = "ordered";
|
|
3402
|
+
}
|
|
3403
|
+
this.rich.insertText(r.index, " ", u.sources.USER), this.rich.history.cutoff();
|
|
3404
|
+
const o = new f().retain(r.index - i).delete(e + 1).retain(s.length() - 2 - i).retain(1, { list: n });
|
|
3405
|
+
return this.rich.updateContents(o, u.sources.USER), this.rich.history.cutoff(), this.rich.setSelection(r.index - e, u.sources.SILENT), !1;
|
|
3406
|
+
}
|
|
3407
|
+
},
|
|
3408
|
+
"code exit": {
|
|
3409
|
+
key: "Enter",
|
|
3410
|
+
collapsed: !0,
|
|
3411
|
+
format: ["code-block"],
|
|
3412
|
+
prefix: /^$/,
|
|
3413
|
+
suffix: /^\s*$/,
|
|
3414
|
+
handler(r) {
|
|
3415
|
+
const [t, e] = this.rich.getLine(r.index);
|
|
3416
|
+
let s = 2, i = t;
|
|
3417
|
+
for (; i != null && i.length() <= 1 && i.formats()["code-block"]; )
|
|
3418
|
+
if (i = i.prev, s -= 1, s <= 0) {
|
|
3419
|
+
const n = new f().retain(r.index + t.length() - e - 2).retain(1, { "code-block": null }).delete(1);
|
|
3420
|
+
return this.rich.updateContents(n, u.sources.USER), this.rich.setSelection(r.index - 1, u.sources.SILENT), !1;
|
|
3421
|
+
}
|
|
3422
|
+
return !0;
|
|
3423
|
+
}
|
|
3424
|
+
},
|
|
3425
|
+
"embed left": ut("ArrowLeft", !1),
|
|
3426
|
+
"embed left shift": ut("ArrowLeft", !0),
|
|
3427
|
+
"embed right": ut("ArrowRight", !1),
|
|
3428
|
+
"embed right shift": ut("ArrowRight", !0),
|
|
3429
|
+
"table down": Yt(!1),
|
|
3430
|
+
"table up": Yt(!0)
|
|
3431
|
+
}
|
|
3432
|
+
};
|
|
3433
|
+
gt.DEFAULTS = Ve;
|
|
3434
|
+
function Xt(r) {
|
|
3435
|
+
return {
|
|
3436
|
+
key: "Tab",
|
|
3437
|
+
shiftKey: !r,
|
|
3438
|
+
format: { "code-block": !0 },
|
|
3439
|
+
handler(t, { event: e }) {
|
|
3440
|
+
const s = this.rich.scroll.query("code-block"), { TAB: i } = s;
|
|
3441
|
+
if (t.length === 0 && !e.shiftKey) {
|
|
3442
|
+
this.rich.insertText(t.index, i, u.sources.USER), this.rich.setSelection(t.index + i.length, u.sources.SILENT);
|
|
3443
|
+
return;
|
|
3444
|
+
}
|
|
3445
|
+
const n = t.length === 0 ? this.rich.getLines(t.index, 1) : this.rich.getLines(t);
|
|
3446
|
+
let { index: o, length: l } = t;
|
|
3447
|
+
n.forEach((a, c) => {
|
|
3448
|
+
r ? (a.insertAt(0, i), c === 0 ? o += i.length : l += i.length) : a.domNode.textContent.startsWith(i) && (a.deleteAt(0, i.length), c === 0 ? o -= i.length : l -= i.length);
|
|
3449
|
+
}), this.rich.update(u.sources.USER), this.rich.setSelection(o, l, u.sources.SILENT);
|
|
3450
|
+
}
|
|
3451
|
+
};
|
|
3452
|
+
}
|
|
3453
|
+
function ut(r, t) {
|
|
3454
|
+
return {
|
|
3455
|
+
key: r,
|
|
3456
|
+
shiftKey: t,
|
|
3457
|
+
altKey: null,
|
|
3458
|
+
[r === "ArrowLeft" ? "prefix" : "suffix"]: /^$/,
|
|
3459
|
+
handler(s) {
|
|
3460
|
+
let { index: i } = s;
|
|
3461
|
+
r === "ArrowRight" && (i += s.length + 1);
|
|
3462
|
+
const [n] = this.rich.getLeaf(i);
|
|
3463
|
+
return n instanceof B ? (r === "ArrowLeft" ? t ? this.rich.setSelection(
|
|
3464
|
+
s.index - 1,
|
|
3465
|
+
s.length + 1,
|
|
3466
|
+
u.sources.USER
|
|
3467
|
+
) : this.rich.setSelection(s.index - 1, u.sources.USER) : t ? this.rich.setSelection(
|
|
3468
|
+
s.index,
|
|
3469
|
+
s.length + 1,
|
|
3470
|
+
u.sources.USER
|
|
3471
|
+
) : this.rich.setSelection(
|
|
3472
|
+
s.index + s.length + 1,
|
|
3473
|
+
u.sources.USER
|
|
3474
|
+
), !1) : !0;
|
|
3475
|
+
}
|
|
3476
|
+
};
|
|
3477
|
+
}
|
|
3478
|
+
function wt(r) {
|
|
3479
|
+
return {
|
|
3480
|
+
key: r[0],
|
|
3481
|
+
shortKey: !0,
|
|
3482
|
+
handler(t, e) {
|
|
3483
|
+
this.rich.format(r, !e.format[r], u.sources.USER);
|
|
3484
|
+
}
|
|
3485
|
+
};
|
|
3486
|
+
}
|
|
3487
|
+
function Yt(r) {
|
|
3488
|
+
return {
|
|
3489
|
+
key: r ? "ArrowUp" : "ArrowDown",
|
|
3490
|
+
collapsed: !0,
|
|
3491
|
+
format: ["table"],
|
|
3492
|
+
handler(t, e) {
|
|
3493
|
+
const s = r ? "prev" : "next", i = e.line, n = i.parent[s];
|
|
3494
|
+
if (n != null) {
|
|
3495
|
+
if (n.statics.blotName === "table-row") {
|
|
3496
|
+
let o = n.children.head, l = i;
|
|
3497
|
+
for (; l.prev != null; )
|
|
3498
|
+
l = l.prev, o = o.next;
|
|
3499
|
+
const a = o.offset(this.rich.scroll) + Math.min(e.offset, o.length() - 1);
|
|
3500
|
+
this.rich.setSelection(a, 0, u.sources.USER);
|
|
3501
|
+
}
|
|
3502
|
+
} else {
|
|
3503
|
+
const o = i.table()[s];
|
|
3504
|
+
o != null && (r ? this.rich.setSelection(
|
|
3505
|
+
o.offset(this.rich.scroll) + o.length() - 1,
|
|
3506
|
+
0,
|
|
3507
|
+
u.sources.USER
|
|
3508
|
+
) : this.rich.setSelection(
|
|
3509
|
+
o.offset(this.rich.scroll),
|
|
3510
|
+
0,
|
|
3511
|
+
u.sources.USER
|
|
3512
|
+
));
|
|
3513
|
+
}
|
|
3514
|
+
return !1;
|
|
3515
|
+
}
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
function Ge(r) {
|
|
3519
|
+
if (typeof r == "string" || typeof r == "number")
|
|
3520
|
+
r = { key: r };
|
|
3521
|
+
else if (typeof r == "object")
|
|
3522
|
+
r = W(r);
|
|
3523
|
+
else
|
|
3524
|
+
return null;
|
|
3525
|
+
return r.shortKey && (r[We] = r.shortKey, delete r.shortKey), r;
|
|
3526
|
+
}
|
|
3527
|
+
function Ut({ rich: r, range: t }) {
|
|
3528
|
+
const e = r.getLines(t);
|
|
3529
|
+
let s = {};
|
|
3530
|
+
if (e.length > 1) {
|
|
3531
|
+
const i = e[0].formats(), n = e[e.length - 1].formats();
|
|
3532
|
+
s = C.diff(n, i) || {};
|
|
3533
|
+
}
|
|
3534
|
+
r.deleteText(t, u.sources.USER), Object.keys(s).length > 0 && r.formatLine(t.index, 1, s, u.sources.USER), r.setSelection(t.index, u.sources.SILENT);
|
|
3535
|
+
}
|
|
3536
|
+
function Xe(r, t, e, s) {
|
|
3537
|
+
return t.prev == null && t.next == null ? e.prev == null && e.next == null ? s === 0 ? -1 : 1 : e.prev == null ? -1 : 1 : t.prev == null ? -1 : t.next == null ? 1 : null;
|
|
3538
|
+
}
|
|
3539
|
+
const Ye = /font-weight:\s*normal/, Ze = ["P", "OL", "UL"], Zt = (r) => r && Ze.includes(r.tagName), Qe = (r) => {
|
|
3540
|
+
Array.from(r.querySelectorAll("br")).filter(
|
|
3541
|
+
(t) => Zt(t.previousElementSibling) && Zt(t.nextElementSibling)
|
|
3542
|
+
).forEach((t) => {
|
|
3543
|
+
t.parentNode?.removeChild(t);
|
|
3544
|
+
});
|
|
3545
|
+
}, Je = (r) => {
|
|
3546
|
+
Array.from(r.querySelectorAll('b[style*="font-weight"]')).filter((t) => t.getAttribute("style")?.match(Ye)).forEach((t) => {
|
|
3547
|
+
const e = r.createDocumentFragment();
|
|
3548
|
+
e.append(...t.childNodes), t.parentNode?.replaceChild(e, t);
|
|
3549
|
+
});
|
|
3550
|
+
};
|
|
3551
|
+
function ts(r) {
|
|
3552
|
+
r.querySelector('[id^="docs-internal-guid-"]') && (Je(r), Qe(r));
|
|
3553
|
+
}
|
|
3554
|
+
const es = /\bmso-list:[^;]*ignore/i, ss = /\bmso-list:[^;]*\bl(\d+)/i, is = /\bmso-list:[^;]*\blevel(\d+)/i, rs = (r, t) => {
|
|
3555
|
+
const e = r.getAttribute("style"), s = e?.match(ss);
|
|
3556
|
+
if (!s)
|
|
3557
|
+
return null;
|
|
3558
|
+
const i = Number(s[1]), n = e?.match(is), o = n ? Number(n[1]) : 1, l = new RegExp(
|
|
3559
|
+
`@list l${i}:level${o}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,
|
|
3560
|
+
"i"
|
|
3561
|
+
), a = t.match(l), c = a && a[1] === "bullet" ? "bullet" : "ordered";
|
|
3562
|
+
return { id: i, indent: o, type: c, element: r };
|
|
3563
|
+
}, ns = (r) => {
|
|
3564
|
+
const t = Array.from(r.querySelectorAll("[style*=mso-list]")), e = [], s = [];
|
|
3565
|
+
t.forEach((o) => {
|
|
3566
|
+
(o.getAttribute("style") || "").match(es) ? e.push(o) : s.push(o);
|
|
3567
|
+
}), e.forEach((o) => o.parentNode?.removeChild(o));
|
|
3568
|
+
const i = r.documentElement.innerHTML, n = s.map((o) => rs(o, i)).filter((o) => o);
|
|
3569
|
+
for (; n.length; ) {
|
|
3570
|
+
const o = [];
|
|
3571
|
+
let l = n.shift();
|
|
3572
|
+
for (; l; )
|
|
3573
|
+
o.push(l), l = n.length && n[0]?.element === l.element.nextElementSibling && // Different id means the next item doesn't belong to this group.
|
|
3574
|
+
n[0].id === l.id ? n.shift() : null;
|
|
3575
|
+
const a = document.createElement("ul");
|
|
3576
|
+
o.forEach((d) => {
|
|
3577
|
+
const g = document.createElement("li");
|
|
3578
|
+
g.setAttribute("data-list", d.type), d.indent > 1 && g.setAttribute(
|
|
3579
|
+
"class",
|
|
3580
|
+
`${L}-indent-${d.indent - 1}`
|
|
3581
|
+
), g.innerHTML = d.element.innerHTML, a.appendChild(g);
|
|
3582
|
+
});
|
|
3583
|
+
const c = o[0]?.element, { parentNode: h } = c ?? {};
|
|
3584
|
+
c && h?.replaceChild(a, c), o.slice(1).forEach(({ element: d }) => {
|
|
3585
|
+
h?.removeChild(d);
|
|
3586
|
+
});
|
|
3587
|
+
}
|
|
3588
|
+
};
|
|
3589
|
+
function os(r) {
|
|
3590
|
+
r.documentElement.getAttribute("xmlns:w") === "urn:schemas-microsoft-com:office:word" && ns(r);
|
|
3591
|
+
}
|
|
3592
|
+
const ls = [os, ts], as = (r) => {
|
|
3593
|
+
r.documentElement && ls.forEach((t) => {
|
|
3594
|
+
t(r);
|
|
3595
|
+
});
|
|
3596
|
+
}, cs = G("rich:clipboard"), hs = [
|
|
3597
|
+
[Node.TEXT_NODE, As],
|
|
3598
|
+
[Node.TEXT_NODE, Jt],
|
|
3599
|
+
["br", gs],
|
|
3600
|
+
[Node.ELEMENT_NODE, Jt],
|
|
3601
|
+
[Node.ELEMENT_NODE, ms],
|
|
3602
|
+
[Node.ELEMENT_NODE, ps],
|
|
3603
|
+
[Node.ELEMENT_NODE, Ts],
|
|
3604
|
+
["li", ys],
|
|
3605
|
+
["ol, ul", Es],
|
|
3606
|
+
["pre", bs],
|
|
3607
|
+
["tr", Ls],
|
|
3608
|
+
["b", Ct("bold")],
|
|
3609
|
+
["i", Ct("italic")],
|
|
3610
|
+
["strike", Ct("strike")],
|
|
3611
|
+
["style", Ns]
|
|
3612
|
+
], us = [Ue, Pe].reduce(
|
|
3613
|
+
(r, t) => (r[t.keyName] = t, r),
|
|
3614
|
+
{}
|
|
3615
|
+
), Qt = [
|
|
3616
|
+
je,
|
|
3617
|
+
Fe,
|
|
3618
|
+
$e,
|
|
3619
|
+
_e,
|
|
3620
|
+
Ke,
|
|
3621
|
+
qe
|
|
3622
|
+
].reduce((r, t) => (r[t.keyName] = t, r), {});
|
|
3623
|
+
class fs extends Y {
|
|
3624
|
+
static {
|
|
3625
|
+
this.DEFAULTS = {
|
|
3626
|
+
matchers: []
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
constructor(t, e) {
|
|
3630
|
+
super(t, e), this.rich.root.addEventListener(
|
|
3631
|
+
"copy",
|
|
3632
|
+
(s) => this.onCaptureCopy(s, !1)
|
|
3633
|
+
), this.rich.root.addEventListener("cut", (s) => this.onCaptureCopy(s, !0)), this.rich.root.addEventListener("paste", this.onCapturePaste.bind(this)), this.matchers = [], hs.concat(this.options.matchers ?? []).forEach(
|
|
3634
|
+
([s, i]) => {
|
|
3635
|
+
this.addMatcher(s, i);
|
|
3636
|
+
}
|
|
3637
|
+
);
|
|
3638
|
+
}
|
|
3639
|
+
addMatcher(t, e) {
|
|
3640
|
+
this.matchers.push([t, e]);
|
|
3641
|
+
}
|
|
3642
|
+
convert({ html: t, text: e }, s = {}) {
|
|
3643
|
+
if (s[z.blotName])
|
|
3644
|
+
return new f().insert(e || "", {
|
|
3645
|
+
[z.blotName]: s[z.blotName]
|
|
3646
|
+
});
|
|
3647
|
+
if (!t)
|
|
3648
|
+
return new f().insert(e || "", s);
|
|
3649
|
+
const i = this.convertHTML(t);
|
|
3650
|
+
return ot(i, `
|
|
3651
|
+
`) && (i.ops[i.ops.length - 1].attributes == null || s.table) ? i.compose(new f().retain(i.length() - 1).delete(1)) : i;
|
|
3652
|
+
}
|
|
3653
|
+
normalizeHTML(t) {
|
|
3654
|
+
as(t);
|
|
3655
|
+
}
|
|
3656
|
+
convertHTML(t) {
|
|
3657
|
+
const e = new DOMParser().parseFromString(t, "text/html");
|
|
3658
|
+
this.normalizeHTML(e);
|
|
3659
|
+
const s = e.body, i = /* @__PURE__ */ new WeakMap(), [n, o] = this.prepareMatching(
|
|
3660
|
+
s,
|
|
3661
|
+
i
|
|
3662
|
+
);
|
|
3663
|
+
return ce(
|
|
3664
|
+
this.rich.scroll,
|
|
3665
|
+
s,
|
|
3666
|
+
n,
|
|
3667
|
+
o,
|
|
3668
|
+
i
|
|
3669
|
+
);
|
|
3670
|
+
}
|
|
3671
|
+
dangerouslyPasteHTML(t, e, s = u.sources.API) {
|
|
3672
|
+
if (typeof t == "string") {
|
|
3673
|
+
const i = this.convert({ html: t, text: "" });
|
|
3674
|
+
this.rich.setContents(i, e), this.rich.setSelection(0, u.sources.SILENT);
|
|
3675
|
+
} else {
|
|
3676
|
+
const i = this.convert({ html: e, text: "" });
|
|
3677
|
+
this.rich.updateContents(new f().retain(t).concat(i), s), this.rich.setSelection(t + i.length(), u.sources.SILENT);
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
onCaptureCopy(t, e = !1) {
|
|
3681
|
+
if (t.defaultPrevented) return;
|
|
3682
|
+
t.preventDefault();
|
|
3683
|
+
const [s] = this.rich.selection.getRange();
|
|
3684
|
+
if (s == null) return;
|
|
3685
|
+
const { html: i, text: n } = this.onCopy(s, e);
|
|
3686
|
+
t.clipboardData?.setData("text/plain", n), t.clipboardData?.setData("text/html", i), e && Ut({ range: s, rich: this.rich });
|
|
3687
|
+
}
|
|
3688
|
+
/*
|
|
3689
|
+
* https://www.iana.org/assignments/media-types/text/uri-list
|
|
3690
|
+
*/
|
|
3691
|
+
normalizeURIList(t) {
|
|
3692
|
+
return t.split(/\r?\n/).filter((e) => e[0] !== "#").join(`
|
|
3693
|
+
`);
|
|
3694
|
+
}
|
|
3695
|
+
onCapturePaste(t) {
|
|
3696
|
+
if (t.defaultPrevented || !this.rich.isEnabled()) return;
|
|
3697
|
+
t.preventDefault();
|
|
3698
|
+
const e = this.rich.getSelection(!0);
|
|
3699
|
+
if (e == null) return;
|
|
3700
|
+
const s = t.clipboardData?.getData("text/html");
|
|
3701
|
+
let i = t.clipboardData?.getData("text/plain");
|
|
3702
|
+
if (!s && !i) {
|
|
3703
|
+
const o = t.clipboardData?.getData("text/uri-list");
|
|
3704
|
+
o && (i = this.normalizeURIList(o));
|
|
3705
|
+
}
|
|
3706
|
+
const n = Array.from(t.clipboardData?.files || []);
|
|
3707
|
+
if (!s && n.length > 0) {
|
|
3708
|
+
this.rich.uploader.upload(e, n);
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
3711
|
+
if (s && n.length > 0) {
|
|
3712
|
+
const o = new DOMParser().parseFromString(s, "text/html");
|
|
3713
|
+
if (o.body.childElementCount === 1 && o.body.firstElementChild?.tagName === "IMG") {
|
|
3714
|
+
this.rich.uploader.upload(e, n);
|
|
3715
|
+
return;
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
this.onPaste(e, { html: s, text: i });
|
|
3719
|
+
}
|
|
3720
|
+
onCopy(t) {
|
|
3721
|
+
const e = this.rich.getText(t);
|
|
3722
|
+
return { html: this.rich.getSemanticHTML(t), text: e };
|
|
3723
|
+
}
|
|
3724
|
+
onPaste(t, { text: e, html: s }) {
|
|
3725
|
+
const i = this.rich.getFormat(t.index), n = this.convert({ text: e, html: s }, i);
|
|
3726
|
+
cs.log("onPaste", n, { text: e, html: s });
|
|
3727
|
+
const o = new f().retain(t.index).delete(t.length).concat(n);
|
|
3728
|
+
this.rich.updateContents(o, u.sources.USER), this.rich.setSelection(o.length() - t.length, u.sources.SILENT), this.rich.scrollSelectionIntoView();
|
|
3729
|
+
}
|
|
3730
|
+
prepareMatching(t, e) {
|
|
3731
|
+
const s = [], i = [];
|
|
3732
|
+
return this.matchers.forEach((n) => {
|
|
3733
|
+
const [o, l] = n;
|
|
3734
|
+
switch (o) {
|
|
3735
|
+
case Node.TEXT_NODE:
|
|
3736
|
+
i.push(l);
|
|
3737
|
+
break;
|
|
3738
|
+
case Node.ELEMENT_NODE:
|
|
3739
|
+
s.push(l);
|
|
3740
|
+
break;
|
|
3741
|
+
default:
|
|
3742
|
+
Array.from(t.querySelectorAll(o)).forEach((a) => {
|
|
3743
|
+
e.has(a) ? e.get(a)?.push(l) : e.set(a, [l]);
|
|
3744
|
+
});
|
|
3745
|
+
break;
|
|
3746
|
+
}
|
|
3747
|
+
}), [s, i];
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
function Z(r, t, e, s) {
|
|
3751
|
+
return s.query(t) ? r.reduce((i, n) => {
|
|
3752
|
+
if (!n.insert) return i;
|
|
3753
|
+
if (n.attributes && n.attributes[t])
|
|
3754
|
+
return i.push(n);
|
|
3755
|
+
const o = e ? { [t]: e } : {};
|
|
3756
|
+
return i.insert(n.insert, { ...o, ...n.attributes });
|
|
3757
|
+
}, new f()) : r;
|
|
3758
|
+
}
|
|
3759
|
+
function ot(r, t) {
|
|
3760
|
+
let e = "";
|
|
3761
|
+
for (let s = r.ops.length - 1; s >= 0 && e.length < t.length; --s) {
|
|
3762
|
+
const i = r.ops[s];
|
|
3763
|
+
if (typeof i.insert != "string") break;
|
|
3764
|
+
e = i.insert + e;
|
|
3765
|
+
}
|
|
3766
|
+
return e.slice(-1 * t.length) === t;
|
|
3767
|
+
}
|
|
3768
|
+
function H(r, t) {
|
|
3769
|
+
if (!(r instanceof Element)) return !1;
|
|
3770
|
+
const e = t.query(r);
|
|
3771
|
+
return e && e.prototype instanceof B ? !1 : [
|
|
3772
|
+
"address",
|
|
3773
|
+
"article",
|
|
3774
|
+
"blockquote",
|
|
3775
|
+
"canvas",
|
|
3776
|
+
"dd",
|
|
3777
|
+
"div",
|
|
3778
|
+
"dl",
|
|
3779
|
+
"dt",
|
|
3780
|
+
"fieldset",
|
|
3781
|
+
"figcaption",
|
|
3782
|
+
"figure",
|
|
3783
|
+
"footer",
|
|
3784
|
+
"form",
|
|
3785
|
+
"h1",
|
|
3786
|
+
"h2",
|
|
3787
|
+
"h3",
|
|
3788
|
+
"h4",
|
|
3789
|
+
"h5",
|
|
3790
|
+
"h6",
|
|
3791
|
+
"header",
|
|
3792
|
+
"iframe",
|
|
3793
|
+
"li",
|
|
3794
|
+
"main",
|
|
3795
|
+
"nav",
|
|
3796
|
+
"ol",
|
|
3797
|
+
"output",
|
|
3798
|
+
"p",
|
|
3799
|
+
"pre",
|
|
3800
|
+
"section",
|
|
3801
|
+
"table",
|
|
3802
|
+
"td",
|
|
3803
|
+
"tr",
|
|
3804
|
+
"ul",
|
|
3805
|
+
"video"
|
|
3806
|
+
].includes(r.tagName.toLowerCase());
|
|
3807
|
+
}
|
|
3808
|
+
function ds(r, t) {
|
|
3809
|
+
return r.previousElementSibling && r.nextElementSibling && !H(r.previousElementSibling, t) && !H(r.nextElementSibling, t);
|
|
3810
|
+
}
|
|
3811
|
+
const ft = /* @__PURE__ */ new WeakMap();
|
|
3812
|
+
function ae(r) {
|
|
3813
|
+
return r == null ? !1 : (ft.has(r) || (r.tagName === "PRE" ? ft.set(r, !0) : ft.set(r, ae(r.parentNode))), ft.get(r));
|
|
3814
|
+
}
|
|
3815
|
+
function ce(r, t, e, s, i) {
|
|
3816
|
+
return t.nodeType === t.TEXT_NODE ? s.reduce((n, o) => o(t, n, r), new f()) : t.nodeType === t.ELEMENT_NODE ? Array.from(t.childNodes || []).reduce((n, o) => {
|
|
3817
|
+
let l = ce(
|
|
3818
|
+
r,
|
|
3819
|
+
o,
|
|
3820
|
+
e,
|
|
3821
|
+
s,
|
|
3822
|
+
i
|
|
3823
|
+
);
|
|
3824
|
+
return o.nodeType === t.ELEMENT_NODE && (l = e.reduce((a, c) => c(o, a, r), l), l = (i.get(o) || []).reduce(
|
|
3825
|
+
(a, c) => c(o, a, r),
|
|
3826
|
+
l
|
|
3827
|
+
)), n.concat(l);
|
|
3828
|
+
}, new f()) : new f();
|
|
3829
|
+
}
|
|
3830
|
+
function Ct(r) {
|
|
3831
|
+
return (t, e, s) => Z(e, r, !0, s);
|
|
3832
|
+
}
|
|
3833
|
+
function ps(r, t, e) {
|
|
3834
|
+
const s = j.keys(r), i = q.keys(r), n = V.keys(r), o = {};
|
|
3835
|
+
return s.concat(i).concat(n).forEach((l) => {
|
|
3836
|
+
let a = e.query(l, p.ATTRIBUTE);
|
|
3837
|
+
a != null && (o[a.attrName] = a.value(r), o[a.attrName]) || (a = us[l], a != null && (a.attrName === l || a.keyName === l) && (o[a.attrName] = a.value(r) || void 0), a = Qt[l], a != null && (a.attrName === l || a.keyName === l) && (a = Qt[l], o[a.attrName] = a.value(r) || void 0));
|
|
3838
|
+
}), Object.entries(o).reduce(
|
|
3839
|
+
(l, [a, c]) => Z(l, a, c, e),
|
|
3840
|
+
t
|
|
3841
|
+
);
|
|
3842
|
+
}
|
|
3843
|
+
function ms(r, t, e) {
|
|
3844
|
+
const s = e.query(r);
|
|
3845
|
+
if (s == null) return t;
|
|
3846
|
+
if (s.prototype instanceof B) {
|
|
3847
|
+
const i = {}, n = s.value(r);
|
|
3848
|
+
if (n != null)
|
|
3849
|
+
return i[s.blotName] = n, new f().insert(i, s.formats(r, e));
|
|
3850
|
+
} else if (s.prototype instanceof _ && !ot(t, `
|
|
3851
|
+
`) && t.insert(`
|
|
3852
|
+
`), "blotName" in s && "formats" in s && typeof s.formats == "function")
|
|
3853
|
+
return Z(
|
|
3854
|
+
t,
|
|
3855
|
+
s.blotName,
|
|
3856
|
+
s.formats(r, e),
|
|
3857
|
+
e
|
|
3858
|
+
);
|
|
3859
|
+
return t;
|
|
3860
|
+
}
|
|
3861
|
+
function gs(r, t) {
|
|
3862
|
+
return ot(t, `
|
|
3863
|
+
`) || t.insert(`
|
|
3864
|
+
`), t;
|
|
3865
|
+
}
|
|
3866
|
+
function bs(r, t, e) {
|
|
3867
|
+
const s = e.query("code-block"), i = s && "formats" in s && typeof s.formats == "function" ? s.formats(r, e) : !0;
|
|
3868
|
+
return Z(t, "code-block", i, e);
|
|
3869
|
+
}
|
|
3870
|
+
function Ns() {
|
|
3871
|
+
return new f();
|
|
3872
|
+
}
|
|
3873
|
+
function ys(r, t, e) {
|
|
3874
|
+
const s = e.query(r);
|
|
3875
|
+
if (s == null || s.blotName !== "list" || !ot(t, `
|
|
3876
|
+
`))
|
|
3877
|
+
return t;
|
|
3878
|
+
let i = -1, n = r.parentNode;
|
|
3879
|
+
for (; n != null; )
|
|
3880
|
+
["OL", "UL"].includes(n.tagName) && (i += 1), n = n.parentNode;
|
|
3881
|
+
return i <= 0 ? t : t.reduce((o, l) => l.insert ? l.attributes && typeof l.attributes.indent == "number" ? o.push(l) : o.insert(l.insert, { indent: i, ...l.attributes || {} }) : o, new f());
|
|
3882
|
+
}
|
|
3883
|
+
function Es(r, t, e) {
|
|
3884
|
+
const s = r;
|
|
3885
|
+
let i = s.tagName === "OL" ? "ordered" : "bullet";
|
|
3886
|
+
const n = s.getAttribute("data-checked");
|
|
3887
|
+
return n && (i = n === "true" ? "checked" : "unchecked"), Z(t, "list", i, e);
|
|
3888
|
+
}
|
|
3889
|
+
function Jt(r, t, e) {
|
|
3890
|
+
if (!ot(t, `
|
|
3891
|
+
`)) {
|
|
3892
|
+
if (H(r, e) && (r.childNodes.length > 0 || r instanceof HTMLParagraphElement))
|
|
3893
|
+
return t.insert(`
|
|
3894
|
+
`);
|
|
3895
|
+
if (t.length() > 0 && r.nextSibling) {
|
|
3896
|
+
let s = r.nextSibling;
|
|
3897
|
+
for (; s != null; ) {
|
|
3898
|
+
if (H(s, e))
|
|
3899
|
+
return t.insert(`
|
|
3900
|
+
`);
|
|
3901
|
+
const i = e.query(s);
|
|
3902
|
+
if (i && i.prototype instanceof I)
|
|
3903
|
+
return t.insert(`
|
|
3904
|
+
`);
|
|
3905
|
+
s = s.firstChild;
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
return t;
|
|
3910
|
+
}
|
|
3911
|
+
function Ts(r, t, e) {
|
|
3912
|
+
const s = {}, i = r.style || {};
|
|
3913
|
+
return i.fontStyle === "italic" && (s.italic = !0), i.textDecoration === "underline" && (s.underline = !0), i.textDecoration === "line-through" && (s.strike = !0), (i.fontWeight?.startsWith("bold") || parseInt(i.fontWeight, 10) >= 700) && (s.bold = !0), t = Object.entries(s).reduce(
|
|
3914
|
+
(n, [o, l]) => Z(n, o, l, e),
|
|
3915
|
+
t
|
|
3916
|
+
), parseFloat(i.textIndent || 0) > 0 ? new f().insert(" ").concat(t) : t;
|
|
3917
|
+
}
|
|
3918
|
+
function Ls(r, t, e) {
|
|
3919
|
+
const s = r.parentElement?.tagName === "TABLE" ? r.parentElement : r.parentElement?.parentElement;
|
|
3920
|
+
if (s != null) {
|
|
3921
|
+
const n = Array.from(s.querySelectorAll("tr")).indexOf(r) + 1;
|
|
3922
|
+
return Z(t, "table", n, e);
|
|
3923
|
+
}
|
|
3924
|
+
return t;
|
|
3925
|
+
}
|
|
3926
|
+
function As(r, t, e) {
|
|
3927
|
+
let s = r.data;
|
|
3928
|
+
if (r.parentElement?.tagName === "O:P")
|
|
3929
|
+
return t.insert(s.trim());
|
|
3930
|
+
if (!ae(r)) {
|
|
3931
|
+
if (s.trim().length === 0 && s.includes(`
|
|
3932
|
+
`) && !ds(r, e))
|
|
3933
|
+
return t;
|
|
3934
|
+
s = s.replace(/[^\S\u00a0]/g, " "), s = s.replace(/ {2,}/g, " "), (r.previousSibling == null && r.parentElement != null && H(r.parentElement, e) || r.previousSibling instanceof Element && H(r.previousSibling, e)) && (s = s.replace(/^ /, "")), (r.nextSibling == null && r.parentElement != null && H(r.parentElement, e) || r.nextSibling instanceof Element && H(r.nextSibling, e)) && (s = s.replace(/ $/, "")), s = s.replaceAll(" ", " ");
|
|
3935
|
+
}
|
|
3936
|
+
return t.insert(s);
|
|
3937
|
+
}
|
|
3938
|
+
class ws extends Y {
|
|
3939
|
+
constructor(t, e) {
|
|
3940
|
+
super(t, e), this.lastRecorded = 0, this.ignoreChange = !1, this.stack = { undo: [], redo: [] }, this.currentRange = null, this.rich.on(
|
|
3941
|
+
u.events.EDITOR_CHANGE,
|
|
3942
|
+
(s, i, n, o) => {
|
|
3943
|
+
s === u.events.SELECTION_CHANGE ? i && o !== u.sources.SILENT && (this.currentRange = i) : s === u.events.TEXT_CHANGE && (this.ignoreChange || (!this.options.userOnly || o === u.sources.USER ? this.record(i, n) : this.transform(i)), this.currentRange = St(this.currentRange, i));
|
|
3944
|
+
}
|
|
3945
|
+
), this.rich.keyboard.addBinding(
|
|
3946
|
+
{ key: "z", shortKey: !0 },
|
|
3947
|
+
this.undo.bind(this)
|
|
3948
|
+
), this.rich.keyboard.addBinding(
|
|
3949
|
+
{ key: ["z", "Z"], shortKey: !0, shiftKey: !0 },
|
|
3950
|
+
this.redo.bind(this)
|
|
3951
|
+
), /Win/i.test(navigator.platform) && this.rich.keyboard.addBinding(
|
|
3952
|
+
{ key: "y", shortKey: !0 },
|
|
3953
|
+
this.redo.bind(this)
|
|
3954
|
+
), this.rich.root.addEventListener("beforeinput", (s) => {
|
|
3955
|
+
s.inputType === "historyUndo" ? (this.undo(), s.preventDefault()) : s.inputType === "historyRedo" && (this.redo(), s.preventDefault());
|
|
3956
|
+
});
|
|
3957
|
+
}
|
|
3958
|
+
static {
|
|
3959
|
+
this.DEFAULTS = {
|
|
3960
|
+
delay: 1e3,
|
|
3961
|
+
maxStack: 100,
|
|
3962
|
+
userOnly: !1
|
|
3963
|
+
};
|
|
3964
|
+
}
|
|
3965
|
+
change(t, e) {
|
|
3966
|
+
if (this.stack[t].length === 0) return;
|
|
3967
|
+
const s = this.stack[t].pop();
|
|
3968
|
+
if (!s) return;
|
|
3969
|
+
const i = this.rich.getContents(), n = s.delta.invert(i);
|
|
3970
|
+
this.stack[e].push({
|
|
3971
|
+
delta: n,
|
|
3972
|
+
range: St(s.range, n)
|
|
3973
|
+
}), this.lastRecorded = 0, this.ignoreChange = !0, this.rich.updateContents(s.delta, u.sources.USER), this.ignoreChange = !1, this.restoreSelection(s);
|
|
3974
|
+
}
|
|
3975
|
+
clear() {
|
|
3976
|
+
this.stack = { undo: [], redo: [] };
|
|
3977
|
+
}
|
|
3978
|
+
cutoff() {
|
|
3979
|
+
this.lastRecorded = 0;
|
|
3980
|
+
}
|
|
3981
|
+
record(t, e) {
|
|
3982
|
+
if (t.ops.length === 0) return;
|
|
3983
|
+
this.stack.redo = [];
|
|
3984
|
+
let s = t.invert(e), i = this.currentRange;
|
|
3985
|
+
const n = Date.now();
|
|
3986
|
+
if (this.lastRecorded + this.options.delay > n && this.stack.undo.length > 0) {
|
|
3987
|
+
const o = this.stack.undo.pop();
|
|
3988
|
+
o && (s = s.compose(o.delta), i = o.range);
|
|
3989
|
+
} else
|
|
3990
|
+
this.lastRecorded = n;
|
|
3991
|
+
s.length() !== 0 && (this.stack.undo.push({ delta: s, range: i }), this.stack.undo.length > this.options.maxStack && this.stack.undo.shift());
|
|
3992
|
+
}
|
|
3993
|
+
redo() {
|
|
3994
|
+
this.change("redo", "undo");
|
|
3995
|
+
}
|
|
3996
|
+
transform(t) {
|
|
3997
|
+
te(this.stack.undo, t), te(this.stack.redo, t);
|
|
3998
|
+
}
|
|
3999
|
+
undo() {
|
|
4000
|
+
this.change("undo", "redo");
|
|
4001
|
+
}
|
|
4002
|
+
restoreSelection(t) {
|
|
4003
|
+
if (t.range)
|
|
4004
|
+
this.rich.setSelection(t.range, u.sources.USER);
|
|
4005
|
+
else {
|
|
4006
|
+
const e = ks(this.rich.scroll, t.delta);
|
|
4007
|
+
this.rich.setSelection(e, u.sources.USER);
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
function te(r, t) {
|
|
4012
|
+
let e = t;
|
|
4013
|
+
for (let s = r.length - 1; s >= 0; s -= 1) {
|
|
4014
|
+
const i = r[s];
|
|
4015
|
+
r[s] = {
|
|
4016
|
+
delta: e.transform(i.delta, !0),
|
|
4017
|
+
range: i.range && St(i.range, e)
|
|
4018
|
+
}, e = i.delta.transform(e), r[s].delta.length() === 0 && r.splice(s, 1);
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
function Cs(r, t) {
|
|
4022
|
+
const e = t.ops[t.ops.length - 1];
|
|
4023
|
+
return e == null ? !1 : e.insert != null ? typeof e.insert == "string" && e.insert.endsWith(`
|
|
4024
|
+
`) : e.attributes != null ? Object.keys(e.attributes).some((s) => r.query(s, p.BLOCK) != null) : !1;
|
|
4025
|
+
}
|
|
4026
|
+
function ks(r, t) {
|
|
4027
|
+
const e = t.reduce((i, n) => i + (n.delete || 0), 0);
|
|
4028
|
+
let s = t.length() - e;
|
|
4029
|
+
return Cs(r, t) && (s -= 1), s;
|
|
4030
|
+
}
|
|
4031
|
+
function St(r, t) {
|
|
4032
|
+
if (!r) return r;
|
|
4033
|
+
const e = t.transformPosition(r.index), s = t.transformPosition(r.index + r.length);
|
|
4034
|
+
return { index: e, length: s - e };
|
|
4035
|
+
}
|
|
4036
|
+
const Os = ["insertText", "insertReplacementText"];
|
|
4037
|
+
class vs extends Y {
|
|
4038
|
+
constructor(t, e) {
|
|
4039
|
+
super(t, e), t.root.addEventListener("beforeinput", (s) => {
|
|
4040
|
+
this.handleBeforeInput(s);
|
|
4041
|
+
}), /Android/i.test(navigator.userAgent) || t.on(u.events.COMPOSITION_BEFORE_START, () => {
|
|
4042
|
+
this.handleCompositionStart();
|
|
4043
|
+
});
|
|
4044
|
+
}
|
|
4045
|
+
deleteRange(t) {
|
|
4046
|
+
Ut({ range: t, rich: this.rich });
|
|
4047
|
+
}
|
|
4048
|
+
replaceText(t, e = "") {
|
|
4049
|
+
if (t.length === 0) return !1;
|
|
4050
|
+
if (e) {
|
|
4051
|
+
const s = this.rich.getFormat(t.index, 1);
|
|
4052
|
+
this.deleteRange(t), this.rich.updateContents(
|
|
4053
|
+
new f().retain(t.index).insert(e, s),
|
|
4054
|
+
u.sources.USER
|
|
4055
|
+
);
|
|
4056
|
+
} else
|
|
4057
|
+
this.deleteRange(t);
|
|
4058
|
+
return this.rich.setSelection(t.index + e.length, 0, u.sources.SILENT), !0;
|
|
4059
|
+
}
|
|
4060
|
+
handleBeforeInput(t) {
|
|
4061
|
+
if (this.rich.composition.isComposing || t.defaultPrevented || !Os.includes(t.inputType))
|
|
4062
|
+
return;
|
|
4063
|
+
const e = t.getTargetRanges ? t.getTargetRanges()[0] : null;
|
|
4064
|
+
if (!e || e.collapsed === !0)
|
|
4065
|
+
return;
|
|
4066
|
+
const s = xs(t);
|
|
4067
|
+
if (s == null)
|
|
4068
|
+
return;
|
|
4069
|
+
const i = this.rich.selection.normalizeNative(e), n = i ? this.rich.selection.normalizedToRange(i) : null;
|
|
4070
|
+
n && this.replaceText(n, s) && t.preventDefault();
|
|
4071
|
+
}
|
|
4072
|
+
handleCompositionStart() {
|
|
4073
|
+
const t = this.rich.getSelection();
|
|
4074
|
+
t && this.replaceText(t);
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
function xs(r) {
|
|
4078
|
+
return typeof r.data == "string" ? r.data : r.dataTransfer?.types.includes("text/plain") ? r.dataTransfer.getData("text/plain") : null;
|
|
4079
|
+
}
|
|
4080
|
+
const Rs = fe, Ss = 100, Is = (r) => !!(r.key === "ArrowLeft" || r.key === "ArrowRight" || // RTL scripts or moving from the end of the previous line
|
|
4081
|
+
r.key === "ArrowUp" || r.key === "ArrowDown" || r.key === "Home" || Rs && r.key === "a" && r.ctrlKey === !0);
|
|
4082
|
+
class Bs extends Y {
|
|
4083
|
+
constructor(t, e) {
|
|
4084
|
+
super(t, e), this.isListening = !1, this.selectionChangeDeadline = 0, this.handleArrowKeys(), this.handleNavigationShortcuts();
|
|
4085
|
+
}
|
|
4086
|
+
handleArrowKeys() {
|
|
4087
|
+
this.rich.keyboard.addBinding({
|
|
4088
|
+
key: ["ArrowLeft", "ArrowRight"],
|
|
4089
|
+
offset: 0,
|
|
4090
|
+
shiftKey: null,
|
|
4091
|
+
handler(t, { line: e, event: s }) {
|
|
4092
|
+
if (!(e instanceof T) || !e.uiNode)
|
|
4093
|
+
return !0;
|
|
4094
|
+
const i = getComputedStyle(e.domNode).direction === "rtl";
|
|
4095
|
+
return i && s.key !== "ArrowRight" || !i && s.key !== "ArrowLeft" ? !0 : (this.rich.setSelection(
|
|
4096
|
+
t.index - 1,
|
|
4097
|
+
t.length + (s.shiftKey ? 1 : 0),
|
|
4098
|
+
u.sources.USER
|
|
4099
|
+
), !1);
|
|
4100
|
+
}
|
|
4101
|
+
});
|
|
4102
|
+
}
|
|
4103
|
+
handleNavigationShortcuts() {
|
|
4104
|
+
this.rich.root.addEventListener("keydown", (t) => {
|
|
4105
|
+
!t.defaultPrevented && Is(t) && this.ensureListeningToSelectionChange();
|
|
4106
|
+
});
|
|
4107
|
+
}
|
|
4108
|
+
/**
|
|
4109
|
+
* We only listen to the `selectionchange` event when
|
|
4110
|
+
* there is an intention of moving the caret to the beginning using shortcuts.
|
|
4111
|
+
* This is primarily implemented to prevent infinite loops, as we are changing
|
|
4112
|
+
* the selection within the handler of a `selectionchange` event.
|
|
4113
|
+
*/
|
|
4114
|
+
ensureListeningToSelectionChange() {
|
|
4115
|
+
if (this.selectionChangeDeadline = Date.now() + Ss, this.isListening) return;
|
|
4116
|
+
this.isListening = !0;
|
|
4117
|
+
const t = () => {
|
|
4118
|
+
this.isListening = !1, Date.now() <= this.selectionChangeDeadline && this.handleSelectionChange();
|
|
4119
|
+
};
|
|
4120
|
+
document.addEventListener("selectionchange", t, {
|
|
4121
|
+
once: !0
|
|
4122
|
+
});
|
|
4123
|
+
}
|
|
4124
|
+
handleSelectionChange() {
|
|
4125
|
+
const t = document.getSelection();
|
|
4126
|
+
if (!t) return;
|
|
4127
|
+
const e = t.getRangeAt(0);
|
|
4128
|
+
if (e.collapsed !== !0 || e.startOffset !== 0) return;
|
|
4129
|
+
const s = this.rich.scroll.find(e.startContainer);
|
|
4130
|
+
if (!(s instanceof T) || !s.uiNode) return;
|
|
4131
|
+
const i = document.createRange();
|
|
4132
|
+
i.setStartAfter(s.uiNode), i.setEndAfter(s.uiNode), t.removeAllRanges(), t.addRange(i);
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
class he extends Y {
|
|
4136
|
+
constructor(t, e) {
|
|
4137
|
+
super(t, e), t.root.addEventListener("drop", (s) => {
|
|
4138
|
+
s.preventDefault();
|
|
4139
|
+
let i = null;
|
|
4140
|
+
if (document.caretRangeFromPoint)
|
|
4141
|
+
i = document.caretRangeFromPoint(s.clientX, s.clientY);
|
|
4142
|
+
else if (document.caretPositionFromPoint) {
|
|
4143
|
+
const o = document.caretPositionFromPoint(s.clientX, s.clientY);
|
|
4144
|
+
i = document.createRange(), i.setStart(o.offsetNode, o.offset), i.setEnd(o.offsetNode, o.offset);
|
|
4145
|
+
}
|
|
4146
|
+
const n = i && t.selection.normalizeNative(i);
|
|
4147
|
+
if (n) {
|
|
4148
|
+
const o = t.selection.normalizedToRange(n);
|
|
4149
|
+
s.dataTransfer?.files && this.upload(o, s.dataTransfer.files);
|
|
4150
|
+
}
|
|
4151
|
+
});
|
|
4152
|
+
}
|
|
4153
|
+
upload(t, e) {
|
|
4154
|
+
const s = [];
|
|
4155
|
+
Array.from(e).forEach((i) => {
|
|
4156
|
+
i && this.options.mimetypes?.includes(i.type) && s.push(i);
|
|
4157
|
+
}), s.length > 0 && this.options.handler.call(this, t, s);
|
|
4158
|
+
}
|
|
4159
|
+
}
|
|
4160
|
+
he.DEFAULTS = {
|
|
4161
|
+
mimetypes: ["image/png", "image/jpeg"],
|
|
4162
|
+
handler(r, t) {
|
|
4163
|
+
if (!this.rich.scroll.query("image"))
|
|
4164
|
+
return;
|
|
4165
|
+
const e = t.map((s) => new Promise((i) => {
|
|
4166
|
+
const n = new FileReader();
|
|
4167
|
+
n.onload = () => {
|
|
4168
|
+
i(n.result);
|
|
4169
|
+
}, n.readAsDataURL(s);
|
|
4170
|
+
}));
|
|
4171
|
+
Promise.all(e).then((s) => {
|
|
4172
|
+
const i = s.reduce((n, o) => n.insert({ image: o }), new f().retain(r.index).delete(r.length));
|
|
4173
|
+
this.rich.updateContents(i, m.sources.USER), this.rich.setSelection(
|
|
4174
|
+
r.index + s.length,
|
|
4175
|
+
m.sources.SILENT
|
|
4176
|
+
);
|
|
4177
|
+
});
|
|
4178
|
+
}
|
|
4179
|
+
};
|
|
4180
|
+
u.register({
|
|
4181
|
+
"blots/block": O,
|
|
4182
|
+
"blots/block/embed": I,
|
|
4183
|
+
"blots/break": F,
|
|
4184
|
+
"blots/container": Bt,
|
|
4185
|
+
"blots/cursor": U,
|
|
4186
|
+
"blots/embed": ie,
|
|
4187
|
+
"blots/inline": M,
|
|
4188
|
+
"blots/scroll": Me,
|
|
4189
|
+
"blots/text": $,
|
|
4190
|
+
"modules/clipboard": fs,
|
|
4191
|
+
"modules/history": ws,
|
|
4192
|
+
"modules/keyboard": gt,
|
|
4193
|
+
"modules/uploader": he,
|
|
4194
|
+
"modules/input": vs,
|
|
4195
|
+
"modules/uiNode": Bs
|
|
4196
|
+
});
|
|
4197
|
+
export {
|
|
4198
|
+
C as A,
|
|
4199
|
+
O as B,
|
|
4200
|
+
q as C,
|
|
4201
|
+
f as D,
|
|
4202
|
+
ie as E,
|
|
4203
|
+
Ke as F,
|
|
4204
|
+
Pe as G,
|
|
4205
|
+
oe as H,
|
|
4206
|
+
R as I,
|
|
4207
|
+
Y as M,
|
|
4208
|
+
k as O,
|
|
4209
|
+
Ne as P,
|
|
4210
|
+
u as R,
|
|
4211
|
+
p as S,
|
|
4212
|
+
$ as T,
|
|
4213
|
+
rt as a,
|
|
4214
|
+
Bt as b,
|
|
4215
|
+
M as c,
|
|
4216
|
+
B as d,
|
|
4217
|
+
I as e,
|
|
4218
|
+
U as f,
|
|
4219
|
+
F as g,
|
|
4220
|
+
z as h,
|
|
4221
|
+
st as i,
|
|
4222
|
+
Le as j,
|
|
4223
|
+
se as k,
|
|
4224
|
+
mt as l,
|
|
4225
|
+
m,
|
|
4226
|
+
G as n,
|
|
4227
|
+
qe as o,
|
|
4228
|
+
_e as p,
|
|
4229
|
+
$e as q,
|
|
4230
|
+
Fe as r,
|
|
4231
|
+
je as s,
|
|
4232
|
+
ce as t,
|
|
4233
|
+
Vs as u,
|
|
4234
|
+
Ws as v,
|
|
4235
|
+
Hs as w,
|
|
4236
|
+
Ks as x,
|
|
4237
|
+
qs as y,
|
|
4238
|
+
zs as z
|
|
4239
|
+
};
|