fix: plugin-designer

This commit is contained in:
kangwei 2020-04-15 16:17:26 +08:00
commit c0c8760936
2 changed files with 5 additions and 8 deletions

View File

@ -157,7 +157,7 @@ export class Selection {
return nodes;
}
onSelectionChange(fn: (ids: string[]) => void): () => void {
onSelectionChange(fn: () => void): () => void {
this.emitter.on('selectionchange', fn);
return () => {
this.emitter.removeListener('selectionchange', fn);

View File

@ -1,23 +1,20 @@
import { Selection, DocumentModel, Node } from '@ali/lowcode-designer';
import { Selection, Node } from '@ali/lowcode-designer';
import { editor, designer } from './editor';
let currentSelection: Selection;
// let currentDocument: DocumentModel;
// get selection async
editor.once('designer.ready', () => {
const getSelection = () => {
if (editor.designer.currentSelection) {
currentSelection = editor.designer.currentSelection;
// currentDocument = editor.designer.currentDocument;
currentSelection.onSelectionChange((ids: string[]) => {
// console.log(ids);
// const nodes = ids.map((id: string) => currentDocument.getNode(id));
currentSelection.onSelectionChange(() => {
// const nodes = currentSelection.getNodes();
// console.log(nodes);
});
} else {
console.log('waiting ...');
// console.log('waiting ...');
requestAnimationFrame(getSelection);
}
};