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
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
import { Node, mergeAttributes } from '@tiptap/core';
|
|
3
|
-
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
4
|
-
|
|
5
|
-
import { NodeViewTableOfContent } from 'reactjs-tiptap-editor-pro/extensions/TableOfContent/components/NodeViewTableOfContent';
|
|
6
|
-
import { TableOfContentActionButton } from 'reactjs-tiptap-editor-pro/extensions/TableOfContent/components/TableOfContentActionButton';
|
|
7
|
-
import { findNode, isTitleNode } from 'reactjs-tiptap-editor-pro/utils/node';
|
|
8
|
-
|
|
9
|
-
declare module '@tiptap/core' {
|
|
10
|
-
interface Commands<ReturnType> {
|
|
11
|
-
tableOfContents: {
|
|
12
|
-
setTableOfContents: () => ReturnType
|
|
13
|
-
removeTableOfContents: () => ReturnType
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface Options {
|
|
19
|
-
onHasOneBeforeInsert?: () => void
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const TableOfContents = Node.create<Options>({
|
|
23
|
-
name: 'tableOfContents',
|
|
24
|
-
group: 'block',
|
|
25
|
-
atom: true,
|
|
26
|
-
|
|
27
|
-
addOptions() {
|
|
28
|
-
return {
|
|
29
|
-
...this.parent?.(),
|
|
30
|
-
onHasOneBeforeInsert: () => {
|
|
31
|
-
return;
|
|
32
|
-
},
|
|
33
|
-
resizable: true,
|
|
34
|
-
lastColumnResizable: true,
|
|
35
|
-
allowTableNodeSelection: false,
|
|
36
|
-
button: ({ editor, t }: any) => ({
|
|
37
|
-
component: TableOfContentActionButton,
|
|
38
|
-
componentProps: {
|
|
39
|
-
disabled: false,
|
|
40
|
-
icon: 'BookMarked',
|
|
41
|
-
tooltip: t('editor.table.tooltip'),
|
|
42
|
-
editor,
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
parseHTML() {
|
|
49
|
-
return [
|
|
50
|
-
{
|
|
51
|
-
tag: 'toc',
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
renderHTML({ HTMLAttributes }) {
|
|
57
|
-
return ['toc', mergeAttributes(HTMLAttributes)];
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
addNodeView() {
|
|
61
|
-
return ReactNodeViewRenderer(NodeViewTableOfContent);
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
// @ts-expect-error
|
|
65
|
-
addCommands() {
|
|
66
|
-
return {
|
|
67
|
-
setTableOfContents:
|
|
68
|
-
() =>
|
|
69
|
-
({ commands, editor, view }) => {
|
|
70
|
-
const nodes = findNode(editor, this.name);
|
|
71
|
-
|
|
72
|
-
if (nodes.length > 0) {
|
|
73
|
-
// @ts-expect-error
|
|
74
|
-
this.options.onHasOneBeforeInsert();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const titleNode = view.props.state.doc.content.firstChild as any;
|
|
79
|
-
|
|
80
|
-
if (isTitleNode(titleNode)) {
|
|
81
|
-
const pos = ((titleNode.firstChild && titleNode.firstChild.nodeSize) || 0) + 1;
|
|
82
|
-
return commands.insertContentAt(pos, { type: this.name });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return commands.insertContent({
|
|
86
|
-
type: this.name,
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
removeTableOfContents: () =>
|
|
90
|
-
({ state, dispatch }: any) => {
|
|
91
|
-
const { tr } = state;
|
|
92
|
-
const nodeType = state.schema.nodes.tableOfContents;
|
|
93
|
-
|
|
94
|
-
state.doc.descendants((node: any, pos: any) => {
|
|
95
|
-
if (node.type === nodeType) {
|
|
96
|
-
const from = pos;
|
|
97
|
-
const to = pos + node.nodeSize;
|
|
98
|
-
tr.delete(from, to);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
if (tr.docChanged) {
|
|
103
|
-
dispatch(tr);
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return false;
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
addGlobalAttributes() {
|
|
113
|
-
return [
|
|
114
|
-
{
|
|
115
|
-
types: ['heading'],
|
|
116
|
-
attributes: {
|
|
117
|
-
id: {
|
|
118
|
-
default: null,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
},
|
|
124
|
-
});
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import { NodeViewWrapper } from '@tiptap/react';
|
|
6
|
-
import cls from 'clsx';
|
|
7
|
-
|
|
8
|
-
import { useLocale } from 'reactjs-tiptap-editor-pro/locales';
|
|
9
|
-
import { useEditableEditor } from 'reactjs-tiptap-editor-pro/store/editableEditor';
|
|
10
|
-
|
|
11
|
-
import styles from './index.module.scss';
|
|
12
|
-
|
|
13
|
-
function arrToTree(tocs: any) {
|
|
14
|
-
const result = [] as any;
|
|
15
|
-
const levels = [result];
|
|
16
|
-
|
|
17
|
-
tocs.forEach((o: any) => {
|
|
18
|
-
let offset = -1;
|
|
19
|
-
let parent = levels[o.level + offset];
|
|
20
|
-
|
|
21
|
-
while (!parent) {
|
|
22
|
-
offset -= 1;
|
|
23
|
-
parent = levels[o.level + offset];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
parent.push({ ...o, children: (levels[o.level] = []) });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function NodeViewTableOfContent({ editor }: any) {
|
|
33
|
-
const isEditable = useEditableEditor();
|
|
34
|
-
const [items, setItems] = useState([]);
|
|
35
|
-
const { t } = useLocale();
|
|
36
|
-
|
|
37
|
-
const handleUpdate = useCallback(() => {
|
|
38
|
-
const headings = [] as any;
|
|
39
|
-
const transaction = editor.state.tr;
|
|
40
|
-
|
|
41
|
-
editor.state.doc.descendants((node: any, pos: any) => {
|
|
42
|
-
if (node.type.name === 'heading') {
|
|
43
|
-
const id = `heading-${headings.length + 1}`;
|
|
44
|
-
|
|
45
|
-
if (node.attrs.id !== id) {
|
|
46
|
-
transaction.setNodeMarkup(pos, undefined, {
|
|
47
|
-
...node.attrs,
|
|
48
|
-
id,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
headings.push({
|
|
53
|
-
level: node.attrs.level,
|
|
54
|
-
text: node.textContent,
|
|
55
|
-
id,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
transaction.setMeta('addToHistory', false);
|
|
61
|
-
transaction.setMeta('preventUpdate', true);
|
|
62
|
-
editor.view.dispatch(transaction);
|
|
63
|
-
|
|
64
|
-
setItems(headings);
|
|
65
|
-
editor.eventEmitter && editor.eventEmitter.emit('TableOfContents', arrToTree(headings));
|
|
66
|
-
}, [editor]);
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (!editor) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!editor.options.editable) {
|
|
74
|
-
handleUpdate();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
editor.on('update', handleUpdate);
|
|
79
|
-
|
|
80
|
-
return () => {
|
|
81
|
-
editor.off('update', handleUpdate);
|
|
82
|
-
};
|
|
83
|
-
}, [editor, handleUpdate]);
|
|
84
|
-
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
handleUpdate();
|
|
87
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
-
}, []);
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<NodeViewWrapper className={cls('tableOfContent', styles.toc, isEditable && styles.visible)}>
|
|
92
|
-
{isEditable
|
|
93
|
-
? (
|
|
94
|
-
<div style={{ position: 'relative' }}>
|
|
95
|
-
<p className="text-[20px] mb-[8px] font-semibold">
|
|
96
|
-
{t('editor.table_of_content')}
|
|
97
|
-
</p>
|
|
98
|
-
|
|
99
|
-
<ul className={styles.list}>
|
|
100
|
-
{items.map((item: any, index) => (
|
|
101
|
-
<li className={styles.item}
|
|
102
|
-
key={`table-of-content-${index}`}
|
|
103
|
-
style={{ paddingLeft: `${item.level - 1}rem` }}
|
|
104
|
-
>
|
|
105
|
-
<a href={`#${item.id}`}>
|
|
106
|
-
{item.text}
|
|
107
|
-
</a>
|
|
108
|
-
</li>
|
|
109
|
-
))}
|
|
110
|
-
</ul>
|
|
111
|
-
</div>
|
|
112
|
-
)
|
|
113
|
-
: null}
|
|
114
|
-
</NodeViewWrapper>
|
|
115
|
-
);
|
|
116
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { Editor } from '@tiptap/core';
|
|
4
|
-
import { ActionButton } from 'reactjs-tiptap-editor-pro/components/ActionButton';
|
|
5
|
-
import { TableOfContents } from 'reactjs-tiptap-editor-pro/extensions/TableOfContent/TableOfContent';
|
|
6
|
-
import { useActive } from 'reactjs-tiptap-editor-pro/hooks/useActive';
|
|
7
|
-
|
|
8
|
-
export function TableOfContentActionButton({ editor, icon, tooltip }: { editor: Editor, tooltip: string, icon: string }) {
|
|
9
|
-
const isTaskListActive = useActive(editor, TableOfContents.name);
|
|
10
|
-
|
|
11
|
-
const tableOfContent = useCallback(() => {
|
|
12
|
-
if (isTaskListActive) {
|
|
13
|
-
editor.chain().focus().removeTableOfContents().run();
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
editor.chain().focus().setTableOfContents().run();
|
|
17
|
-
}, [editor, isTaskListActive]);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<ActionButton
|
|
21
|
-
action={tableOfContent}
|
|
22
|
-
isActive={() => isTaskListActive || false}
|
|
23
|
-
icon={icon}
|
|
24
|
-
tooltip={tooltip}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.toc {
|
|
2
|
-
width: max-content;
|
|
3
|
-
max-width: 100%;
|
|
4
|
-
border-radius: 0.5rem;
|
|
5
|
-
opacity: 0.75;
|
|
6
|
-
|
|
7
|
-
&.visible {
|
|
8
|
-
padding: 0.75rem;
|
|
9
|
-
margin: 0.75em 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.list {
|
|
13
|
-
padding: 0;
|
|
14
|
-
margin: 0 0 12px;
|
|
15
|
-
list-style: none;
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.item {
|
|
20
|
-
a:hover {
|
|
21
|
-
opacity: 0.5;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&--3 {
|
|
25
|
-
padding-left: 1rem;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&--4 {
|
|
29
|
-
padding-left: 2rem;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&--5 {
|
|
33
|
-
padding-left: 3rem;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&--6 {
|
|
37
|
-
padding-left: 4rem;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './TableOfContent';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { TaskItemOptions } from '@tiptap/extension-task-item';
|
|
2
|
-
import { TaskItem } from '@tiptap/extension-task-item';
|
|
3
|
-
import type { TaskListOptions as TiptapTaskListOptions } from '@tiptap/extension-task-list';
|
|
4
|
-
import { TaskList as TiptapTaskList } from '@tiptap/extension-task-list';
|
|
5
|
-
|
|
6
|
-
import { ActionButton } from 'reactjs-tiptap-editor-pro/components';
|
|
7
|
-
import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Represents the interface for task list options, extending TiptapTaskListOptions and GeneralOptions.
|
|
11
|
-
*/
|
|
12
|
-
export interface TaskListOptions extends TiptapTaskListOptions, GeneralOptions<TaskListOptions> {
|
|
13
|
-
/** options for task items */
|
|
14
|
-
taskItem: Partial<TaskItemOptions>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const TaskList = TiptapTaskList.extend<TaskListOptions>({
|
|
18
|
-
addOptions() {
|
|
19
|
-
return {
|
|
20
|
-
...this.parent?.(),
|
|
21
|
-
HTMLAttributes: {
|
|
22
|
-
class: 'task-list',
|
|
23
|
-
},
|
|
24
|
-
taskItem: {
|
|
25
|
-
HTMLAttributes: {
|
|
26
|
-
class: 'task-list-item',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
button: ({ editor, t }) => ({
|
|
30
|
-
component: ActionButton,
|
|
31
|
-
componentProps: {
|
|
32
|
-
action: () => editor.commands.toggleTaskList(),
|
|
33
|
-
isActive: () => editor.isActive('taskList') || false,
|
|
34
|
-
disabled: false,
|
|
35
|
-
icon: 'ListTodo',
|
|
36
|
-
shortcutKeys: ['shift', 'mod', '9'],
|
|
37
|
-
tooltip: t('editor.tasklist.tooltip'),
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
addExtensions() {
|
|
44
|
-
return [TaskItem.configure(this.options.taskItem)];
|
|
45
|
-
},
|
|
46
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './TaskList';
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { Editor, Extension } from '@tiptap/core';
|
|
2
|
-
import type { TextAlignOptions as TiptapTextAlignOptions } from '@tiptap/extension-text-align';
|
|
3
|
-
import TiptapTextAlign from '@tiptap/extension-text-align';
|
|
4
|
-
|
|
5
|
-
import TextAlignMenuButton from 'reactjs-tiptap-editor-pro/extensions/TextAlign/components/TextAlignMenuButton';
|
|
6
|
-
import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
|
|
7
|
-
|
|
8
|
-
type Alignments = 'left' | 'center' | 'right' | 'justify';
|
|
9
|
-
/**
|
|
10
|
-
* Represents the interface for text align options, extending TiptapTextAlignOptions and GeneralOptions.
|
|
11
|
-
*/
|
|
12
|
-
export interface TextAlignOptions extends TiptapTextAlignOptions, GeneralOptions<TextAlignOptions> {
|
|
13
|
-
/**
|
|
14
|
-
* List of available alignment options
|
|
15
|
-
*
|
|
16
|
-
* @default ['left', 'center', 'right', 'justify']
|
|
17
|
-
*/
|
|
18
|
-
alignments: Alignments[]
|
|
19
|
-
}
|
|
20
|
-
export const TextAlign = TiptapTextAlign.extend<TextAlignOptions>({
|
|
21
|
-
addOptions() {
|
|
22
|
-
return {
|
|
23
|
-
...this.parent?.(),
|
|
24
|
-
types: ['heading', 'paragraph', 'list_item', 'title'],
|
|
25
|
-
button({
|
|
26
|
-
editor,
|
|
27
|
-
extension,
|
|
28
|
-
t,
|
|
29
|
-
}: {
|
|
30
|
-
editor: Editor
|
|
31
|
-
extension: Extension
|
|
32
|
-
t: (...args: any[]) => string
|
|
33
|
-
}) {
|
|
34
|
-
const alignments = (extension.options?.alignments as Alignments[]) || [];
|
|
35
|
-
const shortcutKeysMap = {
|
|
36
|
-
left: ['mod', 'Shift', 'L'],
|
|
37
|
-
center: ['mod', 'Shift', 'E'],
|
|
38
|
-
right: ['mod', 'Shift', 'R'],
|
|
39
|
-
justify: ['mod', 'Shift', 'J'],
|
|
40
|
-
};
|
|
41
|
-
const iconMap = {
|
|
42
|
-
left: 'AlignLeft',
|
|
43
|
-
center: 'AlignCenter',
|
|
44
|
-
right: 'AlignRight',
|
|
45
|
-
justify: 'AlignJustify',
|
|
46
|
-
};
|
|
47
|
-
const items = alignments.map(k => ({
|
|
48
|
-
title: t(`editor.textalign.${k}.tooltip`),
|
|
49
|
-
icon: iconMap[k],
|
|
50
|
-
shortcutKeys: shortcutKeysMap[k],
|
|
51
|
-
isActive: () => editor.isActive({ textAlign: k }) || false,
|
|
52
|
-
action: () => editor.commands?.setTextAlign?.(k),
|
|
53
|
-
disabled: !editor?.can?.()?.setTextAlign?.(k),
|
|
54
|
-
}));
|
|
55
|
-
const disabled = items.filter(k => k.disabled).length === items.length;
|
|
56
|
-
return {
|
|
57
|
-
component: TextAlignMenuButton,
|
|
58
|
-
componentProps: {
|
|
59
|
-
icon: 'AlignJustify',
|
|
60
|
-
tooltip: t('editor.textalign.tooltip'),
|
|
61
|
-
disabled,
|
|
62
|
-
items,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { ActionButton, IconComponent } from 'reactjs-tiptap-editor-pro/components';
|
|
4
|
-
import { Popover, PopoverContent, PopoverTrigger, Toggle, Tooltip, TooltipContent, TooltipTrigger } from 'reactjs-tiptap-editor-pro/components/ui';
|
|
5
|
-
import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
|
|
6
|
-
import { getShortcutKey } from 'reactjs-tiptap-editor-pro/utils/plateform';
|
|
7
|
-
|
|
8
|
-
export interface Item {
|
|
9
|
-
title: string
|
|
10
|
-
icon?: any
|
|
11
|
-
isActive: NonNullable<ButtonViewReturnComponentProps['isActive']>
|
|
12
|
-
action?: ButtonViewReturnComponentProps['action']
|
|
13
|
-
style?: React.CSSProperties
|
|
14
|
-
shortcutKeys?: string[]
|
|
15
|
-
disabled?: boolean
|
|
16
|
-
divider?: boolean
|
|
17
|
-
default?: boolean
|
|
18
|
-
}
|
|
19
|
-
interface IPropsTextAlignMenuButton {
|
|
20
|
-
editor: any
|
|
21
|
-
disabled?: boolean
|
|
22
|
-
color?: string
|
|
23
|
-
maxHeight?: string | number
|
|
24
|
-
icon?: any
|
|
25
|
-
tooltip?: string
|
|
26
|
-
items?: Item[]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function TextAlignMenuButton(props: IPropsTextAlignMenuButton) {
|
|
30
|
-
const active = useMemo(() => {
|
|
31
|
-
const find: any = props?.items?.find((k: any) => k.isActive());
|
|
32
|
-
if (find && !find.default) {
|
|
33
|
-
return {
|
|
34
|
-
...find,
|
|
35
|
-
icon: find.icon ? find.icon : props.icon,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const item: Item = {
|
|
39
|
-
title: props?.tooltip as any,
|
|
40
|
-
icon: props.icon,
|
|
41
|
-
isActive: () => false,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return item;
|
|
45
|
-
}, [props]);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Popover modal>
|
|
49
|
-
<PopoverTrigger asChild
|
|
50
|
-
disabled={props?.disabled}
|
|
51
|
-
>
|
|
52
|
-
<ActionButton
|
|
53
|
-
customClass="!w-12 h-12"
|
|
54
|
-
disabled={props?.disabled}
|
|
55
|
-
icon={props?.icon}
|
|
56
|
-
tooltip={props?.tooltip}
|
|
57
|
-
>
|
|
58
|
-
<IconComponent className="ml-1 size-3 text-zinc-500"
|
|
59
|
-
name="MenuDown"
|
|
60
|
-
/>
|
|
61
|
-
</ActionButton>
|
|
62
|
-
</PopoverTrigger>
|
|
63
|
-
|
|
64
|
-
<PopoverContent
|
|
65
|
-
align="start"
|
|
66
|
-
className="flex w-full min-w-4 flex-row gap-1 !p-[4px]"
|
|
67
|
-
side="bottom"
|
|
68
|
-
>
|
|
69
|
-
{props?.items?.map((item, index) => {
|
|
70
|
-
return (
|
|
71
|
-
<Tooltip key={`text-align-${index}`}>
|
|
72
|
-
<TooltipTrigger asChild>
|
|
73
|
-
<Toggle
|
|
74
|
-
className="size-7 p-1"
|
|
75
|
-
data-state={active.title === item.title ? 'on' : 'off'}
|
|
76
|
-
onClick={item?.action}
|
|
77
|
-
pressed={active.title === item.title}
|
|
78
|
-
size="sm"
|
|
79
|
-
>
|
|
80
|
-
{item?.icon && <IconComponent name={item.icon} />}
|
|
81
|
-
</Toggle>
|
|
82
|
-
</TooltipTrigger>
|
|
83
|
-
|
|
84
|
-
<TooltipContent className="flex flex-col items-center">
|
|
85
|
-
<span>
|
|
86
|
-
{item.title}
|
|
87
|
-
</span>
|
|
88
|
-
|
|
89
|
-
{!!item.shortcutKeys?.length && (
|
|
90
|
-
<span>
|
|
91
|
-
{item.shortcutKeys?.map(item => getShortcutKey(item)).join(' ')}
|
|
92
|
-
</span>
|
|
93
|
-
)}
|
|
94
|
-
</TooltipContent>
|
|
95
|
-
</Tooltip>
|
|
96
|
-
);
|
|
97
|
-
})}
|
|
98
|
-
</PopoverContent>
|
|
99
|
-
</Popover>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default TextAlignMenuButton;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './TextAlign';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
import TextDropdown from './components/TextDropdown';
|
|
4
|
-
import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
|
|
5
|
-
|
|
6
|
-
export interface TextBubbleOptions extends GeneralOptions<TextBubbleOptions> {}
|
|
7
|
-
|
|
8
|
-
export const TextBubble = Extension.create<TextBubbleOptions>({
|
|
9
|
-
name: 'text-bubble',
|
|
10
|
-
addOptions() {
|
|
11
|
-
return {
|
|
12
|
-
...this.parent?.(),
|
|
13
|
-
toolbar: false,
|
|
14
|
-
button: () => ({
|
|
15
|
-
component: TextDropdown,
|
|
16
|
-
componentProps: {},
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export default TextBubble;
|