reactjs-tiptap-editor-pro 0.2.31 → 0.2.33
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/ColorPicker-MEAh4MhG.js +28181 -0
- package/lib/ColorPicker-ZncOwjAP.cjs +142 -0
- package/lib/extension-bundle.cjs +133 -0
- package/lib/extension-bundle.d.cts +947 -0
- package/lib/extension-bundle.d.ts +947 -0
- package/lib/extension-bundle.js +23921 -0
- package/lib/index.cjs +140 -0
- package/lib/index.d.cts +513 -0
- package/lib/index.d.ts +513 -0
- package/lib/index.js +3700 -0
- package/lib/locale-bundle-DiqW5jwb.cjs +1 -0
- package/lib/locale-bundle-DxCAtRDI.js +1487 -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/lucide-react-BFZtMawV.js +30462 -0
- package/lib/lucide-react-CMPhLW1m.cjs +7851 -0
- package/lib/style.css +1 -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,109 +0,0 @@
|
|
|
1
|
-
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
|
|
2
|
-
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
-
|
|
4
|
-
import KatexActiveButton from 'reactjs-tiptap-editor-pro/extensions/Katex/components/KatexActiveButton';
|
|
5
|
-
import { KatexWrapper } from 'reactjs-tiptap-editor-pro/extensions/Katex/components/KatexWrapper';
|
|
6
|
-
|
|
7
|
-
export interface IKatexAttrs {
|
|
8
|
-
text?: string
|
|
9
|
-
defaultShowPicker?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface IKatexOptions {
|
|
13
|
-
HTMLAttributes: Record<string, any>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getDatasetAttribute(attribute: string) {
|
|
17
|
-
return (element: any) => {
|
|
18
|
-
return element.getAttribute(attribute);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare module '@tiptap/core' {
|
|
23
|
-
interface Commands<ReturnType> {
|
|
24
|
-
katex: {
|
|
25
|
-
setKatex: (arg?: IKatexAttrs) => ReturnType
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const Katex = Node.create<IKatexOptions>({
|
|
31
|
-
name: 'katex',
|
|
32
|
-
group: 'inline',
|
|
33
|
-
inline: true,
|
|
34
|
-
defining: true,
|
|
35
|
-
draggable: true,
|
|
36
|
-
selectable: true,
|
|
37
|
-
|
|
38
|
-
addOptions() {
|
|
39
|
-
return {
|
|
40
|
-
HTMLAttributes: {
|
|
41
|
-
class: 'katex',
|
|
42
|
-
},
|
|
43
|
-
button: ({ editor, t }: any) => {
|
|
44
|
-
return {
|
|
45
|
-
component: KatexActiveButton,
|
|
46
|
-
componentProps: {
|
|
47
|
-
editor,
|
|
48
|
-
action: () => {
|
|
49
|
-
return true;
|
|
50
|
-
},
|
|
51
|
-
isActive: () => false,
|
|
52
|
-
disabled: false,
|
|
53
|
-
icon: 'KatexIcon',
|
|
54
|
-
tooltip: t('editor.katex.tooltip'),
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
addAttributes() {
|
|
62
|
-
return {
|
|
63
|
-
text: {
|
|
64
|
-
default: '',
|
|
65
|
-
parseHTML: getDatasetAttribute('text'),
|
|
66
|
-
},
|
|
67
|
-
defaultShowPicker: {
|
|
68
|
-
default: false,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
parseHTML() {
|
|
74
|
-
return [{ tag: 'span.katex' }];
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
renderHTML({ HTMLAttributes }) {
|
|
78
|
-
return ['span', mergeAttributes((this.options && this.options.HTMLAttributes) || {}, HTMLAttributes)];
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
addCommands() {
|
|
82
|
-
return {
|
|
83
|
-
setKatex:
|
|
84
|
-
options =>
|
|
85
|
-
({ commands }) => {
|
|
86
|
-
return commands.insertContent({
|
|
87
|
-
type: this.name,
|
|
88
|
-
attrs: options,
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
addInputRules() {
|
|
95
|
-
return [
|
|
96
|
-
nodeInputRule({
|
|
97
|
-
find: /^\$katex\$$/,
|
|
98
|
-
type: this.type,
|
|
99
|
-
getAttributes: () => {
|
|
100
|
-
return { defaultShowPicker: true };
|
|
101
|
-
},
|
|
102
|
-
}),
|
|
103
|
-
];
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
addNodeView() {
|
|
107
|
-
return ReactNodeViewRenderer(KatexWrapper);
|
|
108
|
-
},
|
|
109
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import katex from 'katex';
|
|
4
|
-
import { HelpCircle } from 'lucide-react';
|
|
5
|
-
|
|
6
|
-
import { ActionButton, Button, Label, Popover, PopoverContent, PopoverTrigger } from 'reactjs-tiptap-editor-pro/components';
|
|
7
|
-
import { Textarea } from 'reactjs-tiptap-editor-pro/components/ui/textarea';
|
|
8
|
-
import type { IKatexAttrs } from 'reactjs-tiptap-editor-pro/extensions/Katex/Katex';
|
|
9
|
-
import { Katex } from 'reactjs-tiptap-editor-pro/extensions/Katex/Katex';
|
|
10
|
-
import { useAttributes } from 'reactjs-tiptap-editor-pro/hooks/useAttributes';
|
|
11
|
-
import { useLocale } from 'reactjs-tiptap-editor-pro/locales';
|
|
12
|
-
|
|
13
|
-
function KatexActiveButton({ editor, ...props }: any) {
|
|
14
|
-
const { t } = useLocale();
|
|
15
|
-
|
|
16
|
-
const attrs = useAttributes<IKatexAttrs>(editor, Katex.name, {
|
|
17
|
-
text: '',
|
|
18
|
-
defaultShowPicker: false,
|
|
19
|
-
});
|
|
20
|
-
const { text, defaultShowPicker } = attrs;
|
|
21
|
-
|
|
22
|
-
const [currentValue, setCurrentValue] = useState('');
|
|
23
|
-
|
|
24
|
-
const submit = useCallback(() => {
|
|
25
|
-
editor.chain().focus().setKatex({ text: currentValue }).run();
|
|
26
|
-
setCurrentValue('');
|
|
27
|
-
}, [editor, currentValue]);
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (defaultShowPicker) {
|
|
31
|
-
editor.chain().updateAttributes(Katex.name, { defaultShowPicker: false }).focus().run();
|
|
32
|
-
}
|
|
33
|
-
}, [editor, defaultShowPicker]);
|
|
34
|
-
|
|
35
|
-
const formatText = useMemo(() => {
|
|
36
|
-
try {
|
|
37
|
-
return katex.renderToString(`${currentValue}`);
|
|
38
|
-
} catch {
|
|
39
|
-
return currentValue;
|
|
40
|
-
}
|
|
41
|
-
}, [currentValue]);
|
|
42
|
-
|
|
43
|
-
const previewContent = useMemo(
|
|
44
|
-
() => {
|
|
45
|
-
if (`${currentValue}`.trim()) {
|
|
46
|
-
return (
|
|
47
|
-
<span contentEditable={false}
|
|
48
|
-
dangerouslySetInnerHTML={{ __html: formatText || '' }}
|
|
49
|
-
>
|
|
50
|
-
</span>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return null;
|
|
55
|
-
},
|
|
56
|
-
[currentValue, formatText],
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Popover modal>
|
|
61
|
-
<PopoverTrigger asChild>
|
|
62
|
-
<ActionButton
|
|
63
|
-
icon={props?.icon}
|
|
64
|
-
tooltip={props?.tooltip}
|
|
65
|
-
/>
|
|
66
|
-
</PopoverTrigger>
|
|
67
|
-
|
|
68
|
-
<PopoverContent align="start"
|
|
69
|
-
className="size-full p-2"
|
|
70
|
-
hideWhenDetached
|
|
71
|
-
side="bottom"
|
|
72
|
-
>
|
|
73
|
-
<Label className="mb-[6px]">
|
|
74
|
-
{t('editor.formula.dialog.text')}
|
|
75
|
-
</Label>
|
|
76
|
-
|
|
77
|
-
<div className="mb-[16px] flex w-full max-w-sm items-center gap-1.5">
|
|
78
|
-
<div className="relative w-full max-w-sm">
|
|
79
|
-
<Textarea
|
|
80
|
-
autoFocus
|
|
81
|
-
className="w-full"
|
|
82
|
-
defaultValue={text}
|
|
83
|
-
onChange={e => setCurrentValue(e.target.value)}
|
|
84
|
-
placeholder="Text"
|
|
85
|
-
required
|
|
86
|
-
rows={3}
|
|
87
|
-
value={currentValue}
|
|
88
|
-
/>
|
|
89
|
-
</div>
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
{previewContent && (
|
|
93
|
-
<div className="my-[10px] max-w-[286px] overflow-auto whitespace-nowrap rounded-[6px] !border p-[10px]">
|
|
94
|
-
{previewContent}
|
|
95
|
-
</div>
|
|
96
|
-
)}
|
|
97
|
-
|
|
98
|
-
<div className="flex items-center justify-between gap-[6px]">
|
|
99
|
-
<Button className="flex-1"
|
|
100
|
-
onClick={submit}
|
|
101
|
-
>
|
|
102
|
-
Submit
|
|
103
|
-
</Button>
|
|
104
|
-
|
|
105
|
-
<a href="https://katex.org/docs/supported"
|
|
106
|
-
rel="noreferrer noopener"
|
|
107
|
-
target="_blank"
|
|
108
|
-
>
|
|
109
|
-
<HelpCircle size={16} />
|
|
110
|
-
</a>
|
|
111
|
-
</div>
|
|
112
|
-
</PopoverContent>
|
|
113
|
-
</Popover>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export default KatexActiveButton;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { NodeViewWrapper } from '@tiptap/react';
|
|
4
|
-
|
|
5
|
-
import katex from 'katex';
|
|
6
|
-
import { useTheme } from 'reactjs-tiptap-editor-pro/theme/theme';
|
|
7
|
-
import { convertColorToRGBA } from 'reactjs-tiptap-editor-pro/utils/color';
|
|
8
|
-
|
|
9
|
-
export function KatexWrapper({ node }: any) {
|
|
10
|
-
const theme = useTheme();
|
|
11
|
-
const { text } = node.attrs;
|
|
12
|
-
|
|
13
|
-
const backgroundColor = useMemo(() => {
|
|
14
|
-
const color = 'rgb(254, 242, 237)';
|
|
15
|
-
if (theme === 'dark')
|
|
16
|
-
return convertColorToRGBA(color, 0.75);
|
|
17
|
-
return color;
|
|
18
|
-
}, [theme]);
|
|
19
|
-
|
|
20
|
-
const formatText = useMemo(() => {
|
|
21
|
-
try {
|
|
22
|
-
return katex.renderToString(`${text}`);
|
|
23
|
-
} catch {
|
|
24
|
-
return text;
|
|
25
|
-
}
|
|
26
|
-
}, [text]);
|
|
27
|
-
|
|
28
|
-
const content = useMemo(
|
|
29
|
-
() =>
|
|
30
|
-
text.trim()
|
|
31
|
-
? (
|
|
32
|
-
<span contentEditable={false} dangerouslySetInnerHTML={{ __html: formatText }}></span>
|
|
33
|
-
)
|
|
34
|
-
: (
|
|
35
|
-
<span contentEditable={false}>
|
|
36
|
-
Not enter a formula
|
|
37
|
-
</span>
|
|
38
|
-
),
|
|
39
|
-
[text, formatText],
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<NodeViewWrapper
|
|
44
|
-
style={{
|
|
45
|
-
display: 'inline-block',
|
|
46
|
-
backgroundColor,
|
|
47
|
-
}}
|
|
48
|
-
as="span"
|
|
49
|
-
>
|
|
50
|
-
{content}
|
|
51
|
-
</NodeViewWrapper>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Katex';
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import type { Editor } from '@tiptap/core';
|
|
3
|
-
|
|
4
|
-
import { DEFAULT_LINE_HEIGHT, DEFAULT_LINE_HEIGHT_LIST } from 'reactjs-tiptap-editor-pro/constants';
|
|
5
|
-
import LineHeightDropdown from 'reactjs-tiptap-editor-pro/extensions/LineHeight/components/LineHeightDropdown';
|
|
6
|
-
import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
|
|
7
|
-
import { createLineHeightCommand } from 'reactjs-tiptap-editor-pro/utils/line-height';
|
|
8
|
-
|
|
9
|
-
export interface LineHeightOptions extends GeneralOptions<LineHeightOptions> {
|
|
10
|
-
types: string[]
|
|
11
|
-
lineHeights: string[]
|
|
12
|
-
defaultHeight: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare module '@tiptap/core' {
|
|
16
|
-
interface Commands<ReturnType> {
|
|
17
|
-
lineHeight: {
|
|
18
|
-
setLineHeight: (lineHeight: string) => ReturnType
|
|
19
|
-
unsetLineHeight: () => ReturnType
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const LineHeight = Extension.create<LineHeightOptions>({
|
|
25
|
-
name: 'lineHeight',
|
|
26
|
-
addOptions() {
|
|
27
|
-
return {
|
|
28
|
-
...this.parent?.(),
|
|
29
|
-
types: ['paragraph', 'heading', 'list_item', 'todo_item'],
|
|
30
|
-
lineHeights: DEFAULT_LINE_HEIGHT_LIST,
|
|
31
|
-
defaultHeight: DEFAULT_LINE_HEIGHT,
|
|
32
|
-
button({ editor, t }: { editor: Editor, t: any }) {
|
|
33
|
-
return {
|
|
34
|
-
component: LineHeightDropdown,
|
|
35
|
-
componentProps: {
|
|
36
|
-
editor,
|
|
37
|
-
tooltip: t('editor.lineheight.tooltip'),
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
addGlobalAttributes() {
|
|
45
|
-
return [
|
|
46
|
-
{
|
|
47
|
-
types: this.options.types,
|
|
48
|
-
attributes: {
|
|
49
|
-
lineHeight: {
|
|
50
|
-
default: null,
|
|
51
|
-
parseHTML: (element) => {
|
|
52
|
-
return element.style.lineHeight || this.options.defaultHeight;
|
|
53
|
-
},
|
|
54
|
-
renderHTML: (attributes) => {
|
|
55
|
-
if (attributes.lineHeight === this.options.defaultHeight || !attributes.lineHeight) {
|
|
56
|
-
return {};
|
|
57
|
-
}
|
|
58
|
-
return { style: `line-height: ${attributes.lineHeight}` };
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
addCommands() {
|
|
67
|
-
return {
|
|
68
|
-
setLineHeight: lineHeight => createLineHeightCommand(lineHeight),
|
|
69
|
-
unsetLineHeight:
|
|
70
|
-
() =>
|
|
71
|
-
({ commands }) => {
|
|
72
|
-
return this.options.types.every(type => commands.resetAttributes(type, 'lineHeight'));
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ActionButton,
|
|
5
|
-
DropdownMenu,
|
|
6
|
-
DropdownMenuCheckboxItem,
|
|
7
|
-
DropdownMenuContent,
|
|
8
|
-
DropdownMenuTrigger,
|
|
9
|
-
IconComponent,
|
|
10
|
-
} from 'reactjs-tiptap-editor-pro/components';
|
|
11
|
-
import { useLocale } from 'reactjs-tiptap-editor-pro/locales';
|
|
12
|
-
import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
|
|
13
|
-
|
|
14
|
-
interface IPropsLineHeightDropdown {
|
|
15
|
-
editor: any
|
|
16
|
-
icon?: any
|
|
17
|
-
tooltip?: string
|
|
18
|
-
disabled?: boolean
|
|
19
|
-
action?: ButtonViewReturnComponentProps['action']
|
|
20
|
-
isActive?: ButtonViewReturnComponentProps['isActive']
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function percentageToDecimal(percentageString: any) {
|
|
24
|
-
const percentage = Number.parseFloat(percentageString.replace('%', ''));
|
|
25
|
-
const decimal = percentage / 100;
|
|
26
|
-
return decimal;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function LineHeightDropdown(props: IPropsLineHeightDropdown) {
|
|
30
|
-
const { t } = useLocale();
|
|
31
|
-
const [value, setValue] = useState('default');
|
|
32
|
-
|
|
33
|
-
function toggleLightheight(key: string) {
|
|
34
|
-
if (key === 'default') {
|
|
35
|
-
props.editor.commands.unsetLineHeight();
|
|
36
|
-
} else {
|
|
37
|
-
props.editor.commands.setLineHeight(key);
|
|
38
|
-
}
|
|
39
|
-
setValue(key);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const LineHeights = useMemo(() => {
|
|
43
|
-
const lineHeightOptions = props.editor.extensionManager.extensions.find(
|
|
44
|
-
(e: any) => e.name === 'lineHeight',
|
|
45
|
-
)!.options;
|
|
46
|
-
const a = lineHeightOptions.lineHeights;
|
|
47
|
-
const b = a.map((item: any) => ({
|
|
48
|
-
label: percentageToDecimal(item),
|
|
49
|
-
value: item,
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
b.unshift({
|
|
53
|
-
label: t('editor.default'),
|
|
54
|
-
value: 'default',
|
|
55
|
-
});
|
|
56
|
-
return b;
|
|
57
|
-
}, [props]);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<DropdownMenu>
|
|
61
|
-
<DropdownMenuTrigger asChild
|
|
62
|
-
disabled={props?.disabled}
|
|
63
|
-
>
|
|
64
|
-
<ActionButton
|
|
65
|
-
customClass="!w-12 h-12"
|
|
66
|
-
disabled={props?.disabled}
|
|
67
|
-
icon="LineHeight"
|
|
68
|
-
tooltip={props?.tooltip}
|
|
69
|
-
>
|
|
70
|
-
<IconComponent className="ml-1 size-3 text-zinc-500"
|
|
71
|
-
name="MenuDown"
|
|
72
|
-
/>
|
|
73
|
-
</ActionButton>
|
|
74
|
-
</DropdownMenuTrigger>
|
|
75
|
-
|
|
76
|
-
<DropdownMenuContent className="min-w-24">
|
|
77
|
-
{LineHeights?.map((item: any, index: any) => {
|
|
78
|
-
return (
|
|
79
|
-
<DropdownMenuCheckboxItem
|
|
80
|
-
checked={item.value === value}
|
|
81
|
-
key={`lineHeight-${index}`}
|
|
82
|
-
onClick={() => toggleLightheight(item.value)}
|
|
83
|
-
>
|
|
84
|
-
{item.label}
|
|
85
|
-
</DropdownMenuCheckboxItem>
|
|
86
|
-
);
|
|
87
|
-
})}
|
|
88
|
-
</DropdownMenuContent>
|
|
89
|
-
</DropdownMenu>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export default LineHeightDropdown;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './LineHeight';
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { getMarkRange, mergeAttributes } from '@tiptap/core';
|
|
2
|
-
import type { LinkOptions as TiptapLinkOptions } from '@tiptap/extension-link';
|
|
3
|
-
import { Link as TiptapLink } from '@tiptap/extension-link';
|
|
4
|
-
import { Plugin, TextSelection } from '@tiptap/pm/state';
|
|
5
|
-
import type { EditorView } from '@tiptap/pm/view';
|
|
6
|
-
|
|
7
|
-
import LinkEditPopover from 'reactjs-tiptap-editor-pro/extensions/Link/components/LinkEditPopover';
|
|
8
|
-
import type { GeneralOptions } from 'reactjs-tiptap-editor-pro/types';
|
|
9
|
-
|
|
10
|
-
export interface LinkOptions extends TiptapLinkOptions, GeneralOptions<LinkOptions> {}
|
|
11
|
-
|
|
12
|
-
export const Link = TiptapLink.extend<LinkOptions>({
|
|
13
|
-
inclusive: false,
|
|
14
|
-
parseHTML() {
|
|
15
|
-
return [
|
|
16
|
-
{
|
|
17
|
-
tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])',
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
},
|
|
21
|
-
renderHTML({ HTMLAttributes }) {
|
|
22
|
-
return [
|
|
23
|
-
'a',
|
|
24
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
25
|
-
class: 'link',
|
|
26
|
-
}),
|
|
27
|
-
0,
|
|
28
|
-
];
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
addOptions() {
|
|
32
|
-
return {
|
|
33
|
-
...this.parent?.(),
|
|
34
|
-
openOnClick: true,
|
|
35
|
-
button: ({ editor, t }) => {
|
|
36
|
-
return {
|
|
37
|
-
component: LinkEditPopover,
|
|
38
|
-
componentProps: {
|
|
39
|
-
editor,
|
|
40
|
-
action: (value) => {
|
|
41
|
-
const { link, text, openInNewTab } = value as any;
|
|
42
|
-
editor
|
|
43
|
-
.chain()
|
|
44
|
-
.extendMarkRange('link')
|
|
45
|
-
.insertContent({
|
|
46
|
-
type: 'text',
|
|
47
|
-
text,
|
|
48
|
-
marks: [
|
|
49
|
-
{
|
|
50
|
-
type: 'link',
|
|
51
|
-
attrs: {
|
|
52
|
-
href: link,
|
|
53
|
-
target: openInNewTab ? '_blank' : '',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
})
|
|
58
|
-
.setLink({ href: link })
|
|
59
|
-
.focus()
|
|
60
|
-
.run();
|
|
61
|
-
},
|
|
62
|
-
id: 'linkk',
|
|
63
|
-
isActive: () => editor.isActive('link') || false,
|
|
64
|
-
disabled: !editor.can().setLink({ href: '' }),
|
|
65
|
-
icon: 'Link',
|
|
66
|
-
tooltip: t('editor.link.tooltip'),
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
addProseMirrorPlugins() {
|
|
74
|
-
return [
|
|
75
|
-
new Plugin({
|
|
76
|
-
props: {
|
|
77
|
-
handleClick: (view: EditorView, pos: number) => {
|
|
78
|
-
const { schema, doc, tr } = view.state;
|
|
79
|
-
const range = getMarkRange(doc.resolve(pos), schema.marks.link);
|
|
80
|
-
if (!range) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
const $start = doc.resolve(range.from);
|
|
84
|
-
const $end = doc.resolve(range.to);
|
|
85
|
-
const transaction = tr.setSelection(new TextSelection($start, $end));
|
|
86
|
-
view.dispatch(transaction);
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
];
|
|
91
|
-
},
|
|
92
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unsafe-optional-chaining */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
|
-
import React, { useEffect, useState } from 'react';
|
|
5
|
-
|
|
6
|
-
import { Button, IconComponent, Input, Label, Switch } from 'reactjs-tiptap-editor-pro/components';
|
|
7
|
-
import { useLocale } from 'reactjs-tiptap-editor-pro/locales';
|
|
8
|
-
|
|
9
|
-
interface IPropsLinkEditBlock {
|
|
10
|
-
editor: any
|
|
11
|
-
onSetLink: (link: string, text?: string, openInNewTab?: boolean) => void
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function LinkEditBlock(props: IPropsLinkEditBlock) {
|
|
15
|
-
const { t } = useLocale();
|
|
16
|
-
|
|
17
|
-
const [form, setForm] = useState({
|
|
18
|
-
text: '',
|
|
19
|
-
link: '',
|
|
20
|
-
});
|
|
21
|
-
const [openInNewTab, setOpenInNewTab] = useState<boolean>(false);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (props?.editor) {
|
|
25
|
-
const { href: link, target } = props.editor?.getAttributes('link');
|
|
26
|
-
|
|
27
|
-
const { from, to } = props.editor.state.selection;
|
|
28
|
-
const text = props.editor.state.doc.textBetween(from, to, ' ');
|
|
29
|
-
setForm({
|
|
30
|
-
link,
|
|
31
|
-
text,
|
|
32
|
-
});
|
|
33
|
-
setOpenInNewTab(target === '_blank');
|
|
34
|
-
}
|
|
35
|
-
}, [props?.editor]);
|
|
36
|
-
|
|
37
|
-
function handleSubmit(event: any) {
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
event.stopPropagation();
|
|
40
|
-
props?.onSetLink(form.link, form.text, openInNewTab);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<div className="border-neutral-200 rounded-lg !border bg-white p-2 shadow-sm dark:border-neutral-800 dark:bg-black">
|
|
45
|
-
<form className="flex flex-col gap-2"
|
|
46
|
-
onSubmit={handleSubmit}
|
|
47
|
-
>
|
|
48
|
-
<Label className="mb-[6px]">
|
|
49
|
-
{t('editor.link.dialog.text')}
|
|
50
|
-
</Label>
|
|
51
|
-
|
|
52
|
-
<div className="mb-[10px] flex w-full max-w-sm items-center gap-1.5">
|
|
53
|
-
<div className="relative w-full max-w-sm items-center">
|
|
54
|
-
<Input
|
|
55
|
-
className="w-80"
|
|
56
|
-
onChange={e => setForm({ ...form, text: e.target.value })}
|
|
57
|
-
placeholder="Text"
|
|
58
|
-
required
|
|
59
|
-
type="text"
|
|
60
|
-
value={form.text}
|
|
61
|
-
/>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
<Label className="mb-[6px]">
|
|
66
|
-
{t('editor.link.dialog.link')}
|
|
67
|
-
</Label>
|
|
68
|
-
|
|
69
|
-
<div className="flex w-full max-w-sm items-center gap-1.5">
|
|
70
|
-
<div className="relative w-full max-w-sm items-center">
|
|
71
|
-
<Input
|
|
72
|
-
className="pl-10"
|
|
73
|
-
onChange={e => setForm({ ...form, link: e.target.value })}
|
|
74
|
-
required
|
|
75
|
-
type="url"
|
|
76
|
-
value={form.link}
|
|
77
|
-
/>
|
|
78
|
-
|
|
79
|
-
<span className="absolute inset-y-0 start-0 flex items-center justify-center px-2">
|
|
80
|
-
<IconComponent className="size-5 text-muted-foreground"
|
|
81
|
-
name="Link"
|
|
82
|
-
/>
|
|
83
|
-
</span>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
|
|
87
|
-
<div className="flex items-center space-x-2">
|
|
88
|
-
<Label>
|
|
89
|
-
{t('editor.link.dialog.openInNewTab')}
|
|
90
|
-
</Label>
|
|
91
|
-
|
|
92
|
-
<Switch
|
|
93
|
-
checked={openInNewTab}
|
|
94
|
-
onCheckedChange={(e) => {
|
|
95
|
-
setOpenInNewTab(e);
|
|
96
|
-
}}
|
|
97
|
-
/>
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
<Button className="mt-2 self-end"
|
|
101
|
-
type="submit"
|
|
102
|
-
>
|
|
103
|
-
{t('editor.link.dialog.button.apply')}
|
|
104
|
-
</Button>
|
|
105
|
-
</form>
|
|
106
|
-
</div>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export default LinkEditBlock;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { ActionButton, IconComponent, Popover, PopoverContent, PopoverTrigger } from 'reactjs-tiptap-editor-pro/components';
|
|
4
|
-
import LinkEditBlock from 'reactjs-tiptap-editor-pro/extensions/Link/components/LinkEditBlock';
|
|
5
|
-
import type { ButtonViewReturnComponentProps } from 'reactjs-tiptap-editor-pro/types';
|
|
6
|
-
|
|
7
|
-
interface IPropsLinkEditPopover {
|
|
8
|
-
editor: any
|
|
9
|
-
icon?: any
|
|
10
|
-
title?: string
|
|
11
|
-
tooltip?: string
|
|
12
|
-
disabled?: boolean
|
|
13
|
-
shortcutKeys?: string[]
|
|
14
|
-
isActive?: ButtonViewReturnComponentProps['isActive']
|
|
15
|
-
action?: ButtonViewReturnComponentProps['action']
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function LinkEditPopover(props: IPropsLinkEditPopover) {
|
|
19
|
-
const [open, setOpen] = useState(false);
|
|
20
|
-
|
|
21
|
-
function onSetLink(link: string, text?: string, openInNewTab?: boolean) {
|
|
22
|
-
if (props.action) {
|
|
23
|
-
props.action({ link, text, openInNewTab });
|
|
24
|
-
setOpen(false);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Popover modal open={open} onOpenChange={setOpen}>
|
|
30
|
-
<PopoverTrigger disabled={props?.disabled} asChild>
|
|
31
|
-
<ActionButton
|
|
32
|
-
tooltip={props?.tooltip}
|
|
33
|
-
isActive={props?.isActive}
|
|
34
|
-
disabled={props?.disabled}
|
|
35
|
-
>
|
|
36
|
-
<IconComponent name={props?.icon} />
|
|
37
|
-
</ActionButton>
|
|
38
|
-
</PopoverTrigger>
|
|
39
|
-
<PopoverContent hideWhenDetached className="w-full" align="start" side="bottom">
|
|
40
|
-
<LinkEditBlock editor={props.editor} onSetLink={onSetLink} />
|
|
41
|
-
</PopoverContent>
|
|
42
|
-
</Popover>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default LinkEditPopover;
|