diff --git a/localtypings/pxteditor.d.ts b/localtypings/pxteditor.d.ts index 59845ba17139..77b5595b934f 100644 --- a/localtypings/pxteditor.d.ts +++ b/localtypings/pxteditor.d.ts @@ -66,6 +66,7 @@ declare namespace pxt.editor { | "renderxml" | "renderbyblockid" | "setscale" + | "updatefilters" | "startactivity" | "saveproject" | "compile" @@ -1028,6 +1029,7 @@ declare namespace pxt.editor { handleExtensionRequest(request: pxt.editor.ExtensionRequest): void; fireResize(): void; + updateFilters(filters?: pxt.editor.ProjectFilters): void; updateEditorLogo(left: number, rgba?: string): number; loadBlocklyAsync(): Promise; diff --git a/pxteditor/editorcontroller.ts b/pxteditor/editorcontroller.ts index fb5f9d7c4346..55524047f6a6 100644 --- a/pxteditor/editorcontroller.ts +++ b/pxteditor/editorcontroller.ts @@ -95,6 +95,15 @@ export function bindEditorMessages(getEditorAsync: () => Promise) return Promise.resolve() .then(() => projectView.editor.setScale(zoommsg.scale)); } + case "updatefilters": return Promise.resolve() + .then(() => { + // Restored from LBOS-1046 (lost in the v12 upstream merge). + // p2-studio CodingCanvas sends { type: 'pxteditor', action: 'updatefilters', + // filters: {...} } when active bits change, so the toolbox can be restricted + // to blocks/namespaces appropriate for the connected codeBit / BLE bit. + const filters = (data as any).filters as pxt.editor.ProjectFilters; + projectView.updateFilters(filters); + }); case "stopsimulator": { const stop = data as pxt.editor.EditorMessageStopRequest; return Promise.resolve()