tiptap: use clone

This commit is contained in:
fantasticit 2022-05-01 13:27:19 +08:00
parent ca41b31eea
commit 9f5b3f4054
3 changed files with 11 additions and 2 deletions

View File

@ -56,6 +56,7 @@
"@tiptap/suggestion": "^2.0.0-beta.90", "@tiptap/suggestion": "^2.0.0-beta.90",
"axios": "^0.25.0", "axios": "^0.25.0",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"clone": "^2.1.2",
"deep-equal": "^2.0.5", "deep-equal": "^2.0.5",
"dompurify": "^2.3.5", "dompurify": "^2.3.5",
"interactjs": "^1.10.11", "interactjs": "^1.10.11",

View File

@ -1,5 +1,6 @@
import { NodeViewWrapper } from '@tiptap/react'; import { NodeViewWrapper } from '@tiptap/react';
import cls from 'classnames'; import cls from 'classnames';
import clone from 'clone';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Spin, Typography } from '@douyinfe/semi-ui'; import { Spin, Typography } from '@douyinfe/semi-ui';
import { Resizeable } from 'components/resizeable'; import { Resizeable } from 'components/resizeable';
@ -83,13 +84,13 @@ export const MindWrapper = ({ editor, node, updateAttributes }) => {
mind = new window.MindElixir({ mind = new window.MindElixir({
el: `#${containerId.current}`, el: `#${containerId.current}`,
direction: window.MindElixir.SIDE, direction: window.MindElixir.SIDE,
data: JSON.parse(JSON.stringify(data)), data: clone(data),
editable: editor.isEditable, editable: editor.isEditable,
contextMenu: editor.isEditable, contextMenu: editor.isEditable,
keypress: editor.isEditable, keypress: editor.isEditable,
nodeMenu: editor.isEditable, nodeMenu: editor.isEditable,
toolBar: true, toolBar: true,
draggable: false, // 需要修复 draggable: false, // TODO: 需要修复
locale: 'zh_CN', locale: 'zh_CN',
}); });
mind.shouldPreventDefault = () => editor.isActive('mind'); mind.shouldPreventDefault = () => editor.isActive('mind');

View File

@ -86,6 +86,7 @@ importers:
'@types/react': 17.0.38 '@types/react': 17.0.38
axios: ^0.25.0 axios: ^0.25.0
classnames: ^2.3.1 classnames: ^2.3.1
clone: ^2.1.2
deep-equal: ^2.0.5 deep-equal: ^2.0.5
dompurify: ^2.3.5 dompurify: ^2.3.5
interactjs: ^1.10.11 interactjs: ^1.10.11
@ -169,6 +170,7 @@ importers:
'@tiptap/suggestion': 2.0.0-beta.90_@tiptap+core@2.0.0-beta.171 '@tiptap/suggestion': 2.0.0-beta.90_@tiptap+core@2.0.0-beta.171
axios: 0.25.0 axios: 0.25.0
classnames: 2.3.1 classnames: 2.3.1
clone: 2.1.2
deep-equal: 2.0.5 deep-equal: 2.0.5
dompurify: 2.3.5 dompurify: 2.3.5
interactjs: 1.10.11 interactjs: 1.10.11
@ -3021,6 +3023,11 @@ packages:
engines: {node: '>=0.8'} engines: {node: '>=0.8'}
dev: true dev: true
/clone/2.1.2:
resolution: {integrity: sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=}
engines: {node: '>=0.8'}
dev: false
/clsx/1.1.1: /clsx/1.1.1:
resolution: {integrity: sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==} resolution: {integrity: sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==}
engines: {node: '>=6'} engines: {node: '>=6'}