reactjs-tiptap-editor-pro 0.2.31 → 0.2.32
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/lib/RichTextEditor-BwbqJLnA.cjs +141 -0
- package/lib/RichTextEditor-iGJ6-rbq.js +8833 -0
- package/lib/extension-bundle.cjs +33 -0
- package/lib/extension-bundle.d.cts +947 -0
- package/lib/extension-bundle.d.ts +947 -0
- package/lib/extension-bundle.js +5755 -0
- package/lib/index-DV-nXpU1.cjs +1 -0
- package/lib/index-M6H3FoBi.js +1147 -0
- package/lib/index.cjs +1 -0
- package/lib/index.d.cts +513 -0
- package/lib/index.d.ts +513 -0
- package/lib/index.js +16 -0
- package/lib/locale-bundle.cjs +1 -0
- package/lib/locale-bundle.d.cts +1140 -0
- package/lib/locale-bundle.d.ts +1140 -0
- package/lib/locale-bundle.js +9 -0
- package/lib/style.css +1 -0
- package/lib/tiptap-DkWHMWDt.js +6061 -0
- package/lib/tiptap-gBG-1T-V.cjs +116 -0
- package/lib/vendor-BJ0Yf78E.cjs +8114 -0
- package/lib/vendor-Cpa6z-M0.js +67575 -0
- package/package.json +58 -5
- package/src/components/ActionButton.tsx +0 -103
- package/src/components/ActionMenuButton.tsx +0 -76
- package/src/components/BubbleMenu.tsx +0 -93
- package/src/components/CharactorCount.tsx +0 -50
- package/src/components/ColorPicker.tsx +0 -272
- package/src/components/RichTextEditor.tsx +0 -212
- package/src/components/SizeSetter/SizeSetter.tsx +0 -102
- package/src/components/Toolbar.tsx +0 -108
- package/src/components/icons/Activity.tsx +0 -19
- package/src/components/icons/Animas.tsx +0 -24
- package/src/components/icons/AspectRatio.tsx +0 -13
- package/src/components/icons/Blockquote.tsx +0 -17
- package/src/components/icons/ColumnAddLeft.tsx +0 -7
- package/src/components/icons/ColumnAddRight.tsx +0 -7
- package/src/components/icons/DeleteColumn.tsx +0 -26
- package/src/components/icons/DeleteRow.tsx +0 -26
- package/src/components/icons/Direction.tsx +0 -7
- package/src/components/icons/Excalidraw.tsx +0 -7
- package/src/components/icons/ExportPdf.tsx +0 -8
- package/src/components/icons/ExportWord.tsx +0 -24
- package/src/components/icons/FileWordOutline.tsx +0 -13
- package/src/components/icons/Flag.tsx +0 -19
- package/src/components/icons/Food.tsx +0 -20
- package/src/components/icons/GIfIcon.tsx +0 -10
- package/src/components/icons/Icon.tsx +0 -30
- package/src/components/icons/ImportWord.tsx +0 -23
- package/src/components/icons/LeftToRight.tsx +0 -7
- package/src/components/icons/LineHeight.tsx +0 -13
- package/src/components/icons/MenuDown.tsx +0 -24
- package/src/components/icons/Mermaid.tsx +0 -13
- package/src/components/icons/NoFill.tsx +0 -7
- package/src/components/icons/Object.tsx +0 -24
- package/src/components/icons/RightToLeft.tsx +0 -7
- package/src/components/icons/SizeL.tsx +0 -9
- package/src/components/icons/SizeM.tsx +0 -13
- package/src/components/icons/SizeS.tsx +0 -13
- package/src/components/icons/Symbol.tsx +0 -19
- package/src/components/icons/Travel.tsx +0 -24
- package/src/components/icons/Twitter.tsx +0 -7
- package/src/components/icons/icons.ts +0 -212
- package/src/components/icons/index.ts +0 -12
- package/src/components/index.ts +0 -9
- package/src/components/menus/bubble.ts +0 -395
- package/src/components/menus/components/BubbleMenuContent.tsx +0 -15
- package/src/components/menus/components/BubbleMenuDrawer.tsx +0 -128
- package/src/components/menus/components/BubbleMenuExcalidraw.tsx +0 -91
- package/src/components/menus/components/BubbleMenuIframe.tsx +0 -143
- package/src/components/menus/components/BubbleMenuKatex.tsx +0 -136
- package/src/components/menus/components/BubbleMenuLink.tsx +0 -99
- package/src/components/menus/components/BubbleMenuMedia.tsx +0 -235
- package/src/components/menus/components/BubbleMenuMermaid.tsx +0 -128
- package/src/components/menus/components/BubbleMenuText.tsx +0 -102
- package/src/components/menus/components/BubbleMenuTwitter.tsx +0 -91
- package/src/components/menus/components/ColumnsBubbleMenu.tsx +0 -59
- package/src/components/menus/components/ContentMenu.tsx +0 -396
- package/src/components/menus/components/TableBubbleMenu.tsx +0 -362
- package/src/components/menus/index.ts +0 -7
- package/src/components/ui/button.tsx +0 -56
- package/src/components/ui/checkbox.tsx +0 -30
- package/src/components/ui/dialog.tsx +0 -128
- package/src/components/ui/dropdown-menu.tsx +0 -203
- package/src/components/ui/emoji-picker.tsx +0 -166
- package/src/components/ui/index.ts +0 -14
- package/src/components/ui/input.tsx +0 -25
- package/src/components/ui/label.tsx +0 -26
- package/src/components/ui/popover.tsx +0 -31
- package/src/components/ui/select.tsx +0 -162
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/switch.tsx +0 -29
- package/src/components/ui/tabs.tsx +0 -55
- package/src/components/ui/textarea.tsx +0 -24
- package/src/components/ui/toast.tsx +0 -129
- package/src/components/ui/toaster.tsx +0 -44
- package/src/components/ui/toggle.tsx +0 -45
- package/src/components/ui/tooltip.tsx +0 -30
- package/src/components/ui/use-toast.ts +0 -197
- package/src/constants/index.ts +0 -223
- package/src/constants/resetCSS.ts +0 -139
- package/src/extension-bundle.ts +0 -2
- package/src/extensions/Attachment/Attachment.ts +0 -144
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIcon.tsx +0 -69
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIconString.ts +0 -28
- package/src/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.tsx +0 -155
- package/src/extensions/Attachment/components/NodeViewAttachment/index.module.scss +0 -23
- package/src/extensions/Attachment/index.ts +0 -1
- package/src/extensions/BaseKit.ts +0 -253
- package/src/extensions/Blockquote/Blockquote.ts +0 -31
- package/src/extensions/Blockquote/index.ts +0 -1
- package/src/extensions/Bold/Bold.ts +0 -26
- package/src/extensions/Bold/index.ts +0 -1
- package/src/extensions/BulletList/BulletList.ts +0 -28
- package/src/extensions/BulletList/index.ts +0 -1
- package/src/extensions/Clear/Clear.ts +0 -24
- package/src/extensions/Clear/index.ts +0 -1
- package/src/extensions/Code/Code.ts +0 -26
- package/src/extensions/Code/index.ts +0 -1
- package/src/extensions/CodeBlock/CodeBlock.ts +0 -54
- package/src/extensions/CodeBlock/components/CodeBlockActiveButton.tsx +0 -66
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.tsx +0 -89
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/index.module.scss +0 -81
- package/src/extensions/CodeBlock/highlighter.ts +0 -132
- package/src/extensions/CodeBlock/index.ts +0 -1
- package/src/extensions/CodeBlock/shiki-plugin.ts +0 -213
- package/src/extensions/Color/Color.ts +0 -52
- package/src/extensions/Color/components/ColorActionButton.tsx +0 -104
- package/src/extensions/Color/index.ts +0 -1
- package/src/extensions/Document/Document.ts +0 -8
- package/src/extensions/Document/index.ts +0 -1
- package/src/extensions/Drawer/Drawer.ts +0 -177
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.module.scss +0 -85
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.tsx +0 -598
- package/src/extensions/Drawer/components/ControlDrawer/icon.tsx +0 -500
- package/src/extensions/Drawer/components/DrawerActiveButton.tsx +0 -239
- package/src/extensions/Drawer/components/EditDrawerBlock.tsx +0 -238
- package/src/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.tsx +0 -260
- package/src/extensions/Drawer/index.ts +0 -1
- package/src/extensions/Emoji/Emoji.ts +0 -146
- package/src/extensions/Emoji/components/EmojiList/EmojiList.tsx +0 -103
- package/src/extensions/Emoji/components/EmojiList/emojis.ts +0 -1858
- package/src/extensions/Emoji/components/EmojiPicker/EmojiPicker.tsx +0 -61
- package/src/extensions/Emoji/index.ts +0 -1
- package/src/extensions/Excalidraw/Excalidraw.ts +0 -123
- package/src/extensions/Excalidraw/components/ExcalidrawActiveButton.tsx +0 -138
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.tsx +0 -178
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/index.module.scss +0 -43
- package/src/extensions/Excalidraw/index.ts +0 -1
- package/src/extensions/ExportPdf/ExportPdf.ts +0 -25
- package/src/extensions/ExportPdf/index.ts +0 -1
- package/src/extensions/ExportWord/ExportWord.ts +0 -87
- package/src/extensions/ExportWord/index.ts +0 -1
- package/src/extensions/FontFamily/FontFamily.ts +0 -64
- package/src/extensions/FontFamily/components/FontFamilyButton.tsx +0 -97
- package/src/extensions/FontFamily/index.ts +0 -1
- package/src/extensions/FontSize/FontSize.ts +0 -119
- package/src/extensions/FontSize/components/FontSizeMenuButton.tsx +0 -84
- package/src/extensions/FontSize/index.ts +0 -1
- package/src/extensions/FormatPainter/FormatPainter.ts +0 -121
- package/src/extensions/FormatPainter/index.ts +0 -1
- package/src/extensions/Heading/Heading.ts +0 -57
- package/src/extensions/Heading/components/HeadingButton.tsx +0 -96
- package/src/extensions/Heading/index.ts +0 -1
- package/src/extensions/Highlight/Highlight.ts +0 -36
- package/src/extensions/Highlight/components/HighlightActionButton.tsx +0 -108
- package/src/extensions/Highlight/index.ts +0 -1
- package/src/extensions/History/History.ts +0 -39
- package/src/extensions/History/components/HistoryActionButton.tsx +0 -74
- package/src/extensions/History/index.ts +0 -1
- package/src/extensions/HorizontalRule/HorizontalRule.ts +0 -42
- package/src/extensions/HorizontalRule/index.ts +0 -1
- package/src/extensions/Iframe/Iframe.ts +0 -140
- package/src/extensions/Iframe/components/IframeNodeView.tsx +0 -92
- package/src/extensions/Iframe/components/index.module.scss +0 -40
- package/src/extensions/Iframe/embed.ts +0 -487
- package/src/extensions/Iframe/index.ts +0 -1
- package/src/extensions/Image/Image.ts +0 -303
- package/src/extensions/Image/components/ActionImageButton.tsx +0 -186
- package/src/extensions/Image/components/ImageCropper.tsx +0 -198
- package/src/extensions/Image/components/ImageView.tsx +0 -271
- package/src/extensions/Image/index.ts +0 -1
- package/src/extensions/Image/store.ts +0 -15
- package/src/extensions/ImageGif/ImageGif.ts +0 -176
- package/src/extensions/ImageGif/components/ImageGifActionButton.tsx +0 -138
- package/src/extensions/ImageGif/components/ImageGifView.tsx +0 -260
- package/src/extensions/ImageGif/index.ts +0 -1
- package/src/extensions/ImportWord/ImportWord.ts +0 -52
- package/src/extensions/ImportWord/components/ImportWordButton.tsx +0 -151
- package/src/extensions/ImportWord/index.ts +0 -1
- package/src/extensions/Indent/Indent.ts +0 -110
- package/src/extensions/Indent/index.ts +0 -1
- package/src/extensions/Italic/Italic.ts +0 -29
- package/src/extensions/Italic/index.ts +0 -1
- package/src/extensions/Katex/Katex.ts +0 -109
- package/src/extensions/Katex/components/KatexActiveButton.tsx +0 -117
- package/src/extensions/Katex/components/KatexWrapper.tsx +0 -53
- package/src/extensions/Katex/index.ts +0 -1
- package/src/extensions/LineHeight/LineHeight.ts +0 -76
- package/src/extensions/LineHeight/components/LineHeightDropdown.tsx +0 -93
- package/src/extensions/LineHeight/index.ts +0 -1
- package/src/extensions/Link/Link.ts +0 -92
- package/src/extensions/Link/components/LinkEditBlock.tsx +0 -110
- package/src/extensions/Link/components/LinkEditPopover.tsx +0 -46
- package/src/extensions/Link/components/LinkViewBlock.tsx +0 -54
- package/src/extensions/Link/index.ts +0 -1
- package/src/extensions/ListItem/ListItem.ts +0 -1
- package/src/extensions/ListItem/index.ts +0 -1
- package/src/extensions/Mention/Mention.ts +0 -100
- package/src/extensions/Mention/components/NodeViewMentionList/NodeViewMentionList.tsx +0 -94
- package/src/extensions/Mention/components/NodeViewMentionList/index.module.scss +0 -38
- package/src/extensions/Mention/index.ts +0 -1
- package/src/extensions/Mermaid/Mermaid.ts +0 -177
- package/src/extensions/Mermaid/components/EditMermaidBlock.tsx +0 -155
- package/src/extensions/Mermaid/components/MermaidActiveButton.tsx +0 -151
- package/src/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.tsx +0 -260
- package/src/extensions/Mermaid/index.ts +0 -1
- package/src/extensions/MoreMark/MoreMark.ts +0 -102
- package/src/extensions/MoreMark/components/ActionMoreButton.tsx +0 -97
- package/src/extensions/MoreMark/index.ts +0 -1
- package/src/extensions/MultiColumn/Column.ts +0 -36
- package/src/extensions/MultiColumn/MultiColumn.ts +0 -111
- package/src/extensions/MultiColumn/components/ColumnActionButton.ts +0 -22
- package/src/extensions/MultiColumn/index.ts +0 -3
- package/src/extensions/OrderedList/OrderedList.ts +0 -28
- package/src/extensions/OrderedList/index.ts +0 -1
- package/src/extensions/SearchAndReplace/SearchAndReplace.ts +0 -395
- package/src/extensions/SearchAndReplace/components/SearchAndReplaceButton.tsx +0 -190
- package/src/extensions/SearchAndReplace/index.ts +0 -1
- package/src/extensions/Selection/Selection.ts +0 -32
- package/src/extensions/Selection/index.ts +0 -1
- package/src/extensions/SlashCommand/SlashCommand.ts +0 -255
- package/src/extensions/SlashCommand/components/CommandsList.tsx +0 -180
- package/src/extensions/SlashCommand/groups.ts +0 -183
- package/src/extensions/SlashCommand/index.ts +0 -1
- package/src/extensions/SlashCommand/types.ts +0 -24
- package/src/extensions/Strike/Strike.ts +0 -26
- package/src/extensions/Strike/index.ts +0 -1
- package/src/extensions/Subscript/Subscript.ts +0 -88
- package/src/extensions/Subscript/index.ts +0 -1
- package/src/extensions/Table/Cell.ts +0 -131
- package/src/extensions/Table/Header.ts +0 -93
- package/src/extensions/Table/Row.ts +0 -8
- package/src/extensions/Table/Table.ts +0 -60
- package/src/extensions/Table/cell-background.ts +0 -112
- package/src/extensions/Table/components/CreateTablePopover.tsx +0 -132
- package/src/extensions/Table/components/TableActionButton.tsx +0 -42
- package/src/extensions/Table/index.ts +0 -6
- package/src/extensions/Table/utils.ts +0 -352
- package/src/extensions/TableOfContent/TableOfContent.ts +0 -124
- package/src/extensions/TableOfContent/components/NodeViewTableOfContent.tsx +0 -116
- package/src/extensions/TableOfContent/components/TableOfContentActionButton.tsx +0 -27
- package/src/extensions/TableOfContent/components/index.module.scss +0 -40
- package/src/extensions/TableOfContent/index.ts +0 -1
- package/src/extensions/TaskList/TaskList.ts +0 -46
- package/src/extensions/TaskList/index.ts +0 -1
- package/src/extensions/TextAlign/TextAlign.ts +0 -68
- package/src/extensions/TextAlign/components/TextAlignMenuButton.tsx +0 -103
- package/src/extensions/TextAlign/index.ts +0 -1
- package/src/extensions/TextBubble/TextBubble.ts +0 -22
- package/src/extensions/TextBubble/components/TextDropdown.tsx +0 -146
- package/src/extensions/TextBubble/index.ts +0 -1
- package/src/extensions/TextDirection/TextDirection.ts +0 -97
- package/src/extensions/TextDirection/components/TextDirectionButton.tsx +0 -103
- package/src/extensions/TextDirection/index.ts +0 -1
- package/src/extensions/TrailingNode/TrailingNode.ts +0 -71
- package/src/extensions/TrailingNode/index.ts +0 -1
- package/src/extensions/Twitter/Twitter.ts +0 -161
- package/src/extensions/Twitter/components/FormEditLinkTwitter.tsx +0 -68
- package/src/extensions/Twitter/components/NodeViewTweet.tsx +0 -30
- package/src/extensions/Twitter/components/TwitterActiveButton.tsx +0 -41
- package/src/extensions/Twitter/index.ts +0 -1
- package/src/extensions/UnderLine/Underline.ts +0 -30
- package/src/extensions/UnderLine/index.ts +0 -1
- package/src/extensions/Video/Video.ts +0 -204
- package/src/extensions/Video/components/ActiveVideoButton.tsx +0 -191
- package/src/extensions/Video/index.ts +0 -1
- package/src/extensions/Video/store.ts +0 -15
- package/src/extensions/index.ts +0 -122
- package/src/hooks/useActive.tsx +0 -24
- package/src/hooks/useAttributes.tsx +0 -45
- package/src/hooks/useCopy.tsx +0 -20
- package/src/hooks/useEditorState.tsx +0 -23
- package/src/hooks/useExtension.tsx +0 -29
- package/src/index.ts +0 -8
- package/src/lib/utils.ts +0 -7
- package/src/locale-bundle.ts +0 -3
- package/src/locales/en.ts +0 -173
- package/src/locales/hu.ts +0 -173
- package/src/locales/index.tsx +0 -163
- package/src/locales/pt-br.ts +0 -173
- package/src/locales/vi.ts +0 -173
- package/src/locales/zh-cn.ts +0 -173
- package/src/plugins/DragHandle/index.ts +0 -375
- package/src/plugins/DragHandle/range.ts +0 -114
- package/src/plugins/DragHandle/utils.ts +0 -80
- package/src/plugins/image-upload.ts +0 -160
- package/src/store/ProviderRichText.tsx +0 -53
- package/src/store/editableEditor.ts +0 -15
- package/src/store/fast-context.tsx +0 -70
- package/src/store/store.ts +0 -35
- package/src/styles/ProseMirror.scss +0 -176
- package/src/styles/columns.scss +0 -23
- package/src/styles/editor.scss +0 -411
- package/src/styles/global.scss +0 -87
- package/src/styles/index.scss +0 -5
- package/src/styles/mention.scss +0 -6
- package/src/theme/theme.ts +0 -15
- package/src/types.ts +0 -271
- package/src/utils/_event.ts +0 -55
- package/src/utils/color.ts +0 -67
- package/src/utils/columns.ts +0 -142
- package/src/utils/customEvents/customEvents.ts +0 -18
- package/src/utils/customEvents/events.constant.ts +0 -11
- package/src/utils/delete-node.ts +0 -46
- package/src/utils/dom-dataset.ts +0 -121
- package/src/utils/download.ts +0 -17
- package/src/utils/dynamicCSS.ts +0 -192
- package/src/utils/editor-container-size.ts +0 -28
- package/src/utils/file.ts +0 -112
- package/src/utils/getRenderContainer.ts +0 -41
- package/src/utils/indent.ts +0 -99
- package/src/utils/is-mobile.ts +0 -57
- package/src/utils/json.ts +0 -18
- package/src/utils/line-height.ts +0 -109
- package/src/utils/lru-cache.ts +0 -145
- package/src/utils/mitt.ts +0 -114
- package/src/utils/node.ts +0 -92
- package/src/utils/pdf.ts +0 -72
- package/src/utils/plateform.ts +0 -49
- package/src/utils/shortId.ts +0 -5
- package/src/utils/storage.ts +0 -18
- package/src/utils/utils.ts +0 -71
- package/src/vite-env.d.ts +0 -3
package/src/types.ts
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import type { Editor as CoreEditor, Extension, JSONContent } from '@tiptap/core';
|
|
2
|
-
import type { Editor } from '@tiptap/react';
|
|
3
|
-
|
|
4
|
-
import { type ActionButtonProps } from './components';
|
|
5
|
-
import { EditorView } from '@tiptap/pm/view';
|
|
6
|
-
import { EditorState } from '@tiptap/pm/state';
|
|
7
|
-
|
|
8
|
-
export type { Editor, JSONContent } from '@tiptap/core';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents the onChange event for EchoEditor.
|
|
12
|
-
*/
|
|
13
|
-
export interface EchoEditorOnChange {
|
|
14
|
-
/** Editor object */
|
|
15
|
-
editor: CoreEditor
|
|
16
|
-
/** Output content, can be a string or JSON content */
|
|
17
|
-
output: string | JSONContent
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Represents the keys for different extensions.
|
|
22
|
-
*/
|
|
23
|
-
export type ExtensionNameKeys =
|
|
24
|
-
| 'bold'
|
|
25
|
-
| 'italic'
|
|
26
|
-
| 'underline'
|
|
27
|
-
| 'strike'
|
|
28
|
-
| 'color'
|
|
29
|
-
| 'highlight'
|
|
30
|
-
| 'heading'
|
|
31
|
-
| 'textAlign'
|
|
32
|
-
| 'bulletList'
|
|
33
|
-
| 'orderedList'
|
|
34
|
-
| 'taskList'
|
|
35
|
-
| 'indent'
|
|
36
|
-
| 'link'
|
|
37
|
-
| 'image'
|
|
38
|
-
| 'video'
|
|
39
|
-
| 'table'
|
|
40
|
-
| 'blockquote'
|
|
41
|
-
| 'horizontalRule'
|
|
42
|
-
| 'code'
|
|
43
|
-
| 'codeBlock'
|
|
44
|
-
| 'clear'
|
|
45
|
-
| 'history';
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Represents the general options for Tiptap extensions.
|
|
49
|
-
*/
|
|
50
|
-
export interface GeneralOptions<T> {
|
|
51
|
-
/** Enabled divider */
|
|
52
|
-
divider: boolean
|
|
53
|
-
/** Enabled spacer */
|
|
54
|
-
spacer: boolean
|
|
55
|
-
/** Button view function */
|
|
56
|
-
button: ButtonView<T>
|
|
57
|
-
/** Show on Toolbar */
|
|
58
|
-
toolbar?: boolean
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Represents the props for the ButtonView component.
|
|
63
|
-
*/
|
|
64
|
-
export interface ButtonViewReturnComponentProps {
|
|
65
|
-
/** Method triggered when action is performed */
|
|
66
|
-
action?: (value?: any) => void
|
|
67
|
-
/** Whether it is in the active state */
|
|
68
|
-
isActive?: () => boolean
|
|
69
|
-
/** Button icon */
|
|
70
|
-
icon?: any
|
|
71
|
-
/** Text displayed on hover */
|
|
72
|
-
tooltip?: string
|
|
73
|
-
[x: string]: any
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Represents the slots for the ButtonView component.
|
|
78
|
-
*/
|
|
79
|
-
export interface ButtonViewReturnComponentSlots {
|
|
80
|
-
/** Dialog slot */
|
|
81
|
-
dialog: () => any
|
|
82
|
-
[x: string]: () => any
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Represents the return value for the ButtonView component.
|
|
87
|
-
*/
|
|
88
|
-
export interface ButtonViewReturn {
|
|
89
|
-
/** Component */
|
|
90
|
-
component: unknown
|
|
91
|
-
/** Component props */
|
|
92
|
-
componentProps: ButtonViewReturnComponentProps
|
|
93
|
-
/** Component slots */
|
|
94
|
-
componentSlots?: ButtonViewReturnComponentSlots
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Represents the parameters for the ButtonView function.
|
|
99
|
-
*/
|
|
100
|
-
export interface ButtonViewParams<T = any> {
|
|
101
|
-
/** Editor object */
|
|
102
|
-
editor: Editor
|
|
103
|
-
/** Extension object */
|
|
104
|
-
extension: Extension<T>
|
|
105
|
-
/** Translation function */
|
|
106
|
-
t: (path: string) => string
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Represents the ButtonView function.
|
|
111
|
-
*/
|
|
112
|
-
export type ButtonView<T = any> = (options: ButtonViewParams<T>) => ButtonViewReturn | ButtonViewReturn[];
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Represents the BubbleMenuRenderProps.
|
|
116
|
-
*/
|
|
117
|
-
export interface BubbleMenuRenderProps {
|
|
118
|
-
editor: Editor
|
|
119
|
-
disabled: boolean
|
|
120
|
-
bubbleMenu: BubbleMenuProps
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface BubbleMenuConfig {
|
|
124
|
-
/**
|
|
125
|
-
* @description Column menu hidden
|
|
126
|
-
* @default false
|
|
127
|
-
*/
|
|
128
|
-
hidden?: boolean
|
|
129
|
-
/**
|
|
130
|
-
* custom menu actions
|
|
131
|
-
*/
|
|
132
|
-
actions?: ActionButtonProps[]
|
|
133
|
-
items?: string[]
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Represents the BubbleMenuProps.
|
|
139
|
-
*/
|
|
140
|
-
export interface BubbleMenuProps {
|
|
141
|
-
columnConfig?: {
|
|
142
|
-
/**
|
|
143
|
-
* @description Column menu hidden
|
|
144
|
-
* @default false
|
|
145
|
-
*/
|
|
146
|
-
hidden?: boolean
|
|
147
|
-
}
|
|
148
|
-
tableConfig?: BubbleMenuConfig
|
|
149
|
-
floatingMenuConfig?: {
|
|
150
|
-
/**
|
|
151
|
-
* @description Floating menu hidden
|
|
152
|
-
* @default false
|
|
153
|
-
*/
|
|
154
|
-
hidden?: boolean
|
|
155
|
-
}
|
|
156
|
-
linkConfig?: {
|
|
157
|
-
/**
|
|
158
|
-
* @description Link menu hidden
|
|
159
|
-
* @default false
|
|
160
|
-
*/
|
|
161
|
-
hidden?: boolean
|
|
162
|
-
}
|
|
163
|
-
textConfig?: {
|
|
164
|
-
/**
|
|
165
|
-
* @description Text menu hidden
|
|
166
|
-
* @default false
|
|
167
|
-
*/
|
|
168
|
-
hidden?: boolean
|
|
169
|
-
items?: string[]
|
|
170
|
-
}
|
|
171
|
-
imageConfig?: {
|
|
172
|
-
/**
|
|
173
|
-
* @description Image menu hidden
|
|
174
|
-
* @default false
|
|
175
|
-
*/
|
|
176
|
-
hidden?: boolean
|
|
177
|
-
}
|
|
178
|
-
imageGifConfig?: {
|
|
179
|
-
/**
|
|
180
|
-
* @description Image menu hidden
|
|
181
|
-
* @default false
|
|
182
|
-
*/
|
|
183
|
-
hidden?: boolean
|
|
184
|
-
}
|
|
185
|
-
videoConfig?: {
|
|
186
|
-
/**
|
|
187
|
-
* @description Video menu hidden
|
|
188
|
-
* @default false
|
|
189
|
-
*/
|
|
190
|
-
hidden?: boolean
|
|
191
|
-
}
|
|
192
|
-
katexConfig?: {
|
|
193
|
-
/**
|
|
194
|
-
* @description katex menu hidden
|
|
195
|
-
* @default false
|
|
196
|
-
*/
|
|
197
|
-
hidden?: boolean
|
|
198
|
-
}
|
|
199
|
-
excalidrawConfig?: {
|
|
200
|
-
/**
|
|
201
|
-
* @description excalidraw menu hidden
|
|
202
|
-
* @default false
|
|
203
|
-
*/
|
|
204
|
-
hidden?: boolean
|
|
205
|
-
}
|
|
206
|
-
iframeConfig?: {
|
|
207
|
-
/**
|
|
208
|
-
* @description iframe menu hidden
|
|
209
|
-
* @default false
|
|
210
|
-
*/
|
|
211
|
-
hidden?: boolean
|
|
212
|
-
}
|
|
213
|
-
mermaidConfig?: {
|
|
214
|
-
/**
|
|
215
|
-
* @description mermaid menu hidden
|
|
216
|
-
* @default false
|
|
217
|
-
*/
|
|
218
|
-
hidden?: boolean
|
|
219
|
-
}
|
|
220
|
-
twitterConfig?: {
|
|
221
|
-
/**
|
|
222
|
-
* @description twitter menu hidden
|
|
223
|
-
* @default false
|
|
224
|
-
*/
|
|
225
|
-
hidden?: boolean
|
|
226
|
-
}
|
|
227
|
-
drawerConfig?: {
|
|
228
|
-
/**
|
|
229
|
-
* @description twitter menu hidden
|
|
230
|
-
* @default false
|
|
231
|
-
*/
|
|
232
|
-
hidden?: boolean
|
|
233
|
-
}
|
|
234
|
-
render?: (props: BubbleMenuRenderProps, dom: React.ReactNode) => React.ReactNode
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Represents the ToolbarItemProps.
|
|
239
|
-
*/
|
|
240
|
-
export interface ToolbarItemProps {
|
|
241
|
-
button: {
|
|
242
|
-
component: React.ComponentType<any>
|
|
243
|
-
componentProps: Record<string, any>
|
|
244
|
-
}
|
|
245
|
-
divider: boolean
|
|
246
|
-
spacer: boolean
|
|
247
|
-
type: string
|
|
248
|
-
name: string
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
export interface ToolbarRenderProps {
|
|
252
|
-
editor: Editor
|
|
253
|
-
disabled: boolean
|
|
254
|
-
}
|
|
255
|
-
export interface ToolbarProps {
|
|
256
|
-
render?: (props: ToolbarRenderProps, toolbarItems: ToolbarItemProps[], dom: any[], containerDom: (innerContent: React.ReactNode) => React.ReactNode) => React.ReactNode
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export interface NameValueOption<T = string> {
|
|
260
|
-
name: string
|
|
261
|
-
value: T
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export interface ShouldShowProps {
|
|
265
|
-
editor: Editor;
|
|
266
|
-
view: EditorView;
|
|
267
|
-
state?: EditorState;
|
|
268
|
-
oldState?: EditorState;
|
|
269
|
-
from?: number;
|
|
270
|
-
to?: number;
|
|
271
|
-
}
|
package/src/utils/_event.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import mitt from 'reactjs-tiptap-editor-pro/utils/mitt';
|
|
2
|
-
|
|
3
|
-
let event: any;
|
|
4
|
-
function getEventEmitter() {
|
|
5
|
-
try {
|
|
6
|
-
if (!event) {
|
|
7
|
-
event = mitt();
|
|
8
|
-
}
|
|
9
|
-
return event;
|
|
10
|
-
} catch {
|
|
11
|
-
throw new Error('Error EventEmitter');
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const OPEN_COUNT_SETTING_MODAL = 'OPEN_COUNT_SETTING_MODAL';
|
|
16
|
-
export const OPEN_LINK_SETTING_MODAL = 'OPEN_LINK_SETTING_MODAL';
|
|
17
|
-
export const OPEN_FLOW_SETTING_MODAL = 'OPEN_FLOW_SETTING_MODAL';
|
|
18
|
-
export const OPEN_MIND_SETTING_MODAL = 'OPEN_MIND_SETTING_MODAL';
|
|
19
|
-
export const OPEN_EXCALIDRAW_SETTING_MODAL = 'OPEN_EXCALIDRAW_SETTING_MODAL';
|
|
20
|
-
export const OPEN_DRAWER_SETTING_MODAL = 'OPEN_DRAWER_SETTING_MODAL';
|
|
21
|
-
|
|
22
|
-
export function subject(eventName: any, handler: any) {
|
|
23
|
-
const event = getEventEmitter();
|
|
24
|
-
event.on(eventName, handler);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function cancelSubject(eventName: any, handler: any) {
|
|
28
|
-
const event = getEventEmitter();
|
|
29
|
-
event.off(eventName, handler);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function triggerOpenCountSettingModal(data: any) {
|
|
33
|
-
const event = getEventEmitter();
|
|
34
|
-
event.emit(OPEN_COUNT_SETTING_MODAL, data);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function triggerOpenLinkSettingModal(data: any) {
|
|
38
|
-
const event = getEventEmitter();
|
|
39
|
-
event.emit(OPEN_LINK_SETTING_MODAL, data);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function triggerOpenFlowSettingModal(data: any) {
|
|
43
|
-
const event = getEventEmitter();
|
|
44
|
-
event.emit(OPEN_FLOW_SETTING_MODAL, data);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function triggerOpenMindSettingModal(data: any) {
|
|
48
|
-
const event = getEventEmitter();
|
|
49
|
-
event.emit(OPEN_MIND_SETTING_MODAL, data);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function triggerOpenExcalidrawSettingModal(data: any) {
|
|
53
|
-
const event = getEventEmitter();
|
|
54
|
-
event.emit(OPEN_EXCALIDRAW_SETTING_MODAL, data);
|
|
55
|
-
}
|
package/src/utils/color.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
const colors = [
|
|
3
|
-
'#47A1FF',
|
|
4
|
-
'#59CB74',
|
|
5
|
-
'#FFB952',
|
|
6
|
-
'#FC6980',
|
|
7
|
-
'#6367EC',
|
|
8
|
-
'#DA65CC',
|
|
9
|
-
'#FBD54A',
|
|
10
|
-
'#ADDF84',
|
|
11
|
-
'#6CD3FF',
|
|
12
|
-
'#659AEC',
|
|
13
|
-
'#9F8CF1',
|
|
14
|
-
'#ED8CCE',
|
|
15
|
-
'#A2E5FF',
|
|
16
|
-
'#4DCCCB',
|
|
17
|
-
'#F79452',
|
|
18
|
-
'#84E0BE',
|
|
19
|
-
'#5982F6',
|
|
20
|
-
'#E37474',
|
|
21
|
-
'#3FDDC7',
|
|
22
|
-
'#9861E5',
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const total = colors.length;
|
|
26
|
-
export const getRandomColor = () => colors[Math.trunc(Math.random() * total)];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param hexCode
|
|
30
|
-
* @param opacity
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export function convertColorToRGBA(hexCode: string, opacity = 1) {
|
|
34
|
-
let r = 0;
|
|
35
|
-
let g = 0;
|
|
36
|
-
let b = 0;
|
|
37
|
-
|
|
38
|
-
if (hexCode.startsWith('rgb')) {
|
|
39
|
-
// @ts-expect-error
|
|
40
|
-
const rgb = hexCode
|
|
41
|
-
.replace(/\s/g, '')
|
|
42
|
-
.match(/rgb\((.*)\)$/)[1]
|
|
43
|
-
.split(',');
|
|
44
|
-
|
|
45
|
-
r = +rgb[0];
|
|
46
|
-
g = +rgb[1];
|
|
47
|
-
b = +rgb[2];
|
|
48
|
-
} else if (hexCode.startsWith('#')) {
|
|
49
|
-
let hex = hexCode.replace('#', '');
|
|
50
|
-
|
|
51
|
-
if (hex.length === 3) {
|
|
52
|
-
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
r = Number.parseInt(hex.substring(0, 2), 16);
|
|
56
|
-
g = Number.parseInt(hex.substring(2, 4), 16);
|
|
57
|
-
b = Number.parseInt(hex.substring(4, 6), 16);
|
|
58
|
-
} else {
|
|
59
|
-
return hexCode;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (opacity > 1 && opacity <= 100) {
|
|
63
|
-
opacity = opacity / 100;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return `rgba(${r},${g},${b},${opacity})`;
|
|
67
|
-
}
|
package/src/utils/columns.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
import { findParentNode } from '@tiptap/core';
|
|
3
|
-
import { Node } from '@tiptap/pm/model';
|
|
4
|
-
import { type EditorState, TextSelection } from '@tiptap/pm/state';
|
|
5
|
-
|
|
6
|
-
import { Column, MultiColumn } from 'reactjs-tiptap-editor-pro/extensions/MultiColumn';
|
|
7
|
-
|
|
8
|
-
export function createColumn(colType: any, index: any, colContent = null) {
|
|
9
|
-
if (colContent) {
|
|
10
|
-
return colType.createChecked({ index }, colContent);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return colType.createAndFill({ index });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function getColumnsNodeTypes(schema: any) {
|
|
17
|
-
if (schema.cached.columnsNodeTypes) {
|
|
18
|
-
return schema.cached.columnsNodeTypes;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const roles = {
|
|
22
|
-
columns: schema.nodes.columns,
|
|
23
|
-
column: schema.nodes.column,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
schema.cached.columnsNodeTypes = roles;
|
|
27
|
-
|
|
28
|
-
return roles;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function createColumns(schema: any, colsCount: any, colContent = null) {
|
|
32
|
-
const types = getColumnsNodeTypes(schema);
|
|
33
|
-
const cols = [];
|
|
34
|
-
|
|
35
|
-
for (let index = 0; index < colsCount; index += 1) {
|
|
36
|
-
const col = createColumn(types.column, index, colContent);
|
|
37
|
-
|
|
38
|
-
if (col) {
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
cols.push(col);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return types.columns.createChecked({ cols: colsCount }, cols);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function addOrDeleteCol({
|
|
48
|
-
state,
|
|
49
|
-
dispatch,
|
|
50
|
-
type,
|
|
51
|
-
}: {
|
|
52
|
-
state: EditorState
|
|
53
|
-
dispatch: any
|
|
54
|
-
type: 'addBefore' | 'addAfter' | 'delete'
|
|
55
|
-
}) {
|
|
56
|
-
const maybeColumns = findParentNode((node: Node) => node.type.name === MultiColumn.name)(state.selection);
|
|
57
|
-
const maybeColumn = findParentNode((node: Node) => node.type.name === Column.name)(state.selection);
|
|
58
|
-
|
|
59
|
-
if (dispatch && maybeColumns && maybeColumn) {
|
|
60
|
-
const cols = maybeColumns.node;
|
|
61
|
-
const colIndex = maybeColumn.node.attrs.index;
|
|
62
|
-
const colsJSON = cols.toJSON();
|
|
63
|
-
|
|
64
|
-
let nextIndex = colIndex;
|
|
65
|
-
|
|
66
|
-
if (type === 'delete') {
|
|
67
|
-
nextIndex = colIndex - 1;
|
|
68
|
-
colsJSON.content.splice(colIndex, 1);
|
|
69
|
-
} else {
|
|
70
|
-
nextIndex = type === 'addBefore' ? colIndex : colIndex + 1;
|
|
71
|
-
colsJSON.content.splice(nextIndex, 0, {
|
|
72
|
-
type: 'column',
|
|
73
|
-
attrs: {
|
|
74
|
-
index: colIndex,
|
|
75
|
-
},
|
|
76
|
-
content: [
|
|
77
|
-
{
|
|
78
|
-
type: 'paragraph',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
colsJSON.attrs.cols = colsJSON.content.length;
|
|
85
|
-
|
|
86
|
-
colsJSON.content.forEach((colJSON: any, index: any) => {
|
|
87
|
-
colJSON.attrs.index = index;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const nextCols = Node.fromJSON(state.schema, colsJSON);
|
|
91
|
-
|
|
92
|
-
let nextSelectPos = maybeColumns.pos;
|
|
93
|
-
nextCols.content.forEach((col, pos, index) => {
|
|
94
|
-
if (index < nextIndex) {
|
|
95
|
-
nextSelectPos += col.nodeSize;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const tr = state.tr.setTime(Date.now());
|
|
100
|
-
|
|
101
|
-
tr.replaceWith(maybeColumns.pos, maybeColumns.pos + maybeColumns.node.nodeSize, nextCols).setSelection(
|
|
102
|
-
TextSelection.near(tr.doc.resolve(nextSelectPos)),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
dispatch(tr);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function gotoCol({ state, dispatch, type }: { state: EditorState, dispatch: any, type: 'before' | 'after' }) {
|
|
112
|
-
const maybeColumns = findParentNode((node: Node) => node.type.name === MultiColumn.name)(state.selection);
|
|
113
|
-
const maybeColumn = findParentNode((node: Node) => node.type.name === Column.name)(state.selection);
|
|
114
|
-
|
|
115
|
-
if (dispatch && maybeColumns && maybeColumn) {
|
|
116
|
-
const cols = maybeColumns.node;
|
|
117
|
-
const colIndex = maybeColumn.node.attrs.index;
|
|
118
|
-
|
|
119
|
-
let nextIndex = 0;
|
|
120
|
-
|
|
121
|
-
if (type === 'before') {
|
|
122
|
-
nextIndex = (colIndex - 1 + cols.attrs.cols) % cols.attrs.cols;
|
|
123
|
-
} else {
|
|
124
|
-
nextIndex = (colIndex + 1) % cols.attrs.cols;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
let nextSelectPos = maybeColumns.pos;
|
|
128
|
-
cols.content.forEach((col, pos, index) => {
|
|
129
|
-
if (index < nextIndex) {
|
|
130
|
-
nextSelectPos += col.nodeSize;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const tr = state.tr.setTime(Date.now());
|
|
135
|
-
|
|
136
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve(nextSelectPos)));
|
|
137
|
-
dispatch(tr);
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type EventValues } from 'reactjs-tiptap-editor-pro/utils/customEvents/events.constant';
|
|
2
|
-
|
|
3
|
-
export function listenEvent (eventName: EventValues, callback: any) {
|
|
4
|
-
window.addEventListener(eventName, callback);
|
|
5
|
-
|
|
6
|
-
return () => {
|
|
7
|
-
window.removeEventListener(eventName, callback);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
export function dispatchEvent (eventName: EventValues, detail?: any) {
|
|
13
|
-
window.dispatchEvent(
|
|
14
|
-
new CustomEvent(eventName, {
|
|
15
|
-
detail,
|
|
16
|
-
}),
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const EVENTS = {
|
|
2
|
-
UPLOAD_IMAGE: (id: any) => `UPLOAD_IMAGE-${id}`,
|
|
3
|
-
UPLOAD_VIDEO: (id: string) => `UPLOAD_VIDEO-${id}`,
|
|
4
|
-
EDIT: (id: string) => `EDIT-${id}`,
|
|
5
|
-
UPDATE_THEME: (id: string) => `UPDATE_THEME-${id}`,
|
|
6
|
-
|
|
7
|
-
SEARCH_REPLCE: 'SEARCH_REPLACE',
|
|
8
|
-
} as const;
|
|
9
|
-
|
|
10
|
-
// type EventsType = typeof EVENTS;
|
|
11
|
-
export type EventValues = any;
|
package/src/utils/delete-node.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
import type { Editor } from '@tiptap/core';
|
|
3
|
-
|
|
4
|
-
export function deleteNode(nodeType: string, editor: Editor) {
|
|
5
|
-
const { state } = editor;
|
|
6
|
-
const $pos = state.selection.$anchor;
|
|
7
|
-
let done = false;
|
|
8
|
-
|
|
9
|
-
if ($pos.depth) {
|
|
10
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
11
|
-
const node = $pos.node(d);
|
|
12
|
-
if (node.type.name === nodeType) {
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
if (editor.dispatchTransaction)
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
editor.dispatchTransaction(state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView());
|
|
17
|
-
done = true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
const node = state.selection.node;
|
|
23
|
-
if (node && node.type.name === nodeType) {
|
|
24
|
-
editor.chain().deleteSelection().run();
|
|
25
|
-
done = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!done) {
|
|
30
|
-
const pos = $pos.pos;
|
|
31
|
-
|
|
32
|
-
if (pos) {
|
|
33
|
-
const node = state.tr.doc.nodeAt(pos);
|
|
34
|
-
|
|
35
|
-
if (node && node.type.name === nodeType) {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
if (editor.dispatchTransaction)
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
editor.dispatchTransaction(state.tr.delete(pos, pos + node.nodeSize));
|
|
40
|
-
done = true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return done;
|
|
46
|
-
}
|