import { TripdocsSdkContext } from '@src/Docs'; import { hashCode, intToRGB } from '@src/utils/hexColorUtils'; import { createRandomId } from '@src/utils/randomId'; import storage from '@src/utils/storage'; import { Avatar, Button, Image } from 'antd'; import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'; import { ELTYPE, getGlobalCommentRangeId } from '../config'; import { InlineSlateEditor, renderLeaf } from '../SideComment/inlineSlateEditor'; import { css, cx } from '@emotion/css'; import { insertSideComment } from '../SideComment/insertSideComment'; import { timeFormat } from '../SideComment/utils'; import { Transforms } from '@src/components/slate-packages/slate'; import { f } from '@src/resource/string'; const GlobalCommentEditor = (props: any) => { const { commentData, setCommentData, commentValue, setCommentValue, isMobile, setEditor, globalCommentEditor } = props; const { editor, docId, userInfo } = useContext(TripdocsSdkContext); const displayName = userInfo?.displayName || userInfo?.userName || 'UNKNOWN(佚名)'; const headPortrait = userInfo?.headPortrait; useEffect(() => { editor && console.log('commentValue :>> ', editor.selection, window?.tripdocs.editorsMap, commentValue); }, [commentValue]); const [inlineEditorValue, setInlineEditorValue] = useState([ { type: ELTYPE.PARAGRAPH, children: [{ text: '' }], }, ]); const commentValueLength = commentValue?.replace(/[\!\@]\[\[(.*?)\]\]/g, '').length; return ( <>