From 286e7d8f458bdee504f85dcf96aef2b19cbefb75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B1=E5=86=A0?= Date: Wed, 15 Apr 2020 10:15:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20polyfill=20exchange?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vision exchange api --- packages/designer/src/document/selection.ts | 2 +- packages/vision-polyfill/src/exchange.ts | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/designer/src/document/selection.ts b/packages/designer/src/document/selection.ts index 2e1dc1e96..caa4e4cef 100644 --- a/packages/designer/src/document/selection.ts +++ b/packages/designer/src/document/selection.ts @@ -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); diff --git a/packages/vision-polyfill/src/exchange.ts b/packages/vision-polyfill/src/exchange.ts index 812bf38a6..33789d69a 100644 --- a/packages/vision-polyfill/src/exchange.ts +++ b/packages/vision-polyfill/src/exchange.ts @@ -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); } };