fix(editor): remove rootRect and modify layout

This commit is contained in:
austaras
2022-07-26 17:28:19 +08:00
parent 8b5e47ed73
commit b9f46028a8
21 changed files with 138 additions and 200 deletions
@@ -4,7 +4,7 @@ import {
PluginHooks,
Virgo,
} from '@toeverything/components/editor-core';
import { domToRect, Point } from '@toeverything/utils';
import { Point } from '@toeverything/utils';
import { GroupDirection } from '@toeverything/framework/virgo';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { DragItem } from './DragItem';
@@ -46,7 +46,7 @@ export const GroupMenu = function ({ editor, hooks }: GroupMenuProps) {
setShowMenu(false);
}
},
[setShowMenu]
[]
);
const handleRootDragOver = useCallback(
@@ -128,8 +128,8 @@ export const GroupMenu = function ({ editor, hooks }: GroupMenuProps) {
if (editor.container) {
setPosition(
new Point(
groupBlock.dom.offsetLeft - editor.container.offsetLeft,
groupBlock.dom.offsetTop - editor.container.offsetTop
groupBlock.dom.offsetLeft,
groupBlock.dom.offsetTop
)
);
}
@@ -22,9 +22,9 @@ export const Line = function ({ direction, editor, groupBlock }: LineProps) {
if (groupBlock && groupBlock.dom && editor.container) {
setRect(
Rect.fromLWTH(
groupBlock.dom.offsetLeft - editor.container.offsetLeft,
groupBlock.dom.offsetLeft,
groupBlock.dom.offsetWidth,
groupBlock.dom.offsetTop - editor.container.offsetTop,
groupBlock.dom.offsetTop,
groupBlock.dom.offsetHeight
)
);
@@ -13,7 +13,7 @@ export class GroupMenuPlugin extends BasePlugin {
return PLUGIN_NAME;
}
protected override on_render(): void {
protected override _onRender(): void {
if (this.editor.isWhiteboard) return;
this.root = new PluginRenderRoot({
name: PLUGIN_NAME,