mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
feat: ve事件埋点
This commit is contained in:
parent
078bad27ee
commit
700e5b06dd
@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { autorun, Reaction, untracked } from '@ali/lowcode-editor-core';
|
||||
import { autorun, Reaction, untracked, globalContext, Editor } from '@ali/lowcode-editor-core';
|
||||
import { NodeSchema } from '@ali/lowcode-types';
|
||||
|
||||
// TODO: cache to localStorage
|
||||
@ -114,6 +114,11 @@ export class History {
|
||||
}
|
||||
const cursor = this.session.cursor - 1;
|
||||
this.go(cursor);
|
||||
const editor = globalContext.get(Editor);
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
editor.emit('history.back', cursor);
|
||||
}
|
||||
|
||||
forward() {
|
||||
@ -122,6 +127,11 @@ export class History {
|
||||
}
|
||||
const cursor = this.session.cursor + 1;
|
||||
this.go(cursor);
|
||||
const editor = globalContext.get(Editor);
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
editor.emit('history.forward', cursor);
|
||||
}
|
||||
|
||||
savePoint() {
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
import { globalContext } from './di';
|
||||
import { Editor } from './editor';
|
||||
|
||||
interface KeyMap {
|
||||
[key: number]: string;
|
||||
}
|
||||
@ -329,6 +332,16 @@ function fireCallback(callback: HotkeyCallback, e: KeyboardEvent, combo?: string
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
const editor = globalContext.get(Editor);
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
editor.emit('hotkey.callback.call', {
|
||||
callback,
|
||||
e,
|
||||
combo,
|
||||
sequence,
|
||||
});
|
||||
}
|
||||
|
||||
export class Hotkey {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import logger from '@ali/vu-logger';
|
||||
import { EventEmitter } from 'events';
|
||||
import { editor } from './editor';
|
||||
|
||||
/**
|
||||
* Bus class as an EventEmitter
|
||||
@ -19,7 +20,6 @@ export class Bus {
|
||||
// alias to unsub
|
||||
off(event: string, func: (...args: any[]) => any) {
|
||||
this.unsub(event, func);
|
||||
|
||||
}
|
||||
|
||||
// alias to pub
|
||||
@ -62,4 +62,18 @@ export class Bus {
|
||||
}
|
||||
}
|
||||
|
||||
export default new Bus();
|
||||
const bus = new Bus();
|
||||
|
||||
editor.on('hotkey.callback.call', (data) => {
|
||||
bus.emit('ve.hotkey.callback.call', data);
|
||||
});
|
||||
|
||||
editor.on('history.back', (data) => {
|
||||
bus.emit('ve.history.back', data);
|
||||
});
|
||||
|
||||
editor.on('history.forward', (data) => {
|
||||
bus.emit('ve.history.forward', data);
|
||||
});
|
||||
|
||||
export default bus;
|
||||
|
||||
@ -2,6 +2,7 @@ import { skeleton, editor } from './editor';
|
||||
import { ReactElement } from 'react';
|
||||
import { IWidgetBaseConfig, Skeleton } from '@ali/lowcode-editor-skeleton';
|
||||
import { uniqueId } from '@ali/lowcode-utils';
|
||||
import bus from './bus';
|
||||
|
||||
export interface IContentItemConfig {
|
||||
title: string;
|
||||
@ -175,6 +176,7 @@ const dockPane = Object.assign(skeleton.leftArea, {
|
||||
console.warn(`Could not find pane with name ${name}`);
|
||||
}
|
||||
pane?.active();
|
||||
bus.emit('ve.dock_pane.active_doc', pane);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user