pxt-core
Version:
Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors
39 lines (38 loc) • 2.11 kB
TypeScript
/// <reference path="../pxtlib.d.ts" />
import * as Blockly from "blockly";
export interface BlockSnippet {
target: string;
versions: pxt.TargetVersions;
xml: string[];
extensions?: string[];
}
export interface DomToWorkspaceOptions {
applyHideMetaComment?: boolean;
keepMetaComments?: boolean;
}
export interface PostWorkspaceLoad {
afterWorkspaceLoad?: () => void;
}
/**
* Converts a DOM into workspace without triggering any Blockly event. Returns the new block ids
* @param dom
* @param workspace
*/
export declare function domToWorkspaceNoEvents(dom: Element, workspace: Blockly.Workspace, opts?: DomToWorkspaceOptions): string[];
export declare function clearWithoutEvents(workspace: Blockly.Workspace): void;
export declare function saveWorkspaceXml(ws: Blockly.Workspace, keepIds?: boolean): string;
export declare function workspaceToDom(workspace: Blockly.Workspace, keepIds?: boolean): Element;
export declare function saveBlocksXml(ws: Blockly.Workspace, keepIds?: boolean): string[];
export declare function getDirectChildren(parent: Element, tag: string): Element[];
export declare function getBlocksWithType(parent: Document | Element, type: string): Element[];
export declare function getChildrenWithAttr(parent: Document | Element, tag: string, attr: string, value: string): Element[];
export declare function getFirstChildWithAttr(parent: Document | Element, tag: string, attr: string, value: string): Element;
export declare function loadBlocksXml(ws: Blockly.WorkspaceSvg, text: string): void;
/**
* Loads the xml into a off-screen workspace (not suitable for size computations)
*/
export declare function loadWorkspaceXml(xml: string, skipReport?: boolean, opts?: DomToWorkspaceOptions): Blockly.Workspace;
export declare function importXml(pkgTargetVersion: string, xml: string, info: pxtc.BlocksInfo, skipReport?: boolean): string;
export declare function patchCommentIds(xml: Element): void;
export declare function patchShadows(root: Element, inShadow: boolean): void;
export declare function validateAllReferencedBlocksExist(xml: string): boolean;