@cgboiler/biz-basic 1.0.53 → 1.0.55
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/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/rich-text-editor/RichTextEditor.d.ts +14 -5
- package/es/rich-text-editor/RichTextEditor.js +76 -196
- package/es/rich-text-editor/_atomic.css +2 -1
- package/es/rich-text-editor/extensions/ConsumedTrigger.d.ts +8 -0
- package/es/rich-text-editor/extensions/ConsumedTrigger.js +22 -0
- package/es/rich-text-editor/extensions/CustomContent.d.ts +5 -0
- package/es/rich-text-editor/extensions/CustomContent.js +103 -0
- package/es/rich-text-editor/extensions/HashTag.d.ts +15 -0
- package/es/rich-text-editor/extensions/HashTag.js +133 -0
- package/es/rich-text-editor/extensions/HorizontalRule.d.ts +2 -0
- package/es/rich-text-editor/extensions/HorizontalRule.js +16 -0
- package/es/rich-text-editor/extensions/IMEComposition.d.ts +16 -0
- package/es/rich-text-editor/extensions/IMEComposition.js +30 -0
- package/es/rich-text-editor/extensions/ImageUpload.d.ts +56 -0
- package/es/rich-text-editor/extensions/ImageUpload.js +80 -0
- package/es/rich-text-editor/extensions/MarkdownExtensions.d.ts +15 -0
- package/es/rich-text-editor/extensions/MarkdownExtensions.js +35 -0
- package/es/rich-text-editor/extensions/MediaInputRules.d.ts +17 -0
- package/es/rich-text-editor/extensions/MediaInputRules.js +47 -0
- package/es/rich-text-editor/extensions/MentionExtension.d.ts +15 -0
- package/es/rich-text-editor/extensions/MentionExtension.js +60 -0
- package/es/rich-text-editor/extensions/index.d.ts +16 -0
- package/es/rich-text-editor/extensions/index.js +20 -0
- package/es/rich-text-editor/hooks/index.d.ts +6 -0
- package/es/rich-text-editor/hooks/index.js +4 -0
- package/es/rich-text-editor/hooks/useEditorHistory.d.ts +17 -0
- package/es/rich-text-editor/hooks/useEditorHistory.js +87 -0
- package/es/rich-text-editor/index copy 2.css +1 -0
- package/es/rich-text-editor/index copy 2.less +598 -0
- package/es/rich-text-editor/index copy.css +1 -0
- package/es/rich-text-editor/index copy.less +356 -0
- package/es/rich-text-editor/index.css +1 -1
- package/es/rich-text-editor/index.less +444 -254
- package/es/rich-text-editor/lib/utils.d.ts +123 -0
- package/es/rich-text-editor/lib/utils.js +244 -0
- package/es/rich-text-editor/menu-system/components/_atomic.css +44 -0
- package/es/rich-text-editor/menu-system/components/blockquote-button.d.ts +49 -0
- package/es/rich-text-editor/menu-system/components/blockquote-button.js +75 -0
- package/es/rich-text-editor/menu-system/components/code-block-button.d.ts +49 -0
- package/es/rich-text-editor/menu-system/components/code-block-button.js +75 -0
- package/es/rich-text-editor/menu-system/components/color-highlight-button.d.ts +61 -0
- package/es/rich-text-editor/menu-system/components/color-highlight-button.js +102 -0
- package/es/rich-text-editor/menu-system/components/color-highlight-popover.d.ts +32 -0
- package/es/rich-text-editor/menu-system/components/color-highlight-popover.js +99 -0
- package/es/rich-text-editor/menu-system/components/heading-dropdown-menu.d.ts +43 -0
- package/es/rich-text-editor/menu-system/components/heading-dropdown-menu.js +102 -0
- package/es/rich-text-editor/menu-system/components/horizontal-rule-button.d.ts +22 -0
- package/es/rich-text-editor/menu-system/components/horizontal-rule-button.js +42 -0
- package/es/rich-text-editor/menu-system/components/image-upload-button.d.ts +40 -0
- package/es/rich-text-editor/menu-system/components/image-upload-button.js +71 -0
- package/es/rich-text-editor/menu-system/components/image-upload-node.d.ts +93 -0
- package/es/rich-text-editor/menu-system/components/image-upload-node.js +299 -0
- package/es/rich-text-editor/menu-system/components/link-popover.d.ts +32 -0
- package/es/rich-text-editor/menu-system/components/link-popover.js +127 -0
- package/es/rich-text-editor/menu-system/components/list-button.d.ts +40 -0
- package/es/rich-text-editor/menu-system/components/list-button.js +69 -0
- package/es/rich-text-editor/menu-system/components/list-dropdown-menu.d.ts +41 -0
- package/es/rich-text-editor/menu-system/components/list-dropdown-menu.js +97 -0
- package/es/rich-text-editor/menu-system/components/mark-button.d.ts +58 -0
- package/es/rich-text-editor/menu-system/components/mark-button.js +80 -0
- package/es/rich-text-editor/menu-system/components/text-align-button.d.ts +58 -0
- package/es/rich-text-editor/menu-system/components/text-align-button.js +80 -0
- package/es/rich-text-editor/menu-system/components/undo-redo-button.d.ts +58 -0
- package/es/rich-text-editor/menu-system/components/undo-redo-button.js +77 -0
- package/es/rich-text-editor/menu-system/hooks/use-blockquote.d.ts +34 -0
- package/es/rich-text-editor/menu-system/hooks/use-blockquote.js +140 -0
- package/es/rich-text-editor/menu-system/hooks/use-code-block.d.ts +34 -0
- package/es/rich-text-editor/menu-system/hooks/use-code-block.js +140 -0
- package/es/rich-text-editor/menu-system/hooks/use-color-highlight.d.ts +46 -0
- package/es/rich-text-editor/menu-system/hooks/use-color-highlight.js +166 -0
- package/es/rich-text-editor/menu-system/hooks/use-cursor-visibility.d.ts +7 -0
- package/es/rich-text-editor/menu-system/hooks/use-cursor-visibility.js +46 -0
- package/es/rich-text-editor/menu-system/hooks/use-element-rect.d.ts +10 -0
- package/es/rich-text-editor/menu-system/hooks/use-element-rect.js +132 -0
- package/es/rich-text-editor/menu-system/hooks/use-file-upload.d.ts +94 -0
- package/es/rich-text-editor/menu-system/hooks/use-file-upload.js +135 -0
- package/es/rich-text-editor/menu-system/hooks/use-heading-dropdown-menu.d.ts +41 -0
- package/es/rich-text-editor/menu-system/hooks/use-heading-dropdown-menu.js +70 -0
- package/es/rich-text-editor/menu-system/hooks/use-heading.d.ts +26 -0
- package/es/rich-text-editor/menu-system/hooks/use-heading.js +166 -0
- package/es/rich-text-editor/menu-system/hooks/use-image-upload.d.ts +35 -0
- package/es/rich-text-editor/menu-system/hooks/use-image-upload.js +103 -0
- package/es/rich-text-editor/menu-system/hooks/use-link-popover.d.ts +10 -0
- package/es/rich-text-editor/menu-system/hooks/use-link-popover.js +62 -0
- package/es/rich-text-editor/menu-system/hooks/use-list-dropdown-menu.d.ts +34 -0
- package/es/rich-text-editor/menu-system/hooks/use-list-dropdown-menu.js +121 -0
- package/es/rich-text-editor/menu-system/hooks/use-list.d.ts +28 -0
- package/es/rich-text-editor/menu-system/hooks/use-list.js +191 -0
- package/es/rich-text-editor/menu-system/hooks/use-mark.d.ts +22 -0
- package/es/rich-text-editor/menu-system/hooks/use-mark.js +109 -0
- package/es/rich-text-editor/menu-system/hooks/use-menu-navigation.d.ts +16 -0
- package/es/rich-text-editor/menu-system/hooks/use-menu-navigation.js +134 -0
- package/es/rich-text-editor/menu-system/hooks/use-mobile.d.ts +1 -0
- package/es/rich-text-editor/menu-system/hooks/use-mobile.js +20 -0
- package/es/rich-text-editor/menu-system/hooks/use-text-align.d.ts +28 -0
- package/es/rich-text-editor/menu-system/hooks/use-text-align.js +113 -0
- package/es/rich-text-editor/menu-system/hooks/use-throttled-callback.d.ts +8 -0
- package/es/rich-text-editor/menu-system/hooks/use-throttled-callback.js +45 -0
- package/es/rich-text-editor/menu-system/hooks/use-undo-redo.d.ts +60 -0
- package/es/rich-text-editor/menu-system/hooks/use-undo-redo.js +96 -0
- package/es/rich-text-editor/menu-system/hooks/use-window-size.d.ts +21 -0
- package/es/rich-text-editor/menu-system/hooks/use-window-size.js +74 -0
- package/es/rich-text-editor/menu-system/icons/_atomic.css +32 -0
- package/es/rich-text-editor/menu-system/icons/index.d.ts +546 -0
- package/es/rich-text-editor/menu-system/icons/index.js +487 -0
- package/es/rich-text-editor/menu-system/primitives/_atomic.css +38 -0
- package/es/rich-text-editor/menu-system/primitives/button.d.ts +110 -0
- package/es/rich-text-editor/menu-system/primitives/button.js +107 -0
- package/es/rich-text-editor/menu-system/primitives/card.d.ts +75 -0
- package/es/rich-text-editor/menu-system/primitives/card.js +116 -0
- package/es/rich-text-editor/menu-system/primitives/input.d.ts +37 -0
- package/es/rich-text-editor/menu-system/primitives/input.js +55 -0
- package/es/rich-text-editor/menu-system/primitives/separator.d.ts +34 -0
- package/es/rich-text-editor/menu-system/primitives/separator.js +42 -0
- package/es/rich-text-editor/menu-system/primitives/toolbar.d.ts +39 -0
- package/es/rich-text-editor/menu-system/primitives/toolbar.js +149 -0
- package/es/rich-text-editor/menu-system/styles/animations.css +1 -0
- package/es/rich-text-editor/menu-system/styles/animations.less +91 -0
- package/es/rich-text-editor/menu-system/styles/button-colors.css +1 -0
- package/es/rich-text-editor/menu-system/styles/button-colors.less +142 -0
- package/es/rich-text-editor/menu-system/styles/button-group.css +1 -0
- package/es/rich-text-editor/menu-system/styles/button-group.less +23 -0
- package/es/rich-text-editor/menu-system/styles/button.css +1 -0
- package/es/rich-text-editor/menu-system/styles/button.less +322 -0
- package/es/rich-text-editor/menu-system/styles/card.css +1 -0
- package/es/rich-text-editor/menu-system/styles/card.less +78 -0
- package/es/rich-text-editor/menu-system/styles/color-highlight-button.css +1 -0
- package/es/rich-text-editor/menu-system/styles/color-highlight-button.less +57 -0
- package/es/rich-text-editor/menu-system/styles/color-highlight-popover.css +1 -0
- package/es/rich-text-editor/menu-system/styles/color-highlight-popover.less +51 -0
- package/es/rich-text-editor/menu-system/styles/dropdown-menu.css +1 -0
- package/es/rich-text-editor/menu-system/styles/dropdown-menu.less +40 -0
- package/es/rich-text-editor/menu-system/styles/image-upload-node.css +1 -0
- package/es/rich-text-editor/menu-system/styles/image-upload-node.less +240 -0
- package/es/rich-text-editor/menu-system/styles/input.css +1 -0
- package/es/rich-text-editor/menu-system/styles/input.less +53 -0
- package/es/rich-text-editor/menu-system/styles/link-popover.css +1 -0
- package/es/rich-text-editor/menu-system/styles/link-popover.less +32 -0
- package/es/rich-text-editor/menu-system/styles/separator.css +1 -0
- package/es/rich-text-editor/menu-system/styles/separator.less +26 -0
- package/es/rich-text-editor/menu-system/styles/simple-editor.css +1 -0
- package/es/rich-text-editor/menu-system/styles/simple-editor.less +39 -0
- package/es/rich-text-editor/menu-system/styles/toolbar.css +1 -0
- package/es/rich-text-editor/menu-system/styles/toolbar.less +87 -0
- package/es/rich-text-editor/menu-system/styles/variables.css +1 -0
- package/es/rich-text-editor/menu-system/styles/variables.less +296 -0
- package/es/rich-text-editor/menu-system/utils/tiptap-utils.d.ts +122 -0
- package/es/rich-text-editor/menu-system/utils/tiptap-utils.js +243 -0
- package/es/rich-text-editor/types.d.ts +4 -0
- package/es/rich-text-editor/types.js +4 -0
- package/es/rich-text-editor/useExtensions.d.ts +3 -3
- package/es/rich-text-editor/useExtensions.js +63 -428
- package/es/rich-text-editor/utils/eventHandlers.d.ts +37 -0
- package/es/rich-text-editor/utils/eventHandlers.js +103 -0
- package/es/rich-text-editor/utils/index.d.ts +6 -0
- package/es/rich-text-editor/utils/index.js +19 -0
- package/es/rich-text-editor/utils/triggerHelpers.d.ts +31 -0
- package/es/rich-text-editor/utils/triggerHelpers.js +46 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/rich-text-editor/RichTextEditor.d.ts +14 -5
- package/lib/rich-text-editor/RichTextEditor.js +76 -206
- package/lib/rich-text-editor/_atomic.css +2 -1
- package/lib/rich-text-editor/extensions/ConsumedTrigger.d.ts +8 -0
- package/lib/rich-text-editor/extensions/ConsumedTrigger.js +41 -0
- package/lib/rich-text-editor/extensions/CustomContent.d.ts +5 -0
- package/lib/rich-text-editor/extensions/CustomContent.js +132 -0
- package/lib/rich-text-editor/extensions/HashTag.d.ts +15 -0
- package/lib/rich-text-editor/extensions/HashTag.js +157 -0
- package/lib/rich-text-editor/extensions/HorizontalRule.d.ts +2 -0
- package/lib/rich-text-editor/extensions/HorizontalRule.js +45 -0
- package/lib/rich-text-editor/extensions/IMEComposition.d.ts +16 -0
- package/lib/rich-text-editor/extensions/IMEComposition.js +49 -0
- package/lib/rich-text-editor/extensions/ImageUpload.d.ts +56 -0
- package/lib/rich-text-editor/extensions/ImageUpload.js +99 -0
- package/lib/rich-text-editor/extensions/MarkdownExtensions.d.ts +15 -0
- package/lib/rich-text-editor/extensions/MarkdownExtensions.js +54 -0
- package/lib/rich-text-editor/extensions/MediaInputRules.d.ts +17 -0
- package/lib/rich-text-editor/extensions/MediaInputRules.js +66 -0
- package/lib/rich-text-editor/extensions/MentionExtension.d.ts +15 -0
- package/lib/rich-text-editor/extensions/MentionExtension.js +89 -0
- package/lib/rich-text-editor/extensions/index.d.ts +16 -0
- package/lib/rich-text-editor/extensions/index.js +49 -0
- package/lib/rich-text-editor/hooks/index.d.ts +6 -0
- package/lib/rich-text-editor/hooks/index.js +23 -0
- package/lib/rich-text-editor/hooks/useEditorHistory.d.ts +17 -0
- package/lib/rich-text-editor/hooks/useEditorHistory.js +116 -0
- package/lib/rich-text-editor/index copy 2.css +1 -0
- package/lib/rich-text-editor/index copy 2.less +598 -0
- package/lib/rich-text-editor/index copy.css +1 -0
- package/lib/rich-text-editor/index copy.less +356 -0
- package/lib/rich-text-editor/index.css +1 -1
- package/lib/rich-text-editor/index.less +444 -254
- package/lib/rich-text-editor/lib/utils.d.ts +123 -0
- package/lib/rich-text-editor/lib/utils.js +263 -0
- package/lib/rich-text-editor/menu-system/components/_atomic.css +44 -0
- package/lib/rich-text-editor/menu-system/components/blockquote-button.d.ts +49 -0
- package/lib/rich-text-editor/menu-system/components/blockquote-button.js +94 -0
- package/lib/rich-text-editor/menu-system/components/code-block-button.d.ts +49 -0
- package/lib/rich-text-editor/menu-system/components/code-block-button.js +94 -0
- package/lib/rich-text-editor/menu-system/components/color-highlight-button.d.ts +61 -0
- package/lib/rich-text-editor/menu-system/components/color-highlight-button.js +119 -0
- package/lib/rich-text-editor/menu-system/components/color-highlight-popover.d.ts +32 -0
- package/lib/rich-text-editor/menu-system/components/color-highlight-popover.js +118 -0
- package/lib/rich-text-editor/menu-system/components/heading-dropdown-menu.d.ts +43 -0
- package/lib/rich-text-editor/menu-system/components/heading-dropdown-menu.js +131 -0
- package/lib/rich-text-editor/menu-system/components/horizontal-rule-button.d.ts +22 -0
- package/lib/rich-text-editor/menu-system/components/horizontal-rule-button.js +61 -0
- package/lib/rich-text-editor/menu-system/components/image-upload-button.d.ts +40 -0
- package/lib/rich-text-editor/menu-system/components/image-upload-button.js +90 -0
- package/lib/rich-text-editor/menu-system/components/image-upload-node.d.ts +93 -0
- package/lib/rich-text-editor/menu-system/components/image-upload-node.js +316 -0
- package/lib/rich-text-editor/menu-system/components/link-popover.d.ts +32 -0
- package/lib/rich-text-editor/menu-system/components/link-popover.js +146 -0
- package/lib/rich-text-editor/menu-system/components/list-button.d.ts +40 -0
- package/lib/rich-text-editor/menu-system/components/list-button.js +88 -0
- package/lib/rich-text-editor/menu-system/components/list-dropdown-menu.d.ts +41 -0
- package/lib/rich-text-editor/menu-system/components/list-dropdown-menu.js +116 -0
- package/lib/rich-text-editor/menu-system/components/mark-button.d.ts +58 -0
- package/lib/rich-text-editor/menu-system/components/mark-button.js +99 -0
- package/lib/rich-text-editor/menu-system/components/text-align-button.d.ts +58 -0
- package/lib/rich-text-editor/menu-system/components/text-align-button.js +99 -0
- package/lib/rich-text-editor/menu-system/components/undo-redo-button.d.ts +58 -0
- package/lib/rich-text-editor/menu-system/components/undo-redo-button.js +96 -0
- package/lib/rich-text-editor/menu-system/hooks/use-blockquote.d.ts +34 -0
- package/lib/rich-text-editor/menu-system/hooks/use-blockquote.js +154 -0
- package/lib/rich-text-editor/menu-system/hooks/use-code-block.d.ts +34 -0
- package/lib/rich-text-editor/menu-system/hooks/use-code-block.js +154 -0
- package/lib/rich-text-editor/menu-system/hooks/use-color-highlight.d.ts +46 -0
- package/lib/rich-text-editor/menu-system/hooks/use-color-highlight.js +185 -0
- package/lib/rich-text-editor/menu-system/hooks/use-cursor-visibility.d.ts +7 -0
- package/lib/rich-text-editor/menu-system/hooks/use-cursor-visibility.js +65 -0
- package/lib/rich-text-editor/menu-system/hooks/use-element-rect.d.ts +10 -0
- package/lib/rich-text-editor/menu-system/hooks/use-element-rect.js +149 -0
- package/lib/rich-text-editor/menu-system/hooks/use-file-upload.d.ts +94 -0
- package/lib/rich-text-editor/menu-system/hooks/use-file-upload.js +154 -0
- package/lib/rich-text-editor/menu-system/hooks/use-heading-dropdown-menu.d.ts +41 -0
- package/lib/rich-text-editor/menu-system/hooks/use-heading-dropdown-menu.js +84 -0
- package/lib/rich-text-editor/menu-system/hooks/use-heading.d.ts +26 -0
- package/lib/rich-text-editor/menu-system/hooks/use-heading.js +190 -0
- package/lib/rich-text-editor/menu-system/hooks/use-image-upload.d.ts +35 -0
- package/lib/rich-text-editor/menu-system/hooks/use-image-upload.js +122 -0
- package/lib/rich-text-editor/menu-system/hooks/use-link-popover.d.ts +10 -0
- package/lib/rich-text-editor/menu-system/hooks/use-link-popover.js +81 -0
- package/lib/rich-text-editor/menu-system/hooks/use-list-dropdown-menu.d.ts +34 -0
- package/lib/rich-text-editor/menu-system/hooks/use-list-dropdown-menu.js +140 -0
- package/lib/rich-text-editor/menu-system/hooks/use-list.d.ts +28 -0
- package/lib/rich-text-editor/menu-system/hooks/use-list.js +205 -0
- package/lib/rich-text-editor/menu-system/hooks/use-mark.d.ts +22 -0
- package/lib/rich-text-editor/menu-system/hooks/use-mark.js +138 -0
- package/lib/rich-text-editor/menu-system/hooks/use-menu-navigation.d.ts +16 -0
- package/lib/rich-text-editor/menu-system/hooks/use-menu-navigation.js +153 -0
- package/lib/rich-text-editor/menu-system/hooks/use-mobile.d.ts +1 -0
- package/lib/rich-text-editor/menu-system/hooks/use-mobile.js +39 -0
- package/lib/rich-text-editor/menu-system/hooks/use-text-align.d.ts +28 -0
- package/lib/rich-text-editor/menu-system/hooks/use-text-align.js +132 -0
- package/lib/rich-text-editor/menu-system/hooks/use-throttled-callback.d.ts +8 -0
- package/lib/rich-text-editor/menu-system/hooks/use-throttled-callback.js +64 -0
- package/lib/rich-text-editor/menu-system/hooks/use-undo-redo.d.ts +60 -0
- package/lib/rich-text-editor/menu-system/hooks/use-undo-redo.js +115 -0
- package/lib/rich-text-editor/menu-system/hooks/use-window-size.d.ts +21 -0
- package/lib/rich-text-editor/menu-system/hooks/use-window-size.js +93 -0
- package/lib/rich-text-editor/menu-system/icons/_atomic.css +32 -0
- package/lib/rich-text-editor/menu-system/icons/index.d.ts +546 -0
- package/lib/rich-text-editor/menu-system/icons/index.js +506 -0
- package/lib/rich-text-editor/menu-system/primitives/_atomic.css +38 -0
- package/lib/rich-text-editor/menu-system/primitives/button.d.ts +110 -0
- package/lib/rich-text-editor/menu-system/primitives/button.js +126 -0
- package/lib/rich-text-editor/menu-system/primitives/card.d.ts +75 -0
- package/lib/rich-text-editor/menu-system/primitives/card.js +135 -0
- package/lib/rich-text-editor/menu-system/primitives/input.d.ts +37 -0
- package/lib/rich-text-editor/menu-system/primitives/input.js +74 -0
- package/lib/rich-text-editor/menu-system/primitives/separator.d.ts +34 -0
- package/lib/rich-text-editor/menu-system/primitives/separator.js +61 -0
- package/lib/rich-text-editor/menu-system/primitives/toolbar.d.ts +39 -0
- package/lib/rich-text-editor/menu-system/primitives/toolbar.js +168 -0
- package/lib/rich-text-editor/menu-system/styles/animations.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/animations.less +91 -0
- package/lib/rich-text-editor/menu-system/styles/button-colors.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/button-colors.less +142 -0
- package/lib/rich-text-editor/menu-system/styles/button-group.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/button-group.less +23 -0
- package/lib/rich-text-editor/menu-system/styles/button.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/button.less +322 -0
- package/lib/rich-text-editor/menu-system/styles/card.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/card.less +78 -0
- package/lib/rich-text-editor/menu-system/styles/color-highlight-button.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/color-highlight-button.less +57 -0
- package/lib/rich-text-editor/menu-system/styles/color-highlight-popover.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/color-highlight-popover.less +51 -0
- package/lib/rich-text-editor/menu-system/styles/dropdown-menu.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/dropdown-menu.less +40 -0
- package/lib/rich-text-editor/menu-system/styles/image-upload-node.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/image-upload-node.less +240 -0
- package/lib/rich-text-editor/menu-system/styles/input.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/input.less +53 -0
- package/lib/rich-text-editor/menu-system/styles/link-popover.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/link-popover.less +32 -0
- package/lib/rich-text-editor/menu-system/styles/separator.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/separator.less +26 -0
- package/lib/rich-text-editor/menu-system/styles/simple-editor.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/simple-editor.less +39 -0
- package/lib/rich-text-editor/menu-system/styles/toolbar.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/toolbar.less +87 -0
- package/lib/rich-text-editor/menu-system/styles/variables.css +1 -0
- package/lib/rich-text-editor/menu-system/styles/variables.less +296 -0
- package/lib/rich-text-editor/menu-system/utils/tiptap-utils.d.ts +122 -0
- package/lib/rich-text-editor/menu-system/utils/tiptap-utils.js +262 -0
- package/lib/rich-text-editor/types.d.ts +4 -0
- package/lib/rich-text-editor/types.js +4 -0
- package/lib/rich-text-editor/useExtensions.d.ts +3 -3
- package/lib/rich-text-editor/useExtensions.js +64 -429
- package/lib/rich-text-editor/utils/eventHandlers.d.ts +37 -0
- package/lib/rich-text-editor/utils/eventHandlers.js +132 -0
- package/lib/rich-text-editor/utils/index.d.ts +6 -0
- package/lib/rich-text-editor/utils/index.js +32 -0
- package/lib/rich-text-editor/utils/triggerHelpers.d.ts +31 -0
- package/lib/rich-text-editor/utils/triggerHelpers.js +65 -0
- package/package.json +13 -3
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ref, watch, onBeforeUnmount } from "vue";
|
|
2
|
+
import { NodeSelection, TextSelection } from "@tiptap/pm/state";
|
|
3
|
+
import {
|
|
4
|
+
findNodePosition,
|
|
5
|
+
isNodeInSchema,
|
|
6
|
+
isNodeTypeSelected,
|
|
7
|
+
isValidPosition
|
|
8
|
+
} from "../utils/tiptap-utils";
|
|
9
|
+
import { BlockquoteIcon } from "../icons";
|
|
10
|
+
const BLOCKQUOTE_SHORTCUT_KEY = "mod+shift+b";
|
|
11
|
+
function canToggleBlockquote(editor, turnInto = true) {
|
|
12
|
+
var _a;
|
|
13
|
+
if (!editor || !editor.isEditable)
|
|
14
|
+
return false;
|
|
15
|
+
if (!isNodeInSchema("blockquote", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
16
|
+
return false;
|
|
17
|
+
if (!turnInto) {
|
|
18
|
+
return editor.can().toggleWrap("blockquote");
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const view = editor.view;
|
|
22
|
+
const state = view.state;
|
|
23
|
+
const selection = state.selection;
|
|
24
|
+
if (selection.empty || selection instanceof TextSelection) {
|
|
25
|
+
const pos = (_a = findNodePosition({
|
|
26
|
+
editor,
|
|
27
|
+
node: state.selection.$anchor.node(1)
|
|
28
|
+
})) == null ? void 0 : _a.pos;
|
|
29
|
+
if (!isValidPosition(pos))
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function toggleBlockquote(editor) {
|
|
38
|
+
var _a;
|
|
39
|
+
if (!editor || !editor.isEditable)
|
|
40
|
+
return false;
|
|
41
|
+
if (!canToggleBlockquote(editor))
|
|
42
|
+
return false;
|
|
43
|
+
try {
|
|
44
|
+
const view = editor.view;
|
|
45
|
+
let state = view.state;
|
|
46
|
+
let tr = state.tr;
|
|
47
|
+
if (state.selection.empty || state.selection instanceof TextSelection) {
|
|
48
|
+
const pos = (_a = findNodePosition({
|
|
49
|
+
editor,
|
|
50
|
+
node: state.selection.$anchor.node(1)
|
|
51
|
+
})) == null ? void 0 : _a.pos;
|
|
52
|
+
if (!isValidPosition(pos))
|
|
53
|
+
return false;
|
|
54
|
+
tr = tr.setSelection(NodeSelection.create(state.doc, pos));
|
|
55
|
+
view.dispatch(tr);
|
|
56
|
+
state = view.state;
|
|
57
|
+
}
|
|
58
|
+
const selection = state.selection;
|
|
59
|
+
let chain = editor.chain().focus();
|
|
60
|
+
if (selection instanceof NodeSelection) {
|
|
61
|
+
chain = chain.clearNodes();
|
|
62
|
+
}
|
|
63
|
+
const toggle = editor.isActive("blockquote") ? chain.lift("blockquote") : chain.wrapIn("blockquote");
|
|
64
|
+
toggle.run();
|
|
65
|
+
editor.chain().focus().selectTextblockEnd().run();
|
|
66
|
+
return true;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function shouldShowButton(props) {
|
|
72
|
+
const { editor, hideWhenUnavailable } = props;
|
|
73
|
+
if (!editor || !editor.isEditable)
|
|
74
|
+
return false;
|
|
75
|
+
if (!isNodeInSchema("blockquote", editor))
|
|
76
|
+
return false;
|
|
77
|
+
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
78
|
+
return canToggleBlockquote(editor);
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
function useBlockquote(config) {
|
|
83
|
+
const { hideWhenUnavailable = false, onToggled } = config;
|
|
84
|
+
const isVisible = ref(true);
|
|
85
|
+
const isActive = ref(false);
|
|
86
|
+
const canToggle = ref(false);
|
|
87
|
+
const getEditor = () => {
|
|
88
|
+
const editor = config.editor;
|
|
89
|
+
return editor && "value" in editor ? editor.value : editor;
|
|
90
|
+
};
|
|
91
|
+
const updateState = () => {
|
|
92
|
+
const editor = getEditor();
|
|
93
|
+
if (!editor || !editor.isEditable) {
|
|
94
|
+
isVisible.value = false;
|
|
95
|
+
isActive.value = false;
|
|
96
|
+
canToggle.value = false;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
isActive.value = editor.isActive("blockquote");
|
|
100
|
+
canToggle.value = canToggleBlockquote(editor);
|
|
101
|
+
isVisible.value = shouldShowButton({ editor, hideWhenUnavailable });
|
|
102
|
+
};
|
|
103
|
+
watch(
|
|
104
|
+
() => getEditor(),
|
|
105
|
+
(editor) => {
|
|
106
|
+
if (!editor)
|
|
107
|
+
return;
|
|
108
|
+
updateState();
|
|
109
|
+
editor.on("selectionUpdate", updateState);
|
|
110
|
+
editor.on("transaction", updateState);
|
|
111
|
+
onBeforeUnmount(() => {
|
|
112
|
+
editor.off("selectionUpdate", updateState);
|
|
113
|
+
editor.off("transaction", updateState);
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
{ immediate: true }
|
|
117
|
+
);
|
|
118
|
+
const handleToggle = () => {
|
|
119
|
+
const editor = getEditor();
|
|
120
|
+
if (toggleBlockquote(editor)) {
|
|
121
|
+
onToggled == null ? void 0 : onToggled();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
isVisible,
|
|
126
|
+
isActive,
|
|
127
|
+
handleToggle,
|
|
128
|
+
canToggle,
|
|
129
|
+
label: "Blockquote",
|
|
130
|
+
shortcutKeys: BLOCKQUOTE_SHORTCUT_KEY,
|
|
131
|
+
Icon: BlockquoteIcon
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
BLOCKQUOTE_SHORTCUT_KEY,
|
|
136
|
+
canToggleBlockquote,
|
|
137
|
+
shouldShowButton,
|
|
138
|
+
toggleBlockquote,
|
|
139
|
+
useBlockquote
|
|
140
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/vue-3';
|
|
2
|
+
export declare const CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
3
|
+
export interface UseCodeBlockConfig {
|
|
4
|
+
editor: any;
|
|
5
|
+
hideWhenUnavailable?: boolean;
|
|
6
|
+
onToggled?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function canToggle(editor: Editor | null, turnInto?: boolean): boolean;
|
|
9
|
+
export declare function toggleCodeBlock(editor: Editor | null): boolean;
|
|
10
|
+
export declare function shouldShowButton(props: {
|
|
11
|
+
editor: Editor | null;
|
|
12
|
+
hideWhenUnavailable: boolean;
|
|
13
|
+
}): boolean;
|
|
14
|
+
export declare function useCodeBlock(config: UseCodeBlockConfig): {
|
|
15
|
+
isVisible: import("vue").Ref<boolean, boolean>;
|
|
16
|
+
isActive: import("vue").Ref<boolean, boolean>;
|
|
17
|
+
handleToggle: () => void;
|
|
18
|
+
canToggle: import("vue").Ref<boolean, boolean>;
|
|
19
|
+
label: string;
|
|
20
|
+
shortcutKeys: string;
|
|
21
|
+
Icon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
22
|
+
className: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
27
|
+
className: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
}>> & Readonly<{}>, {
|
|
32
|
+
className: string;
|
|
33
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ref, watch, onBeforeUnmount } from "vue";
|
|
2
|
+
import { NodeSelection, TextSelection } from "@tiptap/pm/state";
|
|
3
|
+
import {
|
|
4
|
+
findNodePosition,
|
|
5
|
+
isNodeInSchema,
|
|
6
|
+
isNodeTypeSelected,
|
|
7
|
+
isValidPosition
|
|
8
|
+
} from "../utils/tiptap-utils";
|
|
9
|
+
import { CodeBlockIcon } from "../icons";
|
|
10
|
+
const CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
11
|
+
function canToggle(editor, turnInto = true) {
|
|
12
|
+
var _a;
|
|
13
|
+
if (!editor || !editor.isEditable)
|
|
14
|
+
return false;
|
|
15
|
+
if (!isNodeInSchema("codeBlock", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
16
|
+
return false;
|
|
17
|
+
if (!turnInto) {
|
|
18
|
+
return editor.can().toggleNode("codeBlock", "paragraph");
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const view = editor.view;
|
|
22
|
+
const state = view.state;
|
|
23
|
+
const selection = state.selection;
|
|
24
|
+
if (selection.empty || selection instanceof TextSelection) {
|
|
25
|
+
const pos = (_a = findNodePosition({
|
|
26
|
+
editor,
|
|
27
|
+
node: state.selection.$anchor.node(1)
|
|
28
|
+
})) == null ? void 0 : _a.pos;
|
|
29
|
+
if (!isValidPosition(pos))
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function toggleCodeBlock(editor) {
|
|
38
|
+
var _a;
|
|
39
|
+
if (!editor || !editor.isEditable)
|
|
40
|
+
return false;
|
|
41
|
+
if (!canToggle(editor))
|
|
42
|
+
return false;
|
|
43
|
+
try {
|
|
44
|
+
const view = editor.view;
|
|
45
|
+
let state = view.state;
|
|
46
|
+
let tr = state.tr;
|
|
47
|
+
if (state.selection.empty || state.selection instanceof TextSelection) {
|
|
48
|
+
const pos = (_a = findNodePosition({
|
|
49
|
+
editor,
|
|
50
|
+
node: state.selection.$anchor.node(1)
|
|
51
|
+
})) == null ? void 0 : _a.pos;
|
|
52
|
+
if (!isValidPosition(pos))
|
|
53
|
+
return false;
|
|
54
|
+
tr = tr.setSelection(NodeSelection.create(state.doc, pos));
|
|
55
|
+
view.dispatch(tr);
|
|
56
|
+
state = view.state;
|
|
57
|
+
}
|
|
58
|
+
const selection = state.selection;
|
|
59
|
+
let chain = editor.chain().focus();
|
|
60
|
+
if (selection instanceof NodeSelection) {
|
|
61
|
+
chain = chain.clearNodes();
|
|
62
|
+
}
|
|
63
|
+
const toggle = editor.isActive("codeBlock") ? chain.setNode("paragraph") : chain.toggleNode("codeBlock", "paragraph");
|
|
64
|
+
toggle.run();
|
|
65
|
+
editor.chain().focus().selectTextblockEnd().run();
|
|
66
|
+
return true;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function shouldShowButton(props) {
|
|
72
|
+
const { editor, hideWhenUnavailable } = props;
|
|
73
|
+
if (!editor || !editor.isEditable)
|
|
74
|
+
return false;
|
|
75
|
+
if (!isNodeInSchema("codeBlock", editor))
|
|
76
|
+
return false;
|
|
77
|
+
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
78
|
+
return canToggle(editor);
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
function useCodeBlock(config) {
|
|
83
|
+
const { hideWhenUnavailable = false, onToggled } = config;
|
|
84
|
+
const isVisible = ref(true);
|
|
85
|
+
const isActive = ref(false);
|
|
86
|
+
const canToggleState = ref(false);
|
|
87
|
+
const getEditor = () => {
|
|
88
|
+
const editor = config.editor;
|
|
89
|
+
return editor && "value" in editor ? editor.value : editor;
|
|
90
|
+
};
|
|
91
|
+
const updateState = () => {
|
|
92
|
+
const editor = getEditor();
|
|
93
|
+
if (!editor || !editor.isEditable) {
|
|
94
|
+
isVisible.value = false;
|
|
95
|
+
isActive.value = false;
|
|
96
|
+
canToggleState.value = false;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
isActive.value = editor.isActive("codeBlock");
|
|
100
|
+
canToggleState.value = canToggle(editor);
|
|
101
|
+
isVisible.value = shouldShowButton({ editor, hideWhenUnavailable });
|
|
102
|
+
};
|
|
103
|
+
watch(
|
|
104
|
+
() => getEditor(),
|
|
105
|
+
(editor) => {
|
|
106
|
+
if (!editor)
|
|
107
|
+
return;
|
|
108
|
+
updateState();
|
|
109
|
+
editor.on("selectionUpdate", updateState);
|
|
110
|
+
editor.on("transaction", updateState);
|
|
111
|
+
onBeforeUnmount(() => {
|
|
112
|
+
editor.off("selectionUpdate", updateState);
|
|
113
|
+
editor.off("transaction", updateState);
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
{ immediate: true }
|
|
117
|
+
);
|
|
118
|
+
const handleToggle = () => {
|
|
119
|
+
const editor = getEditor();
|
|
120
|
+
if (toggleCodeBlock(editor)) {
|
|
121
|
+
onToggled == null ? void 0 : onToggled();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
isVisible,
|
|
126
|
+
isActive,
|
|
127
|
+
handleToggle,
|
|
128
|
+
canToggle: canToggleState,
|
|
129
|
+
label: "Code Block",
|
|
130
|
+
shortcutKeys: CODE_BLOCK_SHORTCUT_KEY,
|
|
131
|
+
Icon: CodeBlockIcon
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
CODE_BLOCK_SHORTCUT_KEY,
|
|
136
|
+
canToggle,
|
|
137
|
+
shouldShowButton,
|
|
138
|
+
toggleCodeBlock,
|
|
139
|
+
useCodeBlock
|
|
140
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/vue-3';
|
|
2
|
+
export declare const COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
3
|
+
export declare const HIGHLIGHT_COLORS: {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
border: string;
|
|
7
|
+
}[];
|
|
8
|
+
export type HighlightColor = (typeof HIGHLIGHT_COLORS)[number];
|
|
9
|
+
export declare function canColorHighlight(editor: Editor | null): boolean;
|
|
10
|
+
export declare function isColorHighlightActive(editor: Editor | null, highlightColor?: string): boolean;
|
|
11
|
+
export declare function removeHighlight(editor: Editor | null): boolean;
|
|
12
|
+
export declare function shouldShowButton(props: {
|
|
13
|
+
editor: Editor | null;
|
|
14
|
+
hideWhenUnavailable: boolean;
|
|
15
|
+
}): boolean;
|
|
16
|
+
export declare function useColorHighlight(config: {
|
|
17
|
+
editor: any;
|
|
18
|
+
label?: string;
|
|
19
|
+
highlightColor?: string;
|
|
20
|
+
hideWhenUnavailable?: boolean;
|
|
21
|
+
onApplied?: (params: {
|
|
22
|
+
color: string;
|
|
23
|
+
label: string;
|
|
24
|
+
}) => void;
|
|
25
|
+
}): {
|
|
26
|
+
isVisible: import("vue").Ref<boolean, boolean>;
|
|
27
|
+
isActive: import("vue").Ref<boolean, boolean>;
|
|
28
|
+
handleColorHighlight: () => void;
|
|
29
|
+
handleRemoveHighlight: () => void;
|
|
30
|
+
canHighlight: import("vue").Ref<boolean, boolean>;
|
|
31
|
+
label: string;
|
|
32
|
+
shortcutKeys: string;
|
|
33
|
+
Icon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
34
|
+
className: {
|
|
35
|
+
type: StringConstructor;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
39
|
+
className: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
}>> & Readonly<{}>, {
|
|
44
|
+
className: string;
|
|
45
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
46
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { ref, watch, onBeforeUnmount } from "vue";
|
|
2
|
+
import { isMarkInSchema, isNodeTypeSelected } from "../utils/tiptap-utils";
|
|
3
|
+
import { HighlighterIcon } from "../icons";
|
|
4
|
+
const COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
5
|
+
const HIGHLIGHT_COLORS = [
|
|
6
|
+
{
|
|
7
|
+
label: "Default background",
|
|
8
|
+
value: "var(--tt-bg-color)",
|
|
9
|
+
border: "var(--tt-bg-color-contrast)"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: "Gray background",
|
|
13
|
+
value: "var(--tt-color-highlight-gray)",
|
|
14
|
+
border: "var(--tt-color-highlight-gray-contrast)"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: "Brown background",
|
|
18
|
+
value: "var(--tt-color-highlight-brown)",
|
|
19
|
+
border: "var(--tt-color-highlight-brown-contrast)"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Orange background",
|
|
23
|
+
value: "var(--tt-color-highlight-orange)",
|
|
24
|
+
border: "var(--tt-color-highlight-orange-contrast)"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Yellow background",
|
|
28
|
+
value: "var(--tt-color-highlight-yellow)",
|
|
29
|
+
border: "var(--tt-color-highlight-yellow-contrast)"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "Green background",
|
|
33
|
+
value: "var(--tt-color-highlight-green)",
|
|
34
|
+
border: "var(--tt-color-highlight-green-contrast)"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "Blue background",
|
|
38
|
+
value: "var(--tt-color-highlight-blue)",
|
|
39
|
+
border: "var(--tt-color-highlight-blue-contrast)"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: "Purple background",
|
|
43
|
+
value: "var(--tt-color-highlight-purple)",
|
|
44
|
+
border: "var(--tt-color-highlight-purple-contrast)"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: "Pink background",
|
|
48
|
+
value: "var(--tt-color-highlight-pink)",
|
|
49
|
+
border: "var(--tt-color-highlight-pink-contrast)"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: "Red background",
|
|
53
|
+
value: "var(--tt-color-highlight-red)",
|
|
54
|
+
border: "var(--tt-color-highlight-red-contrast)"
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
function canColorHighlight(editor) {
|
|
58
|
+
if (!editor || !editor.isEditable)
|
|
59
|
+
return false;
|
|
60
|
+
if (!isMarkInSchema("highlight", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
61
|
+
return false;
|
|
62
|
+
return editor.can().setMark("highlight");
|
|
63
|
+
}
|
|
64
|
+
function isColorHighlightActive(editor, highlightColor) {
|
|
65
|
+
if (!editor || !editor.isEditable)
|
|
66
|
+
return false;
|
|
67
|
+
return highlightColor ? editor.isActive("highlight", { color: highlightColor }) : editor.isActive("highlight");
|
|
68
|
+
}
|
|
69
|
+
function removeHighlight(editor) {
|
|
70
|
+
if (!editor || !editor.isEditable)
|
|
71
|
+
return false;
|
|
72
|
+
if (!canColorHighlight(editor))
|
|
73
|
+
return false;
|
|
74
|
+
return editor.chain().focus().unsetMark("highlight").run();
|
|
75
|
+
}
|
|
76
|
+
function shouldShowButton(props) {
|
|
77
|
+
const { editor, hideWhenUnavailable } = props;
|
|
78
|
+
if (!editor || !editor.isEditable)
|
|
79
|
+
return false;
|
|
80
|
+
if (!isMarkInSchema("highlight", editor))
|
|
81
|
+
return false;
|
|
82
|
+
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
83
|
+
return canColorHighlight(editor);
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
function useColorHighlight(config) {
|
|
88
|
+
const { label, highlightColor, hideWhenUnavailable = false, onApplied } = config;
|
|
89
|
+
const isVisible = ref(true);
|
|
90
|
+
const isActive = ref(false);
|
|
91
|
+
const canHighlight = ref(false);
|
|
92
|
+
const getEditor = () => {
|
|
93
|
+
const editor = config.editor;
|
|
94
|
+
return editor && "value" in editor ? editor.value : editor;
|
|
95
|
+
};
|
|
96
|
+
const updateState = () => {
|
|
97
|
+
const editor = getEditor();
|
|
98
|
+
if (!editor || !editor.isEditable) {
|
|
99
|
+
isVisible.value = false;
|
|
100
|
+
isActive.value = false;
|
|
101
|
+
canHighlight.value = false;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
isActive.value = isColorHighlightActive(editor, highlightColor);
|
|
105
|
+
canHighlight.value = canColorHighlight(editor);
|
|
106
|
+
isVisible.value = shouldShowButton({ editor, hideWhenUnavailable });
|
|
107
|
+
};
|
|
108
|
+
watch(
|
|
109
|
+
() => getEditor(),
|
|
110
|
+
(editor) => {
|
|
111
|
+
if (!editor)
|
|
112
|
+
return;
|
|
113
|
+
updateState();
|
|
114
|
+
editor.on("selectionUpdate", updateState);
|
|
115
|
+
editor.on("transaction", updateState);
|
|
116
|
+
onBeforeUnmount(() => {
|
|
117
|
+
editor.off("selectionUpdate", updateState);
|
|
118
|
+
editor.off("transaction", updateState);
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
{ immediate: true }
|
|
122
|
+
);
|
|
123
|
+
const handleColorHighlight = () => {
|
|
124
|
+
const editor = getEditor();
|
|
125
|
+
if (!editor || !canHighlight.value || !highlightColor || !label)
|
|
126
|
+
return;
|
|
127
|
+
if (editor.state.storedMarks) {
|
|
128
|
+
const highlightMarkType = editor.schema.marks.highlight;
|
|
129
|
+
if (highlightMarkType) {
|
|
130
|
+
editor.view.dispatch(editor.state.tr.removeStoredMark(highlightMarkType));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
setTimeout(() => {
|
|
134
|
+
const success = editor.chain().focus().toggleMark("highlight", { color: highlightColor }).run();
|
|
135
|
+
if (success) {
|
|
136
|
+
onApplied == null ? void 0 : onApplied({ color: highlightColor, label });
|
|
137
|
+
}
|
|
138
|
+
}, 0);
|
|
139
|
+
};
|
|
140
|
+
const handleRemoveHighlight = () => {
|
|
141
|
+
const editor = getEditor();
|
|
142
|
+
const success = removeHighlight(editor);
|
|
143
|
+
if (success) {
|
|
144
|
+
onApplied == null ? void 0 : onApplied({ color: "", label: "Remove highlight" });
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
isVisible,
|
|
149
|
+
isActive,
|
|
150
|
+
handleColorHighlight,
|
|
151
|
+
handleRemoveHighlight,
|
|
152
|
+
canHighlight,
|
|
153
|
+
label: label || "Highlight",
|
|
154
|
+
shortcutKeys: COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
155
|
+
Icon: HighlighterIcon
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
160
|
+
HIGHLIGHT_COLORS,
|
|
161
|
+
canColorHighlight,
|
|
162
|
+
isColorHighlightActive,
|
|
163
|
+
removeHighlight,
|
|
164
|
+
shouldShowButton,
|
|
165
|
+
useColorHighlight
|
|
166
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { Editor } from '@tiptap/vue-3';
|
|
3
|
+
export interface CursorVisibilityOptions {
|
|
4
|
+
editor?: Editor | null | Ref<Editor | null | undefined>;
|
|
5
|
+
overlayHeight?: number | Ref<number>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useCursorVisibility(options: CursorVisibilityOptions): Ref<import("./use-element-rect").RectState, import("./use-element-rect").RectState>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
import { useWindowSizeStore } from "./use-window-size";
|
|
3
|
+
import { useBodyRect } from "./use-element-rect";
|
|
4
|
+
function useCursorVisibility(options) {
|
|
5
|
+
const windowSize = useWindowSizeStore();
|
|
6
|
+
const rect = useBodyRect({
|
|
7
|
+
enabled: true,
|
|
8
|
+
throttleMs: 100,
|
|
9
|
+
useResizeObserver: true
|
|
10
|
+
});
|
|
11
|
+
const ensureCursorVisibility = () => {
|
|
12
|
+
const editor = typeof options.editor === "function" ? options.editor() : options.editor && "value" in options.editor ? options.editor.value : options.editor;
|
|
13
|
+
const overlayHeight = options.overlayHeight && "value" in options.overlayHeight ? options.overlayHeight.value : options.overlayHeight || 0;
|
|
14
|
+
if (!editor)
|
|
15
|
+
return;
|
|
16
|
+
const { state, view } = editor;
|
|
17
|
+
if (!view.hasFocus())
|
|
18
|
+
return;
|
|
19
|
+
const { from } = state.selection;
|
|
20
|
+
const cursorCoords = view.coordsAtPos(from);
|
|
21
|
+
if (windowSize.value.height < rect.value.height && cursorCoords) {
|
|
22
|
+
const availableSpace = windowSize.value.height - cursorCoords.top;
|
|
23
|
+
if (availableSpace < overlayHeight) {
|
|
24
|
+
const targetCursorY = Math.max(windowSize.value.height / 2, overlayHeight);
|
|
25
|
+
const currentScrollY = window.scrollY;
|
|
26
|
+
const cursorAbsoluteY = cursorCoords.top + currentScrollY;
|
|
27
|
+
const newScrollY = cursorAbsoluteY - targetCursorY;
|
|
28
|
+
window.scrollTo({
|
|
29
|
+
top: Math.max(0, newScrollY),
|
|
30
|
+
behavior: "smooth"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
watch(
|
|
36
|
+
[windowSize, rect, () => options.overlayHeight, () => options.editor],
|
|
37
|
+
() => {
|
|
38
|
+
ensureCursorVisibility();
|
|
39
|
+
},
|
|
40
|
+
{ deep: true }
|
|
41
|
+
);
|
|
42
|
+
return rect;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
useCursorVisibility
|
|
46
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export type RectState = Omit<DOMRect, 'toJSON'>;
|
|
3
|
+
export interface ElementRectOptions {
|
|
4
|
+
element?: Element | Ref<Element | null> | string | null;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
throttleMs?: number;
|
|
7
|
+
useResizeObserver?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useElementRect(options?: ElementRectOptions): Ref<RectState>;
|
|
10
|
+
export declare function useBodyRect(options?: Omit<ElementRectOptions, 'element'>): Ref<RectState>;
|