fix: mark-range restore location error
This commit is contained in:
parent
f34d86eb01
commit
679bb4116f
|
@ -59,7 +59,7 @@ const Comment: React.FC<CommentProps> = forwardRef<CommentRef, CommentProps>(
|
|||
const loading = useSelector((state) => state.loading['comment/fetch']);
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
const list: Array<DataItem> = [];
|
||||
const tempList: Array<DataItem> = [];
|
||||
dataSource.forEach((item: DataSourceItem) => {
|
||||
//获取评论编号对应在编辑器中的所有节点
|
||||
const elements: Array<NodeInterface> =
|
||||
|
@ -74,14 +74,14 @@ const Comment: React.FC<CommentProps> = forwardRef<CommentRef, CommentProps>(
|
|||
//获取目标评论在编辑器中的 top
|
||||
const top = getRectTop(elements[0]);
|
||||
if (top < 0) return;
|
||||
list.push({
|
||||
tempList.push({
|
||||
...item,
|
||||
top,
|
||||
type: 'view',
|
||||
type: list.find((c) => c.id === item.id)?.type || 'view',
|
||||
});
|
||||
});
|
||||
//根据top大小排序,越小排在越前面
|
||||
updateList(list.sort((a, b) => (a.top < b.top ? -1 : 1)));
|
||||
updateList(tempList.sort((a, b) => (a.top < b.top ? -1 : 1)));
|
||||
}, [loading, dataSource]);
|
||||
|
||||
const remove = (render_id: string, id: number) => {
|
||||
|
|
|
@ -18,12 +18,9 @@ export type CommentItemProps = Omit<
|
|||
onOk: (event: React.MouseEvent) => void;
|
||||
onEdit: (itme: DataItem, info_id: number) => void;
|
||||
onRemove: (id: string, info_id: number) => void;
|
||||
} & { ref: React.Ref<HTMLDivElement> };
|
||||
};
|
||||
|
||||
const CommentItem: React.FC<CommentItemProps> = forwardRef<
|
||||
HTMLDivElement,
|
||||
CommentItemProps
|
||||
>(
|
||||
const CommentItem = forwardRef<HTMLDivElement, CommentItemProps>(
|
||||
(
|
||||
{
|
||||
item,
|
||||
|
|
|
@ -701,7 +701,7 @@ export default class<T extends MarkRangeOptions> extends MarkPlugin<T> {
|
|||
.shrinkToElementNode()
|
||||
.shrinkToTextNode()
|
||||
.toPath(undefined, container);
|
||||
paths.push({
|
||||
paths.unshift({
|
||||
id: id.split(','),
|
||||
path: rangePath
|
||||
? [rangePath.start.path, rangePath.end.path]
|
||||
|
|
Loading…
Reference in New Issue