feat: 🎸 polyfill exchange

vision exchange api
This commit is contained in:
弱冠 2020-04-15 10:15:30 +08:00
parent e49a02e37c
commit 286e7d8f45
2 changed files with 6 additions and 9 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 editor from './editor';
import { Selection, Node } from '@ali/lowcode-designer';
import { editor } 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);
}
};