mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
parent
d480a03369
commit
d8d9184f3f
@ -83,14 +83,13 @@ const appendComponent = ({ text, type, data = {} }: ComponentItem): void => {
|
||||
|
||||
const dragstartHandler = ({ text, type, data = {} }: ComponentItem, e: DragEvent) => {
|
||||
if (e.dataTransfer) {
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
e.dataTransfer.setData(
|
||||
'data',
|
||||
'text/html',
|
||||
serialize({
|
||||
name: text,
|
||||
type,
|
||||
...data,
|
||||
}).replace(/"(\w+)":\s/g, '$1: '),
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -121,6 +120,6 @@ const dragHandler = (e: DragEvent) => {
|
||||
|
||||
if (timeout || !stage.value) return;
|
||||
|
||||
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
||||
timeout = stage.value.delayedMarkContainer(e);
|
||||
};
|
||||
</script>
|
||||
|
@ -146,9 +146,8 @@ const contextmenuHandler = (e: MouseEvent) => {
|
||||
|
||||
const dragoverHandler = (e: DragEvent) => {
|
||||
e.preventDefault();
|
||||
if (e.dataTransfer) {
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
}
|
||||
if (!e.dataTransfer) return;
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
};
|
||||
|
||||
const dropHandler = async (e: DragEvent) => {
|
||||
@ -164,7 +163,15 @@ const dropHandler = async (e: DragEvent) => {
|
||||
|
||||
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
||||
const parseDSL = getConfig('parseDSL');
|
||||
const config = parseDSL(`(${e.dataTransfer.getData('data')})`);
|
||||
|
||||
const data = e.dataTransfer.getData('text/html');
|
||||
|
||||
if (!data) return;
|
||||
|
||||
const config = parseDSL(`(${data})`);
|
||||
|
||||
if (!config) return;
|
||||
|
||||
const layout = await services?.editorService.getLayout(parent);
|
||||
|
||||
const containerRect = stageContainer.value.getBoundingClientRect();
|
||||
|
Loading…
x
Reference in New Issue
Block a user