@vkzstudio/muza-ui 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/Button.js +19 -19
- package/dist/components/Button/ButtonLoader.d.ts +7 -0
- package/dist/components/Button/ButtonLoader.d.ts.map +1 -0
- package/dist/components/Button/ButtonLoader.js +40 -0
- package/dist/components/Button/buttonVariants.d.ts.map +1 -1
- package/dist/components/Button/buttonVariants.js +0 -1
- package/dist/components/DropdownMenu/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/components/Icons/CustomIcons.d.ts +1 -0
- package/dist/components/Icons/CustomIcons.d.ts.map +1 -1
- package/dist/components/Icons/CustomIcons.js +39 -28
- package/dist/components/ReorderableTable/ReorderableTable.js +1 -1
- package/dist/components/SwipeButton/SwipeButton.js +1 -1
- package/dist/components/TextEditor/EditorToolbar.d.ts +18 -0
- package/dist/components/TextEditor/EditorToolbar.d.ts.map +1 -0
- package/dist/components/TextEditor/EditorToolbar.js +175 -0
- package/dist/components/TextEditor/LinkBubbleMenu.d.ts +52 -0
- package/dist/components/TextEditor/LinkBubbleMenu.d.ts.map +1 -0
- package/dist/components/TextEditor/LinkBubbleMenu.js +97 -0
- package/dist/components/TextEditor/TextEditor.d.ts +134 -0
- package/dist/components/TextEditor/TextEditor.d.ts.map +1 -0
- package/dist/components/TextEditor/TextEditor.js +240 -0
- package/dist/components/TextEditor/TextEditor.stories.d.ts +51 -0
- package/dist/components/TextEditor/TextEditor.stories.d.ts.map +1 -0
- package/dist/components/TextEditor/ToolbarButton.d.ts +38 -0
- package/dist/components/TextEditor/ToolbarButton.d.ts.map +1 -0
- package/dist/components/TextEditor/ToolbarButton.js +68 -0
- package/dist/components/TextEditor/ToolbarSeparator.d.ts +22 -0
- package/dist/components/TextEditor/ToolbarSeparator.d.ts.map +1 -0
- package/dist/components/TextEditor/ToolbarSeparator.js +23 -0
- package/dist/components/TextEditor/index.d.ts +4 -0
- package/dist/components/TextEditor/index.d.ts.map +1 -0
- package/dist/components/TextEditor/useLinkEditor.d.ts +37 -0
- package/dist/components/TextEditor/useLinkEditor.d.ts.map +1 -0
- package/dist/components/TextEditor/useLinkEditor.js +32 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.js +140 -132
- package/dist/muza-ui.css +1 -1
- package/dist/node_modules/@popperjs/core/lib/createPopper.js +122 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/contains.js +18 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js +23 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js +37 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js +32 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js +10 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js +17 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js +9 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js +13 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getNodeName.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js +10 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js +35 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getParentNode.js +18 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js +10 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js +21 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getWindow.js +12 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js +11 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js +9 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/instanceOf.js +20 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js +8 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/isTableElement.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js +16 -0
- package/dist/node_modules/@popperjs/core/lib/enums.js +31 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/applyStyles.js +47 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/arrow.js +37 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/computeStyles.js +99 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/eventListeners.js +26 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/flip.js +74 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/hide.js +44 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/offset.js +31 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/popperOffsets.js +19 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/preventOverflow.js +54 -0
- package/dist/node_modules/@popperjs/core/lib/popper.js +27 -0
- package/dist/node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js +27 -0
- package/dist/node_modules/@popperjs/core/lib/utils/computeOffsets.js +54 -0
- package/dist/node_modules/@popperjs/core/lib/utils/debounce.js +13 -0
- package/dist/node_modules/@popperjs/core/lib/utils/detectOverflow.js +33 -0
- package/dist/node_modules/@popperjs/core/lib/utils/expandToHashMap.js +8 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getAltAxis.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getBasePlacement.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getFreshSideObject.js +11 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositePlacement.js +14 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js +12 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getVariation.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/math.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/mergeByName.js +15 -0
- package/dist/node_modules/@popperjs/core/lib/utils/mergePaddingObject.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/utils/orderModifiers.js +31 -0
- package/dist/node_modules/@popperjs/core/lib/utils/rectToClientRect.js +11 -0
- package/dist/node_modules/@popperjs/core/lib/utils/userAgent.js +9 -0
- package/dist/node_modules/@popperjs/core/lib/utils/within.js +12 -0
- package/dist/node_modules/@tiptap/core/dist/index.js +2857 -0
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +45 -0
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js +76 -0
- package/dist/node_modules/@tiptap/extension-bubble-menu/dist/index.js +129 -0
- package/dist/node_modules/@tiptap/extension-bullet-list/dist/index.js +55 -0
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +54 -0
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +136 -0
- package/dist/node_modules/@tiptap/extension-document/dist/index.js +10 -0
- package/dist/node_modules/@tiptap/extension-dropcursor/dist/index.js +21 -0
- package/dist/node_modules/@tiptap/extension-gapcursor/dist/index.js +25 -0
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +56 -0
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +55 -0
- package/dist/node_modules/@tiptap/extension-history/dist/index.js +36 -0
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +59 -0
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js +75 -0
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +272 -0
- package/dist/node_modules/@tiptap/extension-list-item/dist/index.js +34 -0
- package/dist/node_modules/@tiptap/extension-ordered-list/dist/index.js +73 -0
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +34 -0
- package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js +53 -0
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js +64 -0
- package/dist/node_modules/@tiptap/extension-text/dist/index.js +9 -0
- package/dist/node_modules/@tiptap/react/dist/index.js +709 -0
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js +30 -0
- package/dist/node_modules/framer-motion/dist/es/animation/animate/resolve-subjects.js +4 -4
- package/dist/node_modules/framer-motion/dist/es/animation/animate/subject.js +24 -24
- package/dist/node_modules/framer-motion/dist/es/animation/sequence/create.js +61 -56
- package/dist/node_modules/framer-motion/dist/es/animation/utils/create-visual-element.js +8 -8
- package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +32 -30
- package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +22 -22
- package/dist/node_modules/framer-motion/dist/es/components/AnimatePresence/index.js +34 -32
- package/dist/node_modules/framer-motion/dist/es/components/Reorder/Group.js +34 -26
- package/dist/node_modules/framer-motion/dist/es/components/Reorder/Item.js +30 -25
- package/dist/node_modules/framer-motion/dist/es/components/Reorder/utils/auto-scroll.js +64 -0
- package/dist/node_modules/framer-motion/dist/es/context/MotionContext/utils.js +2 -2
- package/dist/node_modules/framer-motion/dist/es/events/add-pointer-event.js +3 -3
- package/dist/node_modules/framer-motion/dist/es/gestures/drag/VisualElementDragControls.js +100 -89
- package/dist/node_modules/framer-motion/dist/es/gestures/drag/index.js +11 -7
- package/dist/node_modules/framer-motion/dist/es/gestures/drag/utils/constraints.js +4 -4
- package/dist/node_modules/framer-motion/dist/es/gestures/focus.js +2 -2
- package/dist/node_modules/framer-motion/dist/es/gestures/hover.js +1 -1
- package/dist/node_modules/framer-motion/dist/es/gestures/pan/PanSession.js +106 -59
- package/dist/node_modules/framer-motion/dist/es/gestures/pan/index.js +6 -6
- package/dist/node_modules/framer-motion/dist/es/gestures/press.js +1 -1
- package/dist/node_modules/framer-motion/dist/es/motion/features/animation/exit.js +1 -1
- package/dist/node_modules/framer-motion/dist/es/motion/features/animation/index.js +5 -5
- package/dist/node_modules/framer-motion/dist/es/motion/features/definitions.js +18 -6
- package/dist/node_modules/framer-motion/dist/es/motion/features/drag.js +1 -1
- package/dist/node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.js +27 -42
- package/dist/node_modules/framer-motion/dist/es/motion/features/layout.js +4 -4
- package/dist/node_modules/framer-motion/dist/es/motion/features/load-features.js +10 -7
- package/dist/node_modules/framer-motion/dist/es/motion/features/viewport/index.js +4 -4
- package/dist/node_modules/framer-motion/dist/es/motion/index.js +49 -49
- package/dist/node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.js +18 -13
- package/dist/node_modules/framer-motion/dist/es/motion/utils/use-visual-element.js +41 -40
- package/dist/node_modules/framer-motion/dist/es/motion/utils/use-visual-state.js +13 -13
- package/dist/node_modules/framer-motion/dist/es/render/dom/create-visual-element.js +6 -6
- package/dist/node_modules/framer-motion/dist/es/render/dom/use-render.js +12 -12
- package/dist/node_modules/framer-motion/dist/es/render/html/use-html-visual-state.js +3 -3
- package/dist/node_modules/framer-motion/dist/es/render/html/use-props.js +7 -7
- package/dist/node_modules/framer-motion/dist/es/render/svg/use-props.js +5 -5
- package/dist/node_modules/framer-motion/dist/es/render/svg/use-svg-visual-state.js +1 -1
- package/dist/node_modules/framer-motion/dist/es/value/use-transform.js +26 -18
- package/dist/node_modules/linkifyjs/dist/linkify.js +707 -0
- package/dist/node_modules/motion-dom/dist/es/animation/AsyncMotionValueAnimation.js +33 -30
- package/dist/node_modules/motion-dom/dist/es/animation/NativeAnimation.js +17 -17
- package/dist/node_modules/motion-dom/dist/es/animation/NativeAnimationExtended.js +20 -19
- package/dist/node_modules/motion-dom/dist/es/animation/animate/single-value.js +10 -0
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/interfaces/motion-value.js +13 -13
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/interfaces/visual-element-target.js +11 -11
- package/dist/node_modules/motion-dom/dist/es/animation/keyframes/DOMKeyframesResolver.js +24 -20
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/utils/default-transitions.js +1 -1
- package/dist/node_modules/motion-dom/dist/es/animation/utils/is-css-variable.js +7 -3
- package/dist/node_modules/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.js +1 -1
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/animation/mix-values.js +2 -2
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/geometry/delta-apply.js +4 -4
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/geometry/delta-calc.js +1 -1
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/geometry/delta-remove.js +6 -6
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/node/DocumentProjectionNode.js +7 -4
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/node/create-projection-node.js +149 -149
- package/dist/node_modules/motion-dom/dist/es/projection/shared/stack.js +60 -0
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/styles/scale-border-radius.js +1 -1
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/styles/scale-box-shadow.js +2 -2
- package/dist/node_modules/motion-dom/dist/es/projection/styles/scale-correction.js +21 -0
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/VisualElement.js +58 -50
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/dom/DOMVisualElement.js +7 -6
- package/dist/node_modules/motion-dom/dist/es/render/dom/utils/camel-to-dash.js +6 -0
- package/dist/node_modules/motion-dom/dist/es/render/html/HTMLVisualElement.js +38 -0
- package/dist/node_modules/motion-dom/dist/es/render/html/utils/build-styles.js +29 -0
- package/dist/node_modules/motion-dom/dist/es/render/html/utils/build-transform.js +37 -0
- package/dist/node_modules/motion-dom/dist/es/render/html/utils/scrape-motion-values.js +14 -0
- package/dist/node_modules/motion-dom/dist/es/render/svg/SVGVisualElement.js +40 -0
- package/dist/node_modules/motion-dom/dist/es/render/svg/utils/build-attrs.js +32 -0
- package/dist/node_modules/motion-dom/dist/es/render/svg/utils/path.js +15 -0
- package/dist/node_modules/motion-dom/dist/es/render/svg/utils/scrape-motion-values.js +15 -0
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/animation-state.js +31 -31
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/is-controlling-variants.js +1 -1
- package/dist/node_modules/motion-dom/dist/es/render/utils/is-forced-motion-value.js +9 -0
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/motion-values.js +6 -6
- package/dist/node_modules/motion-dom/dist/es/render/utils/reduced-motion/index.js +15 -0
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/setters.js +4 -4
- package/dist/node_modules/{framer-motion → motion-dom}/dist/es/utils/delay.js +2 -2
- package/dist/node_modules/motion-dom/dist/es/utils/resolve-elements.js +8 -6
- package/dist/node_modules/motion-dom/dist/es/value/types/maps/number.js +62 -42
- package/dist/node_modules/motion-dom/dist/es/value/utils/resolve-motion-value.js +7 -0
- package/dist/node_modules/motion-dom/dist/es/value/will-change/is.js +7 -0
- package/dist/node_modules/motion-utils/dist/es/errors.js +10 -9
- package/dist/node_modules/orderedmap/dist/index.js +103 -0
- package/dist/node_modules/prosemirror-commands/dist/index.js +388 -0
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js +86 -0
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +204 -0
- package/dist/node_modules/prosemirror-history/dist/index.js +248 -0
- package/dist/node_modules/prosemirror-keymap/dist/index.js +62 -0
- package/dist/node_modules/prosemirror-model/dist/index.js +2733 -0
- package/dist/node_modules/prosemirror-schema-list/dist/index.js +88 -0
- package/dist/node_modules/prosemirror-state/dist/index.js +822 -0
- package/dist/node_modules/prosemirror-transform/dist/index.js +1520 -0
- package/dist/node_modules/prosemirror-view/dist/index.js +3794 -0
- package/dist/node_modules/rope-sequence/dist/index.js +100 -0
- package/dist/node_modules/tippy.js/dist/tippy.esm.js +813 -0
- package/dist/node_modules/w3c-keyname/index.js +93 -0
- package/dist/translations/locales/cs.d.ts.map +1 -1
- package/dist/translations/locales/cs.js +18 -0
- package/dist/translations/locales/en.d.ts.map +1 -1
- package/dist/translations/locales/en.js +18 -0
- package/dist/translations/locales/sk.d.ts.map +1 -1
- package/dist/translations/locales/sk.js +18 -0
- package/dist/translations/types.d.ts +22 -0
- package/dist/translations/types.d.ts.map +1 -1
- package/package.json +17 -1
- package/dist/node_modules/framer-motion/dist/es/animation/animate/single-value.js +0 -10
- package/dist/node_modules/framer-motion/dist/es/motion/utils/is-forced-motion-value.js +0 -8
- package/dist/node_modules/framer-motion/dist/es/projection/shared/stack.js +0 -58
- package/dist/node_modules/framer-motion/dist/es/projection/styles/scale-correction.js +0 -10
- package/dist/node_modules/framer-motion/dist/es/render/dom/utils/camel-to-dash.js +0 -4
- package/dist/node_modules/framer-motion/dist/es/render/html/HTMLVisualElement.js +0 -38
- package/dist/node_modules/framer-motion/dist/es/render/html/utils/build-styles.js +0 -29
- package/dist/node_modules/framer-motion/dist/es/render/html/utils/build-transform.js +0 -31
- package/dist/node_modules/framer-motion/dist/es/render/html/utils/scrape-motion-values.js +0 -12
- package/dist/node_modules/framer-motion/dist/es/render/svg/SVGVisualElement.js +0 -40
- package/dist/node_modules/framer-motion/dist/es/render/svg/utils/build-attrs.js +0 -23
- package/dist/node_modules/framer-motion/dist/es/render/svg/utils/path.js +0 -18
- package/dist/node_modules/framer-motion/dist/es/render/svg/utils/scrape-motion-values.js +0 -15
- package/dist/node_modules/framer-motion/dist/es/utils/reduced-motion/index.js +0 -13
- package/dist/node_modules/framer-motion/dist/es/value/use-will-change/is.js +0 -7
- package/dist/node_modules/framer-motion/dist/es/value/utils/resolve-motion-value.js +0 -7
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/interfaces/visual-element-variant.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/interfaces/visual-element.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/optimized-appear/data-id.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/optimized-appear/get-appear-id.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/utils/calc-child-stagger.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es/animation/animators/waapi → motion-dom/dist/es/animation}/utils/get-final-keyframe.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/animation/utils/is-transition-defined.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/events/add-dom-event.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/geometry/conversion.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/geometry/copy.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/geometry/models.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/geometry/utils.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/node/HTMLProjectionNode.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/node/state.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/styles/transform.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es/render → motion-dom/dist/es/projection}/utils/compare-by-depth.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/utils/each-axis.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es/render → motion-dom/dist/es/projection}/utils/flat-tree.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/utils/has-transform.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/projection/utils/measure.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es/motion/features → motion-dom/dist/es/render}/Feature.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/html/utils/render.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/object/ObjectVisualElement.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/store.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/svg/utils/camel-case-attrs.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/svg/utils/is-svg-tag.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/svg/utils/render.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/get-variant-context.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es/animation → motion-dom/dist/es/render}/utils/is-animation-controls.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es/animation → motion-dom/dist/es/render}/utils/is-keyframes-target.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/is-variant-label.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es → motion-dom/dist/es/render}/utils/reduced-motion/state.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/resolve-dynamic-variants.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/resolve-variants.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es → motion-dom/dist/es/render}/utils/shallow-compare.js +0 -0
- /package/dist/node_modules/{framer-motion → motion-dom}/dist/es/render/utils/variant-props.js +0 -0
- /package/dist/node_modules/{framer-motion/dist/es/value/use-will-change → motion-dom/dist/es/value/will-change}/add-will-change.js +0 -0
|
@@ -0,0 +1,2857 @@
|
|
|
1
|
+
import { EditorState as Lt, NodeSelection as J, Plugin as I, PluginKey as j, Selection as F, TextSelection as P, AllSelection as zt } from "../../../prosemirror-state/dist/index.js";
|
|
2
|
+
import { EditorView as Ht } from "../../../prosemirror-view/dist/index.js";
|
|
3
|
+
import { keymap as _t } from "../../../prosemirror-keymap/dist/index.js";
|
|
4
|
+
import { DOMSerializer as Wt, Schema as xt, Fragment as $, Node as Vt, DOMParser as nt, Slice as Kt } from "../../../prosemirror-model/dist/index.js";
|
|
5
|
+
import { findWrapping as Ut, canJoin as dt, Transform as qt, canSplit as V, joinPoint as Ct, liftTarget as Gt, ReplaceStep as Jt, ReplaceAroundStep as Yt } from "../../../prosemirror-transform/dist/index.js";
|
|
6
|
+
import { wrapIn as Qt, setBlockType as gt, selectTextblockStart as Xt, selectTextblockEnd as Zt, selectParentNode as te, selectNodeForward as ee, selectNodeBackward as ne, newlineInCode as re, liftEmptyBlock as oe, lift as se, joinUp as ie, joinTextblockForward as ae, joinTextblockBackward as ce, joinForward as le, joinDown as de, joinBackward as ue, exitCode as fe, deleteSelection as pe, createParagraphNear as he } from "../../../prosemirror-commands/dist/index.js";
|
|
7
|
+
import { wrapInList as me, sinkListItem as ge, liftListItem as ye } from "../../../prosemirror-schema-list/dist/index.js";
|
|
8
|
+
function Y(n) {
|
|
9
|
+
const { state: t, transaction: e } = n;
|
|
10
|
+
let { selection: r } = e, { doc: o } = e, { storedMarks: s } = e;
|
|
11
|
+
return {
|
|
12
|
+
...t,
|
|
13
|
+
apply: t.apply.bind(t),
|
|
14
|
+
applyTransaction: t.applyTransaction.bind(t),
|
|
15
|
+
plugins: t.plugins,
|
|
16
|
+
schema: t.schema,
|
|
17
|
+
reconfigure: t.reconfigure.bind(t),
|
|
18
|
+
toJSON: t.toJSON.bind(t),
|
|
19
|
+
get storedMarks() {
|
|
20
|
+
return s;
|
|
21
|
+
},
|
|
22
|
+
get selection() {
|
|
23
|
+
return r;
|
|
24
|
+
},
|
|
25
|
+
get doc() {
|
|
26
|
+
return o;
|
|
27
|
+
},
|
|
28
|
+
get tr() {
|
|
29
|
+
return r = e.selection, o = e.doc, s = e.storedMarks, e;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
class Q {
|
|
34
|
+
constructor(t) {
|
|
35
|
+
this.editor = t.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = t.state;
|
|
36
|
+
}
|
|
37
|
+
get hasCustomState() {
|
|
38
|
+
return !!this.customState;
|
|
39
|
+
}
|
|
40
|
+
get state() {
|
|
41
|
+
return this.customState || this.editor.state;
|
|
42
|
+
}
|
|
43
|
+
get commands() {
|
|
44
|
+
const { rawCommands: t, editor: e, state: r } = this, { view: o } = e, { tr: s } = r, i = this.buildProps(s);
|
|
45
|
+
return Object.fromEntries(Object.entries(t).map(([c, a]) => [c, (...u) => {
|
|
46
|
+
const d = a(...u)(i);
|
|
47
|
+
return !s.getMeta("preventDispatch") && !this.hasCustomState && o.dispatch(s), d;
|
|
48
|
+
}]));
|
|
49
|
+
}
|
|
50
|
+
get chain() {
|
|
51
|
+
return () => this.createChain();
|
|
52
|
+
}
|
|
53
|
+
get can() {
|
|
54
|
+
return () => this.createCan();
|
|
55
|
+
}
|
|
56
|
+
createChain(t, e = !0) {
|
|
57
|
+
const { rawCommands: r, editor: o, state: s } = this, { view: i } = o, c = [], a = !!t, l = t || s.tr, u = () => (!a && e && !l.getMeta("preventDispatch") && !this.hasCustomState && i.dispatch(l), c.every((f) => f === !0)), d = {
|
|
58
|
+
...Object.fromEntries(Object.entries(r).map(([f, p]) => [f, (...h) => {
|
|
59
|
+
const g = this.buildProps(l, e), y = p(...h)(g);
|
|
60
|
+
return c.push(y), d;
|
|
61
|
+
}])),
|
|
62
|
+
run: u
|
|
63
|
+
};
|
|
64
|
+
return d;
|
|
65
|
+
}
|
|
66
|
+
createCan(t) {
|
|
67
|
+
const { rawCommands: e, state: r } = this, o = !1, s = t || r.tr, i = this.buildProps(s, o);
|
|
68
|
+
return {
|
|
69
|
+
...Object.fromEntries(Object.entries(e).map(([a, l]) => [a, (...u) => l(...u)({ ...i, dispatch: void 0 })])),
|
|
70
|
+
chain: () => this.createChain(s, o)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
buildProps(t, e = !0) {
|
|
74
|
+
const { rawCommands: r, editor: o, state: s } = this, { view: i } = o, c = {
|
|
75
|
+
tr: t,
|
|
76
|
+
editor: o,
|
|
77
|
+
view: i,
|
|
78
|
+
state: Y({
|
|
79
|
+
state: s,
|
|
80
|
+
transaction: t
|
|
81
|
+
}),
|
|
82
|
+
dispatch: e ? () => {
|
|
83
|
+
} : void 0,
|
|
84
|
+
chain: () => this.createChain(t, e),
|
|
85
|
+
can: () => this.createCan(t),
|
|
86
|
+
get commands() {
|
|
87
|
+
return Object.fromEntries(Object.entries(r).map(([a, l]) => [a, (...u) => l(...u)(c)]));
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return c;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class ke {
|
|
94
|
+
constructor() {
|
|
95
|
+
this.callbacks = {};
|
|
96
|
+
}
|
|
97
|
+
on(t, e) {
|
|
98
|
+
return this.callbacks[t] || (this.callbacks[t] = []), this.callbacks[t].push(e), this;
|
|
99
|
+
}
|
|
100
|
+
emit(t, ...e) {
|
|
101
|
+
const r = this.callbacks[t];
|
|
102
|
+
return r && r.forEach((o) => o.apply(this, e)), this;
|
|
103
|
+
}
|
|
104
|
+
off(t, e) {
|
|
105
|
+
const r = this.callbacks[t];
|
|
106
|
+
return r && (e ? this.callbacks[t] = r.filter((o) => o !== e) : delete this.callbacks[t]), this;
|
|
107
|
+
}
|
|
108
|
+
once(t, e) {
|
|
109
|
+
const r = (...o) => {
|
|
110
|
+
this.off(t, r), e.apply(this, o);
|
|
111
|
+
};
|
|
112
|
+
return this.on(t, r);
|
|
113
|
+
}
|
|
114
|
+
removeAllListeners() {
|
|
115
|
+
this.callbacks = {};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function k(n, t, e) {
|
|
119
|
+
return n.config[t] === void 0 && n.parent ? k(n.parent, t, e) : typeof n.config[t] == "function" ? n.config[t].bind({
|
|
120
|
+
...e,
|
|
121
|
+
parent: n.parent ? k(n.parent, t, e) : null
|
|
122
|
+
}) : n.config[t];
|
|
123
|
+
}
|
|
124
|
+
function X(n) {
|
|
125
|
+
const t = n.filter((o) => o.type === "extension"), e = n.filter((o) => o.type === "node"), r = n.filter((o) => o.type === "mark");
|
|
126
|
+
return {
|
|
127
|
+
baseExtensions: t,
|
|
128
|
+
nodeExtensions: e,
|
|
129
|
+
markExtensions: r
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function Tt(n) {
|
|
133
|
+
const t = [], { nodeExtensions: e, markExtensions: r } = X(n), o = [...e, ...r], s = {
|
|
134
|
+
default: null,
|
|
135
|
+
rendered: !0,
|
|
136
|
+
renderHTML: null,
|
|
137
|
+
parseHTML: null,
|
|
138
|
+
keepOnSplit: !0,
|
|
139
|
+
isRequired: !1
|
|
140
|
+
};
|
|
141
|
+
return n.forEach((i) => {
|
|
142
|
+
const c = {
|
|
143
|
+
name: i.name,
|
|
144
|
+
options: i.options,
|
|
145
|
+
storage: i.storage,
|
|
146
|
+
extensions: o
|
|
147
|
+
}, a = k(i, "addGlobalAttributes", c);
|
|
148
|
+
if (!a)
|
|
149
|
+
return;
|
|
150
|
+
a().forEach((u) => {
|
|
151
|
+
u.types.forEach((d) => {
|
|
152
|
+
Object.entries(u.attributes).forEach(([f, p]) => {
|
|
153
|
+
t.push({
|
|
154
|
+
type: d,
|
|
155
|
+
name: f,
|
|
156
|
+
attribute: {
|
|
157
|
+
...s,
|
|
158
|
+
...p
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}), o.forEach((i) => {
|
|
165
|
+
const c = {
|
|
166
|
+
name: i.name,
|
|
167
|
+
options: i.options,
|
|
168
|
+
storage: i.storage
|
|
169
|
+
}, a = k(i, "addAttributes", c);
|
|
170
|
+
if (!a)
|
|
171
|
+
return;
|
|
172
|
+
const l = a();
|
|
173
|
+
Object.entries(l).forEach(([u, d]) => {
|
|
174
|
+
const f = {
|
|
175
|
+
...s,
|
|
176
|
+
...d
|
|
177
|
+
};
|
|
178
|
+
typeof (f == null ? void 0 : f.default) == "function" && (f.default = f.default()), f != null && f.isRequired && (f == null ? void 0 : f.default) === void 0 && delete f.default, t.push({
|
|
179
|
+
type: i.name,
|
|
180
|
+
name: u,
|
|
181
|
+
attribute: f
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}), t;
|
|
185
|
+
}
|
|
186
|
+
function S(n, t) {
|
|
187
|
+
if (typeof n == "string") {
|
|
188
|
+
if (!t.nodes[n])
|
|
189
|
+
throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);
|
|
190
|
+
return t.nodes[n];
|
|
191
|
+
}
|
|
192
|
+
return n;
|
|
193
|
+
}
|
|
194
|
+
function be(...n) {
|
|
195
|
+
return n.filter((t) => !!t).reduce((t, e) => {
|
|
196
|
+
const r = { ...t };
|
|
197
|
+
return Object.entries(e).forEach(([o, s]) => {
|
|
198
|
+
if (!r[o]) {
|
|
199
|
+
r[o] = s;
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (o === "class") {
|
|
203
|
+
const c = s ? String(s).split(" ") : [], a = r[o] ? r[o].split(" ") : [], l = c.filter((u) => !a.includes(u));
|
|
204
|
+
r[o] = [...a, ...l].join(" ");
|
|
205
|
+
} else if (o === "style") {
|
|
206
|
+
const c = s ? s.split(";").map((u) => u.trim()).filter(Boolean) : [], a = r[o] ? r[o].split(";").map((u) => u.trim()).filter(Boolean) : [], l = /* @__PURE__ */ new Map();
|
|
207
|
+
a.forEach((u) => {
|
|
208
|
+
const [d, f] = u.split(":").map((p) => p.trim());
|
|
209
|
+
l.set(d, f);
|
|
210
|
+
}), c.forEach((u) => {
|
|
211
|
+
const [d, f] = u.split(":").map((p) => p.trim());
|
|
212
|
+
l.set(d, f);
|
|
213
|
+
}), r[o] = Array.from(l.entries()).map(([u, d]) => `${u}: ${d}`).join("; ");
|
|
214
|
+
} else
|
|
215
|
+
r[o] = s;
|
|
216
|
+
}), r;
|
|
217
|
+
}, {});
|
|
218
|
+
}
|
|
219
|
+
function it(n, t) {
|
|
220
|
+
return t.filter((e) => e.type === n.type.name).filter((e) => e.attribute.rendered).map((e) => e.attribute.renderHTML ? e.attribute.renderHTML(n.attrs) || {} : {
|
|
221
|
+
[e.name]: n.attrs[e.name]
|
|
222
|
+
}).reduce((e, r) => be(e, r), {});
|
|
223
|
+
}
|
|
224
|
+
function At(n) {
|
|
225
|
+
return typeof n == "function";
|
|
226
|
+
}
|
|
227
|
+
function b(n, t = void 0, ...e) {
|
|
228
|
+
return At(n) ? t ? n.bind(t)(...e) : n(...e) : n;
|
|
229
|
+
}
|
|
230
|
+
function ve(n = {}) {
|
|
231
|
+
return Object.keys(n).length === 0 && n.constructor === Object;
|
|
232
|
+
}
|
|
233
|
+
function we(n) {
|
|
234
|
+
return typeof n != "string" ? n : n.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(n) : n === "true" ? !0 : n === "false" ? !1 : n;
|
|
235
|
+
}
|
|
236
|
+
function yt(n, t) {
|
|
237
|
+
return "style" in n ? n : {
|
|
238
|
+
...n,
|
|
239
|
+
getAttrs: (e) => {
|
|
240
|
+
const r = n.getAttrs ? n.getAttrs(e) : n.attrs;
|
|
241
|
+
if (r === !1)
|
|
242
|
+
return !1;
|
|
243
|
+
const o = t.reduce((s, i) => {
|
|
244
|
+
const c = i.attribute.parseHTML ? i.attribute.parseHTML(e) : we(e.getAttribute(i.name));
|
|
245
|
+
return c == null ? s : {
|
|
246
|
+
...s,
|
|
247
|
+
[i.name]: c
|
|
248
|
+
};
|
|
249
|
+
}, {});
|
|
250
|
+
return { ...r, ...o };
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function kt(n) {
|
|
255
|
+
return Object.fromEntries(
|
|
256
|
+
// @ts-ignore
|
|
257
|
+
Object.entries(n).filter(([t, e]) => t === "attrs" && ve(e) ? !1 : e != null)
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
function Me(n, t) {
|
|
261
|
+
var e;
|
|
262
|
+
const r = Tt(n), { nodeExtensions: o, markExtensions: s } = X(n), i = (e = o.find((l) => k(l, "topNode"))) === null || e === void 0 ? void 0 : e.name, c = Object.fromEntries(o.map((l) => {
|
|
263
|
+
const u = r.filter((y) => y.type === l.name), d = {
|
|
264
|
+
name: l.name,
|
|
265
|
+
options: l.options,
|
|
266
|
+
storage: l.storage,
|
|
267
|
+
editor: t
|
|
268
|
+
}, f = n.reduce((y, v) => {
|
|
269
|
+
const w = k(v, "extendNodeSchema", d);
|
|
270
|
+
return {
|
|
271
|
+
...y,
|
|
272
|
+
...w ? w(l) : {}
|
|
273
|
+
};
|
|
274
|
+
}, {}), p = kt({
|
|
275
|
+
...f,
|
|
276
|
+
content: b(k(l, "content", d)),
|
|
277
|
+
marks: b(k(l, "marks", d)),
|
|
278
|
+
group: b(k(l, "group", d)),
|
|
279
|
+
inline: b(k(l, "inline", d)),
|
|
280
|
+
atom: b(k(l, "atom", d)),
|
|
281
|
+
selectable: b(k(l, "selectable", d)),
|
|
282
|
+
draggable: b(k(l, "draggable", d)),
|
|
283
|
+
code: b(k(l, "code", d)),
|
|
284
|
+
whitespace: b(k(l, "whitespace", d)),
|
|
285
|
+
linebreakReplacement: b(k(l, "linebreakReplacement", d)),
|
|
286
|
+
defining: b(k(l, "defining", d)),
|
|
287
|
+
isolating: b(k(l, "isolating", d)),
|
|
288
|
+
attrs: Object.fromEntries(u.map((y) => {
|
|
289
|
+
var v;
|
|
290
|
+
return [y.name, { default: (v = y == null ? void 0 : y.attribute) === null || v === void 0 ? void 0 : v.default }];
|
|
291
|
+
}))
|
|
292
|
+
}), m = b(k(l, "parseHTML", d));
|
|
293
|
+
m && (p.parseDOM = m.map((y) => yt(y, u)));
|
|
294
|
+
const h = k(l, "renderHTML", d);
|
|
295
|
+
h && (p.toDOM = (y) => h({
|
|
296
|
+
node: y,
|
|
297
|
+
HTMLAttributes: it(y, u)
|
|
298
|
+
}));
|
|
299
|
+
const g = k(l, "renderText", d);
|
|
300
|
+
return g && (p.toText = g), [l.name, p];
|
|
301
|
+
})), a = Object.fromEntries(s.map((l) => {
|
|
302
|
+
const u = r.filter((g) => g.type === l.name), d = {
|
|
303
|
+
name: l.name,
|
|
304
|
+
options: l.options,
|
|
305
|
+
storage: l.storage,
|
|
306
|
+
editor: t
|
|
307
|
+
}, f = n.reduce((g, y) => {
|
|
308
|
+
const v = k(y, "extendMarkSchema", d);
|
|
309
|
+
return {
|
|
310
|
+
...g,
|
|
311
|
+
...v ? v(l) : {}
|
|
312
|
+
};
|
|
313
|
+
}, {}), p = kt({
|
|
314
|
+
...f,
|
|
315
|
+
inclusive: b(k(l, "inclusive", d)),
|
|
316
|
+
excludes: b(k(l, "excludes", d)),
|
|
317
|
+
group: b(k(l, "group", d)),
|
|
318
|
+
spanning: b(k(l, "spanning", d)),
|
|
319
|
+
code: b(k(l, "code", d)),
|
|
320
|
+
attrs: Object.fromEntries(u.map((g) => {
|
|
321
|
+
var y;
|
|
322
|
+
return [g.name, { default: (y = g == null ? void 0 : g.attribute) === null || y === void 0 ? void 0 : y.default }];
|
|
323
|
+
}))
|
|
324
|
+
}), m = b(k(l, "parseHTML", d));
|
|
325
|
+
m && (p.parseDOM = m.map((g) => yt(g, u)));
|
|
326
|
+
const h = k(l, "renderHTML", d);
|
|
327
|
+
return h && (p.toDOM = (g) => h({
|
|
328
|
+
mark: g,
|
|
329
|
+
HTMLAttributes: it(g, u)
|
|
330
|
+
})), [l.name, p];
|
|
331
|
+
}));
|
|
332
|
+
return new xt({
|
|
333
|
+
topNode: i,
|
|
334
|
+
nodes: c,
|
|
335
|
+
marks: a
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function rt(n, t) {
|
|
339
|
+
return t.nodes[n] || t.marks[n] || null;
|
|
340
|
+
}
|
|
341
|
+
function bt(n, t) {
|
|
342
|
+
return Array.isArray(t) ? t.some((e) => (typeof e == "string" ? e : e.name) === n.name) : t;
|
|
343
|
+
}
|
|
344
|
+
function ut(n, t) {
|
|
345
|
+
const e = Wt.fromSchema(t).serializeFragment(n), o = document.implementation.createHTMLDocument().createElement("div");
|
|
346
|
+
return o.appendChild(e), o.innerHTML;
|
|
347
|
+
}
|
|
348
|
+
const Se = (n, t = 500) => {
|
|
349
|
+
let e = "";
|
|
350
|
+
const r = n.parentOffset;
|
|
351
|
+
return n.parent.nodesBetween(Math.max(0, r - t), r, (o, s, i, c) => {
|
|
352
|
+
var a, l;
|
|
353
|
+
const u = ((l = (a = o.type.spec).toText) === null || l === void 0 ? void 0 : l.call(a, {
|
|
354
|
+
node: o,
|
|
355
|
+
pos: s,
|
|
356
|
+
parent: i,
|
|
357
|
+
index: c
|
|
358
|
+
})) || o.textContent || "%leaf%";
|
|
359
|
+
e += o.isAtom && !o.isText ? u : u.slice(0, Math.max(0, r - s));
|
|
360
|
+
}), e;
|
|
361
|
+
};
|
|
362
|
+
function ft(n) {
|
|
363
|
+
return Object.prototype.toString.call(n) === "[object RegExp]";
|
|
364
|
+
}
|
|
365
|
+
class Z {
|
|
366
|
+
constructor(t) {
|
|
367
|
+
this.find = t.find, this.handler = t.handler;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const Ee = (n, t) => {
|
|
371
|
+
if (ft(t))
|
|
372
|
+
return t.exec(n);
|
|
373
|
+
const e = t(n);
|
|
374
|
+
if (!e)
|
|
375
|
+
return null;
|
|
376
|
+
const r = [e.text];
|
|
377
|
+
return r.index = e.index, r.input = n, r.data = e.data, e.replaceWith && (e.text.includes(e.replaceWith) || console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'), r.push(e.replaceWith)), r;
|
|
378
|
+
};
|
|
379
|
+
function z(n) {
|
|
380
|
+
var t;
|
|
381
|
+
const { editor: e, from: r, to: o, text: s, rules: i, plugin: c } = n, { view: a } = e;
|
|
382
|
+
if (a.composing)
|
|
383
|
+
return !1;
|
|
384
|
+
const l = a.state.doc.resolve(r);
|
|
385
|
+
if (
|
|
386
|
+
// check for code node
|
|
387
|
+
l.parent.type.spec.code || !((t = l.nodeBefore || l.nodeAfter) === null || t === void 0) && t.marks.find((f) => f.type.spec.code)
|
|
388
|
+
)
|
|
389
|
+
return !1;
|
|
390
|
+
let u = !1;
|
|
391
|
+
const d = Se(l) + s;
|
|
392
|
+
return i.forEach((f) => {
|
|
393
|
+
if (u)
|
|
394
|
+
return;
|
|
395
|
+
const p = Ee(d, f.find);
|
|
396
|
+
if (!p)
|
|
397
|
+
return;
|
|
398
|
+
const m = a.state.tr, h = Y({
|
|
399
|
+
state: a.state,
|
|
400
|
+
transaction: m
|
|
401
|
+
}), g = {
|
|
402
|
+
from: r - (p[0].length - s.length),
|
|
403
|
+
to: o
|
|
404
|
+
}, { commands: y, chain: v, can: w } = new Q({
|
|
405
|
+
editor: e,
|
|
406
|
+
state: h
|
|
407
|
+
});
|
|
408
|
+
f.handler({
|
|
409
|
+
state: h,
|
|
410
|
+
range: g,
|
|
411
|
+
match: p,
|
|
412
|
+
commands: y,
|
|
413
|
+
chain: v,
|
|
414
|
+
can: w
|
|
415
|
+
}) === null || !m.steps.length || (m.setMeta(c, {
|
|
416
|
+
transform: m,
|
|
417
|
+
from: r,
|
|
418
|
+
to: o,
|
|
419
|
+
text: s
|
|
420
|
+
}), a.dispatch(m), u = !0);
|
|
421
|
+
}), u;
|
|
422
|
+
}
|
|
423
|
+
function xe(n) {
|
|
424
|
+
const { editor: t, rules: e } = n, r = new I({
|
|
425
|
+
state: {
|
|
426
|
+
init() {
|
|
427
|
+
return null;
|
|
428
|
+
},
|
|
429
|
+
apply(o, s, i) {
|
|
430
|
+
const c = o.getMeta(r);
|
|
431
|
+
if (c)
|
|
432
|
+
return c;
|
|
433
|
+
const a = o.getMeta("applyInputRules");
|
|
434
|
+
return !!a && setTimeout(() => {
|
|
435
|
+
let { text: u } = a;
|
|
436
|
+
typeof u == "string" ? u = u : u = ut($.from(u), i.schema);
|
|
437
|
+
const { from: d } = a, f = d + u.length;
|
|
438
|
+
z({
|
|
439
|
+
editor: t,
|
|
440
|
+
from: d,
|
|
441
|
+
to: f,
|
|
442
|
+
text: u,
|
|
443
|
+
rules: e,
|
|
444
|
+
plugin: r
|
|
445
|
+
});
|
|
446
|
+
}), o.selectionSet || o.docChanged ? null : s;
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
props: {
|
|
450
|
+
handleTextInput(o, s, i, c) {
|
|
451
|
+
return z({
|
|
452
|
+
editor: t,
|
|
453
|
+
from: s,
|
|
454
|
+
to: i,
|
|
455
|
+
text: c,
|
|
456
|
+
rules: e,
|
|
457
|
+
plugin: r
|
|
458
|
+
});
|
|
459
|
+
},
|
|
460
|
+
handleDOMEvents: {
|
|
461
|
+
compositionend: (o) => (setTimeout(() => {
|
|
462
|
+
const { $cursor: s } = o.state.selection;
|
|
463
|
+
s && z({
|
|
464
|
+
editor: t,
|
|
465
|
+
from: s.pos,
|
|
466
|
+
to: s.pos,
|
|
467
|
+
text: "",
|
|
468
|
+
rules: e,
|
|
469
|
+
plugin: r
|
|
470
|
+
});
|
|
471
|
+
}), !1)
|
|
472
|
+
},
|
|
473
|
+
// add support for input rules to trigger on enter
|
|
474
|
+
// this is useful for example for code blocks
|
|
475
|
+
handleKeyDown(o, s) {
|
|
476
|
+
if (s.key !== "Enter")
|
|
477
|
+
return !1;
|
|
478
|
+
const { $cursor: i } = o.state.selection;
|
|
479
|
+
return i ? z({
|
|
480
|
+
editor: t,
|
|
481
|
+
from: i.pos,
|
|
482
|
+
to: i.pos,
|
|
483
|
+
text: `
|
|
484
|
+
`,
|
|
485
|
+
rules: e,
|
|
486
|
+
plugin: r
|
|
487
|
+
}) : !1;
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
// @ts-ignore
|
|
491
|
+
isInputRules: !0
|
|
492
|
+
});
|
|
493
|
+
return r;
|
|
494
|
+
}
|
|
495
|
+
function Ce(n) {
|
|
496
|
+
return Object.prototype.toString.call(n).slice(8, -1);
|
|
497
|
+
}
|
|
498
|
+
function H(n) {
|
|
499
|
+
return Ce(n) !== "Object" ? !1 : n.constructor === Object && Object.getPrototypeOf(n) === Object.prototype;
|
|
500
|
+
}
|
|
501
|
+
function tt(n, t) {
|
|
502
|
+
const e = { ...n };
|
|
503
|
+
return H(n) && H(t) && Object.keys(t).forEach((r) => {
|
|
504
|
+
H(t[r]) && H(n[r]) ? e[r] = tt(n[r], t[r]) : e[r] = t[r];
|
|
505
|
+
}), e;
|
|
506
|
+
}
|
|
507
|
+
class U {
|
|
508
|
+
constructor(t = {}) {
|
|
509
|
+
this.type = "mark", this.name = "mark", this.parent = null, this.child = null, this.config = {
|
|
510
|
+
name: this.name,
|
|
511
|
+
defaultOptions: {}
|
|
512
|
+
}, this.config = {
|
|
513
|
+
...this.config,
|
|
514
|
+
...t
|
|
515
|
+
}, this.name = this.config.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(k(this, "addOptions", {
|
|
516
|
+
name: this.name
|
|
517
|
+
}))), this.storage = b(k(this, "addStorage", {
|
|
518
|
+
name: this.name,
|
|
519
|
+
options: this.options
|
|
520
|
+
})) || {};
|
|
521
|
+
}
|
|
522
|
+
static create(t = {}) {
|
|
523
|
+
return new U(t);
|
|
524
|
+
}
|
|
525
|
+
configure(t = {}) {
|
|
526
|
+
const e = this.extend({
|
|
527
|
+
...this.config,
|
|
528
|
+
addOptions: () => tt(this.options, t)
|
|
529
|
+
});
|
|
530
|
+
return e.name = this.name, e.parent = this.parent, e;
|
|
531
|
+
}
|
|
532
|
+
extend(t = {}) {
|
|
533
|
+
const e = new U(t);
|
|
534
|
+
return e.parent = this, this.child = e, e.name = t.name ? t.name : e.parent.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`), e.options = b(k(e, "addOptions", {
|
|
535
|
+
name: e.name
|
|
536
|
+
})), e.storage = b(k(e, "addStorage", {
|
|
537
|
+
name: e.name,
|
|
538
|
+
options: e.options
|
|
539
|
+
})), e;
|
|
540
|
+
}
|
|
541
|
+
static handleExit({ editor: t, mark: e }) {
|
|
542
|
+
const { tr: r } = t.state, o = t.state.selection.$from;
|
|
543
|
+
if (o.pos === o.end()) {
|
|
544
|
+
const i = o.marks();
|
|
545
|
+
if (!!!i.find((l) => (l == null ? void 0 : l.type.name) === e.name))
|
|
546
|
+
return !1;
|
|
547
|
+
const a = i.find((l) => (l == null ? void 0 : l.type.name) === e.name);
|
|
548
|
+
return a && r.removeStoredMark(a), r.insertText(" ", o.pos), t.view.dispatch(r), !0;
|
|
549
|
+
}
|
|
550
|
+
return !1;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function Te(n) {
|
|
554
|
+
return typeof n == "number";
|
|
555
|
+
}
|
|
556
|
+
class Ae {
|
|
557
|
+
constructor(t) {
|
|
558
|
+
this.find = t.find, this.handler = t.handler;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
const Pe = (n, t, e) => {
|
|
562
|
+
if (ft(t))
|
|
563
|
+
return [...n.matchAll(t)];
|
|
564
|
+
const r = t(n, e);
|
|
565
|
+
return r ? r.map((o) => {
|
|
566
|
+
const s = [o.text];
|
|
567
|
+
return s.index = o.index, s.input = n, s.data = o.data, o.replaceWith && (o.text.includes(o.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), s.push(o.replaceWith)), s;
|
|
568
|
+
}) : [];
|
|
569
|
+
};
|
|
570
|
+
function Oe(n) {
|
|
571
|
+
const { editor: t, state: e, from: r, to: o, rule: s, pasteEvent: i, dropEvent: c } = n, { commands: a, chain: l, can: u } = new Q({
|
|
572
|
+
editor: t,
|
|
573
|
+
state: e
|
|
574
|
+
}), d = [];
|
|
575
|
+
return e.doc.nodesBetween(r, o, (p, m) => {
|
|
576
|
+
if (!p.isTextblock || p.type.spec.code)
|
|
577
|
+
return;
|
|
578
|
+
const h = Math.max(r, m), g = Math.min(o, m + p.content.size), y = p.textBetween(h - m, g - m, void 0, "");
|
|
579
|
+
Pe(y, s.find, i).forEach((w) => {
|
|
580
|
+
if (w.index === void 0)
|
|
581
|
+
return;
|
|
582
|
+
const E = h + w.index + 1, M = E + w[0].length, x = {
|
|
583
|
+
from: e.tr.mapping.map(E),
|
|
584
|
+
to: e.tr.mapping.map(M)
|
|
585
|
+
}, T = s.handler({
|
|
586
|
+
state: e,
|
|
587
|
+
range: x,
|
|
588
|
+
match: w,
|
|
589
|
+
commands: a,
|
|
590
|
+
chain: l,
|
|
591
|
+
can: u,
|
|
592
|
+
pasteEvent: i,
|
|
593
|
+
dropEvent: c
|
|
594
|
+
});
|
|
595
|
+
d.push(T);
|
|
596
|
+
});
|
|
597
|
+
}), d.every((p) => p !== null);
|
|
598
|
+
}
|
|
599
|
+
let _ = null;
|
|
600
|
+
const Ie = (n) => {
|
|
601
|
+
var t;
|
|
602
|
+
const e = new ClipboardEvent("paste", {
|
|
603
|
+
clipboardData: new DataTransfer()
|
|
604
|
+
});
|
|
605
|
+
return (t = e.clipboardData) === null || t === void 0 || t.setData("text/html", n), e;
|
|
606
|
+
};
|
|
607
|
+
function $e(n) {
|
|
608
|
+
const { editor: t, rules: e } = n;
|
|
609
|
+
let r = null, o = !1, s = !1, i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
610
|
+
try {
|
|
611
|
+
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
612
|
+
} catch {
|
|
613
|
+
c = null;
|
|
614
|
+
}
|
|
615
|
+
const a = ({ state: u, from: d, to: f, rule: p, pasteEvt: m }) => {
|
|
616
|
+
const h = u.tr, g = Y({
|
|
617
|
+
state: u,
|
|
618
|
+
transaction: h
|
|
619
|
+
});
|
|
620
|
+
if (!(!Oe({
|
|
621
|
+
editor: t,
|
|
622
|
+
state: g,
|
|
623
|
+
from: Math.max(d - 1, 0),
|
|
624
|
+
to: f.b - 1,
|
|
625
|
+
rule: p,
|
|
626
|
+
pasteEvent: m,
|
|
627
|
+
dropEvent: c
|
|
628
|
+
}) || !h.steps.length)) {
|
|
629
|
+
try {
|
|
630
|
+
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
631
|
+
} catch {
|
|
632
|
+
c = null;
|
|
633
|
+
}
|
|
634
|
+
return i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, h;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
return e.map((u) => new I({
|
|
638
|
+
// we register a global drag handler to track the current drag source element
|
|
639
|
+
view(d) {
|
|
640
|
+
const f = (m) => {
|
|
641
|
+
var h;
|
|
642
|
+
r = !((h = d.dom.parentElement) === null || h === void 0) && h.contains(m.target) ? d.dom.parentElement : null, r && (_ = t);
|
|
643
|
+
}, p = () => {
|
|
644
|
+
_ && (_ = null);
|
|
645
|
+
};
|
|
646
|
+
return window.addEventListener("dragstart", f), window.addEventListener("dragend", p), {
|
|
647
|
+
destroy() {
|
|
648
|
+
window.removeEventListener("dragstart", f), window.removeEventListener("dragend", p);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
},
|
|
652
|
+
props: {
|
|
653
|
+
handleDOMEvents: {
|
|
654
|
+
drop: (d, f) => {
|
|
655
|
+
if (s = r === d.dom.parentElement, c = f, !s) {
|
|
656
|
+
const p = _;
|
|
657
|
+
p != null && p.isEditable && setTimeout(() => {
|
|
658
|
+
const m = p.state.selection;
|
|
659
|
+
m && p.commands.deleteRange({ from: m.from, to: m.to });
|
|
660
|
+
}, 10);
|
|
661
|
+
}
|
|
662
|
+
return !1;
|
|
663
|
+
},
|
|
664
|
+
paste: (d, f) => {
|
|
665
|
+
var p;
|
|
666
|
+
const m = (p = f.clipboardData) === null || p === void 0 ? void 0 : p.getData("text/html");
|
|
667
|
+
return i = f, o = !!(m != null && m.includes("data-pm-slice")), !1;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
appendTransaction: (d, f, p) => {
|
|
672
|
+
const m = d[0], h = m.getMeta("uiEvent") === "paste" && !o, g = m.getMeta("uiEvent") === "drop" && !s, y = m.getMeta("applyPasteRules"), v = !!y;
|
|
673
|
+
if (!h && !g && !v)
|
|
674
|
+
return;
|
|
675
|
+
if (v) {
|
|
676
|
+
let { text: M } = y;
|
|
677
|
+
typeof M == "string" ? M = M : M = ut($.from(M), p.schema);
|
|
678
|
+
const { from: x } = y, T = x + M.length, A = Ie(M);
|
|
679
|
+
return a({
|
|
680
|
+
rule: u,
|
|
681
|
+
state: p,
|
|
682
|
+
from: x,
|
|
683
|
+
to: { b: T },
|
|
684
|
+
pasteEvt: A
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
const w = f.doc.content.findDiffStart(p.doc.content), E = f.doc.content.findDiffEnd(p.doc.content);
|
|
688
|
+
if (!(!Te(w) || !E || w === E.b))
|
|
689
|
+
return a({
|
|
690
|
+
rule: u,
|
|
691
|
+
state: p,
|
|
692
|
+
from: w,
|
|
693
|
+
to: E,
|
|
694
|
+
pasteEvt: i
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
}));
|
|
698
|
+
}
|
|
699
|
+
function Be(n) {
|
|
700
|
+
const t = n.filter((e, r) => n.indexOf(e) !== r);
|
|
701
|
+
return Array.from(new Set(t));
|
|
702
|
+
}
|
|
703
|
+
class R {
|
|
704
|
+
constructor(t, e) {
|
|
705
|
+
this.splittableMarks = [], this.editor = e, this.extensions = R.resolve(t), this.schema = Me(this.extensions, e), this.setupExtensions();
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Returns a flattened and sorted extension list while
|
|
709
|
+
* also checking for duplicated extensions and warns the user.
|
|
710
|
+
* @param extensions An array of Tiptap extensions
|
|
711
|
+
* @returns An flattened and sorted array of Tiptap extensions
|
|
712
|
+
*/
|
|
713
|
+
static resolve(t) {
|
|
714
|
+
const e = R.sort(R.flatten(t)), r = Be(e.map((o) => o.name));
|
|
715
|
+
return r.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map((o) => `'${o}'`).join(", ")}]. This can lead to issues.`), e;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Create a flattened array of extensions by traversing the `addExtensions` field.
|
|
719
|
+
* @param extensions An array of Tiptap extensions
|
|
720
|
+
* @returns A flattened array of Tiptap extensions
|
|
721
|
+
*/
|
|
722
|
+
static flatten(t) {
|
|
723
|
+
return t.map((e) => {
|
|
724
|
+
const r = {
|
|
725
|
+
name: e.name,
|
|
726
|
+
options: e.options,
|
|
727
|
+
storage: e.storage
|
|
728
|
+
}, o = k(e, "addExtensions", r);
|
|
729
|
+
return o ? [e, ...this.flatten(o())] : e;
|
|
730
|
+
}).flat(10);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Sort extensions by priority.
|
|
734
|
+
* @param extensions An array of Tiptap extensions
|
|
735
|
+
* @returns A sorted array of Tiptap extensions by priority
|
|
736
|
+
*/
|
|
737
|
+
static sort(t) {
|
|
738
|
+
return t.sort((r, o) => {
|
|
739
|
+
const s = k(r, "priority") || 100, i = k(o, "priority") || 100;
|
|
740
|
+
return s > i ? -1 : s < i ? 1 : 0;
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Get all commands from the extensions.
|
|
745
|
+
* @returns An object with all commands where the key is the command name and the value is the command function
|
|
746
|
+
*/
|
|
747
|
+
get commands() {
|
|
748
|
+
return this.extensions.reduce((t, e) => {
|
|
749
|
+
const r = {
|
|
750
|
+
name: e.name,
|
|
751
|
+
options: e.options,
|
|
752
|
+
storage: e.storage,
|
|
753
|
+
editor: this.editor,
|
|
754
|
+
type: rt(e.name, this.schema)
|
|
755
|
+
}, o = k(e, "addCommands", r);
|
|
756
|
+
return o ? {
|
|
757
|
+
...t,
|
|
758
|
+
...o()
|
|
759
|
+
} : t;
|
|
760
|
+
}, {});
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Get all registered Prosemirror plugins from the extensions.
|
|
764
|
+
* @returns An array of Prosemirror plugins
|
|
765
|
+
*/
|
|
766
|
+
get plugins() {
|
|
767
|
+
const { editor: t } = this, e = R.sort([...this.extensions].reverse()), r = [], o = [], s = e.map((i) => {
|
|
768
|
+
const c = {
|
|
769
|
+
name: i.name,
|
|
770
|
+
options: i.options,
|
|
771
|
+
storage: i.storage,
|
|
772
|
+
editor: t,
|
|
773
|
+
type: rt(i.name, this.schema)
|
|
774
|
+
}, a = [], l = k(i, "addKeyboardShortcuts", c);
|
|
775
|
+
let u = {};
|
|
776
|
+
if (i.type === "mark" && k(i, "exitable", c) && (u.ArrowRight = () => U.handleExit({ editor: t, mark: i })), l) {
|
|
777
|
+
const h = Object.fromEntries(Object.entries(l()).map(([g, y]) => [g, () => y({ editor: t })]));
|
|
778
|
+
u = { ...u, ...h };
|
|
779
|
+
}
|
|
780
|
+
const d = _t(u);
|
|
781
|
+
a.push(d);
|
|
782
|
+
const f = k(i, "addInputRules", c);
|
|
783
|
+
bt(i, t.options.enableInputRules) && f && r.push(...f());
|
|
784
|
+
const p = k(i, "addPasteRules", c);
|
|
785
|
+
bt(i, t.options.enablePasteRules) && p && o.push(...p());
|
|
786
|
+
const m = k(i, "addProseMirrorPlugins", c);
|
|
787
|
+
if (m) {
|
|
788
|
+
const h = m();
|
|
789
|
+
a.push(...h);
|
|
790
|
+
}
|
|
791
|
+
return a;
|
|
792
|
+
}).flat();
|
|
793
|
+
return [
|
|
794
|
+
xe({
|
|
795
|
+
editor: t,
|
|
796
|
+
rules: r
|
|
797
|
+
}),
|
|
798
|
+
...$e({
|
|
799
|
+
editor: t,
|
|
800
|
+
rules: o
|
|
801
|
+
}),
|
|
802
|
+
...s
|
|
803
|
+
];
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Get all attributes from the extensions.
|
|
807
|
+
* @returns An array of attributes
|
|
808
|
+
*/
|
|
809
|
+
get attributes() {
|
|
810
|
+
return Tt(this.extensions);
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Get all node views from the extensions.
|
|
814
|
+
* @returns An object with all node views where the key is the node name and the value is the node view function
|
|
815
|
+
*/
|
|
816
|
+
get nodeViews() {
|
|
817
|
+
const { editor: t } = this, { nodeExtensions: e } = X(this.extensions);
|
|
818
|
+
return Object.fromEntries(e.filter((r) => !!k(r, "addNodeView")).map((r) => {
|
|
819
|
+
const o = this.attributes.filter((a) => a.type === r.name), s = {
|
|
820
|
+
name: r.name,
|
|
821
|
+
options: r.options,
|
|
822
|
+
storage: r.storage,
|
|
823
|
+
editor: t,
|
|
824
|
+
type: S(r.name, this.schema)
|
|
825
|
+
}, i = k(r, "addNodeView", s);
|
|
826
|
+
if (!i)
|
|
827
|
+
return [];
|
|
828
|
+
const c = (a, l, u, d, f) => {
|
|
829
|
+
const p = it(a, o);
|
|
830
|
+
return i()({
|
|
831
|
+
// pass-through
|
|
832
|
+
node: a,
|
|
833
|
+
view: l,
|
|
834
|
+
getPos: u,
|
|
835
|
+
decorations: d,
|
|
836
|
+
innerDecorations: f,
|
|
837
|
+
// tiptap-specific
|
|
838
|
+
editor: t,
|
|
839
|
+
extension: r,
|
|
840
|
+
HTMLAttributes: p
|
|
841
|
+
});
|
|
842
|
+
};
|
|
843
|
+
return [r.name, c];
|
|
844
|
+
}));
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Go through all extensions, create extension storages & setup marks
|
|
848
|
+
* & bind editor event listener.
|
|
849
|
+
*/
|
|
850
|
+
setupExtensions() {
|
|
851
|
+
this.extensions.forEach((t) => {
|
|
852
|
+
var e;
|
|
853
|
+
this.editor.extensionStorage[t.name] = t.storage;
|
|
854
|
+
const r = {
|
|
855
|
+
name: t.name,
|
|
856
|
+
options: t.options,
|
|
857
|
+
storage: t.storage,
|
|
858
|
+
editor: this.editor,
|
|
859
|
+
type: rt(t.name, this.schema)
|
|
860
|
+
};
|
|
861
|
+
t.type === "mark" && (!((e = b(k(t, "keepOnSplit", r))) !== null && e !== void 0) || e) && this.splittableMarks.push(t.name);
|
|
862
|
+
const o = k(t, "onBeforeCreate", r), s = k(t, "onCreate", r), i = k(t, "onUpdate", r), c = k(t, "onSelectionUpdate", r), a = k(t, "onTransaction", r), l = k(t, "onFocus", r), u = k(t, "onBlur", r), d = k(t, "onDestroy", r);
|
|
863
|
+
o && this.editor.on("beforeCreate", o), s && this.editor.on("create", s), i && this.editor.on("update", i), c && this.editor.on("selectionUpdate", c), a && this.editor.on("transaction", a), l && this.editor.on("focus", l), u && this.editor.on("blur", u), d && this.editor.on("destroy", d);
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
class C {
|
|
868
|
+
constructor(t = {}) {
|
|
869
|
+
this.type = "extension", this.name = "extension", this.parent = null, this.child = null, this.config = {
|
|
870
|
+
name: this.name,
|
|
871
|
+
defaultOptions: {}
|
|
872
|
+
}, this.config = {
|
|
873
|
+
...this.config,
|
|
874
|
+
...t
|
|
875
|
+
}, this.name = this.config.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(k(this, "addOptions", {
|
|
876
|
+
name: this.name
|
|
877
|
+
}))), this.storage = b(k(this, "addStorage", {
|
|
878
|
+
name: this.name,
|
|
879
|
+
options: this.options
|
|
880
|
+
})) || {};
|
|
881
|
+
}
|
|
882
|
+
static create(t = {}) {
|
|
883
|
+
return new C(t);
|
|
884
|
+
}
|
|
885
|
+
configure(t = {}) {
|
|
886
|
+
const e = this.extend({
|
|
887
|
+
...this.config,
|
|
888
|
+
addOptions: () => tt(this.options, t)
|
|
889
|
+
});
|
|
890
|
+
return e.name = this.name, e.parent = this.parent, e;
|
|
891
|
+
}
|
|
892
|
+
extend(t = {}) {
|
|
893
|
+
const e = new C({ ...this.config, ...t });
|
|
894
|
+
return e.parent = this, this.child = e, e.name = t.name ? t.name : e.parent.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`), e.options = b(k(e, "addOptions", {
|
|
895
|
+
name: e.name
|
|
896
|
+
})), e.storage = b(k(e, "addStorage", {
|
|
897
|
+
name: e.name,
|
|
898
|
+
options: e.options
|
|
899
|
+
})), e;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
function Pt(n, t, e) {
|
|
903
|
+
const { from: r, to: o } = t, { blockSeparator: s = `
|
|
904
|
+
|
|
905
|
+
`, textSerializers: i = {} } = e || {};
|
|
906
|
+
let c = "";
|
|
907
|
+
return n.nodesBetween(r, o, (a, l, u, d) => {
|
|
908
|
+
var f;
|
|
909
|
+
a.isBlock && l > r && (c += s);
|
|
910
|
+
const p = i == null ? void 0 : i[a.type.name];
|
|
911
|
+
if (p)
|
|
912
|
+
return u && (c += p({
|
|
913
|
+
node: a,
|
|
914
|
+
pos: l,
|
|
915
|
+
parent: u,
|
|
916
|
+
index: d,
|
|
917
|
+
range: t
|
|
918
|
+
})), !1;
|
|
919
|
+
a.isText && (c += (f = a == null ? void 0 : a.text) === null || f === void 0 ? void 0 : f.slice(Math.max(r, l) - l, o - l));
|
|
920
|
+
}), c;
|
|
921
|
+
}
|
|
922
|
+
function Ot(n) {
|
|
923
|
+
return Object.fromEntries(Object.entries(n.nodes).filter(([, t]) => t.spec.toText).map(([t, e]) => [t, e.spec.toText]));
|
|
924
|
+
}
|
|
925
|
+
const Ne = C.create({
|
|
926
|
+
name: "clipboardTextSerializer",
|
|
927
|
+
addOptions() {
|
|
928
|
+
return {
|
|
929
|
+
blockSeparator: void 0
|
|
930
|
+
};
|
|
931
|
+
},
|
|
932
|
+
addProseMirrorPlugins() {
|
|
933
|
+
return [
|
|
934
|
+
new I({
|
|
935
|
+
key: new j("clipboardTextSerializer"),
|
|
936
|
+
props: {
|
|
937
|
+
clipboardTextSerializer: () => {
|
|
938
|
+
const { editor: n } = this, { state: t, schema: e } = n, { doc: r, selection: o } = t, { ranges: s } = o, i = Math.min(...s.map((u) => u.$from.pos)), c = Math.max(...s.map((u) => u.$to.pos)), a = Ot(e);
|
|
939
|
+
return Pt(r, { from: i, to: c }, {
|
|
940
|
+
...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
|
|
941
|
+
textSerializers: a
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
})
|
|
946
|
+
];
|
|
947
|
+
}
|
|
948
|
+
}), je = () => ({ editor: n, view: t }) => (requestAnimationFrame(() => {
|
|
949
|
+
var e;
|
|
950
|
+
n.isDestroyed || (t.dom.blur(), (e = window == null ? void 0 : window.getSelection()) === null || e === void 0 || e.removeAllRanges());
|
|
951
|
+
}), !0), Re = (n = !1) => ({ commands: t }) => t.setContent("", n), Fe = () => ({ state: n, tr: t, dispatch: e }) => {
|
|
952
|
+
const { selection: r } = t, { ranges: o } = r;
|
|
953
|
+
return e && o.forEach(({ $from: s, $to: i }) => {
|
|
954
|
+
n.doc.nodesBetween(s.pos, i.pos, (c, a) => {
|
|
955
|
+
if (c.type.isText)
|
|
956
|
+
return;
|
|
957
|
+
const { doc: l, mapping: u } = t, d = l.resolve(u.map(a)), f = l.resolve(u.map(a + c.nodeSize)), p = d.blockRange(f);
|
|
958
|
+
if (!p)
|
|
959
|
+
return;
|
|
960
|
+
const m = Gt(p);
|
|
961
|
+
if (c.type.isTextblock) {
|
|
962
|
+
const { defaultType: h } = d.parent.contentMatchAt(d.index());
|
|
963
|
+
t.setNodeMarkup(p.start, h);
|
|
964
|
+
}
|
|
965
|
+
(m || m === 0) && t.lift(p, m);
|
|
966
|
+
});
|
|
967
|
+
}), !0;
|
|
968
|
+
}, De = (n) => (t) => n(t), Le = () => ({ state: n, dispatch: t }) => he(n, t), ze = (n, t) => ({ editor: e, tr: r }) => {
|
|
969
|
+
const { state: o } = e, s = o.doc.slice(n.from, n.to);
|
|
970
|
+
r.deleteRange(n.from, n.to);
|
|
971
|
+
const i = r.mapping.map(t);
|
|
972
|
+
return r.insert(i, s.content), r.setSelection(new P(r.doc.resolve(Math.max(i - 1, 0)))), !0;
|
|
973
|
+
}, He = () => ({ tr: n, dispatch: t }) => {
|
|
974
|
+
const { selection: e } = n, r = e.$anchor.node();
|
|
975
|
+
if (r.content.size > 0)
|
|
976
|
+
return !1;
|
|
977
|
+
const o = n.selection.$anchor;
|
|
978
|
+
for (let s = o.depth; s > 0; s -= 1)
|
|
979
|
+
if (o.node(s).type === r.type) {
|
|
980
|
+
if (t) {
|
|
981
|
+
const c = o.before(s), a = o.after(s);
|
|
982
|
+
n.delete(c, a).scrollIntoView();
|
|
983
|
+
}
|
|
984
|
+
return !0;
|
|
985
|
+
}
|
|
986
|
+
return !1;
|
|
987
|
+
}, _e = (n) => ({ tr: t, state: e, dispatch: r }) => {
|
|
988
|
+
const o = S(n, e.schema), s = t.selection.$anchor;
|
|
989
|
+
for (let i = s.depth; i > 0; i -= 1)
|
|
990
|
+
if (s.node(i).type === o) {
|
|
991
|
+
if (r) {
|
|
992
|
+
const a = s.before(i), l = s.after(i);
|
|
993
|
+
t.delete(a, l).scrollIntoView();
|
|
994
|
+
}
|
|
995
|
+
return !0;
|
|
996
|
+
}
|
|
997
|
+
return !1;
|
|
998
|
+
}, We = (n) => ({ tr: t, dispatch: e }) => {
|
|
999
|
+
const { from: r, to: o } = n;
|
|
1000
|
+
return e && t.delete(r, o), !0;
|
|
1001
|
+
}, Ve = () => ({ state: n, dispatch: t }) => pe(n, t), Ke = () => ({ commands: n }) => n.keyboardShortcut("Enter"), Ue = () => ({ state: n, dispatch: t }) => fe(n, t);
|
|
1002
|
+
function q(n, t, e = { strict: !0 }) {
|
|
1003
|
+
const r = Object.keys(t);
|
|
1004
|
+
return r.length ? r.every((o) => e.strict ? t[o] === n[o] : ft(t[o]) ? t[o].test(n[o]) : t[o] === n[o]) : !0;
|
|
1005
|
+
}
|
|
1006
|
+
function It(n, t, e = {}) {
|
|
1007
|
+
return n.find((r) => r.type === t && q(
|
|
1008
|
+
// Only check equality for the attributes that are provided
|
|
1009
|
+
Object.fromEntries(Object.keys(e).map((o) => [o, r.attrs[o]])),
|
|
1010
|
+
e
|
|
1011
|
+
));
|
|
1012
|
+
}
|
|
1013
|
+
function vt(n, t, e = {}) {
|
|
1014
|
+
return !!It(n, t, e);
|
|
1015
|
+
}
|
|
1016
|
+
function pt(n, t, e) {
|
|
1017
|
+
var r;
|
|
1018
|
+
if (!n || !t)
|
|
1019
|
+
return;
|
|
1020
|
+
let o = n.parent.childAfter(n.parentOffset);
|
|
1021
|
+
if ((!o.node || !o.node.marks.some((u) => u.type === t)) && (o = n.parent.childBefore(n.parentOffset)), !o.node || !o.node.marks.some((u) => u.type === t) || (e = e || ((r = o.node.marks[0]) === null || r === void 0 ? void 0 : r.attrs), !It([...o.node.marks], t, e)))
|
|
1022
|
+
return;
|
|
1023
|
+
let i = o.index, c = n.start() + o.offset, a = i + 1, l = c + o.node.nodeSize;
|
|
1024
|
+
for (; i > 0 && vt([...n.parent.child(i - 1).marks], t, e); )
|
|
1025
|
+
i -= 1, c -= n.parent.child(i).nodeSize;
|
|
1026
|
+
for (; a < n.parent.childCount && vt([...n.parent.child(a).marks], t, e); )
|
|
1027
|
+
l += n.parent.child(a).nodeSize, a += 1;
|
|
1028
|
+
return {
|
|
1029
|
+
from: c,
|
|
1030
|
+
to: l
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
function B(n, t) {
|
|
1034
|
+
if (typeof n == "string") {
|
|
1035
|
+
if (!t.marks[n])
|
|
1036
|
+
throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);
|
|
1037
|
+
return t.marks[n];
|
|
1038
|
+
}
|
|
1039
|
+
return n;
|
|
1040
|
+
}
|
|
1041
|
+
const qe = (n, t = {}) => ({ tr: e, state: r, dispatch: o }) => {
|
|
1042
|
+
const s = B(n, r.schema), { doc: i, selection: c } = e, { $from: a, from: l, to: u } = c;
|
|
1043
|
+
if (o) {
|
|
1044
|
+
const d = pt(a, s, t);
|
|
1045
|
+
if (d && d.from <= l && d.to >= u) {
|
|
1046
|
+
const f = P.create(i, d.from, d.to);
|
|
1047
|
+
e.setSelection(f);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
return !0;
|
|
1051
|
+
}, Ge = (n) => (t) => {
|
|
1052
|
+
const e = typeof n == "function" ? n(t) : n;
|
|
1053
|
+
for (let r = 0; r < e.length; r += 1)
|
|
1054
|
+
if (e[r](t))
|
|
1055
|
+
return !0;
|
|
1056
|
+
return !1;
|
|
1057
|
+
};
|
|
1058
|
+
function $t(n) {
|
|
1059
|
+
return n instanceof P;
|
|
1060
|
+
}
|
|
1061
|
+
function O(n = 0, t = 0, e = 0) {
|
|
1062
|
+
return Math.min(Math.max(n, t), e);
|
|
1063
|
+
}
|
|
1064
|
+
function Bt(n, t = null) {
|
|
1065
|
+
if (!t)
|
|
1066
|
+
return null;
|
|
1067
|
+
const e = F.atStart(n), r = F.atEnd(n);
|
|
1068
|
+
if (t === "start" || t === !0)
|
|
1069
|
+
return e;
|
|
1070
|
+
if (t === "end")
|
|
1071
|
+
return r;
|
|
1072
|
+
const o = e.from, s = r.to;
|
|
1073
|
+
return t === "all" ? P.create(n, O(0, o, s), O(n.content.size, o, s)) : P.create(n, O(t, o, s), O(t, o, s));
|
|
1074
|
+
}
|
|
1075
|
+
function wt() {
|
|
1076
|
+
return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
|
|
1077
|
+
}
|
|
1078
|
+
function G() {
|
|
1079
|
+
return [
|
|
1080
|
+
"iPad Simulator",
|
|
1081
|
+
"iPhone Simulator",
|
|
1082
|
+
"iPod Simulator",
|
|
1083
|
+
"iPad",
|
|
1084
|
+
"iPhone",
|
|
1085
|
+
"iPod"
|
|
1086
|
+
].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
1087
|
+
}
|
|
1088
|
+
function Je() {
|
|
1089
|
+
return typeof navigator < "u" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1;
|
|
1090
|
+
}
|
|
1091
|
+
const Ye = (n = null, t = {}) => ({ editor: e, view: r, tr: o, dispatch: s }) => {
|
|
1092
|
+
t = {
|
|
1093
|
+
scrollIntoView: !0,
|
|
1094
|
+
...t
|
|
1095
|
+
};
|
|
1096
|
+
const i = () => {
|
|
1097
|
+
(G() || wt()) && r.dom.focus(), requestAnimationFrame(() => {
|
|
1098
|
+
e.isDestroyed || (r.focus(), Je() && !G() && !wt() && r.dom.focus({ preventScroll: !0 }));
|
|
1099
|
+
});
|
|
1100
|
+
};
|
|
1101
|
+
if (r.hasFocus() && n === null || n === !1)
|
|
1102
|
+
return !0;
|
|
1103
|
+
if (s && n === null && !$t(e.state.selection))
|
|
1104
|
+
return i(), !0;
|
|
1105
|
+
const c = Bt(o.doc, n) || e.state.selection, a = e.state.selection.eq(c);
|
|
1106
|
+
return s && (a || o.setSelection(c), a && o.storedMarks && o.setStoredMarks(o.storedMarks), i()), !0;
|
|
1107
|
+
}, Qe = (n, t) => (e) => n.every((r, o) => t(r, { ...e, index: o })), Xe = (n, t) => ({ tr: e, commands: r }) => r.insertContentAt({ from: e.selection.from, to: e.selection.to }, n, t), Nt = (n) => {
|
|
1108
|
+
const t = n.childNodes;
|
|
1109
|
+
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
1110
|
+
const r = t[e];
|
|
1111
|
+
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? n.removeChild(r) : r.nodeType === 1 && Nt(r);
|
|
1112
|
+
}
|
|
1113
|
+
return n;
|
|
1114
|
+
};
|
|
1115
|
+
function W(n) {
|
|
1116
|
+
const t = `<body>${n}</body>`, e = new window.DOMParser().parseFromString(t, "text/html").body;
|
|
1117
|
+
return Nt(e);
|
|
1118
|
+
}
|
|
1119
|
+
function D(n, t, e) {
|
|
1120
|
+
if (n instanceof Vt || n instanceof $)
|
|
1121
|
+
return n;
|
|
1122
|
+
e = {
|
|
1123
|
+
slice: !0,
|
|
1124
|
+
parseOptions: {},
|
|
1125
|
+
...e
|
|
1126
|
+
};
|
|
1127
|
+
const r = typeof n == "object" && n !== null, o = typeof n == "string";
|
|
1128
|
+
if (r)
|
|
1129
|
+
try {
|
|
1130
|
+
if (Array.isArray(n) && n.length > 0)
|
|
1131
|
+
return $.fromArray(n.map((c) => t.nodeFromJSON(c)));
|
|
1132
|
+
const i = t.nodeFromJSON(n);
|
|
1133
|
+
return e.errorOnInvalidContent && i.check(), i;
|
|
1134
|
+
} catch (s) {
|
|
1135
|
+
if (e.errorOnInvalidContent)
|
|
1136
|
+
throw new Error("[tiptap error]: Invalid JSON content", { cause: s });
|
|
1137
|
+
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", n, "Error:", s), D("", t, e);
|
|
1138
|
+
}
|
|
1139
|
+
if (o) {
|
|
1140
|
+
if (e.errorOnInvalidContent) {
|
|
1141
|
+
let i = !1, c = "";
|
|
1142
|
+
const a = new xt({
|
|
1143
|
+
topNode: t.spec.topNode,
|
|
1144
|
+
marks: t.spec.marks,
|
|
1145
|
+
// Prosemirror's schemas are executed such that: the last to execute, matches last
|
|
1146
|
+
// This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
|
|
1147
|
+
nodes: t.spec.nodes.append({
|
|
1148
|
+
__tiptap__private__unknown__catch__all__node: {
|
|
1149
|
+
content: "inline*",
|
|
1150
|
+
group: "block",
|
|
1151
|
+
parseDOM: [
|
|
1152
|
+
{
|
|
1153
|
+
tag: "*",
|
|
1154
|
+
getAttrs: (l) => (i = !0, c = typeof l == "string" ? l : l.outerHTML, null)
|
|
1155
|
+
}
|
|
1156
|
+
]
|
|
1157
|
+
}
|
|
1158
|
+
})
|
|
1159
|
+
});
|
|
1160
|
+
if (e.slice ? nt.fromSchema(a).parseSlice(W(n), e.parseOptions) : nt.fromSchema(a).parse(W(n), e.parseOptions), e.errorOnInvalidContent && i)
|
|
1161
|
+
throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${c}`) });
|
|
1162
|
+
}
|
|
1163
|
+
const s = nt.fromSchema(t);
|
|
1164
|
+
return e.slice ? s.parseSlice(W(n), e.parseOptions).content : s.parse(W(n), e.parseOptions);
|
|
1165
|
+
}
|
|
1166
|
+
return D("", t, e);
|
|
1167
|
+
}
|
|
1168
|
+
function Ze(n, t, e) {
|
|
1169
|
+
const r = n.steps.length - 1;
|
|
1170
|
+
if (r < t)
|
|
1171
|
+
return;
|
|
1172
|
+
const o = n.steps[r];
|
|
1173
|
+
if (!(o instanceof Jt || o instanceof Yt))
|
|
1174
|
+
return;
|
|
1175
|
+
const s = n.mapping.maps[r];
|
|
1176
|
+
let i = 0;
|
|
1177
|
+
s.forEach((c, a, l, u) => {
|
|
1178
|
+
i === 0 && (i = u);
|
|
1179
|
+
}), n.setSelection(F.near(n.doc.resolve(i), e));
|
|
1180
|
+
}
|
|
1181
|
+
const tn = (n) => !("type" in n), en = (n, t, e) => ({ tr: r, dispatch: o, editor: s }) => {
|
|
1182
|
+
var i;
|
|
1183
|
+
if (o) {
|
|
1184
|
+
e = {
|
|
1185
|
+
parseOptions: s.options.parseOptions,
|
|
1186
|
+
updateSelection: !0,
|
|
1187
|
+
applyInputRules: !1,
|
|
1188
|
+
applyPasteRules: !1,
|
|
1189
|
+
...e
|
|
1190
|
+
};
|
|
1191
|
+
let c;
|
|
1192
|
+
const a = (g) => {
|
|
1193
|
+
s.emit("contentError", {
|
|
1194
|
+
editor: s,
|
|
1195
|
+
error: g,
|
|
1196
|
+
disableCollaboration: () => {
|
|
1197
|
+
s.storage.collaboration && (s.storage.collaboration.isDisabled = !0);
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
}, l = {
|
|
1201
|
+
preserveWhitespace: "full",
|
|
1202
|
+
...e.parseOptions
|
|
1203
|
+
};
|
|
1204
|
+
if (!e.errorOnInvalidContent && !s.options.enableContentCheck && s.options.emitContentError)
|
|
1205
|
+
try {
|
|
1206
|
+
D(t, s.schema, {
|
|
1207
|
+
parseOptions: l,
|
|
1208
|
+
errorOnInvalidContent: !0
|
|
1209
|
+
});
|
|
1210
|
+
} catch (g) {
|
|
1211
|
+
a(g);
|
|
1212
|
+
}
|
|
1213
|
+
try {
|
|
1214
|
+
c = D(t, s.schema, {
|
|
1215
|
+
parseOptions: l,
|
|
1216
|
+
errorOnInvalidContent: (i = e.errorOnInvalidContent) !== null && i !== void 0 ? i : s.options.enableContentCheck
|
|
1217
|
+
});
|
|
1218
|
+
} catch (g) {
|
|
1219
|
+
return a(g), !1;
|
|
1220
|
+
}
|
|
1221
|
+
let { from: u, to: d } = typeof n == "number" ? { from: n, to: n } : { from: n.from, to: n.to }, f = !0, p = !0;
|
|
1222
|
+
if ((tn(c) ? c : [c]).forEach((g) => {
|
|
1223
|
+
g.check(), f = f ? g.isText && g.marks.length === 0 : !1, p = p ? g.isBlock : !1;
|
|
1224
|
+
}), u === d && p) {
|
|
1225
|
+
const { parent: g } = r.doc.resolve(u);
|
|
1226
|
+
g.isTextblock && !g.type.spec.code && !g.childCount && (u -= 1, d += 1);
|
|
1227
|
+
}
|
|
1228
|
+
let h;
|
|
1229
|
+
if (f) {
|
|
1230
|
+
if (Array.isArray(t))
|
|
1231
|
+
h = t.map((g) => g.text || "").join("");
|
|
1232
|
+
else if (t instanceof $) {
|
|
1233
|
+
let g = "";
|
|
1234
|
+
t.forEach((y) => {
|
|
1235
|
+
y.text && (g += y.text);
|
|
1236
|
+
}), h = g;
|
|
1237
|
+
} else typeof t == "object" && t && t.text ? h = t.text : h = t;
|
|
1238
|
+
r.insertText(h, u, d);
|
|
1239
|
+
} else
|
|
1240
|
+
h = c, r.replaceWith(u, d, h);
|
|
1241
|
+
e.updateSelection && Ze(r, r.steps.length - 1, -1), e.applyInputRules && r.setMeta("applyInputRules", { from: u, text: h }), e.applyPasteRules && r.setMeta("applyPasteRules", { from: u, text: h });
|
|
1242
|
+
}
|
|
1243
|
+
return !0;
|
|
1244
|
+
}, nn = () => ({ state: n, dispatch: t }) => ie(n, t), rn = () => ({ state: n, dispatch: t }) => de(n, t), on = () => ({ state: n, dispatch: t }) => ue(n, t), sn = () => ({ state: n, dispatch: t }) => le(n, t), an = () => ({ state: n, dispatch: t, tr: e }) => {
|
|
1245
|
+
try {
|
|
1246
|
+
const r = Ct(n.doc, n.selection.$from.pos, -1);
|
|
1247
|
+
return r == null ? !1 : (e.join(r, 2), t && t(e), !0);
|
|
1248
|
+
} catch {
|
|
1249
|
+
return !1;
|
|
1250
|
+
}
|
|
1251
|
+
}, cn = () => ({ state: n, dispatch: t, tr: e }) => {
|
|
1252
|
+
try {
|
|
1253
|
+
const r = Ct(n.doc, n.selection.$from.pos, 1);
|
|
1254
|
+
return r == null ? !1 : (e.join(r, 2), t && t(e), !0);
|
|
1255
|
+
} catch {
|
|
1256
|
+
return !1;
|
|
1257
|
+
}
|
|
1258
|
+
}, ln = () => ({ state: n, dispatch: t }) => ce(n, t), dn = () => ({ state: n, dispatch: t }) => ae(n, t);
|
|
1259
|
+
function jt() {
|
|
1260
|
+
return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
|
|
1261
|
+
}
|
|
1262
|
+
function un(n) {
|
|
1263
|
+
const t = n.split(/-(?!$)/);
|
|
1264
|
+
let e = t[t.length - 1];
|
|
1265
|
+
e === "Space" && (e = " ");
|
|
1266
|
+
let r, o, s, i;
|
|
1267
|
+
for (let c = 0; c < t.length - 1; c += 1) {
|
|
1268
|
+
const a = t[c];
|
|
1269
|
+
if (/^(cmd|meta|m)$/i.test(a))
|
|
1270
|
+
i = !0;
|
|
1271
|
+
else if (/^a(lt)?$/i.test(a))
|
|
1272
|
+
r = !0;
|
|
1273
|
+
else if (/^(c|ctrl|control)$/i.test(a))
|
|
1274
|
+
o = !0;
|
|
1275
|
+
else if (/^s(hift)?$/i.test(a))
|
|
1276
|
+
s = !0;
|
|
1277
|
+
else if (/^mod$/i.test(a))
|
|
1278
|
+
G() || jt() ? i = !0 : o = !0;
|
|
1279
|
+
else
|
|
1280
|
+
throw new Error(`Unrecognized modifier name: ${a}`);
|
|
1281
|
+
}
|
|
1282
|
+
return r && (e = `Alt-${e}`), o && (e = `Ctrl-${e}`), i && (e = `Meta-${e}`), s && (e = `Shift-${e}`), e;
|
|
1283
|
+
}
|
|
1284
|
+
const fn = (n) => ({ editor: t, view: e, tr: r, dispatch: o }) => {
|
|
1285
|
+
const s = un(n).split(/-(?!$)/), i = s.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), c = new KeyboardEvent("keydown", {
|
|
1286
|
+
key: i === "Space" ? " " : i,
|
|
1287
|
+
altKey: s.includes("Alt"),
|
|
1288
|
+
ctrlKey: s.includes("Ctrl"),
|
|
1289
|
+
metaKey: s.includes("Meta"),
|
|
1290
|
+
shiftKey: s.includes("Shift"),
|
|
1291
|
+
bubbles: !0,
|
|
1292
|
+
cancelable: !0
|
|
1293
|
+
}), a = t.captureTransaction(() => {
|
|
1294
|
+
e.someProp("handleKeyDown", (l) => l(e, c));
|
|
1295
|
+
});
|
|
1296
|
+
return a == null || a.steps.forEach((l) => {
|
|
1297
|
+
const u = l.map(r.mapping);
|
|
1298
|
+
u && o && r.maybeStep(u);
|
|
1299
|
+
}), !0;
|
|
1300
|
+
};
|
|
1301
|
+
function L(n, t, e = {}) {
|
|
1302
|
+
const { from: r, to: o, empty: s } = n.selection, i = t ? S(t, n.schema) : null, c = [];
|
|
1303
|
+
n.doc.nodesBetween(r, o, (d, f) => {
|
|
1304
|
+
if (d.isText)
|
|
1305
|
+
return;
|
|
1306
|
+
const p = Math.max(r, f), m = Math.min(o, f + d.nodeSize);
|
|
1307
|
+
c.push({
|
|
1308
|
+
node: d,
|
|
1309
|
+
from: p,
|
|
1310
|
+
to: m
|
|
1311
|
+
});
|
|
1312
|
+
});
|
|
1313
|
+
const a = o - r, l = c.filter((d) => i ? i.name === d.node.type.name : !0).filter((d) => q(d.node.attrs, e, { strict: !1 }));
|
|
1314
|
+
return s ? !!l.length : l.reduce((d, f) => d + f.to - f.from, 0) >= a;
|
|
1315
|
+
}
|
|
1316
|
+
const pn = (n, t = {}) => ({ state: e, dispatch: r }) => {
|
|
1317
|
+
const o = S(n, e.schema);
|
|
1318
|
+
return L(e, o, t) ? se(e, r) : !1;
|
|
1319
|
+
}, hn = () => ({ state: n, dispatch: t }) => oe(n, t), mn = (n) => ({ state: t, dispatch: e }) => {
|
|
1320
|
+
const r = S(n, t.schema);
|
|
1321
|
+
return ye(r)(t, e);
|
|
1322
|
+
}, gn = () => ({ state: n, dispatch: t }) => re(n, t);
|
|
1323
|
+
function et(n, t) {
|
|
1324
|
+
return t.nodes[n] ? "node" : t.marks[n] ? "mark" : null;
|
|
1325
|
+
}
|
|
1326
|
+
function Mt(n, t) {
|
|
1327
|
+
const e = typeof t == "string" ? [t] : t;
|
|
1328
|
+
return Object.keys(n).reduce((r, o) => (e.includes(o) || (r[o] = n[o]), r), {});
|
|
1329
|
+
}
|
|
1330
|
+
const yn = (n, t) => ({ tr: e, state: r, dispatch: o }) => {
|
|
1331
|
+
let s = null, i = null;
|
|
1332
|
+
const c = et(typeof n == "string" ? n : n.name, r.schema);
|
|
1333
|
+
return c ? (c === "node" && (s = S(n, r.schema)), c === "mark" && (i = B(n, r.schema)), o && e.selection.ranges.forEach((a) => {
|
|
1334
|
+
r.doc.nodesBetween(a.$from.pos, a.$to.pos, (l, u) => {
|
|
1335
|
+
s && s === l.type && e.setNodeMarkup(u, void 0, Mt(l.attrs, t)), i && l.marks.length && l.marks.forEach((d) => {
|
|
1336
|
+
i === d.type && e.addMark(u, u + l.nodeSize, i.create(Mt(d.attrs, t)));
|
|
1337
|
+
});
|
|
1338
|
+
});
|
|
1339
|
+
}), !0) : !1;
|
|
1340
|
+
}, kn = () => ({ tr: n, dispatch: t }) => (t && n.scrollIntoView(), !0), bn = () => ({ tr: n, dispatch: t }) => {
|
|
1341
|
+
if (t) {
|
|
1342
|
+
const e = new zt(n.doc);
|
|
1343
|
+
n.setSelection(e);
|
|
1344
|
+
}
|
|
1345
|
+
return !0;
|
|
1346
|
+
}, vn = () => ({ state: n, dispatch: t }) => ne(n, t), wn = () => ({ state: n, dispatch: t }) => ee(n, t), Mn = () => ({ state: n, dispatch: t }) => te(n, t), Sn = () => ({ state: n, dispatch: t }) => Zt(n, t), En = () => ({ state: n, dispatch: t }) => Xt(n, t);
|
|
1347
|
+
function at(n, t, e = {}, r = {}) {
|
|
1348
|
+
return D(n, t, {
|
|
1349
|
+
slice: !1,
|
|
1350
|
+
parseOptions: e,
|
|
1351
|
+
errorOnInvalidContent: r.errorOnInvalidContent
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
const xn = (n, t = !1, e = {}, r = {}) => ({ editor: o, tr: s, dispatch: i, commands: c }) => {
|
|
1355
|
+
var a, l;
|
|
1356
|
+
const { doc: u } = s;
|
|
1357
|
+
if (e.preserveWhitespace !== "full") {
|
|
1358
|
+
const d = at(n, o.schema, e, {
|
|
1359
|
+
errorOnInvalidContent: (a = r.errorOnInvalidContent) !== null && a !== void 0 ? a : o.options.enableContentCheck
|
|
1360
|
+
});
|
|
1361
|
+
return i && s.replaceWith(0, u.content.size, d).setMeta("preventUpdate", !t), !0;
|
|
1362
|
+
}
|
|
1363
|
+
return i && s.setMeta("preventUpdate", !t), c.insertContentAt({ from: 0, to: u.content.size }, n, {
|
|
1364
|
+
parseOptions: e,
|
|
1365
|
+
errorOnInvalidContent: (l = r.errorOnInvalidContent) !== null && l !== void 0 ? l : o.options.enableContentCheck
|
|
1366
|
+
});
|
|
1367
|
+
};
|
|
1368
|
+
function Rt(n, t) {
|
|
1369
|
+
const e = B(t, n.schema), { from: r, to: o, empty: s } = n.selection, i = [];
|
|
1370
|
+
s ? (n.storedMarks && i.push(...n.storedMarks), i.push(...n.selection.$head.marks())) : n.doc.nodesBetween(r, o, (a) => {
|
|
1371
|
+
i.push(...a.marks);
|
|
1372
|
+
});
|
|
1373
|
+
const c = i.find((a) => a.type.name === e.name);
|
|
1374
|
+
return c ? { ...c.attrs } : {};
|
|
1375
|
+
}
|
|
1376
|
+
function yr(n, t) {
|
|
1377
|
+
const e = new qt(n);
|
|
1378
|
+
return t.forEach((r) => {
|
|
1379
|
+
r.steps.forEach((o) => {
|
|
1380
|
+
e.step(o);
|
|
1381
|
+
});
|
|
1382
|
+
}), e;
|
|
1383
|
+
}
|
|
1384
|
+
function Cn(n) {
|
|
1385
|
+
for (let t = 0; t < n.edgeCount; t += 1) {
|
|
1386
|
+
const { type: e } = n.edge(t);
|
|
1387
|
+
if (e.isTextblock && !e.hasRequiredAttrs())
|
|
1388
|
+
return e;
|
|
1389
|
+
}
|
|
1390
|
+
return null;
|
|
1391
|
+
}
|
|
1392
|
+
function kr(n, t, e) {
|
|
1393
|
+
const r = [];
|
|
1394
|
+
return n.nodesBetween(t.from, t.to, (o, s) => {
|
|
1395
|
+
e(o) && r.push({
|
|
1396
|
+
node: o,
|
|
1397
|
+
pos: s
|
|
1398
|
+
});
|
|
1399
|
+
}), r;
|
|
1400
|
+
}
|
|
1401
|
+
function Tn(n, t) {
|
|
1402
|
+
for (let e = n.depth; e > 0; e -= 1) {
|
|
1403
|
+
const r = n.node(e);
|
|
1404
|
+
if (t(r))
|
|
1405
|
+
return {
|
|
1406
|
+
pos: e > 0 ? n.before(e) : 0,
|
|
1407
|
+
start: n.start(e),
|
|
1408
|
+
depth: e,
|
|
1409
|
+
node: r
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
function ht(n) {
|
|
1414
|
+
return (t) => Tn(t.$from, n);
|
|
1415
|
+
}
|
|
1416
|
+
function An(n, t) {
|
|
1417
|
+
const e = {
|
|
1418
|
+
from: 0,
|
|
1419
|
+
to: n.content.size
|
|
1420
|
+
};
|
|
1421
|
+
return Pt(n, e, t);
|
|
1422
|
+
}
|
|
1423
|
+
function Pn(n, t) {
|
|
1424
|
+
const e = S(t, n.schema), { from: r, to: o } = n.selection, s = [];
|
|
1425
|
+
n.doc.nodesBetween(r, o, (c) => {
|
|
1426
|
+
s.push(c);
|
|
1427
|
+
});
|
|
1428
|
+
const i = s.reverse().find((c) => c.type.name === e.name);
|
|
1429
|
+
return i ? { ...i.attrs } : {};
|
|
1430
|
+
}
|
|
1431
|
+
function On(n, t) {
|
|
1432
|
+
const e = et(typeof t == "string" ? t : t.name, n.schema);
|
|
1433
|
+
return e === "node" ? Pn(n, t) : e === "mark" ? Rt(n, t) : {};
|
|
1434
|
+
}
|
|
1435
|
+
function In(n, t = JSON.stringify) {
|
|
1436
|
+
const e = {};
|
|
1437
|
+
return n.filter((r) => {
|
|
1438
|
+
const o = t(r);
|
|
1439
|
+
return Object.prototype.hasOwnProperty.call(e, o) ? !1 : e[o] = !0;
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
function $n(n) {
|
|
1443
|
+
const t = In(n);
|
|
1444
|
+
return t.length === 1 ? t : t.filter((e, r) => !t.filter((s, i) => i !== r).some((s) => e.oldRange.from >= s.oldRange.from && e.oldRange.to <= s.oldRange.to && e.newRange.from >= s.newRange.from && e.newRange.to <= s.newRange.to));
|
|
1445
|
+
}
|
|
1446
|
+
function br(n) {
|
|
1447
|
+
const { mapping: t, steps: e } = n, r = [];
|
|
1448
|
+
return t.maps.forEach((o, s) => {
|
|
1449
|
+
const i = [];
|
|
1450
|
+
if (o.ranges.length)
|
|
1451
|
+
o.forEach((c, a) => {
|
|
1452
|
+
i.push({ from: c, to: a });
|
|
1453
|
+
});
|
|
1454
|
+
else {
|
|
1455
|
+
const { from: c, to: a } = e[s];
|
|
1456
|
+
if (c === void 0 || a === void 0)
|
|
1457
|
+
return;
|
|
1458
|
+
i.push({ from: c, to: a });
|
|
1459
|
+
}
|
|
1460
|
+
i.forEach(({ from: c, to: a }) => {
|
|
1461
|
+
const l = t.slice(s).map(c, -1), u = t.slice(s).map(a), d = t.invert().map(l, -1), f = t.invert().map(u);
|
|
1462
|
+
r.push({
|
|
1463
|
+
oldRange: {
|
|
1464
|
+
from: d,
|
|
1465
|
+
to: f
|
|
1466
|
+
},
|
|
1467
|
+
newRange: {
|
|
1468
|
+
from: l,
|
|
1469
|
+
to: u
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
});
|
|
1473
|
+
}), $n(r);
|
|
1474
|
+
}
|
|
1475
|
+
function Ft(n, t, e) {
|
|
1476
|
+
const r = [];
|
|
1477
|
+
return n === t ? e.resolve(n).marks().forEach((o) => {
|
|
1478
|
+
const s = e.resolve(n), i = pt(s, o.type);
|
|
1479
|
+
i && r.push({
|
|
1480
|
+
mark: o,
|
|
1481
|
+
...i
|
|
1482
|
+
});
|
|
1483
|
+
}) : e.nodesBetween(n, t, (o, s) => {
|
|
1484
|
+
!o || (o == null ? void 0 : o.nodeSize) === void 0 || r.push(...o.marks.map((i) => ({
|
|
1485
|
+
from: s,
|
|
1486
|
+
to: s + o.nodeSize,
|
|
1487
|
+
mark: i
|
|
1488
|
+
})));
|
|
1489
|
+
}), r;
|
|
1490
|
+
}
|
|
1491
|
+
function K(n, t, e) {
|
|
1492
|
+
return Object.fromEntries(Object.entries(e).filter(([r]) => {
|
|
1493
|
+
const o = n.find((s) => s.type === t && s.name === r);
|
|
1494
|
+
return o ? o.attribute.keepOnSplit : !1;
|
|
1495
|
+
}));
|
|
1496
|
+
}
|
|
1497
|
+
function ct(n, t, e = {}) {
|
|
1498
|
+
const { empty: r, ranges: o } = n.selection, s = t ? B(t, n.schema) : null;
|
|
1499
|
+
if (r)
|
|
1500
|
+
return !!(n.storedMarks || n.selection.$from.marks()).filter((d) => s ? s.name === d.type.name : !0).find((d) => q(d.attrs, e, { strict: !1 }));
|
|
1501
|
+
let i = 0;
|
|
1502
|
+
const c = [];
|
|
1503
|
+
if (o.forEach(({ $from: d, $to: f }) => {
|
|
1504
|
+
const p = d.pos, m = f.pos;
|
|
1505
|
+
n.doc.nodesBetween(p, m, (h, g) => {
|
|
1506
|
+
if (!h.isText && !h.marks.length)
|
|
1507
|
+
return;
|
|
1508
|
+
const y = Math.max(p, g), v = Math.min(m, g + h.nodeSize), w = v - y;
|
|
1509
|
+
i += w, c.push(...h.marks.map((E) => ({
|
|
1510
|
+
mark: E,
|
|
1511
|
+
from: y,
|
|
1512
|
+
to: v
|
|
1513
|
+
})));
|
|
1514
|
+
});
|
|
1515
|
+
}), i === 0)
|
|
1516
|
+
return !1;
|
|
1517
|
+
const a = c.filter((d) => s ? s.name === d.mark.type.name : !0).filter((d) => q(d.mark.attrs, e, { strict: !1 })).reduce((d, f) => d + f.to - f.from, 0), l = c.filter((d) => s ? d.mark.type !== s && d.mark.type.excludes(s) : !0).reduce((d, f) => d + f.to - f.from, 0);
|
|
1518
|
+
return (a > 0 ? a + l : a) >= i;
|
|
1519
|
+
}
|
|
1520
|
+
function Bn(n, t, e = {}) {
|
|
1521
|
+
if (!t)
|
|
1522
|
+
return L(n, null, e) || ct(n, null, e);
|
|
1523
|
+
const r = et(t, n.schema);
|
|
1524
|
+
return r === "node" ? L(n, t, e) : r === "mark" ? ct(n, t, e) : !1;
|
|
1525
|
+
}
|
|
1526
|
+
function St(n, t) {
|
|
1527
|
+
const { nodeExtensions: e } = X(t), r = e.find((i) => i.name === n);
|
|
1528
|
+
if (!r)
|
|
1529
|
+
return !1;
|
|
1530
|
+
const o = {
|
|
1531
|
+
name: r.name,
|
|
1532
|
+
options: r.options,
|
|
1533
|
+
storage: r.storage
|
|
1534
|
+
}, s = b(k(r, "group", o));
|
|
1535
|
+
return typeof s != "string" ? !1 : s.split(" ").includes("list");
|
|
1536
|
+
}
|
|
1537
|
+
function mt(n, { checkChildren: t = !0, ignoreWhitespace: e = !1 } = {}) {
|
|
1538
|
+
var r;
|
|
1539
|
+
if (e) {
|
|
1540
|
+
if (n.type.name === "hardBreak")
|
|
1541
|
+
return !0;
|
|
1542
|
+
if (n.isText)
|
|
1543
|
+
return /^\s*$/m.test((r = n.text) !== null && r !== void 0 ? r : "");
|
|
1544
|
+
}
|
|
1545
|
+
if (n.isText)
|
|
1546
|
+
return !n.text;
|
|
1547
|
+
if (n.isAtom || n.isLeaf)
|
|
1548
|
+
return !1;
|
|
1549
|
+
if (n.content.childCount === 0)
|
|
1550
|
+
return !0;
|
|
1551
|
+
if (t) {
|
|
1552
|
+
let o = !0;
|
|
1553
|
+
return n.content.forEach((s) => {
|
|
1554
|
+
o !== !1 && (mt(s, { ignoreWhitespace: e, checkChildren: t }) || (o = !1));
|
|
1555
|
+
}), o;
|
|
1556
|
+
}
|
|
1557
|
+
return !1;
|
|
1558
|
+
}
|
|
1559
|
+
function vr(n) {
|
|
1560
|
+
return n instanceof J;
|
|
1561
|
+
}
|
|
1562
|
+
function wr(n, t, e) {
|
|
1563
|
+
const o = n.state.doc.content.size, s = O(t, 0, o), i = O(e, 0, o), c = n.coordsAtPos(s), a = n.coordsAtPos(i, -1), l = Math.min(c.top, a.top), u = Math.max(c.bottom, a.bottom), d = Math.min(c.left, a.left), f = Math.max(c.right, a.right), p = f - d, m = u - l, y = {
|
|
1564
|
+
top: l,
|
|
1565
|
+
bottom: u,
|
|
1566
|
+
left: d,
|
|
1567
|
+
right: f,
|
|
1568
|
+
width: p,
|
|
1569
|
+
height: m,
|
|
1570
|
+
x: d,
|
|
1571
|
+
y: l
|
|
1572
|
+
};
|
|
1573
|
+
return {
|
|
1574
|
+
...y,
|
|
1575
|
+
toJSON: () => y
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
function Nn(n, t, e) {
|
|
1579
|
+
var r;
|
|
1580
|
+
const { selection: o } = t;
|
|
1581
|
+
let s = null;
|
|
1582
|
+
if ($t(o) && (s = o.$cursor), s) {
|
|
1583
|
+
const c = (r = n.storedMarks) !== null && r !== void 0 ? r : s.marks();
|
|
1584
|
+
return !!e.isInSet(c) || !c.some((a) => a.type.excludes(e));
|
|
1585
|
+
}
|
|
1586
|
+
const { ranges: i } = o;
|
|
1587
|
+
return i.some(({ $from: c, $to: a }) => {
|
|
1588
|
+
let l = c.depth === 0 ? n.doc.inlineContent && n.doc.type.allowsMarkType(e) : !1;
|
|
1589
|
+
return n.doc.nodesBetween(c.pos, a.pos, (u, d, f) => {
|
|
1590
|
+
if (l)
|
|
1591
|
+
return !1;
|
|
1592
|
+
if (u.isInline) {
|
|
1593
|
+
const p = !f || f.type.allowsMarkType(e), m = !!e.isInSet(u.marks) || !u.marks.some((h) => h.type.excludes(e));
|
|
1594
|
+
l = p && m;
|
|
1595
|
+
}
|
|
1596
|
+
return !l;
|
|
1597
|
+
}), l;
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
const jn = (n, t = {}) => ({ tr: e, state: r, dispatch: o }) => {
|
|
1601
|
+
const { selection: s } = e, { empty: i, ranges: c } = s, a = B(n, r.schema);
|
|
1602
|
+
if (o)
|
|
1603
|
+
if (i) {
|
|
1604
|
+
const l = Rt(r, a);
|
|
1605
|
+
e.addStoredMark(a.create({
|
|
1606
|
+
...l,
|
|
1607
|
+
...t
|
|
1608
|
+
}));
|
|
1609
|
+
} else
|
|
1610
|
+
c.forEach((l) => {
|
|
1611
|
+
const u = l.$from.pos, d = l.$to.pos;
|
|
1612
|
+
r.doc.nodesBetween(u, d, (f, p) => {
|
|
1613
|
+
const m = Math.max(p, u), h = Math.min(p + f.nodeSize, d);
|
|
1614
|
+
f.marks.find((y) => y.type === a) ? f.marks.forEach((y) => {
|
|
1615
|
+
a === y.type && e.addMark(m, h, a.create({
|
|
1616
|
+
...y.attrs,
|
|
1617
|
+
...t
|
|
1618
|
+
}));
|
|
1619
|
+
}) : e.addMark(m, h, a.create(t));
|
|
1620
|
+
});
|
|
1621
|
+
});
|
|
1622
|
+
return Nn(r, e, a);
|
|
1623
|
+
}, Rn = (n, t) => ({ tr: e }) => (e.setMeta(n, t), !0), Fn = (n, t = {}) => ({ state: e, dispatch: r, chain: o }) => {
|
|
1624
|
+
const s = S(n, e.schema);
|
|
1625
|
+
let i;
|
|
1626
|
+
return e.selection.$anchor.sameParent(e.selection.$head) && (i = e.selection.$anchor.parent.attrs), s.isTextblock ? o().command(({ commands: c }) => gt(s, { ...i, ...t })(e) ? !0 : c.clearNodes()).command(({ state: c }) => gt(s, { ...i, ...t })(c, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
|
|
1627
|
+
}, Dn = (n) => ({ tr: t, dispatch: e }) => {
|
|
1628
|
+
if (e) {
|
|
1629
|
+
const { doc: r } = t, o = O(n, 0, r.content.size), s = J.create(r, o);
|
|
1630
|
+
t.setSelection(s);
|
|
1631
|
+
}
|
|
1632
|
+
return !0;
|
|
1633
|
+
}, Ln = (n) => ({ tr: t, dispatch: e }) => {
|
|
1634
|
+
if (e) {
|
|
1635
|
+
const { doc: r } = t, { from: o, to: s } = typeof n == "number" ? { from: n, to: n } : n, i = P.atStart(r).from, c = P.atEnd(r).to, a = O(o, i, c), l = O(s, i, c), u = P.create(r, a, l);
|
|
1636
|
+
t.setSelection(u);
|
|
1637
|
+
}
|
|
1638
|
+
return !0;
|
|
1639
|
+
}, zn = (n) => ({ state: t, dispatch: e }) => {
|
|
1640
|
+
const r = S(n, t.schema);
|
|
1641
|
+
return ge(r)(t, e);
|
|
1642
|
+
};
|
|
1643
|
+
function Et(n, t) {
|
|
1644
|
+
const e = n.storedMarks || n.selection.$to.parentOffset && n.selection.$from.marks();
|
|
1645
|
+
if (e) {
|
|
1646
|
+
const r = e.filter((o) => t == null ? void 0 : t.includes(o.type.name));
|
|
1647
|
+
n.tr.ensureMarks(r);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
const Hn = ({ keepMarks: n = !0 } = {}) => ({ tr: t, state: e, dispatch: r, editor: o }) => {
|
|
1651
|
+
const { selection: s, doc: i } = t, { $from: c, $to: a } = s, l = o.extensionManager.attributes, u = K(l, c.node().type.name, c.node().attrs);
|
|
1652
|
+
if (s instanceof J && s.node.isBlock)
|
|
1653
|
+
return !c.parentOffset || !V(i, c.pos) ? !1 : (r && (n && Et(e, o.extensionManager.splittableMarks), t.split(c.pos).scrollIntoView()), !0);
|
|
1654
|
+
if (!c.parent.isBlock)
|
|
1655
|
+
return !1;
|
|
1656
|
+
const d = a.parentOffset === a.parent.content.size, f = c.depth === 0 ? void 0 : Cn(c.node(-1).contentMatchAt(c.indexAfter(-1)));
|
|
1657
|
+
let p = d && f ? [
|
|
1658
|
+
{
|
|
1659
|
+
type: f,
|
|
1660
|
+
attrs: u
|
|
1661
|
+
}
|
|
1662
|
+
] : void 0, m = V(t.doc, t.mapping.map(c.pos), 1, p);
|
|
1663
|
+
if (!p && !m && V(t.doc, t.mapping.map(c.pos), 1, f ? [{ type: f }] : void 0) && (m = !0, p = f ? [
|
|
1664
|
+
{
|
|
1665
|
+
type: f,
|
|
1666
|
+
attrs: u
|
|
1667
|
+
}
|
|
1668
|
+
] : void 0), r) {
|
|
1669
|
+
if (m && (s instanceof P && t.deleteSelection(), t.split(t.mapping.map(c.pos), 1, p), f && !d && !c.parentOffset && c.parent.type !== f)) {
|
|
1670
|
+
const h = t.mapping.map(c.before()), g = t.doc.resolve(h);
|
|
1671
|
+
c.node(-1).canReplaceWith(g.index(), g.index() + 1, f) && t.setNodeMarkup(t.mapping.map(c.before()), f);
|
|
1672
|
+
}
|
|
1673
|
+
n && Et(e, o.extensionManager.splittableMarks), t.scrollIntoView();
|
|
1674
|
+
}
|
|
1675
|
+
return m;
|
|
1676
|
+
}, _n = (n, t = {}) => ({ tr: e, state: r, dispatch: o, editor: s }) => {
|
|
1677
|
+
var i;
|
|
1678
|
+
const c = S(n, r.schema), { $from: a, $to: l } = r.selection, u = r.selection.node;
|
|
1679
|
+
if (u && u.isBlock || a.depth < 2 || !a.sameParent(l))
|
|
1680
|
+
return !1;
|
|
1681
|
+
const d = a.node(-1);
|
|
1682
|
+
if (d.type !== c)
|
|
1683
|
+
return !1;
|
|
1684
|
+
const f = s.extensionManager.attributes;
|
|
1685
|
+
if (a.parent.content.size === 0 && a.node(-1).childCount === a.indexAfter(-1)) {
|
|
1686
|
+
if (a.depth === 2 || a.node(-3).type !== c || a.index(-2) !== a.node(-2).childCount - 1)
|
|
1687
|
+
return !1;
|
|
1688
|
+
if (o) {
|
|
1689
|
+
let y = $.empty;
|
|
1690
|
+
const v = a.index(-1) ? 1 : a.index(-2) ? 2 : 3;
|
|
1691
|
+
for (let A = a.depth - v; A >= a.depth - 3; A -= 1)
|
|
1692
|
+
y = $.from(a.node(A).copy(y));
|
|
1693
|
+
const w = a.indexAfter(-1) < a.node(-2).childCount ? 1 : a.indexAfter(-2) < a.node(-3).childCount ? 2 : 3, E = {
|
|
1694
|
+
...K(f, a.node().type.name, a.node().attrs),
|
|
1695
|
+
...t
|
|
1696
|
+
}, M = ((i = c.contentMatch.defaultType) === null || i === void 0 ? void 0 : i.createAndFill(E)) || void 0;
|
|
1697
|
+
y = y.append($.from(c.createAndFill(null, M) || void 0));
|
|
1698
|
+
const x = a.before(a.depth - (v - 1));
|
|
1699
|
+
e.replace(x, a.after(-w), new Kt(y, 4 - v, 0));
|
|
1700
|
+
let T = -1;
|
|
1701
|
+
e.doc.nodesBetween(x, e.doc.content.size, (A, Dt) => {
|
|
1702
|
+
if (T > -1)
|
|
1703
|
+
return !1;
|
|
1704
|
+
A.isTextblock && A.content.size === 0 && (T = Dt + 1);
|
|
1705
|
+
}), T > -1 && e.setSelection(P.near(e.doc.resolve(T))), e.scrollIntoView();
|
|
1706
|
+
}
|
|
1707
|
+
return !0;
|
|
1708
|
+
}
|
|
1709
|
+
const p = l.pos === a.end() ? d.contentMatchAt(0).defaultType : null, m = {
|
|
1710
|
+
...K(f, d.type.name, d.attrs),
|
|
1711
|
+
...t
|
|
1712
|
+
}, h = {
|
|
1713
|
+
...K(f, a.node().type.name, a.node().attrs),
|
|
1714
|
+
...t
|
|
1715
|
+
};
|
|
1716
|
+
e.delete(a.pos, l.pos);
|
|
1717
|
+
const g = p ? [
|
|
1718
|
+
{ type: c, attrs: m },
|
|
1719
|
+
{ type: p, attrs: h }
|
|
1720
|
+
] : [{ type: c, attrs: m }];
|
|
1721
|
+
if (!V(e.doc, a.pos, 2))
|
|
1722
|
+
return !1;
|
|
1723
|
+
if (o) {
|
|
1724
|
+
const { selection: y, storedMarks: v } = r, { splittableMarks: w } = s.extensionManager, E = v || y.$to.parentOffset && y.$from.marks();
|
|
1725
|
+
if (e.split(a.pos, 2, g).scrollIntoView(), !E || !o)
|
|
1726
|
+
return !0;
|
|
1727
|
+
const M = E.filter((x) => w.includes(x.type.name));
|
|
1728
|
+
e.ensureMarks(M);
|
|
1729
|
+
}
|
|
1730
|
+
return !0;
|
|
1731
|
+
}, ot = (n, t) => {
|
|
1732
|
+
const e = ht((i) => i.type === t)(n.selection);
|
|
1733
|
+
if (!e)
|
|
1734
|
+
return !0;
|
|
1735
|
+
const r = n.doc.resolve(Math.max(0, e.pos - 1)).before(e.depth);
|
|
1736
|
+
if (r === void 0)
|
|
1737
|
+
return !0;
|
|
1738
|
+
const o = n.doc.nodeAt(r);
|
|
1739
|
+
return e.node.type === (o == null ? void 0 : o.type) && dt(n.doc, e.pos) && n.join(e.pos), !0;
|
|
1740
|
+
}, st = (n, t) => {
|
|
1741
|
+
const e = ht((i) => i.type === t)(n.selection);
|
|
1742
|
+
if (!e)
|
|
1743
|
+
return !0;
|
|
1744
|
+
const r = n.doc.resolve(e.start).after(e.depth);
|
|
1745
|
+
if (r === void 0)
|
|
1746
|
+
return !0;
|
|
1747
|
+
const o = n.doc.nodeAt(r);
|
|
1748
|
+
return e.node.type === (o == null ? void 0 : o.type) && dt(n.doc, r) && n.join(r), !0;
|
|
1749
|
+
}, Wn = (n, t, e, r = {}) => ({ editor: o, tr: s, state: i, dispatch: c, chain: a, commands: l, can: u }) => {
|
|
1750
|
+
const { extensions: d, splittableMarks: f } = o.extensionManager, p = S(n, i.schema), m = S(t, i.schema), { selection: h, storedMarks: g } = i, { $from: y, $to: v } = h, w = y.blockRange(v), E = g || h.$to.parentOffset && h.$from.marks();
|
|
1751
|
+
if (!w)
|
|
1752
|
+
return !1;
|
|
1753
|
+
const M = ht((x) => St(x.type.name, d))(h);
|
|
1754
|
+
if (w.depth >= 1 && M && w.depth - M.depth <= 1) {
|
|
1755
|
+
if (M.node.type === p)
|
|
1756
|
+
return l.liftListItem(m);
|
|
1757
|
+
if (St(M.node.type.name, d) && p.validContent(M.node.content) && c)
|
|
1758
|
+
return a().command(() => (s.setNodeMarkup(M.pos, p), !0)).command(() => ot(s, p)).command(() => st(s, p)).run();
|
|
1759
|
+
}
|
|
1760
|
+
return !e || !E || !c ? a().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => ot(s, p)).command(() => st(s, p)).run() : a().command(() => {
|
|
1761
|
+
const x = u().wrapInList(p, r), T = E.filter((A) => f.includes(A.type.name));
|
|
1762
|
+
return s.ensureMarks(T), x ? !0 : l.clearNodes();
|
|
1763
|
+
}).wrapInList(p, r).command(() => ot(s, p)).command(() => st(s, p)).run();
|
|
1764
|
+
}, Vn = (n, t = {}, e = {}) => ({ state: r, commands: o }) => {
|
|
1765
|
+
const { extendEmptyMarkRange: s = !1 } = e, i = B(n, r.schema);
|
|
1766
|
+
return ct(r, i, t) ? o.unsetMark(i, { extendEmptyMarkRange: s }) : o.setMark(i, t);
|
|
1767
|
+
}, Kn = (n, t, e = {}) => ({ state: r, commands: o }) => {
|
|
1768
|
+
const s = S(n, r.schema), i = S(t, r.schema), c = L(r, s, e);
|
|
1769
|
+
let a;
|
|
1770
|
+
return r.selection.$anchor.sameParent(r.selection.$head) && (a = r.selection.$anchor.parent.attrs), c ? o.setNode(i, a) : o.setNode(s, { ...a, ...e });
|
|
1771
|
+
}, Un = (n, t = {}) => ({ state: e, commands: r }) => {
|
|
1772
|
+
const o = S(n, e.schema);
|
|
1773
|
+
return L(e, o, t) ? r.lift(o) : r.wrapIn(o, t);
|
|
1774
|
+
}, qn = () => ({ state: n, dispatch: t }) => {
|
|
1775
|
+
const e = n.plugins;
|
|
1776
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
1777
|
+
const o = e[r];
|
|
1778
|
+
let s;
|
|
1779
|
+
if (o.spec.isInputRules && (s = o.getState(n))) {
|
|
1780
|
+
if (t) {
|
|
1781
|
+
const i = n.tr, c = s.transform;
|
|
1782
|
+
for (let a = c.steps.length - 1; a >= 0; a -= 1)
|
|
1783
|
+
i.step(c.steps[a].invert(c.docs[a]));
|
|
1784
|
+
if (s.text) {
|
|
1785
|
+
const a = i.doc.resolve(s.from).marks();
|
|
1786
|
+
i.replaceWith(s.from, s.to, n.schema.text(s.text, a));
|
|
1787
|
+
} else
|
|
1788
|
+
i.delete(s.from, s.to);
|
|
1789
|
+
}
|
|
1790
|
+
return !0;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
return !1;
|
|
1794
|
+
}, Gn = () => ({ tr: n, dispatch: t }) => {
|
|
1795
|
+
const { selection: e } = n, { empty: r, ranges: o } = e;
|
|
1796
|
+
return r || t && o.forEach((s) => {
|
|
1797
|
+
n.removeMark(s.$from.pos, s.$to.pos);
|
|
1798
|
+
}), !0;
|
|
1799
|
+
}, Jn = (n, t = {}) => ({ tr: e, state: r, dispatch: o }) => {
|
|
1800
|
+
var s;
|
|
1801
|
+
const { extendEmptyMarkRange: i = !1 } = t, { selection: c } = e, a = B(n, r.schema), { $from: l, empty: u, ranges: d } = c;
|
|
1802
|
+
if (!o)
|
|
1803
|
+
return !0;
|
|
1804
|
+
if (u && i) {
|
|
1805
|
+
let { from: f, to: p } = c;
|
|
1806
|
+
const m = (s = l.marks().find((g) => g.type === a)) === null || s === void 0 ? void 0 : s.attrs, h = pt(l, a, m);
|
|
1807
|
+
h && (f = h.from, p = h.to), e.removeMark(f, p, a);
|
|
1808
|
+
} else
|
|
1809
|
+
d.forEach((f) => {
|
|
1810
|
+
e.removeMark(f.$from.pos, f.$to.pos, a);
|
|
1811
|
+
});
|
|
1812
|
+
return e.removeStoredMark(a), !0;
|
|
1813
|
+
}, Yn = (n, t = {}) => ({ tr: e, state: r, dispatch: o }) => {
|
|
1814
|
+
let s = null, i = null;
|
|
1815
|
+
const c = et(typeof n == "string" ? n : n.name, r.schema);
|
|
1816
|
+
return c ? (c === "node" && (s = S(n, r.schema)), c === "mark" && (i = B(n, r.schema)), o && e.selection.ranges.forEach((a) => {
|
|
1817
|
+
const l = a.$from.pos, u = a.$to.pos;
|
|
1818
|
+
let d, f, p, m;
|
|
1819
|
+
e.selection.empty ? r.doc.nodesBetween(l, u, (h, g) => {
|
|
1820
|
+
s && s === h.type && (p = Math.max(g, l), m = Math.min(g + h.nodeSize, u), d = g, f = h);
|
|
1821
|
+
}) : r.doc.nodesBetween(l, u, (h, g) => {
|
|
1822
|
+
g < l && s && s === h.type && (p = Math.max(g, l), m = Math.min(g + h.nodeSize, u), d = g, f = h), g >= l && g <= u && (s && s === h.type && e.setNodeMarkup(g, void 0, {
|
|
1823
|
+
...h.attrs,
|
|
1824
|
+
...t
|
|
1825
|
+
}), i && h.marks.length && h.marks.forEach((y) => {
|
|
1826
|
+
if (i === y.type) {
|
|
1827
|
+
const v = Math.max(g, l), w = Math.min(g + h.nodeSize, u);
|
|
1828
|
+
e.addMark(v, w, i.create({
|
|
1829
|
+
...y.attrs,
|
|
1830
|
+
...t
|
|
1831
|
+
}));
|
|
1832
|
+
}
|
|
1833
|
+
}));
|
|
1834
|
+
}), f && (d !== void 0 && e.setNodeMarkup(d, void 0, {
|
|
1835
|
+
...f.attrs,
|
|
1836
|
+
...t
|
|
1837
|
+
}), i && f.marks.length && f.marks.forEach((h) => {
|
|
1838
|
+
i === h.type && e.addMark(p, m, i.create({
|
|
1839
|
+
...h.attrs,
|
|
1840
|
+
...t
|
|
1841
|
+
}));
|
|
1842
|
+
}));
|
|
1843
|
+
}), !0) : !1;
|
|
1844
|
+
}, Qn = (n, t = {}) => ({ state: e, dispatch: r }) => {
|
|
1845
|
+
const o = S(n, e.schema);
|
|
1846
|
+
return Qt(o, t)(e, r);
|
|
1847
|
+
}, Xn = (n, t = {}) => ({ state: e, dispatch: r }) => {
|
|
1848
|
+
const o = S(n, e.schema);
|
|
1849
|
+
return me(o, t)(e, r);
|
|
1850
|
+
};
|
|
1851
|
+
var Zn = /* @__PURE__ */ Object.freeze({
|
|
1852
|
+
__proto__: null,
|
|
1853
|
+
blur: je,
|
|
1854
|
+
clearContent: Re,
|
|
1855
|
+
clearNodes: Fe,
|
|
1856
|
+
command: De,
|
|
1857
|
+
createParagraphNear: Le,
|
|
1858
|
+
cut: ze,
|
|
1859
|
+
deleteCurrentNode: He,
|
|
1860
|
+
deleteNode: _e,
|
|
1861
|
+
deleteRange: We,
|
|
1862
|
+
deleteSelection: Ve,
|
|
1863
|
+
enter: Ke,
|
|
1864
|
+
exitCode: Ue,
|
|
1865
|
+
extendMarkRange: qe,
|
|
1866
|
+
first: Ge,
|
|
1867
|
+
focus: Ye,
|
|
1868
|
+
forEach: Qe,
|
|
1869
|
+
insertContent: Xe,
|
|
1870
|
+
insertContentAt: en,
|
|
1871
|
+
joinBackward: on,
|
|
1872
|
+
joinDown: rn,
|
|
1873
|
+
joinForward: sn,
|
|
1874
|
+
joinItemBackward: an,
|
|
1875
|
+
joinItemForward: cn,
|
|
1876
|
+
joinTextblockBackward: ln,
|
|
1877
|
+
joinTextblockForward: dn,
|
|
1878
|
+
joinUp: nn,
|
|
1879
|
+
keyboardShortcut: fn,
|
|
1880
|
+
lift: pn,
|
|
1881
|
+
liftEmptyBlock: hn,
|
|
1882
|
+
liftListItem: mn,
|
|
1883
|
+
newlineInCode: gn,
|
|
1884
|
+
resetAttributes: yn,
|
|
1885
|
+
scrollIntoView: kn,
|
|
1886
|
+
selectAll: bn,
|
|
1887
|
+
selectNodeBackward: vn,
|
|
1888
|
+
selectNodeForward: wn,
|
|
1889
|
+
selectParentNode: Mn,
|
|
1890
|
+
selectTextblockEnd: Sn,
|
|
1891
|
+
selectTextblockStart: En,
|
|
1892
|
+
setContent: xn,
|
|
1893
|
+
setMark: jn,
|
|
1894
|
+
setMeta: Rn,
|
|
1895
|
+
setNode: Fn,
|
|
1896
|
+
setNodeSelection: Dn,
|
|
1897
|
+
setTextSelection: Ln,
|
|
1898
|
+
sinkListItem: zn,
|
|
1899
|
+
splitBlock: Hn,
|
|
1900
|
+
splitListItem: _n,
|
|
1901
|
+
toggleList: Wn,
|
|
1902
|
+
toggleMark: Vn,
|
|
1903
|
+
toggleNode: Kn,
|
|
1904
|
+
toggleWrap: Un,
|
|
1905
|
+
undoInputRule: qn,
|
|
1906
|
+
unsetAllMarks: Gn,
|
|
1907
|
+
unsetMark: Jn,
|
|
1908
|
+
updateAttributes: Yn,
|
|
1909
|
+
wrapIn: Qn,
|
|
1910
|
+
wrapInList: Xn
|
|
1911
|
+
});
|
|
1912
|
+
const tr = C.create({
|
|
1913
|
+
name: "commands",
|
|
1914
|
+
addCommands() {
|
|
1915
|
+
return {
|
|
1916
|
+
...Zn
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
}), er = C.create({
|
|
1920
|
+
name: "drop",
|
|
1921
|
+
addProseMirrorPlugins() {
|
|
1922
|
+
return [
|
|
1923
|
+
new I({
|
|
1924
|
+
key: new j("tiptapDrop"),
|
|
1925
|
+
props: {
|
|
1926
|
+
handleDrop: (n, t, e, r) => {
|
|
1927
|
+
this.editor.emit("drop", {
|
|
1928
|
+
editor: this.editor,
|
|
1929
|
+
event: t,
|
|
1930
|
+
slice: e,
|
|
1931
|
+
moved: r
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
})
|
|
1936
|
+
];
|
|
1937
|
+
}
|
|
1938
|
+
}), nr = C.create({
|
|
1939
|
+
name: "editable",
|
|
1940
|
+
addProseMirrorPlugins() {
|
|
1941
|
+
return [
|
|
1942
|
+
new I({
|
|
1943
|
+
key: new j("editable"),
|
|
1944
|
+
props: {
|
|
1945
|
+
editable: () => this.editor.options.editable
|
|
1946
|
+
}
|
|
1947
|
+
})
|
|
1948
|
+
];
|
|
1949
|
+
}
|
|
1950
|
+
}), rr = new j("focusEvents"), or = C.create({
|
|
1951
|
+
name: "focusEvents",
|
|
1952
|
+
addProseMirrorPlugins() {
|
|
1953
|
+
const { editor: n } = this;
|
|
1954
|
+
return [
|
|
1955
|
+
new I({
|
|
1956
|
+
key: rr,
|
|
1957
|
+
props: {
|
|
1958
|
+
handleDOMEvents: {
|
|
1959
|
+
focus: (t, e) => {
|
|
1960
|
+
n.isFocused = !0;
|
|
1961
|
+
const r = n.state.tr.setMeta("focus", { event: e }).setMeta("addToHistory", !1);
|
|
1962
|
+
return t.dispatch(r), !1;
|
|
1963
|
+
},
|
|
1964
|
+
blur: (t, e) => {
|
|
1965
|
+
n.isFocused = !1;
|
|
1966
|
+
const r = n.state.tr.setMeta("blur", { event: e }).setMeta("addToHistory", !1);
|
|
1967
|
+
return t.dispatch(r), !1;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
})
|
|
1972
|
+
];
|
|
1973
|
+
}
|
|
1974
|
+
}), sr = C.create({
|
|
1975
|
+
name: "keymap",
|
|
1976
|
+
addKeyboardShortcuts() {
|
|
1977
|
+
const n = () => this.editor.commands.first(({ commands: i }) => [
|
|
1978
|
+
() => i.undoInputRule(),
|
|
1979
|
+
// maybe convert first text block node to default node
|
|
1980
|
+
() => i.command(({ tr: c }) => {
|
|
1981
|
+
const { selection: a, doc: l } = c, { empty: u, $anchor: d } = a, { pos: f, parent: p } = d, m = d.parent.isTextblock && f > 0 ? c.doc.resolve(f - 1) : d, h = m.parent.type.spec.isolating, g = d.pos - d.parentOffset, y = h && m.parent.childCount === 1 ? g === d.pos : F.atStart(l).from === f;
|
|
1982
|
+
return !u || !p.type.isTextblock || p.textContent.length || !y || y && d.parent.type.name === "paragraph" ? !1 : i.clearNodes();
|
|
1983
|
+
}),
|
|
1984
|
+
() => i.deleteSelection(),
|
|
1985
|
+
() => i.joinBackward(),
|
|
1986
|
+
() => i.selectNodeBackward()
|
|
1987
|
+
]), t = () => this.editor.commands.first(({ commands: i }) => [
|
|
1988
|
+
() => i.deleteSelection(),
|
|
1989
|
+
() => i.deleteCurrentNode(),
|
|
1990
|
+
() => i.joinForward(),
|
|
1991
|
+
() => i.selectNodeForward()
|
|
1992
|
+
]), r = {
|
|
1993
|
+
Enter: () => this.editor.commands.first(({ commands: i }) => [
|
|
1994
|
+
() => i.newlineInCode(),
|
|
1995
|
+
() => i.createParagraphNear(),
|
|
1996
|
+
() => i.liftEmptyBlock(),
|
|
1997
|
+
() => i.splitBlock()
|
|
1998
|
+
]),
|
|
1999
|
+
"Mod-Enter": () => this.editor.commands.exitCode(),
|
|
2000
|
+
Backspace: n,
|
|
2001
|
+
"Mod-Backspace": n,
|
|
2002
|
+
"Shift-Backspace": n,
|
|
2003
|
+
Delete: t,
|
|
2004
|
+
"Mod-Delete": t,
|
|
2005
|
+
"Mod-a": () => this.editor.commands.selectAll()
|
|
2006
|
+
}, o = {
|
|
2007
|
+
...r
|
|
2008
|
+
}, s = {
|
|
2009
|
+
...r,
|
|
2010
|
+
"Ctrl-h": n,
|
|
2011
|
+
"Alt-Backspace": n,
|
|
2012
|
+
"Ctrl-d": t,
|
|
2013
|
+
"Ctrl-Alt-Backspace": t,
|
|
2014
|
+
"Alt-Delete": t,
|
|
2015
|
+
"Alt-d": t,
|
|
2016
|
+
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2017
|
+
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2018
|
+
};
|
|
2019
|
+
return G() || jt() ? s : o;
|
|
2020
|
+
},
|
|
2021
|
+
addProseMirrorPlugins() {
|
|
2022
|
+
return [
|
|
2023
|
+
// With this plugin we check if the whole document was selected and deleted.
|
|
2024
|
+
// In this case we will additionally call `clearNodes()` to convert e.g. a heading
|
|
2025
|
+
// to a paragraph if necessary.
|
|
2026
|
+
// This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
|
|
2027
|
+
// with many other commands.
|
|
2028
|
+
new I({
|
|
2029
|
+
key: new j("clearDocument"),
|
|
2030
|
+
appendTransaction: (n, t, e) => {
|
|
2031
|
+
if (n.some((h) => h.getMeta("composition")))
|
|
2032
|
+
return;
|
|
2033
|
+
const r = n.some((h) => h.docChanged) && !t.doc.eq(e.doc), o = n.some((h) => h.getMeta("preventClearDocument"));
|
|
2034
|
+
if (!r || o)
|
|
2035
|
+
return;
|
|
2036
|
+
const { empty: s, from: i, to: c } = t.selection, a = F.atStart(t.doc).from, l = F.atEnd(t.doc).to;
|
|
2037
|
+
if (s || !(i === a && c === l) || !mt(e.doc))
|
|
2038
|
+
return;
|
|
2039
|
+
const f = e.tr, p = Y({
|
|
2040
|
+
state: e,
|
|
2041
|
+
transaction: f
|
|
2042
|
+
}), { commands: m } = new Q({
|
|
2043
|
+
editor: this.editor,
|
|
2044
|
+
state: p
|
|
2045
|
+
});
|
|
2046
|
+
if (m.clearNodes(), !!f.steps.length)
|
|
2047
|
+
return f;
|
|
2048
|
+
}
|
|
2049
|
+
})
|
|
2050
|
+
];
|
|
2051
|
+
}
|
|
2052
|
+
}), ir = C.create({
|
|
2053
|
+
name: "paste",
|
|
2054
|
+
addProseMirrorPlugins() {
|
|
2055
|
+
return [
|
|
2056
|
+
new I({
|
|
2057
|
+
key: new j("tiptapPaste"),
|
|
2058
|
+
props: {
|
|
2059
|
+
handlePaste: (n, t, e) => {
|
|
2060
|
+
this.editor.emit("paste", {
|
|
2061
|
+
editor: this.editor,
|
|
2062
|
+
event: t,
|
|
2063
|
+
slice: e
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
})
|
|
2068
|
+
];
|
|
2069
|
+
}
|
|
2070
|
+
}), ar = C.create({
|
|
2071
|
+
name: "tabindex",
|
|
2072
|
+
addProseMirrorPlugins() {
|
|
2073
|
+
return [
|
|
2074
|
+
new I({
|
|
2075
|
+
key: new j("tabindex"),
|
|
2076
|
+
props: {
|
|
2077
|
+
attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
|
|
2078
|
+
}
|
|
2079
|
+
})
|
|
2080
|
+
];
|
|
2081
|
+
}
|
|
2082
|
+
});
|
|
2083
|
+
class N {
|
|
2084
|
+
get name() {
|
|
2085
|
+
return this.node.type.name;
|
|
2086
|
+
}
|
|
2087
|
+
constructor(t, e, r = !1, o = null) {
|
|
2088
|
+
this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = t, this.editor = e, this.currentNode = o;
|
|
2089
|
+
}
|
|
2090
|
+
get node() {
|
|
2091
|
+
return this.currentNode || this.resolvedPos.node();
|
|
2092
|
+
}
|
|
2093
|
+
get element() {
|
|
2094
|
+
return this.editor.view.domAtPos(this.pos).node;
|
|
2095
|
+
}
|
|
2096
|
+
get depth() {
|
|
2097
|
+
var t;
|
|
2098
|
+
return (t = this.actualDepth) !== null && t !== void 0 ? t : this.resolvedPos.depth;
|
|
2099
|
+
}
|
|
2100
|
+
get pos() {
|
|
2101
|
+
return this.resolvedPos.pos;
|
|
2102
|
+
}
|
|
2103
|
+
get content() {
|
|
2104
|
+
return this.node.content;
|
|
2105
|
+
}
|
|
2106
|
+
set content(t) {
|
|
2107
|
+
let e = this.from, r = this.to;
|
|
2108
|
+
if (this.isBlock) {
|
|
2109
|
+
if (this.content.size === 0) {
|
|
2110
|
+
console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
|
|
2111
|
+
return;
|
|
2112
|
+
}
|
|
2113
|
+
e = this.from + 1, r = this.to - 1;
|
|
2114
|
+
}
|
|
2115
|
+
this.editor.commands.insertContentAt({ from: e, to: r }, t);
|
|
2116
|
+
}
|
|
2117
|
+
get attributes() {
|
|
2118
|
+
return this.node.attrs;
|
|
2119
|
+
}
|
|
2120
|
+
get textContent() {
|
|
2121
|
+
return this.node.textContent;
|
|
2122
|
+
}
|
|
2123
|
+
get size() {
|
|
2124
|
+
return this.node.nodeSize;
|
|
2125
|
+
}
|
|
2126
|
+
get from() {
|
|
2127
|
+
return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth);
|
|
2128
|
+
}
|
|
2129
|
+
get range() {
|
|
2130
|
+
return {
|
|
2131
|
+
from: this.from,
|
|
2132
|
+
to: this.to
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
get to() {
|
|
2136
|
+
return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
|
|
2137
|
+
}
|
|
2138
|
+
get parent() {
|
|
2139
|
+
if (this.depth === 0)
|
|
2140
|
+
return null;
|
|
2141
|
+
const t = this.resolvedPos.start(this.resolvedPos.depth - 1), e = this.resolvedPos.doc.resolve(t);
|
|
2142
|
+
return new N(e, this.editor);
|
|
2143
|
+
}
|
|
2144
|
+
get before() {
|
|
2145
|
+
let t = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
|
|
2146
|
+
return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.from - 3)), new N(t, this.editor);
|
|
2147
|
+
}
|
|
2148
|
+
get after() {
|
|
2149
|
+
let t = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
|
|
2150
|
+
return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.to + 3)), new N(t, this.editor);
|
|
2151
|
+
}
|
|
2152
|
+
get children() {
|
|
2153
|
+
const t = [];
|
|
2154
|
+
return this.node.content.forEach((e, r) => {
|
|
2155
|
+
const o = e.isBlock && !e.isTextblock, s = e.isAtom && !e.isText, i = this.pos + r + (s ? 0 : 1);
|
|
2156
|
+
if (i < 0 || i > this.resolvedPos.doc.nodeSize - 2)
|
|
2157
|
+
return;
|
|
2158
|
+
const c = this.resolvedPos.doc.resolve(i);
|
|
2159
|
+
if (!o && c.depth <= this.depth)
|
|
2160
|
+
return;
|
|
2161
|
+
const a = new N(c, this.editor, o, o ? e : null);
|
|
2162
|
+
o && (a.actualDepth = this.depth + 1), t.push(new N(c, this.editor, o, o ? e : null));
|
|
2163
|
+
}), t;
|
|
2164
|
+
}
|
|
2165
|
+
get firstChild() {
|
|
2166
|
+
return this.children[0] || null;
|
|
2167
|
+
}
|
|
2168
|
+
get lastChild() {
|
|
2169
|
+
const t = this.children;
|
|
2170
|
+
return t[t.length - 1] || null;
|
|
2171
|
+
}
|
|
2172
|
+
closest(t, e = {}) {
|
|
2173
|
+
let r = null, o = this.parent;
|
|
2174
|
+
for (; o && !r; ) {
|
|
2175
|
+
if (o.node.type.name === t)
|
|
2176
|
+
if (Object.keys(e).length > 0) {
|
|
2177
|
+
const s = o.node.attrs, i = Object.keys(e);
|
|
2178
|
+
for (let c = 0; c < i.length; c += 1) {
|
|
2179
|
+
const a = i[c];
|
|
2180
|
+
if (s[a] !== e[a])
|
|
2181
|
+
break;
|
|
2182
|
+
}
|
|
2183
|
+
} else
|
|
2184
|
+
r = o;
|
|
2185
|
+
o = o.parent;
|
|
2186
|
+
}
|
|
2187
|
+
return r;
|
|
2188
|
+
}
|
|
2189
|
+
querySelector(t, e = {}) {
|
|
2190
|
+
return this.querySelectorAll(t, e, !0)[0] || null;
|
|
2191
|
+
}
|
|
2192
|
+
querySelectorAll(t, e = {}, r = !1) {
|
|
2193
|
+
let o = [];
|
|
2194
|
+
if (!this.children || this.children.length === 0)
|
|
2195
|
+
return o;
|
|
2196
|
+
const s = Object.keys(e);
|
|
2197
|
+
return this.children.forEach((i) => {
|
|
2198
|
+
r && o.length > 0 || (i.node.type.name === t && s.every((a) => e[a] === i.node.attrs[a]) && o.push(i), !(r && o.length > 0) && (o = o.concat(i.querySelectorAll(t, e, r))));
|
|
2199
|
+
}), o;
|
|
2200
|
+
}
|
|
2201
|
+
setAttribute(t) {
|
|
2202
|
+
const { tr: e } = this.editor.state;
|
|
2203
|
+
e.setNodeMarkup(this.from, void 0, {
|
|
2204
|
+
...this.node.attrs,
|
|
2205
|
+
...t
|
|
2206
|
+
}), this.editor.view.dispatch(e);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
const cr = `.ProseMirror {
|
|
2210
|
+
position: relative;
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
.ProseMirror {
|
|
2214
|
+
word-wrap: break-word;
|
|
2215
|
+
white-space: pre-wrap;
|
|
2216
|
+
white-space: break-spaces;
|
|
2217
|
+
-webkit-font-variant-ligatures: none;
|
|
2218
|
+
font-variant-ligatures: none;
|
|
2219
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
.ProseMirror [contenteditable="false"] {
|
|
2223
|
+
white-space: normal;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
2227
|
+
white-space: pre-wrap;
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
.ProseMirror pre {
|
|
2231
|
+
white-space: pre-wrap;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
img.ProseMirror-separator {
|
|
2235
|
+
display: inline !important;
|
|
2236
|
+
border: none !important;
|
|
2237
|
+
margin: 0 !important;
|
|
2238
|
+
width: 0 !important;
|
|
2239
|
+
height: 0 !important;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
.ProseMirror-gapcursor {
|
|
2243
|
+
display: none;
|
|
2244
|
+
pointer-events: none;
|
|
2245
|
+
position: absolute;
|
|
2246
|
+
margin: 0;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
.ProseMirror-gapcursor:after {
|
|
2250
|
+
content: "";
|
|
2251
|
+
display: block;
|
|
2252
|
+
position: absolute;
|
|
2253
|
+
top: -2px;
|
|
2254
|
+
width: 20px;
|
|
2255
|
+
border-top: 1px solid black;
|
|
2256
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
@keyframes ProseMirror-cursor-blink {
|
|
2260
|
+
to {
|
|
2261
|
+
visibility: hidden;
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
.ProseMirror-hideselection *::selection {
|
|
2266
|
+
background: transparent;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
2270
|
+
background: transparent;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
.ProseMirror-hideselection * {
|
|
2274
|
+
caret-color: transparent;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
2278
|
+
display: block;
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
2282
|
+
opacity: 0
|
|
2283
|
+
}`;
|
|
2284
|
+
function lr(n, t, e) {
|
|
2285
|
+
const r = document.querySelector("style[data-tiptap-style]");
|
|
2286
|
+
if (r !== null)
|
|
2287
|
+
return r;
|
|
2288
|
+
const o = document.createElement("style");
|
|
2289
|
+
return t && o.setAttribute("nonce", t), o.setAttribute("data-tiptap-style", ""), o.innerHTML = n, document.getElementsByTagName("head")[0].appendChild(o), o;
|
|
2290
|
+
}
|
|
2291
|
+
class Mr extends ke {
|
|
2292
|
+
constructor(t = {}) {
|
|
2293
|
+
super(), this.isFocused = !1, this.isInitialized = !1, this.extensionStorage = {}, this.options = {
|
|
2294
|
+
element: document.createElement("div"),
|
|
2295
|
+
content: "",
|
|
2296
|
+
injectCSS: !0,
|
|
2297
|
+
injectNonce: void 0,
|
|
2298
|
+
extensions: [],
|
|
2299
|
+
autofocus: !1,
|
|
2300
|
+
editable: !0,
|
|
2301
|
+
editorProps: {},
|
|
2302
|
+
parseOptions: {},
|
|
2303
|
+
coreExtensionOptions: {},
|
|
2304
|
+
enableInputRules: !0,
|
|
2305
|
+
enablePasteRules: !0,
|
|
2306
|
+
enableCoreExtensions: !0,
|
|
2307
|
+
enableContentCheck: !1,
|
|
2308
|
+
emitContentError: !1,
|
|
2309
|
+
onBeforeCreate: () => null,
|
|
2310
|
+
onCreate: () => null,
|
|
2311
|
+
onUpdate: () => null,
|
|
2312
|
+
onSelectionUpdate: () => null,
|
|
2313
|
+
onTransaction: () => null,
|
|
2314
|
+
onFocus: () => null,
|
|
2315
|
+
onBlur: () => null,
|
|
2316
|
+
onDestroy: () => null,
|
|
2317
|
+
onContentError: ({ error: e }) => {
|
|
2318
|
+
throw e;
|
|
2319
|
+
},
|
|
2320
|
+
onPaste: () => null,
|
|
2321
|
+
onDrop: () => null
|
|
2322
|
+
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.setOptions(t), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("contentError", this.options.onContentError), this.createView(), this.injectCSS(), this.on("create", this.options.onCreate), this.on("update", this.options.onUpdate), this.on("selectionUpdate", this.options.onSelectionUpdate), this.on("transaction", this.options.onTransaction), this.on("focus", this.options.onFocus), this.on("blur", this.options.onBlur), this.on("destroy", this.options.onDestroy), this.on("drop", ({ event: e, slice: r, moved: o }) => this.options.onDrop(e, r, o)), this.on("paste", ({ event: e, slice: r }) => this.options.onPaste(e, r)), window.setTimeout(() => {
|
|
2323
|
+
this.isDestroyed || (this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0);
|
|
2324
|
+
}, 0);
|
|
2325
|
+
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Returns the editor storage.
|
|
2328
|
+
*/
|
|
2329
|
+
get storage() {
|
|
2330
|
+
return this.extensionStorage;
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* An object of all registered commands.
|
|
2334
|
+
*/
|
|
2335
|
+
get commands() {
|
|
2336
|
+
return this.commandManager.commands;
|
|
2337
|
+
}
|
|
2338
|
+
/**
|
|
2339
|
+
* Create a command chain to call multiple commands at once.
|
|
2340
|
+
*/
|
|
2341
|
+
chain() {
|
|
2342
|
+
return this.commandManager.chain();
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Check if a command or a command chain can be executed. Without executing it.
|
|
2346
|
+
*/
|
|
2347
|
+
can() {
|
|
2348
|
+
return this.commandManager.can();
|
|
2349
|
+
}
|
|
2350
|
+
/**
|
|
2351
|
+
* Inject CSS styles.
|
|
2352
|
+
*/
|
|
2353
|
+
injectCSS() {
|
|
2354
|
+
this.options.injectCSS && document && (this.css = lr(cr, this.options.injectNonce));
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* Update editor options.
|
|
2358
|
+
*
|
|
2359
|
+
* @param options A list of options
|
|
2360
|
+
*/
|
|
2361
|
+
setOptions(t = {}) {
|
|
2362
|
+
this.options = {
|
|
2363
|
+
...this.options,
|
|
2364
|
+
...t
|
|
2365
|
+
}, !(!this.view || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
|
|
2366
|
+
}
|
|
2367
|
+
/**
|
|
2368
|
+
* Update editable state of the editor.
|
|
2369
|
+
*/
|
|
2370
|
+
setEditable(t, e = !0) {
|
|
2371
|
+
this.setOptions({ editable: t }), e && this.emit("update", { editor: this, transaction: this.state.tr });
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Returns whether the editor is editable.
|
|
2375
|
+
*/
|
|
2376
|
+
get isEditable() {
|
|
2377
|
+
return this.options.editable && this.view && this.view.editable;
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Returns the editor state.
|
|
2381
|
+
*/
|
|
2382
|
+
get state() {
|
|
2383
|
+
return this.view.state;
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Register a ProseMirror plugin.
|
|
2387
|
+
*
|
|
2388
|
+
* @param plugin A ProseMirror plugin
|
|
2389
|
+
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
2390
|
+
* @returns The new editor state
|
|
2391
|
+
*/
|
|
2392
|
+
registerPlugin(t, e) {
|
|
2393
|
+
const r = At(e) ? e(t, [...this.state.plugins]) : [...this.state.plugins, t], o = this.state.reconfigure({ plugins: r });
|
|
2394
|
+
return this.view.updateState(o), o;
|
|
2395
|
+
}
|
|
2396
|
+
/**
|
|
2397
|
+
* Unregister a ProseMirror plugin.
|
|
2398
|
+
*
|
|
2399
|
+
* @param nameOrPluginKeyToRemove The plugins name
|
|
2400
|
+
* @returns The new editor state or undefined if the editor is destroyed
|
|
2401
|
+
*/
|
|
2402
|
+
unregisterPlugin(t) {
|
|
2403
|
+
if (this.isDestroyed)
|
|
2404
|
+
return;
|
|
2405
|
+
const e = this.state.plugins;
|
|
2406
|
+
let r = e;
|
|
2407
|
+
if ([].concat(t).forEach((s) => {
|
|
2408
|
+
const i = typeof s == "string" ? `${s}$` : s.key;
|
|
2409
|
+
r = r.filter((c) => !c.key.startsWith(i));
|
|
2410
|
+
}), e.length === r.length)
|
|
2411
|
+
return;
|
|
2412
|
+
const o = this.state.reconfigure({
|
|
2413
|
+
plugins: r
|
|
2414
|
+
});
|
|
2415
|
+
return this.view.updateState(o), o;
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Creates an extension manager.
|
|
2419
|
+
*/
|
|
2420
|
+
createExtensionManager() {
|
|
2421
|
+
var t, e;
|
|
2422
|
+
const o = [...this.options.enableCoreExtensions ? [
|
|
2423
|
+
nr,
|
|
2424
|
+
Ne.configure({
|
|
2425
|
+
blockSeparator: (e = (t = this.options.coreExtensionOptions) === null || t === void 0 ? void 0 : t.clipboardTextSerializer) === null || e === void 0 ? void 0 : e.blockSeparator
|
|
2426
|
+
}),
|
|
2427
|
+
tr,
|
|
2428
|
+
or,
|
|
2429
|
+
sr,
|
|
2430
|
+
ar,
|
|
2431
|
+
er,
|
|
2432
|
+
ir
|
|
2433
|
+
].filter((s) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[s.name] !== !1 : !0) : [], ...this.options.extensions].filter((s) => ["extension", "node", "mark"].includes(s == null ? void 0 : s.type));
|
|
2434
|
+
this.extensionManager = new R(o, this);
|
|
2435
|
+
}
|
|
2436
|
+
/**
|
|
2437
|
+
* Creates an command manager.
|
|
2438
|
+
*/
|
|
2439
|
+
createCommandManager() {
|
|
2440
|
+
this.commandManager = new Q({
|
|
2441
|
+
editor: this
|
|
2442
|
+
});
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Creates a ProseMirror schema.
|
|
2446
|
+
*/
|
|
2447
|
+
createSchema() {
|
|
2448
|
+
this.schema = this.extensionManager.schema;
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Creates a ProseMirror view.
|
|
2452
|
+
*/
|
|
2453
|
+
createView() {
|
|
2454
|
+
var t;
|
|
2455
|
+
let e;
|
|
2456
|
+
try {
|
|
2457
|
+
e = at(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
|
|
2458
|
+
} catch (i) {
|
|
2459
|
+
if (!(i instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(i.message))
|
|
2460
|
+
throw i;
|
|
2461
|
+
this.emit("contentError", {
|
|
2462
|
+
editor: this,
|
|
2463
|
+
error: i,
|
|
2464
|
+
disableCollaboration: () => {
|
|
2465
|
+
this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((c) => c.name !== "collaboration"), this.createExtensionManager();
|
|
2466
|
+
}
|
|
2467
|
+
}), e = at(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
|
|
2468
|
+
}
|
|
2469
|
+
const r = Bt(e, this.options.autofocus);
|
|
2470
|
+
this.view = new Ht(this.options.element, {
|
|
2471
|
+
...this.options.editorProps,
|
|
2472
|
+
attributes: {
|
|
2473
|
+
// add `role="textbox"` to the editor element
|
|
2474
|
+
role: "textbox",
|
|
2475
|
+
...(t = this.options.editorProps) === null || t === void 0 ? void 0 : t.attributes
|
|
2476
|
+
},
|
|
2477
|
+
dispatchTransaction: this.dispatchTransaction.bind(this),
|
|
2478
|
+
state: Lt.create({
|
|
2479
|
+
doc: e,
|
|
2480
|
+
selection: r || void 0
|
|
2481
|
+
})
|
|
2482
|
+
});
|
|
2483
|
+
const o = this.state.reconfigure({
|
|
2484
|
+
plugins: this.extensionManager.plugins
|
|
2485
|
+
});
|
|
2486
|
+
this.view.updateState(o), this.createNodeViews(), this.prependClass();
|
|
2487
|
+
const s = this.view.dom;
|
|
2488
|
+
s.editor = this;
|
|
2489
|
+
}
|
|
2490
|
+
/**
|
|
2491
|
+
* Creates all node views.
|
|
2492
|
+
*/
|
|
2493
|
+
createNodeViews() {
|
|
2494
|
+
this.view.isDestroyed || this.view.setProps({
|
|
2495
|
+
nodeViews: this.extensionManager.nodeViews
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
/**
|
|
2499
|
+
* Prepend class name to element.
|
|
2500
|
+
*/
|
|
2501
|
+
prependClass() {
|
|
2502
|
+
this.view.dom.className = `tiptap ${this.view.dom.className}`;
|
|
2503
|
+
}
|
|
2504
|
+
captureTransaction(t) {
|
|
2505
|
+
this.isCapturingTransaction = !0, t(), this.isCapturingTransaction = !1;
|
|
2506
|
+
const e = this.capturedTransaction;
|
|
2507
|
+
return this.capturedTransaction = null, e;
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* The callback over which to send transactions (state updates) produced by the view.
|
|
2511
|
+
*
|
|
2512
|
+
* @param transaction An editor state transaction
|
|
2513
|
+
*/
|
|
2514
|
+
dispatchTransaction(t) {
|
|
2515
|
+
if (this.view.isDestroyed)
|
|
2516
|
+
return;
|
|
2517
|
+
if (this.isCapturingTransaction) {
|
|
2518
|
+
if (!this.capturedTransaction) {
|
|
2519
|
+
this.capturedTransaction = t;
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
t.steps.forEach((i) => {
|
|
2523
|
+
var c;
|
|
2524
|
+
return (c = this.capturedTransaction) === null || c === void 0 ? void 0 : c.step(i);
|
|
2525
|
+
});
|
|
2526
|
+
return;
|
|
2527
|
+
}
|
|
2528
|
+
const e = this.state.apply(t), r = !this.state.selection.eq(e.selection);
|
|
2529
|
+
this.emit("beforeTransaction", {
|
|
2530
|
+
editor: this,
|
|
2531
|
+
transaction: t,
|
|
2532
|
+
nextState: e
|
|
2533
|
+
}), this.view.updateState(e), this.emit("transaction", {
|
|
2534
|
+
editor: this,
|
|
2535
|
+
transaction: t
|
|
2536
|
+
}), r && this.emit("selectionUpdate", {
|
|
2537
|
+
editor: this,
|
|
2538
|
+
transaction: t
|
|
2539
|
+
});
|
|
2540
|
+
const o = t.getMeta("focus"), s = t.getMeta("blur");
|
|
2541
|
+
o && this.emit("focus", {
|
|
2542
|
+
editor: this,
|
|
2543
|
+
event: o.event,
|
|
2544
|
+
transaction: t
|
|
2545
|
+
}), s && this.emit("blur", {
|
|
2546
|
+
editor: this,
|
|
2547
|
+
event: s.event,
|
|
2548
|
+
transaction: t
|
|
2549
|
+
}), !(!t.docChanged || t.getMeta("preventUpdate")) && this.emit("update", {
|
|
2550
|
+
editor: this,
|
|
2551
|
+
transaction: t
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Get attributes of the currently selected node or mark.
|
|
2556
|
+
*/
|
|
2557
|
+
getAttributes(t) {
|
|
2558
|
+
return On(this.state, t);
|
|
2559
|
+
}
|
|
2560
|
+
isActive(t, e) {
|
|
2561
|
+
const r = typeof t == "string" ? t : null, o = typeof t == "string" ? e : t;
|
|
2562
|
+
return Bn(this.state, r, o);
|
|
2563
|
+
}
|
|
2564
|
+
/**
|
|
2565
|
+
* Get the document as JSON.
|
|
2566
|
+
*/
|
|
2567
|
+
getJSON() {
|
|
2568
|
+
return this.state.doc.toJSON();
|
|
2569
|
+
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Get the document as HTML.
|
|
2572
|
+
*/
|
|
2573
|
+
getHTML() {
|
|
2574
|
+
return ut(this.state.doc.content, this.schema);
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* Get the document as text.
|
|
2578
|
+
*/
|
|
2579
|
+
getText(t) {
|
|
2580
|
+
const { blockSeparator: e = `
|
|
2581
|
+
|
|
2582
|
+
`, textSerializers: r = {} } = t || {};
|
|
2583
|
+
return An(this.state.doc, {
|
|
2584
|
+
blockSeparator: e,
|
|
2585
|
+
textSerializers: {
|
|
2586
|
+
...Ot(this.schema),
|
|
2587
|
+
...r
|
|
2588
|
+
}
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2591
|
+
/**
|
|
2592
|
+
* Check if there is no content.
|
|
2593
|
+
*/
|
|
2594
|
+
get isEmpty() {
|
|
2595
|
+
return mt(this.state.doc);
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Get the number of characters for the current document.
|
|
2599
|
+
*
|
|
2600
|
+
* @deprecated
|
|
2601
|
+
*/
|
|
2602
|
+
getCharacterCount() {
|
|
2603
|
+
return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'), this.state.doc.content.size - 2;
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
* Destroy the editor.
|
|
2607
|
+
*/
|
|
2608
|
+
destroy() {
|
|
2609
|
+
if (this.emit("destroy"), this.view) {
|
|
2610
|
+
const t = this.view.dom;
|
|
2611
|
+
t && t.editor && delete t.editor, this.view.destroy();
|
|
2612
|
+
}
|
|
2613
|
+
this.removeAllListeners();
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Check if the editor is already destroyed.
|
|
2617
|
+
*/
|
|
2618
|
+
get isDestroyed() {
|
|
2619
|
+
var t;
|
|
2620
|
+
return !(!((t = this.view) === null || t === void 0) && t.docView);
|
|
2621
|
+
}
|
|
2622
|
+
$node(t, e) {
|
|
2623
|
+
var r;
|
|
2624
|
+
return ((r = this.$doc) === null || r === void 0 ? void 0 : r.querySelector(t, e)) || null;
|
|
2625
|
+
}
|
|
2626
|
+
$nodes(t, e) {
|
|
2627
|
+
var r;
|
|
2628
|
+
return ((r = this.$doc) === null || r === void 0 ? void 0 : r.querySelectorAll(t, e)) || null;
|
|
2629
|
+
}
|
|
2630
|
+
$pos(t) {
|
|
2631
|
+
const e = this.state.doc.resolve(t);
|
|
2632
|
+
return new N(e, this);
|
|
2633
|
+
}
|
|
2634
|
+
get $doc() {
|
|
2635
|
+
return this.$pos(0);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
function Sr(n) {
|
|
2639
|
+
return new Z({
|
|
2640
|
+
find: n.find,
|
|
2641
|
+
handler: ({ state: t, range: e, match: r }) => {
|
|
2642
|
+
const o = b(n.getAttributes, void 0, r);
|
|
2643
|
+
if (o === !1 || o === null)
|
|
2644
|
+
return null;
|
|
2645
|
+
const { tr: s } = t, i = r[r.length - 1], c = r[0];
|
|
2646
|
+
if (i) {
|
|
2647
|
+
const a = c.search(/\S/), l = e.from + c.indexOf(i), u = l + i.length;
|
|
2648
|
+
if (Ft(e.from, e.to, t.doc).filter((p) => p.mark.type.excluded.find((h) => h === n.type && h !== p.mark.type)).filter((p) => p.to > l).length)
|
|
2649
|
+
return null;
|
|
2650
|
+
u < e.to && s.delete(u, e.to), l > e.from && s.delete(e.from + a, l);
|
|
2651
|
+
const f = e.from + a + i.length;
|
|
2652
|
+
s.addMark(e.from + a, f, n.type.create(o || {})), s.removeStoredMark(n.type);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
function Er(n) {
|
|
2658
|
+
return new Z({
|
|
2659
|
+
find: n.find,
|
|
2660
|
+
handler: ({ state: t, range: e, match: r }) => {
|
|
2661
|
+
const o = b(n.getAttributes, void 0, r) || {}, { tr: s } = t, i = e.from;
|
|
2662
|
+
let c = e.to;
|
|
2663
|
+
const a = n.type.create(o);
|
|
2664
|
+
if (r[1]) {
|
|
2665
|
+
const l = r[0].lastIndexOf(r[1]);
|
|
2666
|
+
let u = i + l;
|
|
2667
|
+
u > c ? u = c : c = u + r[1].length;
|
|
2668
|
+
const d = r[0][r[0].length - 1];
|
|
2669
|
+
s.insertText(d, i + r[0].length - 1), s.replaceWith(u, c, a);
|
|
2670
|
+
} else if (r[0]) {
|
|
2671
|
+
const l = n.type.isInline ? i : i - 1;
|
|
2672
|
+
s.insert(l, n.type.create(o)).delete(s.mapping.map(i), s.mapping.map(c));
|
|
2673
|
+
}
|
|
2674
|
+
s.scrollIntoView();
|
|
2675
|
+
}
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
function xr(n) {
|
|
2679
|
+
return new Z({
|
|
2680
|
+
find: n.find,
|
|
2681
|
+
handler: ({ state: t, range: e, match: r }) => {
|
|
2682
|
+
const o = t.doc.resolve(e.from), s = b(n.getAttributes, void 0, r) || {};
|
|
2683
|
+
if (!o.node(-1).canReplaceWith(o.index(-1), o.indexAfter(-1), n.type))
|
|
2684
|
+
return null;
|
|
2685
|
+
t.tr.delete(e.from, e.to).setBlockType(e.from, e.from, n.type, s);
|
|
2686
|
+
}
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
function Cr(n) {
|
|
2690
|
+
return new Z({
|
|
2691
|
+
find: n.find,
|
|
2692
|
+
handler: ({ state: t, range: e, match: r, chain: o }) => {
|
|
2693
|
+
const s = b(n.getAttributes, void 0, r) || {}, i = t.tr.delete(e.from, e.to), a = i.doc.resolve(e.from).blockRange(), l = a && Ut(a, n.type, s);
|
|
2694
|
+
if (!l)
|
|
2695
|
+
return null;
|
|
2696
|
+
if (i.wrap(a, l), n.keepMarks && n.editor) {
|
|
2697
|
+
const { selection: d, storedMarks: f } = t, { splittableMarks: p } = n.editor.extensionManager, m = f || d.$to.parentOffset && d.$from.marks();
|
|
2698
|
+
if (m) {
|
|
2699
|
+
const h = m.filter((g) => p.includes(g.type.name));
|
|
2700
|
+
i.ensureMarks(h);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
if (n.keepAttributes) {
|
|
2704
|
+
const d = n.type.name === "bulletList" || n.type.name === "orderedList" ? "listItem" : "taskList";
|
|
2705
|
+
o().updateAttributes(d, s).run();
|
|
2706
|
+
}
|
|
2707
|
+
const u = i.doc.resolve(e.from - 1).nodeBefore;
|
|
2708
|
+
u && u.type === n.type && dt(i.doc, e.from - 1) && (!n.joinPredicate || n.joinPredicate(r, u)) && i.join(e.from - 1);
|
|
2709
|
+
}
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
class lt {
|
|
2713
|
+
constructor(t = {}) {
|
|
2714
|
+
this.type = "node", this.name = "node", this.parent = null, this.child = null, this.config = {
|
|
2715
|
+
name: this.name,
|
|
2716
|
+
defaultOptions: {}
|
|
2717
|
+
}, this.config = {
|
|
2718
|
+
...this.config,
|
|
2719
|
+
...t
|
|
2720
|
+
}, this.name = this.config.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(k(this, "addOptions", {
|
|
2721
|
+
name: this.name
|
|
2722
|
+
}))), this.storage = b(k(this, "addStorage", {
|
|
2723
|
+
name: this.name,
|
|
2724
|
+
options: this.options
|
|
2725
|
+
})) || {};
|
|
2726
|
+
}
|
|
2727
|
+
static create(t = {}) {
|
|
2728
|
+
return new lt(t);
|
|
2729
|
+
}
|
|
2730
|
+
configure(t = {}) {
|
|
2731
|
+
const e = this.extend({
|
|
2732
|
+
...this.config,
|
|
2733
|
+
addOptions: () => tt(this.options, t)
|
|
2734
|
+
});
|
|
2735
|
+
return e.name = this.name, e.parent = this.parent, e;
|
|
2736
|
+
}
|
|
2737
|
+
extend(t = {}) {
|
|
2738
|
+
const e = new lt(t);
|
|
2739
|
+
return e.parent = this, this.child = e, e.name = t.name ? t.name : e.parent.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`), e.options = b(k(e, "addOptions", {
|
|
2740
|
+
name: e.name
|
|
2741
|
+
})), e.storage = b(k(e, "addStorage", {
|
|
2742
|
+
name: e.name,
|
|
2743
|
+
options: e.options
|
|
2744
|
+
})), e;
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
function Tr(n) {
|
|
2748
|
+
return new Ae({
|
|
2749
|
+
find: n.find,
|
|
2750
|
+
handler: ({ state: t, range: e, match: r, pasteEvent: o }) => {
|
|
2751
|
+
const s = b(n.getAttributes, void 0, r, o);
|
|
2752
|
+
if (s === !1 || s === null)
|
|
2753
|
+
return null;
|
|
2754
|
+
const { tr: i } = t, c = r[r.length - 1], a = r[0];
|
|
2755
|
+
let l = e.to;
|
|
2756
|
+
if (c) {
|
|
2757
|
+
const u = a.search(/\S/), d = e.from + a.indexOf(c), f = d + c.length;
|
|
2758
|
+
if (Ft(e.from, e.to, t.doc).filter((m) => m.mark.type.excluded.find((g) => g === n.type && g !== m.mark.type)).filter((m) => m.to > d).length)
|
|
2759
|
+
return null;
|
|
2760
|
+
f < e.to && i.delete(f, e.to), d > e.from && i.delete(e.from + u, d), l = e.from + u + c.length, i.addMark(e.from + u, l, n.type.create(s || {})), i.removeStoredMark(n.type);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
});
|
|
2764
|
+
}
|
|
2765
|
+
function Ar(n, t) {
|
|
2766
|
+
const { selection: e } = n, { $from: r } = e;
|
|
2767
|
+
if (e instanceof J) {
|
|
2768
|
+
const s = r.index();
|
|
2769
|
+
return r.parent.canReplaceWith(s, s + 1, t);
|
|
2770
|
+
}
|
|
2771
|
+
let o = r.depth;
|
|
2772
|
+
for (; o >= 0; ) {
|
|
2773
|
+
const s = r.index(o);
|
|
2774
|
+
if (r.node(o).contentMatchAt(s).matchType(t))
|
|
2775
|
+
return !0;
|
|
2776
|
+
o -= 1;
|
|
2777
|
+
}
|
|
2778
|
+
return !1;
|
|
2779
|
+
}
|
|
2780
|
+
export {
|
|
2781
|
+
Q as CommandManager,
|
|
2782
|
+
Mr as Editor,
|
|
2783
|
+
C as Extension,
|
|
2784
|
+
Z as InputRule,
|
|
2785
|
+
U as Mark,
|
|
2786
|
+
lt as Node,
|
|
2787
|
+
N as NodePos,
|
|
2788
|
+
Ae as PasteRule,
|
|
2789
|
+
b as callOrReturn,
|
|
2790
|
+
Ar as canInsertNode,
|
|
2791
|
+
yr as combineTransactionSteps,
|
|
2792
|
+
Y as createChainableState,
|
|
2793
|
+
at as createDocument,
|
|
2794
|
+
D as createNodeFromContent,
|
|
2795
|
+
lr as createStyleTag,
|
|
2796
|
+
Cn as defaultBlockAt,
|
|
2797
|
+
Mt as deleteProps,
|
|
2798
|
+
W as elementFromString,
|
|
2799
|
+
kr as findChildrenInRange,
|
|
2800
|
+
Be as findDuplicates,
|
|
2801
|
+
ht as findParentNode,
|
|
2802
|
+
Tn as findParentNodeClosestToPos,
|
|
2803
|
+
we as fromString,
|
|
2804
|
+
On as getAttributes,
|
|
2805
|
+
Tt as getAttributesFromExtensions,
|
|
2806
|
+
br as getChangedRanges,
|
|
2807
|
+
k as getExtensionField,
|
|
2808
|
+
ut as getHTMLFromFragment,
|
|
2809
|
+
Rt as getMarkAttributes,
|
|
2810
|
+
pt as getMarkRange,
|
|
2811
|
+
B as getMarkType,
|
|
2812
|
+
Ft as getMarksBetween,
|
|
2813
|
+
Pn as getNodeAttributes,
|
|
2814
|
+
S as getNodeType,
|
|
2815
|
+
it as getRenderedAttributes,
|
|
2816
|
+
Me as getSchemaByResolvedExtensions,
|
|
2817
|
+
rt as getSchemaTypeByName,
|
|
2818
|
+
et as getSchemaTypeNameByName,
|
|
2819
|
+
K as getSplittedAttributes,
|
|
2820
|
+
An as getText,
|
|
2821
|
+
Pt as getTextBetween,
|
|
2822
|
+
Se as getTextContentFromNodes,
|
|
2823
|
+
Ot as getTextSerializersFromSchema,
|
|
2824
|
+
yt as injectExtensionAttributesToParseRule,
|
|
2825
|
+
xe as inputRulesPlugin,
|
|
2826
|
+
Bn as isActive,
|
|
2827
|
+
ve as isEmptyObject,
|
|
2828
|
+
bt as isExtensionRulesEnabled,
|
|
2829
|
+
At as isFunction,
|
|
2830
|
+
St as isList,
|
|
2831
|
+
jt as isMacOS,
|
|
2832
|
+
ct as isMarkActive,
|
|
2833
|
+
L as isNodeActive,
|
|
2834
|
+
mt as isNodeEmpty,
|
|
2835
|
+
vr as isNodeSelection,
|
|
2836
|
+
Te as isNumber,
|
|
2837
|
+
H as isPlainObject,
|
|
2838
|
+
ft as isRegExp,
|
|
2839
|
+
Je as isSafari,
|
|
2840
|
+
$t as isTextSelection,
|
|
2841
|
+
G as isiOS,
|
|
2842
|
+
Sr as markInputRule,
|
|
2843
|
+
Tr as markPasteRule,
|
|
2844
|
+
be as mergeAttributes,
|
|
2845
|
+
tt as mergeDeep,
|
|
2846
|
+
O as minMax,
|
|
2847
|
+
Er as nodeInputRule,
|
|
2848
|
+
q as objectIncludes,
|
|
2849
|
+
$e as pasteRulesPlugin,
|
|
2850
|
+
wr as posToDOMRect,
|
|
2851
|
+
In as removeDuplicates,
|
|
2852
|
+
Bt as resolveFocusPosition,
|
|
2853
|
+
Ze as selectionToInsertionEnd,
|
|
2854
|
+
X as splitExtensions,
|
|
2855
|
+
xr as textblockTypeInputRule,
|
|
2856
|
+
Cr as wrappingInputRule
|
|
2857
|
+
};
|